优化收预付款的逻辑
This commit is contained in:
@@ -290,8 +290,7 @@ public class DepotHeadController {
|
|||||||
JSONObject result = ExceptionConstants.standardSuccess();
|
JSONObject result = ExceptionConstants.standardSuccess();
|
||||||
String beanJson = body.getInfo();
|
String beanJson = body.getInfo();
|
||||||
String rows = body.getRows();
|
String rows = body.getRows();
|
||||||
BigDecimal preTotalPrice = body.getPreTotalPrice();
|
depotHeadService.updateDepotHeadAndDetail(beanJson,rows,tenantId,request);
|
||||||
depotHeadService.updateDepotHeadAndDetail(beanJson,rows,preTotalPrice,tenantId,request);
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import com.jsh.erp.exception.JshException;
|
|||||||
import com.jsh.erp.service.accountItem.AccountItemService;
|
import com.jsh.erp.service.accountItem.AccountItemService;
|
||||||
import com.jsh.erp.service.log.LogService;
|
import com.jsh.erp.service.log.LogService;
|
||||||
import com.jsh.erp.service.orgaUserRel.OrgaUserRelService;
|
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.service.user.UserService;
|
||||||
import com.jsh.erp.utils.StringUtil;
|
import com.jsh.erp.utils.StringUtil;
|
||||||
import com.jsh.erp.utils.Tools;
|
import com.jsh.erp.utils.Tools;
|
||||||
@@ -46,6 +47,8 @@ public class AccountHeadService {
|
|||||||
@Resource
|
@Resource
|
||||||
private UserService userService;
|
private UserService userService;
|
||||||
@Resource
|
@Resource
|
||||||
|
private SupplierService supplierService;
|
||||||
|
@Resource
|
||||||
private LogService logService;
|
private LogService logService;
|
||||||
@Resource
|
@Resource
|
||||||
private AccountItemMapperEx accountItemMapperEx;
|
private AccountItemMapperEx accountItemMapperEx;
|
||||||
@@ -221,6 +224,7 @@ public class AccountHeadService {
|
|||||||
return list==null?0:list.size();
|
return list==null?0:list.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
||||||
public void addAccountHeadAndDetail(String beanJson, String rows, HttpServletRequest request) throws Exception {
|
public void addAccountHeadAndDetail(String beanJson, String rows, HttpServletRequest request) throws Exception {
|
||||||
AccountHead accountHead = JSONObject.parseObject(beanJson, AccountHead.class);
|
AccountHead accountHead = JSONObject.parseObject(beanJson, AccountHead.class);
|
||||||
User userInfo=userService.getCurrentUser();
|
User userInfo=userService.getCurrentUser();
|
||||||
@@ -236,12 +240,18 @@ public class AccountHeadService {
|
|||||||
/**处理单据子表信息*/
|
/**处理单据子表信息*/
|
||||||
accountItemService.saveDetials(rows, headId, type, request);
|
accountItemService.saveDetials(rows, headId, type, request);
|
||||||
}
|
}
|
||||||
|
if("收预付款".equals(accountHead.getType())){
|
||||||
|
supplierService.updateAdvanceIn(accountHead.getOrganId(), accountHead.getTotalPrice());
|
||||||
|
}
|
||||||
logService.insertLog("财务单据",
|
logService.insertLog("财务单据",
|
||||||
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_ADD).append(accountHead.getBillNo()).toString(), request);
|
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 {
|
public void updateAccountHeadAndDetail(String beanJson, String rows, HttpServletRequest request) throws Exception {
|
||||||
AccountHead accountHead = JSONObject.parseObject(beanJson, AccountHead.class);
|
AccountHead accountHead = JSONObject.parseObject(beanJson, AccountHead.class);
|
||||||
|
//获取之前的金额数据
|
||||||
|
BigDecimal preTotalPrice = getAccountHead(accountHead.getId()).getTotalPrice().abs();
|
||||||
accountHeadMapper.updateByPrimaryKeySelective(accountHead);
|
accountHeadMapper.updateByPrimaryKeySelective(accountHead);
|
||||||
//根据单据编号查询单据id
|
//根据单据编号查询单据id
|
||||||
AccountHeadExample dhExample = new AccountHeadExample();
|
AccountHeadExample dhExample = new AccountHeadExample();
|
||||||
@@ -253,6 +263,9 @@ public class AccountHeadService {
|
|||||||
/**处理单据子表信息*/
|
/**处理单据子表信息*/
|
||||||
accountItemService.saveDetials(rows, headId, type, request);
|
accountItemService.saveDetials(rows, headId, type, request);
|
||||||
}
|
}
|
||||||
|
if("收预付款".equals(accountHead.getType())){
|
||||||
|
supplierService.updateAdvanceIn(accountHead.getOrganId(), accountHead.getTotalPrice().subtract(preTotalPrice));
|
||||||
|
}
|
||||||
logService.insertLog("财务单据",
|
logService.insertLog("财务单据",
|
||||||
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(accountHead.getBillNo()).toString(), request);
|
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(accountHead.getBillNo()).toString(), request);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -267,7 +267,7 @@ public class DepotHeadService {
|
|||||||
}
|
}
|
||||||
//对于零售出库单据,更新会员的预收款信息
|
//对于零售出库单据,更新会员的预收款信息
|
||||||
if (BusinessConstants.DEPOTHEAD_TYPE_OUT.equals(depotHead.getType())
|
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(BusinessConstants.PAY_TYPE_PREPAID.equals(depotHead.getPayType())) {
|
||||||
if (depotHead.getOrganId() != null) {
|
if (depotHead.getOrganId() != null) {
|
||||||
supplierService.updateAdvanceIn(depotHead.getOrganId(), depotHead.getTotalPrice().abs());
|
supplierService.updateAdvanceIn(depotHead.getOrganId(), depotHead.getTotalPrice().abs());
|
||||||
@@ -689,16 +689,16 @@ public class DepotHeadService {
|
|||||||
* 更新单据主表及单据子表信息
|
* 更新单据主表及单据子表信息
|
||||||
* @param beanJson
|
* @param beanJson
|
||||||
* @param rows
|
* @param rows
|
||||||
* @param preTotalPrice
|
|
||||||
* @param tenantId
|
* @param tenantId
|
||||||
* @param request
|
* @param request
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
||||||
public void updateDepotHeadAndDetail(String beanJson, String rows,
|
public void updateDepotHeadAndDetail(String beanJson, String rows, Long tenantId,HttpServletRequest request)throws Exception {
|
||||||
BigDecimal preTotalPrice, Long tenantId,HttpServletRequest request)throws Exception {
|
|
||||||
/**更新单据主表信息*/
|
/**更新单据主表信息*/
|
||||||
DepotHead depotHead = JSONObject.parseObject(beanJson, DepotHead.class);
|
DepotHead depotHead = JSONObject.parseObject(beanJson, DepotHead.class);
|
||||||
|
//获取之前的金额数据
|
||||||
|
BigDecimal preTotalPrice = getDepotHead(depotHead.getId()).getTotalPrice().abs();
|
||||||
String subType = depotHead.getSubType();
|
String subType = depotHead.getSubType();
|
||||||
if("零售".equals(subType) || "零售退货".equals(subType)
|
if("零售".equals(subType) || "零售退货".equals(subType)
|
||||||
|| "采购".equals(subType) || "采购退货".equals(subType)
|
|| "采购".equals(subType) || "采购退货".equals(subType)
|
||||||
|
|||||||
Reference in New Issue
Block a user