|
|
@@ -166,9 +166,9 @@ public class FsCompanyDeductController extends BaseController
|
|
|
@RepeatSubmit
|
|
|
public R audit(@RequestBody CompanyDeduct param)
|
|
|
{
|
|
|
- CompanyDeduct deduct=companyDeductService.selectCompanyDeductById(param.getDeductId());
|
|
|
+ CompanyDeduct deduct=companyDeductService.selectCompanyDeductByIdForUpdate(param.getDeductId());
|
|
|
if(deduct.getIsAudit()!=0){
|
|
|
- return R.error("非法操作");
|
|
|
+ return R.error("该扣款记录已审核,请勿重复操作");
|
|
|
}
|
|
|
deduct.setIsAudit(param.getIsAudit());
|
|
|
deduct.setRemark(param.getRemark());
|
|
|
@@ -176,9 +176,22 @@ public class FsCompanyDeductController extends BaseController
|
|
|
if(loginUser.getUser().getDeptId() == null){
|
|
|
return R.error("审核失败,当前审核账号未绑定部门!");
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
if(deduct.getIsAudit()==1){
|
|
|
Company company=companyService.selectCompanyByIdForUpdate(deduct.getCompanyId());
|
|
|
- company.setMoney(company.getMoney().subtract(deduct.getMoney()));
|
|
|
+ BigDecimal deductMoney = deduct.getMoney();
|
|
|
+ BigDecimal companyMoney = company.getMoney();
|
|
|
+ if(companyMoney == null){
|
|
|
+ companyMoney = BigDecimal.ZERO;
|
|
|
+ }
|
|
|
+ if(deductMoney == null){
|
|
|
+ deductMoney = BigDecimal.ZERO;
|
|
|
+ }
|
|
|
+ if(companyMoney.compareTo(deductMoney) < 0){
|
|
|
+ return R.error("审核失败,销售公司余额不足!当前余额:" + companyMoney + "元,扣款金额:" + deductMoney + "元");
|
|
|
+ }
|
|
|
+ company.setMoney(companyMoney.subtract(deductMoney));
|
|
|
deduct.setBalance(company.getMoney());
|
|
|
companyService.updateCompany(company);
|
|
|
//生成流水
|