ソースを参照

fix 订单支付金额

he2802 4 年 前
コミット
07e69378fc

+ 4 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/order/domain/Order.java

@@ -58,7 +58,7 @@ private static final long serialVersionUID=1L;
     /** 支付时间 */
     private Long payTime;
 
-    /** 支付平台 1微信 2支付宝 */
+    /** 支付平台 1微信 2支付宝 3金币*/
     private Integer payType;
 
     /** 微信流水号 */
@@ -85,4 +85,7 @@ private static final long serialVersionUID=1L;
     @TableField(exist = false)
     private String nickname;
 
+    /** 支付价格 */
+    private BigDecimal payPrice;
+
 }

+ 13 - 4
zhongzheng-system/src/main/java/com/zhongzheng/modules/order/service/impl/OrderServiceImpl.java

@@ -239,6 +239,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
         add.setPayType(3); //金币支付
         add.setOrderType(2);
         BigDecimal totalPrice = new BigDecimal(0);
+        BigDecimal payPrice = new BigDecimal(0);
         Boolean couponBool = true;
         for (OrderGoodsAddBo g : goodsList) {
             g.setOrderSn(out_trade_no);
@@ -303,7 +304,8 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
                     throw new CustomException("优惠券数据错误");
                 }
             }
-
+            //订单价格不计算优惠
+            totalPrice = totalPrice.add(g.getGoodsPrice());
             //查詢該活動是否使用於此課程上
             if(activity!=null&&activity >0 && g.getGoodsType()==1 && activityConfigurationService.selectCount(g.getGoodsId(),activity) > 0 ){
                 //使用活動
@@ -331,7 +333,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
                 }
             }
 
-            totalPrice = totalPrice.add(g.getGoodsPrice());
+            payPrice = payPrice.add(g.getGoodsPrice());
 
         }
         BigDecimal zero = new BigDecimal("0.01");
@@ -341,10 +343,16 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
         }
         add.setOrderPrice(totalPrice);
 
-        if(userVo.getMoney().compareTo(totalPrice) < 0){
+        if(payPrice.compareTo(zero) < 0){
+            //价格不能小于0.01
+            payPrice = zero;
+        }
+        add.setPayPrice(payPrice);
+
+        if(userVo.getMoney().compareTo(payPrice) < 0){
             throw new CustomException("金币不足");
         }
-        userVo.setMoney(userVo.getMoney().subtract(totalPrice));
+        userVo.setMoney(userVo.getMoney().subtract(payPrice));
         add.setOrderStatus(0);
         if(!this.save(add)){
             throw new CustomException("订单数据错误");
@@ -459,6 +467,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
         }
 
         add.setOrderPrice(totalPrice);
+        add.setPayPrice(totalPrice);
         if(!this.save(add)){
             throw new CustomException("订单数据错误");
         }

+ 7 - 2
zhongzheng-system/src/main/java/com/zhongzheng/modules/order/vo/OrderVo.java

@@ -50,8 +50,8 @@ public class OrderVo {
 	@ApiModelProperty("支付时间")
 	private Long payTime;
 	/** 支付平台 1微信 2支付宝 */
-	@Excel(name = "支付平台 1微信 2支付宝")
-	@ApiModelProperty("支付平台 1微信 2支付宝")
+	@Excel(name = "支付平台 1微信 2支付宝 3金币")
+	@ApiModelProperty("支付平台 1微信 2支付宝 3金币")
 	private Integer payType;
 	/** 微信流水号 */
 	@Excel(name = "微信流水号")
@@ -70,4 +70,9 @@ public class OrderVo {
 	@Excel(name = "订单类型")
 	@ApiModelProperty("订单类型 1充值订单 2消费订单")
 	private Integer orderType;
+
+	/** 支付价格 */
+	@Excel(name = "支付价格")
+	@ApiModelProperty("支付价格")
+	private BigDecimal payPrice;
 }