|
@@ -107,10 +107,10 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
|
|
SysUser sysUser = sysUserFeignService.queryUserInfo();
|
|
SysUser sysUser = sysUserFeignService.queryUserInfo();
|
|
Integer studentId = sysUser.getId();
|
|
Integer studentId = sysUser.getId();
|
|
String goodsId = goodsSellDto.getGoodsId();
|
|
String goodsId = goodsSellDto.getGoodsId();
|
|
- if(StringUtils.isEmpty(goodsId)){
|
|
|
|
|
|
+ if (StringUtils.isEmpty(goodsId)) {
|
|
throw new BizException("请选择需要购买的商品");
|
|
throw new BizException("请选择需要购买的商品");
|
|
}
|
|
}
|
|
- if(studentId == null){
|
|
|
|
|
|
+ if (studentId == null) {
|
|
throw new BizException("请指定学员");
|
|
throw new BizException("请指定学员");
|
|
}
|
|
}
|
|
studentDao.lockUser(studentId);
|
|
studentDao.lockUser(studentId);
|
|
@@ -231,11 +231,11 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
|
|
repairInfo.setCreateTime(date);
|
|
repairInfo.setCreateTime(date);
|
|
repairInfo.setUpdateTime(date);
|
|
repairInfo.setUpdateTime(date);
|
|
String goodsJson = repairInfo.getGoodsJson();
|
|
String goodsJson = repairInfo.getGoodsJson();
|
|
- if(StringUtils.isNotEmpty(goodsJson)){
|
|
|
|
|
|
+ if (StringUtils.isNotEmpty(goodsJson)) {
|
|
List<RepairGoodsDto> repairGoodsDtos = JSONObject.parseArray(goodsJson, RepairGoodsDto.class);
|
|
List<RepairGoodsDto> repairGoodsDtos = JSONObject.parseArray(goodsJson, RepairGoodsDto.class);
|
|
List<Integer> goodsIds = repairGoodsDtos.stream().map(e -> e.getId()).collect(Collectors.toList());
|
|
List<Integer> goodsIds = repairGoodsDtos.stream().map(e -> e.getId()).collect(Collectors.toList());
|
|
Map<Integer, BigDecimal> map = getMap("goods", "id_", "group_purchase_price_", goodsIds, Integer.class, BigDecimal.class);
|
|
Map<Integer, BigDecimal> map = getMap("goods", "id_", "group_purchase_price_", goodsIds, Integer.class, BigDecimal.class);
|
|
- repairGoodsDtos.forEach(e->{
|
|
|
|
|
|
+ repairGoodsDtos.forEach(e -> {
|
|
e.setGroupPurchasePrice(map.get(e.getId()));
|
|
e.setGroupPurchasePrice(map.get(e.getId()));
|
|
});
|
|
});
|
|
repairInfo.setGoodsJson(JSONObject.toJSONString(repairGoodsDtos));
|
|
repairInfo.setGoodsJson(JSONObject.toJSONString(repairGoodsDtos));
|
|
@@ -247,13 +247,13 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
|
|
return repairInfoMap;
|
|
return repairInfoMap;
|
|
}
|
|
}
|
|
|
|
|
|
- if(StringUtils.isNoneBlank(repairInfo.getGoodsJson())){
|
|
|
|
|
|
+ if (StringUtils.isNoneBlank(repairInfo.getGoodsJson())) {
|
|
JSONArray goods = JSON.parseArray(repairInfo.getGoodsJson());
|
|
JSONArray goods = JSON.parseArray(repairInfo.getGoodsJson());
|
|
for (Object good : goods) {
|
|
for (Object good : goods) {
|
|
- JSONObject goodObject= (JSONObject) good;
|
|
|
|
|
|
+ JSONObject goodObject = (JSONObject) good;
|
|
BigDecimal groupPurchasePrice = goodObject.getBigDecimal("groupPurchasePrice");
|
|
BigDecimal groupPurchasePrice = goodObject.getBigDecimal("groupPurchasePrice");
|
|
- if(Objects.nonNull(groupPurchasePrice)){
|
|
|
|
- amount=amount.add(groupPurchasePrice);
|
|
|
|
|
|
+ if (Objects.nonNull(groupPurchasePrice)) {
|
|
|
|
+ amount = amount.add(groupPurchasePrice);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -402,7 +402,7 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
|
|
studentDao.lockUser(studentRepair.getStudentId());
|
|
studentDao.lockUser(studentRepair.getStudentId());
|
|
BigDecimal amount = studentRepair.getAmount();
|
|
BigDecimal amount = studentRepair.getAmount();
|
|
String goodsJson = studentRepair.getGoodsJson();
|
|
String goodsJson = studentRepair.getGoodsJson();
|
|
- if(StringUtils.isNotEmpty(goodsJson)){
|
|
|
|
|
|
+ if (StringUtils.isNotEmpty(goodsJson)) {
|
|
List<RepairGoodsDto> repairGoodsDtos = JSONObject.parseArray(goodsJson, RepairGoodsDto.class);
|
|
List<RepairGoodsDto> repairGoodsDtos = JSONObject.parseArray(goodsJson, RepairGoodsDto.class);
|
|
BigDecimal reduce = repairGoodsDtos.stream().map(e -> e.getGroupPurchasePrice()).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
BigDecimal reduce = repairGoodsDtos.stream().map(e -> e.getGroupPurchasePrice()).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
amount = amount.add(reduce);
|
|
amount = amount.add(reduce);
|
|
@@ -562,13 +562,13 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
|
|
//商品总付款
|
|
//商品总付款
|
|
BigDecimal detailTotalPrice = orderDetails.stream().map(StudentPaymentOrderDetail::getPrice).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
BigDecimal detailTotalPrice = orderDetails.stream().map(StudentPaymentOrderDetail::getPrice).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
//商品销售占的余额
|
|
//商品销售占的余额
|
|
- BigDecimal detailTotalBalance = detailTotalPrice.multiply(totalBalance).divide(totalPrice,2,BigDecimal.ROUND_HALF_UP);
|
|
|
|
|
|
+ BigDecimal detailTotalBalance = detailTotalPrice.multiply(totalBalance).divide(totalPrice, 2, BigDecimal.ROUND_HALF_UP);
|
|
|
|
|
|
int i = 1;
|
|
int i = 1;
|
|
BigDecimal detailRouteBalance = BigDecimal.ZERO;
|
|
BigDecimal detailRouteBalance = BigDecimal.ZERO;
|
|
for (StudentPaymentOrderDetail orderDetail : orderDetails) {
|
|
for (StudentPaymentOrderDetail orderDetail : orderDetails) {
|
|
- BigDecimal detailBalance = orderDetail.getPrice().multiply(detailTotalBalance).divide(detailTotalPrice,2,BigDecimal.ROUND_HALF_UP);
|
|
|
|
- if(i == orderDetails.size()){
|
|
|
|
|
|
+ BigDecimal detailBalance = orderDetail.getPrice().multiply(detailTotalBalance).divide(detailTotalPrice, 2, BigDecimal.ROUND_HALF_UP);
|
|
|
|
+ if (i == orderDetails.size()) {
|
|
detailBalance = detailTotalBalance.subtract(detailRouteBalance);
|
|
detailBalance = detailTotalBalance.subtract(detailRouteBalance);
|
|
}
|
|
}
|
|
detailRouteBalance = detailRouteBalance.add(detailBalance);
|
|
detailRouteBalance = detailRouteBalance.add(detailBalance);
|
|
@@ -585,9 +585,9 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
|
|
for (Goods goods : orderDetail.getGoodsList()) {
|
|
for (Goods goods : orderDetail.getGoodsList()) {
|
|
BigDecimal expectAmount = goods.getGroupPurchasePrice().multiply(orderDetail.getPrice()).divide(goodsTotalPrice, 2, BigDecimal.ROUND_HALF_UP);
|
|
BigDecimal expectAmount = goods.getGroupPurchasePrice().multiply(orderDetail.getPrice()).divide(goodsTotalPrice, 2, BigDecimal.ROUND_HALF_UP);
|
|
BigDecimal balance = goods.getGroupPurchasePrice().multiply(detailBalance).divide(goodsTotalPrice, 2, BigDecimal.ROUND_HALF_UP);
|
|
BigDecimal balance = goods.getGroupPurchasePrice().multiply(detailBalance).divide(goodsTotalPrice, 2, BigDecimal.ROUND_HALF_UP);
|
|
- if(j==orderDetail.getGoodsList().size()){
|
|
|
|
- expectAmount = orderDetail.getPrice().subtract(routePrice);
|
|
|
|
- balance = orderDetail.getPrice().subtract(routeBalance);
|
|
|
|
|
|
+ if (j == orderDetail.getGoodsList().size()) {
|
|
|
|
+ expectAmount = orderDetail.getPrice().subtract(routePrice);
|
|
|
|
+ balance = orderDetail.getPrice().subtract(routeBalance);
|
|
}
|
|
}
|
|
routePrice = routePrice.add(expectAmount);
|
|
routePrice = routePrice.add(expectAmount);
|
|
routeBalance = routeBalance.add(balance);
|
|
routeBalance = routeBalance.add(balance);
|
|
@@ -595,9 +595,9 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
|
|
|
|
|
|
SellOrder sellOrder = new SellOrder();
|
|
SellOrder sellOrder = new SellOrder();
|
|
Map<String, BigDecimal> CostMap = new HashMap<>();
|
|
Map<String, BigDecimal> CostMap = new HashMap<>();
|
|
- CostMap.put("sellCost",goods.getDiscountPrice());
|
|
|
|
- if(goods.getAgreeCostPrice() != null){
|
|
|
|
- CostMap.put("SellCost2",goods.getAgreeCostPrice());
|
|
|
|
|
|
+ CostMap.put("sellCost", goods.getDiscountPrice());
|
|
|
|
+ if (goods.getAgreeCostPrice() != null) {
|
|
|
|
+ CostMap.put("SellCost2", goods.getAgreeCostPrice());
|
|
}
|
|
}
|
|
sellOrder.setOrganId(studentPaymentOrder.getOrganId());
|
|
sellOrder.setOrganId(studentPaymentOrder.getOrganId());
|
|
sellOrder.setTransNo(studentPaymentOrder.getTransNo());
|
|
sellOrder.setTransNo(studentPaymentOrder.getTransNo());
|
|
@@ -627,7 +627,7 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
|
|
}
|
|
}
|
|
sellOrderDao.batchInsert(sellOrders);
|
|
sellOrderDao.batchInsert(sellOrders);
|
|
}
|
|
}
|
|
- }else if(studentPaymentOrder.getStatus() == DealStatusEnum.CLOSE || studentPaymentOrder.getStatus() == DealStatusEnum.FAILED){
|
|
|
|
|
|
+ } else if (studentPaymentOrder.getStatus() == DealStatusEnum.CLOSE || studentPaymentOrder.getStatus() == DealStatusEnum.FAILED) {
|
|
if (studentPaymentOrder.getBalancePaymentAmount() != null && studentPaymentOrder.getBalancePaymentAmount().compareTo(BigDecimal.ZERO) > 0) {
|
|
if (studentPaymentOrder.getBalancePaymentAmount() != null && studentPaymentOrder.getBalancePaymentAmount().compareTo(BigDecimal.ZERO) > 0) {
|
|
sysUserCashAccountService.updateBalance(studentPaymentOrder.getUserId(), studentPaymentOrder.getBalancePaymentAmount(), PlatformCashAccountDetailTypeEnum.REFUNDS, "乐器维修支付失败");
|
|
sysUserCashAccountService.updateBalance(studentPaymentOrder.getUserId(), studentPaymentOrder.getBalancePaymentAmount(), PlatformCashAccountDetailTypeEnum.REFUNDS, "乐器维修支付失败");
|
|
}
|
|
}
|
|
@@ -649,7 +649,7 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
|
|
if (repairInfo == null) {
|
|
if (repairInfo == null) {
|
|
throw new BizException("维修单不存在");
|
|
throw new BizException("维修单不存在");
|
|
}
|
|
}
|
|
- if(repairInfo.getPayStatus().equals(2)){
|
|
|
|
|
|
+ if (repairInfo.getPayStatus().equals(2)) {
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -703,13 +703,14 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
|
|
sysUserCashAccountDetailService.insert(paymentDetail);
|
|
sysUserCashAccountDetailService.insert(paymentDetail);
|
|
//生成销售订单
|
|
//生成销售订单
|
|
List<Integer> goodsIds = new ArrayList<>();
|
|
List<Integer> goodsIds = new ArrayList<>();
|
|
- 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);
|
|
goodsIds = goods.stream().map(Goods::getId).collect(Collectors.toList());
|
|
goodsIds = goods.stream().map(Goods::getId).collect(Collectors.toList());
|
|
|
|
+ if (goodsIds.size() > 0) {
|
|
|
|
+ sellOrderService.addSellOrder(studentPaymentOrder.getId(), repairInfo.getMusicGroupId(), goodsIds, studentPaymentOrder.getExpectAmount(), studentPaymentOrder.getBalancePaymentAmount());
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
- sellOrderService.addSellOrder(studentPaymentOrder.getId(),repairInfo.getMusicGroupId(),goodsIds,studentPaymentOrder.getExpectAmount(),studentPaymentOrder.getBalancePaymentAmount());
|
|
|
|
-
|
|
|
|
String imContent = repairInfo.getStudentName() + "学员您好,您的乐器维修已受理,我们会尽快完成保养维修";
|
|
String imContent = repairInfo.getStudentName() + "学员您好,您的乐器维修已受理,我们会尽快完成保养维修";
|
|
|
|
|
|
if (repairInfo.getType().equals(1)) { //线上
|
|
if (repairInfo.getType().equals(1)) { //线上
|