|
|
@@ -16,10 +16,7 @@ import com.usoftchina.saas.commons.po.Status;
|
|
|
import com.usoftchina.saas.context.BaseContextHolder;
|
|
|
import com.usoftchina.saas.exception.BizException;
|
|
|
import com.usoftchina.saas.money.dto.*;
|
|
|
-import com.usoftchina.saas.money.mapper.VerificationListMapper;
|
|
|
-import com.usoftchina.saas.money.mapper.VerificationMapper;
|
|
|
-import com.usoftchina.saas.money.mapper.VerificationdetMapper;
|
|
|
-import com.usoftchina.saas.money.mapper.VerificationdetailMapper;
|
|
|
+import com.usoftchina.saas.money.mapper.*;
|
|
|
import com.usoftchina.saas.money.po.*;
|
|
|
import com.usoftchina.saas.money.service.VerificationService;
|
|
|
import com.usoftchina.saas.page.PageRequest;
|
|
|
@@ -29,10 +26,12 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
import javax.print.DocFlavor;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
import java.util.Iterator;
|
|
|
import java.util.List;
|
|
|
+import java.util.logging.SimpleFormatter;
|
|
|
|
|
|
@Service
|
|
|
public class VerificationServiceImpl extends CommonBaseServiceImpl<VerificationMapper,Verification> implements VerificationService {
|
|
|
@@ -48,6 +47,12 @@ public class VerificationServiceImpl extends CommonBaseServiceImpl<VerificationM
|
|
|
private VerificationListMapper verificationListMapper;
|
|
|
@Autowired
|
|
|
private MessageLogService messageLogService;
|
|
|
+ @Autowired
|
|
|
+ private SubledgerMapper subledgerMapper;
|
|
|
+ @Autowired
|
|
|
+ private RecbalanceMapper recbalanceMapper;
|
|
|
+ @Autowired
|
|
|
+ private PaybalanceMapper paybalanceMapper;
|
|
|
|
|
|
|
|
|
@Override
|
|
|
@@ -93,6 +98,8 @@ public class VerificationServiceImpl extends CommonBaseServiceImpl<VerificationM
|
|
|
|
|
|
List<Verificationdetail> verificationdetail = verificationdetailMapper.selectByFK(id);
|
|
|
List<VerificationdetailDTO> items2 = BeanMapper.mapList(verificationdetail, VerificationdetailDTO.class);
|
|
|
+ String type = main.getVc_kind();
|
|
|
+ main.setVc_kind(transferKind(type));
|
|
|
verificationFormDTO.setMain(main);
|
|
|
verificationFormDTO.setItems1(items1);
|
|
|
verificationFormDTO.setItems2(items2);
|
|
|
@@ -122,32 +129,40 @@ public class VerificationServiceImpl extends CommonBaseServiceImpl<VerificationM
|
|
|
List<Verificationdet> updateDetails1 = new ArrayList<>();
|
|
|
List<Verificationdetail> updateDetails2 = new ArrayList<>();
|
|
|
DocSavedDTO saveDTO = new DocSavedDTO();
|
|
|
- Long id = Long.valueOf(String.valueOf(main.getVc_id()));
|
|
|
+ Long id = main.getId();
|
|
|
String code = main.getVc_code();
|
|
|
Verification verification = BeanMapper.map(main,Verification.class);
|
|
|
verification.setCompanyId(companyId);
|
|
|
verification.setCreatorId(userId);
|
|
|
verification.setCreateTime(new Date());
|
|
|
+ String kind = verification.getVc_kind();
|
|
|
+ verification.setVc_kind(transferKind(kind));
|
|
|
+
|
|
|
//编号获取
|
|
|
code = pushMaxnubmer(code,id);
|
|
|
-// code = "1";
|
|
|
verification.setVc_code(code);
|
|
|
saveDTO.setCode(code);
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("YYYYMM");
|
|
|
+ String dateYM = simpleDateFormat.format(verification.getVc_date());
|
|
|
+ Integer numberYM = Integer.valueOf(dateYM);
|
|
|
//判断更新与保存动作
|
|
|
if (StringUtils.isEmpty(id) || "0".equals(id.toString())){
|
|
|
//插入操作
|
|
|
getMapper().insertSelective(verification);
|
|
|
id = verification.getId();
|
|
|
+
|
|
|
//添加从表传输对象
|
|
|
for (VerificationdetDTO item : items1) {
|
|
|
Verificationdet detail = BeanMapper.map(item,Verificationdet.class);
|
|
|
detail.setVd_vcid(id);
|
|
|
detail.setCompanyId(companyId);
|
|
|
+ detail.setVd_ym(numberYM);
|
|
|
insertDetails1.add(detail);
|
|
|
}
|
|
|
for (VerificationdetailDTO item : items2) {
|
|
|
Verificationdetail detail = BeanMapper.map(item,Verificationdetail.class);
|
|
|
detail.setVcd_vcid(id);
|
|
|
+ detail.setVcd_ym(numberYM);
|
|
|
detail.setCompanyId(companyId);
|
|
|
insertDetails2.add(detail);
|
|
|
}
|
|
|
@@ -158,8 +173,6 @@ public class VerificationServiceImpl extends CommonBaseServiceImpl<VerificationM
|
|
|
if (insertDetails2.size()>0) {
|
|
|
verificationdetailMapper.batchInsert(insertDetails2);
|
|
|
}
|
|
|
- saveDTO.setId(id);
|
|
|
- return saveDTO;
|
|
|
}
|
|
|
//更新操作
|
|
|
getMapper().updateByPrimaryKeySelective(verification);
|
|
|
@@ -167,6 +180,7 @@ public class VerificationServiceImpl extends CommonBaseServiceImpl<VerificationM
|
|
|
for (VerificationdetDTO item : items1) {
|
|
|
Verificationdet detail = BeanMapper.map(item, Verificationdet.class);
|
|
|
detail.setVd_vcid(id);
|
|
|
+ detail.setVd_ym(numberYM);
|
|
|
detail.setCompanyId(companyId);
|
|
|
if (StringUtils.isEmpty(detail.getId()) || "0".equals(detail.getId().toString())) {
|
|
|
insertDetails1.add(detail);
|
|
|
@@ -177,6 +191,7 @@ public class VerificationServiceImpl extends CommonBaseServiceImpl<VerificationM
|
|
|
for (VerificationdetailDTO item : items2) {
|
|
|
Verificationdetail detail = BeanMapper.map(item, Verificationdetail.class);
|
|
|
detail.setVcd_vcid(id);
|
|
|
+ detail.setVcd_ym(numberYM);
|
|
|
detail.setCompanyId(companyId);
|
|
|
if (StringUtils.isEmpty(detail.getId()) || "0".equals(detail.getId().toString())) {
|
|
|
insertDetails2.add(detail);
|
|
|
@@ -198,19 +213,186 @@ public class VerificationServiceImpl extends CommonBaseServiceImpl<VerificationM
|
|
|
if (updateDetails2.size()>0) {
|
|
|
verificationdetailMapper.batchUpdate(updateDetails2);
|
|
|
}
|
|
|
-
|
|
|
+ updateCorrespondingData(formdata);
|
|
|
saveDTO.setId(id);
|
|
|
return saveDTO;
|
|
|
}
|
|
|
|
|
|
+ private void updateCorrespondingData(VerificationFormDTO formdata) {
|
|
|
+ //获取主表信息
|
|
|
+ VerificationDTO main = formdata.getMain();
|
|
|
+ //获取从表1
|
|
|
+ List<VerificationdetDTO> items1 = formdata.getItems1();
|
|
|
+ //获取从表2
|
|
|
+ List<VerificationdetailDTO> items2 = formdata.getItems2();
|
|
|
+
|
|
|
+ String type = main.getVc_kind();
|
|
|
+ if(type.equals("receipts_offset_receivable") || type.equals("prepaid_offset_payable") ||
|
|
|
+ type.equals("receivable_offset_payable")){
|
|
|
+ Double total1 = new Double(0);
|
|
|
+ for(VerificationdetDTO det : items1){
|
|
|
+ Double nowbalanceDet = det.getVd_nowbalance()==null?new Double(0):det.getVd_nowbalance();
|
|
|
+ total1 += nowbalanceDet;
|
|
|
+
|
|
|
+ //单据金额
|
|
|
+ Double amount = det.getVd_amount();
|
|
|
+ //核销金额
|
|
|
+ if(amount>0 && nowbalanceDet<0){
|
|
|
+ String msg = BizExceptionCode.MONEY_NOWAMOUNT_POSITIVE.getMessage();
|
|
|
+ int code = BizExceptionCode.MONEY_NOWAMOUNT_POSITIVE.getCode();
|
|
|
+ String error = String.format(msg, det.getVd_slkind());
|
|
|
+ throw new BizException(code, error);
|
|
|
+ }
|
|
|
+ if(amount<0 && nowbalanceDet>0){
|
|
|
+ String msg = BizExceptionCode.MONEY_NOWAMOUNT_POSITIVE.getMessage();
|
|
|
+ int code = BizExceptionCode.MONEY_NOWAMOUNT_POSITIVE.getCode();
|
|
|
+ String error = String.format(msg, det.getVd_slkind());
|
|
|
+ throw new BizException(code, error);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Double total2 = new Double(0);
|
|
|
+ for(VerificationdetailDTO detail : items2){
|
|
|
+ Double nowbalanceDet = detail.getVcd_nowbalance()==null?new Double(0):detail.getVcd_nowbalance();
|
|
|
+ total2 += nowbalanceDet;
|
|
|
+
|
|
|
+ //单据金额
|
|
|
+ Double amount = detail.getVcd_amount();
|
|
|
+ //核销金额
|
|
|
+ if(amount>0 && nowbalanceDet<0){
|
|
|
+ String msg = BizExceptionCode.MONEY_NOWAMOUNT_POSITIVE.getMessage();
|
|
|
+ int code = BizExceptionCode.MONEY_NOWAMOUNT_POSITIVE.getCode();
|
|
|
+ String error = String.format(msg, detail.getVcd_slkind());
|
|
|
+ throw new BizException(code, error);
|
|
|
+ }
|
|
|
+ if(amount<0 && nowbalanceDet>0){
|
|
|
+ String msg = BizExceptionCode.MONEY_NOWAMOUNT_POSITIVE.getMessage();
|
|
|
+ int code = BizExceptionCode.MONEY_NOWAMOUNT_POSITIVE.getCode();
|
|
|
+ String error = String.format(msg, detail.getVcd_slkind());
|
|
|
+ throw new BizException(code, error);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(total1.doubleValue()!=total2.doubleValue()){
|
|
|
+ throw new BizException(500, BizExceptionCode.VERIFICATION_CHECK_BALANCE.getMessage());
|
|
|
+ }
|
|
|
+ }else if(type.equals("receivable_to_receivable") || type.equals("payable_to_payable")){
|
|
|
+ for(VerificationdetDTO det : items1){
|
|
|
+ Double namount = det.getSl_namount()==null?new Double(0):det.getSl_namount();
|
|
|
+ Double nowbalance = det.getVd_nowbalance()==null?new Double(0):det.getVd_nowbalance();
|
|
|
+ if(namount<nowbalance){
|
|
|
+ throw new BizException(500, BizExceptionCode.VERIFICATION_CHECK_BALANCE.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ //插入中间表
|
|
|
+ private Subledger changSubledgerUntil(VerificationDTO verification){
|
|
|
+ Subledger subledger = new Subledger();
|
|
|
+ String kind = verification.getVc_kind();
|
|
|
+ subledger.setCompanyId(BaseContextHolder.getCompanyId());
|
|
|
+ subledger.setSl_code(verification.getVc_code());
|
|
|
+ subledger.setSl_kind(kind);
|
|
|
+ if(kind.equals("receipts_offset_receivable") || kind.equals("prepaid_offset_payable") ||
|
|
|
+ kind.equals("receivable_offset_payable")){
|
|
|
+ subledger.setSl_custid(0);
|
|
|
+ subledger.setSl_vendid(verification.getVc_vendid());
|
|
|
+ }else{
|
|
|
+ subledger.setSl_custid(verification.getVc_custid());
|
|
|
+ subledger.setSl_vendid(0);
|
|
|
+ }
|
|
|
+
|
|
|
+ subledger.setSl_date(verification.getVc_date());
|
|
|
+ subledger.setSl_amount(-verification.getVc_amount2());
|
|
|
+ subledger.setSl_orderamount(new Double(0));
|
|
|
+ subledger.setSl_yamount(new Double(0));
|
|
|
+ subledger.setSl_remark(verification.getVc_remark());
|
|
|
+ subledger.setSl_discount(new Double(0));
|
|
|
+ if(kind.equals("receipts_offset_receivable") || kind.equals("prepaid_offset_payable")){
|
|
|
+ subledger.setSl_preamount(-verification.getVc_amount1());
|
|
|
+ }else{
|
|
|
+ subledger.setSl_preamount(new Double(0));
|
|
|
+ }
|
|
|
+ return subledger;
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 审核更新来源单据的已核销,未核销
|
|
|
+ * @param id
|
|
|
+ * @param nowBalance
|
|
|
+ */
|
|
|
+ private void updateAuditSubledeger(int id , Double nowBalance){
|
|
|
+ Subledger subledger = subledgerMapper.selectByPrimaryKey(id);
|
|
|
+ Subledger newSubledeger = new Subledger();
|
|
|
+ newSubledeger.setId(Long.valueOf(String.valueOf(id)));
|
|
|
+ Double newNamout = subledger.getSl_namount()==null?new Double(0):subledger.getSl_namount()-nowBalance;
|
|
|
+ Double newYamout = subledger.getSl_yamount()==null?new Double(0):subledger.getSl_yamount()+nowBalance;
|
|
|
+ newSubledeger.setSl_yamount(newYamout);
|
|
|
+ newSubledeger.setSl_namount(newNamout);
|
|
|
+ newSubledeger.setCompanyId(BaseContextHolder.getCompanyId());
|
|
|
+ newSubledeger.setUpdaterName(BaseContextHolder.getUserName());
|
|
|
+ newSubledeger.setUpdaterId(BaseContextHolder.getUserId());
|
|
|
+ newSubledeger.setUpdateTime(new Date());
|
|
|
+ subledgerMapper.updateByPrimaryKey(newSubledeger);
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 反审核更新来源单据的已核销,未核销
|
|
|
+ * @param id
|
|
|
+ * @param nowBalance
|
|
|
+ */
|
|
|
+ private void updateResAuditSubledeger(int id , Double nowBalance){
|
|
|
+ Subledger subledger = subledgerMapper.selectByPrimaryKey(id);
|
|
|
+ Subledger newSubledeger = new Subledger();
|
|
|
+ newSubledeger.setId(Long.valueOf(String.valueOf(id)));
|
|
|
+ Double newNamout = subledger.getSl_namount()==null?new Double(0):subledger.getSl_namount()+nowBalance;
|
|
|
+ Double newYamout = subledger.getSl_yamount()==null?new Double(0):subledger.getSl_yamount()-nowBalance;
|
|
|
+ newSubledeger.setSl_yamount(newYamout);
|
|
|
+ newSubledeger.setSl_namount(newNamout);
|
|
|
+ newSubledeger.setCompanyId(BaseContextHolder.getCompanyId());
|
|
|
+ newSubledeger.setUpdaterName(BaseContextHolder.getUserName());
|
|
|
+ newSubledeger.setUpdaterId(BaseContextHolder.getUserId());
|
|
|
+ newSubledeger.setUpdateTime(new Date());
|
|
|
+ subledgerMapper.updateByPrimaryKey(newSubledeger);
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 转换核销单类型
|
|
|
+ * @param kind
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private String transferKind(String kind) {
|
|
|
+ switch (kind) {
|
|
|
+ case "receipts_offset_receivable" :
|
|
|
+ return "预收冲应收";
|
|
|
+ case "prepaid_offset_payable":
|
|
|
+ return "预付冲应付";
|
|
|
+ case "receivable_offset_payable":
|
|
|
+ return "应收冲应付";
|
|
|
+ case "receivable_to_receivable":
|
|
|
+ return "应收转应收";
|
|
|
+ case "payable_to_payable":
|
|
|
+ return "应付转应付";
|
|
|
+ default:return "";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public void delete(Long id) {
|
|
|
if (null != id) {
|
|
|
+ Verification verification = verificationMapper.selectByPrimaryKey(Math.toIntExact(id));
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMM");
|
|
|
+ String ym = simpleDateFormat.format(verification.getVc_date());
|
|
|
+ int detno = Integer.valueOf(ym);
|
|
|
+ if(checkSetAcount(detno)){
|
|
|
+ throw new BizException(500, BizExceptionCode.CHECK_SETACOUNT_EXIS.getMessage());
|
|
|
+ }
|
|
|
+ //删除中间表
|
|
|
+ subledgerMapper.deleteByPrimaryKey(verification.getVc_code(),verification.getVc_kind());
|
|
|
+
|
|
|
//从表删除
|
|
|
verificationdetMapper.deleteByParentPrimaryKey(id);
|
|
|
verificationdetailMapper.deleteByParentPrimaryKey(id);
|
|
|
//主表删除
|
|
|
verificationMapper.deleteByPrimaryKey(id);
|
|
|
+
|
|
|
String code = verificationMapper.selectCodeById(id);
|
|
|
DocBaseDTO baseDTO = new DocBaseDTO();
|
|
|
baseDTO.setId(id);
|
|
|
@@ -221,6 +403,18 @@ public class VerificationServiceImpl extends CommonBaseServiceImpl<VerificationM
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ * @param id
|
|
|
+ */
|
|
|
+ private boolean checkSetAcount(Integer detno){
|
|
|
+ boolean isSetAcount = false;
|
|
|
+ int count = verificationMapper.validateSetAcount(detno);
|
|
|
+ if(count>0){
|
|
|
+ isSetAcount = true;
|
|
|
+ }
|
|
|
+ return isSetAcount;
|
|
|
+ }
|
|
|
@Override
|
|
|
public void deleteDetail1(Long id) {
|
|
|
if (null != id) {
|
|
|
@@ -266,11 +460,202 @@ public class VerificationServiceImpl extends CommonBaseServiceImpl<VerificationM
|
|
|
verification.setVc_statuscode(Status.AUDITED.name());
|
|
|
verification.setVc_id(Integer.valueOf(String.valueOf(id)));
|
|
|
verificationMapper.updateByPrimaryKeySelective(verification);
|
|
|
+
|
|
|
+
|
|
|
+ VerificationDTO verificationDTO = formData.getMain();
|
|
|
+ Subledger subledger = changSubledgerUntil(verificationDTO);
|
|
|
+ subledgerMapper.insertSelective(subledger);
|
|
|
+
|
|
|
+ //更新客户或者供应商的金额
|
|
|
+ updateAuditCustomer(verificationDTO);
|
|
|
+ updateAuditVendor(verificationDTO);
|
|
|
+
|
|
|
+ //更新源单金额
|
|
|
+ //获取从表1
|
|
|
+ List<VerificationdetDTO> items1 = formData.getItems1();
|
|
|
+ //获取从表2
|
|
|
+ List<VerificationdetailDTO> items2 = formData.getItems2();
|
|
|
+ for(VerificationdetDTO det : items1){
|
|
|
+ Double nowbalanceDet = det.getVd_nowbalance()==null?new Double(0):det.getVd_nowbalance();
|
|
|
+ updateAuditSubledeger(det.getVd_slid(),nowbalanceDet);
|
|
|
+ }
|
|
|
+ for(VerificationdetailDTO detail : items2){
|
|
|
+ Double nowbalanceDet = detail.getVcd_nowbalance()==null?new Double(0):detail.getVcd_nowbalance();
|
|
|
+ updateAuditSubledeger(detail.getVcd_slid(),nowbalanceDet);
|
|
|
+ }
|
|
|
}
|
|
|
savedDTO.setId(id);
|
|
|
return savedDTO;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 审核更新客户金额
|
|
|
+ * @param verificationDTO
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private void updateAuditCustomer(VerificationDTO verificationDTO){
|
|
|
+ String kind = verificationDTO.getVc_kind();
|
|
|
+ if(kind.equals("receipts_offset_receivable")){
|
|
|
+ Customer customerData = recbalanceMapper.selectCustomerByPrimaryKey(verificationDTO.getVc_custid());
|
|
|
+ Double preamount = customerData.getCu_preamount()==null?new Double(0):customerData.getCu_preamount();
|
|
|
+ Double beginapamount = customerData.getCu_beginaramount()==null?new Double(0):customerData.getCu_beginaramount();
|
|
|
+ Double beginprepayamount= customerData.getCu_beginprerecamount()==null?new Double(0):customerData.getCu_beginprerecamount();
|
|
|
+ Double recamount = customerData.getCu_recamount()==null?new Double(0):customerData.getCu_recamount();
|
|
|
+
|
|
|
+ Customer customer = new Customer();
|
|
|
+ Double amount1 = verificationDTO.getVc_amount1()==null?new Double(0):verificationDTO.getVc_amount1();
|
|
|
+ Double amount2 = verificationDTO.getVc_amount2()==null?new Double(0):verificationDTO.getVc_amount2();
|
|
|
+ customer.setId(Long.valueOf(String.valueOf(verificationDTO.getVc_custid())));
|
|
|
+ customer.setCompanyId(BaseContextHolder.getCompanyId());
|
|
|
+ customer.setUpdaterId(BaseContextHolder.getUserId());
|
|
|
+ customer.setUpdaterName(BaseContextHolder.getUserName());
|
|
|
+ customer.setUpdateTime(new Date());
|
|
|
+ customer.setCu_preamount(preamount+amount1);
|
|
|
+ customer.setCu_recamount(recamount-amount2);
|
|
|
+ customer.setCu_leftamount(beginapamount-beginprepayamount+recamount-amount2-preamount-amount1);
|
|
|
+ recbalanceMapper.updateCustomerByPrimaryKeySelective(customer);
|
|
|
+ }else if(kind.equals("receivable_offset_payable")){
|
|
|
+ Customer customerData = recbalanceMapper.selectCustomerByPrimaryKey(verificationDTO.getVc_custid());
|
|
|
+ Double preamount = customerData.getCu_preamount()==null?new Double(0):customerData.getCu_preamount();
|
|
|
+ Double beginapamount = customerData.getCu_beginaramount()==null?new Double(0):customerData.getCu_beginaramount();
|
|
|
+ Double beginprepayamount= customerData.getCu_beginprerecamount()==null?new Double(0):customerData.getCu_beginprerecamount();
|
|
|
+ Double recamount = customerData.getCu_recamount()==null?new Double(0):customerData.getCu_recamount();
|
|
|
+
|
|
|
+ Customer customer = new Customer();
|
|
|
+ Double amount1 = verificationDTO.getVc_amount1()==null?new Double(0):verificationDTO.getVc_amount1();
|
|
|
+ Double amount2 = verificationDTO.getVc_amount2()==null?new Double(0):verificationDTO.getVc_amount2();
|
|
|
+ customer.setId(Long.valueOf(String.valueOf(verificationDTO.getVc_custid())));
|
|
|
+ customer.setCompanyId(BaseContextHolder.getCompanyId());
|
|
|
+ customer.setUpdaterId(BaseContextHolder.getUserId());
|
|
|
+ customer.setUpdaterName(BaseContextHolder.getUserName());
|
|
|
+ customer.setUpdateTime(new Date());
|
|
|
+ customer.setCu_recamount(recamount-amount1);
|
|
|
+ customer.setCu_leftamount(beginapamount-beginprepayamount+recamount-amount1-preamount);
|
|
|
+ recbalanceMapper.updateCustomerByPrimaryKeySelective(customer);
|
|
|
+ }else if(kind.equals("receivable_to_receivable")){
|
|
|
+ //转入客户
|
|
|
+ Customer customerIn = recbalanceMapper.selectCustomerByPrimaryKey(verificationDTO.getVc_turncustid());
|
|
|
+ //转出客户
|
|
|
+ Customer customerOut = recbalanceMapper.selectCustomerByPrimaryKey(verificationDTO.getVc_custid());
|
|
|
+
|
|
|
+ Double preamountIn = customerIn.getCu_preamount()==null?new Double(0):customerIn.getCu_preamount();
|
|
|
+ Double beginapamountIn = customerIn.getCu_beginaramount()==null?new Double(0):customerIn.getCu_beginaramount();
|
|
|
+ Double beginprepayamountIn = customerIn.getCu_beginprerecamount()==null?new Double(0):customerIn.getCu_beginprerecamount();
|
|
|
+ Double recamountIn = customerIn.getCu_recamount()==null?new Double(0):customerIn.getCu_recamount();
|
|
|
+
|
|
|
+ Double preamountOut = customerOut.getCu_preamount()==null?new Double(0):customerOut.getCu_preamount();
|
|
|
+ Double beginapamountOut = customerOut.getCu_beginaramount()==null?new Double(0):customerOut.getCu_beginaramount();
|
|
|
+ Double beginprepayamountOut = customerOut.getCu_beginprerecamount()==null?new Double(0):customerOut.getCu_beginprerecamount();
|
|
|
+ Double recamountOut = customerOut.getCu_recamount()==null?new Double(0):customerOut.getCu_recamount();
|
|
|
+
|
|
|
+
|
|
|
+ Double amount1 = verificationDTO.getVc_amount1()==null?new Double(0):verificationDTO.getVc_amount1();
|
|
|
+ Double amount2 = verificationDTO.getVc_amount2()==null?new Double(0):verificationDTO.getVc_amount2();
|
|
|
+ Customer newCustomerIn = new Customer();
|
|
|
+ newCustomerIn.setId(Long.valueOf(String.valueOf(verificationDTO.getVc_turncustid())));
|
|
|
+ newCustomerIn.setCompanyId(BaseContextHolder.getCompanyId());
|
|
|
+ newCustomerIn.setUpdaterId(BaseContextHolder.getUserId());
|
|
|
+ newCustomerIn.setUpdaterName(BaseContextHolder.getUserName());
|
|
|
+ newCustomerIn.setUpdateTime(new Date());
|
|
|
+ newCustomerIn.setCu_recamount(recamountIn-amount1);
|
|
|
+ newCustomerIn.setCu_leftamount(beginapamountIn-beginprepayamountIn+recamountIn-amount1-preamountIn);
|
|
|
+ recbalanceMapper.updateCustomerByPrimaryKeySelective(newCustomerIn);
|
|
|
+
|
|
|
+ Customer newCustomerOut = new Customer();
|
|
|
+ newCustomerOut.setId(Long.valueOf(String.valueOf(verificationDTO.getVc_custid())));
|
|
|
+ newCustomerOut.setCompanyId(BaseContextHolder.getCompanyId());
|
|
|
+ newCustomerOut.setUpdaterId(BaseContextHolder.getUserId());
|
|
|
+ newCustomerOut.setUpdaterName(BaseContextHolder.getUserName());
|
|
|
+ newCustomerOut.setUpdateTime(new Date());
|
|
|
+ newCustomerOut.setCu_recamount(recamountOut-amount1);
|
|
|
+ newCustomerOut.setCu_leftamount(beginapamountOut-beginprepayamountOut+recamountOut-amount1-preamountOut);
|
|
|
+ recbalanceMapper.updateCustomerByPrimaryKeySelective(newCustomerOut);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 审核更新供应商金额
|
|
|
+ * @param verificationDTO
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private void updateAuditVendor(VerificationDTO verificationDTO){
|
|
|
+ String kind = verificationDTO.getVc_kind();
|
|
|
+ if(kind.equals("prepaid_offset_payable")){
|
|
|
+ Vendor vendorData = paybalanceMapper.selectVendorByPrimaryKey(verificationDTO.getVc_vendid());
|
|
|
+ Double preamount = vendorData.getVe_preamount()==null?new Double(0):vendorData.getVe_preamount();
|
|
|
+ Double beginapamount = vendorData.getVe_beginapamount()==null?new Double(0):vendorData.getVe_beginapamount();
|
|
|
+ Double beginprepayamount= vendorData.getVe_beginprepayamount()==null?new Double(0):vendorData.getVe_beginprepayamount();
|
|
|
+ Double payamount = vendorData.getVe_payamount()==null?new Double(0):vendorData.getVe_payamount();
|
|
|
+
|
|
|
+ Vendor vendor = new Vendor();
|
|
|
+ Double amount1 = verificationDTO.getVc_amount1()==null?new Double(0):verificationDTO.getVc_amount1();
|
|
|
+ Double amount2 = verificationDTO.getVc_amount2()==null?new Double(0):verificationDTO.getVc_amount2();
|
|
|
+ vendor.setId(Long.valueOf(String.valueOf(verificationDTO.getVc_vendid())));
|
|
|
+ vendor.setCompanyId(BaseContextHolder.getCompanyId());
|
|
|
+ vendor.setUpdaterId(BaseContextHolder.getUserId());
|
|
|
+ vendor.setUpdaterName(BaseContextHolder.getUserName());
|
|
|
+ vendor.setUpdateTime(new Date());
|
|
|
+ vendor.setVe_preamount(preamount-amount1);
|
|
|
+ vendor.setVe_payamount(payamount+amount2);
|
|
|
+ vendor.setVe_leftamount(beginapamount-beginprepayamount+payamount+amount2-preamount+amount1);
|
|
|
+ paybalanceMapper.updateVendorByPrimaryKeySelective(vendor);
|
|
|
+ }else if(kind.equals("receivable_offset_payable")){
|
|
|
+ Vendor vendorData = paybalanceMapper.selectVendorByPrimaryKey(verificationDTO.getVc_vendid());
|
|
|
+ Double preamount = vendorData.getVe_preamount()==null?new Double(0):vendorData.getVe_preamount();
|
|
|
+ Double beginapamount = vendorData.getVe_beginapamount()==null?new Double(0):vendorData.getVe_beginapamount();
|
|
|
+ Double beginprepayamount= vendorData.getVe_beginprepayamount()==null?new Double(0):vendorData.getVe_beginprepayamount();
|
|
|
+ Double payamount = vendorData.getVe_payamount()==null?new Double(0):vendorData.getVe_payamount();
|
|
|
+
|
|
|
+ Vendor vendor = new Vendor();
|
|
|
+ Double amount1 = verificationDTO.getVc_amount1()==null?new Double(0):verificationDTO.getVc_amount1();
|
|
|
+ Double amount2 = verificationDTO.getVc_amount2()==null?new Double(0):verificationDTO.getVc_amount2();
|
|
|
+ vendor.setId(Long.valueOf(String.valueOf(verificationDTO.getVc_vendid())));
|
|
|
+ vendor.setVe_payamount(payamount+amount2);
|
|
|
+ vendor.setUpdaterId(BaseContextHolder.getUserId());
|
|
|
+ vendor.setUpdaterName(BaseContextHolder.getUserName());
|
|
|
+ vendor.setUpdateTime(new Date());
|
|
|
+ vendor.setVe_leftamount(beginapamount-beginprepayamount+payamount+amount2-preamount);
|
|
|
+ paybalanceMapper.updateVendorByPrimaryKeySelective(vendor);
|
|
|
+ }else if(kind.equals("payable_to_payable")){
|
|
|
+ //转入供应商
|
|
|
+ Vendor vendorIn = paybalanceMapper.selectVendorByPrimaryKey(verificationDTO.getVc_turnvendid());
|
|
|
+ //转出供应商
|
|
|
+ Vendor vendorOut = paybalanceMapper.selectVendorByPrimaryKey(verificationDTO.getVc_vendid());
|
|
|
+
|
|
|
+ Double preamountIn = vendorIn.getVe_preamount()==null?new Double(0):vendorIn.getVe_preamount();
|
|
|
+ Double beginapamountIn = vendorIn.getVe_beginapamount()==null?new Double(0):vendorIn.getVe_beginapamount();
|
|
|
+ Double beginprepayamountIn = vendorIn.getVe_beginprepayamount()==null?new Double(0):vendorIn.getVe_beginprepayamount();
|
|
|
+ Double payamountIn = vendorIn.getVe_payamount()==null?new Double(0):vendorIn.getVe_payamount();
|
|
|
+
|
|
|
+ Double preamountOut = vendorOut.getVe_preamount()==null?new Double(0):vendorOut.getVe_preamount();
|
|
|
+ Double beginapamountOut = vendorOut.getVe_beginapamount()==null?new Double(0):vendorOut.getVe_beginapamount();
|
|
|
+ Double beginprepayamountOut = vendorOut.getVe_beginprepayamount()==null?new Double(0):vendorOut.getVe_beginprepayamount();
|
|
|
+ Double payamountOut = vendorOut.getVe_payamount()==null?new Double(0):vendorOut.getVe_payamount();
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ Double amount1 = verificationDTO.getVc_amount1()==null?new Double(0):verificationDTO.getVc_amount1();
|
|
|
+ Double amount2 = verificationDTO.getVc_amount2()==null?new Double(0):verificationDTO.getVc_amount2();
|
|
|
+ Vendor newVendorIn = new Vendor();
|
|
|
+ newVendorIn.setId(Long.valueOf(String.valueOf(verificationDTO.getVc_turnvendid())));
|
|
|
+ newVendorIn.setUpdaterId(BaseContextHolder.getUserId());
|
|
|
+ newVendorIn.setUpdaterName(BaseContextHolder.getUserName());
|
|
|
+ newVendorIn.setUpdateTime(new Date());
|
|
|
+ newVendorIn.setVe_payamount(payamountIn+amount1);
|
|
|
+ newVendorIn.setVe_leftamount(beginapamountIn-beginprepayamountIn+payamountIn+amount1-preamountIn);
|
|
|
+ paybalanceMapper.updateVendorByPrimaryKeySelective(newVendorIn);
|
|
|
+
|
|
|
+ Vendor newVendorOut = new Vendor();
|
|
|
+ newVendorOut.setId(Long.valueOf(String.valueOf(verificationDTO.getVc_vendid())));
|
|
|
+ newVendorOut.setUpdaterId(BaseContextHolder.getUserId());
|
|
|
+ newVendorOut.setUpdaterName(BaseContextHolder.getUserName());
|
|
|
+ newVendorOut.setUpdateTime(new Date());
|
|
|
+ newVendorOut.setVe_payamount(payamountOut-amount1);
|
|
|
+ newVendorOut.setVe_leftamount(beginapamountOut-beginprepayamountOut+payamountOut-amount1-preamountOut);
|
|
|
+ paybalanceMapper.updateVendorByPrimaryKeySelective(newVendorOut);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
@Override
|
|
|
public void resAudit(Long id) {
|
|
|
if (null == id) {
|
|
|
@@ -282,6 +667,27 @@ public class VerificationServiceImpl extends CommonBaseServiceImpl<VerificationM
|
|
|
int errCode = BizExceptionCode.BEFORE_UNAUDIT.getCode();
|
|
|
throw new BizException(errCode, String.format(msg, code));
|
|
|
}
|
|
|
+
|
|
|
+ //更新客户或者供应商的金额
|
|
|
+ Verification nowverification = verificationMapper.selectByPrimaryKey(id);
|
|
|
+ VerificationDTO verificationDTO = BeanMapper.map(nowverification,VerificationDTO.class);
|
|
|
+ updateResAuditCustomer(verificationDTO);
|
|
|
+ updateResAuditVendor(verificationDTO);
|
|
|
+
|
|
|
+ //更新源单金额
|
|
|
+ //获取从表1
|
|
|
+ List<Verificationdet> items1 = verificationdetMapper.selectByFK(id);
|
|
|
+ //获取从表2
|
|
|
+ List<Verificationdetail> items2 = verificationdetailMapper.selectByFK(id);
|
|
|
+ for(Verificationdet det : items1){
|
|
|
+ Double nowbalanceDet = det.getVd_nowbalance()==null?new Double(0):det.getVd_nowbalance();
|
|
|
+ updateAuditSubledeger(det.getVd_slid(),nowbalanceDet);
|
|
|
+ }
|
|
|
+ for(Verificationdetail detail : items2){
|
|
|
+ Double nowbalanceDet = detail.getVcd_nowbalance()==null?new Double(0):detail.getVcd_nowbalance();
|
|
|
+ updateAuditSubledeger(detail.getVcd_slid(),nowbalanceDet);
|
|
|
+ }
|
|
|
+
|
|
|
Verification verification = new Verification();
|
|
|
//生成更新对象
|
|
|
verification.setVc_id(Integer.valueOf(String.valueOf(id)));
|
|
|
@@ -298,17 +704,209 @@ public class VerificationServiceImpl extends CommonBaseServiceImpl<VerificationM
|
|
|
//日志
|
|
|
messageLogService.unAudit(baseDTO);
|
|
|
}
|
|
|
+ /**
|
|
|
+ * 反审核更新客户金额
|
|
|
+ * @param verificationDTO
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private void updateResAuditCustomer(VerificationDTO verificationDTO){
|
|
|
+ String kind = verificationDTO.getVc_kind();
|
|
|
+ if(kind.equals("receipts_offset_receivable")){
|
|
|
+ Customer customerData = recbalanceMapper.selectCustomerByPrimaryKey(verificationDTO.getVc_custid());
|
|
|
+ Double preamount = customerData.getCu_preamount()==null?new Double(0):customerData.getCu_preamount();
|
|
|
+ Double beginapamount = customerData.getCu_beginaramount()==null?new Double(0):customerData.getCu_beginaramount();
|
|
|
+ Double beginprepayamount= customerData.getCu_beginprerecamount()==null?new Double(0):customerData.getCu_beginprerecamount();
|
|
|
+ Double recamount = customerData.getCu_recamount()==null?new Double(0):customerData.getCu_recamount();
|
|
|
+
|
|
|
+ Customer customer = new Customer();
|
|
|
+ Double amount1 = verificationDTO.getVc_amount1()==null?new Double(0):verificationDTO.getVc_amount1();
|
|
|
+ Double amount2 = verificationDTO.getVc_amount2()==null?new Double(0):verificationDTO.getVc_amount2();
|
|
|
+ customer.setId(Long.valueOf(String.valueOf(verificationDTO.getVc_custid())));
|
|
|
+ customer.setCompanyId(BaseContextHolder.getCompanyId());
|
|
|
+ customer.setUpdaterId(BaseContextHolder.getUserId());
|
|
|
+ customer.setUpdaterName(BaseContextHolder.getUserName());
|
|
|
+ customer.setUpdateTime(new Date());
|
|
|
+ customer.setCu_preamount(preamount-amount1);
|
|
|
+ customer.setCu_recamount(recamount+amount2);
|
|
|
+ customer.setCu_leftamount(beginapamount-beginprepayamount+recamount+amount2-preamount+amount1);
|
|
|
+ recbalanceMapper.updateCustomerByPrimaryKeySelective(customer);
|
|
|
+ }else if(kind.equals("receivable_offset_payable")){
|
|
|
+ Customer customerData = recbalanceMapper.selectCustomerByPrimaryKey(verificationDTO.getVc_custid());
|
|
|
+ Double preamount = customerData.getCu_preamount()==null?new Double(0):customerData.getCu_preamount();
|
|
|
+ Double beginapamount = customerData.getCu_beginaramount()==null?new Double(0):customerData.getCu_beginaramount();
|
|
|
+ Double beginprepayamount= customerData.getCu_beginprerecamount()==null?new Double(0):customerData.getCu_beginprerecamount();
|
|
|
+ Double recamount = customerData.getCu_recamount()==null?new Double(0):customerData.getCu_recamount();
|
|
|
+
|
|
|
+ Customer customer = new Customer();
|
|
|
+ Double amount1 = verificationDTO.getVc_amount1()==null?new Double(0):verificationDTO.getVc_amount1();
|
|
|
+ Double amount2 = verificationDTO.getVc_amount2()==null?new Double(0):verificationDTO.getVc_amount2();
|
|
|
+ customer.setId(Long.valueOf(String.valueOf(verificationDTO.getVc_custid())));
|
|
|
+ customer.setCompanyId(BaseContextHolder.getCompanyId());
|
|
|
+ customer.setUpdaterId(BaseContextHolder.getUserId());
|
|
|
+ customer.setUpdaterName(BaseContextHolder.getUserName());
|
|
|
+ customer.setUpdateTime(new Date());
|
|
|
+ customer.setCu_recamount(recamount+amount1);
|
|
|
+ customer.setCu_leftamount(beginapamount-beginprepayamount+recamount+amount1-preamount);
|
|
|
+ recbalanceMapper.updateCustomerByPrimaryKeySelective(customer);
|
|
|
+ }else if(kind.equals("receivable_to_receivable")){
|
|
|
+ //转入客户
|
|
|
+ Customer customerIn = recbalanceMapper.selectCustomerByPrimaryKey(verificationDTO.getVc_turncustid());
|
|
|
+ //转出客户
|
|
|
+ Customer customerOut = recbalanceMapper.selectCustomerByPrimaryKey(verificationDTO.getVc_custid());
|
|
|
+
|
|
|
+ Double preamountIn = customerIn.getCu_preamount()==null?new Double(0):customerIn.getCu_preamount();
|
|
|
+ Double beginapamountIn = customerIn.getCu_beginaramount()==null?new Double(0):customerIn.getCu_beginaramount();
|
|
|
+ Double beginprepayamountIn = customerIn.getCu_beginprerecamount()==null?new Double(0):customerIn.getCu_beginprerecamount();
|
|
|
+ Double recamountIn = customerIn.getCu_recamount()==null?new Double(0):customerIn.getCu_recamount();
|
|
|
+
|
|
|
+ Double preamountOut = customerOut.getCu_preamount()==null?new Double(0):customerOut.getCu_preamount();
|
|
|
+ Double beginapamountOut = customerOut.getCu_beginaramount()==null?new Double(0):customerOut.getCu_beginaramount();
|
|
|
+ Double beginprepayamountOut = customerOut.getCu_beginprerecamount()==null?new Double(0):customerOut.getCu_beginprerecamount();
|
|
|
+ Double recamountOut = customerOut.getCu_recamount()==null?new Double(0):customerOut.getCu_recamount();
|
|
|
+
|
|
|
+
|
|
|
+ Double amount1 = verificationDTO.getVc_amount1()==null?new Double(0):verificationDTO.getVc_amount1();
|
|
|
+ Double amount2 = verificationDTO.getVc_amount2()==null?new Double(0):verificationDTO.getVc_amount2();
|
|
|
+ Customer newCustomerIn = new Customer();
|
|
|
+ newCustomerIn.setId(Long.valueOf(String.valueOf(verificationDTO.getVc_turncustid())));
|
|
|
+ newCustomerIn.setCompanyId(BaseContextHolder.getCompanyId());
|
|
|
+ newCustomerIn.setUpdaterId(BaseContextHolder.getUserId());
|
|
|
+ newCustomerIn.setUpdaterName(BaseContextHolder.getUserName());
|
|
|
+ newCustomerIn.setUpdateTime(new Date());
|
|
|
+ newCustomerIn.setCu_recamount(recamountIn-amount1);
|
|
|
+ newCustomerIn.setCu_leftamount(beginapamountIn-beginprepayamountIn+recamountIn+amount1-preamountIn);
|
|
|
+ recbalanceMapper.updateCustomerByPrimaryKeySelective(newCustomerIn);
|
|
|
+
|
|
|
+ Customer newCustomerOut = new Customer();
|
|
|
+ newCustomerOut.setId(Long.valueOf(String.valueOf(verificationDTO.getVc_custid())));
|
|
|
+ newCustomerOut.setCompanyId(BaseContextHolder.getCompanyId());
|
|
|
+ newCustomerOut.setUpdaterId(BaseContextHolder.getUserId());
|
|
|
+ newCustomerOut.setUpdaterName(BaseContextHolder.getUserName());
|
|
|
+ newCustomerOut.setUpdateTime(new Date());
|
|
|
+ newCustomerOut.setCu_recamount(recamountOut+amount1);
|
|
|
+ newCustomerOut.setCu_leftamount(beginapamountOut-beginprepayamountOut+recamountOut+amount1-preamountOut);
|
|
|
+ recbalanceMapper.updateCustomerByPrimaryKeySelective(newCustomerOut);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 审核更新供应商金额
|
|
|
+ * @param verificationDTO
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private void updateResAuditVendor(VerificationDTO verificationDTO){
|
|
|
+ String kind = verificationDTO.getVc_kind();
|
|
|
+ if(kind.equals("prepaid_offset_payable")){
|
|
|
+ Vendor vendorData = paybalanceMapper.selectVendorByPrimaryKey(verificationDTO.getVc_vendid());
|
|
|
+ Double preamount = vendorData.getVe_preamount()==null?new Double(0):vendorData.getVe_preamount();
|
|
|
+ Double beginapamount = vendorData.getVe_beginapamount()==null?new Double(0):vendorData.getVe_beginapamount();
|
|
|
+ Double beginprepayamount= vendorData.getVe_beginprepayamount()==null?new Double(0):vendorData.getVe_beginprepayamount();
|
|
|
+ Double payamount = vendorData.getVe_payamount()==null?new Double(0):vendorData.getVe_payamount();
|
|
|
+
|
|
|
+ Vendor vendor = new Vendor();
|
|
|
+ Double amount1 = verificationDTO.getVc_amount1()==null?new Double(0):verificationDTO.getVc_amount1();
|
|
|
+ Double amount2 = verificationDTO.getVc_amount2()==null?new Double(0):verificationDTO.getVc_amount2();
|
|
|
+ vendor.setId(Long.valueOf(String.valueOf(verificationDTO.getVc_vendid())));
|
|
|
+ vendor.setCompanyId(BaseContextHolder.getCompanyId());
|
|
|
+ vendor.setUpdaterId(BaseContextHolder.getUserId());
|
|
|
+ vendor.setUpdaterName(BaseContextHolder.getUserName());
|
|
|
+ vendor.setUpdateTime(new Date());
|
|
|
+ vendor.setVe_preamount(preamount+amount1);
|
|
|
+ vendor.setVe_payamount(payamount-amount2);
|
|
|
+ vendor.setVe_leftamount(beginapamount-beginprepayamount+payamount-amount2-preamount-amount1);
|
|
|
+ paybalanceMapper.updateVendorByPrimaryKeySelective(vendor);
|
|
|
+ }else if(kind.equals("receivable_offset_payable")){
|
|
|
+ Vendor vendorData = paybalanceMapper.selectVendorByPrimaryKey(verificationDTO.getVc_vendid());
|
|
|
+ Double preamount = vendorData.getVe_preamount()==null?new Double(0):vendorData.getVe_preamount();
|
|
|
+ Double beginapamount = vendorData.getVe_beginapamount()==null?new Double(0):vendorData.getVe_beginapamount();
|
|
|
+ Double beginprepayamount= vendorData.getVe_beginprepayamount()==null?new Double(0):vendorData.getVe_beginprepayamount();
|
|
|
+ Double payamount = vendorData.getVe_payamount()==null?new Double(0):vendorData.getVe_payamount();
|
|
|
+
|
|
|
+ Vendor vendor = new Vendor();
|
|
|
+ Double amount1 = verificationDTO.getVc_amount1()==null?new Double(0):verificationDTO.getVc_amount1();
|
|
|
+ Double amount2 = verificationDTO.getVc_amount2()==null?new Double(0):verificationDTO.getVc_amount2();
|
|
|
+ vendor.setId(Long.valueOf(String.valueOf(verificationDTO.getVc_vendid())));
|
|
|
+ vendor.setVe_payamount(payamount+amount2);
|
|
|
+ vendor.setUpdaterId(BaseContextHolder.getUserId());
|
|
|
+ vendor.setUpdaterName(BaseContextHolder.getUserName());
|
|
|
+ vendor.setUpdateTime(new Date());
|
|
|
+ vendor.setVe_leftamount(beginapamount-beginprepayamount+payamount+amount2-preamount);
|
|
|
+ paybalanceMapper.updateVendorByPrimaryKeySelective(vendor);
|
|
|
+ }else if(kind.equals("payable_to_payable")){
|
|
|
+ //转入供应商
|
|
|
+ Vendor vendorIn = paybalanceMapper.selectVendorByPrimaryKey(verificationDTO.getVc_turnvendid());
|
|
|
+ //转出供应商
|
|
|
+ Vendor vendorOut = paybalanceMapper.selectVendorByPrimaryKey(verificationDTO.getVc_vendid());
|
|
|
+
|
|
|
+ Double preamountIn = vendorIn.getVe_preamount()==null?new Double(0):vendorIn.getVe_preamount();
|
|
|
+ Double beginapamountIn = vendorIn.getVe_beginapamount()==null?new Double(0):vendorIn.getVe_beginapamount();
|
|
|
+ Double beginprepayamountIn = vendorIn.getVe_beginprepayamount()==null?new Double(0):vendorIn.getVe_beginprepayamount();
|
|
|
+ Double payamountIn = vendorIn.getVe_payamount()==null?new Double(0):vendorIn.getVe_payamount();
|
|
|
+
|
|
|
+ Double preamountOut = vendorOut.getVe_preamount()==null?new Double(0):vendorOut.getVe_preamount();
|
|
|
+ Double beginapamountOut = vendorOut.getVe_beginapamount()==null?new Double(0):vendorOut.getVe_beginapamount();
|
|
|
+ Double beginprepayamountOut = vendorOut.getVe_beginprepayamount()==null?new Double(0):vendorOut.getVe_beginprepayamount();
|
|
|
+ Double payamountOut = vendorOut.getVe_payamount()==null?new Double(0):vendorOut.getVe_payamount();
|
|
|
+
|
|
|
|
|
|
+
|
|
|
+ Double amount1 = verificationDTO.getVc_amount1()==null?new Double(0):verificationDTO.getVc_amount1();
|
|
|
+ Double amount2 = verificationDTO.getVc_amount2()==null?new Double(0):verificationDTO.getVc_amount2();
|
|
|
+ Vendor newVendorIn = new Vendor();
|
|
|
+ newVendorIn.setId(Long.valueOf(String.valueOf(verificationDTO.getVc_turnvendid())));
|
|
|
+ newVendorIn.setUpdaterId(BaseContextHolder.getUserId());
|
|
|
+ newVendorIn.setUpdaterName(BaseContextHolder.getUserName());
|
|
|
+ newVendorIn.setUpdateTime(new Date());
|
|
|
+ newVendorIn.setVe_payamount(payamountIn+amount1);
|
|
|
+ newVendorIn.setVe_leftamount(beginapamountIn-beginprepayamountIn+payamountIn+amount1-preamountIn);
|
|
|
+ paybalanceMapper.updateVendorByPrimaryKeySelective(newVendorIn);
|
|
|
+
|
|
|
+ Vendor newVendorOut = new Vendor();
|
|
|
+ newVendorOut.setId(Long.valueOf(String.valueOf(verificationDTO.getVc_vendid())));
|
|
|
+ newVendorOut.setUpdaterId(BaseContextHolder.getUserId());
|
|
|
+ newVendorOut.setUpdaterName(BaseContextHolder.getUserName());
|
|
|
+ newVendorOut.setUpdateTime(new Date());
|
|
|
+ newVendorOut.setVe_payamount(payamountOut+amount1);
|
|
|
+ newVendorOut.setVe_leftamount(beginapamountOut-beginprepayamountOut+payamountOut+amount1-preamountOut);
|
|
|
+ paybalanceMapper.updateVendorByPrimaryKeySelective(newVendorOut);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
@Override
|
|
|
public void batchAudit(BatchDealBaseDTO baseDTO) {
|
|
|
Iterator isList = baseDTO.getBaseDTOs().iterator();
|
|
|
while (isList.hasNext()){
|
|
|
DocBaseDTO docBaseDTO = (DocBaseDTO) isList.next();
|
|
|
Long id = docBaseDTO.getId();
|
|
|
+
|
|
|
+ //更新客户或者供应商的金额
|
|
|
+ Verification nowverification = verificationMapper.selectByPrimaryKey(id);
|
|
|
+ VerificationDTO verificationDTO = BeanMapper.map(nowverification,VerificationDTO.class);
|
|
|
+ updateAuditCustomer(verificationDTO);
|
|
|
+ updateAuditVendor(verificationDTO);
|
|
|
+
|
|
|
+ //更新源单金额
|
|
|
+ //获取从表1
|
|
|
+ List<Verificationdet> items1 = verificationdetMapper.selectByFK(id);
|
|
|
+ //获取从表2
|
|
|
+ List<Verificationdetail> items2 = verificationdetailMapper.selectByFK(id);
|
|
|
+ for(Verificationdet det : items1){
|
|
|
+ Double nowbalanceDet = det.getVd_nowbalance()==null?new Double(0):det.getVd_nowbalance();
|
|
|
+ updateAuditSubledeger(det.getVd_slid(),nowbalanceDet);
|
|
|
+ }
|
|
|
+ for(Verificationdetail detail : items2){
|
|
|
+ Double nowbalanceDet = detail.getVcd_nowbalance()==null?new Double(0):detail.getVcd_nowbalance();
|
|
|
+ updateAuditSubledeger(detail.getVcd_slid(),nowbalanceDet);
|
|
|
+ }
|
|
|
+
|
|
|
Verification verification = new Verification();
|
|
|
verification.setVc_status(Status.AUDITED.getDisplay());
|
|
|
verification.setVc_statuscode(Status.AUDITED.name());
|
|
|
verification.setVc_id(Integer.valueOf(String.valueOf(id)));
|
|
|
+ verification.setCompanyId(BaseContextHolder.getCompanyId());
|
|
|
+ verification.setUpdaterId(BaseContextHolder.getUserId());
|
|
|
+ verification.setUpdaterName(BaseContextHolder.getUserName());
|
|
|
+ verification.setUpdateTime(new Date());
|
|
|
verificationMapper.updateByPrimaryKeySelective(verification);
|
|
|
}
|
|
|
}
|
|
|
@@ -319,10 +917,34 @@ public class VerificationServiceImpl extends CommonBaseServiceImpl<VerificationM
|
|
|
while (isList.hasNext()){
|
|
|
DocBaseDTO docBaseDTO = (DocBaseDTO) isList.next();
|
|
|
Long id = docBaseDTO.getId();
|
|
|
+
|
|
|
+ //更新客户或者供应商的金额
|
|
|
+ Verification nowverification = verificationMapper.selectByPrimaryKey(id);
|
|
|
+ VerificationDTO verificationDTO = BeanMapper.map(nowverification,VerificationDTO.class);
|
|
|
+ updateResAuditCustomer(verificationDTO);
|
|
|
+ updateResAuditVendor(verificationDTO);
|
|
|
+
|
|
|
+ //更新源单金额
|
|
|
+ //获取从表1
|
|
|
+ List<Verificationdet> items1 = verificationdetMapper.selectByFK(id);
|
|
|
+ //获取从表2
|
|
|
+ List<Verificationdetail> items2 = verificationdetailMapper.selectByFK(id);
|
|
|
+ for(Verificationdet det : items1){
|
|
|
+ Double nowbalanceDet = det.getVd_nowbalance()==null?new Double(0):det.getVd_nowbalance();
|
|
|
+ updateAuditSubledeger(det.getVd_slid(),nowbalanceDet);
|
|
|
+ }
|
|
|
+ for(Verificationdetail detail : items2){
|
|
|
+ Double nowbalanceDet = detail.getVcd_nowbalance()==null?new Double(0):detail.getVcd_nowbalance();
|
|
|
+ updateAuditSubledeger(detail.getVcd_slid(),nowbalanceDet);
|
|
|
+ }
|
|
|
+
|
|
|
Verification verification = new Verification();
|
|
|
verification.setVc_status(Status.UNAUDITED.getDisplay());
|
|
|
verification.setVc_statuscode(Status.UNAUDITED.name());
|
|
|
verification.setVc_id(Integer.valueOf(String.valueOf(id)));
|
|
|
+ verification.setUpdaterId(BaseContextHolder.getUserId());
|
|
|
+ verification.setUpdaterName(BaseContextHolder.getUserName());
|
|
|
+ verification.setUpdateTime(new Date());
|
|
|
verificationMapper.updateByPrimaryKeySelective(verification);
|
|
|
}
|
|
|
}
|