退款最大值按甲方要求调整成整个单的总额

This commit is contained in:
donqi 2022-10-06 15:34:57 +08:00
parent 37befabb49
commit 0785a887d8
2 changed files with 21 additions and 18 deletions

View File

@ -1,11 +1,8 @@
package com.ghy.web.controller.order; package com.ghy.web.controller.order;
import java.math.BigDecimal;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import com.ghy.payment.domain.FinancialDetail;
import com.ghy.payment.service.FinancialDetailService;
import org.apache.shiro.authz.annotation.RequiresPermissions; import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
@ -35,9 +32,6 @@ public class AfterServiceRecordController extends BaseController
@Autowired @Autowired
private IAfterServiceRecordService afterServiceRecordService; private IAfterServiceRecordService afterServiceRecordService;
@Autowired
private FinancialDetailService financialDetailService;
@RequiresPermissions("worker:record:view") @RequiresPermissions("worker:record:view")
@GetMapping() @GetMapping()
public String record() public String record()
@ -113,11 +107,6 @@ public class AfterServiceRecordController extends BaseController
@ResponseBody @ResponseBody
public AjaxResult addSave(@RequestBody AfterServiceRecord afterServiceRecord) public AjaxResult addSave(@RequestBody AfterServiceRecord afterServiceRecord)
{ {
FinancialDetail financialDetail = financialDetailService.selectByOrderDetailId(afterServiceRecord.getOrderDetailId());
if ((afterServiceRecord.getRefund() != null && afterServiceRecord.getRefund().compareTo(financialDetail.getPayMoney()) > 0)
|| (afterServiceRecord.getAgreedRefund() != null && afterServiceRecord.getAgreedRefund().compareTo(financialDetail.getPayMoney()) > 0)) {
return AjaxResult.error("退款金额超出子单最大可退金额");
}
return toAjax(afterServiceRecordService.insertAfterServiceRecord(afterServiceRecord)); return toAjax(afterServiceRecordService.insertAfterServiceRecord(afterServiceRecord));
} }

View File

@ -29,10 +29,11 @@ import com.ghy.order.service.IAfterServiceRecordService;
import com.ghy.order.service.OrderDetailService; import com.ghy.order.service.OrderDetailService;
import com.ghy.order.service.OrderGoodsService; import com.ghy.order.service.OrderGoodsService;
import com.ghy.order.service.OrderMasterService; import com.ghy.order.service.OrderMasterService;
import com.ghy.payment.domain.FinancialChangeRecord;
import com.ghy.payment.domain.FinancialDetail; import com.ghy.payment.domain.FinancialDetail;
import com.ghy.payment.domain.FinancialMaster; import com.ghy.payment.domain.FinancialMaster;
import com.ghy.payment.domain.OrderTimeoutRecord; import com.ghy.payment.domain.OrderTimeoutRecord;
import com.ghy.payment.service.FinancialDetailService; import com.ghy.payment.service.FinancialChangeRecordService;
import com.ghy.payment.service.FinancialMasterService; import com.ghy.payment.service.FinancialMasterService;
import com.ghy.payment.service.OrderFineRecordService; import com.ghy.payment.service.OrderFineRecordService;
import com.ghy.system.domain.SysArea; import com.ghy.system.domain.SysArea;
@ -46,6 +47,7 @@ import com.ghy.worker.domain.WorkerCertification;
import com.ghy.worker.service.IWorkerCertificationService; import com.ghy.worker.service.IWorkerCertificationService;
import com.ghy.worker.service.WorkerService; import com.ghy.worker.service.WorkerService;
import com.huifu.adapay.core.exception.BaseAdaPayException; import com.huifu.adapay.core.exception.BaseAdaPayException;
import org.apache.commons.collections.CollectionUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions; import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -91,8 +93,6 @@ public class OrderMasterController extends BaseController {
@Autowired @Autowired
private FinancialMasterService financialMasterService; private FinancialMasterService financialMasterService;
@Autowired @Autowired
private FinancialDetailService financialDetailService;
@Autowired
private GoodsStandardService goodsStandardService; private GoodsStandardService goodsStandardService;
@Autowired @Autowired
private OrderFineRecordService orderFineRecordService; private OrderFineRecordService orderFineRecordService;
@ -100,6 +100,8 @@ public class OrderMasterController extends BaseController {
private ISysAreaService sysAreaService; private ISysAreaService sysAreaService;
@Autowired @Autowired
private IAfterServiceRecordService afterServiceRecordService; private IAfterServiceRecordService afterServiceRecordService;
@Autowired
private FinancialChangeRecordService financialChangeRecordService;
@RequiresPermissions("order:master:view") @RequiresPermissions("order:master:view")
@GetMapping() @GetMapping()
@ -607,7 +609,10 @@ public class OrderMasterController extends BaseController {
try { try {
List<OrderStandardDetail> orderStandardDetails = new ArrayList<>(); List<OrderStandardDetail> orderStandardDetails = new ArrayList<>();
List<OrderDetail> detailList = orderDetailService.selectByOrderMasterId(orderMasterId); List<OrderDetail> detailList = orderDetailService.selectByOrderMasterId(orderMasterId);
detailList.forEach(detail -> { // 查询主单金额
FinancialMaster financialMaster = financialMasterService.selectByOrderMasterId(orderMasterId);
BigDecimal totalMoney = financialMaster.getPayMoney();
for (OrderDetail detail: detailList) {
// 师傅信息 // 师傅信息
Worker worker = workerService.selectById(detail.getWorkerId()); Worker worker = workerService.selectById(detail.getWorkerId());
@ -619,17 +624,26 @@ public class OrderMasterController extends BaseController {
workerName = workerRealInfo == null ? worker.getName() : workerRealInfo.getName(); workerName = workerRealInfo == null ? worker.getName() : workerRealInfo.getName();
} }
// 查询子财务单金额 // 查询子单加价记录
FinancialDetail financialDetail = financialDetailService.selectByOrderDetailId(detail.getId()); FinancialChangeRecord changeRecordQry = new FinancialChangeRecord();
changeRecordQry.setOrderDetailId(detail.getId());
List<FinancialChangeRecord> financialChangeRecords = financialChangeRecordService.selectFinancialChangeRecordList(changeRecordQry);
if (CollectionUtils.isNotEmpty(financialChangeRecords)) {
totalMoney.add(financialChangeRecords.get(0).getChangeMoney());
}
OrderStandardDetail detailRes = new OrderStandardDetail(); OrderStandardDetail detailRes = new OrderStandardDetail();
detailRes.setOrderDetailId(detail.getId()); detailRes.setOrderDetailId(detail.getId());
detailRes.setOrderDetailCode(detail.getCode()); detailRes.setOrderDetailCode(detail.getCode());
detailRes.setWorkerName(workerName); detailRes.setWorkerName(workerName);
detailRes.setRemark(workerName + "(" + detail.getCode() + ")"); detailRes.setRemark(workerName + "(" + detail.getCode() + ")");
detailRes.setPayMoney(financialDetail != null ? financialDetail.getPayMoney() : new BigDecimal(0));
orderStandardDetails.add(detailRes); orderStandardDetails.add(detailRes);
}
orderStandardDetails.stream().forEach(detail -> {
detail.setPayMoney(totalMoney);
}); });
return AjaxResult.success(orderStandardDetails); return AjaxResult.success(orderStandardDetails);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();