Bläddra i källkod

订单增加代金券信息

Memory_LG 3 veckor sedan
förälder
incheckning
49c7e80be7

+ 22 - 0
qmjszx-admin/src/main/java/beilv/web/controller/carinformation/CardAppController.java

@@ -10,6 +10,7 @@ import beilv.common.core.controller.BaseController;
 import beilv.common.core.domain.AjaxResult;
 import beilv.common.core.page.TableDataInfo;
 import beilv.common.utils.DateUtils;
+import beilv.common.utils.StringUtils;
 import beilv.common.utils.uuid.IdUtils;
 import beilv.competition.domain.Competition;
 import beilv.competition.domain.RedisTask;
@@ -23,6 +24,8 @@ import beilv.vipCardAmountLog.domain.VipCardAmountLog;
 import beilv.vipCardAmountLog.service.IVipCardAmountLogService;
 import beilv.vipCardLog.domain.VipCardLog;
 import beilv.vipCardLog.service.IVipCardLogService;
+import beilv.voucher.domain.BeilvVoucherMember;
+import beilv.voucher.service.IBeilvVoucherMemberService;
 import beilv.wx.pay.controller.WxPayController;
 import beilv.wx.pay.domain.vo.AppRefundParam;
 import lombok.extern.slf4j.Slf4j;
@@ -82,6 +85,9 @@ public class CardAppController extends BaseController {
     @Autowired
     private IVipCardAmountLogService amountLogService;
 
+    @Autowired
+    private IBeilvVoucherMemberService voucherMemberService;
+
     /**
      * 新增充值记录
      */
@@ -101,8 +107,17 @@ public class CardAppController extends BaseController {
         vipCardLog.setCreateTime(DateUtils.getNowDate());
         //设置支付方式
         vipCardLog.setPaymentType("weChart");
+        vipCardLog.setOriginalPrice(vipCardLog.getPracticalMoney());
         //开启订单定时任务
         createOrderTaskQueue(uuid, "chongzhi", "");
+
+        //判断订单是否使用代金券
+        if(StringUtils.isNotEmpty(vipCardLog.getVoucherId())){
+            //修改代金券状态为已使用
+            voucherMemberService.updateBeilvVoucherMember(new BeilvVoucherMember(Long.parseLong(vipCardLog.getVoucherId()), "2"));
+            vipCardLog.setOriginalPrice(vipCardLog.getOriginalPrice().add(vipCardLog.getVoucherPrice()));
+        }
+
         //写入订单信息
         return insertVipCardLog(vipCardLog, uuid);
     }
@@ -126,6 +141,13 @@ public class CardAppController extends BaseController {
             //开启订单的定时任务, 超过设定的时间则设置为取消订单.
             createOrderTaskQueue(uuid, vipCardLog.getOrderType(), vipCardLog.getBusId());
         }
+
+        //判断订单是否使用代金券
+        if(StringUtils.isNotEmpty(vipCardLog.getVoucherId())){
+            //修改代金券状态为已使用
+            voucherMemberService.updateBeilvVoucherMember(new BeilvVoucherMember(Long.parseLong(vipCardLog.getVoucherId()), "2"));
+        }
+
         //写入订单表
         return insertVipCardLog(vipCardLog, uuid);
     }

+ 6 - 0
qmjszx-business/src/main/java/beilv/vipCardLog/domain/VipCardLog.java

@@ -117,6 +117,12 @@ public class VipCardLog extends BaseEntity {
 
     private String description;
 
+    /**
+     * 代金券信息
+     */
+    private BigDecimal voucherPrice;
+    private String voucherId;
+
     public VipCardLog(String busId, String orderType, String paymentStatus, Date verifyTime) {
         this.busId = busId;
         this.orderType = orderType;

+ 5 - 0
qmjszx-business/src/main/java/beilv/voucher/domain/BeilvVoucherMember.java

@@ -90,4 +90,9 @@ public class BeilvVoucherMember extends BaseEntity {
     public BeilvVoucherMember(String isValidity) {
         this.isValidity = isValidity;
     }
+
+    public BeilvVoucherMember(Long id, String isValidity) {
+        this.id = id;
+        this.isValidity = isValidity;
+    }
 }

+ 9 - 3
qmjszx-business/src/main/resources/mapper/vipCardLog/VipCardLogMapper.xml

@@ -20,16 +20,17 @@
         <result property="originalPrice" column="original_price"/>
         <result property="memberPrice" column="member_price"/>
         <result property="paymentId" column="payment_id"/>
+        <result property="voucherPrice" column="voucher_price"/>
     </resultMap>
 
     <sql id="selectVipCardLogVo">
         select a.id, a.user_id, a.bus_id, a.order_type, a.payment_status, a.create_time, a.payment_type, a.payment_time, a.cancellation_time,
-               a.verify_time, a.refund_time, a.practical_money, a.original_price, a.member_price, a.payment_id from beilv_vip_card_log a
+               a.verify_time, a.refund_time, a.practical_money, a.original_price, a.member_price, a.payment_id, a.voucher_price from beilv_vip_card_log a
     </sql>
 
     <select id="selectVipCardLogList" parameterType="VipCardLog" resultMap="VipCardLogResult">
         select a.id, a.user_id, a.bus_id, a.order_type, a.payment_status, a.create_time, a.payment_type, a.payment_time, a.cancellation_time,
-        a.verify_time, a.refund_time, a.practical_money, a.original_price, a.member_price, a.payment_id, b.username, b.mobile from beilv_vip_card_log a
+        a.verify_time, a.refund_time, a.practical_money, a.original_price, a.member_price, a.payment_id, b.username, b.mobile, a.voucher_price from beilv_vip_card_log a
         left join sys_member b on a.user_id = b.id
         <where>
             <if test="username != null and username != ''">and b.username like concat('%',#{username},'%')</if>
@@ -75,6 +76,7 @@
             <if test="paymentId != null">payment_id,</if>
             <if test="competitionName != null">competition_name,</if>
             <if test="competitionMobile != null">competition_mobile,</if>
+            <if test="voucherPrice != null">voucher_price,</if>
         </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="id != null">#{id},</if>
@@ -94,6 +96,7 @@
             <if test="paymentId != null">#{paymentId},</if>
             <if test="competitionName != null">#{competitionName},</if>
             <if test="competitionMobile != null">#{competitionMobile},</if>
+            <if test="voucherPrice != null">#{voucherPrice},</if>
         </trim>
     </insert>
 
@@ -115,6 +118,7 @@
             <if test="memberPrice != null">member_price = #{memberPrice},</if>
             <if test="paymentId != null">payment_id = #{paymentId},</if>
             <if test="refundPrice != null">refund_price = #{refundPrice},</if>
+            <if test="voucherPrice != null">voucher_price = #{voucherPrice},</if>
         </trim>
         <where>
             <if test="id != null and id != ''">
@@ -170,7 +174,8 @@
             c.name siteName,
             b.site_type siteType,
             b.session session,
-            b.ticket_date ticketDate
+            b.ticket_date ticketDate,
+            a.voucher_price voucherPrice
         from beilv_vip_card_log a
         left join beilv_admission_ticket b on a.bus_id = b.id
         left join beilv_site c on b.site_id = c.id
@@ -207,6 +212,7 @@
         b.competition_state competitionState,
         b.publish_time publishTime,
         b.competition_img competitionImg,
+        a.voucher_price voucherPrice
         COALESCE(a.competition_name, c.username) AS competitionName,
         COALESCE(a.competition_mobile, c.mobile) AS competitionMobile
         from beilv_vip_card_log a