检验信用;

This commit is contained in:
王奎兴
2026-06-17 15:38:19 +08:00
parent 23dc97f1d0
commit 93a6f7228c
11 changed files with 829 additions and 9 deletions
@@ -26,6 +26,8 @@ import com.mhd.common.core.service.jPush.AsyncJPushApplicationService;
import com.mhd.common.core.utils.StringUtils;
import com.mhd.system.api.FinanceServiceFeign;
import com.mhd.system.api.WlhyServiceFeign;
import com.mhd.system.api.domain.UserShipperEntityFeign;
import com.mhd.system.api.domain.UserShipperFeignDTO;
import com.mhd.system.api.event.object.ShipperNameChangedEvent;
import com.mhd.system.api.service.webSocket.AsyncWebSocketApplicationService;
import com.mhd.user.domain.businessPartnerPushLog.entity.BusinessPartnerPushLog;
@@ -1676,4 +1678,140 @@ public class UserShipperApplicationService {
return AjaxResult.error("批量查询赊销额度失败:" + e.getMessage());
}
}
public AjaxResult querySaleCreditLimitFeign(UserShipperFeignDTO userShipperDTO) {
List<UserShipperEntityFeign> customerNcCodeList = userShipperDTO.getCustomerNcCodeList();
if (CollUtil.isEmpty(customerNcCodeList)) {
return AjaxResult.error("客户编码列表不能为空");
}
try {
// 第一步:调用UAP登录接口获取token(批量共用一个token)
String loginUrl = "http://10.0.0.212/uapws/rest/user/login";
com.alibaba.fastjson.JSONObject loginParam = new com.alibaba.fastjson.JSONObject();
loginParam.put("usercode", "MDM");
loginParam.put("pwd", "MDM1234!@#$");
log.info("调用UAP登录接口,请求参数:{}", loginParam.toJSONString());
String loginResult = HttpRequest.post(loginUrl)
.header("Content-Type", "application/json")
.body(loginParam.toJSONString())
.execute()
.body();
log.info("UAP登录接口返回:{}", loginResult);
if (StringUtils.isEmpty(loginResult)) {
return AjaxResult.error("UAP登录接口返回为空");
}
com.alibaba.fastjson.JSONObject loginJson = com.alibaba.fastjson.JSONObject.parseObject(loginResult);
String uapToken = loginJson.getString("uap_token");
String uapUsercode = loginJson.getString("uap_usercode");
String uapDataSource = loginJson.getString("uap_dataSource");
if (StringUtils.isEmpty(uapToken)) {
return AjaxResult.error("UAP登录失败,未获取到token");
}
// 第二步:遍历每个customerNcCode,逐个查询赊销额度
String queryUrl = "http://10.0.0.212/uapws/rest/api/salecredit/querysalecreditlimit";
com.alibaba.fastjson.JSONObject allResults = new com.alibaba.fastjson.JSONObject();
for (UserShipperEntityFeign userShipperEntity : customerNcCodeList) {
if (StringUtils.isEmpty(userShipperEntity.getCustomerNcCode())) {
continue;
}
UserShipperEntity userShipperEntity1 = userShipperMapper.selectOne(new LambdaQueryWrapper<UserShipperEntity>()
.eq(UserShipperEntity::getCustomerNcCode, userShipperEntity.getCustomerNcCode())
.eq(UserShipperEntity::getUserId, userShipperEntity.getUserId()));
String orgcode = userShipperMapper.getOrgNcCode(userShipperEntity1.getOrganizationId());
if (StringUtils.isEmpty(orgcode)) {
return AjaxResult.error("组织NC编码不能为空");
}
try {
com.alibaba.fastjson.JSONObject queryParam = new com.alibaba.fastjson.JSONObject();
queryParam.put("custcode", userShipperEntity.getCustomerNcCode());
queryParam.put("orgcode", orgcode);
log.info("调用赊销额度查询接口,custcode={}orgcode={}", userShipperEntity.getCustomerNcCode(), orgcode);
String queryResult = HttpRequest.post(queryUrl)
.header("Content-Type", "application/json")
.header("uap_token", uapToken)
.header("uap_usercode", uapUsercode)
.header("uap_dataSource", uapDataSource)
.header("token", "94B3992EAD9747D3598CC6F7775F6239B5DC3B526DF7DE0091CB8B2D")
.body(queryParam.toJSONString())
.execute()
.body();
log.info("赊销额度查询接口返回,custcode={}result={}", userShipperEntity.getCustomerNcCode(), queryResult);
if (StringUtils.isNotEmpty(queryResult)) {
com.alibaba.fastjson.JSONObject resultJson = com.alibaba.fastjson.JSONObject.parseObject(queryResult);
allResults.put(userShipperEntity.getCustomerNcCode(), resultJson);
// 第三步:查询成功,更新货主的额度同步时间(limitTime)
if (userShipperEntity1 != null) {
// 根据查询结果同步数据
com.alibaba.fastjson.JSONObject dataJson = resultJson.getJSONObject("data");
if (dataJson != null) {
// 同步额度数据(limitdatas
com.alibaba.fastjson.JSONArray limitdatas = dataJson.getJSONArray("limitdatas");
if (limitdatas != null && !limitdatas.isEmpty()) {
com.alibaba.fastjson.JSONObject limitData = limitdatas.getJSONObject(0);
userShipperEntity1.setLimitTime(new Date());
userShipperEntity1.setAuthorizedQuota(limitData.getBigDecimal("nlimitmny"));
userShipperEntity1.setAuthorizedUsedAmount(limitData.getBigDecimal("nengrossmny"));
userShipperEntity1.setSettlementCurrency(limitData.getString("currencycode"));
userShipperEntity1.setCreditAmount(limitData.getBigDecimal("nbalancemny"));
userShipperMapper.updateById(userShipperEntity1);
log.info("更新货主额度同步成功,custcode={}shipperId={}", userShipperEntity1.getCustomerNcCode(), userShipperEntity1.getShipperId());
} else {
log.info("赊销额度查询无limitdatas返回,跳过额度更新,custcode={}", userShipperEntity1.getCustomerNcCode());
}
// 同步协议明细(agreedaydatas),与limitdatas独立
com.alibaba.fastjson.JSONArray agreedaydatas = dataJson.getJSONArray("agreedaydatas");
if (agreedaydatas != null && !agreedaydatas.isEmpty()) {
// 先删除该货主已有的协议明细,避免重复
agreementDetailsMapper.delete(new LambdaQueryWrapper<AgreementDetails>()
.eq(AgreementDetails::getShipperId, userShipperEntity1.getShipperId()));
int i;
for (i = 0; i < agreedaydatas.size(); i++) {
com.alibaba.fastjson.JSONObject agreeItem = agreedaydatas.getJSONObject(i);
AgreementDetails agreementDetails = new AgreementDetails();
agreementDetails.setShipperId(userShipperEntity1.getShipperId());
agreementDetails.setOrgcode(agreeItem.getString("orgcode"));
agreementDetails.setCode(agreeItem.getString("code"));
agreementDetails.setPday(agreeItem.getString("pday"));
agreementDetails.setPname(agreeItem.getString("pname"));
agreementDetails.setPtypename(agreeItem.getString("ptypename"));
agreementDetails.setPcode(agreeItem.getString("pcode"));
agreementDetails.setPtype(agreeItem.getString("ptype"));
agreementDetailsMapper.insert(agreementDetails);
}
userShipperEntity1.setAgreementCount(i);
userShipperMapper.updateById(userShipperEntity1);
log.info("同步协议明细成功,custcode={}shipperId={},共{}条", userShipperEntity1.getCustomerNcCode(), userShipperEntity1.getShipperId(), agreedaydatas.size());
} else {
log.info("赊销额度查询无agreedaydatas返回,跳过协议明细同步,custcode={}", userShipperEntity1.getCustomerNcCode());
}
} else {
log.info("赊销额度查询无data返回,跳过更新,custcode={}", userShipperEntity1.getCustomerNcCode());
}
} else {
log.warn("未找到对应货主,custcode={}organizationId={}", userShipperEntity1.getCustomerNcCode(), userShipperDTO.getOrganizationId());
}
} else {
log.warn("赊销额度查询返回为空,custcode={}", userShipperEntity1.getCustomerNcCode());
}
} catch (Exception e) {
log.error("查询赊销额度异常,custcode={}", userShipperEntity1.getCustomerNcCode(), e);
}
}
return AjaxResult.success(allResults);
} catch (Exception e) {
log.error("批量查询赊销额度异常", e);
return AjaxResult.error("批量查询赊销额度失败:" + e.getMessage());
}
}
}
@@ -5,6 +5,7 @@ import com.mhd.common.core.domain.entity.R;
import com.mhd.common.core.utils.bean.BeanUtils;
import com.mhd.common.log.annotation.Log;
import com.mhd.common.log.enums.BusinessType;
import com.mhd.system.api.domain.UserShipperFeignDTO;
import com.mhd.user.application.service.UserApplicationService;
import com.mhd.user.application.service.UserShipperApplicationService;
import com.mhd.user.domain.userAggregate.repository.todo.*;
@@ -99,6 +100,17 @@ public class UserShipperAPI extends BaseController {
return userShipperApplicationService.querySaleCreditLimit(userShipperDTO);
}
/**
* 查询赊销额度
* @param userShipperDTO 包含 customerNcCode(客户编码)和 orgcode(组织编码)
* @return 赊销额度查询结果
*/
@ApiOperation("查询赊销额度")
@PostMapping("/querySaleCreditLimitFeign")
public AjaxResult querySaleCreditLimitFeign(@RequestBody UserShipperFeignDTO userShipperDTO) {
return userShipperApplicationService.querySaleCreditLimitFeign(userShipperDTO);
}
@Log(title = "托运人管理-查询", description ="查询托运人列表",businessType = BusinessType.INQUIRE)
@ApiOperation("查询托运人列表")
@@ -330,4 +342,4 @@ public class UserShipperAPI extends BaseController {
}
return AjaxResult.success(resultMap);
}
}
}