|
@@ -8,7 +8,6 @@ import com.caimei.modules.order.entity.*;
|
|
|
import com.caimei.modules.order.utils.Disguiser;
|
|
|
import com.caimei.redis.RedisService;
|
|
|
import com.caimei.utils.MathUtil;
|
|
|
-import com.google.common.util.concurrent.AtomicDouble;
|
|
|
import com.thinkgem.jeesite.common.service.BaseService;
|
|
|
import okhttp3.*;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
@@ -63,11 +62,19 @@ public class SplitAccountService extends BaseService {
|
|
|
AtomicReference<Double> costPrice = new AtomicReference<Double>(0d);
|
|
|
AtomicReference<Double> cmCostPrice = new AtomicReference<Double>(0d);
|
|
|
AtomicReference<Double> organizeCostPrice = new AtomicReference<Double>(0d);
|
|
|
+ AtomicReference<Double> total = new AtomicReference<Double>(0d);
|
|
|
// 收款对应的订单信息
|
|
|
ShopOrderVo shopOrder = newOrderDao.getShopOrderListByOrderId(Integer.valueOf(i));
|
|
|
for (OrderReceiptRelationPo orderRelation : orderRelations) {
|
|
|
logger.info("【分账】>>>>>>>>>>子订单id:" + orderRelation.getShopOrderId() + "进入分账");
|
|
|
- setSplitAccountDetail(costPrice, organizeCostPrice, cmCostPrice, shopOrder, orderRelation);
|
|
|
+ setSplitAccountDetail(costPrice, organizeCostPrice, cmCostPrice, total, shopOrder, orderRelation);
|
|
|
+ }
|
|
|
+ if (MathUtil.compare(total, MathUtil.add(MathUtil.add(costPrice, cmCostPrice), organizeCostPrice)) <= 0) {
|
|
|
+ logger.info("收款总金额不足分帐------------->total: " + total.get()
|
|
|
+ + "costPrice: " + costPrice.get() + "----------"
|
|
|
+ + "cmCostPrice: " + cmCostPrice.get() + "-------------"
|
|
|
+ + "organizeCostPrice: " + organizeCostPrice.get() + "---------------");
|
|
|
+ return;
|
|
|
}
|
|
|
/**
|
|
|
* 线上订单,付第三方如果不为0,需要从供应商成本中支付
|
|
@@ -235,7 +242,7 @@ public class SplitAccountService extends BaseService {
|
|
|
accountPayOrder.setP3_timestamp(format1);
|
|
|
String substring = format1.substring(20);
|
|
|
// fz+当前微秒时间+原唯一订单号
|
|
|
- accountPayOrder.setP4_orderId("FZ" + substring + shopOrder.getShopOrderNo());
|
|
|
+ accountPayOrder.setP4_orderId("FZ" + substring + shopOrder.getShopOrderId());
|
|
|
//付款账户子订单绑定商户号
|
|
|
accountPayOrder.setP5_customerNumber(shopOrder.getSplitCode());
|
|
|
AccountPayOrder.AccountPayOrderExt accountPayOrderExt = new AccountPayOrder.AccountPayOrderExt();
|
|
@@ -290,9 +297,11 @@ public class SplitAccountService extends BaseService {
|
|
|
|
|
|
|
|
|
public void setSplitAccountDetail(AtomicReference<Double> costPrice, AtomicReference<Double> organizePrice,
|
|
|
- AtomicReference<Double> cmCostPrice, ShopOrderVo shopOrder, OrderReceiptRelationPo orderRelation) {
|
|
|
+ AtomicReference<Double> cmCostPrice, AtomicReference<Double> total,
|
|
|
+ ShopOrderVo shopOrder, OrderReceiptRelationPo orderRelation) {
|
|
|
// 待分账总金额
|
|
|
double splitAmount = orderRelation.getAssociateAmount();
|
|
|
+ total.updateAndGet(v -> MathUtil.add(v, splitAmount).doubleValue());
|
|
|
// 总手续费
|
|
|
double procedureFee;
|
|
|
if (12 == orderRelation.getPayType()) {
|