|
@@ -403,7 +403,7 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
|
|
|
return payMap;
|
|
|
}
|
|
|
|
|
|
- public List<StudentPaymentOrderDetail> initStudentPaymentOrderDetail(StudentPaymentOrder studentPaymentOrder, List<GoodsSellDto> goodsSellDtos){
|
|
|
+ public void initStudentPaymentOrderDetail(StudentPaymentOrder studentPaymentOrder, List<GoodsSellDto> goodsSellDtos){
|
|
|
Date date = new Date();
|
|
|
//添加订单详情
|
|
|
List<StudentPaymentOrderDetail> studentPaymentOrderDetailList = new ArrayList<StudentPaymentOrderDetail>();
|
|
@@ -413,24 +413,17 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
|
|
|
BigDecimal totalPrice = BigDecimal.ZERO;
|
|
|
|
|
|
if (goodsSellDtos != null) {
|
|
|
- //String goodsIdsStr = goodsSellDtos.stream().map(t -> t.getGoodsId().toString()).collect(Collectors.joining(","));
|
|
|
-
|
|
|
StringBuffer sb = new StringBuffer();
|
|
|
for (GoodsSellDto goodsSellDto : goodsSellDtos) {
|
|
|
for (int i = 0; i < goodsSellDto.getGoodsNum(); i++) {
|
|
|
sb.append(goodsSellDto.getGoodsId()).append(",");
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
String goodsIdsStr = StringUtils.removeEnd(sb.toString(), ",");
|
|
|
|
|
|
List<Goods> goodsList = goodsService.findGoodsByIds(goodsIdsStr);
|
|
|
Map<Integer, Goods> goodsMap = goodsList.stream().collect(Collectors.toMap(Goods::getId, t -> t));
|
|
|
- BigDecimal totalGroupPurchasePrice = BigDecimal.ZERO;
|
|
|
-
|
|
|
- for (String goodsIdStr : goodsIdsStr.split(",")) {
|
|
|
- totalGroupPurchasePrice = totalGroupPurchasePrice.add(goodsMap.get(Integer.parseInt(goodsIdStr)).getGroupPurchasePrice());
|
|
|
- }
|
|
|
+ BigDecimal totalGroupPurchasePrice = goodsMap.values().stream().map(Goods::getGroupPurchasePrice).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
|
|
|
Goods goods = null;
|
|
|
for (String goodsIdStr : goodsIdsStr.split(",")) {
|
|
@@ -472,10 +465,27 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (studentPaymentOrderDetailList.size() > 0) {
|
|
|
+ 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);
|
|
|
}
|
|
|
- return studentPaymentOrderDetailList;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -1235,234 +1245,6 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
|
|
|
return pageInfo;
|
|
|
}
|
|
|
|
|
|
- @Transactional(rollbackFor = Exception.class)
|
|
|
- public void saveSellOrder(String orderNo) {
|
|
|
- StudentPaymentOrder orderByOrderNo = studentPaymentOrderService.findOrderByOrderNo(orderNo);
|
|
|
- StudentGoodsSell studentGoodsSell = studentGoodsSellDao.findByOrderNo(orderNo);
|
|
|
- String goodsJson = studentGoodsSell.getGoodsJson();
|
|
|
- List<GoodsSellDto> goodsSellDtos = JSONObject.parseArray(goodsJson, GoodsSellDto.class);
|
|
|
- //用户选择的商品
|
|
|
-// Map<Integer, List<GoodsSellDto>> collect = goodsSellDtos.stream().collect(Collectors.groupingBy(GoodsSellDto::getGoodsId));
|
|
|
- List<Integer> goodsIds = goodsSellDtos.stream().map(e -> e.getGoodsId()).collect(Collectors.toList());
|
|
|
- sellOrderService.initSellOrder(orderByOrderNo,null,goodsIds,null,true);
|
|
|
- /*goodsSellDtos.forEach(e -> {
|
|
|
- for (int i = 0; i < e.getGoodsNum(); i++) {
|
|
|
- goodsIds.add(e.getGoodsId());
|
|
|
- }
|
|
|
- });
|
|
|
- AccountType accountType = AccountType.INTERNAL;
|
|
|
- if (StringUtils.isNotEmpty(orderByOrderNo.getPaymentChannel())) {
|
|
|
- accountType = sysPaymentConfigService.checkAccountType(PaymentChannelEnum.valueOf(orderByOrderNo.getPaymentChannel()), orderByOrderNo.getMerNos(), orderByOrderNo.getTenantId());
|
|
|
- }
|
|
|
- //实际扣减的库存商品
|
|
|
- List<SellOrder> sellOrderList = goodsService.subtractStock(goodsIds, accountType);
|
|
|
- Map<String, BigDecimal> costMap = new HashMap<>(2);
|
|
|
- BigDecimal balancePaymentAmount = orderByOrderNo.getBalancePaymentAmount();
|
|
|
- //可用余额
|
|
|
- BigDecimal usableBalance = balancePaymentAmount;
|
|
|
- BigDecimal marketAmount = studentGoodsSell.getMarketAmount().add(studentGoodsSell.getCouponMarketAmount());
|
|
|
- //可用减免金额
|
|
|
- BigDecimal usableMarketAmount = marketAmount;
|
|
|
- //包含减免余额的总金额
|
|
|
- BigDecimal totalAmount = goodsSellDtos.stream().map(e -> e.getTotalGoodsPrice()).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
- //组合商品减免金额
|
|
|
- Map<Integer, BigDecimal> parentGoodsCutTotalPriceMap = new HashMap<>();
|
|
|
- //组合商品附加金额
|
|
|
- Map<Integer, BigDecimal> parentGoodsAddTotalPriceMap = new HashMap<>();
|
|
|
- //组合商品实际总价
|
|
|
- Map<Integer, BigDecimal> parentGoodsTotalPriceMap = new HashMap<>();
|
|
|
- //应付总额
|
|
|
- BigDecimal totalActual = totalAmount.subtract(marketAmount);
|
|
|
- //可用应付
|
|
|
- BigDecimal usableActual = totalActual;
|
|
|
- //获取实付总额
|
|
|
- BigDecimal realityAmount = totalActual.subtract(usableBalance);
|
|
|
- //可用实付总额
|
|
|
- BigDecimal usableAmount = realityAmount;
|
|
|
- //可用组合商品总减免金额
|
|
|
- BigDecimal usableParentGoodsCutTotalPrice;
|
|
|
- //可用组合商品总附加金额
|
|
|
- BigDecimal usableParentGoodsAddTotalPrice;
|
|
|
-
|
|
|
- //获取组合商品列表
|
|
|
- List<SellOrder> orderList = sellOrderList.stream().filter(sellOrder -> sellOrder.getParentGoodsId() != null).collect(Collectors.toList());
|
|
|
- Map<Integer, List<SellOrder>> orderListMap = orderList.stream().collect(Collectors.groupingBy(SellOrder::getParentGoodsId));
|
|
|
-
|
|
|
- //获取组合商品实际销售价,和单个商品总和价
|
|
|
- for (Integer integer : orderListMap.keySet()) {
|
|
|
- SellOrder sellOrder = orderListMap.get(integer).get(0);
|
|
|
- //获取组合商品销售总价
|
|
|
- GoodsSellDto goodsSellDto = collect.get(sellOrder.getParentGoodsId()).get(0);
|
|
|
- BigDecimal parentTotalGoodsPrice = goodsSellDto.getTotalGoodsPrice().divide(new BigDecimal(goodsSellDto.getGoodsNum()));
|
|
|
- BigDecimal totalGoodsPrice = BigDecimal.ZERO;
|
|
|
- //获取单个商品销售总价
|
|
|
- for (GoodsSellDto sellDto : goodsSellDto.getGoodsSellDtos()) {
|
|
|
- totalGoodsPrice = totalGoodsPrice.add(sellDto.getTotalGoodsPrice());
|
|
|
- }
|
|
|
- parentGoodsTotalPriceMap.put(sellOrder.getParentGoodsId(), totalGoodsPrice);
|
|
|
- //如果组合价大于预计总价
|
|
|
- if (parentTotalGoodsPrice.compareTo(totalGoodsPrice) == 1) {
|
|
|
- parentGoodsAddTotalPriceMap.put(sellOrder.getParentGoodsId(), parentTotalGoodsPrice.subtract(totalGoodsPrice));
|
|
|
- } else if (parentTotalGoodsPrice.compareTo(totalGoodsPrice) == -1) {//小于
|
|
|
- parentGoodsCutTotalPriceMap.put(sellOrder.getParentGoodsId(), totalGoodsPrice.subtract(parentTotalGoodsPrice));
|
|
|
- }
|
|
|
- }
|
|
|
- //分配组合商品的中单个商品的价格
|
|
|
- noFreeAmount:
|
|
|
- for (Integer parentGoodsId : orderListMap.keySet()) {
|
|
|
-
|
|
|
- BigDecimal addTotalPrice = parentGoodsAddTotalPriceMap.get(parentGoodsId);
|
|
|
- usableParentGoodsAddTotalPrice = addTotalPrice;
|
|
|
- BigDecimal cutTotalPrice = parentGoodsCutTotalPriceMap.get(parentGoodsId);
|
|
|
- usableParentGoodsCutTotalPrice = cutTotalPrice;
|
|
|
-
|
|
|
- //获取组合商品销售总价
|
|
|
- GoodsSellDto goodsSellDto = collect.get(parentGoodsId).get(0);
|
|
|
-// BigDecimal divide = goodsSellDto.getGoodsPrice();
|
|
|
-
|
|
|
- //获取子商品明细map
|
|
|
- List<GoodsSellDto> sellDtos = goodsSellDto.getGoodsSellDtos();
|
|
|
- Map<Integer, List<GoodsSellDto>> subGoodsMap = sellDtos.stream().collect(Collectors.groupingBy(GoodsSellDto::getGoodsId));
|
|
|
- List<Integer> integers = new ArrayList<>(subGoodsMap.keySet());
|
|
|
- BigDecimal divide = parentGoodsTotalPriceMap.get(parentGoodsId);
|
|
|
- for (int i = 0; i < integers.size(); i++) {
|
|
|
- GoodsSellDto sellDto = subGoodsMap.get(integers.get(i)).get(0);
|
|
|
- //获取比例
|
|
|
- BigDecimal ratioAmount = sellDto.getTotalGoodsPrice().divide(divide, 6, BigDecimal.ROUND_HALF_UP);
|
|
|
-
|
|
|
- if (addTotalPrice != null && addTotalPrice.doubleValue() > 0l) {
|
|
|
- //如果是最后一件商品
|
|
|
- if (i == integers.size() - 1) {
|
|
|
- sellDto.setTotalGoodsPrice(sellDto.getTotalGoodsPrice().add(usableParentGoodsAddTotalPrice));
|
|
|
- } else {
|
|
|
- //获取分配的附加
|
|
|
- BigDecimal multiply = ratioAmount.multiply(addTotalPrice).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
- sellDto.setTotalGoodsPrice(sellDto.getTotalGoodsPrice().add(multiply));
|
|
|
- usableParentGoodsAddTotalPrice = usableParentGoodsAddTotalPrice.subtract(multiply);
|
|
|
- }
|
|
|
- sellDto.setGoodsPrice(sellDto.getTotalGoodsPrice());
|
|
|
- } else if (cutTotalPrice != null && cutTotalPrice.doubleValue() > 0l) {
|
|
|
- //如果是最后一件商品
|
|
|
- if (i == integers.size() - 1) {
|
|
|
- sellDto.setTotalGoodsPrice(sellDto.getTotalGoodsPrice().subtract(usableParentGoodsCutTotalPrice));
|
|
|
- } else {
|
|
|
- //获取分配的组合减免金额
|
|
|
- BigDecimal multiply = ratioAmount.multiply(cutTotalPrice).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
- sellDto.setTotalGoodsPrice(sellDto.getTotalGoodsPrice().subtract(multiply));
|
|
|
- usableParentGoodsCutTotalPrice = usableParentGoodsCutTotalPrice.subtract(multiply);
|
|
|
- }
|
|
|
- sellDto.setGoodsPrice(sellDto.getTotalGoodsPrice());
|
|
|
- } else {
|
|
|
- continue noFreeAmount;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- for (int i = 0; i < sellOrderList.size(); i++) {
|
|
|
- SellOrder sellOrder = sellOrderList.get(i);
|
|
|
- Integer e = null;
|
|
|
- if (sellOrder.getParentGoodsId() != null) {
|
|
|
- e = sellOrder.getParentGoodsId();
|
|
|
- } else {
|
|
|
- e = sellOrder.getGoodsId();
|
|
|
- }
|
|
|
- GoodsSellDto goodsSellDto = collect.get(e).get(0);
|
|
|
- List<GoodsSellDto> sellDtos = goodsSellDto.getGoodsSellDtos();
|
|
|
- if (sellDtos != null && sellDtos.size() > 0) {
|
|
|
- Map<Integer, List<GoodsSellDto>> map = sellDtos.stream().collect(Collectors.groupingBy(GoodsSellDto::getGoodsId));
|
|
|
- goodsSellDto = map.get(sellOrder.getGoodsId()).get(0);
|
|
|
- }
|
|
|
- sellOrder.setOrganId(orderByOrderNo.getOrganId());
|
|
|
- sellOrder.setTransNo(orderByOrderNo.getTransNo());
|
|
|
- sellOrder.setOrderId(orderByOrderNo.getId());
|
|
|
- sellOrder.setOrderNo(orderByOrderNo.getOrderNo());
|
|
|
- Goods goods = goodsService.get(e);
|
|
|
- costMap.put("sellCost", goods.getDiscountPrice());
|
|
|
- if (goods.getAgreeCostPrice() != null) {
|
|
|
- costMap.put("SellCost2", goods.getAgreeCostPrice());
|
|
|
- }
|
|
|
- BigDecimal multiply2 = goodsSellDto.getGoodsPrice().multiply(new BigDecimal(sellOrder.getNum()));
|
|
|
- //获取比例
|
|
|
- BigDecimal ratioAmount = multiply2.divide(totalAmount, 6, BigDecimal.ROUND_HALF_UP);
|
|
|
- //实际支付价格
|
|
|
- BigDecimal actualAmount = multiply2;
|
|
|
- //如果有减免金额
|
|
|
- if (marketAmount.doubleValue() > 0l) {
|
|
|
- //如果是最后一件商品
|
|
|
- if (i == sellOrderList.size() - 1) {
|
|
|
- actualAmount = multiply2.subtract(usableMarketAmount);
|
|
|
- } else {
|
|
|
- //获取分配的减免金额
|
|
|
- BigDecimal multiply = ratioAmount.multiply(marketAmount).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
- actualAmount = multiply2.subtract(multiply);
|
|
|
- usableMarketAmount = usableMarketAmount.subtract(multiply);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //如果没有使用余额,那么实际金额和预计金额一致
|
|
|
- if (balancePaymentAmount.doubleValue() == 0l) {
|
|
|
- sellOrder.setActualAmount(actualAmount);
|
|
|
- sellOrder.setBalanceAmount(BigDecimal.ZERO);
|
|
|
- } else {
|
|
|
- //如果是最后一件商品
|
|
|
- if (i == sellOrderList.size() - 1) {
|
|
|
- sellOrder.setActualAmount(usableAmount);
|
|
|
- sellOrder.setBalanceAmount(usableBalance);
|
|
|
- } else {
|
|
|
- //获取分配的余额
|
|
|
- BigDecimal multiply = ratioAmount.multiply(balancePaymentAmount).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
- //分配的实际支付
|
|
|
- BigDecimal multiply1 = ratioAmount.multiply(realityAmount).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
- sellOrder.setActualAmount(multiply1);
|
|
|
- sellOrder.setBalanceAmount(multiply);
|
|
|
- usableAmount = usableAmount.subtract(multiply1);
|
|
|
- usableBalance = usableBalance.subtract(multiply);
|
|
|
- usableActual = usableActual.subtract(multiply1).subtract(multiply);
|
|
|
- }
|
|
|
- }
|
|
|
- sellOrder.setExpectAmount(sellOrder.getActualAmount().add(sellOrder.getBalanceAmount()));
|
|
|
-// sellOrder.setSellCost2(JSONObject.toJSONString(costMap));
|
|
|
- if (SellTypeEnum.ACCESSORIES.getCode().equals(goodsSellDto.getGoodsType()) || SellTypeEnum.INSTRUMENT.getCode().equals(goodsSellDto.getGoodsType())) {
|
|
|
- sellOrder.setType(SellTypeEnum.valueOf(goodsSellDto.getGoodsType()));
|
|
|
- } else {
|
|
|
- sellOrder.setType(SellTypeEnum.OTHER);
|
|
|
- }
|
|
|
- sellOrder.setGoodsId(sellOrder.getGoodsId());
|
|
|
- sellOrder.setGoodsName(goodsSellDto.getGoodsName());
|
|
|
- sellOrder.setUserId(studentGoodsSell.getUserId());
|
|
|
- sellOrder.setPaymentChannel(orderByOrderNo.getPaymentChannel());
|
|
|
- sellOrder.setMerNo(orderByOrderNo.getMerNos());
|
|
|
- sellOrder.setSellTime(orderByOrderNo.getPayTime());
|
|
|
- sellOrder.setEduTeacherId(studentGoodsSell.getTeacherId());
|
|
|
- sellOrder.setCooperationOrganId(studentGoodsSell.getCooperationOrganId());
|
|
|
- }
|
|
|
- if (sellOrderList.size() > 0) {
|
|
|
- //如果有优惠券金额
|
|
|
- BigDecimal couponMarketAmount = studentGoodsSell.getCouponMarketAmount();
|
|
|
- if (couponMarketAmount.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 = couponMarketAmount;
|
|
|
- for (int i = 0; i < sellOrders.size(); i++) {
|
|
|
- SellOrder sellOrder = sellOrders.get(i);
|
|
|
- //如果是最后一件商品
|
|
|
- if (i == sellOrders.size() - 1) {
|
|
|
- sellOrder.setCouponRemitAmount(subCouponMarketAmount);
|
|
|
- } else {
|
|
|
- //获取比例
|
|
|
- BigDecimal ratioAmount = sellOrder.getExpectAmount().divide(reduce, 6, BigDecimal.ROUND_HALF_UP);
|
|
|
- //获取分配的减免金额
|
|
|
- BigDecimal multiply = couponMarketAmount.multiply(ratioAmount).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
- subCouponMarketAmount = subCouponMarketAmount.subtract(multiply);
|
|
|
- sellOrder.setCouponRemitAmount(multiply);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- sellOrderService.batchInsert(sellOrderList);
|
|
|
- sellOrderService.syncSellOrder2Mall(sellOrderList,orderByOrderNo);
|
|
|
- }*/
|
|
|
- }
|
|
|
-
|
|
|
@Override
|
|
|
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
|
|
|
public Boolean orderCallback(StudentPaymentOrder studentPaymentOrder) {
|
|
@@ -1536,32 +1318,10 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
|
|
|
rechargeDetail.setPerAmount(studentPaymentOrder.getPerAmount().negate());
|
|
|
}
|
|
|
sysUserCashAccountDetailService.insert(paymentDetail);
|
|
|
- //优惠券减免金额
|
|
|
- BigDecimal couponRemitFee = studentPaymentOrder.getCouponRemitFee();
|
|
|
- if (couponRemitFee.compareTo(BigDecimal.ZERO) > 0 && repairInfo.getAmount().compareTo(BigDecimal.ZERO) > 0) {
|
|
|
- //获取维修金额
|
|
|
- BigDecimal repairAmount = repairInfo.getAmount();
|
|
|
- //获取比例
|
|
|
- BigDecimal divide = repairAmount.divide(repairAmount.add(couponRemitFee), 6, BigDecimal.ROUND_HALF_UP);
|
|
|
- BigDecimal bigDecimal = couponRemitFee.multiply(divide).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
- couponRemitFee = couponRemitFee.subtract(bigDecimal);
|
|
|
-// repairInfo.setAmount(repairAmount.subtract(bigDecimal));
|
|
|
-// studentRepairDao.update(repairInfo);
|
|
|
- }
|
|
|
//生成销售订单
|
|
|
- if (StringUtils.isNotBlank(repairInfo.getGoodsJson())) {
|
|
|
- List<Goods> goods = JSONObject.parseArray(repairInfo.getGoodsJson(), Goods.class);
|
|
|
- List<Integer> goodsIds = goods.stream().map(Goods::getId).collect(Collectors.toList());
|
|
|
- if (goodsIds.size() > 0) {
|
|
|
- /*List<SellOrder> sellOrders = sellOrderService.addSellOrder(studentPaymentOrder.getId(),
|
|
|
- null,
|
|
|
- goodsIds,
|
|
|
- studentPaymentOrder.getExpectAmount().add(repairInfo.getExemptionAmount()),
|
|
|
- studentPaymentOrder.getBalancePaymentAmount(), couponRemitFee);*/
|
|
|
- studentPaymentOrder.setExpectAmount(studentPaymentOrder.getExpectAmount().add(repairInfo.getExemptionAmount()));
|
|
|
- studentPaymentOrder.setCouponRemitFee(couponRemitFee);
|
|
|
- sellOrderService.initSellOrder(studentPaymentOrder,null,goodsIds,null,true);
|
|
|
- }
|
|
|
+ List<StudentPaymentOrderDetail> orderDetails = studentPaymentOrderDetailService.queryOrderDetail(studentPaymentOrder.getId());
|
|
|
+ if (CollectionUtils.isNotEmpty(orderDetails)) {
|
|
|
+ sellOrderService.addOrderDetail2SellOrder(studentPaymentOrderDetailService.queryOrderDetail(studentPaymentOrder.getId()),studentPaymentOrder,null);
|
|
|
}
|
|
|
|
|
|
String imContent = repairInfo.getStudentName() + "学员您好,您的乐器维修已受理,我们会尽快完成保养维修";
|
|
@@ -1587,54 +1347,6 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
|
|
|
if (this.update(repairInfo) <= 0) {
|
|
|
throw new BizException("维修单更新失败");
|
|
|
}
|
|
|
-
|
|
|
- //增加商品库存
|
|
|
- List<StudentPaymentOrderDetail> studentPaymentOrderDetailList = studentPaymentOrderDetailService.queryOrderDetail(studentPaymentOrder.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;
|
|
|
- }
|
|
|
- goods = goodsMap.get(Integer.parseInt(goodsIdStr));
|
|
|
- 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()));
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
if (studentPaymentOrder.getBalancePaymentAmount() != null && studentPaymentOrder.getBalancePaymentAmount().compareTo(BigDecimal.ZERO) > 0) {
|
|
|
sysUserCashAccountService.updateBalance(studentPaymentOrder.getUserId(), studentPaymentOrder.getBalancePaymentAmount(), PlatformCashAccountDetailTypeEnum.REFUNDS, "乐器维修支付失败");
|
|
|
}
|