Commit 9520afff by huluobin

次卡使用

parent 82550ac6
...@@ -297,6 +297,15 @@ public class MarketServiceImpl implements MarketService { ...@@ -297,6 +297,15 @@ public class MarketServiceImpl implements MarketService {
timesCardUsedRecordList.forEach(timesCardUsedRecord -> timesCardUsedRecord.setStatus(TimesCardUsedRecord.STATUS_USED)); timesCardUsedRecordList.forEach(timesCardUsedRecord -> timesCardUsedRecord.setStatus(TimesCardUsedRecord.STATUS_USED));
if (ListUtil.isNotEmpty(timesCardUsedRecordList)) { if (ListUtil.isNotEmpty(timesCardUsedRecordList)) {
timesCardUsedRecordService.saveOrUpdateBatch(timesCardUsedRecordList); timesCardUsedRecordService.saveOrUpdateBatch(timesCardUsedRecordList);
//更新使用次数
TimesCardCustomerRelevance timesCardCustomerRelevance = timesCardCustomerRelevanceService.getById(timesCardUsedRecordList.stream().findAny().orElseThrow(NullPointerException::new).getCardRelevanceCustomerId());
timesCardCustomerRelevance.setUsedTimes(timesCardCustomerRelevance.getUsedTimes() + 1);
if (timesCardCustomerRelevance.getUsedTimes().equals(timesCardCustomerRelevance.getSumTimes())) {
//次数用完
timesCardCustomerRelevance.setStatus(2);
}
timesCardCustomerRelevanceService.updateById(timesCardCustomerRelevance);
} }
} }
...@@ -373,8 +382,8 @@ public class MarketServiceImpl implements MarketService { ...@@ -373,8 +382,8 @@ public class MarketServiceImpl implements MarketService {
if (orderServe != null) { if (orderServe != null) {
BigDecimal actualDiscountAmount = orderServe.getPayPrice().min(timesCardUsedRecord.getDiscountAmount()); BigDecimal actualDiscountAmount = orderServe.getPayPrice().min(timesCardUsedRecord.getDiscountAmount());
//更新次卡记录 已使用 // //更新次卡记录 已使用
timesCardUsedRecord.setStatus(TimesCardUsedRecord.STATUS_USED); // timesCardUsedRecord.setStatus(TimesCardUsedRecord.STATUS_USED);
//次卡对应订单服务的美甲师 //次卡对应订单服务的美甲师
timesCardUsedRecord.setTechnicianName(orderServe.getTechnicianName()); timesCardUsedRecord.setTechnicianName(orderServe.getTechnicianName());
//次卡店铺名称 //次卡店铺名称
...@@ -408,15 +417,15 @@ public class MarketServiceImpl implements MarketService { ...@@ -408,15 +417,15 @@ public class MarketServiceImpl implements MarketService {
//业绩 //业绩
orderServe.setAchievement(orderServe.getAchievement().subtract(actualDiscountAmount).add(timesCardUsedRecord.getPayAmount())); orderServe.setAchievement(orderServe.getAchievement().subtract(actualDiscountAmount).add(timesCardUsedRecord.getPayAmount()));
orderManage.addDiscountPrice(actualDiscountAmount); orderManage.addDiscountPrice(actualDiscountAmount);
//
//更新使用次数 // //更新使用次数
TimesCardCustomerRelevance timesCardCustomerRelevance = timesCardCustomerRelevanceService.getById(timesCardUsedRecord.getCardRelevanceCustomerId()); // TimesCardCustomerRelevance timesCardCustomerRelevance = timesCardCustomerRelevanceService.getById(timesCardUsedRecord.getCardRelevanceCustomerId());
timesCardCustomerRelevance.setUsedTimes(timesCardCustomerRelevance.getUsedTimes() + 1); // timesCardCustomerRelevance.setUsedTimes(timesCardCustomerRelevance.getUsedTimes() + 1);
if (timesCardCustomerRelevance.getUsedTimes().equals(timesCardCustomerRelevance.getSumTimes())) { // if (timesCardCustomerRelevance.getUsedTimes().equals(timesCardCustomerRelevance.getSumTimes())) {
//次数用完 // //次数用完
timesCardCustomerRelevance.setStatus(2); // timesCardCustomerRelevance.setStatus(2);
} // }
timesCardCustomerRelevanceService.updateById(timesCardCustomerRelevance); // timesCardCustomerRelevanceService.updateById(timesCardCustomerRelevance);
} else { } else {
throw new RRException("次卡冲突"); throw new RRException("次卡冲突");
} }
...@@ -761,14 +770,14 @@ public class MarketServiceImpl implements MarketService { ...@@ -761,14 +770,14 @@ public class MarketServiceImpl implements MarketService {
orderServe.setAchievement(orderServe.getAchievement().subtract(actualDiscountAmount).add(timesCardUsedRecord.getPayAmount())); orderServe.setAchievement(orderServe.getAchievement().subtract(actualDiscountAmount).add(timesCardUsedRecord.getPayAmount()));
orderManage.addDiscountPrice(actualDiscountAmount); orderManage.addDiscountPrice(actualDiscountAmount);
//更新使用次数 // //更新使用次数
TimesCardCustomerRelevance timesCardCustomerRelevance = timesCardCustomerRelevanceService.getById(timesCardUsedRecord.getCardRelevanceCustomerId()); // TimesCardCustomerRelevance timesCardCustomerRelevance = timesCardCustomerRelevanceService.getById(timesCardUsedRecord.getCardRelevanceCustomerId());
timesCardCustomerRelevance.setUsedTimes(timesCardCustomerRelevance.getUsedTimes() + 1); // timesCardCustomerRelevance.setUsedTimes(timesCardCustomerRelevance.getUsedTimes() + 1);
if (timesCardCustomerRelevance.getUsedTimes().equals(timesCardCustomerRelevance.getSumTimes())) { // if (timesCardCustomerRelevance.getUsedTimes().equals(timesCardCustomerRelevance.getSumTimes())) {
//次数用完 // //次数用完
timesCardCustomerRelevance.setStatus(2); // timesCardCustomerRelevance.setStatus(2);
} // }
timesCardCustomerRelevanceService.updateById(timesCardCustomerRelevance); // timesCardCustomerRelevanceService.updateById(timesCardCustomerRelevance);
} else { } else {
throw new RRException("次卡冲突"); throw new RRException("次卡冲突");
} }
......
...@@ -269,14 +269,14 @@ public class OrderManageController { ...@@ -269,14 +269,14 @@ public class OrderManageController {
@ApiOperation("重算业绩") @ApiOperation("重算业绩")
@GetMapping("/technician/ordermanage/no_achievementReCalc/{orderId}") @GetMapping("/technician/ordermanage/no_achievementReCalc/{orderId}")
public JsonResult<Void> achievementReCalc(@PathVariable Integer orderId) { public JsonResult<Void> achievementReCalc(@PathVariable Integer orderId) {
// marketService.achievementReCalc(orderId); marketService.achievementReCalc(orderId);
return JsonResult.success(); return JsonResult.success();
} }
@ApiOperation("重算订单金额") @ApiOperation("重算订单金额")
@GetMapping("/technician/ordermanage/no_calcOrderAmount/{orderId}") @GetMapping("/technician/ordermanage/no_calcOrderAmount/{orderId}")
public JsonResult<Void> calcOrderAmount(@PathVariable Integer orderId) { public JsonResult<Void> calcOrderAmount(@PathVariable Integer orderId) {
// marketService.calcOrderAmount(orderId); marketService.calcOrderAmount(orderId);
return JsonResult.success(); return JsonResult.success();
} }
} }
\ No newline at end of file
...@@ -661,4 +661,13 @@ public class Test { ...@@ -661,4 +661,13 @@ public class Test {
}); });
} }
/**
* 重算订单金额
*/
@org.junit.Test
public void calcOrderAmount() {
marketService.calcOrderAmount(13659);
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment