1 package com.supwisdom.dlpay.api.service.impl
3 import com.supwisdom.dlpay.agent.citizencard.YnrccUtil
4 import com.supwisdom.dlpay.api.bean.YnrccChkfileBean
5 import com.supwisdom.dlpay.api.dao.TransactionChkdtlDao
6 import com.supwisdom.dlpay.api.dao.TransactionChkfileDao
7 import com.supwisdom.dlpay.api.domain.TTransactionChkdtl
8 import com.supwisdom.dlpay.api.domain.TTransactionChkfile
9 import com.supwisdom.dlpay.api.service.TransactionReconciliationService
10 import com.supwisdom.dlpay.exception.TransactionCheckException
11 import com.supwisdom.dlpay.framework.dao.BusinessparaDao
12 import com.supwisdom.dlpay.framework.service.SystemUtilService
13 import com.supwisdom.dlpay.framework.tenant.TenantContext
14 import com.supwisdom.dlpay.framework.util.TradeErrorCode
15 import com.supwisdom.dlpay.util.ConstantUtil
16 import org.springframework.beans.factory.annotation.Autowired
17 import org.springframework.stereotype.Service
20 class TransactionReconciliationServiceImpl : TransactionReconciliationService {
22 private lateinit var transactionChkfileDao: TransactionChkfileDao
24 private lateinit var transactionChkdtlDao: TransactionChkdtlDao
26 private lateinit var systemUtilService: SystemUtilService
28 private lateinit var businessparaDao: BusinessparaDao
30 override fun getTransactionChkfile(accdate: String, sourcetype: String): TTransactionChkfile? {
31 return transactionChkfileDao.getByAccdateAndSourcetype(accdate, sourcetype)
34 override fun doInitTransactionChkfile(accdate: String, sourcetype: String): TTransactionChkfile {
35 return transactionChkfileDao.getByAccdateAndSourcetype(accdate, sourcetype).let {
37 if (ConstantUtil.CHKFILE_STATUS_INIT != it.status)
38 throw TransactionCheckException(TradeErrorCode.BUSINESS_DEAL_ERROR, "accdate=$accdate,sourcetype=$sourcetype 的chkfile已经存在")
41 transactionChkfileDao.save(TTransactionChkfile().apply {
42 this.accdate = accdate
43 this.sourcetype = sourcetype
44 this.status = ConstantUtil.CHKFILE_STATUS_INIT
45 this.result = ConstantUtil.CHKFILE_RESULT_NONE
51 this.lastsaved = systemUtilService.sysdatetime.sysdate
52 this.tenantid = TenantContext.getTenantSchema()
58 override fun saveOrUpdateTransactionChkfile(chkfile: TTransactionChkfile) {
59 transactionChkfileDao.save(chkfile)
62 override fun saveYnrccTransactionChkDtl(chkfile: TTransactionChkfile, bean: YnrccChkfileBean): TTransactionChkdtl {
63 return transactionChkdtlDao.save(TTransactionChkdtl().apply {
64 this.chkfileId = chkfile.id
65 this.accdate = chkfile.accdate
66 this.sourcetype = chkfile.sourcetype
67 this.recordno = bean.recordno
68 this.amount = bean.amount / 100.0
69 this.otherRefno = bean.agentrefno
70 this.localRefno = bean.refno
71 this.otherAccdate = bean.agentdate
72 this.transtype = bean.flag
73 this.otherStatus = bean.status
75 this.extdata = bean.summary
76 this.chkresult = ConstantUtil.CHKDTL_CHKRESULT_UNCHECK
78 this.lastsaved = systemUtilService.sysdatetime.sysdate
79 this.tenantid = TenantContext.getTenantSchema()
83 override fun doBatchSaveYnrccTransactionChkDtl(chkfile: TTransactionChkfile, list: ArrayList<YnrccChkfileBean>): Boolean {
85 saveYnrccTransactionChkDtl(chkfile, bean)
90 override fun doSuccessTransactionChkfile(chkfile: TTransactionChkfile, remark: String) {
91 val suminfo = transactionChkdtlDao.getTransactionSumInfo(chkfile.accdate, chkfile.sourcetype)
92 chkfile.status = ConstantUtil.CHKFILE_STATUS_UNCHECK
93 chkfile.remark = remark
94 chkfile.othercnt = suminfo.totalcnt ?: 0
95 chkfile.otheramt = suminfo.totalamt ?: 0.0
96 transactionChkfileDao.save(chkfile)
97 businessparaDao.updateBusinessparaValue(YnrccUtil.YNRCC_BILLS_DOWNLOAD_LASTDATE, chkfile.accdate) //更新下载对账单日期