优化收预付款的逻辑

This commit is contained in:
季圣华
2021-07-08 01:23:12 +08:00
parent b27ffdf1e5
commit ec87cd182b
3 changed files with 18 additions and 6 deletions

View File

@@ -290,8 +290,7 @@ public class DepotHeadController {
JSONObject result = ExceptionConstants.standardSuccess();
String beanJson = body.getInfo();
String rows = body.getRows();
BigDecimal preTotalPrice = body.getPreTotalPrice();
depotHeadService.updateDepotHeadAndDetail(beanJson,rows,preTotalPrice,tenantId,request);
depotHeadService.updateDepotHeadAndDetail(beanJson,rows,tenantId,request);
return result;
}

View File

@@ -13,6 +13,7 @@ import com.jsh.erp.exception.JshException;
import com.jsh.erp.service.accountItem.AccountItemService;
import com.jsh.erp.service.log.LogService;
import com.jsh.erp.service.orgaUserRel.OrgaUserRelService;
import com.jsh.erp.service.supplier.SupplierService;
import com.jsh.erp.service.user.UserService;
import com.jsh.erp.utils.StringUtil;
import com.jsh.erp.utils.Tools;
@@ -46,6 +47,8 @@ public class AccountHeadService {
@Resource
private UserService userService;
@Resource
private SupplierService supplierService;
@Resource
private LogService logService;
@Resource
private AccountItemMapperEx accountItemMapperEx;
@@ -221,6 +224,7 @@ public class AccountHeadService {
return list==null?0:list.size();
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public void addAccountHeadAndDetail(String beanJson, String rows, HttpServletRequest request) throws Exception {
AccountHead accountHead = JSONObject.parseObject(beanJson, AccountHead.class);
User userInfo=userService.getCurrentUser();
@@ -236,12 +240,18 @@ public class AccountHeadService {
/**处理单据子表信息*/
accountItemService.saveDetials(rows, headId, type, request);
}
if("收预付款".equals(accountHead.getType())){
supplierService.updateAdvanceIn(accountHead.getOrganId(), accountHead.getTotalPrice());
}
logService.insertLog("财务单据",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_ADD).append(accountHead.getBillNo()).toString(), request);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public void updateAccountHeadAndDetail(String beanJson, String rows, HttpServletRequest request) throws Exception {
AccountHead accountHead = JSONObject.parseObject(beanJson, AccountHead.class);
//获取之前的金额数据
BigDecimal preTotalPrice = getAccountHead(accountHead.getId()).getTotalPrice().abs();
accountHeadMapper.updateByPrimaryKeySelective(accountHead);
//根据单据编号查询单据id
AccountHeadExample dhExample = new AccountHeadExample();
@@ -253,6 +263,9 @@ public class AccountHeadService {
/**处理单据子表信息*/
accountItemService.saveDetials(rows, headId, type, request);
}
if("收预付款".equals(accountHead.getType())){
supplierService.updateAdvanceIn(accountHead.getOrganId(), accountHead.getTotalPrice().subtract(preTotalPrice));
}
logService.insertLog("财务单据",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(accountHead.getBillNo()).toString(), request);
}

View File

@@ -267,7 +267,7 @@ public class DepotHeadService {
}
//对于零售出库单据,更新会员的预收款信息
if (BusinessConstants.DEPOTHEAD_TYPE_OUT.equals(depotHead.getType())
&& BusinessConstants.SUB_TYPE_TRANSFER.equals(depotHead.getSubType())){
&& BusinessConstants.SUB_TYPE_RETAIL.equals(depotHead.getSubType())){
if(BusinessConstants.PAY_TYPE_PREPAID.equals(depotHead.getPayType())) {
if (depotHead.getOrganId() != null) {
supplierService.updateAdvanceIn(depotHead.getOrganId(), depotHead.getTotalPrice().abs());
@@ -689,16 +689,16 @@ public class DepotHeadService {
* 更新单据主表及单据子表信息
* @param beanJson
* @param rows
* @param preTotalPrice
* @param tenantId
* @param request
* @throws Exception
*/
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public void updateDepotHeadAndDetail(String beanJson, String rows,
BigDecimal preTotalPrice, Long tenantId,HttpServletRequest request)throws Exception {
public void updateDepotHeadAndDetail(String beanJson, String rows, Long tenantId,HttpServletRequest request)throws Exception {
/**更新单据主表信息*/
DepotHead depotHead = JSONObject.parseObject(beanJson, DepotHead.class);
//获取之前的金额数据
BigDecimal preTotalPrice = getDepotHead(depotHead.getId()).getTotalPrice().abs();
String subType = depotHead.getSubType();
if("零售".equals(subType) || "零售退货".equals(subType)
|| "采购".equals(subType) || "采购退货".equals(subType)