Kaynağa Gözat

管乐迷商城改造

zouxuan 1 yıl önce
ebeveyn
işleme
d05cf8b83b
18 değiştirilmiş dosya ile 113 ekleme ve 573 silme
  1. 0 28
      mec-application/src/main/java/com/ym/mec/student/controller/StudentOrderController.java
  2. 2 1
      mec-application/src/main/java/com/ym/mec/web/controller/StudentRepairController.java
  3. 3 0
      mec-biz/src/main/java/com/ym/mec/biz/service/SellOrderService.java
  4. 3 3
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/ActivityUserMapperServiceImpl.java
  5. 3 2
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/ClassGroupServiceImpl.java
  6. 2 2
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleStudentPaymentServiceImpl.java
  7. 3 2
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/EduPracticeGroupServiceImpl.java
  8. 4 3
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/ExportServiceImpl.java
  9. 5 0
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupCalenderRefundPeriodServiceImpl.java
  10. 32 7
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderServiceImpl.java
  11. 3 2
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentStudentCourseDetailServiceImpl.java
  12. 36 391
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/SellOrderServiceImpl.java
  13. 2 2
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentPaymentOrderDetailServiceImpl.java
  14. 8 65
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentPaymentOrderServiceImpl.java
  15. 3 3
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentRepairServiceImpl.java
  16. 3 2
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/SubjectChangeServiceImpl.java
  17. 1 1
      mec-biz/src/main/resources/config/mybatis/SellOrderMapper.xml
  18. 0 59
      mec-mall/mall-admin/src/main/java/com/yonge/cooleshow/admin/service/impl/OmsOrderReturnApplyServiceImpl.java

+ 0 - 28
mec-application/src/main/java/com/ym/mec/student/controller/StudentOrderController.java

@@ -888,34 +888,6 @@ public class StudentOrderController extends BaseController {
         return succeed(musicGroupRegCalender);
     }
 
-    /*@GetMapping("fixSellOrder")
-    public HttpResponseResult<List<SellOrder>> fixSellOrder(String orderNo) {
-        StudentPaymentOrder order = studentPaymentOrderService.findOrderByOrderNo(orderNo);
-        List<SellOrder> sellOrders = new ArrayList<>();
-        if (order == null || !order.getStatus().equals(DealStatusEnum.SUCCESS) || !order.getType().equals(OrderTypeEnum.APPLY)) {
-            return succeed(sellOrders);
-        }
-
-        List<StudentPaymentOrderDetail> orderDetails = studentPaymentOrderDetailService.getOrderGoodsDetail(order.getId());
-        //销售订单详情
-        if (orderDetails.size() > 0) {
-            MusicGroup musicGroup = musicGroupService.get(order.getMusicGroupId());
-            BigDecimal couponRemitFee = order.getCouponRemitFee();
-            if (couponRemitFee.compareTo(BigDecimal.ZERO) > 0) {
-                BigDecimal musicFee = orderDetails.stream().filter(o -> o.getType().getCode().equals("MUSICAL")
-                                || o.getType().getCode().equals("ACCESSORIES") || o.getType().getCode().equals("TEACHING"))
-                        .map(o -> o.getPrice()).reduce(BigDecimal.ZERO, BigDecimal::add);
-                BigDecimal expectAmount = order.getExpectAmount();
-                //获取比例
-                BigDecimal ratioAmount = musicFee.divide(expectAmount, 6, BigDecimal.ROUND_HALF_UP);
-                //获取分配的减免金额
-                couponRemitFee = couponRemitFee.multiply(ratioAmount).setScale(2, BigDecimal.ROUND_HALF_UP);
-            }
-            sellOrders = sellOrderService.addOrderDetail2SellOrder(orderDetails, order, musicGroup, couponRemitFee);
-        }
-        return succeed(sellOrders);
-
-    }*/
 
     @ApiImplicitParams({
             @ApiImplicitParam(name = "queryDate", dataType = "String", value = "年月"),

+ 2 - 1
mec-application/src/main/java/com/ym/mec/web/controller/StudentRepairController.java

@@ -27,6 +27,7 @@ import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
 import java.io.OutputStream;
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.util.Date;
 import java.util.List;
 import java.util.stream.Collectors;
@@ -88,7 +89,7 @@ public class StudentRepairController extends BaseController {
             }
             List<RepairGoodsDto> repairGoodsDtos = JSONObject.parseArray(row.getGoodsJson(), RepairGoodsDto.class);
             BigDecimal repairGoodsAmount = repairGoodsDtos.stream().map(RepairGoodsDto::getGroupPurchasePrice).reduce(BigDecimal.ZERO, BigDecimal::add);
-            BigDecimal goodsRouteAmount = (row.getAmount().add(repairGoodsAmount).subtract(row.getExemptionAmount())).multiply(repairGoodsAmount).divide(row.getAmount().add(repairGoodsAmount), 2, BigDecimal.ROUND_DOWN);
+            BigDecimal goodsRouteAmount = (row.getAmount().add(repairGoodsAmount).subtract(row.getExemptionAmount())).multiply(repairGoodsAmount).divide(row.getAmount().add(repairGoodsAmount), 2, RoundingMode.DOWN);
             BigDecimal repairRouteAmount = row.getAmount().add(repairGoodsAmount).subtract(row.getExemptionAmount()).subtract(goodsRouteAmount);
             String goodiesStr = repairGoodsDtos.stream().map(RepairGoodsDto::getName).collect(Collectors.joining(","));
             row.setGoodsJson(goodiesStr);

+ 3 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/SellOrderService.java

@@ -14,6 +14,7 @@ import java.util.function.Function;
 
 public interface SellOrderService extends BaseService<Integer, SellOrder> {
 
+
     /**
      * 添加销售订单
      *
@@ -93,4 +94,6 @@ public interface SellOrderService extends BaseService<Integer, SellOrder> {
                                   BigDecimal actualTotalAmount,Boolean saveFlag);
 
     void deleteByOrderNo(String orderNo);
+
+    void batchUpdate(List<SellOrder> sellOrderList);
 }

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

@@ -758,7 +758,7 @@ public class ActivityUserMapperServiceImpl extends BaseServiceImpl<Integer, Acti
 								   ActivityUserMapper activityUserMapper){
 		//实际支付金额,去除优惠券
 		BigDecimal totalAmount = activityUserMapper.getSubNoCoursePrice();
-		BigDecimal singleAmount = totalAmount.divide(new BigDecimal(courseNum), ROUND_DOWN);
+		BigDecimal singleAmount = totalAmount.divide(new BigDecimal(courseNum), RoundingMode.DOWN);
 		BigDecimal firstSingleAmount = totalAmount.subtract(singleAmount.multiply(new BigDecimal(courseNum))).add(singleAmount);
 		for (Integer i = 0; i < courseNum; i++) {
 			CourseScheduleStudentPayment courseScheduleStudentPayment = new CourseScheduleStudentPayment();
@@ -1265,9 +1265,9 @@ public class ActivityUserMapperServiceImpl extends BaseServiceImpl<Integer, Acti
 				activityUserMapper.setActualPrice(subActual);
 			} else {
 				//获取比例
-				BigDecimal ratioAmount = activity.getMarketPrice().divide(reduce, 6, BigDecimal.ROUND_HALF_UP);
+				BigDecimal ratioAmount = activity.getMarketPrice().divide(reduce, 6, RoundingMode.DOWN);
 				//获取分配的减免金额
-				BigDecimal multiply = ratioAmount.multiply(totalActual).setScale(2, BigDecimal.ROUND_HALF_UP);
+				BigDecimal multiply = ratioAmount.multiply(totalActual).setScale(2, RoundingMode.DOWN);
 				subActual = subActual.subtract(multiply);
 				activityUserMapper.setActualPrice(multiply);
 			}

+ 3 - 2
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ClassGroupServiceImpl.java

@@ -43,6 +43,7 @@ import org.springframework.transaction.interceptor.TransactionAspectSupport;
 import org.springframework.util.CollectionUtils;
 
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.time.*;
 import java.time.format.DateTimeFormatter;
 import java.util.*;
@@ -1405,7 +1406,7 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
                             if (unitPrice != null) {
                                 courseType = courseSchedule.getType();
                                 BigDecimal duration = new BigDecimal(DateUtil.minutesBetween(courseSchedule.getStartClassTime(), courseSchedule.getEndClassTime()));
-                                courseScheduleStudentPayment.setExpectPrice(unitPrice.multiply(duration).setScale(2, BigDecimal.ROUND_DOWN));
+                                courseScheduleStudentPayment.setExpectPrice(unitPrice.multiply(duration).setScale(2, RoundingMode.DOWN));
 
                                 if (totalPriceMap.containsKey(courseType)) {
                                     totalPriceMap.put(courseType, totalPriceMap.get(courseType).add(courseScheduleStudentPayment.getExpectPrice()));
@@ -1418,7 +1419,7 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
                             if (originUnitPrice != null) {
                                 courseType = courseSchedule.getType();
                                 BigDecimal duration = new BigDecimal(DateUtil.minutesBetween(courseSchedule.getStartClassTime(), courseSchedule.getEndClassTime()));
-                                courseScheduleStudentPayment.setOriginalPrice(originUnitPrice.multiply(duration).setScale(2, BigDecimal.ROUND_DOWN));
+                                courseScheduleStudentPayment.setOriginalPrice(originUnitPrice.multiply(duration).setScale(2, RoundingMode.DOWN));
 
                                 if (totalOrignPriceMap.containsKey(courseType)) {
                                     totalOrignPriceMap.put(courseType, totalOrignPriceMap.get(courseType).add(courseScheduleStudentPayment.getOriginalPrice()));

+ 2 - 2
mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleStudentPaymentServiceImpl.java

@@ -510,8 +510,8 @@ public class CourseScheduleStudentPaymentServiceImpl extends BaseServiceImpl<Lon
 					//课程每分钟现价
 					BigDecimal unitMinuteCurrentPrice = detail.getCourseCurrentPrice().divide(new BigDecimal(detail.getTotalCourseMinutes()), CommonConstants.DECIMAL_PLACE, BigDecimal.ROUND_DOWN);
 					BigDecimal unitMinuteOriginalPrice = detail.getCourseOriginalPrice().divide(new BigDecimal(detail.getTotalCourseMinutes()), CommonConstants.DECIMAL_PLACE, BigDecimal.ROUND_DOWN);
-					BigDecimal originalPrice = unitMinuteOriginalPrice.multiply(new BigDecimal(courseMinutes)).setScale(2, BigDecimal.ROUND_DOWN);
-					BigDecimal expectPrice = unitMinuteCurrentPrice.multiply(new BigDecimal(courseMinutes)).setScale(2, BigDecimal.ROUND_DOWN);
+					BigDecimal originalPrice = unitMinuteOriginalPrice.multiply(new BigDecimal(courseMinutes)).setScale(2, RoundingMode.DOWN);
+					BigDecimal expectPrice = unitMinuteCurrentPrice.multiply(new BigDecimal(courseMinutes)).setScale(2, RoundingMode.DOWN);
 					studentPayment.setOriginalPrice(studentPayment.getOriginalPrice().add(originalPrice));
 					studentPayment.setExpectPrice(studentPayment.getExpectPrice().add(expectPrice));
 					detail.setSubCourseCurrentPrice(detail.getSubCourseCurrentPrice().subtract(expectPrice));

+ 3 - 2
mec-biz/src/main/java/com/ym/mec/biz/service/impl/EduPracticeGroupServiceImpl.java

@@ -39,6 +39,7 @@ import org.springframework.transaction.interceptor.TransactionAspectSupport;
 import org.springframework.util.CollectionUtils;
 
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.time.*;
 import java.time.format.DateTimeFormatter;
 import java.time.temporal.WeekFields;
@@ -391,8 +392,8 @@ public class EduPracticeGroupServiceImpl implements EduPracticeGroupService{
         if(teacherDefaultSalary == null){
         	throw new BizException("请设置老师课酬");
         }
-        BigDecimal studentSingleCourseCost=amount.divide(new BigDecimal(practiceCourses.size()), CommonConstants.DECIMAL_PLACE, BigDecimal.ROUND_DOWN);
-        BigDecimal studentSingleCourseOriginalCost=originalAmount.divide(new BigDecimal(practiceCourses.size()), CommonConstants.DECIMAL_PLACE, BigDecimal.ROUND_DOWN);
+        BigDecimal studentSingleCourseCost=amount.divide(new BigDecimal(practiceCourses.size()), CommonConstants.DECIMAL_PLACE, RoundingMode.DOWN);
+        BigDecimal studentSingleCourseOriginalCost=originalAmount.divide(new BigDecimal(practiceCourses.size()), CommonConstants.DECIMAL_PLACE, RoundingMode.DOWN);
         for (CourseSchedule courseSchedule : practiceCourses) {
             //课程与老师薪水表
             CourseScheduleTeacherSalary courseScheduleTeacherSalary = new CourseScheduleTeacherSalary();

+ 4 - 3
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ExportServiceImpl.java

@@ -41,6 +41,7 @@ import javax.servlet.http.HttpServletResponse;
 import java.io.*;
 import java.lang.reflect.Method;
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.util.*;
 import java.util.concurrent.CompletableFuture;
 import java.util.concurrent.ExecutorService;
@@ -1917,7 +1918,7 @@ public class ExportServiceImpl implements ExportService {
                         if(i == orderItemList.size() -1){
                             realAmount = realAmount.subtract(subBalanceAmount);
                         }else {
-                            BigDecimal decimal = realAmount.multiply(divide).setScale(2, BigDecimal.ROUND_DOWN);
+                            BigDecimal decimal = realAmount.multiply(divide).setScale(2, RoundingMode.DOWN);
                             subBalanceAmount = subBalanceAmount.subtract(decimal);
                             realAmount = realAmount.subtract(decimal);
                         }
@@ -3353,8 +3354,8 @@ public class ExportServiceImpl implements ExportService {
         BigDecimal actualAmount = subTotalAmount;
         for (int i = 0; i < detailList.size(); i++) {
             StudentPaymentOrderDetail detail = detailList.get(i);
-            BigDecimal ratio = detail.getPrice().divide(expectAmount, 8, BigDecimal.ROUND_DOWN);
-            BigDecimal price = actualAmount.multiply(ratio).setScale(2, BigDecimal.ROUND_DOWN);
+            BigDecimal ratio = detail.getPrice().divide(expectAmount, 8, RoundingMode.DOWN);
+            BigDecimal price = actualAmount.multiply(ratio).setScale(2, RoundingMode.DOWN);
             if (i == detailList.size() - 1) {
                 detail.setPrice(subTotalAmount);
             } else {

+ 5 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupCalenderRefundPeriodServiceImpl.java

@@ -194,6 +194,7 @@ public class MusicGroupCalenderRefundPeriodServiceImpl extends BaseServiceImpl<I
     public void batchUpdate(List<CooperationCalenderRefundUpdateDto> refundPeriods) {
         List<Integer> periodsIds = refundPeriods.stream().map(e -> e.getId()).collect(Collectors.toList());
         List<MusicGroupCalenderRefundPeriod> periods = musicGroupCalenderRefundPeriodDao.queryByIds(periodsIds);
+        BigDecimal originalAmount = periods.stream().map(e -> e.getRefundAmount()).reduce(BigDecimal.ZERO, BigDecimal::add);
         Map<Integer, CooperationCalenderRefundUpdateDto> periodMap = refundPeriods.stream().collect(Collectors.toMap(e -> e.getId(), e -> e));
         periods.forEach(e->{
             CooperationCalenderRefundUpdateDto dto = periodMap.get(e.getId());
@@ -210,5 +211,9 @@ public class MusicGroupCalenderRefundPeriodServiceImpl extends BaseServiceImpl<I
             }
         });
         musicGroupCalenderRefundPeriodDao.batchUpdate(periods);
+        BigDecimal currentAmount = periods.stream().map(e -> e.getRefundAmount()).reduce(BigDecimal.ZERO, BigDecimal::add);
+        if(originalAmount.compareTo(currentAmount) != 0){
+            //变更订单信息
+        }
     }
 }

+ 32 - 7
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderServiceImpl.java

@@ -428,7 +428,7 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
         }
         //保存活动缴费信息
         List<MusicGroupPaymentCalenderActivity> calenderActivityList = musicGroupPaymentBaseCalender.getCalenderActivityList();
-        if (calenderActivityList != null && calenderActivityList.size() > 0) {
+        if (CollectionUtils.isNotEmpty(calenderActivityList)) {
             musicGroupPaymentCalenderActivityService.initBean(calenderActivityList);
             musicGroupPaymentCalenderActivityService.batchInsert(musicGroupPaymentBaseCalender, calenderId);
         }
@@ -533,8 +533,8 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
         // 分摊总金额
         for (int i = 0; i < lastIndex; i++) {
             MusicGroupPaymentCalenderCourseSettings setting = settings.get(i);
-            BigDecimal ratio = setting.getUnitPrice().divide(totalUnitPrice, 10, BigDecimal.ROUND_HALF_UP);
-            BigDecimal itemAmount = totalAmount.multiply(ratio).setScale(2, BigDecimal.ROUND_HALF_UP);
+            BigDecimal ratio = setting.getUnitPrice().divide(totalUnitPrice, 10, RoundingMode.DOWN);
+            BigDecimal itemAmount = totalAmount.multiply(ratio).setScale(2, RoundingMode.DOWN);
             setting.setOverflowCoursePrice(itemAmount.add(setting.getOverflowCoursePrice()));
             remainingAmount = remainingAmount.subtract(itemAmount);
         }
@@ -1166,7 +1166,7 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
                     //获取比例
                     BigDecimal proportion = BigDecimal.ZERO;
                     if (totalCostPrice.compareTo(BigDecimal.ZERO) > 0) {
-                        proportion = goodsDto.getOrganCostPrice().divide(totalCostPrice, 2, BigDecimal.ROUND_HALF_UP);
+                        proportion = goodsDto.getOrganCostPrice().divide(totalCostPrice, 6, RoundingMode.DOWN);
                     }
                     SellOrder sellOrder = new SellOrder();
                     sellOrder.setGoodsSkuId(goodsDto.getSkuStockId());
@@ -1181,7 +1181,7 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
                     if (j == goodsDtoList.size() - 1) {
                         sellOrder.setOrderAmount(waitAmount);
                     } else {
-                        BigDecimal amount = totalAmount.multiply(proportion);
+                        BigDecimal amount = totalAmount.multiply(proportion).setScale(2, RoundingMode.DOWN);
                         waitAmount = waitAmount.subtract(amount);
                         sellOrder.setOrderAmount(amount);
                     }
@@ -1206,6 +1206,31 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
         sellOrderService.batchInsert(sellOrderList);
     }
 
+    public void updateSellOrder(List<SellOrder> sellOrderList, StudentPaymentOrder studentPaymentOrder) {
+        //获取总价
+        BigDecimal totalCostPrice = sellOrderList.stream().map(e->e.getExpectAmount()).reduce(BigDecimal.ZERO, BigDecimal::add);
+        //待分配金额
+        BigDecimal waitAmount = studentPaymentOrder.getExpectAmount();
+        for (int i = 0; i < sellOrderList.size(); i++) {
+            SellOrder sellOrder = sellOrderList.get(i);
+            //获取比例
+            BigDecimal proportion = BigDecimal.ZERO;
+            if (totalCostPrice.compareTo(BigDecimal.ZERO) > 0) {
+                proportion = sellOrder.getExpectAmount().divide(totalCostPrice, 6, RoundingMode.DOWN);
+            }
+            if (i == sellOrderList.size() - 1) {
+                sellOrder.setOrderAmount(waitAmount);
+            } else {
+                BigDecimal amount = studentPaymentOrder.getExpectAmount().multiply(proportion).setScale(2, RoundingMode.DOWN);
+                waitAmount = waitAmount.subtract(amount);
+                sellOrder.setOrderAmount(amount);
+            }
+            sellOrder.setActualAmount(sellOrder.getOrderAmount());
+            sellOrder.setExpectAmount(sellOrder.getOrderAmount());
+        }
+        sellOrderService.batchUpdate(sellOrderList);
+    }
+
     public void syncMallOrder(MusicGroupPaymentCalenderAddress address, MusicGroupPaymentCalender calender,
                               MusicGroup musicGroup, List<MusicGroupPaymentCalenderGoods> goods){
         // 查询地区信息
@@ -1249,9 +1274,9 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
                     orderItemCreate.setRealAmount(waitRemitFee);
                 } else {
                     //获取比例
-                    BigDecimal ratioAmount = goodsDto.getOrganCostPrice().divide(totalAmount, 6, RoundingMode.HALF_UP);
+                    BigDecimal ratioAmount = goodsDto.getOrganCostPrice().divide(totalAmount, 6, RoundingMode.DOWN);
                     //获取分配的金额
-                    BigDecimal multiply = ratioAmount.multiply(totalPrice).setScale(2, RoundingMode.HALF_UP);
+                    BigDecimal multiply = ratioAmount.multiply(totalPrice).setScale(2, RoundingMode.DOWN);
                     orderItemCreate.setRealAmount(multiply);
                     waitRemitFee = waitRemitFee.subtract(multiply);
                 }

+ 3 - 2
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentStudentCourseDetailServiceImpl.java

@@ -15,6 +15,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -205,8 +206,8 @@ public class MusicGroupPaymentStudentCourseDetailServiceImpl extends BaseService
 		// 分摊总金额
 		for (int i = 0; i < lastIndex; i++) {
 			MusicGroupPaymentStudentCourseDetail courseDetail = courseDetails.get(i);
-			BigDecimal ratio = courseDetail.getCourseOriginalPrice().divide(totalUnitPrice, 10, BigDecimal.ROUND_HALF_UP);
-			BigDecimal itemAmount = totalAmount.multiply(ratio).setScale(2, BigDecimal.ROUND_HALF_UP);
+			BigDecimal ratio = courseDetail.getCourseOriginalPrice().divide(totalUnitPrice, 10, RoundingMode.DOWN);
+			BigDecimal itemAmount = totalAmount.multiply(ratio).setScale(2, RoundingMode.DOWN);
 			courseDetail.setCourseCurrentPrice(itemAmount.add(courseDetail.getCourseCurrentPrice()));
 			courseDetail.setSubCourseCurrentPrice(courseDetail.getCourseCurrentPrice());
 			remainingAmount = remainingAmount.subtract(itemAmount);

+ 36 - 391
mec-biz/src/main/java/com/ym/mec/biz/service/impl/SellOrderServiceImpl.java

@@ -1,60 +1,36 @@
 package com.ym.mec.biz.service.impl;
 
 
-import static com.ym.mec.biz.dal.enums.GroupType.GOODS_SELL;
-import static com.ym.mec.biz.dal.enums.GroupType.MUSIC;
-import static com.ym.mec.biz.dal.enums.OrderDetailTypeEnum.*;
-import static com.ym.mec.biz.dal.enums.OrderDetailTypeEnum.ORGAN_SHARE_PROFIT;
-
-import java.math.BigDecimal;
-import java.math.RoundingMode;
-import java.util.*;
-import java.util.function.Consumer;
-import java.util.function.Function;
-import java.util.function.Supplier;
-import java.util.stream.Collectors;
-
 import com.alibaba.fastjson.JSON;
-import com.ym.mec.biz.dal.dto.ComplementGoodsDto;
+import com.ym.mec.biz.dal.dao.*;
 import com.ym.mec.biz.dal.entity.*;
-import com.ym.mec.biz.dal.mapper.GoodsSubMapper;
+import com.ym.mec.biz.dal.enums.*;
 import com.ym.mec.biz.dal.page.MusicGroupShippingAddressQueryInfo;
 import com.ym.mec.biz.service.*;
 import com.ym.mec.common.api.CommonResult;
+import com.ym.mec.common.dal.BaseDAO;
 import com.ym.mec.common.dto.OrderCreate;
 import com.ym.mec.common.dto.PmsProductDto;
 import com.ym.mec.common.dto.PmsProductQueryParamDto;
 import com.ym.mec.common.dto.ReturnApplyDto;
 import com.ym.mec.common.exception.BizException;
 import com.ym.mec.common.page.PageInfo;
-import com.ym.mec.common.page.WrapperUtil;
+import com.ym.mec.common.service.impl.BaseServiceImpl;
 import com.ym.mec.mall.MallFeignService;
 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.Isolation;
 import org.springframework.transaction.annotation.Transactional;
 
-import com.ym.mec.biz.dal.dao.GoodsDao;
-import com.ym.mec.biz.dal.dao.MusicGroupDao;
-import com.ym.mec.biz.dal.dao.SellOrderDao;
-import com.ym.mec.biz.dal.dao.SporadicChargeInfoDao;
-import com.ym.mec.biz.dal.dao.StudentPaymentOrderDao;
-import com.ym.mec.biz.dal.dao.StudentPaymentOrderDetailDao;
-import com.ym.mec.biz.dal.dao.StudentRepairDao;
-import com.ym.mec.biz.dal.enums.AccountType;
-import com.ym.mec.biz.dal.enums.GoodsType;
-import com.ym.mec.biz.dal.enums.KitGroupPurchaseTypeEnum;
-import com.ym.mec.biz.dal.enums.OrderDetailTypeEnum;
-import com.ym.mec.biz.dal.enums.OrderTypeEnum;
-import com.ym.mec.biz.dal.enums.PaymentChannelEnum;
-import com.ym.mec.biz.dal.enums.ReturnFeeEnum;
-import com.ym.mec.biz.dal.enums.SellStatus;
-import com.ym.mec.biz.dal.enums.SellTypeEnum;
-import com.ym.mec.biz.dal.enums.SporadicChargeTypeEnum;
-import com.ym.mec.common.dal.BaseDAO;
-import com.ym.mec.common.service.impl.BaseServiceImpl;
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.util.*;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+
+import static com.ym.mec.biz.dal.enums.GroupType.GOODS_SELL;
+import static com.ym.mec.biz.dal.enums.GroupType.MUSIC;
 
 @Service
 public class SellOrderServiceImpl extends BaseServiceImpl<Integer, SellOrder> implements SellOrderService {
@@ -71,8 +47,6 @@ public class SellOrderServiceImpl extends BaseServiceImpl<Integer, SellOrder> im
     @Autowired
     private SysUserCashAccountLogService sysUserCashAccountLogService;
     @Autowired
-    private GoodsService goodsService;
-    @Autowired
     private StudentPaymentOrderDetailDao studentPaymentOrderDetailDao;
     @Autowired
     private SporadicChargeInfoDao sporadicChargeInfoDao;
@@ -99,188 +73,6 @@ public class SellOrderServiceImpl extends BaseServiceImpl<Integer, SellOrder> im
         return sellOrderDao;
     }
 
-
- /*   @Override
-    @Transactional(rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
-    public List<SellOrder> addSellOrder(Long orderId, String musicGroupId, List<Integer> goodsIds, BigDecimal totalAmount, BigDecimal balance, BigDecimal couponRemitFee) {
-        if (goodsIds == null || goodsIds.size() <= 0) {
-            return null;
-        }
-        if (balance == null) {
-            balance = BigDecimal.ZERO;
-        }
-        StudentPaymentOrder order = studentPaymentOrderDao.get(orderId);
-        BigDecimal totalActualAmount = order.getActualAmount() == null ? BigDecimal.ZERO : order.getActualAmount();
-        MusicGroup musicGroup = new MusicGroup();
-        if (StringUtils.isNotBlank(musicGroupId)) {
-            musicGroup = musicGroupDao.get(musicGroupId);
-        }
-        int goodsNum = goodsIds.size();
-        BigDecimal goodsTotalPrice = BigDecimal.ZERO;
-        List<Goods> goodies = goodsDao.getGoodies(goodsIds);
-        int i = 1;
-        for (Integer goodsId : goodsIds) {
-            for (Goods goods : goodies) {
-                if (goods.getId().equals(goodsId)) {
-                    goodsTotalPrice = goodsTotalPrice.add(goods.getDiscountPrice());
-                    break;
-                }
-            }
-        }
-        //商品总价值去掉优惠券减免
-//        if(goodsTotalPrice.compareTo(couponRemitFee) <= 0){
-//            goodsTotalPrice = BigDecimal.ZERO;
-//        }else {
-//            goodsTotalPrice = goodsTotalPrice.subtract(couponRemitFee);
-//        }
-
-        //已分配的商品余额
-        BigDecimal hasRouteBalance = BigDecimal.ZERO;
-        //已分配的商品现金
-        BigDecimal hasRouteActualAmount = BigDecimal.ZERO;
-        //商品占用的的余额
-        BigDecimal goodsTotalBalance = totalAmount.compareTo(BigDecimal.ZERO) <= 0 ? BigDecimal.ZERO : goodsTotalPrice.multiply(balance).divide(totalAmount, 2, BigDecimal.ROUND_DOWN);
-        //商品占用的总现金
-        BigDecimal goodsTotalActualAmount = totalAmount.compareTo(BigDecimal.ZERO) <= 0 ? BigDecimal.ZERO : goodsTotalPrice.multiply(totalActualAmount).divide(totalAmount, 2, BigDecimal.ROUND_DOWN);
-        AccountType accountType = sysPaymentConfigService.checkAccountType(PaymentChannelEnum.valueOf(order.getPaymentChannel()), order.getMerNos(), order.getTenantId());
-
-        List<SellOrder> sellOrderList = goodsService.subtractStock(goodsIds, accountType);
-        BigDecimal freeCouponRemitFee = couponRemitFee;
-        for (int j = 0; j < goodsIds.size(); j++) {
-            Integer goodsId = goodsIds.get(j);
-            BigDecimal goodsPrice = BigDecimal.ZERO;
-            Goods nowGoods = new Goods();
-            for (Goods goods : goodies) {
-                if (goods.getId().equals(goodsId)) {
-                    nowGoods = goods;
-                    break;
-                }
-            }
-            goodsPrice = nowGoods.getDiscountPrice();
-            //扣除减免金额
-//            if(couponRemitFee.compareTo(BigDecimal.ZERO) > 0){
-//                if(j == goodsIds.size() - 1){
-//                    goodsPrice = goodsPrice.subtract(freeCouponRemitFee);
-//                }else {
-//                    //获取比例
-//                    BigDecimal divide = goodsPrice.divide(goodsPrice.add(couponRemitFee), 6, BigDecimal.ROUND_HALF_UP);
-//                    //分摊金额
-//                    BigDecimal scale = couponRemitFee.multiply(divide).setScale(2, BigDecimal.ROUND_HALF_UP);
-//                    freeCouponRemitFee = freeCouponRemitFee.subtract(scale);
-//                    goodsPrice = goodsPrice.subtract(scale);
-//                }
-//            }
-
-            //当前商品占用的总优惠券减免
-            BigDecimal couponBalance = goodsTotalPrice.compareTo(BigDecimal.ZERO) <= 0 ? BigDecimal.ZERO :
-                    couponRemitFee.multiply(goodsPrice).divide(goodsTotalPrice, 2, BigDecimal.ROUND_DOWN);
-            //当前商品占用的总余额
-            BigDecimal goodsBalance = goodsTotalPrice.compareTo(BigDecimal.ZERO) <= 0 ? BigDecimal.ZERO :
-                    goodsTotalBalance.multiply(goodsPrice).divide(goodsTotalPrice, 2, BigDecimal.ROUND_DOWN);
-            //当前商品占用的总现金
-            BigDecimal goodsActualAmount = goodsTotalPrice.compareTo(BigDecimal.ZERO) <= 0 ? BigDecimal.ZERO :
-                    goodsTotalActualAmount.multiply(goodsPrice).divide(goodsTotalPrice, 2, BigDecimal.ROUND_DOWN);
-
-            if (i == goodsNum) {
-                couponBalance = couponRemitFee.subtract(freeCouponRemitFee);
-                goodsBalance = goodsTotalBalance.subtract(hasRouteBalance);
-                goodsActualAmount = goodsTotalActualAmount.subtract(hasRouteActualAmount);
-            }
-            freeCouponRemitFee = freeCouponRemitFee.subtract(couponBalance);
-            hasRouteBalance = hasRouteBalance.add(goodsBalance);
-            hasRouteActualAmount = hasRouteActualAmount.add(goodsActualAmount);
-            i++;
-
-            int complementGoodsNum = nowGoods.getComplementGoodsIdList() == null ? 1 : nowGoods.getComplementGoodsIdList().split(",").length;
-            BigDecimal complementPrice = nowGoods.getDiscountPrice();
-            Map<Integer, BigDecimal> complementGoodsPrice = new HashMap<>();
-            complementGoodsPrice.put(nowGoods.getId(), nowGoods.getDiscountPrice());
-            if (nowGoods.getComplementGoodsIdList() != null) {
-                List<Goods> complementGoodies = goodsDao.findGoodsByIds(nowGoods.getComplementGoodsIdList());
-                complementGoodsPrice = complementGoodies.stream().collect(Collectors.toMap(Goods::getId, Goods::getDiscountPrice));
-                complementPrice = complementGoodies.stream().map(Goods::getDiscountPrice).reduce(BigDecimal.ZERO, BigDecimal::add);
-            }
-
-            BigDecimal hasRouteSellOrderActualAmount = BigDecimal.ZERO;
-            BigDecimal hasRouteSellOrderBalance = BigDecimal.ZERO;
-            BigDecimal hasRouteCouponBalance = BigDecimal.ZERO;
-            for (SellOrder sellOrder : sellOrderList) {
-                if (!goodsId.equals(sellOrder.getParentGoodsId()) && !goodsId.equals(sellOrder.getGoodsId())) {
-                    continue;
-                }
-                if (sellOrder.getHasRoute()) {
-                    continue;
-                }
-                BigDecimal sellOrderActualAmount = BigDecimal.ZERO;
-                BigDecimal sellOrderBalance = BigDecimal.ZERO;
-                if (complementPrice.compareTo(BigDecimal.ZERO) > 0) {
-                    sellOrderActualAmount = complementGoodsPrice.get(sellOrder.getGoodsId()).multiply(new BigDecimal(sellOrder.getNum())).multiply(goodsActualAmount).divide(complementPrice, 2, BigDecimal.ROUND_DOWN);
-                    sellOrderBalance = complementGoodsPrice.get(sellOrder.getGoodsId()).multiply(new BigDecimal(sellOrder.getNum())).multiply(goodsBalance).divide(complementPrice, 2, BigDecimal.ROUND_DOWN);
-                }
-
-                complementGoodsNum = complementGoodsNum - sellOrder.getNum();
-                if (complementGoodsNum <= 0) {
-                    sellOrderActualAmount = goodsActualAmount.subtract(hasRouteSellOrderActualAmount);
-                    sellOrderBalance = goodsBalance.subtract(hasRouteSellOrderBalance);
-                }
-                hasRouteSellOrderActualAmount = hasRouteSellOrderActualAmount.add(sellOrderActualAmount);
-                hasRouteSellOrderBalance = hasRouteSellOrderBalance.add(sellOrderBalance);
-
-                sellOrder.setExpectAmount(sellOrderActualAmount.add(sellOrderBalance));
-                sellOrder.setBalanceAmount(sellOrderBalance);
-//                sellOrder.setCouponRemitAmount(sellOrderCouponBalance);
-                sellOrder.setActualAmount(sellOrderActualAmount);
-                sellOrder.setOrganId(order.getOrganId());
-                sellOrder.setCooperationOrganId(musicGroup.getCooperationOrganId());
-                sellOrder.setTransNo(order.getTransNo());
-                sellOrder.setOrderId(order.getId());
-                sellOrder.setOrderNo(order.getOrderNo());
-                sellOrder.setUserId(order.getUserId());
-                sellOrder.setPaymentChannel(order.getPaymentChannel());
-                sellOrder.setMerNo(order.getMerNos());
-                sellOrder.setSellTime(order.getCreateTime());
-                sellOrder.setCreateIme(new Date());
-                sellOrder.setUpdateTime(new Date());
-                if (nowGoods.getType().equals(GoodsType.INSTRUMENT)) {
-                    sellOrder.setType(SellTypeEnum.INSTRUMENT);
-                } else if (nowGoods.getType().equals(GoodsType.ACCESSORIES)) {
-                    sellOrder.setType(SellTypeEnum.ACCESSORIES);
-                } else {
-                    sellOrder.setType(SellTypeEnum.OTHER);
-                }
-                sellOrder.setHasRoute(true);
-                if (complementGoodsNum <= 0) {
-                    break;
-                }
-            }
-        }
-        if (sellOrderList.size() > 0) {
-            //如果有优惠券金额
-            if (couponRemitFee.compareTo(BigDecimal.ZERO) > 0) {
-                BigDecimal reduce = sellOrderList.stream().map(e -> e.getExpectAmount()).reduce(BigDecimal.ZERO, BigDecimal::add);
-                List<SellOrder> sellOrders = sellOrderList.stream().filter(e -> e.getExpectAmount().compareTo(BigDecimal.ZERO) > 0).collect(Collectors.toList());
-                //可用优惠券金额
-                BigDecimal subCouponMarketAmount = couponRemitFee;
-                for (int j = 0; j < sellOrders.size(); j++) {
-                    SellOrder sellOrder = sellOrders.get(j);
-                    //如果是最后一件商品
-                    if (j == sellOrders.size() - 1) {
-                        sellOrder.setCouponRemitAmount(subCouponMarketAmount);
-                    } else {
-                        //获取比例
-                        BigDecimal ratioAmount = sellOrder.getExpectAmount().divide(reduce, 6, BigDecimal.ROUND_HALF_UP);
-                        //获取分配的减免金额
-                        BigDecimal multiply = couponRemitFee.multiply(ratioAmount).setScale(2, BigDecimal.ROUND_HALF_UP);
-                        subCouponMarketAmount = subCouponMarketAmount.subtract(multiply);
-                        sellOrder.setCouponRemitAmount(multiply);
-                    }
-                }
-            }
-            sellOrderDao.batchInsert(sellOrderList);
-        }
-        return sellOrderList;
-    }
-*/
     @Override
     @Transactional(rollbackFor = Exception.class)
     public void addOrderDetail2SellOrder(List<StudentPaymentOrderDetail> orderDetails,
@@ -295,10 +87,10 @@ public class SellOrderServiceImpl extends BaseServiceImpl<Integer, SellOrder> im
         //获取比例
         BigDecimal totalRatioAmount = BigDecimal.ZERO;
         if(studentPaymentOrder.getExpectAmount().compareTo(BigDecimal.ZERO) > 0){
-            totalRatioAmount = detailTotalPrice.divide(studentPaymentOrder.getExpectAmount(), 6, BigDecimal.ROUND_HALF_UP);
+            totalRatioAmount = detailTotalPrice.divide(studentPaymentOrder.getExpectAmount(), 6, RoundingMode.DOWN);
         }
         //获取分配的余额
-        BigDecimal balancePaymentAmount = studentPaymentOrder.getBalancePaymentAmount().multiply(totalRatioAmount).setScale(2, BigDecimal.ROUND_HALF_UP);
+        BigDecimal balancePaymentAmount = studentPaymentOrder.getBalancePaymentAmount().multiply(totalRatioAmount).setScale(2, RoundingMode.DOWN);
         //获取总优惠券金额
         BigDecimal detailTotalRemitPrice = goodsOrderDetails.stream().map(StudentPaymentOrderDetail::getRemitFee).reduce(BigDecimal.ZERO, BigDecimal::add);
 
@@ -316,12 +108,12 @@ public class SellOrderServiceImpl extends BaseServiceImpl<Integer, SellOrder> im
             //获取支付金额比例
             BigDecimal ratioAmount = BigDecimal.ZERO;
             if(detailTotalPrice.compareTo(BigDecimal.ZERO) > 0){
-                ratioAmount = orderDetail.getPrice().divide(detailTotalPrice, 6, BigDecimal.ROUND_HALF_UP);
+                ratioAmount = orderDetail.getPrice().divide(detailTotalPrice, 6, RoundingMode.DOWN);
             }
             BigDecimal ratioCouponAmount = BigDecimal.ZERO;
             if (detailTotalRemitPrice.compareTo(BigDecimal.ZERO) > 0) {
                 //获取优惠券金额比例
-                ratioCouponAmount = orderDetail.getRemitFee().divide(detailTotalRemitPrice, 6, BigDecimal.ROUND_HALF_UP);
+                ratioCouponAmount = orderDetail.getRemitFee().divide(detailTotalRemitPrice, 6, RoundingMode.DOWN);
             }
             //获取分配的余额
             BigDecimal detailBalance;
@@ -338,13 +130,13 @@ public class SellOrderServiceImpl extends BaseServiceImpl<Integer, SellOrder> im
                 detailActualAmount = subDetailActualAmount;
             } else {
                 //获取分配的余额
-                detailBalance = balancePaymentAmount.multiply(ratioAmount).setScale(2, BigDecimal.ROUND_DOWN);
+                detailBalance = balancePaymentAmount.multiply(ratioAmount).setScale(2, RoundingMode.DOWN);
                 subDetailBalance = subDetailBalance.subtract(detailBalance);
                 //获取分配的优惠券金额
-                couponRemitFee = detailTotalRemitPrice.multiply(ratioCouponAmount).setScale(2, BigDecimal.ROUND_HALF_UP);
+                couponRemitFee = detailTotalRemitPrice.multiply(ratioCouponAmount).setScale(2, RoundingMode.DOWN);
                 subDetailCouponRemitFee = subDetailCouponRemitFee.subtract(couponRemitFee);
                 //获取剩余待分配的现金
-                detailActualAmount = totalDetailActualAmount.multiply(ratioAmount).setScale(2, BigDecimal.ROUND_DOWN);
+                detailActualAmount = totalDetailActualAmount.multiply(ratioAmount).setScale(2, RoundingMode.DOWN);
                 subDetailActualAmount = subDetailActualAmount.subtract(detailActualAmount);
             }
             List<Integer> goodsIds = Arrays.asList(orderDetail.getGoodsIdList().split(",")).stream().map(Integer::parseInt).collect(Collectors.toList());
@@ -354,132 +146,6 @@ public class SellOrderServiceImpl extends BaseServiceImpl<Integer, SellOrder> im
         this.batchInsert(sellOrders);
         //同步销售订单到商城
         this.syncSellOrder2Mall(sellOrders, studentPaymentOrder);
-
-/*
-            BigDecimal goodsTotalPrice = orderDetail.getGoodsList().stream().map(Goods::getGroupPurchasePrice).reduce(BigDecimal.ZERO, BigDecimal::add);
-            BigDecimal routePrice = BigDecimal.ZERO;
-            BigDecimal routeBalance = BigDecimal.ZERO;
-            int j = 1;
-
-            List<Integer> goodsIds = orderDetail.getGoodsList().stream().map(Goods::getId).collect(Collectors.toList());
-            List<SellOrder> sellOrderList = goodsService.subtractStock(goodsIds, accountType);
-            for (Goods goods : orderDetail.getGoodsList()) {
-                BigDecimal expectAmount = BigDecimal.ZERO;
-                BigDecimal balance = BigDecimal.ZERO;
-                if (goodsTotalPrice.compareTo(BigDecimal.ZERO) > 0) {
-                    expectAmount = goods.getGroupPurchasePrice().multiply(orderDetail.getPrice()).divide(goodsTotalPrice, 2, BigDecimal.ROUND_DOWN);
-                    balance = goods.getGroupPurchasePrice().multiply(detailBalance).divide(goodsTotalPrice, 2, BigDecimal.ROUND_DOWN);
-                }
-                if (j == orderDetail.getGoodsList().size()) {
-                    expectAmount = orderDetail.getPrice().subtract(routePrice);
-                    balance = detailBalance.subtract(routeBalance);
-                }
-                routePrice = routePrice.add(expectAmount);
-                routeBalance = routeBalance.add(balance);
-                j++;
-
-                int complementGoodsNum = goods.getComplementGoodsIdList() == null ? 1 : goods.getComplementGoodsIdList().split(",").length;
-                BigDecimal complementPrice = goods.getGroupPurchasePrice();
-                Map<Integer, BigDecimal> complementGoodsPrice = new HashMap<>();
-                complementGoodsPrice.put(goods.getId(), goods.getGroupPurchasePrice());
-                if (goods.getComplementGoodsIdList() != null) {
-                    List<Goods> complementGoodies = goodsDao.findGoodsByIds(goods.getComplementGoodsIdList());
-                    complementGoodsPrice = complementGoodies.stream().collect(Collectors.toMap(Goods::getId, Goods::getGroupPurchasePrice));
-                    complementPrice = complementGoodies.stream().map(Goods::getGroupPurchasePrice).reduce(BigDecimal.ZERO, BigDecimal::add);
-                }
-
-                BigDecimal hasRouteSellOrderExpectAmount = BigDecimal.ZERO;
-                BigDecimal hasRouteSellOrderBalance = BigDecimal.ZERO;
-                for (SellOrder sellOrder : sellOrderList) {
-                    if (!goods.getId().equals(sellOrder.getParentGoodsId()) && !goods.getId().equals(sellOrder.getGoodsId())) {
-                        continue;
-                    }
-                    if (sellOrder.getHasRoute()) {
-                        continue;
-                    }
-                    sellOrder.setTenantId(tenantId);
-                    BigDecimal sellOrderExpectAmount = BigDecimal.ZERO;
-                    BigDecimal sellOrderBalance = BigDecimal.ZERO;
-                    if (complementPrice.compareTo(BigDecimal.ZERO) > 0) {
-                        sellOrderExpectAmount = complementGoodsPrice.get(sellOrder.getGoodsId()).multiply(new BigDecimal(sellOrder.getNum())).multiply(expectAmount).divide(complementPrice, 2, BigDecimal.ROUND_DOWN);
-                        sellOrderBalance = complementGoodsPrice.get(sellOrder.getGoodsId()).multiply(new BigDecimal(sellOrder.getNum())).multiply(balance).divide(complementPrice, 2, BigDecimal.ROUND_DOWN);
-                    }
-                    complementGoodsNum = complementGoodsNum - sellOrder.getNum();
-                    if (complementGoodsNum <= 0) {
-                        sellOrderExpectAmount = expectAmount.subtract(hasRouteSellOrderExpectAmount);
-                        sellOrderBalance = balance.subtract(hasRouteSellOrderBalance);
-                    }
-                    hasRouteSellOrderExpectAmount = hasRouteSellOrderExpectAmount.add(sellOrderExpectAmount);
-                    hasRouteSellOrderBalance = hasRouteSellOrderBalance.add(sellOrderBalance);
-
-                    sellOrder.setOrganId(studentPaymentOrder.getOrganId());
-                    sellOrder.setTransNo(studentPaymentOrder.getTransNo());
-                    sellOrder.setOrderId(studentPaymentOrder.getId());
-                    if (musicGroup != null) {
-                        sellOrder.setCooperationOrganId(musicGroup.getCooperationOrganId());
-                        sellOrder.setEduTeacherId(musicGroup.getEducationalTeacherId());
-                    }
-                    sellOrder.setOrderNo(studentPaymentOrder.getOrderNo());
-                    sellOrder.setActualAmount(sellOrderExpectAmount.subtract(sellOrderBalance));
-                    sellOrder.setBalanceAmount(sellOrderBalance);
-                    sellOrder.setExpectAmount(sellOrderExpectAmount);
-//                    sellOrder.setCouponRemitAmount(goods.getGroupPurchasePrice().subtract(sellOrderExpectAmount));
-                    sellOrder.setNum(1);
-                    sellOrder.setUserId(studentPaymentOrder.getUserId());
-                    sellOrder.setPaymentChannel(studentPaymentOrder.getPaymentChannel());
-                    sellOrder.setMerNo(studentPaymentOrder.getMerNos());
-                    sellOrder.setSellTime(studentPaymentOrder.getCreateTime());
-                    sellOrder.setCreateIme(new Date());
-                    sellOrder.setUpdateTime(new Date());
-                    if (goods.getType().equals(GoodsType.INSTRUMENT)) {
-                        sellOrder.setType(SellTypeEnum.INSTRUMENT);
-                    } else if (goods.getType().equals(GoodsType.ACCESSORIES)) {
-                        sellOrder.setType(SellTypeEnum.ACCESSORIES);
-                    } else {
-                        sellOrder.setType(SellTypeEnum.OTHER);
-                    }
-                    //租赁、免费的没有销售收入,有销售成本
-                    if (orderDetail.getType().equals(OrderDetailTypeEnum.MUSICAL) &&
-                            (orderDetail.getKitGroupPurchaseType().equals(KitGroupPurchaseTypeEnum.LEASE) ||
-                                    orderDetail.getKitGroupPurchaseType().equals(KitGroupPurchaseTypeEnum.FREE)
-                            )) {
-                        sellOrder.setActualAmount(BigDecimal.ZERO);
-                        sellOrder.setBalanceAmount(BigDecimal.ZERO);
-                        sellOrder.setExpectAmount(BigDecimal.ZERO);
-                    }
-                    sellOrder.setHasRoute(true);
-                    if (complementGoodsNum <= 0) {
-                        break;
-                    }
-                }
-
-            }
-            sellOrders.addAll(sellOrderList);
-        }
-        if (sellOrders.size() > 0) {
-            //如果有优惠券金额
-            if (musicRemitFee.compareTo(BigDecimal.ZERO) > 0) {
-                BigDecimal reduce = sellOrders.stream().map(e -> e.getExpectAmount()).reduce(BigDecimal.ZERO, BigDecimal::add);
-                List<SellOrder> sellOrderList = sellOrders.stream().filter(e -> e.getExpectAmount().compareTo(BigDecimal.ZERO) > 0).collect(Collectors.toList());
-                //可用优惠券金额
-                BigDecimal subCouponMarketAmount = musicRemitFee;
-                for (int j = 0; j < sellOrderList.size(); j++) {
-                    SellOrder sellOrder = sellOrderList.get(j);
-                    //如果是最后一件商品
-                    if (j == sellOrderList.size() - 1) {
-                        sellOrder.setCouponRemitAmount(subCouponMarketAmount);
-                    } else {
-                        //获取比例
-                        BigDecimal ratioAmount = sellOrder.getExpectAmount().divide(reduce, 6, BigDecimal.ROUND_HALF_UP);
-                        //获取分配的减免金额
-                        BigDecimal multiply = musicRemitFee.multiply(ratioAmount).setScale(2, BigDecimal.ROUND_HALF_UP);
-                        subCouponMarketAmount = subCouponMarketAmount.subtract(multiply);
-                        sellOrder.setCouponRemitAmount(multiply);
-                    }
-                }
-            }
-            sellOrderDao.batchInsert(sellOrders);
-        }*/
     }
 
     @Override
@@ -591,33 +257,6 @@ public class SellOrderServiceImpl extends BaseServiceImpl<Integer, SellOrder> im
             orderItemCreate.setProductSkuId(e.getGoodsSkuId().longValue());
             orderItemCreate.setRealAmount(e.getExpectAmount());
             orderItems.add(orderItemCreate);
-            /*List<GoodsSub> list = goodsSubService.lambdaQuery().eq(GoodsSub::getGoodsId, e.getParentGoodsId()).list();
-            if(CollectionUtils.isEmpty(list)){
-                throw new RuntimeException("子商品不存在,请联系管理员");
-            }
-            BigDecimal totalPrice = e.getExpectAmount().divide(new BigDecimal(e.getNum()), 2, RoundingMode.HALF_UP);
-            //总金额按比例分配
-            //待分配
-            BigDecimal waitRemitFee = totalPrice;
-            BigDecimal totalAmount = WrapperUtil.sumList(list, GoodsSub::getGoodsPrice);
-            for (int i = 0; i < list.size(); i++) {
-                GoodsSub goodsDto = list.get(i);
-                OrderCreate.OrderItem orderItemCreate = new OrderCreate.OrderItem();
-                orderItemCreate.setProductQuantity(e.getNum());
-                orderItemCreate.setProductSkuId(goodsDto.getSku().longValue());
-                //如果是最后一件商品
-                if (i == list.size() - 1) {
-                    orderItemCreate.setRealAmount(waitRemitFee);
-                } else {
-                    //获取比例
-                    BigDecimal ratioAmount = goodsDto.getGoodsPrice().divide(totalAmount, 6, RoundingMode.HALF_UP);
-                    //获取分配的金额
-                    BigDecimal multiply = ratioAmount.multiply(totalPrice).setScale(2, RoundingMode.HALF_UP);
-                    orderItemCreate.setRealAmount(multiply);
-                    waitRemitFee = waitRemitFee.subtract(multiply);
-                }
-                orderItems.add(orderItemCreate);*/
-//            }
         }
         return orderItems;
     }
@@ -773,7 +412,7 @@ public class SellOrderServiceImpl extends BaseServiceImpl<Integer, SellOrder> im
 
             if (goodsTotalPrice.compareTo(BigDecimal.ZERO) > 0) {
                 goodsRatioAmount = order.getGroupType() == MUSIC ?nowGoods.getGroupPurchasePrice():nowGoods.getDiscountPrice()
-                        .divide(goodsTotalPrice, 6, RoundingMode.HALF_UP);
+                        .divide(goodsTotalPrice, 6, RoundingMode.DOWN);
             }
             if(i == goodies.size() - 1){
                 expectAmount = subExpectTotalAmount;
@@ -781,11 +420,11 @@ public class SellOrderServiceImpl extends BaseServiceImpl<Integer, SellOrder> im
                 remitAmount = subCouponRemitAmount;
                 actualAmount = subTotalActualAmount;
             }else {
-                expectAmount = goodsRatioAmount.multiply(expectTotalAmount).setScale(2, RoundingMode.HALF_UP);
+                expectAmount = goodsRatioAmount.multiply(expectTotalAmount).setScale(2, RoundingMode.DOWN);
                 subExpectTotalAmount = subExpectTotalAmount.subtract(expectAmount);
-                goodsBalance = goodsRatioAmount.multiply(totalBalance).setScale(2, RoundingMode.HALF_UP);
+                goodsBalance = goodsRatioAmount.multiply(totalBalance).setScale(2, RoundingMode.DOWN);
                 subTotalBalance = subTotalBalance.subtract(goodsBalance);
-                remitAmount = goodsRatioAmount.multiply(couponRemitAmount).setScale(2, RoundingMode.HALF_UP);
+                remitAmount = goodsRatioAmount.multiply(couponRemitAmount).setScale(2, RoundingMode.DOWN);
                 subCouponRemitAmount = subCouponRemitAmount.subtract(remitAmount);
                 actualAmount = expectAmount.subtract(goodsBalance).subtract(remitAmount);
                 subTotalActualAmount = subTotalActualAmount.subtract(actualAmount);
@@ -819,7 +458,7 @@ public class SellOrderServiceImpl extends BaseServiceImpl<Integer, SellOrder> im
                 //获取比例
                 BigDecimal ratioAmount = BigDecimal.ZERO;
                 if(complementPrice.compareTo(BigDecimal.ZERO) > 0){
-                    ratioAmount = goodsSub.getGoodsPrice().divide(complementPrice, 6, RoundingMode.HALF_UP);
+                    ratioAmount = goodsSub.getGoodsPrice().divide(complementPrice, 6, RoundingMode.DOWN);
                 }
                 if (j == goodsSubs.size() - 1){
                     sellOrder.setExpectAmount(subExpectAmount);
@@ -827,16 +466,16 @@ public class SellOrderServiceImpl extends BaseServiceImpl<Integer, SellOrder> im
                     sellOrder.setActualAmount(subActualAmount);
                     sellOrder.setCouponRemitAmount(subRemitAmount);
                 }else {
-                    BigDecimal decimal = expectAmount.multiply(ratioAmount).setScale(2, RoundingMode.HALF_UP);
+                    BigDecimal decimal = expectAmount.multiply(ratioAmount).setScale(2, RoundingMode.DOWN);
                     sellOrder.setExpectAmount(decimal);
                     subExpectAmount = subExpectAmount.subtract(decimal);
-                    BigDecimal balance = goodsBalance.multiply(ratioAmount).setScale(2, RoundingMode.HALF_UP);
+                    BigDecimal balance = goodsBalance.multiply(ratioAmount).setScale(2, RoundingMode.DOWN);
                     sellOrder.setBalanceAmount(balance);
                     subGoodsBalance = subGoodsBalance.subtract(balance);
-                    BigDecimal actual = actualAmount.multiply(ratioAmount).setScale(2, RoundingMode.HALF_UP);
+                    BigDecimal actual = actualAmount.multiply(ratioAmount).setScale(2, RoundingMode.DOWN);
                     sellOrder.setActualAmount(actual);
                     subActualAmount = subActualAmount.subtract(actual);
-                    BigDecimal remit = remitAmount.multiply(ratioAmount).setScale(2, RoundingMode.HALF_UP);
+                    BigDecimal remit = remitAmount.multiply(ratioAmount).setScale(2, RoundingMode.DOWN);
                     sellOrder.setCouponRemitAmount(remit);
                     subRemitAmount = subRemitAmount.subtract(remit);
                 }
@@ -882,6 +521,12 @@ public class SellOrderServiceImpl extends BaseServiceImpl<Integer, SellOrder> im
 
     @Override
     @Transactional(rollbackFor = Exception.class)
+    public void batchUpdate(List<SellOrder> sellOrderList) {
+        sellOrderDao.batchUpdate(sellOrderList);
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
     public List<SellOrder> initSellOrder(StudentPaymentOrder order, String musicGroupId, List<Integer> goodsIds,
                                          KitGroupPurchaseTypeEnum kitGroupPurchaseType,Boolean saveFlag) {
         if (CollectionUtils.isEmpty(goodsIds)) {
@@ -907,13 +552,13 @@ public class SellOrderServiceImpl extends BaseServiceImpl<Integer, SellOrder> im
         //商品总付款
         BigDecimal detailTotalPrice = orderDetails.stream().map(StudentPaymentOrderDetail::getPrice).reduce(BigDecimal.ZERO, BigDecimal::add);
         //商品销售占的余额
-        BigDecimal detailTotalBalance = detailTotalPrice.multiply(totalBalance).divide(totalPrice, 2, BigDecimal.ROUND_DOWN);
+        BigDecimal detailTotalBalance = detailTotalPrice.multiply(totalBalance).divide(totalPrice, 2, RoundingMode.DOWN);
 
         if(detailTotalBalance.subtract(cloudBalanceIncome).compareTo(BigDecimal.ZERO) < 0) {
             detailTotalBalance = cloudBalanceIncome;
         }
 
-        BigDecimal actualAmount = detailTotalPrice.multiply(order.getActualAmount()).divide(totalPrice, 2, BigDecimal.ROUND_DOWN);
+        BigDecimal actualAmount = detailTotalPrice.multiply(order.getActualAmount()).divide(totalPrice, 2, RoundingMode.DOWN);
 
         if(actualAmount.subtract(cloudIncome).compareTo(BigDecimal.ZERO) < 0){
             actualAmount = cloudIncome;

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

@@ -87,9 +87,9 @@ public class StudentPaymentOrderDetailServiceImpl extends BaseServiceImpl<Long,
                     orderDetail.setRemitFee(subCouponRemitFee);
                 } else {
                     //获取比例
-                    BigDecimal ratioAmount = orderDetail.getPrice().divide(expectAmount, 6, BigDecimal.ROUND_HALF_UP);
+                    BigDecimal ratioAmount = orderDetail.getPrice().divide(expectAmount, 6, RoundingMode.DOWN);
                     //获取分配的减免金额
-                    BigDecimal multiply = ratioAmount.multiply(couponRemitFee).setScale(2, BigDecimal.ROUND_HALF_UP);
+                    BigDecimal multiply = ratioAmount.multiply(couponRemitFee).setScale(2, RoundingMode.DOWN);
                     subCouponRemitFee = subCouponRemitFee.subtract(multiply);
                     orderDetail.setRemitFee(multiply);
                 }

+ 8 - 65
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentPaymentOrderServiceImpl.java

@@ -48,6 +48,7 @@ import org.springframework.transaction.annotation.Transactional;
 import javax.annotation.Resource;
 import java.io.IOException;
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.util.*;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.stream.Collectors;
@@ -603,44 +604,6 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
         return true;
     }
 
-    //Date date = new Date();
-    //        BigDecimal balance = BigDecimal.ZERO;
-    //        MusicGroup musicGroup = musicGroupDao.get(studentRegistration.getMusicGroupId());
-    //        if (registerPayDto.getIsUseBalancePayment() && amount.compareTo(BigDecimal.ZERO) > 0) {
-    //            SysUserCashAccount userCashAccount = sysUserCashAccountService.getLocked(userId);
-    //            if (userCashAccount == null) {
-    //                throw new BizException("用户账户找不到");
-    //            }
-    //            if (userCashAccount.getBalance() != null && userCashAccount.getBalance().compareTo(BigDecimal.ZERO) > 0) {
-    //                balance = amount.compareTo(userCashAccount.getBalance()) >= 0 ? userCashAccount.getBalance() : amount;
-    //                amount = amount.subtract(balance);
-    //                studentPaymentOrder.setPaymentChannel("BALANCE");
-    //                studentPaymentOrder.setActualAmount(amount);
-    //                studentPaymentOrder.setBalancePaymentAmount(balance);
-    //                sysUserCashAccountService.updateBalance(userId, balance.negate(), PlatformCashAccountDetailTypeEnum.PAY_FEE, "乐团报名");
-    //            }
-    //        }
-    //        studentPaymentOrder.setPaymentChannel("BALANCE");
-    //        studentPaymentOrder.setRemitFee(remitFee);
-    //        studentPaymentOrder.setCourseRemitFee(courseRemitFee);
-    //        studentPaymentOrder.setOrganId(musicGroup.getOrganId());
-    //        studentPaymentOrder.setRoutingOrganId(musicGroup.getOrganId());
-    //        studentPaymentOrder.setUpdateTime(date);
-    //        studentPaymentOrderService.update(studentPaymentOrder);
-    //        studentPaymentOrder.setVersion(studentPaymentOrder.getVersion() + 1);
-    //
-    //        if (amount.compareTo(BigDecimal.ZERO) == 0) {
-    //            //如果赠送网管课
-    //            studentPaymentRouteOrderService.addRouteOrder(orderNo, musicGroup.getOrganId(), balance);
-    //            Map<String, String> notifyMap = new HashMap<>();
-    //            notifyMap.put("tradeState", "1");
-    //            notifyMap.put("merOrderNo", studentPaymentOrder.getOrderNo());
-    //            notifyMap.put("channelType", channelType);
-    //            notifyMap.put("orderNo", "");
-    //            studentPaymentOrderService.updateOrder(notifyMap);
-    //            return notifyMap;
-    //        }
-
     //调用相应业务回调接口
     @Override
     public void callOrderCallBack(StudentPaymentOrder order) throws Exception {
@@ -1099,13 +1062,11 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
         List<StudentPaymentOrderDetail> studentPaymentOrderDetailList = studentPaymentOrderDetailService.queryOrderDetail(order.getId());
         String goodsIds = studentPaymentOrderDetailList.stream().filter(t -> StringUtils.isNotBlank(t.getMinuendStockGoodsIdList())).map(t -> t.getMinuendStockGoodsIdList()).collect(Collectors.joining(","));
         if(StringUtils.isNotBlank(goodsIds)){
-//        	GoodsProcurement goodsProcurement = null;
         	List<Goods> goodsList = goodsService.getGoodsWithLocked(goodsIds);
         	Map<Integer,Goods> goodsMap = goodsList.stream().collect(Collectors.toMap(Goods :: getId, t -> t));
         	Goods goods = null;
 			Map<Integer, Goods> batchUpdateGoodsMap = new HashMap<Integer, Goods>();
-//			Map<Long, GoodsProcurement> goodsProcurementMap = new HashMap<Long, GoodsProcurement>();
-        	
+
         	for(String goodsIdStr : goodsIds.split(",")){
         		if(StringUtils.isBlank(goodsIdStr)){
 					continue;
@@ -1114,29 +1075,11 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
 				if(batchUpdateGoodsMap.get(goods.getId()) != null){
 					goods = batchUpdateGoodsMap.get(goods.getId());
 				}
-//				goods.setStockCount(new AtomicInteger(goods.getStockCount()).incrementAndGet());
 				goods.setSellCount(new AtomicInteger(goods.getSellCount()).decrementAndGet());
 				goods.setUpdateTime(nowDate);
 				
 				batchUpdateGoodsMap.put(goods.getId(), goods);
-				
-				// 进货清单
-				/*goodsProcurement = goodsProcurementDao.getWithStockSurplusProcurement(goods.getId());
-				if(goodsProcurement != null){
-					if(goodsProcurementMap.get(goodsProcurement.getId()) != null){
-						goodsProcurement = goodsProcurementMap.get(goodsProcurement.getId());
-					}
-					goodsProcurement.setStockSoldNum(new AtomicInteger(goodsProcurement.getStockSoldNum()).decrementAndGet());
-					goodsProcurement.setUpdateTime(nowDate);
-					goodsProcurementMap.put(goodsProcurement.getId(), goodsProcurement);
-				}*/
-				
         	}
-        	
-        	/*if(goodsProcurementMap.size() > 0){
-        		goodsProcurementDao.batchUpdate(new ArrayList<GoodsProcurement>(goodsProcurementMap.values()));
-        	}*/
-            
             if(batchUpdateGoodsMap.size() > 0){
             	goodsService.batchUpdate(new ArrayList<Goods>(batchUpdateGoodsMap.values()));
             }
@@ -1500,8 +1443,8 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
                                     sellOrder.setBalanceAmount(subjectBalance);
                                 }else {
                                     //获取比例
-                                    BigDecimal ratioAmount = totalAmount.divide(studentGoodsSellDto.getExpectAmount(), 6, BigDecimal.ROUND_HALF_UP);
-                                    BigDecimal multiply = balancePaymentAmount.multiply(ratioAmount).setScale(2, BigDecimal.ROUND_HALF_UP);
+                                    BigDecimal ratioAmount = totalAmount.divide(studentGoodsSellDto.getExpectAmount(), 6, RoundingMode.DOWN);
+                                    BigDecimal multiply = balancePaymentAmount.multiply(ratioAmount).setScale(2, RoundingMode.DOWN);
                                     subjectBalance = subjectBalance.subtract(multiply);
                                     sellOrder.setBalanceAmount(multiply);
                                 }
@@ -1662,8 +1605,8 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
                                     sellOrder.setBalanceAmount(subjectBalance);
                                 }else {
                                     //获取比例
-                                    BigDecimal ratioAmount = totalAmount.divide(studentGoodsSellDto.getExpectAmount(), 6, BigDecimal.ROUND_HALF_UP);
-                                    BigDecimal multiply = balancePaymentAmount.multiply(ratioAmount).setScale(2, BigDecimal.ROUND_HALF_UP);
+                                    BigDecimal ratioAmount = totalAmount.divide(studentGoodsSellDto.getExpectAmount(), 6, RoundingMode.DOWN);
+                                    BigDecimal multiply = balancePaymentAmount.multiply(ratioAmount).setScale(2, RoundingMode.DOWN);
                                     subjectBalance = subjectBalance.subtract(multiply);
                                     sellOrder.setBalanceAmount(multiply);
                                 }
@@ -2039,7 +1982,7 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
                                         subtract(row.getTeachingFee()).subtract(row.getMaintenanceFee()).subtract(row.getMaintenanceProductFee()).
                                         subtract(feeByType.getOtherFee()).subtract(row.getLeaseFee()).subtract(row.getCloudTeacherFee()).
                                         subtract(row.getVipCourseFee()).subtract(row.getPracticeCourseFee()));
-                            } else if (row.getGroupType().equals(OrderTypeEnum.REPAIR)) {
+                            } else if (StringUtils.equals(row.getGroupType().getCode(),"REPAIR")) {
                                 row.setRepairFee(feeByType.getActualAmount().subtract(feeByType.getMusicalFee()).subtract(feeByType.getTeachingFee()).subtract(feeByType.getOtherFee()));
                             } else if (row.getGroupType() == GroupType.OUTORDER) {
                                 //销售收入
@@ -2208,7 +2151,7 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
 
     public BigDecimal getActualAmount(BigDecimal price, StudentPaymentOrderExportDto row) {
         if (row.getExpectAmount().compareTo(BigDecimal.ZERO) > 0) {
-            return price.multiply(row.getActualAmount()).divide(row.getExpectAmount(), 2, BigDecimal.ROUND_DOWN);
+            return price.multiply(row.getActualAmount()).divide(row.getExpectAmount(), 2, RoundingMode.DOWN);
         }
         return BigDecimal.ZERO;
     }

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

@@ -450,7 +450,7 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
 
                     BigDecimal tempPrice = BigDecimal.ZERO;
                     if (totalGroupPurchasePrice.compareTo(BigDecimal.ZERO) > 0) {
-                        tempPrice = studentPaymentOrder.getExpectAmount().multiply(goods.getGroupPurchasePrice()).divide(totalGroupPurchasePrice, BigDecimal.ROUND_DOWN).setScale(2, BigDecimal.ROUND_DOWN);
+                        tempPrice = studentPaymentOrder.getExpectAmount().multiply(goods.getGroupPurchasePrice()).divide(totalGroupPurchasePrice, RoundingMode.DOWN).setScale(2, RoundingMode.DOWN);
                     }
 
                     if (totalPrice.add(tempPrice).compareTo(studentPaymentOrder.getExpectAmount()) > 0 || goodsIdsStr.split(",").length == studentPaymentOrderDetailList.size() + 1) {
@@ -744,7 +744,7 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
 
                     BigDecimal tempPrice = BigDecimal.ZERO;
                     if (totalGroupPurchasePrice.compareTo(BigDecimal.ZERO) > 0) {
-                        tempPrice = studentPaymentOrder.getExpectAmount().subtract(repairPrice).multiply(goods.getGroupPurchasePrice()).divide(totalGroupPurchasePrice, BigDecimal.ROUND_DOWN).setScale(2, BigDecimal.ROUND_DOWN);
+                        tempPrice = studentPaymentOrder.getExpectAmount().subtract(repairPrice).multiply(goods.getGroupPurchasePrice()).divide(totalGroupPurchasePrice, RoundingMode.DOWN).setScale(2, RoundingMode.DOWN);
                     }
 
                     if (totalPrice.add(tempPrice).compareTo(studentPaymentOrder.getExpectAmount()) > 0 || goodsIds.split(",").length == studentPaymentOrderDetailList.size()) {
@@ -1007,7 +1007,7 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
                     }
                     studentPaymentOrderDetail.setGoodsIdList(goodsIdStr);
 
-                    BigDecimal tempPrice = studentPaymentOrder.getExpectAmount().subtract(repairPrice).multiply(goods.getGroupPurchasePrice()).divide(totalGroupPurchasePrice, BigDecimal.ROUND_DOWN).setScale(2, BigDecimal.ROUND_DOWN);
+                    BigDecimal tempPrice = studentPaymentOrder.getExpectAmount().subtract(repairPrice).multiply(goods.getGroupPurchasePrice()).divide(totalGroupPurchasePrice, RoundingMode.DOWN).setScale(2, RoundingMode.DOWN);
 
                     if (totalPrice.add(tempPrice).compareTo(studentPaymentOrder.getExpectAmount()) > 0 || goodsIds.split(",").length == studentPaymentOrderDetailList.size()) {
                         studentPaymentOrderDetail.setPrice(studentPaymentOrder.getExpectAmount().subtract(totalPrice));

+ 3 - 2
mec-biz/src/main/java/com/ym/mec/biz/service/impl/SubjectChangeServiceImpl.java

@@ -25,6 +25,7 @@ import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
 
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.util.*;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.stream.Collectors;
@@ -314,7 +315,7 @@ public class SubjectChangeServiceImpl extends BaseServiceImpl<Integer, SubjectCh
             	
             	StudentPaymentOrderDetail spod = new StudentPaymentOrderDetail();
                 spod.setType(OrderDetailTypeEnum.ORGAN_SHARE_PROFIT);
-                spod.setPrice(subjectChange.getChangeCourseFee().multiply(goods.getGroupPurchasePrice()).divide(goodsTotalGroupPurchasePrice, BigDecimal.ROUND_DOWN).setScale(2, BigDecimal.ROUND_DOWN));
+                spod.setPrice(subjectChange.getChangeCourseFee().multiply(goods.getGroupPurchasePrice()).divide(goodsTotalGroupPurchasePrice, RoundingMode.DOWN).setScale(2, RoundingMode.DOWN));
                 spod.setRemitFee(BigDecimal.ZERO);
                 spod.setCreateTime(date);
                 spod.setUpdateTime(date);
@@ -346,7 +347,7 @@ public class SubjectChangeServiceImpl extends BaseServiceImpl<Integer, SubjectCh
                 }
                 studentPaymentOrderDetail.setGoodsIdList(goods.getId() + "");
                 
-                BigDecimal tempPrice = studentPaymentOrder.getExpectAmount().multiply(goods.getGroupPurchasePrice()).divide(goodsTotalGroupPurchasePrice, BigDecimal.ROUND_DOWN).setScale(2, BigDecimal.ROUND_DOWN);
+                BigDecimal tempPrice = studentPaymentOrder.getExpectAmount().multiply(goods.getGroupPurchasePrice()).divide(goodsTotalGroupPurchasePrice, RoundingMode.DOWN).setScale(2, RoundingMode.DOWN);
                 
                 if(totalPrice.add(tempPrice).compareTo(studentPaymentOrder.getExpectAmount()) > 0 || goodsIdsStr.split(",").length == i){
                 	studentPaymentOrderDetail.setPrice(studentPaymentOrder.getExpectAmount().subtract(totalPrice));

+ 1 - 1
mec-biz/src/main/resources/config/mybatis/SellOrderMapper.xml

@@ -275,7 +275,7 @@
                 </if>
                 update_time_ = NOW()
             </set>
-            where id_ = #{sellOrder.id} and tenant_id_ = #{sellOrder.tenantId}
+            where id_ = #{sellOrder.id}
         </foreach>
     </update>
 

+ 0 - 59
mec-mall/mall-admin/src/main/java/com/yonge/cooleshow/admin/service/impl/OmsOrderReturnApplyServiceImpl.java

@@ -154,65 +154,6 @@ public class OmsOrderReturnApplyServiceImpl implements OmsOrderReturnApplyServic
         returnApplyMapper.updateByPrimaryKeySelective(returnApply);
     }
 
-    // private void setRecord(OmsOrderReturnApply returnApply) {
-    //     if (returnApply.getOrderItemId() != null) {
-    //         OmsOrderItem omsOrderItem = orderItemMapper.selectByPrimaryKey(returnApply.getOrderItemId());
-    //         if (omsOrderItem != null) {
-    //             MallOrderItemDto teacherShareDto = new MallOrderItemDto();
-    //             BeanUtils.copyProperties(omsOrderItem, teacherShareDto);
-    //             teacherShareDto.setRealAmount(omsOrderItem.getRealAmount().multiply(BigDecimal.valueOf(omsOrderItem.getProductQuantity())));
-    //             teacherShareDto.setProductSkuId(omsOrderItem.getProductSkuId());
-    //             teacherShareDto.setStatus(PostStatusEnum.CANCEL);
-    //             List<MallOrderItemDto> list = new ArrayList<>();
-    //             list.add(teacherShareDto);
-    //             HttpResponseResult<Boolean> result = adminFeignService.mallRecordState(list);
-    //
-    //             if (result.getStatus()) {
-    //                 log.debug("分润取消写入成功,json: {}", JSON.toJSONString(teacherShareDto));
-    //             } else {
-    //                 log.error("分润取消写入失败,json: {}",JSON.toJSONString(teacherShareDto));
-    //             }
-    //         }
-    //     }
-    // }
-
-    /**
-     * 退款处理
-     *
-     */
-    // private void refundAmount(OmsOrderReturnApply returnApply) {
-    //     // 退款
-    //     UserOrderPayment userOrderPayment = userOrderPaymentMapper.selectByOrderNoAndStatusSucceeded(returnApply.getOrderSn());
-    //     if (userOrderPayment == null) {
-    //         throw new ApiException("未找到付款信息");
-    //     }
-    //     String orderSn = generateOrderSn(returnApply);
-    //
-    //     RefundBill refundReq = new RefundBill(OpenEnum.valueOf(userOrderPayment.getOpenType()),
-    //             PaymentClientEnum.valueOf(userOrderPayment.getPaymentClient()), PayChannelEnum.valueOf(userOrderPayment.getPayChannel()));
-    //     refundReq.setRefundNo(orderSn);
-    //     refundReq.setRefundAmt(returnApply.getReturnAmount().setScale(2, RoundingMode.HALF_UP));
-    //
-    //     refundReq.setReason(returnApply.getProductName());
-    //     refundReq.setPaymentNo(userOrderPayment.getAdapayNo());
-    //     refundReq.setTradeNo(userOrderPayment.getTransNo());
-    //     refundReq.setOrderAmt(userOrderPayment.getPayAmt());
-    //     BaseResult<RefundBill> refundBillBaseResult = paymentClient.refundPayment(refundReq);
-    //     if (refundBillBaseResult.getStatus()) {
-    //         RefundBill refundBill = refundBillBaseResult.getData();
-    //         UserOrderRefund userOrderRefund = new UserOrderRefund();
-    //         userOrderRefund.setReturnId(returnApply.getId());
-    //         userOrderRefund.setOrderNo(orderSn);
-    //         userOrderRefund.setPayTransNo(userOrderPayment.getTransNo());
-    //         userOrderRefund.setRefundAmt(refundBill.getRefundAmt());
-    //         userOrderRefund.setStatus(TradeStatusEnum.pending.getCode());
-    //         userOrderRefund.setPayOrderNo(userOrderPayment.getOrderNo());
-    //         userOrderRefundMapper.insert(userOrderRefund);
-    //     } else {
-    //         throw new BizException(refundBillBaseResult.getMsg());
-    //     }
-    // }
-
     @Override
     public OmsOrderReturnApplyResult getItem(Long id) {
         return returnApplyDao.getDetail(id);