|
|
@@ -886,45 +886,9 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
|
|
|
if (param.getPayType().equals("1")) {
|
|
|
//全款支付
|
|
|
storeOrder.setStatus(0);
|
|
|
- FsCompanyExternalPayReceipt receipt = param.getReceipt();
|
|
|
- if (param.getCompanyCustomerId() != null && receipt != null) {
|
|
|
- int compareTo = receipt.getTotalFee().compareTo(storeOrder.getPayPrice());
|
|
|
- //部分抵扣 把订单总金额减去收款金额
|
|
|
- if (compareTo < 0) {
|
|
|
- storeOrder.setTotalPrice(storeOrder.getTotalPrice().subtract(receipt.getTotalFee()));
|
|
|
- storeOrder.setPayPrice(storeOrder.getPayPrice().subtract(receipt.getTotalFee()));
|
|
|
- storeOrder.setDeductionPrice(receipt.getTotalFee());
|
|
|
- }
|
|
|
- //全部抵扣需把支付金额改成订单总金额
|
|
|
- if (compareTo >= 0) {
|
|
|
- storeOrder.setPaid(1);
|
|
|
- storeOrder.setStatus(1);
|
|
|
- storeOrder.setPayPrice(new BigDecimal(0));
|
|
|
- storeOrder.setDeductionPrice(receipt.getTotalFee());
|
|
|
- storeOrder.setPayMoney(storeOrder.getTotalPrice());
|
|
|
- }
|
|
|
- }
|
|
|
} else if (param.getPayType().equals("2")) {
|
|
|
//物流代收
|
|
|
storeOrder.setStatus(1);
|
|
|
- FsCompanyExternalPayReceipt receipt = param.getReceipt();
|
|
|
- if (param.getCompanyCustomerId() != null && receipt != null) {
|
|
|
- int compareTo = receipt.getTotalFee().compareTo(storeOrder.getPayPrice());
|
|
|
- if (compareTo < 0) {
|
|
|
- storeOrder.setTotalPrice(storeOrder.getTotalPrice().subtract(receipt.getTotalFee()));
|
|
|
- storeOrder.setPayPrice(storeOrder.getPayPrice().subtract(receipt.getTotalFee()));
|
|
|
- storeOrder.setDeductionPrice(receipt.getTotalFee());
|
|
|
- }
|
|
|
- if (compareTo >= 0) {
|
|
|
- storeOrder.setPayMoney(storeOrder.getTotalPrice());
|
|
|
- storeOrder.setPayPrice(new BigDecimal(0));
|
|
|
- storeOrder.setDeductionPrice(receipt.getTotalFee());
|
|
|
- //全部抵扣 支付类型改成全款支付
|
|
|
- storeOrder.setPayType("1");
|
|
|
- }
|
|
|
- storeOrder.setPaid(1);
|
|
|
- }
|
|
|
-
|
|
|
} else if (param.getPayType().equals("3")) {
|
|
|
//货到付款
|
|
|
BigDecimal amount = param.getAmount(); //货到付款 自定义代收金额
|
|
|
@@ -936,6 +900,55 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
|
|
|
storeOrder.setStatus(1);
|
|
|
}
|
|
|
}
|
|
|
+ FsCompanyExternalPayReceipt receipt = param.getReceipt();
|
|
|
+ if (param.getCompanyCustomerId() != null) {
|
|
|
+ //预付金
|
|
|
+ if (param.getPayType().equals("5")) {
|
|
|
+ boolean b = param.getPrepaidAmount().compareTo(storeOrder.getTotalPrice()) >= 0;
|
|
|
+ if (b) {
|
|
|
+ return R.error("定金不能大于等于订单总价");
|
|
|
+ }
|
|
|
+ storeOrder.setStatus(0);
|
|
|
+ storeOrder.setPayPrice(param.getPrepaidAmount());
|
|
|
+ storeOrder.setPayType("2");
|
|
|
+ }
|
|
|
+ if (receipt != null) {
|
|
|
+ int compareTo = receipt.getTotalFee().compareTo(storeOrder.getPayPrice());
|
|
|
+ if(param.getPayType().equals("1")) {
|
|
|
+ //全款
|
|
|
+ if (compareTo < 0) {
|
|
|
+ storeOrder.setTotalPrice(storeOrder.getTotalPrice().subtract(receipt.getTotalFee()));
|
|
|
+ storeOrder.setPayPrice(storeOrder.getPayPrice().subtract(receipt.getTotalFee()));
|
|
|
+ storeOrder.setDeductionPrice(receipt.getTotalFee());
|
|
|
+ storeOrder.setStatus(0);
|
|
|
+ } else {
|
|
|
+ storeOrder.setPayMoney(storeOrder.getTotalPrice());
|
|
|
+ storeOrder.setPayPrice(new BigDecimal(0));
|
|
|
+ storeOrder.setDeductionPrice(receipt.getTotalFee());
|
|
|
+ storeOrder.setPaid(1);
|
|
|
+ storeOrder.setStatus(1);
|
|
|
+ }
|
|
|
+ } else if (param.getPayType().equals("2")) {
|
|
|
+ //物流代收
|
|
|
+ if (compareTo < 0) {
|
|
|
+ storeOrder.setTotalPrice(storeOrder.getTotalPrice().subtract(receipt.getTotalFee()));
|
|
|
+ storeOrder.setPayPrice(storeOrder.getPayPrice().subtract(receipt.getTotalFee()));
|
|
|
+ storeOrder.setPayMoney(receipt.getTotalFee());
|
|
|
+ storeOrder.setDeductionPrice(receipt.getTotalFee());
|
|
|
+ storeOrder.setStatus(1);
|
|
|
+ } else {
|
|
|
+ storeOrder.setPayType("1");
|
|
|
+ storeOrder.setPayMoney(storeOrder.getTotalPrice());
|
|
|
+ }
|
|
|
+ storeOrder.setPaid(1);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //物理代收付款
|
|
|
+ if (param.getPayType().equals("2")) {
|
|
|
+ storeOrder.setPaid(1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
Boolean isPay = true;
|
|
|
if (param.getOrderCreateType() != null && param.getOrderCreateType() == 3 && param.getCompanyId() != null) {
|
|
|
//后台制单 判断是否需要付款
|
|
|
@@ -1697,6 +1710,7 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
|
|
|
.isPay(0)
|
|
|
.isDel(0)
|
|
|
.isBuy(0)
|
|
|
+ .type("gift")
|
|
|
.build();
|
|
|
storeCart.setCreateTime(new Date());
|
|
|
cartService.checkProductStock(giftProduct.getProductId(), storeCart.getProductAttrValueId());
|
|
|
@@ -1725,6 +1739,7 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
|
|
|
createParam.setOrderMedium(param.getOrderMedium()); //后台制单
|
|
|
createParam.setReceipt(receipt);//收款信息
|
|
|
createParam.setCompanyCustomerId(param.getCompanyCustomerId());
|
|
|
+ createParam.setPrepaidAmount(param.getPrepaidAmount());//预付金额
|
|
|
return this.createOrder(param.getUserId(), createParam);
|
|
|
} else {
|
|
|
throw new CustomException("创建失败");
|
|
|
@@ -3419,7 +3434,9 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
|
|
|
|
|
|
if ("truePrice".equals(key)) {
|
|
|
for (FsStoreCartQueryVO storeCart : cartInfo) {
|
|
|
- sumPrice = NumberUtil.add(sumPrice, NumberUtil.mul(storeCart.getCartNum(), storeCart.getPrice()));
|
|
|
+ if ("product".equals(storeCart.getType())) {
|
|
|
+ sumPrice = NumberUtil.add(sumPrice, NumberUtil.mul(storeCart.getCartNum(), storeCart.getPrice()));
|
|
|
+ }
|
|
|
}
|
|
|
} else if ("costPrice".equals(key)) {
|
|
|
for (FsStoreCartQueryVO storeCart : cartInfo) {
|
|
|
@@ -4320,7 +4337,9 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Throwable.class,propagation = Propagation.REQUIRED)
|
|
|
public R pay(FsStoreOrderPayParam param) {
|
|
|
+ logger.info("开始支付,参数:{}",param);
|
|
|
FsStoreOrderScrm order=this.selectFsStoreOrderById(param.getOrderId());
|
|
|
+ logger.info("订单信息:{}",order);
|
|
|
if(order==null){
|
|
|
return R.error("订单不存在");
|
|
|
}
|
|
|
@@ -4366,10 +4385,16 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
|
|
|
}
|
|
|
else if(param.getPayType().equals(2)){
|
|
|
order.setPayType("2");
|
|
|
- BigDecimal payMoney=order.getPayPrice().multiply(new BigDecimal(storeConfig.getPayRate())).divide(new BigDecimal(100));
|
|
|
- payMoney=new BigDecimal(payMoney.setScale(0, BigDecimal.ROUND_HALF_UP).longValue());
|
|
|
- order.setPayDelivery(order.getPayPrice().subtract(payMoney));
|
|
|
- order.setPayMoney(payMoney);
|
|
|
+ if (order.getCompanyCustomerId() == null) {
|
|
|
+ BigDecimal payMoney=order.getPayPrice().multiply(new BigDecimal(storeConfig.getPayRate())).divide(new BigDecimal(100));
|
|
|
+ payMoney=new BigDecimal(payMoney.setScale(0, BigDecimal.ROUND_HALF_UP).longValue());
|
|
|
+ order.setPayDelivery(order.getPayPrice().subtract(payMoney));
|
|
|
+ order.setPayMoney(payMoney);
|
|
|
+ }else {
|
|
|
+ order.setPayMoney(order.getPayPrice());
|
|
|
+ order.setPayDelivery(order.getTotalPrice().subtract(order.getPayMoney()));
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
else if(param.getPayType().equals(3)){
|
|
|
//货到付款
|
|
|
@@ -4857,11 +4882,15 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
|
|
|
}
|
|
|
else if(param.getPayType().equals(2)){
|
|
|
|
|
|
- order.setPayType("2");
|
|
|
- BigDecimal payMoney=order.getPayPrice().multiply(new BigDecimal(storeConfig.getPayRate())).divide(new BigDecimal(100));
|
|
|
- payMoney=new BigDecimal(payMoney.setScale(0, BigDecimal.ROUND_HALF_UP).longValue());
|
|
|
- order.setPayDelivery(order.getPayPrice().subtract(payMoney));
|
|
|
- order.setPayMoney(payMoney);
|
|
|
+ if (order.getCompanyCustomerId() == null) {
|
|
|
+ BigDecimal payMoney=order.getPayPrice().multiply(new BigDecimal(storeConfig.getPayRate())).divide(new BigDecimal(100));
|
|
|
+ payMoney=new BigDecimal(payMoney.setScale(0, BigDecimal.ROUND_HALF_UP).longValue());
|
|
|
+ order.setPayDelivery(order.getPayPrice().subtract(payMoney));
|
|
|
+ order.setPayMoney(payMoney);
|
|
|
+ }else {
|
|
|
+ order.setPayMoney(order.getPayPrice());
|
|
|
+ order.setPayDelivery(order.getTotalPrice().subtract(order.getPayMoney()));
|
|
|
+ }
|
|
|
}
|
|
|
else if(param.getPayType().equals(3)){
|
|
|
//货到付款
|