Browse Source

修改缴费统计

周箭河 4 năm trước cách đây
mục cha
commit
563e4d0d47

+ 11 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/SporadicPayDto.java

@@ -14,6 +14,9 @@ public class SporadicPayDto {
     @ApiModelProperty(value = "支付项编号",required = false)
     private Integer sporadicId;
 
+    @ApiModelProperty(value = "购买数量",required = false)
+    private Integer num = 1;
+
     private boolean isRepeatPay;
 
     @ApiModelProperty(value = "是否余额支付",required = false)
@@ -58,4 +61,12 @@ public class SporadicPayDto {
     public void setUseBalancePayment(Boolean useBalancePayment) {
         isUseBalancePayment = useBalancePayment;
     }
+
+    public Integer getNum() {
+        return num;
+    }
+
+    public void setNum(Integer num) {
+        this.num = num;
+    }
 }

+ 7 - 3
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupServiceImpl.java

@@ -291,9 +291,12 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         if (chargeInfo.getOpenFlag().equals(1)) {
             throw new BizException("项目已关闭");
         }
-        BigDecimal amount = chargeInfo.getAmount();
+        if(sporadicPayDto.getNum()==null){
+            sporadicPayDto.setNum(1);
+        }
+        BigDecimal amount = chargeInfo.getAmount().multiply(new BigDecimal(sporadicPayDto.getNum()));
         if (chargeInfo.getDiscountAmount() != null && chargeInfo.getDiscountAmount().compareTo(BigDecimal.ZERO) > 0) {
-            amount = amount.subtract(chargeInfo.getDiscountAmount());
+            amount = amount.subtract(chargeInfo.getDiscountAmount().multiply(new BigDecimal(sporadicPayDto.getNum())));
         }
         if (!(amount.compareTo(sporadicPayDto.getAmount()) == 0)) {
             throw new BizException("订单金额异常");
@@ -304,7 +307,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
             }
             List<SporadicChargeInfo> activeInfos = sporadicChargeInfoDao.getOrganActiveInfo(chargeInfo.getOrganId(), 12);
             for (SporadicChargeInfo activeInfo : activeInfos) {
-                activeInfo.setPaidAmount(activeInfo.getPaidAmount().add(chargeInfo.getAmount()));
+                activeInfo.setPaidAmount(activeInfo.getPaidAmount().add(amount));
                 activeInfo.setUpdateTime(new Date());
                 int update = sporadicChargeInfoDao.update(activeInfo);
                 if (update <= 0) {
@@ -330,6 +333,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         studentPaymentOrder.setActualAmount(amount);
         studentPaymentOrder.setStatus(DealStatusEnum.ING);
         studentPaymentOrder.setMusicGroupId(sporadicPayDto.getSporadicId().toString());
+        studentPaymentOrder.setClassGroupId(sporadicPayDto.getNum());
         studentPaymentOrderService.insert(studentPaymentOrder);
 
         studentPaymentOrder.setVersion(0);

+ 7 - 3
mec-biz/src/main/java/com/ym/mec/biz/service/impl/SporadicChargeInfoImpl.java

@@ -85,9 +85,13 @@ public class SporadicChargeInfoImpl extends BaseServiceImpl<Integer, SporadicCha
             //福袋活动,增加课程余额
             if (info.getChargeType().getCode() == 6 || info.getChargeType().getCode() == 12) {
                 //第二单起每买一单增加一次抽奖机会
-                int num = studentPaymentOrderDao.getUserOrderNumByType(userId, OrderTypeEnum.DOUBLE_ELEVEN2020);
-                if (num > 1) {
-                    if (!luckDrawCountService.updateTimes(userId.longValue(), 1)) {
+                int times = studentPaymentOrderDao.getUserOrderNumByType(userId, OrderTypeEnum.DOUBLE_ELEVEN2020);
+                Integer num = studentPaymentOrder.getClassGroupId() == null ? 1 : studentPaymentOrder.getClassGroupId();
+                if (times <= 1) {
+                    num--;
+                }
+                if (num > 0) {
+                    if (!luckDrawCountService.updateTimes(userId.longValue(), num)) {
                         throw new BizException("给用户增加抽奖次数失败");
                     }
                 }