Commit 50f60a9f authored by lizhichao's avatar lizhichao

新增外部采购-可用金额验证

parent f80e1e0e
......@@ -3,9 +3,11 @@ package com.zehong.web.controller.transaction;
import java.util.List;
import com.zehong.common.core.domain.entity.SysUser;
import com.zehong.common.utils.SecurityUtils;
import com.zehong.common.utils.ServletUtils;
import com.zehong.common.utils.StringUtils;
import com.zehong.framework.web.service.TokenService;
import com.zehong.system.service.ITAccountService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
......@@ -39,6 +41,8 @@ public class TPurchaseController extends BaseController
private ITPurchaseService tPurchaseService;
@Autowired
private TokenService tokenService;
@Autowired
private ITAccountService itAccountService;
/**
* 查询外部采购(报销)申请列表
*/
......@@ -87,6 +91,11 @@ public class TPurchaseController extends BaseController
@PostMapping
public AjaxResult add(@RequestBody TPurchase tPurchase)
{
SysUser user = SecurityUtils.getLoginUser().getUser();
if(!itAccountService.checkAccountCanTrade(user.getDeptId(),tPurchase.getTotal())){
return AjaxResult.error("账户可用金额不足!");
}
return toAjax(tPurchaseService.insertTPurchase(tPurchase));
}
......
......@@ -58,4 +58,5 @@ public interface TAccountMapper
* @return 结果
*/
public int deleteTAccountByIds(Long[] accountIds);
}
package com.zehong.system.service;
import java.math.BigDecimal;
import java.util.List;
import com.zehong.system.domain.TAccount;
......@@ -58,4 +59,6 @@ public interface ITAccountService
* @return 结果
*/
public int deleteTAccountById(Long accountId);
public boolean checkAccountCanTrade(Long deptId, BigDecimal amount);
}
package com.zehong.system.service.impl;
import java.math.BigDecimal;
import java.util.List;
import com.zehong.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -93,4 +94,20 @@ public class TAccountServiceImpl implements ITAccountService
{
return tAccountMapper.deleteTAccountById(accountId);
}
@Override
public boolean checkAccountCanTrade(Long deptId, BigDecimal amount) {
TAccount tAccount=new TAccount();
tAccount.setDeptId(deptId);
List<TAccount> rst=tAccountMapper.selectTAccountList(tAccount);
if(rst!=null&&rst.size()>0){
if(rst.get(0).getAbleAmount().compareTo(amount)>=0) {
return true;
}else {
return false;
}
}else{
return false;
}
}
}
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