fix(sales): 修复邮费四舍五入保留两位小数的问题

- 修改了邮费比较逻辑,使用 compareTo 方法替代 >
- 优化了优惠金额的判断条件,确保正确处理各种优惠情况- 在 QueryAdditionUtil 中增加了对四舍五入后为0 的判断,避免推送错误数据
This commit is contained in:
liuy 2025-02-17 11:35:41 +08:00
parent 218863d9cb
commit 1ad4889068
3 changed files with 46 additions and 40 deletions

View File

@ -1169,10 +1169,10 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
saleorderRequestChildrenDto.setVdef7("0");
}
saleorderRequestChildrenDtoList.add(saleorderRequestChildrenDto);
//判断是否增加邮费这个存货accumulatedPostage
BigDecimal accumulatedPostage = checkPostageFee(oldValue);
if (accumulatedPostage.compareTo(BigDecimal.ZERO) > 0) {
if (accumulatedPostage.compareTo(BigDecimal.ZERO) != 0) {
//获取平台运维对应的税率
// String tax2 = new BigDecimal(bdTaxitemsEntity.getTaxratio()).divide(new BigDecimal(100), 20, BigDecimal.ROUND_HALF_UP).setScale(2, BigDecimal.ROUND_HALF_UP).stripTrailingZeros().toPlainString();
// BigDecimal noriginalcurprice2 = null;//无税单价
@ -1237,7 +1237,7 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
//平台优惠
if (sonDetailsDto.getVdef4() != null && !"".equals(sonDetailsDto.getVdef4())) {
BigDecimal bigDecimalVdef4 = new BigDecimal(sonDetailsDto.getVdef4());
if (bigDecimalVdef4.compareTo(BigDecimal.ZERO) > 0) {
if (bigDecimalVdef4.compareTo(BigDecimal.ZERO) != 0) {
//发货运费-存货基本档案
BdInvbasdocEntity bdInvbasdocEntity1 = mapBdInvbasdocEntity.get("FY01");
//存货管理档案
@ -1251,7 +1251,7 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
//达人优惠
if (sonDetailsDto.getVdef6() != null && !"".equals(sonDetailsDto.getVdef6())) {
BigDecimal bigDecimalVdef6 = new BigDecimal(sonDetailsDto.getVdef6());
if (bigDecimalVdef6.compareTo(BigDecimal.ZERO) > 0) {
if (bigDecimalVdef6.compareTo(BigDecimal.ZERO) != 0) {
//发货运费-存货基本档案
BdInvbasdocEntity bdInvbasdocEntity1 = mapBdInvbasdocEntity.get("FY02");
//存货管理档案
@ -1265,7 +1265,7 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
//支付优惠
if (sonDetailsDto.getVdef5() != null && !"".equals(sonDetailsDto.getVdef5())) {
BigDecimal bigDecimalVdef5 = new BigDecimal(sonDetailsDto.getVdef5());
if (bigDecimalVdef5.compareTo(BigDecimal.ZERO) > 0) {
if (bigDecimalVdef5.compareTo(BigDecimal.ZERO) != 0) {
//发货运费-存货基本档案
BdInvbasdocEntity bdInvbasdocEntity1 = mapBdInvbasdocEntity.get("FY04");
//存货管理档案
@ -2361,7 +2361,7 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
//判断是否增加邮费这个存货accumulatedPostage
BigDecimal accumulatedPostage = checkPostageFee(oldValue);
if (accumulatedPostage.compareTo(BigDecimal.ZERO) > 0) {
if (accumulatedPostage.compareTo(BigDecimal.ZERO) != 0) {
//获取平台运费对应的税率
// String tax2 = "0." + new BigDecimal(bdTaxitemsEntity.getTaxratio()).stripTrailingZeros().toPlainString();
// BigDecimal noriginalcurprice2 = null;//无税单价
@ -2428,7 +2428,7 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
//平台优惠
if (sonDetailsDto.getVdef4() != null && !"".equals(sonDetailsDto.getVdef4())) {
BigDecimal bigDecimalVdef4 = new BigDecimal(sonDetailsDto.getVdef4());
if (bigDecimalVdef4.compareTo(BigDecimal.ZERO) > 0) {
if (bigDecimalVdef4.compareTo(BigDecimal.ZERO) != 0) {
//发货运费-存货基本档案
BdInvbasdocEntity bdInvbasdocEntity1 = mapBdInvbasdocEntity.get("FY01");
//存货管理档案
@ -2444,7 +2444,7 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
//达人优惠
if (sonDetailsDto.getVdef6() != null && !"".equals(sonDetailsDto.getVdef6())) {
BigDecimal bigDecimalVdef6 = new BigDecimal(sonDetailsDto.getVdef6());
if (bigDecimalVdef6.compareTo(BigDecimal.ZERO) > 0) {
if (bigDecimalVdef6.compareTo(BigDecimal.ZERO) != 0) {
//发货运费-存货基本档案
BdInvbasdocEntity bdInvbasdocEntity1 = mapBdInvbasdocEntity.get("FY02");
//存货管理档案
@ -2460,7 +2460,7 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
//支付优惠
if (sonDetailsDto.getVdef5() != null && !"".equals(sonDetailsDto.getVdef5())) {
BigDecimal bigDecimalVdef5 = new BigDecimal(sonDetailsDto.getVdef5());
if (bigDecimalVdef5.compareTo(BigDecimal.ZERO) > 0) {
if (bigDecimalVdef5.compareTo(BigDecimal.ZERO) != 0) {
//发货运费-存货基本档案
BdInvbasdocEntity bdInvbasdocEntity1 = mapBdInvbasdocEntity.get("FY04");
//存货管理档案
@ -2705,7 +2705,7 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
//平台优惠
if (sonDetailsDto.getVdef4() != null && !"".equals(sonDetailsDto.getVdef4())) {
BigDecimal bigDecimalVdef4 = new BigDecimal(sonDetailsDto.getVdef4());
if (bigDecimalVdef4.compareTo(BigDecimal.ZERO) > 0) {
if (bigDecimalVdef4.compareTo(BigDecimal.ZERO) != 0) {
//发货运费-存货基本档案
BdInvbasdocEntity bdInvbasdocEntity1 = mapBdInvbasdocEntity.get("FY01");
//存货管理档案
@ -2719,7 +2719,7 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
//达人优惠
if (sonDetailsDto.getVdef6() != null && !"".equals(sonDetailsDto.getVdef6())) {
BigDecimal bigDecimalVdef6 = new BigDecimal(sonDetailsDto.getVdef6());
if (bigDecimalVdef6.compareTo(BigDecimal.ZERO) > 0) {
if (bigDecimalVdef6.compareTo(BigDecimal.ZERO) != 0) {
//发货运费-存货基本档案
BdInvbasdocEntity bdInvbasdocEntity1 = mapBdInvbasdocEntity.get("FY02");
//存货管理档案
@ -2733,7 +2733,7 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
//支付优惠
if (sonDetailsDto.getVdef5() != null && !"".equals(sonDetailsDto.getVdef5())) {
BigDecimal bigDecimalVdef5 = new BigDecimal(sonDetailsDto.getVdef5());
if (bigDecimalVdef5.compareTo(BigDecimal.ZERO) > 0) {
if (bigDecimalVdef5.compareTo(BigDecimal.ZERO) != 0) {
//发货运费-存货基本档案
BdInvbasdocEntity bdInvbasdocEntity1 = mapBdInvbasdocEntity.get("FY04");
//存货管理档案

View File

@ -140,7 +140,9 @@ public class QueryAdditionUtil {
saleorderRequestChildrenDto1.setCinventorycode(bdInvbasdocEntity1.getInvcode());
//价税合计
saleorderRequestChildrenDto1.setNoriginalcursummny(noriginalcursummny.setScale(2, BigDecimal.ROUND_HALF_UP).stripTrailingZeros().toPlainString());
BigDecimal noriginalcursummnyRounding2 = noriginalcursummny.setScale(2, BigDecimal.ROUND_HALF_UP);
String noriginalcursummnyStr = noriginalcursummnyRounding2.stripTrailingZeros().toPlainString();
saleorderRequestChildrenDto1.setNoriginalcursummny(noriginalcursummnyStr);
//数量
saleorderRequestChildrenDto1.setNnumber(nnumber);
@ -157,7 +159,11 @@ public class QueryAdditionUtil {
//是否赠品
saleorderRequestChildrenDto1.setBlargessflag(false);
saleorderRequestChildrenDtoList.add(saleorderRequestChildrenDto1);
//2025年2月17日 10:37:37 如果四舍五入保留2位后如果为0则不推送U8C处理0.0033保留2位为0的问题
//和李佳妮还有丽知-山海沟通确定的
if (noriginalcursummnyRounding2.compareTo(BigDecimal.ZERO) != 0) {
saleorderRequestChildrenDtoList.add(saleorderRequestChildrenDto1);
}
}
}
}

View File

@ -107,8 +107,8 @@ class SoSaleOutPluginInitializerToCTest {
// ofsStandardUtil.getOfsSaleOrder(queryOfsSoSaleOutVo, headerDetailsDtoArrayList, 1L);
// System.out.println(headerDetailsDtoArrayList.get(0).getHeader().getDepartmentType());
// String s = "LETS-SH2024101700000270";
// soSaleOutPluginInitializerToC.startImplementStockByCode(s, "stock");
String s = "LETS-SH2024101000026031";
soSaleOutPluginInitializerToC.startImplementStockByCode(s, "tran");
try {
// soSaleOutPluginInitializerToC.startImplementStockByTime("2024-10-18 00:00:00", "2024-10-18 23:59:59");
@ -146,29 +146,29 @@ class SoSaleOutPluginInitializerToCTest {
e.printStackTrace();
}
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
Thread currentThread = Thread.currentThread();
try {
while (true) {
Thread.currentThread().sleep(1000);
long start = System.currentTimeMillis();
currentThread.setName("线程名称:" + UUID.fastUUID());
long end = System.currentTimeMillis();
System.out.println("耗时:" + (end - start));
}
} catch (Exception e) {
e.printStackTrace();
}
}
}, "线程1");
thread.start();
while (true) {
Thread.currentThread().sleep(1000);
System.out.println(thread.getName());
}
// Thread thread = new Thread(new Runnable() {
// @Override
// public void run() {
// Thread currentThread = Thread.currentThread();
// try {
// while (true) {
// Thread.currentThread().sleep(1000);
//
// long start = System.currentTimeMillis();
// currentThread.setName("线程名称:" + UUID.fastUUID());
// long end = System.currentTimeMillis();
// System.out.println("耗时:" + (end - start));
// }
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
// }, "线程1");
// thread.start();
//
// while (true) {
// Thread.currentThread().sleep(1000);
// System.out.println(thread.getName());
// }
}
}