浏览代码

Merge remote-tracking branch 'origin/master'

Joburgess 4 年之前
父节点
当前提交
78fdec773e

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

@@ -282,11 +282,12 @@ public class StudentPaymentOrderDetailServiceImpl extends BaseServiceImpl<Long,
                 }
                 if (studentGoods.getChangeAccessoriesGoods() != null) {
                     String accessoriesNames = studentGoods.getChangeAccessoriesGoods().stream().map(Goods::getName).collect(Collectors.joining(","));
-                    goodsNames = StringUtils.isNotBlank(goodsNames) ? "," + accessoriesNames : accessoriesNames;
+                    goodsNames += StringUtils.isNotBlank(goodsNames) ? "," + accessoriesNames : accessoriesNames;
                 }
                 musicalListDetailDto.setGoodsNames(goodsNames);
                 musicalListDetailDto.setMusicalAmount(studentGoods.getChangeMusicalPrice());
                 musicalListDetailDto.setAccessoriesAmount(studentGoods.getChangeAccessoriesPrice());
+                musicalListDetailDto.setCourseAmount(studentGoods.getChangeCourseFee());
             }
         }
         return musicalListDetailDtos;

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

@@ -119,8 +119,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, "关闭订单");
             }
-            studentGoodsSell = studentGoodsSellDao.findByOrderNo(studentGoodsSell.getOrderNo());
-            studentGoodsSell.setGoodsSellDtos(JSON.parseArray(studentGoodsSell.getGoodsJson(),GoodsSellDto.class));
+            StudentGoodsSell byOrderNo = studentGoodsSellDao.findByOrderNo(studentGoodsSell.getOrderNo());
+            if(byOrderNo != null){
+                studentGoodsSell = byOrderNo;
+                studentGoodsSell.setGoodsSellDtos(JSON.parseArray(byOrderNo.getGoodsJson(),GoodsSellDto.class));
+            }
         }
         Integer studentId = studentGoodsSell.getUserId();
         List<GoodsSellDto> goodsSellDtos = studentGoodsSell.getGoodsSellDtos();
@@ -743,7 +746,9 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
         Map<Integer, List<Goods>> goodsMap = goodsByIds.stream().collect(Collectors.groupingBy(Goods::getId));
         Map<String, BigDecimal> costMap = new HashMap<>(2);
         List<SellOrder> sellOrders = new ArrayList<>();
-        goodsId.forEach(e->{
+        BigDecimal balancePaymentAmount = orderByOrderNo.getBalancePaymentAmount();
+
+        for (Integer e : goodsId) {
             GoodsSellDto goodsSellDto = collect.get(e).get(0);
             Goods goods = goodsMap.get(e).get(0);
 
@@ -756,9 +761,24 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
             sellOrder.setTransNo(orderByOrderNo.getTransNo());
             sellOrder.setOrderId(orderByOrderNo.getId());
             sellOrder.setOrderNo(orderByOrderNo.getOrderNo());
-            sellOrder.setExpectAmount(orderByOrderNo.getExpectAmount());
-            sellOrder.setActualAmount(orderByOrderNo.getActualAmount());
-            sellOrder.setBalanceAmount(orderByOrderNo.getBalancePaymentAmount());
+            sellOrder.setExpectAmount(goodsSellDto.getTotalGoodsPrice());
+            //如果没有使用余额,那么实际金额和预计金额一致
+            if(balancePaymentAmount.doubleValue() == 0l){
+                sellOrder.setActualAmount(goodsSellDto.getTotalGoodsPrice());
+                sellOrder.setBalanceAmount(BigDecimal.ZERO);
+            }else {
+                //余额大于等于商品总价
+                if(balancePaymentAmount.compareTo(goodsSellDto.getTotalGoodsPrice()) >= 1){
+                    sellOrder.setActualAmount(BigDecimal.ZERO);
+                    sellOrder.setBalanceAmount(goodsSellDto.getTotalGoodsPrice());
+                    balancePaymentAmount = balancePaymentAmount.subtract(goodsSellDto.getTotalGoodsPrice());
+                }else {
+                    //余额小于商品总价
+                    sellOrder.setActualAmount(goodsSellDto.getTotalGoodsPrice().subtract(balancePaymentAmount));
+                    sellOrder.setBalanceAmount(balancePaymentAmount);
+                    balancePaymentAmount = BigDecimal.ZERO;
+                }
+            }
             sellOrder.setSellCost(goods.getDiscountPrice());
             sellOrder.setSellCost2(JSONObject.toJSONString(costMap));
             sellOrder.setType(SellTypeEnum.valueOf(goods.getType().getCode()));
@@ -772,7 +792,7 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
             sellOrder.setEduTeacherId(studentGoodsSell.getTeacherId());
             sellOrder.setCooperationOrganId(studentGoodsSell.getCooperationOrganId());
             sellOrders.add(sellOrder);
-        });
+        }
         if(sellOrders.size() > 0){
             sellOrderService.batchInsert(sellOrders);
         }

+ 1 - 1
mec-web/src/main/java/com/ym/mec/web/controller/ExportController.java

@@ -716,7 +716,7 @@ public class ExportController extends BaseController {
         }
         OutputStream outputStream = response.getOutputStream();
         try {
-            HSSFWorkbook workbook = POIUtil.exportExcel(new String[]{"分部", "乐团", "学员编号", "学员姓名","声部", "购买商品", "采购方式", "乐器金额", "教辅金额", "课程金额", "订单总价"}, new String[]{
+            HSSFWorkbook workbook = POIUtil.exportExcel(new String[]{"分部", "乐团", "学员编号", "学员姓名","声部", "购买商品", "乐器采购方式", "乐器金额", "教辅金额", "课程金额", "订单总价"}, new String[]{
                     "organName", "musicGroupName", "userId", "username","subjectName", "goodsNames", "kitGroupPurchaseTypeEnum.msg", "musicalAmount", "accessoriesAmount", "courseAmount", "orderAmount"}, musicalList);
             response.setContentType("application/octet-stream");
             response.setHeader("Content-Disposition", "attachment;filename=lender-" + DateUtil.getDate(new Date()) + ".xls");