Browse Source

商品购买支持优惠券

zouxuan 3 năm trước cách đây
mục cha
commit
3c5de11652

+ 6 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/SysCouponCodeDao.java

@@ -40,4 +40,10 @@ public interface SysCouponCodeDao extends BaseDAO<Long, SysCouponCode> {
      * @return
      */
     List<HorseRaceLampDto> queryHorseRaceLampDtoList(Map<String, Object> params);
+
+    /**
+     * 支付失败退还优惠券
+     * @param couponCodeId
+     */
+    void quit(@Param("couponCodeId") String couponCodeId);
 }

+ 22 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/StudentPaymentOrder.java

@@ -122,6 +122,28 @@ public class StudentPaymentOrder {
 	
 	private String batchNo;
 
+	@ApiModelProperty(value = "优惠券编号列表",required = true)
+	private String couponCodeId;
+
+	@ApiModelProperty(value = "优惠券减免总额",required = true)
+	private BigDecimal couponRemitFee = BigDecimal.ZERO;
+
+	public String getCouponCodeId() {
+		return couponCodeId;
+	}
+
+	public void setCouponCodeId(String couponCodeId) {
+		this.couponCodeId = couponCodeId;
+	}
+
+	public BigDecimal getCouponRemitFee() {
+		return couponRemitFee;
+	}
+
+	public void setCouponRemitFee(BigDecimal couponRemitFee) {
+		this.couponRemitFee = couponRemitFee;
+	}
+
 	public String getReceiveStatus() {
 		return receiveStatus;
 	}

+ 7 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentRepairServiceImpl.java

@@ -78,6 +78,8 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
     private StudentInstrumentService studentInstrumentService;
     @Autowired
     private StudentGoodsSellService studentGoodsSellService;
+    @Autowired
+    private SysCouponCodeDao sysCouponCodeDao;
 
     private final Logger logger = LoggerFactory.getLogger(this.getClass());
 
@@ -144,6 +146,11 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
                 if (orderByOrderNo.getBalancePaymentAmount() != null && orderByOrderNo.getBalancePaymentAmount().compareTo(BigDecimal.ZERO) > 0) {
                     sysUserCashAccountService.updateBalance(orderByOrderNo.getUserId(), orderByOrderNo.getBalancePaymentAmount(), PlatformCashAccountDetailTypeEnum.REFUNDS, "关闭订单");
                 }
+                //退优惠券
+                String couponCodeId = orderByOrderNo.getCouponCodeId();
+                if(StringUtils.isNotEmpty(couponCodeId)){
+                    sysCouponCodeDao.quit(couponCodeId);
+                }
             }
             StudentGoodsSell byOrderNo = studentGoodsSellDao.findByOrderNo(studentGoodsSell.getOrderNo());
             if (byOrderNo != null) {

+ 2 - 0
mec-biz/src/main/resources/config/mybatis/StudentPaymentOrderMapper.xml

@@ -35,6 +35,8 @@
         <result column="version_" property="version"/>
         <result column="receive_status_" property="receiveStatus"/>
         <result column="batch_no_" property="batchNo"/>
+        <result column="coupon_code_id_" property="couponCodeId"/>
+        <result column="coupon_remit_fee_" property="couponRemitFee"/>
     </resultMap>
 
     <resultMap type="com.ym.mec.biz.dal.dto.StudentPaymentOrderDto" extends="StudentPaymentOrder"

+ 3 - 0
mec-biz/src/main/resources/config/mybatis/SysCouponCodeMapper.xml

@@ -106,6 +106,9 @@
 		</set>
 		WHERE id_ = #{id}
 	</update>
+	<update id="quit">
+		UPDATE sys_coupon_code SET usage_status_ = 0,used_time_ = NULL,update_time_ = NOW() WHERE FIND_IN_SET(id_,#{couponCodeId})
+	</update>
 
 	<!-- 根据主键删除一条记录 -->
 	<delete id="delete" >