소스 검색

fixed 储值卡线下发行问题

fushengqian 9 달 전
부모
커밋
66f6fc1285
1개의 변경된 파일21개의 추가작업 그리고 2개의 파일을 삭제
  1. 21 2
      fuint-application/src/main/java/com/fuint/common/service/impl/CouponServiceImpl.java

+ 21 - 2
fuint-application/src/main/java/com/fuint/common/service/impl/CouponServiceImpl.java

@@ -335,9 +335,12 @@ public class CouponServiceImpl extends ServiceImpl<MtCouponMapper, MtCoupon> imp
            }
         }
 
-        // 如果是优惠券,并且是线下发放,生成会员卡券
-        if (reqCouponDto.getId() == null && mtCoupon.getType().equals(CouponTypeEnum.COUPON.getKey()) && mtCoupon.getSendWay().equals(SendWayEnum.OFFLINE.getKey())) {
+        // 如果是优惠券或储值卡,并且是线下发放,生成会员卡券
+        if (reqCouponDto.getId() == null && !mtCoupon.getType().equals(CouponTypeEnum.TIMER.getKey()) && mtCoupon.getSendWay().equals(SendWayEnum.OFFLINE.getKey())) {
             Integer total = mtCoupon.getTotal() * mtCoupon.getSendNum();
+            if (mtCoupon.getSendNum() == null || mtCoupon.getSendNum() <= 0) {
+                total = mtCoupon.getTotal();
+            }
             if (total > 0) {
                 String uuid = UUID.randomUUID().toString().replaceAll("-", "");
                 for (int i = 1; i <= total; i++) {
@@ -365,6 +368,22 @@ public class CouponServiceImpl extends ServiceImpl<MtCouponMapper, MtCoupon> imp
                     }
                     userCoupon.setUuid(uuid);
                     userCoupon.setType(CouponTypeEnum.COUPON.getKey());
+
+                    // 储值卡金额
+                    if (couponInfo.getAmount() == null || couponInfo.getAmount().compareTo(new BigDecimal("0")) <= 0) {
+                        if (StringUtil.isNotEmpty(couponInfo.getInRule())) {
+                            String[] arr = couponInfo.getInRule().split(",");
+                            if (arr.length > 0) {
+                                String[] values = arr[0].split("_");
+                                if (values.length > 1 && (StringUtil.isNotEmpty(values[1]))) {
+                                    couponInfo.setAmount(new BigDecimal(values[1]));
+                                } else {
+                                    couponInfo.setAmount(new BigDecimal(values[0]));
+                                }
+                            }
+                        }
+                    }
+
                     userCoupon.setAmount(couponInfo.getAmount());
                     userCoupon.setBalance(couponInfo.getAmount());
                     userCoupon.setStoreId(0);