From 0949dcbccfb1357ca16c2c82ba57d4eef268b7c7 Mon Sep 17 00:00:00 2001 From: Xia Kaixiang Date: Thu, 15 Aug 2019 14:21:27 +0800 Subject: [PATCH] =?utf8?q?=E5=AF=B9=E8=B4=A6=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../dlpay/api/dao/TransactionChkdtlDao.java | 13 +- .../supwisdom/dlpay/util/ConstantUtil.java | 9 +- .../service/citizencard_checkfile_service.kt | 4 +- .../dlpay/api/scheduler_sourcetype_chk.kt | 131 ++++++++++-------- ...transaction_reconciliation_service_impl.kt | 126 ++++++++++------- .../transaction_reconciliation_service.kt | 17 ++- 6 files changed, 185 insertions(+), 115 deletions(-) diff --git a/payapi/src/main/java/com/supwisdom/dlpay/api/dao/TransactionChkdtlDao.java b/payapi/src/main/java/com/supwisdom/dlpay/api/dao/TransactionChkdtlDao.java index 51301ce9..fb538c8d 100644 --- a/payapi/src/main/java/com/supwisdom/dlpay/api/dao/TransactionChkdtlDao.java +++ b/payapi/src/main/java/com/supwisdom/dlpay/api/dao/TransactionChkdtlDao.java @@ -1,6 +1,5 @@ package com.supwisdom.dlpay.api.dao; -import com.supwisdom.dlpay.api.domain.TPersondtl; import com.supwisdom.dlpay.api.domain.TTransactionChkdtl; import com.supwisdom.dlpay.framework.data.CountAmountBean; import com.supwisdom.dlpay.framework.data.ExistBean; @@ -39,11 +38,19 @@ public interface TransactionChkdtlDao extends JpaRepository getUncheckTransactionChkdtls(String chkfileId); - @Query("select count(t.id) as existed from TTransactionChkdtl t where t.chkfileId=?1 and t.chkresult='uncheck' ") - ExistBean getUncheckCount(String chkfileId); + @Query("select count(t.id) as existed from TTransactionChkdtl t where t.chkfileId=?1 and t.chkresult=?2 ") + ExistBean getCountByChkresult(String chkfileId, String chkresult); @Query(value = "select t.refno from TB_PERSONDTL t left join TB_TRANSACTION_CHKDTL a on t.REFNO=a.OTHER_REFNO and a.CHKFILE_ID=:chkfileId " + " where t.ACCDATE=:accdate and t.SOURCETYPE=:sourcetype and t.status='success' and a.id is null order by t.refno ", nativeQuery = true) List findLocalMoreDtls(@Param("accdate") String accdate, @Param("sourcetype") String sourcetype, @Param("chkfileId") String chkfileId); + @Query("select count(t.id) as existed from TTransactionChkdtl t where t.chkfileId=?1 and t.chkresult<>'equal' and t.chkresult<>'nocharge' ") + ExistBean getErrorCount(String chkfileId); + + @Query("from TTransactionChkdtl t where t.chkresult='nocharge' and t.resolved<>'equal' and t.chkfileId=?1 order by t.recordno ") + List getNeedRepairChkdtls(String chkfileId); + + @Query("select count(t.id) as existed from TTransactionChkdtl t where t.chkfileId=?1 and t.and t.resolved<>'equal' ") + ExistBean getChkdtlNotEqualCount(String chkfileId); } diff --git a/payapi/src/main/java/com/supwisdom/dlpay/util/ConstantUtil.java b/payapi/src/main/java/com/supwisdom/dlpay/util/ConstantUtil.java index 7d7e8097..8dcf53c0 100644 --- a/payapi/src/main/java/com/supwisdom/dlpay/util/ConstantUtil.java +++ b/payapi/src/main/java/com/supwisdom/dlpay/util/ConstantUtil.java @@ -39,8 +39,9 @@ public class ConstantUtil { * */ public static final String CHKFILE_STATUS_INIT = "init"; //初始化 public static final String CHKFILE_STATUS_UNCHECK = "uncheck"; //待对账 - public static final String CHKFILE_STATUS_finish = "finish"; //对账完成 - public static final String CHKFILE_STATUS_ERROR = "error"; //对账异常 + public static final String CHKFILE_STATUS_CHECKOUT = "checkout"; //校对完成 + public static final String CHKFILE_STATUS_FINISH = "finish"; //对账完成 + public static final String CHKFILE_STATUS_ERROR = "error"; //保存数据异常 /** * 对账文件结果状态 @@ -48,6 +49,7 @@ public class ConstantUtil { public static final String CHKFILE_RESULT_NONE = "none"; //未对账 - public static final String CHKFILE_RESULT_EQUAL = "equal"; //对账一致,平 public static final String CHKFILE_RESULT_UNEQUAL = "unequal"; //对账不一致,不平 + public static final String CHKFILE_RESULT_ERROR = "error"; //对账明细有异常 /** * 对账明细状态 @@ -58,12 +60,13 @@ public class ConstantUtil { public static final String CHKDTL_CHKRESULT_NOCHARGE = "nocharge"; //支付未记账 public static final String CHKDTL_CHKRESULT_DIFF = "diff"; //金额不相等 public static final String CHKDTL_CHKRESULT_ERROR = "error"; //记账日期或支付方式错误 + public static final String CHKDTL_CHKRESULT_SURPLUS = "surplus"; //本地多余成功流水 /** * 对账明细解决状态 * */ + public static final String CHKDTL_RESOLVED_NONE = "none"; //已处理 public static final String CHKDTL_RESOLVED_ADD ="add"; //补账 - public static final String CHKDTL_RESOLVED_PROCESSED = "processed"; //已处理 public static final String CHKDTL_RESOLVED_FAIL = "fail"; //补账失败 public static final String CHKDTL_RESOLVED_EQUAL = "equal"; //一致,相等 public static final String CHKDTL_RESOLVED_HANGUP="hangup"; //挂起 diff --git a/payapi/src/main/kotlin/com/supwisdom/dlpay/agent/service/citizencard_checkfile_service.kt b/payapi/src/main/kotlin/com/supwisdom/dlpay/agent/service/citizencard_checkfile_service.kt index 46ae3401..253ef363 100644 --- a/payapi/src/main/kotlin/com/supwisdom/dlpay/agent/service/citizencard_checkfile_service.kt +++ b/payapi/src/main/kotlin/com/supwisdom/dlpay/agent/service/citizencard_checkfile_service.kt @@ -65,7 +65,7 @@ class CitizenCardCheckFileProvider : CheckFileProvider { ?: transactionReconciliationService.saveInitTransactionChkfile(billDate, checkStatus.sourceType) if (chkfile.status == ConstantUtil.CHKFILE_STATUS_UNCHECK) { - return successDownload("[$billDate]日对账数据入库成功", checkStatus) + return successDownload("[$billDate]日对账数据已入库成功", checkStatus) } val resp = citizencardPayService.getChkfilename(billDate, null) when (resp.code) { @@ -147,7 +147,7 @@ class CitizenCardCheckFileProvider : CheckFileProvider { BufferedReader(InputStreamReader(stream)).use { reader -> val header = reader.readLine() val fields = header.split(",").mapNotNull { if (it.isNotEmpty()) it else null } - val batchSize = 10000 //每次保存的数目 + val batchSize = 5000 //每次保存的数目 var failcnt = 0 val datalist = ArrayList() diff --git a/payapi/src/main/kotlin/com/supwisdom/dlpay/api/scheduler_sourcetype_chk.kt b/payapi/src/main/kotlin/com/supwisdom/dlpay/api/scheduler_sourcetype_chk.kt index 26018f54..05b5b5b9 100644 --- a/payapi/src/main/kotlin/com/supwisdom/dlpay/api/scheduler_sourcetype_chk.kt +++ b/payapi/src/main/kotlin/com/supwisdom/dlpay/api/scheduler_sourcetype_chk.kt @@ -185,6 +185,7 @@ class SourceTypeCheck { * 3. 交易流水不存在(notexist), 表示本地交易流水不存在,影响对账文件表的 result 状态,为error。 * 4. 支付未记账 ( nocharge) ,表示本地流水未成功,需要补帐 * 5. 金额不相等(diff), 表示对账明细金额与本地流水不一致, 影响对账文件表的 result 状态,为error。 + * 6. 本地多流水 (surplus), 表示本地的成功流水在对账单中不存在, 影响对账文件表的 result 状态,为error。 * 6. 记账日期或支付方式错误 (error) , 其它类型错误,影响对账文件表的 result 状态,为error。 * * 对账明细表(TTransactionChkDtl) 的 result 表示处理结果 @@ -275,62 +276,74 @@ class SourceTypeCheckExecutor { @Async("sourcetypeCheckTaskExecutor") fun reconciliation(checkStatus: TSourceTypeCheckStatus): Future { // 3. 完成对账 - val result = if (!checkStatus.checkStatus) { - transactionReconciliationService - .getTransactionChkfile(checkStatus.checkAccdate, checkStatus.sourceType)?.let { chkfile -> - try { - when (doCheckProcess(chkfile, checkStatus).result) { - ConstantUtil.CHKFILE_RESULT_EQUAL -> { - ExecutorResult(checkStatus, SUCCESS, "对账成功,双方一致") - } - else -> ExecutorResult(checkStatus, FAIL, "对账不平") - } - } catch (ex: Exception) { - ex.printStackTrace() - ExecutorResult(checkStatus, FAIL, "对账异常") - } - } ?: ExecutorResult(checkStatus, FAIL, "未找到[${checkStatus.checkAccdate}]日入库的对账数据") - } else if (checkStatus.repairStatus) { - // 补帐逻辑 - ExecutorResult(checkStatus, SUCCESS, "对账成功,双方一致") - } else if (checkStatus.settleStatus) { - ExecutorResult(checkStatus, SUCCESS, "对账完成,可以结算") - } else { - ExecutorResult(checkStatus, FAIL, "未找到[${checkStatus.checkAccdate}]日入库的对账数据") - } + val result =transactionReconciliationService.getTransactionChkfile(checkStatus.checkAccdate, checkStatus.sourceType)?.let { chkfile -> + try { + doCheckProcess(chkfile, checkStatus) //执行对账过程 + when (checkStatus.settleStatus) { + true -> ExecutorResult(checkStatus, SUCCESS, "对账成功,双方一致") + false -> ExecutorResult(checkStatus, FAIL, "对账不平") + } + } catch (ex: Exception) { + ex.printStackTrace() + ExecutorResult(checkStatus, FAIL, "对账异常") + } + } ?: ExecutorResult(checkStatus, FAIL, "未找到[${checkStatus.checkAccdate}]日入库的对账数据") + +// val result = if (!checkStatus.checkStatus) { +// transactionReconciliationService +// .getTransactionChkfile(checkStatus.checkAccdate, checkStatus.sourceType)?.let { chkfile -> +// try { +// when (doCheckProcess(chkfile, checkStatus).result) { +// ConstantUtil.CHKFILE_RESULT_EQUAL -> { +// ExecutorResult(checkStatus, SUCCESS, "对账成功,双方一致") +// } +// else -> ExecutorResult(checkStatus, FAIL, "对账不平") +// } +// } catch (ex: Exception) { +// ex.printStackTrace() +// ExecutorResult(checkStatus, FAIL, "对账异常") +// } +// } ?: ExecutorResult(checkStatus, FAIL, "未找到[${checkStatus.checkAccdate}]日入库的对账数据") +// } else if (checkStatus.repairStatus) { +// // 补帐逻辑 +// ExecutorResult(checkStatus, SUCCESS, "对账成功,双方一致") +// } else if (checkStatus.settleStatus) { +// ExecutorResult(checkStatus, SUCCESS, "对账完成,可以结算") +// } else { +// ExecutorResult(checkStatus, FAIL, "未找到[${checkStatus.checkAccdate}]日入库的对账数据") +// } return AsyncResult(result) } - fun doCheckProcess(chkfile: TTransactionChkfile, checkStatus: TSourceTypeCheckStatus): TTransactionChkfile { - // 假设绝大多数记录都是一致的情况下,下面的逻辑采用每1000条批量处理提高性能 - //统一处理交易一致的记录, 对账 1 + fun doCheckProcess(chkfile: TTransactionChkfile, checkStatus: TSourceTypeCheckStatus) { + //step1: 假设绝大多数记录都是一致的情况下,下面的逻辑采用每1000条批量处理提高性能,统一处理交易一致的记录 (0..chkfile.othercnt step 1000).forEach { try { transactionReconciliationService.doCheckEqualTransdtls(chkfile, it) } catch (e1: Exception) { } } - //剩余的未对账记录逐一对比, 对账 2 - // 这个规则业务可以处理 "对账1" 中可能漏掉的记录 - var errorDtl = false + + //step2: 剩余的未对账记录逐一对比, 这个规则业务可以处理 "对账1" 中可能漏掉的记录 transactionReconciliationService.getUncheckTransactionChkdtls(chkfile.id).forEach { - transactionReconciliationService.doCheckTransactionChkdtl(it).also { chkdtl -> - if (chkdtl.chkresult != ConstantUtil.CHKDTL_CHKRESULT_NOCHARGE - && chkdtl.chkresult != ConstantUtil.CHKDTL_CHKRESULT_EQUAL) { - errorDtl = true - } - } + transactionReconciliationService.doCheckTransactionChkdtl(it) } - //判断chkdtl是否全部对账完成 , 对账 3 + //step3: 判断chkdtl是否全部对账完成 if (transactionReconciliationService.checkUncheckExists(chkfile.id)) { throw TransactionException(-2, "存在未对账的明细记录") } - //判断本地是否有多余成功流水,并保存 , 对账 4 - transactionReconciliationService.doCheckLocalMoreDtls(chkfile, checkStatus).also { - if (it.isNotEmpty()) { - errorDtl = true - } + //step4: 判断本地是否有多余成功流水,并保存 + try { + transactionReconciliationService.doCheckLocalMoreDtls(chkfile) + } catch (e1: TransactionException) { + //本地数据存在异常 + checkStatus.checkStatus = false + checkStatus.repairStatus = false + checkStatus.settleStatus = false + checkStatus.remark = e1.message + sourceTypeService.saveOrUpdateSourceTypeCheckStatus(checkStatus) + return //直接返回 } /** @@ -339,25 +352,25 @@ class SourceTypeCheckExecutor { * 2. 对"是否可以补帐"的定义是必须"对账完成" * 3. 当所有明细完成对账或补帐才能结算 */ - return if (!errorDtl) { - chkfile.status = ConstantUtil.CHKFILE_STATUS_finish - checkStatus.checkStatus = true - checkStatus.repairStatus = true - checkStatus.settleStatus = false - // udpate - transactionReconciliationService.doConfirmChkfileStatus(chkfile, checkStatus) - // 调用补帐业务进行补帐处理 + transactionReconciliationService.doFinishChkfileStatus(chkfile, checkStatus) - // 完成补帐业务进入结算状态 - checkStatus.settleStatus = true - transactionReconciliationService.doConfirmChkfileStatus(chkfile, checkStatus) - - } else { - chkfile.status = ConstantUtil.CHKFILE_STATUS_ERROR - checkStatus.settleStatus = false - checkStatus.repairStatus = false - checkStatus.checkStatus = true - transactionReconciliationService.doConfirmChkfileStatus(chkfile, checkStatus) + //补账, result为equal或unequal时补帐,error跳过 + if (chkfile.result in setOf(ConstantUtil.CHKFILE_RESULT_EQUAL, ConstantUtil.CHKFILE_RESULT_UNEQUAL)) { + transactionReconciliationService.getNeedRepairChkdtls(chkfile).forEach { chkdtl -> + try { + transactionReconciliationService.doRepairTransactionChkdtl(chkdtl) //补账 + } catch (e2: Exception) { + try { + transactionReconciliationService.saveOrUpdateTransctionChkdtl(chkdtl.apply { + this.resolved = ConstantUtil.CHKDTL_RESOLVED_FAIL + this.remark = e2.message ?: e2.javaClass.name + }) //补账失败,记录错误 + } catch (e3: Exception) { + } + } + } } + + transactionReconciliationService.doConfirmChkfileStatus(chkfile, checkStatus) } } \ No newline at end of file diff --git a/payapi/src/main/kotlin/com/supwisdom/dlpay/api/service/impl/transaction_reconciliation_service_impl.kt b/payapi/src/main/kotlin/com/supwisdom/dlpay/api/service/impl/transaction_reconciliation_service_impl.kt index 2e2e89a4..ad35776a 100644 --- a/payapi/src/main/kotlin/com/supwisdom/dlpay/api/service/impl/transaction_reconciliation_service_impl.kt +++ b/payapi/src/main/kotlin/com/supwisdom/dlpay/api/service/impl/transaction_reconciliation_service_impl.kt @@ -13,6 +13,7 @@ import com.supwisdom.dlpay.api.service.SourceTypeService import com.supwisdom.dlpay.api.service.TransactionReconciliationService import com.supwisdom.dlpay.api.service.TransactionServiceProxy import com.supwisdom.dlpay.exception.TransactionCheckException +import com.supwisdom.dlpay.exception.TransactionException import com.supwisdom.dlpay.framework.dao.BusinessparaDao import com.supwisdom.dlpay.framework.service.SystemUtilService import com.supwisdom.dlpay.framework.tenant.TenantContext @@ -79,7 +80,7 @@ class TransactionReconciliationServiceImpl : TransactionReconciliationService { this.remark = null this.extdata = bean.summary this.chkresult = ConstantUtil.CHKDTL_CHKRESULT_UNCHECK - this.resolved = null + this.resolved = ConstantUtil.CHKDTL_RESOLVED_NONE this.lastsaved = systemUtilService.sysdatetime.sysdate this.tenantid = TenantContext.getTenantSchema() }) @@ -184,25 +185,17 @@ class TransactionReconciliationServiceImpl : TransactionReconciliationService { //需要补账 chkdtl.chkresult = ConstantUtil.CHKDTL_CHKRESULT_NOCHARGE chkdtl.resolved = ConstantUtil.CHKDTL_RESOLVED_ADD - chkdtl.remark = "本地未入账,需要" + chkdtl.remark = "本地未入账,需要补助" transactionChkdtlDao.save(chkdtl) //对账明细表更新 } } override fun checkUncheckExists(chkfileId: String): Boolean { - return transactionChkdtlDao.getUncheckCount(chkfileId).existed > 0 + return transactionChkdtlDao.getCountByChkresult(chkfileId, ConstantUtil.CHKDTL_CHKRESULT_UNCHECK).existed > 0 } - private fun updateCheckStatusWhenError(message: String, checkStatus: TSourceTypeCheckStatus, - chkfile: TTransactionChkfile) { - checkStatus.checkStatus = false - checkStatus.remark = message - chkfile.status = ConstantUtil.CHKFILE_STATUS_ERROR - } - - override fun doCheckLocalMoreDtls(chkfile: TTransactionChkfile, checkStatus: TSourceTypeCheckStatus): List { - val result = mutableListOf() - transactionChkdtlDao.findLocalMoreDtls(chkfile.accdate, chkfile.sourcetype, chkfile.id)?.also { + override fun doCheckLocalMoreDtls(chkfile: TTransactionChkfile): Int { + return transactionChkdtlDao.findLocalMoreDtls(chkfile.accdate, chkfile.sourcetype, chkfile.id)?.also { it.forEach { refno -> //保存多余的记录 transactionMainDao.findByRefno(refno)?.also { transMain -> @@ -220,54 +213,93 @@ class TransactionReconciliationServiceImpl : TransactionReconciliationService { else -> transMain.reverseType } this.otherStatus = "unknown" - this.remark = "本地成功流水第三方流水不存在" + this.remark = "本地有成功流水,第三方流水不存在" this.extdata = transMain.personDtl.transdesc - this.chkresult = ConstantUtil.CHKDTL_CHKRESULT_ERROR + this.chkresult = ConstantUtil.CHKDTL_CHKRESULT_SURPLUS this.resolved = ConstantUtil.CHKDTL_RESOLVED_HANGUP this.lastsaved = systemUtilService.sysdatetime.sysdate this.tenantid = chkfile.tenantid - }).also { dtl -> - result.add(dtl) - }//保存本地多出的记录 + })//保存本地多出的记录 }.also { transMain -> if (transMain == null) { - chkfile.status = ConstantUtil.CHKFILE_STATUS_ERROR - updateCheckStatusWhenError("交易参考号<$refno>异常,未找到Main记录", - checkStatus, chkfile) - return result + throw TransactionException(-3, "本地存在多余成功流水记录,且交易参考号<$refno>异常,未找到transactionMain记录") } } } - }?.also { - if (it.isNotEmpty()) { - chkfile.status = ConstantUtil.CHKFILE_STATUS_ERROR - updateCheckStatusWhenError("本地有<${it.size}>条流水不在对账文件中,请联系管理员检查", - checkStatus, chkfile) + }?.size ?: 0 + } + + override fun doFinishChkfileStatus(chkfile: TTransactionChkfile, checkStatus: TSourceTypeCheckStatus) { + if (transactionChkdtlDao.getCountByChkresult(chkfile.id, ConstantUtil.CHKDTL_CHKRESULT_UNCHECK).existed > 0) { + throw TransactionException(-2, "存在未对账的明细记录") + } + //明细已全部校对完 + chkfile.status = ConstantUtil.CHKFILE_STATUS_FINISH + checkStatus.checkStatus = true + checkStatus.repairStatus = false + checkStatus.settleStatus = false + if (transactionChkdtlDao.getErrorCount(chkfile.id).existed > 0) { + //除了需要补账的错误外有其他异常 + chkfile.result = ConstantUtil.CHKFILE_RESULT_ERROR + chkfile.remark = "校对完成,明细存在对比异常" + transactionChkdtlDao.getCountByChkresult(chkfile.id, ConstantUtil.CHKDTL_CHKRESULT_SURPLUS).existed.also { + if (null != it && it > 0) { + chkfile.remark = "本地有<${it}>条流水不在对账文件中,请联系管理员检查" + } + } + } else { + //仅存在一致或需补账的记录 + if (transactionChkdtlDao.getCountByChkresult(chkfile.id, ConstantUtil.CHKDTL_CHKRESULT_NOCHARGE).existed > 0) { + //存在需补账记录 + chkfile.result = ConstantUtil.CHKFILE_RESULT_UNEQUAL //不平 + chkfile.remark = "校对完成,存在需补账的交易记录" + } else { + chkfile.result = ConstantUtil.CHKFILE_RESULT_EQUAL //一致 + chkfile.remark = "校对完成,双方交易一致" } } - return result + transactionChkfileDao.save(chkfile) + sourceTypeService.saveOrUpdateSourceTypeCheckStatus(checkStatus) + } + + override fun getNeedRepairChkdtls(chkfile: TTransactionChkfile): List { + return transactionChkdtlDao.getNeedRepairChkdtls(chkfile.id) ?: ArrayList(0) + } + + override fun doRepairTransactionChkdtl(chkdtl: TTransactionChkdtl): TTransactionChkdtl { + transactionService.repair(chkdtl.localRefno, chkdtl.otherAccdate, chkdtl.otherRefno, "补账成功") + chkdtl.resolved = ConstantUtil.CHKDTL_RESOLVED_EQUAL + chkdtl.remark = "本地未入账,补账成功" + return transactionChkdtlDao.save(chkdtl) + } + + override fun saveOrUpdateTransctionChkdtl(chkdtl: TTransactionChkdtl){ + transactionChkdtlDao.save(chkdtl) } override fun doConfirmChkfileStatus(chkfile: TTransactionChkfile, checkStatus: TSourceTypeCheckStatus): TTransactionChkfile { -// if (chkfile.status == ConstantUtil.CHKFILE_STATUS_ERROR) { -// chkfile.remark = checkStatus.remark -// } else { -// val personSumInfo = persondtlDao.getPersondtlSumInfo(chkfile.accdate, chkfile.sourcetype, chkfile.tenantid) -// chkfile.localcnt = personSumInfo.totalcnt ?: 0 -// chkfile.localamt = personSumInfo.totalamt ?: 0.00 -// chkfile.status = ConstantUtil.CHKFILE_STATUS_finish //对账结束 -// if (chkfile.othercnt == chkfile.localcnt && MoneyUtil.moneyEqual(chkfile.otheramt, chkfile.localamt)) { -// //fixme: 是否还需判断chkdtl中resolved是否都equal -// chkfile.result = ConstantUtil.CHKFILE_RESULT_EQUAL -// chkfile.remark = "对账完成,双方一致" -// checkStatus.settleStatus = true -// } else { -// chkfile.result = ConstantUtil.CHKFILE_RESULT_UNEQUAL -// chkfile.remark = "对账不平,请查看明细数据" -// } -// checkStatus.checkStatus = true -// checkStatus.remark = "对账完成" -// } + val personSumInfo = persondtlDao.getPersondtlSumInfo(chkfile.accdate, chkfile.sourcetype, chkfile.tenantid) + chkfile.localcnt = personSumInfo.totalcnt ?: 0 + chkfile.localamt = personSumInfo.totalamt ?: 0.00 + + checkStatus.repairStatus = false + checkStatus.settleStatus = false + checkStatus.remark = chkfile.remark + if (chkfile.result in setOf(ConstantUtil.CHKFILE_RESULT_EQUAL, ConstantUtil.CHKFILE_RESULT_UNEQUAL)) { + val notEqualCount = transactionChkdtlDao.getChkdtlNotEqualCount(chkfile.id).existed + if (notEqualCount == 0 && chkfile.othercnt == chkfile.localcnt && MoneyUtil.moneyEqual(chkfile.otheramt, chkfile.localamt)) { + //对平 + chkfile.remark = when (chkfile.result == ConstantUtil.CHKFILE_RESULT_EQUAL) { + true -> "对账完成,双方交易一致" + else -> "对账完成,补账后双方交易一致" + } + checkStatus.repairStatus = true + checkStatus.settleStatus = true + checkStatus.remark = chkfile.remark + }else{ + checkStatus.remark = "对账完成,补账有失败" + } + } sourceTypeService.saveOrUpdateSourceTypeCheckStatus(checkStatus) return transactionChkfileDao.save(chkfile) diff --git a/payapi/src/main/kotlin/com/supwisdom/dlpay/api/service/transaction_reconciliation_service.kt b/payapi/src/main/kotlin/com/supwisdom/dlpay/api/service/transaction_reconciliation_service.kt index 94299405..21a16a82 100644 --- a/payapi/src/main/kotlin/com/supwisdom/dlpay/api/service/transaction_reconciliation_service.kt +++ b/payapi/src/main/kotlin/com/supwisdom/dlpay/api/service/transaction_reconciliation_service.kt @@ -47,9 +47,24 @@ interface TransactionReconciliationService { fun checkUncheckExists(chkfileId: String): Boolean @Transactional(rollbackFor = [Exception::class]) - fun doCheckLocalMoreDtls(chkfile: TTransactionChkfile, checkStatus: TSourceTypeCheckStatus): List + fun doCheckLocalMoreDtls(chkfile: TTransactionChkfile): Int + + @Transactional(rollbackFor = [Exception::class]) + fun doFinishChkfileStatus(chkfile: TTransactionChkfile, checkStatus: TSourceTypeCheckStatus) + + @Transactional(rollbackFor = [Exception::class], readOnly = true) + fun getNeedRepairChkdtls(chkfile: TTransactionChkfile): List + + @Transactional(rollbackFor = [Exception::class]) + fun doRepairTransactionChkdtl(chkdtl: TTransactionChkdtl): TTransactionChkdtl + + @Transactional(rollbackFor = [Exception::class]) + fun saveOrUpdateTransctionChkdtl(chkdtl: TTransactionChkdtl) + @Transactional(rollbackFor = [Exception::class]) fun doConfirmChkfileStatus(chkfile: TTransactionChkfile, checkStatus: TSourceTypeCheckStatus): TTransactionChkfile + + } \ No newline at end of file -- 2.17.1