|
@@ -220,6 +220,10 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
|
|
studentGoodsSell.setGoodsJson(JSONObject.toJSONString(goodsSellDtos));
|
|
studentGoodsSell.setGoodsJson(JSONObject.toJSONString(goodsSellDtos));
|
|
String orderNo = idGeneratorService.generatorId("payment") + "";
|
|
String orderNo = idGeneratorService.generatorId("payment") + "";
|
|
studentGoodsSell.setOrderNo(orderNo);
|
|
studentGoodsSell.setOrderNo(orderNo);
|
|
|
|
+ List<Integer> couponIdList = studentGoodsSell.getCouponIdList();
|
|
|
|
+ if(couponIdList != null && couponIdList.size() > 0){
|
|
|
|
+ studentGoodsSell.setCouponIds(StringUtils.join(couponIdList,","));
|
|
|
|
+ }
|
|
studentGoodsSellDao.insert(studentGoodsSell);
|
|
studentGoodsSellDao.insert(studentGoodsSell);
|
|
|
|
|
|
if (studentGoodsSell.getType() == 1) {
|
|
if (studentGoodsSell.getType() == 1) {
|
|
@@ -454,6 +458,8 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ StudentPaymentOrder studentPaymentOrder = sysCouponCodeService.use(repairInfo.getCouponIdList(),amount);
|
|
|
|
+ amount = studentPaymentOrder.getActualAmount();
|
|
amount = amount.subtract(repairInfo.getExemptionAmount());
|
|
amount = amount.subtract(repairInfo.getExemptionAmount());
|
|
if (amount.compareTo(BigDecimal.ZERO) < 0) {
|
|
if (amount.compareTo(BigDecimal.ZERO) < 0) {
|
|
throw new BizException("特权减免金额不能大于总金额");
|
|
throw new BizException("特权减免金额不能大于总金额");
|
|
@@ -469,13 +475,10 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
|
|
repairInfo.setPayStatus(1);
|
|
repairInfo.setPayStatus(1);
|
|
String channelType = "";
|
|
String channelType = "";
|
|
|
|
|
|
- StudentPaymentOrder studentPaymentOrder = new StudentPaymentOrder();
|
|
|
|
studentPaymentOrder.setUserId(repairInfo.getStudentId());
|
|
studentPaymentOrder.setUserId(repairInfo.getStudentId());
|
|
studentPaymentOrder.setGroupType(GroupType.REPAIR);
|
|
studentPaymentOrder.setGroupType(GroupType.REPAIR);
|
|
studentPaymentOrder.setOrderNo(orderNo);
|
|
studentPaymentOrder.setOrderNo(orderNo);
|
|
studentPaymentOrder.setType(OrderTypeEnum.REPAIR);
|
|
studentPaymentOrder.setType(OrderTypeEnum.REPAIR);
|
|
- studentPaymentOrder.setExpectAmount(amount);
|
|
|
|
- studentPaymentOrder.setActualAmount(amount);
|
|
|
|
studentPaymentOrder.setStatus(DealStatusEnum.ING);
|
|
studentPaymentOrder.setStatus(DealStatusEnum.ING);
|
|
studentPaymentOrder.setMusicGroupId(repairInfo.getId().toString());
|
|
studentPaymentOrder.setMusicGroupId(repairInfo.getId().toString());
|
|
studentPaymentOrder.setPaymentChannel("BALANCE");
|
|
studentPaymentOrder.setPaymentChannel("BALANCE");
|
|
@@ -487,7 +490,7 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
|
|
studentPaymentOrder.setVersion(0);
|
|
studentPaymentOrder.setVersion(0);
|
|
|
|
|
|
BigDecimal balance = BigDecimal.ZERO;
|
|
BigDecimal balance = BigDecimal.ZERO;
|
|
- if (repairInfo.getIsUseBalancePayment() && amount.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
|
|
|
+ if (repairInfo.getUseBalancePayment() && amount.compareTo(BigDecimal.ZERO) > 0) {
|
|
SysUserCashAccount userCashAccount = sysUserCashAccountService.getLocked(repairInfo.getStudentId());
|
|
SysUserCashAccount userCashAccount = sysUserCashAccountService.getLocked(repairInfo.getStudentId());
|
|
if (userCashAccount == null) {
|
|
if (userCashAccount == null) {
|
|
throw new BizException("用户账户找不到");
|
|
throw new BizException("用户账户找不到");
|
|
@@ -612,7 +615,7 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
|
|
amount = amount.subtract(studentRepair.getExemptionAmount());
|
|
amount = amount.subtract(studentRepair.getExemptionAmount());
|
|
|
|
|
|
String orderNo = idGeneratorService.generatorId("payment") + "";
|
|
String orderNo = idGeneratorService.generatorId("payment") + "";
|
|
- studentRepair.setIsUseBalancePayment(repairInfo.getIsUseBalancePayment());
|
|
|
|
|
|
+ studentRepair.setUseBalancePayment(repairInfo.getUseBalancePayment());
|
|
studentRepair.setTransNo(orderNo);
|
|
studentRepair.setTransNo(orderNo);
|
|
studentRepair.setRepairStatus(0);
|
|
studentRepair.setRepairStatus(0);
|
|
studentRepair.setPayStatus(1);
|
|
studentRepair.setPayStatus(1);
|
|
@@ -643,7 +646,7 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
|
|
studentPaymentOrder.setVersion(0);
|
|
studentPaymentOrder.setVersion(0);
|
|
|
|
|
|
BigDecimal balance = BigDecimal.ZERO;
|
|
BigDecimal balance = BigDecimal.ZERO;
|
|
- if (studentRepair.getIsUseBalancePayment() && amount.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
|
|
|
+ if (studentRepair.getUseBalancePayment() && amount.compareTo(BigDecimal.ZERO) > 0) {
|
|
SysUserCashAccount userCashAccount = sysUserCashAccountService.getLocked(studentRepair.getStudentId());
|
|
SysUserCashAccount userCashAccount = sysUserCashAccountService.getLocked(studentRepair.getStudentId());
|
|
if (userCashAccount == null) {
|
|
if (userCashAccount == null) {
|
|
throw new BizException("用户账户找不到");
|
|
throw new BizException("用户账户找不到");
|
|
@@ -1071,12 +1074,28 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
|
|
rechargeDetail.setPerAmount(studentPaymentOrder.getPerAmount().negate());
|
|
rechargeDetail.setPerAmount(studentPaymentOrder.getPerAmount().negate());
|
|
}
|
|
}
|
|
sysUserCashAccountDetailService.insert(paymentDetail);
|
|
sysUserCashAccountDetailService.insert(paymentDetail);
|
|
|
|
+ //优惠券减免金额
|
|
|
|
+ BigDecimal couponRemitFee = studentPaymentOrder.getCouponRemitFee();
|
|
|
|
+ if(studentPaymentOrder.getCouponRemitFee().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())) {
|
|
if (StringUtils.isNotBlank(repairInfo.getGoodsJson())) {
|
|
List<Goods> goods = JSONObject.parseArray(repairInfo.getGoodsJson(), Goods.class);
|
|
List<Goods> goods = JSONObject.parseArray(repairInfo.getGoodsJson(), Goods.class);
|
|
List<Integer> goodsIds = goods.stream().map(Goods::getId).collect(Collectors.toList());
|
|
List<Integer> goodsIds = goods.stream().map(Goods::getId).collect(Collectors.toList());
|
|
if (goodsIds.size() > 0) {
|
|
if (goodsIds.size() > 0) {
|
|
- sellOrderService.addSellOrder(studentPaymentOrder.getId(), null, goodsIds, studentPaymentOrder.getExpectAmount().add(repairInfo.getExemptionAmount()), studentPaymentOrder.getBalancePaymentAmount());
|
|
|
|
|
|
+ sellOrderService.addSellOrder(studentPaymentOrder.getId(),
|
|
|
|
+ null,
|
|
|
|
+ goodsIds,
|
|
|
|
+ studentPaymentOrder.getExpectAmount().add(repairInfo.getExemptionAmount()),
|
|
|
|
+ studentPaymentOrder.getBalancePaymentAmount(),couponRemitFee);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|