|
@@ -21,6 +21,7 @@ import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
+import java.util.concurrent.atomic.AtomicInteger;
|
|
|
import java.util.concurrent.atomic.AtomicReference;
|
|
|
|
|
|
|
|
@@ -142,7 +143,6 @@ public class PayShopServiceImpl implements PayShopService {
|
|
|
|
|
|
orderPayShop.setPayTime(DateUtils.getDateTime());
|
|
|
orderPayShop.setStatus(1);
|
|
|
- log.info("orderPayShop--------------------"+orderPayShop);
|
|
|
payShopDao.updatePayShop(orderPayShop);
|
|
|
return ResponseJson.success();
|
|
|
} else {
|
|
@@ -256,6 +256,7 @@ public class PayShopServiceImpl implements PayShopService {
|
|
|
log.info("【分账】>>>>>>>>>>子订单id:" + s + "进入分账");
|
|
|
// 收款对应的订单信息
|
|
|
NewShopOrder shopOrder = newOrderDao.getShopOrderListByOrderId(orderRelation.getShopOrderId());
|
|
|
+ orderUtils.getShouldPay(shopOrder);
|
|
|
PayParamBo payParam = new PayParamBo();
|
|
|
//支付金额
|
|
|
payParam.setAllPay(orderRelation.getAssociateAmount());
|
|
@@ -327,11 +328,12 @@ public class PayShopServiceImpl implements PayShopService {
|
|
|
Double paidAmount = newOrderDao.getPaidShopAmount(shopOrderId);
|
|
|
Double paidShop = MathUtil.add(paidAmount, splitAmount).doubleValue();
|
|
|
shopOrder.setPayedShopAmount(paidShop);
|
|
|
- if (MathUtil.compare(shopOrder.getShouldPayShopAmount(), paidShop) == 0) {
|
|
|
+ //todo
|
|
|
+// if (MathUtil.compare(shopOrder.getShouldPayShopAmount(), paidShop) == 0) {
|
|
|
shopOrder.setPayStatus(3);
|
|
|
- } else {
|
|
|
- shopOrder.setPayStatus(2);
|
|
|
- }
|
|
|
+// } else {
|
|
|
+// shopOrder.setPayStatus(2);
|
|
|
+// }
|
|
|
// 修改子订单付款状态及付款金额
|
|
|
newOrderDao.updateShopOrderByPayStatus(shopOrderId, paidShop, shopOrder.getPayStatus());
|
|
|
}
|
|
@@ -390,6 +392,27 @@ public class PayShopServiceImpl implements PayShopService {
|
|
|
@Override
|
|
|
public ResponseJson settleShopOrders(OrderPayShopDetail payShop) {
|
|
|
List<NewShopOrder> shopOrders = payShop.getShopOrders();
|
|
|
+ AtomicInteger flag = new AtomicInteger();
|
|
|
+ shopOrders.forEach(o -> {
|
|
|
+ Calendar instance = Calendar.getInstance();
|
|
|
+ int weekIdx = instance.get(Calendar.DAY_OF_WEEK) - 1;
|
|
|
+ String form = new SimpleDateFormat("HH:mm:ss").format(new Date());
|
|
|
+ Integer sub = Integer.valueOf(form.substring(0, 2));
|
|
|
+ //当前时间周五下午到周日都返回1不能结算,其他时间看够不够24小时
|
|
|
+ if ((5 == weekIdx && sub > 14) || 6 == weekIdx || 7 == weekIdx) {
|
|
|
+ flag.set(1);
|
|
|
+ return;
|
|
|
+ } else {
|
|
|
+ Integer val = payShopDao.getSplitTime(o.getShopOrderId());
|
|
|
+ if (val <= 0) {
|
|
|
+ flag.set(1);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ if (1 == flag.get()) {
|
|
|
+ return ResponseJson.error("当前时间为周五下午到周日,或分账完成时间不足24小时,无法结算!");
|
|
|
+ }
|
|
|
String format = new SimpleDateFormat("yyyy-MM-dd_HH:mm:ss.SSS").format(new Date());
|
|
|
String substring = format.substring(20);
|
|
|
shopOrders.forEach(s -> {
|
|
@@ -403,9 +426,9 @@ public class PayShopServiceImpl implements PayShopService {
|
|
|
});
|
|
|
NewShopOrder shopOrder = newShopOrderDao.findColdChainShopOrder(shopOrders.get(0).getOrderId());
|
|
|
// 联合丽格冷链费
|
|
|
- if (null != shopOrder && 1 == shopOrder.getIsColdChina() && shopOrder.getShopPostFee() >= 700) {
|
|
|
+ if (null != shopOrder && 1 == shopOrder.getIsColdChina() && shopOrder.getShopPostFee() >= 0) {
|
|
|
try {
|
|
|
- orderUtils.settleOrder("JSLLF" + shopOrder.getShopOrderId() + substring, 700d, Constant.LHLGCUSTOMERNUM, shopOrder.getShopOrderId(), 6);
|
|
|
+ orderUtils.settleOrder("JSLLF" + shopOrder.getShopOrderId() + substring, shopOrder.getShopPostFee(), Constant.LHLGCUSTOMERNUM, shopOrder.getShopOrderId(), 6);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
@@ -533,10 +556,8 @@ public class PayShopServiceImpl implements PayShopService {
|
|
|
// 子订单商品成本
|
|
|
AtomicReference<BigDecimal> totalCostPrice = new AtomicReference<>();
|
|
|
for (NewOrderProduct orderProduct : orderProductList) {
|
|
|
- // 售价 * 数量 = 总价
|
|
|
- BigDecimal total = MathUtil.mul(orderProduct.getPrice(), orderProduct.getNum());
|
|
|
// 总价 * 供应商百分比 = 成本分账金额
|
|
|
- double costPrice = MathUtil.mul(total, MathUtil.div(orderProduct.getShopPercent(), 100)).doubleValue();
|
|
|
+ double costPrice = MathUtil.mul(orderProduct.getTotalAmount(), MathUtil.div(orderProduct.getShopPercent(), 100)).doubleValue();
|
|
|
// 供应商承担手续费 ,减去手续费
|
|
|
String payType = payParam.getPayType();
|
|
|
double charge = 0d;
|
|
@@ -560,8 +581,9 @@ public class PayShopServiceImpl implements PayShopService {
|
|
|
charge = Math.max(MathUtil.mul(splitAmount, 0.006, 2).doubleValue(), 0.1);
|
|
|
}
|
|
|
costPrice = costPrice - charge;
|
|
|
+ splitAmount = splitAmount - charge;
|
|
|
totalCostPrice.set(MathUtil.add(costPrice, totalCostPrice.get()));
|
|
|
- double organize = MathUtil.mul(total, MathUtil.div(orderProduct.getOrganizePercent(), 100), 2).doubleValue();
|
|
|
+ double organize = MathUtil.mul(orderProduct.getTotalAmount(), MathUtil.div(orderProduct.getOrganizePercent(), 100), 2).doubleValue();
|
|
|
totalOrganize.set(MathUtil.add(organize, totalOrganize.get()));
|
|
|
/**
|
|
|
* todo
|