refactor(sales): 优化无源仓库收货单转换逻辑- 修复赠品判断逻辑,使用 setScale 方法保留两位小数
- 添加过滤逻辑,去除没有交易成功的无源件明细行- 更新 U8C 接口调用方式,使用 List<Map> 结构传递参数 - 优化 header 信息获取逻辑,提高代码可读性 - 移除不必要的注释和冗余代码,提升代码质量
This commit is contained in:
parent
7b9083b699
commit
a31bcda6c9
|
@ -785,7 +785,7 @@ public class PassiveWarehouseReceiptToC extends PluginBaseEntity {
|
|||
|
||||
//判断是否为赠品
|
||||
Boolean isblargessflag = false;
|
||||
if ("0".equals(passiveStorageSonDetailsDto.getGroupTotalPayAmount().stripTrailingZeros().toPlainString())) {
|
||||
if ("0".equals(passiveStorageSonDetailsDto.getGroupTotalPayAmount().setScale(2, BigDecimal.ROUND_HALF_UP).stripTrailingZeros().toPlainString())) {
|
||||
isblargessflag = true;
|
||||
}
|
||||
|
||||
|
@ -935,6 +935,8 @@ public class PassiveWarehouseReceiptToC extends PluginBaseEntity {
|
|||
// 查询基本档案
|
||||
String sceneType = "tran";
|
||||
List<PassiveStorageSonDetailsDto> passiveStorageSonDetailsDtos = queryBasicArchivesStock(passiveStorageResponseDataList, sceneType);
|
||||
filterAfterSalesOrder(passiveStorageResponseDataList);
|
||||
|
||||
// 分组汇总
|
||||
String dimension = null;
|
||||
Map<String, List<PassiveStorageSonDetailsDto>> stringListMap = groupSummary(passiveStorageSonDetailsDtos, dimension);
|
||||
|
@ -982,28 +984,28 @@ public class PassiveWarehouseReceiptToC extends PluginBaseEntity {
|
|||
//组装应收单表头
|
||||
ArapDjzbVO.Parentt parentVo = new ArapDjzbVO.Parentt();
|
||||
parentVo.setDjrq(generateBusinessDate);//单据日期
|
||||
parentVo.setDwbm(bdCorpEntity.getPkCorp());//公司
|
||||
parentVo.setLrr(OverallConstant.getOverAllValue("u8cApiZdrPK"));//录入人
|
||||
parentVo.setDwbm(bdCorpEntity.getUnitcode());//公司
|
||||
parentVo.setLrr(OverallConstant.getOverAllValue("u8cApiZdrCode"));//录入人
|
||||
parentVo.setWldx("0");//往来对象标识 固定为:客户
|
||||
parentVo.setDeptid(bdDeptdocEntity.getPkDeptdoc());//部门
|
||||
parentVo.setShr(OverallConstant.getOverAllValue("u8cApiZdrPK"));//审批人
|
||||
parentVo.setDeptid(bdDeptdocEntity.getDeptcode());//部门
|
||||
parentVo.setShr(OverallConstant.getOverAllValue("u8cApiZdrCode"));//审批人
|
||||
parentVo.setShrq(generateBusinessDate);//审核日期
|
||||
parentVo.setDjlxbm("D0");//单据类型编码
|
||||
parentVo.setXslxbm(bdBusitypeEntity.getPkBusitype());//业务流程
|
||||
parentVo.setXslxbm(bdBusitypeEntity.getBusicode());//业务流程
|
||||
parentVo.setFeinvstatus("0");//开票状态
|
||||
parentVo.setHbbm(bdCumandocEntity.getPkCumandoc());//客商主键
|
||||
parentVo.setHbbm(bdCubasdocEntity.getCustcode());//客商主键
|
||||
//店铺档案
|
||||
parentVo.setZyx1(shopArchives.getPkDefdoc());
|
||||
parentVo.setDef1(shopArchives.getDocname());
|
||||
parentVo.setZyx1(shopArchives.getDoccode());
|
||||
// parentVo.setDef1(shopArchives.getDocname());
|
||||
//来源平台
|
||||
parentVo.setZyx2(platformArchives.getPkDefdoc());
|
||||
parentVo.setDef2(platformArchives.getDocname());
|
||||
parentVo.setZyx2(platformArchives.getDoccode());
|
||||
// parentVo.setDef2(platformArchives.getDocname());
|
||||
//收发类别
|
||||
parentVo.setZyx3(bdRdclEntity.getPkRdcl());
|
||||
parentVo.setDef3(bdRdclEntity.getRdname());
|
||||
parentVo.setZyx3(bdRdclEntity.getRdcode());
|
||||
// parentVo.setDef3(bdRdclEntity.getRdname());
|
||||
//单据红字标识
|
||||
parentVo.setZyx16(OverallConstant.getOverAllValue("u8c自定义项档案-单据红字标识-Y主键"));
|
||||
parentVo.setDef16(OverallConstant.getOverAllValue("u8c自定义项档案-单据红字标识-Y名称"));
|
||||
parentVo.setZyx16("1");
|
||||
// parentVo.setDef16(OverallConstant.getOverAllValue("u8c自定义项档案-单据红字标识-Y名称"));
|
||||
// parentVo.setZyx19();//自定义项19 OFS单号不传,因为是汇总的
|
||||
|
||||
//验证是否为指定的店铺,如果为true,则取结存价
|
||||
|
@ -1033,7 +1035,7 @@ public class PassiveWarehouseReceiptToC extends PluginBaseEntity {
|
|||
List<ArapDjzbVO.Childrenn> pushScenarioType = new ArrayList<>();
|
||||
ArapDjzbVO.Childrenn arapDjzbVOChildrenn = new ArapDjzbVO.Childrenn();
|
||||
pushScenarioType.add(arapDjzbVOChildrenn);
|
||||
arapDjzbVOChildrenn.setCinventoryid(bdInvmandocEntity.getPkInvmandoc());//存货管理档案
|
||||
arapDjzbVOChildrenn.setCinventoryid(bdInvbasdocEntity.getInvcode());//存货管理档案
|
||||
arapDjzbVOChildrenn.setJfbbje("-" + passiveStorageSonDetailsDto.getGroupTotalPayAmount());//借方本币金额
|
||||
arapDjzbVOChildrenn.setJfybje("-" + passiveStorageSonDetailsDto.getGroupTotalPayAmount());//借方原币金额
|
||||
arapDjzbVOChildrenn.setJfbbsj("-" + noriginalcurmny.stripTrailingZeros().toPlainString());//借方本币税金
|
||||
|
@ -1092,12 +1094,16 @@ public class PassiveWarehouseReceiptToC extends PluginBaseEntity {
|
|||
}
|
||||
|
||||
//推送U8C
|
||||
List<ArapDjzbVO> arapDjzbVOList = new ArrayList<>();
|
||||
ArapDjzbVO arapDjzbVO = new ArapDjzbVO();
|
||||
arapDjzbVO.setParentvo(parentVo);
|
||||
arapDjzbVO.setChildren(pushScenarioType);
|
||||
String mapStr = "{\"djzbvo\":[" + JSONUtil.toJsonStr(arapDjzbVO) + "]}";
|
||||
arapDjzbVOList.add(arapDjzbVO);
|
||||
|
||||
ArapDjzb arapDjzb = sendU8cRedReceivable(JSON.toJSONString(mapStr));
|
||||
Map<String, List<ArapDjzbVO>> listMap = new HashMap<>();
|
||||
listMap.put("djzbvo", arapDjzbVOList);
|
||||
|
||||
ArapDjzb arapDjzb = sendU8cRedReceivable(JSON.toJSONString(listMap));
|
||||
String djbh = null;
|
||||
String dwbm = null;
|
||||
String vouchid = null;
|
||||
|
@ -1230,6 +1236,9 @@ public class PassiveWarehouseReceiptToC extends PluginBaseEntity {
|
|||
//查询OFS无源入库单对应的售后订单,并关联无源无源入库单对象
|
||||
List<RerturnGoodsOrderSearchData> rerturnGoodsOrderSearchData = queryBatchAfterSalesOrder(passiveStorageResponseDataList);
|
||||
findAfterSalesOrder(rerturnGoodsOrderSearchData, passiveStorageResponseDataList);
|
||||
//过滤掉售后订单没有交易成功的数据
|
||||
|
||||
|
||||
//查询OFS售后订单对应的OFS销售订单
|
||||
List<com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDetailsDto> headerDetailsDtos = queryBatchOfsOrder(passiveStorageResponseDataList);
|
||||
findOfsOrder(headerDetailsDtos, passiveStorageResponseDataList);
|
||||
|
@ -1682,7 +1691,7 @@ public class PassiveWarehouseReceiptToC extends PluginBaseEntity {
|
|||
|
||||
passiveStorageSonDetailsDto.setCalculateAccountsReceivable(totalAmount);
|
||||
passiveStorageSonDetailsDto.setCalculationFormula(calculationFormulaStr.toString());
|
||||
|
||||
//把无源入库单明细行关联对应的售后订单明细行的优惠金额,带入到无源入库单明细行
|
||||
passiveStorageSonDetailsDto.setPlatformDiscounts(ofsOrderDetail.getPlatformDiscounts());
|
||||
passiveStorageSonDetailsDto.setMerchantDiscounts(ofsOrderDetail.getMerchantDiscounts());
|
||||
passiveStorageSonDetailsDto.setExpertDiscounts(ofsOrderDetail.getExpertDiscounts());
|
||||
|
@ -1779,8 +1788,13 @@ public class PassiveWarehouseReceiptToC extends PluginBaseEntity {
|
|||
long startLong = System.currentTimeMillis();
|
||||
logger.info("TOC推送开始,推送参数:" + param + ",U8C_URL:" + OverallConstant.getOverAllValue("u8c_url"));
|
||||
String apiCode = "8000370069";
|
||||
String result = HttpRequest.post(OverallConstant.getOverAllValue("u8c_url")).header("appId", OverallConstant.getOverAllValue("appId"))//头信息,多个头信息多次调用此方法即可
|
||||
.header("usercode", OverallConstant.getOverAllValue("u8cApiUsercodePK")).header("password", OverallConstant.getOverAllValue("u8cApiPasswordPK")).header("system", OverallConstant.getOverAllValue("u8cApiSystemPK")).header("trantype", OverallConstant.getOverAllValue("u8cApiTrantypePK")).header("apiCode", apiCode)//头信息,多个头信息多次调用此方法即可
|
||||
String result = HttpRequest.post(OverallConstant.getOverAllValue("u8c_url"))
|
||||
.header("appId", OverallConstant.getOverAllValue("appId"))//头信息,多个头信息多次调用此方法即可
|
||||
.header("usercode", OverallConstant.getOverAllValue("u8cApiUsercodeCode"))
|
||||
.header("password", OverallConstant.getOverAllValue("u8cApiPasswordCode"))
|
||||
.header("system", OverallConstant.getOverAllValue("u8cApiSystemCode"))
|
||||
.header("trantype", OverallConstant.getOverAllValue("u8cApiTrantypeCode"))
|
||||
.header("apiCode", apiCode)//头信息,多个头信息多次调用此方法即可
|
||||
.header("publicKey", OverallConstant.getOverAllValue("publicKey"))//头信息,多个头信息多次调用此方法即可
|
||||
.header("secretKey", OverallConstant.getOverAllValue("secretKey"))//头信息,多个头信息多次调用此方法即可
|
||||
.body(param)//表单内容
|
||||
|
@ -3042,4 +3056,35 @@ public class PassiveWarehouseReceiptToC extends PluginBaseEntity {
|
|||
// }
|
||||
// return map;
|
||||
// }
|
||||
|
||||
/**
|
||||
* 过滤掉没有交易成功的无源件明细行
|
||||
*
|
||||
* @param passiveStorageResponseDataList O无源件交易成功状态
|
||||
* @throws Exception 跑出可能的异常
|
||||
*/
|
||||
private List<PassiveStorageResponse.Data> filterAfterSalesOrder(List<PassiveStorageResponse.Data> passiveStorageResponseDataList) throws Exception {
|
||||
List<PassiveStorageResponse.Data> filteredList = null;
|
||||
if (passiveStorageResponseDataList != null && passiveStorageResponseDataList.size() > 0) {
|
||||
filteredList = passiveStorageResponseDataList.stream().filter(stockinOrder -> {
|
||||
PassiveStorageResponse.Header header = stockinOrder.getHeader();
|
||||
if (header == null) {
|
||||
return false;
|
||||
}
|
||||
RerturnGoodsOrderSearchData returnData = header.getRerturnGoodsOrderSearchData();
|
||||
if (returnData == null) {
|
||||
return false;
|
||||
}
|
||||
RerturnGoodsOrderSearchHeader header1 = returnData.getHeader();
|
||||
if (header1 == null) {
|
||||
return false;
|
||||
}
|
||||
if (header1.getRefundedAt() == null) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
return filteredList;
|
||||
}
|
||||
}
|
|
@ -27,7 +27,10 @@ public class PassiveWarehouseReceiptToCTest {
|
|||
@Test
|
||||
public void startImplementStockByTime() {
|
||||
try {
|
||||
passiveWarehouseReceiptToC.startImplementStockByTime("2025-03-11 22:27:02", "2025-03-11 22:27:02");
|
||||
//测试O无源件入库
|
||||
// passiveWarehouseReceiptToC.startImplementStockByTime("2025-03-11 22:27:02", "2025-03-11 22:27:02");
|
||||
//测试O无源生成红字应收
|
||||
passiveWarehouseReceiptToC.startImplementByTradeTime("2025-03-11 22:27:02", "2025-03-11 22:27:02");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue