fix(sales): 修复红字销售订单和发票推送逻辑

- 在 SoSaleOutPluginInitializerToB 和 SoSaleReturnPluginInitializerToB 中增加 SKU 编码空格处理
- 在 ProxyPurchaseWarehousWarehouse 和 SoSaleReturnPluginInitializerToB 中增加实收/实退数量为 0 时的过滤逻辑
- 优化红字销售订单和发票的推送逻辑,避免重复推送
- 调整测试用例执行方式
This commit is contained in:
liuy 2025-05-22 16:38:38 +08:00
parent 1e18edd0a4
commit a8e0d79bc4
4 changed files with 59 additions and 43 deletions

View File

@ -1376,7 +1376,7 @@ public class SoSaleOutPluginInitializerToB extends PluginBaseEntity {
Assert.notNull(pkCorp, "发货公司主键不能为空");
BdInvmandocEntity bdInvmandocEntity = new BdInvmandocEntity();
bdInvmandocEntity.setInvcode(detailsDto.getSkuCode());
bdInvmandocEntity.setInvcode(detailsDto.getSkuCode().trim());
bdInvmandocEntity.setPkCorp(pkCorp);
List<BdInvmandocEntity> bdInvmandocEntity2 = iBdInvmandocDao.queryBdInvmandocByInvcodeList(bdInvmandocEntity);
if (bdInvmandocEntity2.size() == 0) {

View File

@ -835,6 +835,11 @@ public class SoSaleReturnPluginInitializerToB extends PluginBaseEntity {
// BdInvclEntity bdInvclEntity = queryU8CEntityUtil.queryBdInvbasdocByBdInvcl(bdInvbasdocEntity);
// BdCostsubjEntity bdCostsubjEntity = queryU8CEntityUtil.queryBdCostsubj(bdInvclEntity);
//如果实退数量=0则过滤掉不增加到明细列表中
if ("0".equals(new BigDecimal(stockinB.getReceivedQty()).stripTrailingZeros().toPlainString())) {
continue;
}
// 如果是海外的店铺则税率为零
String exportVaue = ExportConstant.exportConstant.get(header.getStoreCode());
if (exportVaue != null) {
@ -912,27 +917,29 @@ public class SoSaleReturnPluginInitializerToB extends PluginBaseEntity {
saleorderRequestDtoList.add(saleorderRequestDto);
synchronized (PUSH_LOCK1) {
Boolean aBoolean = checkTobOrder(header.getId(), header.getCode());
if (!aBoolean) {
logger.error("经过SQL查询判断在U8C(红字)销售订单不存在OFS入库单号为{} OFS入库主键为{}的单据将调用U8C接口执行推送", header.getCode(), header.getId());
Map<String, List<SaleorderRequestDto>> stringStringMap = new HashMap<>();
stringStringMap.put("saleorder", saleorderRequestDtoList);
SoSaleResultRootDto soSaleResultRootDto = sendU8CTOCOrder(JSON.toJSONString(stringStringMap));
String vreceiptcode = null;
String csaleid = null;
String pk_corp = null;
if (soSaleResultRootDto != null) {
SoSaleResultHeadDto parentvo = soSaleResultRootDto.getParentvo();
List<SoSaleResultBodyDto> childrenvo = soSaleResultRootDto.getChildrenvo();
vreceiptcode = parentvo.getVreceiptcode();
csaleid = parentvo.getCsaleid();
pk_corp = parentvo.getPk_corp();
if (saleorderRequestChildrenDtoList.size() > 0) {
Boolean aBoolean = checkTobOrder(header.getId(), header.getCode());
if (!aBoolean) {
logger.error("经过SQL查询判断在U8C(红字)销售订单不存在OFS入库单号为{} OFS入库主键为{}的单据将调用U8C接口执行推送", header.getCode(), header.getId());
Map<String, List<SaleorderRequestDto>> stringStringMap = new HashMap<>();
stringStringMap.put("saleorder", saleorderRequestDtoList);
SoSaleResultRootDto soSaleResultRootDto = sendU8CTOCOrder(JSON.toJSONString(stringStringMap));
String vreceiptcode = null;
String csaleid = null;
String pk_corp = null;
if (soSaleResultRootDto != null) {
SoSaleResultHeadDto parentvo = soSaleResultRootDto.getParentvo();
List<SoSaleResultBodyDto> childrenvo = soSaleResultRootDto.getChildrenvo();
vreceiptcode = parentvo.getVreceiptcode();
csaleid = parentvo.getCsaleid();
pk_corp = parentvo.getPk_corp();
}
logger.info("TOB红字销售订单编号{} 销售订单主键:{} 销售公司:{}", vreceiptcode, csaleid, pk_corp);
//记录成功
updateSuccessOrFail1(details, "Y", "success", vreceiptcode, csaleid);
} else {
logger.error("经过SQL查询判断在U8C(红字)销售订单存在OFS入库单号为{} OFS入库主键为{}的单据为了避免造成单据重复不推送到U8C", header.getCode(), header.getId());
}
logger.info("TOB红字销售订单编号{} 销售订单主键:{} 销售公司:{}", vreceiptcode, csaleid, pk_corp);
//记录成功
updateSuccessOrFail1(details, "Y", "success", vreceiptcode, csaleid);
} else {
logger.error("经过SQL查询判断在U8C(红字)销售订单存在OFS入库单号为{} OFS入库主键为{}的单据为了避免造成单据重复不推送到U8C", header.getCode(), header.getId());
}
}
} catch (Exception e) {
@ -1643,7 +1650,7 @@ public class SoSaleReturnPluginInitializerToB extends PluginBaseEntity {
Assert.notNull(pkCorp, "发货公司主键不能为空");
BdInvmandocEntity bdInvmandocEntity = new BdInvmandocEntity();
bdInvmandocEntity.setInvcode(detailsDto.getSkuCode());
bdInvmandocEntity.setInvcode(detailsDto.getSkuCode().trim());
bdInvmandocEntity.setPkCorp(pkCorp);
List<BdInvmandocEntity> bdInvmandocEntity2 = iBdInvmandocDao.queryBdInvmandocByInvcodeList(bdInvmandocEntity);
if (bdInvmandocEntity2.size() == 0) {
@ -1924,6 +1931,11 @@ public class SoSaleReturnPluginInitializerToB extends PluginBaseEntity {
// BdInvclEntity bdInvclEntity = queryU8CEntityUtil.queryBdInvbasdocByBdInvcl(bdInvbasdocEntity);
// BdCostsubjEntity bdCostsubjEntity = queryU8CEntityUtil.queryBdCostsubj(bdInvclEntity);
//如果实入数量为0则过滤掉
if ("0".equals(new BigDecimal(stockinB.getReceivedQty()).stripTrailingZeros().toPlainString())) {
continue;
}
//计算公式
StringBuffer calculationFormula = new StringBuffer();
// calculationFormula.append("O实退金额");
@ -1980,25 +1992,27 @@ public class SoSaleReturnPluginInitializerToB extends PluginBaseEntity {
//推送到U8C生成销售发票
synchronized (PUSH_LOCK2) {
Boolean aBoolean = checkTobSalesInvoice(header.getId(), header.getCode());
if (!aBoolean) {
logger.error("经过SQL查询判断在U8C红字销售发票中不存在OFS入库单号为{} OFS入库主键为{}的单据将调用U8C接口执行推送", header.getCode(), header.getId());
SaleinvoiceDto saleinvoiceDto = sendU8CTOCSoSaleinvoiceB(JSON.toJSONString(stringListMap));
String vreceiptcode = null;
String csaleid = null;
String pk_corp = null;
if (saleinvoiceDto != null && saleinvoiceDto.getParentvo() != null && saleinvoiceDto.getChildrenvo() != null) {
SaleinvoiceHeadDto parentvo = saleinvoiceDto.getParentvo();
List<SaleinvoiceBodyDto> childrenvo = saleinvoiceDto.getChildrenvo();
vreceiptcode = parentvo.getVreceiptcode();
csaleid = parentvo.getCsaleid();
pk_corp = parentvo.getPk_corp();
if (salesInvoiceBodyDtoList.size() > 0) {
Boolean aBoolean = checkTobSalesInvoice(header.getId(), header.getCode());
if (!aBoolean) {
logger.error("经过SQL查询判断在U8C红字销售发票中不存在OFS入库单号为{} OFS入库主键为{}的单据将调用U8C接口执行推送", header.getCode(), header.getId());
SaleinvoiceDto saleinvoiceDto = sendU8CTOCSoSaleinvoiceB(JSON.toJSONString(stringListMap));
String vreceiptcode = null;
String csaleid = null;
String pk_corp = null;
if (saleinvoiceDto != null && saleinvoiceDto.getParentvo() != null && saleinvoiceDto.getChildrenvo() != null) {
SaleinvoiceHeadDto parentvo = saleinvoiceDto.getParentvo();
List<SaleinvoiceBodyDto> childrenvo = saleinvoiceDto.getChildrenvo();
vreceiptcode = parentvo.getVreceiptcode();
csaleid = parentvo.getCsaleid();
pk_corp = parentvo.getPk_corp();
}
logger.info("TOB销售发票(红字)生成成功 编码:{} 主键:{} 发票公司:{}", vreceiptcode, csaleid, pk_corp);
//记录成功
updateSuccessOrFail2(details, "Y", "success", vreceiptcode, csaleid);
} else {
logger.error("经过SQL查询判断在U8C红字销售发票中已经存在OFS入库单号为{} OFS入库主键为{}的单据为了避免造成单据重复不推送到U8C", header.getCode(), header.getId());
}
logger.info("TOB销售发票(红字)生成成功 编码:{} 主键:{} 发票公司:{}", vreceiptcode, csaleid, pk_corp);
//记录成功
updateSuccessOrFail2(details, "Y", "success", vreceiptcode, csaleid);
} else {
logger.error("经过SQL查询判断在U8C红字销售发票中已经存在OFS入库单号为{} OFS入库主键为{}的单据为了避免造成单据重复不推送到U8C", header.getCode(), header.getId());
}
}
} catch (Exception e) {

View File

@ -37,7 +37,9 @@ public class SoSaleReturnPluginInitializerToBTest {
// soSaleReturnPluginInitializerToB.startImplementByCode("LETS-RE2024112200000301", "tran");
soSaleReturnPluginInitializerToB.startImplementByStockTime("2024-11-29 00:00:00", "2024-11-30 23:59:59");
// soSaleReturnPluginInitializerToB.startImplementByStockTime("2024-11-29 00:00:00", "2024-11-30 23:59:59");
soSaleReturnPluginInitializerToB.startImplementByCode("LETS-RE2025042200001200", "stock");
} catch (Exception e) {
e.printStackTrace();
}