zouxuan пре 1 година
родитељ
комит
5d4fe77ebc

+ 1 - 5
mec-biz/src/main/java/com/ym/mec/biz/service/StudentPaymentOrderDetailService.java

@@ -14,12 +14,8 @@ public interface StudentPaymentOrderDetailService extends BaseService<Long, Stud
 
     StudentPaymentOrderDetailDao getDao();
 
+    int batchAdd(List<StudentPaymentOrderDetail> studentPaymentOrderDetailList,BigDecimal couponRemitFee,BigDecimal expectAmount);
 
-    /**
-     * 批量添加订单
-     *
-     * @param studentPaymentOrderDetailList 订单详情
-     */
     int batchAdd(List<StudentPaymentOrderDetail> studentPaymentOrderDetailList);
     
     int batchUpdate(List<StudentPaymentOrderDetail> studentPaymentOrderDetailList);

+ 22 - 10
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentPaymentOrderDetailServiceImpl.java

@@ -6,16 +6,12 @@ import com.ym.mec.biz.dal.entity.*;
 import com.ym.mec.biz.dal.enums.*;
 import com.ym.mec.biz.service.*;
 import com.ym.mec.common.dal.BaseDAO;
-import com.ym.mec.common.dto.OrderCreate;
 import com.ym.mec.common.exception.BizException;
 import com.ym.mec.common.page.WrapperUtil;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
-import com.ym.mec.mall.MallFeignService;
 import com.ym.mec.util.collection.MapUtil;
-
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -65,17 +61,11 @@ public class StudentPaymentOrderDetailServiceImpl extends BaseServiceImpl<Long,
     @Resource
     private MusicGroupPaymentCalenderDetailService musicGroupPaymentCalenderDetailService;
     @Resource
-    private ChargeTypeSubjectMapperDao chargeTypeSubjectMapperDao;
-    @Resource
-    private StudentMusicCourseFeeService studentMusicCourseFeeService;
-    @Resource
     private MemberFeeSettingService memberFeeSettingService;
     @Resource
     private MusicGroupPaymentCalenderMemberDao musicGroupPaymentCalenderMemberDao;
     @Resource
     private ImUserFriendService imUserFriendService;
-    @Resource
-    private MallFeignService mallFeignService;
     @Override
     public BaseDAO<Long, StudentPaymentOrderDetail> getDAO() {
         return studentPaymentOrderDetailDao;
@@ -88,6 +78,28 @@ public class StudentPaymentOrderDetailServiceImpl extends BaseServiceImpl<Long,
 
     @Transactional(rollbackFor = Exception.class)
     @Override
+    public int batchAdd(List<StudentPaymentOrderDetail> studentPaymentOrderDetailList,BigDecimal couponRemitFee,BigDecimal expectAmount) {
+        if(couponRemitFee.compareTo(BigDecimal.ZERO) > 0 && expectAmount.compareTo(BigDecimal.ZERO) > 0){
+            BigDecimal subCouponRemitFee = couponRemitFee;
+            for (int i = 0; i < studentPaymentOrderDetailList.size(); i++) {
+                StudentPaymentOrderDetail orderDetail = studentPaymentOrderDetailList.get(i);
+                if (i == studentPaymentOrderDetailList.size() - 1) {
+                    orderDetail.setRemitFee(subCouponRemitFee);
+                } else {
+                    //获取比例
+                    BigDecimal ratioAmount = orderDetail.getPrice().divide(expectAmount, 6, BigDecimal.ROUND_HALF_UP);
+                    //获取分配的减免金额
+                    BigDecimal multiply = ratioAmount.multiply(couponRemitFee).setScale(2, BigDecimal.ROUND_HALF_UP);
+                    subCouponRemitFee = subCouponRemitFee.subtract(multiply);
+                    orderDetail.setRemitFee(multiply);
+                }
+            }
+        }
+        return studentPaymentOrderDetailDao.batchAdd(studentPaymentOrderDetailList);
+    }
+
+    @Transactional(rollbackFor = Exception.class)
+    @Override
     public int batchAdd(List<StudentPaymentOrderDetail> studentPaymentOrderDetailList) {
         return Optional.ofNullable(studentPaymentOrderDetailList)
                 .filter(CollectionUtils::isNotEmpty)

+ 3 - 21
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentRepairServiceImpl.java

@@ -466,25 +466,7 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
         }
 
         if (CollectionUtils.isNotEmpty(studentPaymentOrderDetailList)) {
-            //分摊优惠券金额
-            if(studentPaymentOrder.getCouponRemitFee().compareTo(BigDecimal.ZERO) > 0 &&
-                    studentPaymentOrder.getExpectAmount().compareTo(BigDecimal.ZERO) > 0){
-                BigDecimal subCouponRemitFee = studentPaymentOrder.getCouponRemitFee();
-                for (int i = 0; i < studentPaymentOrderDetailList.size(); i++) {
-                    StudentPaymentOrderDetail orderDetail = studentPaymentOrderDetailList.get(i);
-                    if (i == studentPaymentOrderDetailList.size() - 1) {
-                        orderDetail.setRemitFee(subCouponRemitFee);
-                    } else {
-                        //获取比例
-                        BigDecimal ratioAmount = orderDetail.getPrice().divide(studentPaymentOrder.getExpectAmount(), 6, BigDecimal.ROUND_HALF_UP);
-                        //获取分配的减免金额
-                        BigDecimal multiply = ratioAmount.multiply(studentPaymentOrder.getCouponRemitFee()).setScale(2, BigDecimal.ROUND_HALF_UP);
-                        subCouponRemitFee = subCouponRemitFee.subtract(multiply);
-                        orderDetail.setRemitFee(multiply);
-                    }
-                }
-            }
-            studentPaymentOrderDetailService.batchAdd(studentPaymentOrderDetailList);
+            studentPaymentOrderDetailService.batchAdd(studentPaymentOrderDetailList,studentPaymentOrder.getCouponRemitFee(),studentPaymentOrder.getExpectAmount());
         }
     }
 
@@ -777,8 +759,8 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
             }
         }
 
-        if (studentPaymentOrderDetailList.size() > 0) {
-            studentPaymentOrderDetailService.batchAdd(studentPaymentOrderDetailList);
+        if (CollectionUtils.isNotEmpty(studentPaymentOrderDetailList)) {
+            studentPaymentOrderDetailService.batchAdd(studentPaymentOrderDetailList,studentPaymentOrder.getCouponRemitFee(),studentPaymentOrder.getExpectAmount());
         }
 
         BigDecimal balance = BigDecimal.ZERO;