fix(buildpackage): 修复 TOC 红字应收单推送逻辑
- 在推送 U8C之前增加对 childrenns 列表的空检查 - 避免在没有有效数据时进行不必要的推送操作 - 优化代码结构,提高代码的可读性和性能
This commit is contained in:
parent
d35a0f12b4
commit
82f0c73c49
|
@ -1218,27 +1218,29 @@ public class PassiveWarehouseReceiptToC extends PluginBaseEntity {
|
|||
// groupShipQty = new BigDecimal("0");
|
||||
if ((filterJfbbjeIncludingTax(pushScenarioType)) && groupShipQty.compareTo(BigDecimal.ZERO) == 0) {
|
||||
List<ArapDjzbVO.Childrenn> childrenns = filterZeroJfbbje(pushScenarioType);
|
||||
// 推送U8C
|
||||
List<ArapDjzbVO> arapDjzbVOList = new ArrayList<>();
|
||||
ArapDjzbVO arapDjzbVO = new ArapDjzbVO();
|
||||
arapDjzbVO.setParentvo(parentVo);
|
||||
arapDjzbVO.setChildren(childrenns);
|
||||
arapDjzbVOList.add(arapDjzbVO);
|
||||
if (childrenns != null && childrenns.size() > 0) {
|
||||
// 推送U8C
|
||||
List<ArapDjzbVO> arapDjzbVOList = new ArrayList<>();
|
||||
ArapDjzbVO arapDjzbVO = new ArapDjzbVO();
|
||||
arapDjzbVO.setParentvo(parentVo);
|
||||
arapDjzbVO.setChildren(childrenns);
|
||||
arapDjzbVOList.add(arapDjzbVO);
|
||||
|
||||
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;
|
||||
if (arapDjzb != null && arapDjzb.getParentvo() != null) {
|
||||
djbh = arapDjzb.getParentvo().getDjbh();
|
||||
dwbm = arapDjzb.getParentvo().getDwbm();
|
||||
vouchid = arapDjzb.getParentvo().getVouchid();
|
||||
}
|
||||
logger.info("TOC红字应收单:{} 应收单主键:{} 销售公司:{}", djbh, vouchid, dwbm);
|
||||
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;
|
||||
if (arapDjzb != null && arapDjzb.getParentvo() != null) {
|
||||
djbh = arapDjzb.getParentvo().getDjbh();
|
||||
dwbm = arapDjzb.getParentvo().getDwbm();
|
||||
vouchid = arapDjzb.getParentvo().getVouchid();
|
||||
}
|
||||
logger.info("TOC红字应收单:{} 应收单主键:{} 销售公司:{}", djbh, vouchid, dwbm);
|
||||
// 记录同步状态
|
||||
updateSuccessOrFail3(value, "Y", "success", djbh, vouchid, value.get(0).getStorageTimeStamp());
|
||||
updateSuccessOrFail3(value, "Y", "success", djbh, vouchid, value.get(0).getStorageTimeStamp());
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("TOC红字应收单转换成U8C对象过程中、或者单据推送到U8C出现异常!", e);
|
||||
|
|
|
@ -344,6 +344,7 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity {
|
|||
});
|
||||
if (sceneType.equals("stock")) {
|
||||
getSetStock(returnGoodHeaderDetailsDataDtoList, "2");
|
||||
// getSetStock(returnGoodHeaderDetailsDataDtoList, "0");
|
||||
} else if (sceneType.equals("tran")) {
|
||||
getSetTran(returnGoodHeaderDetailsDataDtoList, "2");
|
||||
}
|
||||
|
@ -777,10 +778,11 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity {
|
|||
|
||||
//如果oldValue存在实入数量=0的明细行则过滤掉
|
||||
//2025年5月6日10:12:21 和丽知闫旭、妮姐沟通,如果oldValue存在实入数量=0的明细行则过滤掉
|
||||
filterReceivedQtyZero(oldValue);
|
||||
if (oldValue == null || oldValue.size() == 0) {
|
||||
continue;
|
||||
}
|
||||
//2025年8月24日14:03:45 和闫旭沟通,需要显示应收,优惠金额等,不咋此处过滤
|
||||
// filterReceivedQtyZero(oldValue);
|
||||
// if (oldValue == null || oldValue.size() == 0) {
|
||||
// continue;
|
||||
// }
|
||||
|
||||
StockinOrderSearchResponse.StockinOrder.StockinH header = oldValue.get(0).getHeader();
|
||||
BdCorpEntity bdCorpEntity = oldValue.get(0).getBdCorpEntity();//表头销售公司
|
||||
|
@ -995,32 +997,38 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity {
|
|||
// continue;
|
||||
// }
|
||||
|
||||
if (ProfilesActiveConstant.PUSH_SCENE_TYPE_1.equals(pushScenarioType) || ProfilesActiveConstant.PUSH_SCENE_TYPE_2.equals(pushScenarioType)) {
|
||||
//推送u8c生成红字销售订单
|
||||
List<SaleorderRequestDto> saleorderRequestDtoList = new ArrayList<>();
|
||||
saleorderRequestDtoList.add(saleorderRequestDto);
|
||||
Map<String, List<SaleorderRequestDto>> stringStringMap = new HashMap<>();
|
||||
stringStringMap.put("saleorder", saleorderRequestDtoList);
|
||||
SoSaleResultRootDto soSaleResultRootDto = sendU8CTOCOrder(JSON.toJSONString(stringStringMap));
|
||||
String vreceiptcode = null;
|
||||
String pk_corp = null;
|
||||
String csaleid = null;
|
||||
if (soSaleResultRootDto != null && soSaleResultRootDto.getParentvo() != null) {
|
||||
vreceiptcode = soSaleResultRootDto.getParentvo().getVreceiptcode();
|
||||
pk_corp = soSaleResultRootDto.getParentvo().getPk_corp();
|
||||
csaleid = soSaleResultRootDto.getParentvo().getCsaleid();
|
||||
//判断如果实入数量全部为0,则不推送u8c,部分存在0的则过滤掉
|
||||
checkSaleOrderNnumber(saleorderRequestChildrenDtoList);
|
||||
if (saleorderRequestChildrenDtoList.size() > 0) {
|
||||
if (ProfilesActiveConstant.PUSH_SCENE_TYPE_1.equals(pushScenarioType) || ProfilesActiveConstant.PUSH_SCENE_TYPE_2.equals(pushScenarioType)) {
|
||||
//推送u8c生成红字销售订单
|
||||
List<SaleorderRequestDto> saleorderRequestDtoList = new ArrayList<>();
|
||||
saleorderRequestDtoList.add(saleorderRequestDto);
|
||||
Map<String, List<SaleorderRequestDto>> stringStringMap = new HashMap<>();
|
||||
stringStringMap.put("saleorder", saleorderRequestDtoList);
|
||||
SoSaleResultRootDto soSaleResultRootDto = sendU8CTOCOrder(JSON.toJSONString(stringStringMap));
|
||||
String vreceiptcode = null;
|
||||
String pk_corp = null;
|
||||
String csaleid = null;
|
||||
if (soSaleResultRootDto != null && soSaleResultRootDto.getParentvo() != null) {
|
||||
vreceiptcode = soSaleResultRootDto.getParentvo().getVreceiptcode();
|
||||
pk_corp = soSaleResultRootDto.getParentvo().getPk_corp();
|
||||
csaleid = soSaleResultRootDto.getParentvo().getCsaleid();
|
||||
}
|
||||
logger.info("TOC销售订单编号:{} 主键:{} 销售公司:{} 公司:{}", vreceiptcode, csaleid, pk_corp, bdCorpEntity.getUnitname());
|
||||
updateSuccessOrFail1(oldValue, "Y", "success", vreceiptcode, csaleid);
|
||||
} else if (ProfilesActiveConstant.PUSH_SCENE_TYPE_0.equals(pushScenarioType)) {
|
||||
//选择暂存等待下次发起
|
||||
String vreceiptcode = "暂存";
|
||||
String csaleid = "暂存";
|
||||
String newstate = "S";
|
||||
String newTransmitInfo = "暂存";
|
||||
updateSuccessOrFail1(oldValue, newstate, newTransmitInfo, vreceiptcode, csaleid);
|
||||
} else {
|
||||
Assert.state(false, "未知的场景类型 pushScenarioType={}", pushScenarioType);
|
||||
}
|
||||
logger.info("TOC销售订单编号:{} 主键:{} 销售公司:{} 公司:{}", vreceiptcode, csaleid, pk_corp, bdCorpEntity.getUnitname());
|
||||
updateSuccessOrFail1(oldValue, "Y", "success", vreceiptcode, csaleid);
|
||||
} else if (ProfilesActiveConstant.PUSH_SCENE_TYPE_0.equals(pushScenarioType)) {
|
||||
//选择暂存等待下次发起
|
||||
String vreceiptcode = "暂存";
|
||||
String csaleid = "暂存";
|
||||
String newstate = "S";
|
||||
String newTransmitInfo = "暂存";
|
||||
updateSuccessOrFail1(oldValue, newstate, newTransmitInfo, vreceiptcode, csaleid);
|
||||
} else {
|
||||
Assert.state(false, "未知的场景类型 pushScenarioType={}", pushScenarioType);
|
||||
updateSuccessOrFail1(oldValue, "N", "不符合条件,不推U8C销售订单", null, null);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
//记录失败
|
||||
|
@ -1098,8 +1106,8 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity {
|
|||
BdDefdocEntity platformArchives = oldValue.get(0).getPlatformArchives();//U8C平台档案
|
||||
BdDefdocEntity shopArchives = oldValue.get(0).getShopArchives();//U8C店铺档案
|
||||
BdRdclEntity bdRdclEntity = oldValue.get(0).getBdRdclEntity();//U8C收发类别
|
||||
String newstate4 = oldValue.get(0).getNewstate4();
|
||||
String def15 = oldValue.get(0).getDef15();
|
||||
String newstate4 = oldValue.get(0).getNewstate4();//确认收入红
|
||||
String def15 = oldValue.get(0).getDef15();//确认收入蓝
|
||||
|
||||
//验证是否为指定的店铺,如果为true,则取结存价
|
||||
Boolean isCheckShopChoose = balanceUnitPriceUtil.checkOfsShop(header.getStoreCode());
|
||||
|
@ -1107,10 +1115,11 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity {
|
|||
GoodsRertunSonDetailsDto goodsRertunSonDetailsDto = groupMergeDetailedRows(oldValue, isCheckShopChoose, sceneType);
|
||||
Assert.notNull(goodsRertunSonDetailsDto, "合并明细行失败!");
|
||||
BigDecimal groupShipQty = goodsRertunSonDetailsDto.getGroupShipQty();
|
||||
BigDecimal groupTotalPayAmount = goodsRertunSonDetailsDto.getGroupTotalPayAmount();
|
||||
|
||||
//当金额>0,但数量为0时,推送红字应收单
|
||||
// if (groupTotalPayAmount != null && groupShipQty != null && groupTotalPayAmount.compareTo(BigDecimal.ZERO) > 0 && groupShipQty.compareTo(BigDecimal.ZERO) == 0) {
|
||||
//是否推送u8c红字销售订单
|
||||
boolean isPushU8CSaleOrder = false;
|
||||
|
||||
//推送红字应收单
|
||||
try {
|
||||
BdBusitypeEntity bdBusitypeEntity = u8cOperationFlowV4();
|
||||
//生成业务日期
|
||||
|
@ -1152,9 +1161,6 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity {
|
|||
//如果合并后的金额为0,则不传到U8C
|
||||
Assert.notNull(goodsRertunSonDetailsDto.getGroupTotalPayAmount(), "goodsRertunSonDetailsDto.getGroupTotalPayAmount()不能为空!");
|
||||
BigDecimal groupTotalPayAmount2 = goodsRertunSonDetailsDto.getGroupTotalPayAmount().setScale(2, BigDecimal.ROUND_HALF_UP);
|
||||
// if ("0".equals(groupTotalPayAmount2.stripTrailingZeros().toPlainString())) {
|
||||
// continue;
|
||||
// }
|
||||
|
||||
//修改为生成红字应收单表体
|
||||
List<ArapDjzbVO.Childrenn> childrennArrayList = new ArrayList<>();
|
||||
|
@ -1218,37 +1224,33 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity {
|
|||
}
|
||||
}
|
||||
|
||||
//如果总金额不为0,并且数量=0,生成红字应收单
|
||||
// for (int i = 0; i < childrennArrayList.size(); i++) {
|
||||
// ArapDjzbVO.Childrenn childrenn = childrennArrayList.get(i);
|
||||
// childrenn.setJfbbje("0");
|
||||
// }
|
||||
// groupShipQty = new BigDecimal("0");
|
||||
if ((filterJfbbjeIncludingTax(childrennArrayList)) && groupShipQty.compareTo(BigDecimal.ZERO) == 0) {
|
||||
List<ArapDjzbVO.Childrenn> childrenns = filterZeroJfbbje(childrennArrayList);
|
||||
if (ProfilesActiveConstant.PUSH_SCENE_TYPE_1.equals(pushScenarioType) || ProfilesActiveConstant.PUSH_SCENE_TYPE_2.equals(pushScenarioType)) {
|
||||
//推送U8C生成红字应收单
|
||||
List<ArapDjzbVO> arapDjzbVOList = new ArrayList<>();
|
||||
ArapDjzbVO arapDjzbVO = new ArapDjzbVO();
|
||||
arapDjzbVO.setParentvo(parentVo);
|
||||
arapDjzbVO.setChildren(childrenns);
|
||||
arapDjzbVOList.add(arapDjzbVO);
|
||||
//如果出现情况二,但是生成的是红字应收单的情况下,只会有一个Y,不会有两个,过滤逻辑只会判断两个Y,需要在这里增加!"Y".equals(newstate4)判断
|
||||
if (childrenns != null && childrenns.size() > 0 && !"A".equals(newstate4)) {
|
||||
//推送U8C生成红字应收单
|
||||
List<ArapDjzbVO> arapDjzbVOList = new ArrayList<>();
|
||||
ArapDjzbVO arapDjzbVO = new ArapDjzbVO();
|
||||
arapDjzbVO.setParentvo(parentVo);
|
||||
arapDjzbVO.setChildren(childrenns);
|
||||
arapDjzbVOList.add(arapDjzbVO);
|
||||
|
||||
Map<String, List<ArapDjzbVO>> listMap = new HashMap<>();
|
||||
listMap.put("djzbvo", arapDjzbVOList);
|
||||
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;
|
||||
if (arapDjzb != null && arapDjzb.getParentvo() != null) {
|
||||
djbh = arapDjzb.getParentvo().getDjbh();
|
||||
dwbm = arapDjzb.getParentvo().getDwbm();
|
||||
vouchid = arapDjzb.getParentvo().getVouchid();
|
||||
ArapDjzb arapDjzb = sendU8cRedReceivable(JSON.toJSONString(listMap));
|
||||
String djbh = null;
|
||||
String dwbm = null;
|
||||
String vouchid = null;
|
||||
if (arapDjzb != null && arapDjzb.getParentvo() != null) {
|
||||
djbh = arapDjzb.getParentvo().getDjbh();
|
||||
dwbm = arapDjzb.getParentvo().getDwbm();
|
||||
vouchid = arapDjzb.getParentvo().getVouchid();
|
||||
}
|
||||
logger.info("TOC红字应收单:{} 销售订单主键:{} 销售公司:{} 公司:{}", djbh, vouchid, dwbm, bdCorpEntity.getUnitname());
|
||||
updateSuccessOrFail2(oldValue, "A", "success", djbh, vouchid, oldValue.get(0).getStorageTimeStamp());
|
||||
}
|
||||
logger.info("TOC红字应收单:{} 销售订单主键:{} 销售公司:{} 公司:{}", djbh, vouchid, dwbm, bdCorpEntity.getUnitname());
|
||||
|
||||
updateSuccessOrFail2(oldValue, "Y", "success", djbh, vouchid, oldValue.get(0).getStorageTimeStamp());
|
||||
} else if (ProfilesActiveConstant.PUSH_SCENE_TYPE_0.equals(pushScenarioType)) {
|
||||
//不推送U8C,单据暂存
|
||||
String vreceiptcode = "暂存";
|
||||
|
@ -1259,6 +1261,8 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity {
|
|||
} else {
|
||||
Assert.state(false, "未知的场景类型 pushScenarioType={}", pushScenarioType);
|
||||
}
|
||||
} else {
|
||||
isPushU8CSaleOrder = true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("TOC退货业务转换成U8C对象过程中、或者单据推送到U8C出现异常!", e);
|
||||
|
@ -1269,247 +1273,181 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity {
|
|||
}
|
||||
updateSuccessOrFail2(oldValue, "N", message, null, null, oldValue.get(0).getStorageTimeStamp());
|
||||
}
|
||||
// }
|
||||
|
||||
//当金额大于或者等于0,数量大于0推送销售订单
|
||||
// if (groupShipQty != null && groupTotalPayAmount != null && groupTotalPayAmount.compareTo(BigDecimal.ZERO) >= 0 && groupShipQty.compareTo(BigDecimal.ZERO) > 0) {
|
||||
try {
|
||||
// checkArchives(oldValue.get(0));
|
||||
//生成业务日期
|
||||
String generateBusinessDate = createSuccessFulTradeDate(header);
|
||||
//推送红蓝字销售订单
|
||||
if (isPushU8CSaleOrder) {
|
||||
try {
|
||||
//生成业务日期
|
||||
String generateBusinessDate = createSuccessFulTradeDate(header);
|
||||
|
||||
SaleorderRequestDto saleorderRequestDto = new SaleorderRequestDto();
|
||||
SaleorderRequestParentDto saleorderRequestParentDto = new SaleorderRequestParentDto();
|
||||
saleorderRequestParentDto.setDbilldate(generateBusinessDate);//单据日期
|
||||
saleorderRequestParentDto.setBretinvflag("Y");//退货标记
|
||||
saleorderRequestParentDto.setCbiztype(bdBusitypeEntity1.getPkBusitype());//业务流程
|
||||
saleorderRequestParentDto.setCcalbodyid(bdCalbodyEntity.getPkCalbody());//库存组织
|
||||
saleorderRequestParentDto.setCcustomerid(bdCumandocEntity.getPkCumandoc());//客户=开票单位=收货单位=表体收货单位=收货单位
|
||||
saleorderRequestParentDto.setCdeptid(bdDeptdocEntity.getPkDeptdoc());//部门
|
||||
saleorderRequestParentDto.setCemployeeid(null);//业务员
|
||||
saleorderRequestParentDto.setCoperatorid(OverallConstant.getOverAllValue("u8cApiZdrPK"));//制单人
|
||||
saleorderRequestParentDto.setCreceiptcorpid(bdCumandocEntity.getPkCumandoc());//开票单位
|
||||
saleorderRequestParentDto.setCreceiptcustomerid(bdCumandocEntity.getPkCumandoc());//收货单位
|
||||
saleorderRequestParentDto.setCsalecorpid(bdSalestruEntity.getCsalestruid());//销售组织
|
||||
saleorderRequestParentDto.setCwarehouseid(bdStordocEntity.getPkStordoc());//仓库
|
||||
saleorderRequestParentDto.setDapprovedate(generateBusinessDate);//审核日期
|
||||
saleorderRequestParentDto.setNdiscountrate("100.000000");//整单折扣
|
||||
saleorderRequestParentDto.setPk_corp(bdCorpEntity.getPkCorp());//公司id
|
||||
//汇总单号=汇总维度
|
||||
saleorderRequestParentDto.setVdef18(keyGroup);
|
||||
//平台
|
||||
saleorderRequestParentDto.setPk_defdoc2(platformArchives.getPkDefdoc());
|
||||
saleorderRequestParentDto.setVdef2(platformArchives.getDocname());
|
||||
saleorderRequestParentDto.setVdef17(ProfilesActiveConstant.sourceSystem1);//来源系统
|
||||
SaleorderRequestDto saleorderRequestDto = new SaleorderRequestDto();
|
||||
SaleorderRequestParentDto saleorderRequestParentDto = new SaleorderRequestParentDto();
|
||||
saleorderRequestParentDto.setDbilldate(generateBusinessDate);//单据日期
|
||||
saleorderRequestParentDto.setBretinvflag("Y");//退货标记
|
||||
saleorderRequestParentDto.setCbiztype(bdBusitypeEntity1.getPkBusitype());//业务流程
|
||||
saleorderRequestParentDto.setCcalbodyid(bdCalbodyEntity.getPkCalbody());//库存组织
|
||||
saleorderRequestParentDto.setCcustomerid(bdCumandocEntity.getPkCumandoc());//客户=开票单位=收货单位=表体收货单位=收货单位
|
||||
saleorderRequestParentDto.setCdeptid(bdDeptdocEntity.getPkDeptdoc());//部门
|
||||
saleorderRequestParentDto.setCemployeeid(null);//业务员
|
||||
saleorderRequestParentDto.setCoperatorid(OverallConstant.getOverAllValue("u8cApiZdrPK"));//制单人
|
||||
saleorderRequestParentDto.setCreceiptcorpid(bdCumandocEntity.getPkCumandoc());//开票单位
|
||||
saleorderRequestParentDto.setCreceiptcustomerid(bdCumandocEntity.getPkCumandoc());//收货单位
|
||||
saleorderRequestParentDto.setCsalecorpid(bdSalestruEntity.getCsalestruid());//销售组织
|
||||
saleorderRequestParentDto.setCwarehouseid(bdStordocEntity.getPkStordoc());//仓库
|
||||
saleorderRequestParentDto.setDapprovedate(generateBusinessDate);//审核日期
|
||||
saleorderRequestParentDto.setNdiscountrate("100.000000");//整单折扣
|
||||
saleorderRequestParentDto.setPk_corp(bdCorpEntity.getPkCorp());//公司id
|
||||
//汇总单号=汇总维度
|
||||
saleorderRequestParentDto.setVdef18(keyGroup);
|
||||
//平台
|
||||
saleorderRequestParentDto.setPk_defdoc2(platformArchives.getPkDefdoc());
|
||||
saleorderRequestParentDto.setVdef2(platformArchives.getDocname());
|
||||
saleorderRequestParentDto.setVdef17(ProfilesActiveConstant.sourceSystem1);//来源系统
|
||||
|
||||
//收发类别
|
||||
saleorderRequestParentDto.setPk_defdoc3(bdRdclEntity.getPkRdcl());
|
||||
saleorderRequestParentDto.setVdef3(bdRdclEntity.getRdname());
|
||||
//收发类别
|
||||
saleorderRequestParentDto.setPk_defdoc3(bdRdclEntity.getPkRdcl());
|
||||
saleorderRequestParentDto.setVdef3(bdRdclEntity.getRdname());
|
||||
|
||||
//2024年8月8日 17:17:58 店铺档案自定义项1,先不传,后续维护好之后再传!
|
||||
//店铺
|
||||
saleorderRequestParentDto.setPk_defdoc1(shopArchives.getPkDefdoc());
|
||||
saleorderRequestParentDto.setVdef1(shopArchives.getDocname());
|
||||
//2024年8月8日 17:17:58 店铺档案自定义项1,先不传,后续维护好之后再传!
|
||||
//店铺
|
||||
saleorderRequestParentDto.setPk_defdoc1(shopArchives.getPkDefdoc());
|
||||
saleorderRequestParentDto.setVdef1(shopArchives.getDocname());
|
||||
|
||||
//单据红字标识
|
||||
saleorderRequestParentDto.setPk_defdoc16(OverallConstant.getOverAllValue("u8c自定义项档案-单据红字标识-Y主键"));
|
||||
saleorderRequestParentDto.setVdef16(OverallConstant.getOverAllValue("u8c自定义项档案-单据红字标识-Y名称"));
|
||||
//单据红字标识
|
||||
saleorderRequestParentDto.setPk_defdoc16(OverallConstant.getOverAllValue("u8c自定义项档案-单据红字标识-Y主键"));
|
||||
saleorderRequestParentDto.setVdef16(OverallConstant.getOverAllValue("u8c自定义项档案-单据红字标识-Y名称"));
|
||||
|
||||
//售后类型标识
|
||||
saleorderRequestParentDto.setPk_defdoc8(OverallConstant.getOverAllValue("售后类型标识-TOC售后-主键"));
|
||||
saleorderRequestParentDto.setVdef8(OverallConstant.getOverAllValue("售后类型标识-TOC售后-名称"));
|
||||
//售后类型标识
|
||||
saleorderRequestParentDto.setPk_defdoc8(OverallConstant.getOverAllValue("售后类型标识-TOC售后-主键"));
|
||||
saleorderRequestParentDto.setVdef8(OverallConstant.getOverAllValue("售后类型标识-TOC售后-名称"));
|
||||
|
||||
saleorderRequestDto.setParentvo(saleorderRequestParentDto);
|
||||
//改为红字应收单表头
|
||||
//组装应收单表头
|
||||
// ArapDjzbVO.Parentt parentVo = new ArapDjzbVO.Parentt();
|
||||
// parentVo.setDjrq(generateBusinessDate);//单据日期
|
||||
// parentVo.setDwbm(bdCorpEntity.getUnitcode());//公司
|
||||
// parentVo.setLrr(OverallConstant.getOverAllValue("u8cApiZdrCode"));//录入人
|
||||
// parentVo.setWldx("0");//往来对象标识 固定为:客户
|
||||
// parentVo.setDeptid(bdDeptdocEntity.getDeptcode());//部门
|
||||
// parentVo.setShr(OverallConstant.getOverAllValue("u8cApiZdrCode"));//审批人
|
||||
// parentVo.setShrq(generateBusinessDate);//审核日期
|
||||
// parentVo.setDjlxbm("D0");//单据类型编码
|
||||
// parentVo.setXslxbm(bdBusitypeEntity.getBusicode());//业务流程
|
||||
// parentVo.setFeinvstatus("0");//开票状态
|
||||
// parentVo.setHbbm(bdCubasdocEntity.getCustcode());//客商主键
|
||||
// parentVo.setZyx1(shopArchives.getDoccode());//店铺档案
|
||||
// parentVo.setZyx2(platformArchives.getDoccode());//来源平台
|
||||
// parentVo.setZyx3(bdRdclEntity.getRdcode());//收发类别
|
||||
// parentVo.setZyx16("1");//单据红字标识
|
||||
// parentVo.setZyx17(ProfilesActiveConstant.sourceSystem1);//来源系统
|
||||
// parentVo.setZyx18(keyGroup);//汇总维度
|
||||
saleorderRequestDto.setParentvo(saleorderRequestParentDto);
|
||||
|
||||
List<SaleorderRequestChildrenDto> saleorderRequestChildrenDtoList = new ArrayList<>();
|
||||
saleorderRequestDto.setChildrenvo(saleorderRequestChildrenDtoList);
|
||||
List<SaleorderRequestChildrenDto> saleorderRequestChildrenDtoList = new ArrayList<>();
|
||||
saleorderRequestDto.setChildrenvo(saleorderRequestChildrenDtoList);
|
||||
|
||||
//存货管理档案:取发货公司的存货管理档案
|
||||
BdInvmandocEntity bdInvmandocEntity = oldValue.get(0).getBdInvmandocEntity();
|
||||
//存货基础档案
|
||||
BdInvbasdocEntity bdInvbasdocEntity = oldValue.get(0).getBdInvbasdocEntity();
|
||||
//根据存货基础档案编码,查询当前存货的税率
|
||||
BdTaxitemsEntity bdTaxitemsEntity1 = oldValue.get(0).getBdTaxitemsEntity();
|
||||
//查询收支项目
|
||||
// BdInvclEntity bdInvclEntity = queryU8CEntityUtil.queryBdInvbasdocByBdInvcl(bdInvbasdocEntity);
|
||||
// BdCostsubjEntity bdCostsubjEntity = queryU8CEntityUtil.queryBdCostsubj(bdInvclEntity);
|
||||
|
||||
//合并后如果数量为0,则过滤掉
|
||||
// if ("0".equals(goodsRertunSonDetailsDto.getGroupShipQty().stripTrailingZeros().toPlainString())) {
|
||||
// continue;
|
||||
// }
|
||||
|
||||
// String tax = new BigDecimal(bdTaxitemsEntity1.getTaxratio()).divide(new BigDecimal(100), 20, BigDecimal.ROUND_HALF_UP).setScale(2, BigDecimal.ROUND_HALF_UP).stripTrailingZeros().toPlainString();
|
||||
|
||||
// BigDecimal noriginalcurprice = null;//无税单价
|
||||
// BigDecimal noriginalcurmny = null;//无税金额
|
||||
// BigDecimal noriginalcurtaxprice = null;//含税单价
|
||||
// BigDecimal noriginalcursummny = null;//价税合计
|
||||
// BigDecimal noriginalcurtaxmny = null;//税额=价税合计-无税金额
|
||||
// try {
|
||||
// noriginalcurtaxprice = goodsRertunSonDetailsDto.getGroupTotalPayAmount().divide(goodsRertunSonDetailsDto.getGroupShipQty(), 20, BigDecimal.ROUND_HALF_UP).setScale(4, BigDecimal.ROUND_HALF_UP);
|
||||
// noriginalcurprice = noriginalcurtaxprice.divide(new BigDecimal(1).add(new BigDecimal(tax)), 20, BigDecimal.ROUND_HALF_UP).setScale(4, BigDecimal.ROUND_HALF_UP);
|
||||
// noriginalcurmny = noriginalcurprice.multiply(goodsRertunSonDetailsDto.getGroupShipQty()).setScale(2, BigDecimal.ROUND_HALF_UP);
|
||||
// noriginalcursummny = noriginalcurtaxprice.multiply(goodsRertunSonDetailsDto.getGroupShipQty()).setScale(2, BigDecimal.ROUND_HALF_UP);
|
||||
// noriginalcurtaxmny = noriginalcursummny.subtract(noriginalcurmny).setScale(2, BigDecimal.ROUND_HALF_UP);
|
||||
// } catch (Exception e) {
|
||||
// logger.error("TOC退货-确认收入,金额计算错误", e);
|
||||
// Assert.state(false, "U8C红字销售订单,金额计算错误,原因:{}", e.getMessage());
|
||||
// }
|
||||
//存货管理档案:取发货公司的存货管理档案
|
||||
BdInvmandocEntity bdInvmandocEntity = oldValue.get(0).getBdInvmandocEntity();
|
||||
//存货基础档案
|
||||
BdInvbasdocEntity bdInvbasdocEntity = oldValue.get(0).getBdInvbasdocEntity();
|
||||
//根据存货基础档案编码,查询当前存货的税率
|
||||
BdTaxitemsEntity bdTaxitemsEntity1 = oldValue.get(0).getBdTaxitemsEntity();
|
||||
|
||||
// 判断是否为赠品
|
||||
Boolean isblargessflag = false;
|
||||
if ("0".equals(goodsRertunSonDetailsDto.getGroupTotalPayAmount().setScale(2, BigDecimal.ROUND_HALF_UP).stripTrailingZeros().toPlainString())) {
|
||||
isblargessflag = true;
|
||||
}
|
||||
Boolean isblargessflag = false;
|
||||
if ("0".equals(goodsRertunSonDetailsDto.getGroupTotalPayAmount().setScale(2, BigDecimal.ROUND_HALF_UP).stripTrailingZeros().toPlainString())) {
|
||||
isblargessflag = true;
|
||||
}
|
||||
|
||||
SaleorderRequestChildrenDto saleorderRequestChildrenDto = new SaleorderRequestChildrenDto();
|
||||
saleorderRequestChildrenDto.setBlargessflag(isblargessflag);//是否赠品
|
||||
saleorderRequestChildrenDto.setCadvisecalbodyid(bdCalbodyEntity.getPkCalbody());//发货库存组织
|
||||
saleorderRequestChildrenDto.setCbodywarehouseid(bdStordocEntity.getPkStordoc());//发货仓库
|
||||
saleorderRequestChildrenDto.setCconsigncorpid(deliverGoodsCorp.getPkCorp());//发货公司
|
||||
saleorderRequestChildrenDto.setCcurrencytypeid("00010000000000000001");//币种
|
||||
saleorderRequestChildrenDto.setCinventoryid(bdInvmandocEntity.getPkInvmandoc());//存货id
|
||||
saleorderRequestChildrenDto.setCreceiptcorpid(bdCumandocEntity.getPkCumandoc());//收货单位
|
||||
saleorderRequestChildrenDto.setDconsigndate(generateBusinessDate);//计划发货日期
|
||||
saleorderRequestChildrenDto.setDdeliverdate(generateBusinessDate);// 要求收货日期
|
||||
saleorderRequestChildrenDto.setNexchangeotobrate("1.00000000");//折本汇率
|
||||
saleorderRequestChildrenDto.setNitemdiscountrate("100.000000");//单品折扣
|
||||
saleorderRequestChildrenDto.setNnumber("-" + goodsRertunSonDetailsDto.getGroupShipQty().stripTrailingZeros().toPlainString());//数量
|
||||
saleorderRequestChildrenDto.setNoriginalcurdiscountmny("0");//折扣额
|
||||
SaleorderRequestChildrenDto saleorderRequestChildrenDto = new SaleorderRequestChildrenDto();
|
||||
saleorderRequestChildrenDto.setBlargessflag(isblargessflag);//是否赠品
|
||||
saleorderRequestChildrenDto.setCadvisecalbodyid(bdCalbodyEntity.getPkCalbody());//发货库存组织
|
||||
saleorderRequestChildrenDto.setCbodywarehouseid(bdStordocEntity.getPkStordoc());//发货仓库
|
||||
saleorderRequestChildrenDto.setCconsigncorpid(deliverGoodsCorp.getPkCorp());//发货公司
|
||||
saleorderRequestChildrenDto.setCcurrencytypeid("00010000000000000001");//币种
|
||||
saleorderRequestChildrenDto.setCinventoryid(bdInvmandocEntity.getPkInvmandoc());//存货id
|
||||
saleorderRequestChildrenDto.setCreceiptcorpid(bdCumandocEntity.getPkCumandoc());//收货单位
|
||||
saleorderRequestChildrenDto.setDconsigndate(generateBusinessDate);//计划发货日期
|
||||
saleorderRequestChildrenDto.setDdeliverdate(generateBusinessDate);// 要求收货日期
|
||||
saleorderRequestChildrenDto.setNexchangeotobrate("1.00000000");//折本汇率
|
||||
saleorderRequestChildrenDto.setNitemdiscountrate("100.000000");//单品折扣
|
||||
saleorderRequestChildrenDto.setNnumber("-" + goodsRertunSonDetailsDto.getGroupShipQty().stripTrailingZeros().toPlainString());//数量
|
||||
saleorderRequestChildrenDto.setNoriginalcurdiscountmny("0");//折扣额
|
||||
// saleorderRequestChildrenDto.setNoriginalcurmny("-" + noriginalcurmny.stripTrailingZeros().toPlainString());//无税金额
|
||||
// saleorderRequestChildrenDto.setNoriginalcurnetprice(noriginalcurprice.stripTrailingZeros().toPlainString());//无税净价
|
||||
// saleorderRequestChildrenDto.setNoriginalcurprice(noriginalcurprice.stripTrailingZeros().toPlainString());//无税单价
|
||||
// saleorderRequestChildrenDto.setNoriginalcursummny("-" + noriginalcursummny.stripTrailingZeros().toPlainString());//价税合计
|
||||
saleorderRequestChildrenDto.setNoriginalcursummny("-" + goodsRertunSonDetailsDto.getGroupTotalPayAmount().setScale(2, BigDecimal.ROUND_HALF_UP).stripTrailingZeros().toPlainString());//价税合计 新逻辑
|
||||
saleorderRequestChildrenDto.setNoriginalcursummny("-" + goodsRertunSonDetailsDto.getGroupTotalPayAmount().setScale(2, BigDecimal.ROUND_HALF_UP).stripTrailingZeros().toPlainString());//价税合计 新逻辑
|
||||
// saleorderRequestChildrenDto.setNoriginalcurtaxmny("-" + noriginalcurtaxmny.stripTrailingZeros().toPlainString());//税额
|
||||
// saleorderRequestChildrenDto.setNoriginalcurtaxnetprice(noriginalcurtaxprice.stripTrailingZeros().toPlainString());//含税净价
|
||||
// saleorderRequestChildrenDto.setNoriginalcurtaxprice(noriginalcurtaxprice.stripTrailingZeros().toPlainString());//含税单价
|
||||
// saleorderRequestChildrenDto.setNtaxrate(new BigDecimal(bdTaxitemsEntity1.getTaxratio()).stripTrailingZeros().toPlainString());//税率
|
||||
// saleorderRequestChildrenDto.setVdef2(bdCostsubjEntity.getCostname());//收支项目
|
||||
// saleorderRequestChildrenDto.setPk_defdoc2(bdCostsubjEntity.getPkCostsubj());
|
||||
//如果优惠金额为0,则传0
|
||||
if (!"0".equals(goodsRertunSonDetailsDto.getVdef4().stripTrailingZeros().toPlainString())) {
|
||||
saleorderRequestChildrenDto.setVdef4("-" + goodsRertunSonDetailsDto.getVdef4().stripTrailingZeros().toPlainString());
|
||||
} else {
|
||||
saleorderRequestChildrenDto.setVdef4("0");
|
||||
}
|
||||
if (!"0".equals(goodsRertunSonDetailsDto.getVdef5().stripTrailingZeros().toPlainString())) {
|
||||
saleorderRequestChildrenDto.setVdef5("-" + goodsRertunSonDetailsDto.getVdef5().stripTrailingZeros().toPlainString());
|
||||
} else {
|
||||
saleorderRequestChildrenDto.setVdef5("0");
|
||||
}
|
||||
if (!"0".equals(goodsRertunSonDetailsDto.getVdef6().stripTrailingZeros().toPlainString())) {
|
||||
saleorderRequestChildrenDto.setVdef6("-" + goodsRertunSonDetailsDto.getVdef6().stripTrailingZeros().toPlainString());
|
||||
} else {
|
||||
saleorderRequestChildrenDto.setVdef6("0");
|
||||
}
|
||||
if (!"0".equals(goodsRertunSonDetailsDto.getVdef7().stripTrailingZeros().toPlainString())) {
|
||||
saleorderRequestChildrenDto.setVdef7("-" + goodsRertunSonDetailsDto.getVdef7().stripTrailingZeros().toPlainString());
|
||||
} else {
|
||||
saleorderRequestChildrenDto.setVdef7("0");
|
||||
}
|
||||
saleorderRequestChildrenDtoList.add(saleorderRequestChildrenDto);
|
||||
|
||||
//如果合并后的金额为0,则不传到U8C
|
||||
// Assert.notNull(goodsRertunSonDetailsDto.getGroupTotalPayAmount(), "goodsRertunSonDetailsDto.getGroupTotalPayAmount()不能为空!");
|
||||
// BigDecimal groupTotalPayAmount = goodsRertunSonDetailsDto.getGroupTotalPayAmount().setScale(2, BigDecimal.ROUND_HALF_UP);
|
||||
// if ("0".equals(groupTotalPayAmount.stripTrailingZeros().toPlainString())) {
|
||||
// continue;
|
||||
// }
|
||||
|
||||
//修改为生成红字应收单表体
|
||||
// List<ArapDjzbVO.Childrenn> childrennArrayList = new ArrayList<>();
|
||||
// ArapDjzbVO.Childrenn arapDjzbVOChildrenn = new ArapDjzbVO.Childrenn();
|
||||
// childrennArrayList.add(arapDjzbVOChildrenn);
|
||||
// arapDjzbVOChildrenn.setCinventoryid(bdInvbasdocEntity.getInvcode());//存货管理档案
|
||||
// arapDjzbVOChildrenn.setJfbbje("-" + groupTotalPayAmount.stripTrailingZeros().toPlainString());//借方本币金额
|
||||
// arapDjzbVOChildrenn.setJfybje("-" + groupTotalPayAmount.stripTrailingZeros().toPlainString());//借方原币金额
|
||||
// arapDjzbVOChildrenn.setJfbbsj("-" + noriginalcurmny.stripTrailingZeros().toPlainString());//借方本币税金
|
||||
// arapDjzbVOChildrenn.setJfybsj("-" + noriginalcurmny.stripTrailingZeros().toPlainString());//借方原币税金
|
||||
// arapDjzbVOChildrenn.setWbfbbje("-" + noriginalcurtaxmny.stripTrailingZeros().toPlainString());//借方本币无税金额
|
||||
// arapDjzbVOChildrenn.setJfybwsje("-" + noriginalcurtaxmny.stripTrailingZeros().toPlainString());//借方原币无税金额
|
||||
|
||||
//退货没有邮费金额,已经向万万确认
|
||||
//所有业务商家优惠都不传
|
||||
//平台优惠
|
||||
if (goodsRertunSonDetailsDto.getVdef4() != null) {
|
||||
BigDecimal vdef4 = goodsRertunSonDetailsDto.getVdef4();
|
||||
if (vdef4.compareTo(BigDecimal.ZERO) > 0) {
|
||||
//发货运费-存货基本档案
|
||||
BdInvbasdocEntity bdInvbasdocEntity1 = mapBdInvbasdocEntity.get("FY01");
|
||||
//存货管理档案
|
||||
BdInvmandocEntity bdInvmandocEntity1 = stringBdInvmandocEntityMap.get(bdInvbasdocEntity1.getInvcode() + deliverGoodsCorp.getPkCorp());
|
||||
//存货对应的税率
|
||||
BdTaxitemsEntity bdTaxitemsEntity = stringBdTaxitemsEntityMap.get("FY01");
|
||||
//补充:平台优惠-存货
|
||||
BigDecimal absAccumulatedPostage = vdef4.abs();
|
||||
BigDecimal negativeValue = absAccumulatedPostage.negate();
|
||||
queryAdditionUtil.additional(saleorderRequestChildrenDtoList, bdInvmandocEntity1, bdInvbasdocEntity1, negativeValue, "-1", bdTaxitemsEntity);
|
||||
// queryAdditionUtil.additionalV3(childrennArrayList, bdInvmandocEntity1, bdInvbasdocEntity1, negativeValue, bdTaxitemsEntity);
|
||||
//如果优惠金额为0,则传0
|
||||
if (!"0".equals(goodsRertunSonDetailsDto.getVdef4().stripTrailingZeros().toPlainString())) {
|
||||
saleorderRequestChildrenDto.setVdef4("-" + goodsRertunSonDetailsDto.getVdef4().stripTrailingZeros().toPlainString());
|
||||
} else {
|
||||
saleorderRequestChildrenDto.setVdef4("0");
|
||||
}
|
||||
}
|
||||
//达人优惠
|
||||
if (goodsRertunSonDetailsDto.getVdef6() != null) {
|
||||
BigDecimal vdef6 = goodsRertunSonDetailsDto.getVdef6();
|
||||
if (vdef6.compareTo(BigDecimal.ZERO) > 0) {
|
||||
//发货运费-存货基本档案
|
||||
BdInvbasdocEntity bdInvbasdocEntity1 = mapBdInvbasdocEntity.get("FY02");
|
||||
//存货管理档案
|
||||
BdInvmandocEntity bdInvmandocEntity1 = stringBdInvmandocEntityMap.get(bdInvbasdocEntity1.getInvcode() + deliverGoodsCorp.getPkCorp());
|
||||
//存货对应的税率
|
||||
BdTaxitemsEntity bdTaxitemsEntity = stringBdTaxitemsEntityMap.get("FY02");
|
||||
//补充:达人优惠-存货
|
||||
BigDecimal absAccumulatedPostage = vdef6.abs();
|
||||
BigDecimal negativeValue = absAccumulatedPostage.negate();
|
||||
queryAdditionUtil.additional(saleorderRequestChildrenDtoList, bdInvmandocEntity1, bdInvbasdocEntity1, negativeValue, "-1", bdTaxitemsEntity);
|
||||
// queryAdditionUtil.additionalV3(childrennArrayList, bdInvmandocEntity1, bdInvbasdocEntity1, negativeValue, bdTaxitemsEntity);
|
||||
if (!"0".equals(goodsRertunSonDetailsDto.getVdef5().stripTrailingZeros().toPlainString())) {
|
||||
saleorderRequestChildrenDto.setVdef5("-" + goodsRertunSonDetailsDto.getVdef5().stripTrailingZeros().toPlainString());
|
||||
} else {
|
||||
saleorderRequestChildrenDto.setVdef5("0");
|
||||
}
|
||||
}
|
||||
//支付优惠
|
||||
if (goodsRertunSonDetailsDto.getVdef5() != null) {
|
||||
BigDecimal vdef5 = goodsRertunSonDetailsDto.getVdef5();
|
||||
if (vdef5.compareTo(BigDecimal.ZERO) > 0) {
|
||||
//发货运费-存货基本档案
|
||||
BdInvbasdocEntity bdInvbasdocEntity1 = mapBdInvbasdocEntity.get("FY04");
|
||||
//存货管理档案
|
||||
BdInvmandocEntity bdInvmandocEntity1 = stringBdInvmandocEntityMap.get(bdInvbasdocEntity1.getInvcode() + deliverGoodsCorp.getPkCorp());
|
||||
//存货对应的税率
|
||||
BdTaxitemsEntity bdTaxitemsEntity = stringBdTaxitemsEntityMap.get("FY04");
|
||||
//补充:支付优惠-存货
|
||||
BigDecimal absAccumulatedPostage = vdef5.abs();
|
||||
BigDecimal negativeValue = absAccumulatedPostage.negate();// 符号取反(转为负数)
|
||||
queryAdditionUtil.additional(saleorderRequestChildrenDtoList, bdInvmandocEntity1, bdInvbasdocEntity1, negativeValue, "-1", bdTaxitemsEntity);
|
||||
// queryAdditionUtil.additionalV3(childrennArrayList, bdInvmandocEntity1, bdInvbasdocEntity1, negativeValue, bdTaxitemsEntity);
|
||||
if (!"0".equals(goodsRertunSonDetailsDto.getVdef6().stripTrailingZeros().toPlainString())) {
|
||||
saleorderRequestChildrenDto.setVdef6("-" + goodsRertunSonDetailsDto.getVdef6().stripTrailingZeros().toPlainString());
|
||||
} else {
|
||||
saleorderRequestChildrenDto.setVdef6("0");
|
||||
}
|
||||
}
|
||||
if (!"0".equals(goodsRertunSonDetailsDto.getVdef7().stripTrailingZeros().toPlainString())) {
|
||||
saleorderRequestChildrenDto.setVdef7("-" + goodsRertunSonDetailsDto.getVdef7().stripTrailingZeros().toPlainString());
|
||||
} else {
|
||||
saleorderRequestChildrenDto.setVdef7("0");
|
||||
}
|
||||
saleorderRequestChildrenDtoList.add(saleorderRequestChildrenDto);
|
||||
|
||||
//存货数量>0生成红字销售订单
|
||||
if (groupShipQty.compareTo(BigDecimal.ZERO) > 0) {
|
||||
//退货没有邮费金额,已经向万万确认
|
||||
//所有业务商家优惠都不传
|
||||
//平台优惠
|
||||
if (goodsRertunSonDetailsDto.getVdef4() != null) {
|
||||
BigDecimal vdef4 = goodsRertunSonDetailsDto.getVdef4();
|
||||
if (vdef4.compareTo(BigDecimal.ZERO) > 0) {
|
||||
//发货运费-存货基本档案
|
||||
BdInvbasdocEntity bdInvbasdocEntity1 = mapBdInvbasdocEntity.get("FY01");
|
||||
//存货管理档案
|
||||
BdInvmandocEntity bdInvmandocEntity1 = stringBdInvmandocEntityMap.get(bdInvbasdocEntity1.getInvcode() + deliverGoodsCorp.getPkCorp());
|
||||
//存货对应的税率
|
||||
BdTaxitemsEntity bdTaxitemsEntity = stringBdTaxitemsEntityMap.get("FY01");
|
||||
//补充:平台优惠-存货
|
||||
BigDecimal absAccumulatedPostage = vdef4.abs();
|
||||
BigDecimal negativeValue = absAccumulatedPostage.negate();
|
||||
queryAdditionUtil.additional(saleorderRequestChildrenDtoList, bdInvmandocEntity1, bdInvbasdocEntity1, negativeValue, "-1", bdTaxitemsEntity);
|
||||
}
|
||||
}
|
||||
//达人优惠
|
||||
if (goodsRertunSonDetailsDto.getVdef6() != null) {
|
||||
BigDecimal vdef6 = goodsRertunSonDetailsDto.getVdef6();
|
||||
if (vdef6.compareTo(BigDecimal.ZERO) > 0) {
|
||||
//发货运费-存货基本档案
|
||||
BdInvbasdocEntity bdInvbasdocEntity1 = mapBdInvbasdocEntity.get("FY02");
|
||||
//存货管理档案
|
||||
BdInvmandocEntity bdInvmandocEntity1 = stringBdInvmandocEntityMap.get(bdInvbasdocEntity1.getInvcode() + deliverGoodsCorp.getPkCorp());
|
||||
//存货对应的税率
|
||||
BdTaxitemsEntity bdTaxitemsEntity = stringBdTaxitemsEntityMap.get("FY02");
|
||||
//补充:达人优惠-存货
|
||||
BigDecimal absAccumulatedPostage = vdef6.abs();
|
||||
BigDecimal negativeValue = absAccumulatedPostage.negate();
|
||||
queryAdditionUtil.additional(saleorderRequestChildrenDtoList, bdInvmandocEntity1, bdInvbasdocEntity1, negativeValue, "-1", bdTaxitemsEntity);
|
||||
}
|
||||
}
|
||||
//支付优惠
|
||||
if (goodsRertunSonDetailsDto.getVdef5() != null) {
|
||||
BigDecimal vdef5 = goodsRertunSonDetailsDto.getVdef5();
|
||||
if (vdef5.compareTo(BigDecimal.ZERO) > 0) {
|
||||
//发货运费-存货基本档案
|
||||
BdInvbasdocEntity bdInvbasdocEntity1 = mapBdInvbasdocEntity.get("FY04");
|
||||
//存货管理档案
|
||||
BdInvmandocEntity bdInvmandocEntity1 = stringBdInvmandocEntityMap.get(bdInvbasdocEntity1.getInvcode() + deliverGoodsCorp.getPkCorp());
|
||||
//存货对应的税率
|
||||
BdTaxitemsEntity bdTaxitemsEntity = stringBdTaxitemsEntityMap.get("FY04");
|
||||
//补充:支付优惠-存货
|
||||
BigDecimal absAccumulatedPostage = vdef5.abs();
|
||||
BigDecimal negativeValue = absAccumulatedPostage.negate();// 符号取反(转为负数)
|
||||
queryAdditionUtil.additional(saleorderRequestChildrenDtoList, bdInvmandocEntity1, bdInvbasdocEntity1, negativeValue, "-1", bdTaxitemsEntity);
|
||||
}
|
||||
}
|
||||
|
||||
//存货数量>0生成红字销售订单
|
||||
// if (groupShipQty.compareTo(BigDecimal.ZERO) > 0) {
|
||||
//2025年8月25日10:42:30 不在此处验证,否则影响红字应收单推送
|
||||
//判断入库时间(关单时间)与交易成功时间,推送u8c生成蓝字销售订单,仅满足情况二的条件才生成这张蓝字销售订单
|
||||
//2025年8月25日10:59:26 把实入数量=0的明细行去掉
|
||||
checkSaleOrderNnumber(saleorderRequestChildrenDtoList);
|
||||
|
||||
boolean oneSuccess = false;
|
||||
if (!"Y".equals(newstate4)) {
|
||||
if (ProfilesActiveConstant.PUSH_SCENE_TYPE_1.equals(pushScenarioType) || ProfilesActiveConstant.PUSH_SCENE_TYPE_2.equals(pushScenarioType)) {
|
||||
if ((ProfilesActiveConstant.PUSH_SCENE_TYPE_1.equals(pushScenarioType) || ProfilesActiveConstant.PUSH_SCENE_TYPE_2.equals(pushScenarioType)) && saleorderRequestChildrenDtoList.size() > 0) {
|
||||
//推送U8C红字销售订单,如果推送失败,抛出异常,那么就会外围的try catch捕获,代码不会往下执行
|
||||
List<SaleorderRequestDto> saleorderRequestDtoList = new ArrayList<>();
|
||||
saleorderRequestDtoList.add(saleorderRequestDto);
|
||||
|
@ -1527,27 +1465,6 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity {
|
|||
logger.info("TOC红字销售订单编号:{} 销售订单主键:{} 销售公司:{} 公司:{}", vreceiptcode, csaleid, pk_corp, bdCorpEntity.getUnitname());
|
||||
updateSuccessOrFail2(oldValue, "Y", "success", vreceiptcode, csaleid, oldValue.get(0).getStorageTimeStamp());
|
||||
oneSuccess = true;
|
||||
|
||||
//推送第一笔红字销售订单
|
||||
// List<ArapDjzbVO> arapDjzbVOList = new ArrayList<>();
|
||||
// ArapDjzbVO arapDjzbVO = new ArapDjzbVO();
|
||||
// arapDjzbVO.setParentvo(parentVo);
|
||||
// arapDjzbVO.setChildren(childrennArrayList);
|
||||
// arapDjzbVOList.add(arapDjzbVO);
|
||||
//
|
||||
// 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;
|
||||
// if (arapDjzb != null && arapDjzb.getParentvo() != null) {
|
||||
// djbh = arapDjzb.getParentvo().getDjbh();
|
||||
// dwbm = arapDjzb.getParentvo().getDwbm();
|
||||
// vouchid = arapDjzb.getParentvo().getVouchid();
|
||||
// }
|
||||
// logger.info("TOC红字应收单:{} 销售订单主键:{} 销售公司:{}", djbh, vouchid, dwbm);
|
||||
} else if (ProfilesActiveConstant.PUSH_SCENE_TYPE_0.equals(pushScenarioType)) {
|
||||
//不推送U8C,单据暂存
|
||||
String vreceiptcode = "暂存";
|
||||
|
@ -1557,15 +1474,16 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity {
|
|||
updateSuccessOrFail2(oldValue, newstate, newTransmitInfo, vreceiptcode, csaleid, oldValue.get(0).getStorageTimeStamp());
|
||||
oneSuccess = true;
|
||||
} else {
|
||||
Assert.state(false, "未知的场景类型 pushScenarioType={}", pushScenarioType);
|
||||
updateSuccessOrFail2(oldValue, "N", "不符合条件,不推U8C红字销售订单", null, null, oldValue.get(0).getStorageTimeStamp());
|
||||
}
|
||||
} else {
|
||||
oneSuccess = true;
|
||||
}
|
||||
|
||||
try {
|
||||
//2025年8月25日10:41:37 如果实入数量全部0,蓝字销售订单则不推送,存在部分数量为0,则过滤
|
||||
if (!"Y".equals(def15) && oneSuccess && "2".equals(oldValue.get(0).getStorageTimeStamp())) {
|
||||
if (ProfilesActiveConstant.PUSH_SCENE_TYPE_1.equals(pushScenarioType) || ProfilesActiveConstant.PUSH_SCENE_TYPE_2.equals(pushScenarioType)) {
|
||||
if ((ProfilesActiveConstant.PUSH_SCENE_TYPE_1.equals(pushScenarioType) || ProfilesActiveConstant.PUSH_SCENE_TYPE_2.equals(pushScenarioType)) && saleorderRequestChildrenDtoList.size() > 0) {
|
||||
if ("2".equals(oldValue.get(0).getStorageTimeStamp())) {
|
||||
SaleorderRequestDto saleorderRequestDto1 = transformRedSalesOrderToBlueSalesOrder(saleorderRequestDto, bdBusitypeEntity2);
|
||||
|
||||
|
@ -1595,7 +1513,7 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity {
|
|||
String newTransmitInfo = "暂存";
|
||||
updateSuccessOrFail3(oldValue, newstate, newTransmitInfo, vreceiptcode, csaleid, oldValue.get(0).getStorageTimeStamp());
|
||||
} else {
|
||||
Assert.state(false, "未知的场景类型 pushScenarioType={}", pushScenarioType);
|
||||
updateSuccessOrFail3(oldValue, "N", "不符合条件,不推U8C蓝字销售订单", null, null, oldValue.get(0).getStorageTimeStamp());
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
@ -1607,17 +1525,16 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity {
|
|||
}
|
||||
updateSuccessOrFail3(oldValue, "N", message, null, null, oldValue.get(0).getStorageTimeStamp());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
//记录红字销售订单异常失败
|
||||
logger.error("TOC退货业务转换成U8C对象过程中、或者单据推送到U8C出现异常!", e);
|
||||
String message = e.getMessage();
|
||||
if (message == null) {
|
||||
message = "未知错误";
|
||||
}
|
||||
updateSuccessOrFail2(oldValue, "N", message, null, null, oldValue.get(0).getStorageTimeStamp());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
//记录红字销售订单异常失败
|
||||
logger.error("TOC退货业务转换成U8C对象过程中、或者单据推送到U8C出现异常!", e);
|
||||
String message = e.getMessage();
|
||||
if (message == null) {
|
||||
message = "未知错误";
|
||||
}
|
||||
updateSuccessOrFail2(oldValue, "N", message, null, null, oldValue.get(0).getStorageTimeStamp());
|
||||
}
|
||||
// }
|
||||
}
|
||||
} else {
|
||||
//2024年8月6日 11:28:54此处不记录失败,不认为是错误
|
||||
|
@ -3053,6 +2970,7 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity {
|
|||
public void run() {
|
||||
try {
|
||||
String successY = "Y";
|
||||
String successA = "A";
|
||||
if (sonDetailsDtoList != null && sonDetailsDtoList.size() > 0) {
|
||||
List<TocofsReturngoodsDetailedEntity> tocofsReturngoodsDetailedEntityArrayList = new ArrayList<>();
|
||||
for (int i = 0; i < sonDetailsDtoList.size(); i++) {
|
||||
|
@ -3077,7 +2995,7 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity {
|
|||
tocofsReturngoodsDetailedEntity.setDef10(goodsRertunSonDetailsDto.getPayDiscounts());
|
||||
tocofsReturngoodsDetailedEntity.setDef11(goodsRertunSonDetailsDto.getExpertDiscounts());
|
||||
tocofsReturngoodsDetailedEntity.setDef12(goodsRertunSonDetailsDto.getMerchantDiscounts());
|
||||
if (successY.equals(newstate)) {
|
||||
if (successY.equals(newstate) || successA.equals(newstate)) {
|
||||
tocofsReturngoodsDetailedEntity.setNewsystemnumber4(newsystemnumber);
|
||||
tocofsReturngoodsDetailedEntity.setNewsystemprimary4(newsystemprimary);
|
||||
}
|
||||
|
@ -3298,9 +3216,12 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity {
|
|||
// }
|
||||
|
||||
//这里不可能是1,退款业务只可能是2、3
|
||||
if ("2".equals(stockinB.getStorageTimeStamp())) {
|
||||
newstate = no2NameMap2.get(stockinB.getId());
|
||||
if ("A".equals(newstate)) {
|
||||
//如果为A,代表红字应收单已经推送到u8c需要过滤
|
||||
isSuccess = true;
|
||||
} else if ("2".equals(stockinB.getStorageTimeStamp())) {
|
||||
//如果是2同时判断两个状态为Y,则过滤
|
||||
newstate = no2NameMap2.get(stockinB.getId());
|
||||
newstate2 = no2NameMap3.get(stockinB.getId());
|
||||
if (newstate != null && !"".equals(newstate) && (succeseeY.equals(newstate) || succeseeH.equals(newstate))) {
|
||||
if (newstate2 != null && !"".equals(newstate2) && (succeseeY.equals(newstate2) || succeseeH.equals(newstate2))) {
|
||||
|
@ -3309,7 +3230,6 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity {
|
|||
}
|
||||
} else if ("3".equals(stockinB.getStorageTimeStamp())) {
|
||||
//如果是3仅判断一个状态为Y
|
||||
newstate = no2NameMap2.get(stockinB.getId());
|
||||
if (newstate != null && !"".equals(newstate) && (succeseeY.equals(newstate) || succeseeH.equals(newstate))) {
|
||||
isSuccess = true;
|
||||
}
|
||||
|
@ -4168,6 +4088,9 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity {
|
|||
StockinOrderSearchResponse.StockinOrder.StockinH header = stockinOrder.getHeader();
|
||||
List<StockinOrderSearchResponse.StockinOrder.StockinB> details = stockinOrder.getDetails();
|
||||
com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDetailsDto headerDetailsDto = header.getHeaderDetailsDto();
|
||||
if (headerDetailsDto == null) {
|
||||
Assert.state(false, "售后入库单对应的销售订单为空! 售后入库单号:{}", header.getCode());
|
||||
}
|
||||
com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDto header1 = headerDetailsDto.getHeader();
|
||||
|
||||
String closedAt = header.getClosedAt();
|
||||
|
@ -4379,4 +4302,29 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity {
|
|||
return new BigDecimal(jfbbje).compareTo(BigDecimal.ZERO) != 0;
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断实入数量如果为0,则过滤掉
|
||||
*
|
||||
* @param saleorderRequestChildrenDtoList u8c销售订单明细行
|
||||
*/
|
||||
private void checkSaleOrderNnumber(List<SaleorderRequestChildrenDto> saleorderRequestChildrenDtoList) {
|
||||
if (saleorderRequestChildrenDtoList == null || saleorderRequestChildrenDtoList.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 过滤逻辑:转换为 BigDecimal 后判断是否为 0
|
||||
saleorderRequestChildrenDtoList.removeIf(dto -> {
|
||||
String numberStr = dto.getNnumber();
|
||||
if (numberStr == null) {
|
||||
return false; // 保留 null 值(根据业务需求调整)
|
||||
}
|
||||
try {
|
||||
BigDecimal number = new BigDecimal(numberStr);
|
||||
return number.compareTo(BigDecimal.ZERO) == 0;
|
||||
} catch (NumberFormatException e) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
|
@ -74,7 +74,7 @@ public class SoSaleReturnPluginInitializerToCTest {
|
|||
//满足红字应收单
|
||||
// soSaleReturnPluginInitializerToC.startImplementByCode("LETS-RE2025072200001324", "tran");
|
||||
//情况一
|
||||
soSaleReturnPluginInitializerToC.startImplementByCode("LETS-RE2025072900000460", "stock");
|
||||
soSaleReturnPluginInitializerToC.startImplementByCode("LETS-RE2025072200000255", "tran");
|
||||
//情况二
|
||||
// soSaleReturnPluginInitializerToC.startImplementByCode("LETS-RE2025072800000594", "tran");
|
||||
//情况三
|
||||
|
|
Loading…
Reference in New Issue