|
|
@@ -2,6 +2,7 @@ package com.usoftchina.saas.money.service.impl;
|
|
|
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
+import com.usoftchina.saas.base.Result;
|
|
|
import com.usoftchina.saas.base.service.CommonBaseServiceImpl;
|
|
|
import com.usoftchina.saas.commons.api.MaxnumberService;
|
|
|
import com.usoftchina.saas.commons.api.MessageLogService;
|
|
|
@@ -217,7 +218,7 @@ public class VerificationServiceImpl extends CommonBaseServiceImpl<VerificationM
|
|
|
total1 += nowbalanceDet;
|
|
|
|
|
|
//单据金额
|
|
|
- Double amount = det.getVd_amount();
|
|
|
+ Double amount = det.getSl_namount();
|
|
|
//核销金额
|
|
|
if(amount.doubleValue()>0 && nowbalanceDet.doubleValue()<0){
|
|
|
String msg = BizExceptionCode.MONEY_NOWAMOUNT_POSITIVE.getMessage();
|
|
|
@@ -261,7 +262,7 @@ public class VerificationServiceImpl extends CommonBaseServiceImpl<VerificationM
|
|
|
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.doubleValue()<nowbalance.doubleValue()){
|
|
|
- throw new BizException(500, BizExceptionCode.VERIFICATION_CHECK_BALANCE.getMessage());
|
|
|
+ throw new BizException(500, BizExceptionCode.RECALANCE_OUTNOWBALANCE.getMessage());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -269,14 +270,15 @@ public class VerificationServiceImpl extends CommonBaseServiceImpl<VerificationM
|
|
|
}
|
|
|
|
|
|
//插入中间表
|
|
|
- private Subledger changSubledgerUntil(VerificationDTO verification){
|
|
|
+ private Subledger changSubledgerUntil(VerificationDTO verification, int cs){
|
|
|
Subledger subledger = new Subledger();
|
|
|
String kind = verification.getVc_kind();
|
|
|
subledger.setCompanyId(BaseContextHolder.getCompanyId());
|
|
|
subledger.setSl_code(verification.getVc_code());
|
|
|
+ Double amount1 = verification.getVc_amount1()==null?new Double(0):verification.getVc_amount1();
|
|
|
+ Double amount2 = verification.getVc_amount2()==null?new Double(0):verification.getVc_amount2();
|
|
|
|
|
|
- if(kind.equals("receipts_offset_receivable") || kind.equals("prepaid_offset_payable") ||
|
|
|
- kind.equals("receivable_offset_payable")){
|
|
|
+ if(kind.equals("receipts_offset_receivable") || kind.equals("prepaid_offset_payable") ){
|
|
|
|
|
|
/*
|
|
|
['receipts_offset_receivable', '预收冲应收'],
|
|
|
@@ -285,29 +287,33 @@ public class VerificationServiceImpl extends CommonBaseServiceImpl<VerificationM
|
|
|
['receivable_to_receivable', '应收转应收'],
|
|
|
['payable_to_payable', '应付转应付']
|
|
|
*/
|
|
|
- subledger.setSl_custid(0);
|
|
|
+ subledger.setSl_custid(verification.getVc_custid());
|
|
|
subledger.setSl_vendid(verification.getVc_vendid());
|
|
|
+ subledger.setSl_amount(-amount2);
|
|
|
+ subledger.setSl_preamount(-amount1);
|
|
|
}else{
|
|
|
- subledger.setSl_custid(verification.getVc_custid());
|
|
|
- subledger.setSl_vendid(0);
|
|
|
+ if( cs == 2){
|
|
|
+ subledger.setSl_custid(verification.getVc_turncustid());
|
|
|
+ subledger.setSl_vendid(verification.getVc_turnvendid());
|
|
|
+ subledger.setSl_amount(amount1);
|
|
|
+ subledger.setSl_preamount(new Double(0));
|
|
|
+ } else {
|
|
|
+ subledger.setSl_custid(verification.getVc_custid());
|
|
|
+ subledger.setSl_vendid(verification.getVc_vendid());
|
|
|
+ subledger.setSl_amount(-amount1);
|
|
|
+ subledger.setSl_preamount(new Double(0));
|
|
|
+ }
|
|
|
}
|
|
|
- kind = transferKind(kind);
|
|
|
- subledger.setSl_kind(kind);
|
|
|
- Double amount1 = verification.getVc_amount1()==null?new Double(0):verification.getVc_amount1();
|
|
|
- Double amount2 = verification.getVc_amount2()==null?new Double(0):verification.getVc_amount2();
|
|
|
+
|
|
|
subledger.setSl_date(verification.getVc_date());
|
|
|
subledger.setSl_ym(DateUtils.getYm(verification.getVc_date()));
|
|
|
- subledger.setSl_amount(-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));
|
|
|
subledger.setSl_ym(DateUtils.getYm(verification.getVc_date()));
|
|
|
- if(kind.equals("receipts_offset_receivable") || kind.equals("prepaid_offset_payable")){
|
|
|
- subledger.setSl_preamount(-amount1);
|
|
|
- }else{
|
|
|
- subledger.setSl_preamount(amount1);
|
|
|
- }
|
|
|
+ kind = transferKind(kind);
|
|
|
+ subledger.setSl_kind(kind);
|
|
|
return subledger;
|
|
|
}
|
|
|
/**
|
|
|
@@ -552,10 +558,20 @@ public class VerificationServiceImpl extends CommonBaseServiceImpl<VerificationM
|
|
|
formData.getMain().setVc_auditdate(new Date());
|
|
|
baseDTO = this.saveFormData(formData);
|
|
|
Long id = baseDTO.getId();
|
|
|
+
|
|
|
VerificationDTO verificationDTO = formData.getMain();
|
|
|
- Subledger subledger = changSubledgerUntil(verificationDTO);
|
|
|
+
|
|
|
+ Subledger subledger = changSubledgerUntil(verificationDTO, 1);
|
|
|
subledgerMapper.insertSelective(subledger);
|
|
|
|
|
|
+ if ("receivable_to_receivable".equals(verificationDTO.getVc_kind()) ||
|
|
|
+ "receivable_offset_payable".equals(verificationDTO.getVc_kind())
|
|
|
+ || "payable_to_payable".equals(verificationDTO.getVc_kind())){
|
|
|
+ Subledger subledger1 = changSubledgerUntil(verificationDTO,2);
|
|
|
+ subledgerMapper.insertSelective(subledger1);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
//更新客户或者供应商的金额
|
|
|
updateAuditCustomer(verificationDTO);
|
|
|
updateAuditVendor(verificationDTO);
|
|
|
@@ -1081,8 +1097,18 @@ public class VerificationServiceImpl extends CommonBaseServiceImpl<VerificationM
|
|
|
if (null == code) {
|
|
|
throw new BizException(BizExceptionCode.NULL_CODE);
|
|
|
}
|
|
|
- Integer count = "0".equals(String.valueOf(id)) ? verificationMapper.validateCodeWhenInsert(code) :
|
|
|
- verificationMapper.validateCodeWhenUpdate(code, id);
|
|
|
- return maxnumberService.pushMaxnubmer(count, code, BillCodeSeq.VERIFICATION.getCaller()).getData();
|
|
|
+ String billCode = null;
|
|
|
+ synchronized (VerificationServiceImpl.class) {
|
|
|
+ Integer count = "0".equals(String.valueOf(id)) ? verificationMapper.validateCodeWhenInsert(code) :
|
|
|
+ verificationMapper.validateCodeWhenUpdate(code, id);
|
|
|
+ Result<String> res = maxnumberService.pushMaxnubmer(count, code, BillCodeSeq.VERIFICATION.getCaller());
|
|
|
+ if (res.isSuccess()) {
|
|
|
+ billCode = res.getData();
|
|
|
+ } else {
|
|
|
+ throw new BizException(123456, res.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return billCode;
|
|
|
+ // return maxnumberService.pushMaxnubmer(count, code, BillCodeSeq.VERIFICATION.getCaller()).getData();
|
|
|
}
|
|
|
}
|