浏览代码

订单改价

ct 4 天之前
父节点
当前提交
e4a4ecda0c

+ 2 - 1
fs-service-system/src/main/java/com/fs/store/param/FsStoreOrderCreateParam.java

@@ -35,7 +35,7 @@ public class FsStoreOrderCreateParam implements Serializable
 
     @ApiModelProperty(value = "使用积分 1使用")
     private Integer useIntegral;
-    private BigDecimal payPrice;
+    private BigDecimal payPrice; //制单 改价 订单总价
     private Long paymentId;
 
     @ApiModelProperty(value = "优惠券")
@@ -50,4 +50,5 @@ public class FsStoreOrderCreateParam implements Serializable
 
     private Long customerId;
 
+    private BigDecimal amount; //货到付款代收金额
 }

+ 2 - 2
fs-service-system/src/main/java/com/fs/store/param/FsStoreOrderCreateUserParam.java

@@ -27,7 +27,7 @@ public class FsStoreOrderCreateUserParam implements Serializable
     @NotNull(message = "付款方式不能为空")
     private Integer payType;
     private Long paymentId;
-    private BigDecimal payPrice;
+    private BigDecimal payPrice; //改价 订单总价
     private Long customerId;
-
+    private BigDecimal amount; //货到付款代收金额
 }

+ 27 - 11
fs-service-system/src/main/java/com/fs/store/service/impl/FsStoreOrderServiceImpl.java

@@ -552,21 +552,34 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService
                 storeOrder.setServiceFee(config.getServiceFee());
             }
 
+            //后台制单处理
+            if(param.getPayPrice()!=null&&param.getPayPrice().compareTo(BigDecimal.ZERO)>0){
+                if (param.getPayPrice().compareTo(dto.getTotalPrice()) > 0) {
+                    return R.error("改价价格不能大于商品总价");
+                }
+                storeOrder.setPayPrice(param.getPayPrice());
+            }
+            else{
+                storeOrder.setPayPrice(dto.getPayPrice());
+            }
 
+            //付款方式
             if(param.getPayType().equals("1")){
                 //全款支付
                 storeOrder.setStatus(0);
             }
             else if(param.getPayType().equals("2")){
-                //货到付款
+                //物流代收
                 storeOrder.setStatus(1);
             }
-            //后台制单处理
-            if(param.getPayPrice()!=null&&param.getPayPrice().compareTo(BigDecimal.ZERO)>0){
-                storeOrder.setPayPrice(param.getPayPrice());
-            }
-            else{
-                storeOrder.setPayPrice(dto.getPayPrice());
+            else if(param.getPayType().equals("3")){
+                //货到付款
+                storeOrder.setStatus(1);
+                BigDecimal amount = param.getAmount();  //货到付款 自定义代收金额
+                if (amount != null && amount.compareTo(BigDecimal.ZERO) > 0){
+                    storeOrder.setPayMoney(amount);
+                    storeOrder.setPayDelivery(storeOrder.getPayPrice().subtract(amount) );
+                }
             }
             storeOrder.setOrderCreateType(param.getOrderCreateType());
             Long prescribe = carts.stream().filter(item -> item.getProductType()!=null&&item.getProductType()==2).count();
@@ -654,7 +667,9 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService
             //添加支付到期时间
             Calendar calendar = Calendar.getInstance();
             calendar.setTime(storeOrder.getCreateTime());
-            calendar.add(Calendar.MINUTE,config.getUnPayTime());
+            if (config.getUnPayTime() != null){
+                calendar.add(Calendar.MINUTE,config.getUnPayTime());
+            }
             SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
             String payLimitTime = format.format(calendar.getTime() );
             //删除推荐订单KEY
@@ -981,6 +996,7 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService
             createParam.setPaymentId(param.getPaymentId());
             createParam.setPayPrice(param.getPayPrice());
             createParam.setCustomerId(param.getCustomerId());
+            createParam.setAmount(param.getAmount());
             return this.createOrder(param.getUserId(),createParam);
         }
         else{
@@ -2041,9 +2057,9 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService
         if(money==null){
             return R.error("请输入价格");
         }
-        if(money.compareTo(BigDecimal.ZERO)<=0){
-            return R.error("价格应大于0");
-        }
+//        if(money.compareTo(BigDecimal.ZERO)<=0){
+//            return R.error("价格应大于0");
+//        }
         String key=redisCache.getCacheObject("createOrderKey:"+createOrderKey);
         if (StringUtils.isEmpty(key)) {
             throw new CustomException("订单已过期",501);