From: Xia Kaixiang Date: Mon, 9 Sep 2019 08:55:26 +0000 (+0800) Subject: 对账任务修改 X-Git-Tag: 1.0.1^2~16 X-Git-Url: https://source.supwisdom.com/gerrit/gitweb?a=commitdiff_plain;h=67a80d913b8cc50f165108c5a1e5a1d70e1d620e;p=epayment%2Ffood_payapi.git 对账任务修改 --- diff --git a/config/application-devel-pg-xkx.properties b/config/application-devel-pg-xkx.properties index a3f5f418..0167251c 100644 --- a/config/application-devel-pg-xkx.properties +++ b/config/application-devel-pg-xkx.properties @@ -30,6 +30,7 @@ shopbalance.updater.cron=- #download.ynrcc.chkfile.cron =3 0/2 * * * ? #query.third.transdtl.result.cron=7 0/1 * * * ? #dayend.settletask.cron=0 0/2 * * * ? +payapi.sourcetype.checker.scheduler=0 0/2 * * * ? ############################################# spring.cloud.consul.enabled=false spring.cloud.consul.host=172.28.201.70 @@ -41,7 +42,7 @@ resttemplate.proxy.port=8087 #============== kafka =================== # 指定kafka 代理地址,可以多个 -#spring.kafka.bootstrap-servers=172.28.201.101:9192 +spring.kafka.bootstrap-servers=172.28.201.101:9192 #=============== provider ======================= spring.kafka.producer.retries=3 # 每次批量发送消息的数量 diff --git a/payapi/src/main/java/com/supwisdom/dlpay/api/dao/PersondtlDao.java b/payapi/src/main/java/com/supwisdom/dlpay/api/dao/PersondtlDao.java index c04f3f35..18c15d99 100644 --- a/payapi/src/main/java/com/supwisdom/dlpay/api/dao/PersondtlDao.java +++ b/payapi/src/main/java/com/supwisdom/dlpay/api/dao/PersondtlDao.java @@ -13,6 +13,6 @@ import org.springframework.stereotype.Repository; public interface PersondtlDao extends JpaRepository,JpaSpecificationExecutor { Page findByUseridAndStatus(String userid,String status, Pageable pageable); - @Query("select count(t.refno) as totalcnt,sum(t.amount) as totalamt from TPersondtl t where t.accdate=?1 and t.sourceType=?2 and t.tenantid=?3 ") + @Query("select count(t.refno) as totalcnt,sum(t.amount) as totalamt from TPersondtl t where t.status='success' and t.accdate=?1 and t.sourceType=?2 and t.tenantid=?3 ") CountAmountBean getPersondtlSumInfo(String accdate, String sourcetype, String tenantid); } diff --git a/payapi/src/main/java/com/supwisdom/dlpay/api/dao/SourceTypeCheckDao.java b/payapi/src/main/java/com/supwisdom/dlpay/api/dao/SourceTypeCheckDao.java index 9f1a81d3..13244fe6 100644 --- a/payapi/src/main/java/com/supwisdom/dlpay/api/dao/SourceTypeCheckDao.java +++ b/payapi/src/main/java/com/supwisdom/dlpay/api/dao/SourceTypeCheckDao.java @@ -1,7 +1,10 @@ package com.supwisdom.dlpay.api.dao; import com.supwisdom.dlpay.api.domain.TSourceTypeCheckStatus; +import com.supwisdom.dlpay.framework.data.ExistBean; +import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.CrudRepository; +import org.springframework.data.repository.query.Param; import org.springframework.stereotype.Repository; @Repository @@ -10,4 +13,8 @@ public interface SourceTypeCheckDao extends CrudRepository findLocalMoreDtls(@Param("accdate") String accdate, @Param("sourcetype") String sourcetype, @Param("chkfileId") String chkfileId); @@ -54,4 +54,7 @@ public interface TransactionChkdtlDao extends JpaRepository'equal' ") ExistBean getChkdtlNotEqualCount(String chkfileId); + + @Query("select count(t.id) as existed from TTransactionChkdtl t where t.chkfileId=?1 and t.resolved='equal' ") + ExistBean getChkdtlEqualCount(String chkfileId); } diff --git a/payapi/src/main/java/com/supwisdom/dlpay/api/domain/TSourceType.java b/payapi/src/main/java/com/supwisdom/dlpay/api/domain/TSourceType.java index 49f1d81a..befec80f 100644 --- a/payapi/src/main/java/com/supwisdom/dlpay/api/domain/TSourceType.java +++ b/payapi/src/main/java/com/supwisdom/dlpay/api/domain/TSourceType.java @@ -58,10 +58,12 @@ public class TSourceType implements DictionaryTable, Serializable { @Column(name = "PAYDESC", length = 200) private String paydesc; - - @Column(name = "tplusn", precision = 5) + @Column(name = "tplusn", nullable = false, precision = 5) private Integer tplusN; // 系统结算日期, T+0 ~ T+N + @Column(name = "START_CHKTIME", precision = 5) + private String startChktime; //开始能对账的时间。比如微信、支付宝是上午10点生成对账单,一般设为10:30开始对,则填:103000;为空时这说明无限制 + @Column(name = "tenantid", length = 20) @NotNull private String tenantid = ""; @@ -179,4 +181,12 @@ public class TSourceType implements DictionaryTable, Serializable { public void setTplusN(Integer tplusN) { this.tplusN = tplusN; } + + public String getStartChktime() { + return startChktime; + } + + public void setStartChktime(String startChktime) { + this.startChktime = startChktime; + } } diff --git a/payapi/src/main/java/com/supwisdom/dlpay/api/domain/TSourceTypeCheckStatus.java b/payapi/src/main/java/com/supwisdom/dlpay/api/domain/TSourceTypeCheckStatus.java index aae858e4..e055f3cd 100644 --- a/payapi/src/main/java/com/supwisdom/dlpay/api/domain/TSourceTypeCheckStatus.java +++ b/payapi/src/main/java/com/supwisdom/dlpay/api/domain/TSourceTypeCheckStatus.java @@ -22,16 +22,13 @@ public class TSourceTypeCheckStatus { @NotNull private String startAccdate; // 对账起始日期 - @Column(name = "check_file_date", length = 8) - private String checkFileDate; // 当前对账文件日期 - - @Column(name = "check_file_status") - private Boolean checkFileOk; // 当前对账文件下载成功标志 - @Column(name = "check_accdate", length = 8) @NotNull private String checkAccdate; // 当前对账记账日期 + @Column(name = "check_file_status") + private Boolean checkFileOk; // 当前对账文件下载成功标志 + @Column(name = "check_status") @NotNull private Boolean checkStatus; // 当前对账完成状态 @@ -118,14 +115,6 @@ public class TSourceTypeCheckStatus { this.startAccdate = startAccdate; } - public String getCheckFileDate() { - return checkFileDate; - } - - public void setCheckFileDate(String checkFileDate) { - this.checkFileDate = checkFileDate; - } - public Boolean getCheckFileOk() { return checkFileOk; } diff --git a/payapi/src/main/java/com/supwisdom/dlpay/api/domain/TTransactionChkdtl.java b/payapi/src/main/java/com/supwisdom/dlpay/api/domain/TTransactionChkdtl.java index ef5422a1..a96eb070 100644 --- a/payapi/src/main/java/com/supwisdom/dlpay/api/domain/TTransactionChkdtl.java +++ b/payapi/src/main/java/com/supwisdom/dlpay/api/domain/TTransactionChkdtl.java @@ -66,7 +66,7 @@ public class TTransactionChkdtl { @Column(name = "LASTSAVED") private Timestamp lastsaved; - @Column(name = "tenantid", length = 20) + @Column(name = "tenantid", nullable = false, length = 20) private String tenantid = ""; public String getId() { diff --git a/payapi/src/main/java/com/supwisdom/dlpay/api/domain/TTransactionChkfile.java b/payapi/src/main/java/com/supwisdom/dlpay/api/domain/TTransactionChkfile.java index f6f3df67..d5499dc6 100644 --- a/payapi/src/main/java/com/supwisdom/dlpay/api/domain/TTransactionChkfile.java +++ b/payapi/src/main/java/com/supwisdom/dlpay/api/domain/TTransactionChkfile.java @@ -46,7 +46,7 @@ public class TTransactionChkfile { @Column(name = "LASTSAVED") private Timestamp lastsaved; - @Column(name = "tenantid", length = 20) + @Column(name = "tenantid", nullable = false, length = 20) private String tenantid = ""; public String getId() { diff --git a/payapi/src/main/java/com/supwisdom/dlpay/framework/dao/SettleCtlDao.java b/payapi/src/main/java/com/supwisdom/dlpay/framework/dao/SettleCtlDao.java index 88e3eb2f..5dc15cb9 100644 --- a/payapi/src/main/java/com/supwisdom/dlpay/framework/dao/SettleCtlDao.java +++ b/payapi/src/main/java/com/supwisdom/dlpay/framework/dao/SettleCtlDao.java @@ -23,6 +23,9 @@ public interface SettleCtlDao extends JpaRepository { @Query(value = "from TSettlectl where tenantId=:tenantid ") TSettlectl findByTenantIdWithLock(@Param("tenantid") String tenantid); + @Query(value = "from TSettlectl where tenantId=:tenantid ") + TSettlectl findByTenantId(@Param("tenantid") String tenantid); + @Modifying(clearAutomatically = true) @Query(value = "update TB_SETTLECTL set PERIODYEAR=:peridyear,PERIODMONTH=:peridmonth where BOOKSETNO=1 ", nativeQuery = true) void updateSettlePeriod(@Param("peridyear") int peridyear, @Param("peridmonth") int peridmonth); diff --git a/payapi/src/main/java/com/supwisdom/dlpay/framework/service/SystemUtilService.java b/payapi/src/main/java/com/supwisdom/dlpay/framework/service/SystemUtilService.java index 7eda63df..1c8123be 100644 --- a/payapi/src/main/java/com/supwisdom/dlpay/framework/service/SystemUtilService.java +++ b/payapi/src/main/java/com/supwisdom/dlpay/framework/service/SystemUtilService.java @@ -71,4 +71,7 @@ public interface SystemUtilService { String getSubsystemSignKey(String syscode); + @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) + String getSettleDateBytenantId(String tenantId) throws Exception; + } diff --git a/payapi/src/main/java/com/supwisdom/dlpay/framework/service/impl/DayendSettleServiceImpl.java b/payapi/src/main/java/com/supwisdom/dlpay/framework/service/impl/DayendSettleServiceImpl.java index d1ff06dd..94566fac 100644 --- a/payapi/src/main/java/com/supwisdom/dlpay/framework/service/impl/DayendSettleServiceImpl.java +++ b/payapi/src/main/java/com/supwisdom/dlpay/framework/service/impl/DayendSettleServiceImpl.java @@ -1,6 +1,7 @@ package com.supwisdom.dlpay.framework.service.impl; import com.supwisdom.dlpay.api.dao.DebitCreditDtlDao; +import com.supwisdom.dlpay.api.dao.SourceTypeCheckDao; import com.supwisdom.dlpay.exception.TransactionException; import com.supwisdom.dlpay.framework.dao.*; import com.supwisdom.dlpay.framework.data.FSubjectInfoBean; @@ -53,6 +54,8 @@ public class DayendSettleServiceImpl implements DayendSettleService { private SubjectdayDao subjectdayDao; @Autowired private DebitCreditDtlDao debitCreditDtlDao; + @Autowired + private SourceTypeCheckDao sourceTypeCheckDao; private static final Logger logger = LoggerFactory.getLogger(DayendSettleServiceImpl.class); @@ -157,6 +160,10 @@ public class DayendSettleServiceImpl implements DayendSettleService { throw new TransactionException(-99, "日终结算已完成"); } + if (sourceTypeCheckDao.checkCanSettleCondition(String.valueOf(settledate), tSettlectl.getTenantId()).getExisted() > 0) { + throw new TransactionException(-90, "有对账未完成"); + } + TPeriod period = periodDao.getPeriod(periodYear, periodMonth, TenantContext.getTenantSchema()); if (null == period) throw new Exception("year=[" + periodYear + "],month=[" + periodMonth + "] t_period not find "); if (settledate > Integer.valueOf(period.getEnddate())) { diff --git a/payapi/src/main/java/com/supwisdom/dlpay/framework/service/impl/SystemUtilServiceImpl.java b/payapi/src/main/java/com/supwisdom/dlpay/framework/service/impl/SystemUtilServiceImpl.java index d67a64dc..a15f4de4 100644 --- a/payapi/src/main/java/com/supwisdom/dlpay/framework/service/impl/SystemUtilServiceImpl.java +++ b/payapi/src/main/java/com/supwisdom/dlpay/framework/service/impl/SystemUtilServiceImpl.java @@ -1,5 +1,7 @@ package com.supwisdom.dlpay.framework.service.impl; +import com.supwisdom.dlpay.exception.TransactionCheckException; +import com.supwisdom.dlpay.exception.TransactionProcessException; import com.supwisdom.dlpay.framework.core.DatabaseConfig; import com.supwisdom.dlpay.framework.dao.*; import com.supwisdom.dlpay.framework.data.SystemDateTime; @@ -8,6 +10,7 @@ import com.supwisdom.dlpay.framework.service.SystemUtilService; import com.supwisdom.dlpay.framework.util.DateUtil; import com.supwisdom.dlpay.framework.util.NumberUtil; import com.supwisdom.dlpay.framework.util.StringUtil; +import com.supwisdom.dlpay.framework.util.TradeErrorCode; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -183,4 +186,11 @@ public class SystemUtilServiceImpl implements SystemUtilService { return ""; } + @Override + public String getSettleDateBytenantId(String tenantId) throws Exception{ + TSettlectl ctl = settleCtlDao.findByTenantId(tenantId); + if(null==ctl) throw new TransactionProcessException(TradeErrorCode.BUSINESS_DEAL_ERROR,"获取当前结算日期失败!"); + return ctl.getSettledate().toString(); + } + } 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 253ef363..25c298b8 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 @@ -40,7 +40,7 @@ class CitizenCardCheckFileProvider : CheckFileProvider { override fun acquireCheckFile(checkStatus: TSourceTypeCheckStatus): AgentResponse { try { - val billDate = checkStatus.checkFileDate + val billDate = checkStatus.checkAccdate logger.info("大理农商行对账单下载:download checkdate=【$billDate】") val chkfile: TTransactionChkfile = transactionReconciliationService @@ -130,7 +130,7 @@ class CitizenCardCheckFileProvider : CheckFileProvider { override fun downloadCheckFile(checkStatus: TSourceTypeCheckStatus): AgentResponse { try { - val billDate = checkStatus.checkFileDate + val billDate = checkStatus.checkAccdate val agentUrl = checkStatus.chkfileUrl if ("none" == agentUrl) { return successDownload("当日无交易明细", checkStatus) 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 f6416e0b..87107ff2 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 @@ -10,6 +10,8 @@ import com.supwisdom.dlpay.api.service.SourceTypeService import com.supwisdom.dlpay.api.service.TransactionReconciliationService import com.supwisdom.dlpay.exception.TransactionException import com.supwisdom.dlpay.framework.service.SystemUtilService +import com.supwisdom.dlpay.framework.tenant.TenantContext +import com.supwisdom.dlpay.framework.util.Constants import com.supwisdom.dlpay.framework.util.DateUtil import com.supwisdom.dlpay.util.ConstantUtil import mu.KotlinLogging @@ -78,67 +80,86 @@ class SourceTypeCheck { @Autowired private lateinit var sourceTypeCheckExecutor: SourceTypeCheckExecutor - private fun prepareCheckStatus(checkStatus: TSourceTypeCheckStatus) { - if (checkStatus.startAccdate.isNullOrEmpty()) { - // 没有对账文件状态时创建一条以当前系统记账日期为起始时间的对账明细 - checkStatus.startAccdate = systemUtilService.accdate - checkStatus.checkAccdate = checkStatus.startAccdate - checkStatus.checkFileDate = checkStatus.startAccdate - } else { - checkStatus.apply { - checkAccdate = DateUtil.getNewDay(checkAccdate, 1) - checkFileDate = DateUtil.getNewDay(checkFileDate, 1) - } - } - checkStatus.apply { + private fun newSourceTypeStatus(sourceType: TSourceType, accdate: String): TSourceTypeCheckStatus { + return sourceTypeService.saveOrUpdateSourceTypeCheckStatus(TSourceTypeCheckStatus().apply { + this.sourceType = sourceType.sourceType + this.startAccdate = accdate + this.checkAccdate = accdate + this.checkFileOk = false this.checkStatus = false - checkFileOk = false - repairStatus = false - settleStatus = false - forceRecheck = false - } + this.repairStatus = false + this.settleStatus = false + this.forceRecheck = false + this.lastUpdate = systemUtilService.sysdatetime.sysdate + this.tenantId = sourceType.tenantid + this.chkfileUrl = null + this.remark = null + }) } - private fun newSourceTypeStatus(sourceType: TSourceType, accdate: String): TSourceTypeCheckStatus { - return TSourceTypeCheckStatus().also { - it.sourceType = sourceType.sourceType - it.tenantId = sourceType.tenantid - // 没有对账文件状态时创建一条以当前系统记账日期为起始时间的对账明细 + private fun canStartCheck(sourcetype: TSourceType): Boolean { + val hosttime = systemUtilService.sysdatetime.hosttime + if(DateUtil.checkDatetimeValid(sourcetype.startChktime,DateUtil.TIME_FMT) && DateUtil.compareDatetime(hosttime, sourcetype.startChktime, DateUtil.TIME_FMT)<=0){ + return false //sourcetype 设定了每天开始对账时间,小于这个对账时间不能对账 } - } - - private fun isCheckFinish(status: TSourceTypeCheckStatus): Boolean { - return (status.checkStatus && status.repairStatus) + return true } private fun determineSourceTypeCheck(sourcetype: TSourceType): TSourceTypeCheckStatus? { - if (!sourcetype.checkable || !sourcetype.enable) { - return null - } - val accdate = systemUtilService.accdate - val status = sourceTypeService.getSourceTypeCheckStatus(sourcetype.sourceType) - ?: newSourceTypeStatus(sourcetype, accdate) + try { + if (!sourcetype.checkable || !sourcetype.enable) { + return null + } - val interval = DateUtil.getIntervalDay(status.checkAccdate, accdate).toInt() - return if (status.checkStatus && status.repairStatus && interval == sourcetype.tplusN) { - // 当前日期对账已完成,并且已经对账到最后一天 - null - } else if (status.checkStatus && interval > sourcetype.tplusN) { - // 当前日期对账已完成 且 后面还有对账可以进行 - prepareCheckStatus(status) - sourceTypeService.saveOrUpdateSourceTypeCheckStatus(status) - } else if ((!status.checkStatus || !status.repairStatus) && interval >= sourcetype.tplusN) { - // 当前对账并未完成 且满足对账条件 - status - } else { - // 其它条件不对账 - null + val accdate = systemUtilService.accdate + var status = sourceTypeService.getSourceTypeCheckStatus(sourcetype.sourceType) + ?: newSourceTypeStatus(sourcetype, accdate) + + if (status.settleStatus) { + //已完成清算可以结算了,直接切换到下一天 + val nextday = DateUtil.getNewDay(status.checkAccdate, 1) + status.apply { + this.checkAccdate = nextday + this.checkFileOk = false + this.checkStatus = false + this.repairStatus = false + this.settleStatus = false + this.forceRecheck = false + this.chkfileUrl = null + this.remark = null + } + status = sourceTypeService.saveOrUpdateSourceTypeCheckStatus(status) //更新 + } + + val interval = DateUtil.getIntervalDay(status.checkAccdate, accdate).toInt() + if (interval > sourcetype.tplusN) { + if (!status.settleStatus) { + //未结算过,继续 + return status + } + return null + } else if (interval == sourcetype.tplusN) { + //对最后一天的账(比如:T+1对昨天的帐,需判断可以对账的起始时间) + if (!status.settleStatus && canStartCheck(sourcetype)) { + return status + } + return null + } else { + // 其它条件不对账 + return null + } + + } catch (ex: Exception) { + ex.printStackTrace() + return null } } @Scheduled(cron = "\${payapi.sourcetype.checker.scheduler:-}") @SchedulerLock(name = "payapiSourceTypeCheckLock", lockAtMostForString = "PT30M") fun runCheck() { + if(TenantContext.getTenantSchema()==null) TenantContext.setTenantSchema(Constants.DEFAULT_TENANTID) + val allSourcetype = sourceTypeService.allEnabledSourcetype ?: return @@ -148,7 +169,7 @@ class SourceTypeCheck { val checkProcessResult = checkFileStatus.map { // 对账文件是否下载完成 - if (it.checkFileOk) { + if (it.checkFileOk && !it.forceRecheck) { // 开始对账 sourceTypeCheckExecutor.reconciliation(it) } else { @@ -248,6 +269,11 @@ class SourceTypeCheckExecutor { fun checkAndDownloadChkfile(checkStatus: TSourceTypeCheckStatus): Future { // 2. 根据对账日期下载对账文件 try { + if(TenantContext.getTenantSchema()==null) TenantContext.setTenantSchema(Constants.DEFAULT_TENANTID) + if (checkStatus.settleStatus) { + return AsyncResult(ExecutorResult(checkStatus, FAIL, "[${checkStatus.checkAccdate}]日对账已完成")) + } + val result = getProvider(checkStatus.sourceType)?.let { provider -> val acResp = provider.acquireCheckFile(checkStatus) if (acResp.code == AgentCode.REQUIRE_QUERY) { @@ -286,12 +312,20 @@ class SourceTypeCheckExecutor { @Async("sourcetypeCheckTaskExecutor") fun reconciliation(checkStatus: TSourceTypeCheckStatus): Future { // 3. 完成对账 + if(TenantContext.getTenantSchema()==null) TenantContext.setTenantSchema(Constants.DEFAULT_TENANTID) + if (!checkStatus.checkFileOk) { + return AsyncResult(ExecutorResult(checkStatus, FAIL, "checkAccdate=[${checkStatus.checkAccdate}]对账单未完成下载,不能对账")) + } else if (checkStatus.settleStatus) { + //当天已完成对账 + return AsyncResult(ExecutorResult(checkStatus, SUCCESS, "checkAccdate=[${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, "对账不平") + false -> ExecutorResult(checkStatus, FAIL, chkfile.remark) } } catch (ex: Exception) { ex.printStackTrace() @@ -365,7 +399,7 @@ class SourceTypeCheckExecutor { transactionReconciliationService.doFinishChkfileStatus(chkfile, checkStatus) //补账, result为equal或unequal时补帐,error跳过 - if (checkStatus.repairStatus) { + if (checkStatus.checkStatus && checkStatus.repairStatus) { transactionReconciliationService.getNeedRepairChkdtls(chkfile).forEach { chkdtl -> try { transactionReconciliationService.doRepairTransactionChkdtl(chkdtl) //补账 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 3becb428..2fbe26ae 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 @@ -196,16 +196,16 @@ class TransactionReconciliationServiceImpl : TransactionReconciliationService { override fun doCheckLocalMoreDtls(chkfile: TTransactionChkfile): Int { return transactionChkdtlDao.findLocalMoreDtls(chkfile.accdate, chkfile.sourcetype, chkfile.id)?.also { - it.forEach { refno -> + it.forEachIndexed { index, refno -> //保存多余的记录 transactionMainDao.findByRefno(refno)?.also { transMain -> transactionChkdtlDao.save(TTransactionChkdtl().apply { this.chkfileId = chkfile.id this.accdate = chkfile.accdate this.sourcetype = chkfile.sourcetype - this.recordno = null + this.recordno = -1 * (index + 1) this.amount = transMain.personDtl.amount - this.otherRefno = transMain.reverseRefno ?: "0" + this.otherRefno = transMain.sourceTypeRefno ?: "$index" this.localRefno = transMain.refno this.otherAccdate = transMain.accdate this.transtype = when (transMain.reverseType) { @@ -256,8 +256,8 @@ class TransactionReconciliationServiceImpl : TransactionReconciliationService { chkfile.remark = "校对完成,双方交易一致" } checkStatus.repairStatus = true - checkStatus.remark = chkfile.remark } + checkStatus.remark = chkfile.remark transactionChkfileDao.save(chkfile) sourceTypeService.saveOrUpdateSourceTypeCheckStatus(checkStatus) } @@ -286,13 +286,15 @@ class TransactionReconciliationServiceImpl : TransactionReconciliationService { 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)) { + val equalCount = transactionChkdtlDao.getChkdtlEqualCount(chkfile.id).existed + if (notEqualCount == 0 && equalCount==chkfile.othercnt && chkfile.othercnt == chkfile.localcnt && MoneyUtil.moneyEqual(chkfile.otheramt, chkfile.localamt)) { //对平 chkfile.remark = when (chkfile.result == ConstantUtil.CHKFILE_RESULT_EQUAL) { true -> "对账完成,双方交易一致" else -> "对账完成,补账后双方交易一致" } checkStatus.settleStatus = true + checkStatus.forceRecheck = false //清掉 checkStatus.remark = chkfile.remark }else{ checkStatus.remark = "对账完成,补账有失败" diff --git a/payapi/src/main/kotlin/com/supwisdom/dlpay/api/service/impl/transaction_service_impl.kt b/payapi/src/main/kotlin/com/supwisdom/dlpay/api/service/impl/transaction_service_impl.kt index b708983f..2b43122b 100644 --- a/payapi/src/main/kotlin/com/supwisdom/dlpay/api/service/impl/transaction_service_impl.kt +++ b/payapi/src/main/kotlin/com/supwisdom/dlpay/api/service/impl/transaction_service_impl.kt @@ -12,10 +12,7 @@ import com.supwisdom.dlpay.exception.TransactionCheckException import com.supwisdom.dlpay.exception.TransactionProcessException import com.supwisdom.dlpay.framework.service.SystemUtilService import com.supwisdom.dlpay.framework.tenant.TenantContext -import com.supwisdom.dlpay.framework.util.MoneyUtil -import com.supwisdom.dlpay.framework.util.Subject -import com.supwisdom.dlpay.framework.util.TradeDict -import com.supwisdom.dlpay.framework.util.TradeErrorCode +import com.supwisdom.dlpay.framework.util.* import org.springframework.beans.factory.annotation.Autowired import org.springframework.stereotype.Service import java.sql.SQLException @@ -557,6 +554,13 @@ class TransactionServiceImpl : TransactionService { "补帐交易<$refno>状态错误,status<${transaction.status}>") } + val currentSettledate = systemUtilService.getSettleDateBytenantId(transaction.tenantid) + if (DateUtil.compareDatetime(transaction.accdate, currentSettledate, DateUtil.DATE_FMT) < 0) { + //流水记账日期小于结算日期 ( transaction.accdate这天已结算,不能补账!) + throw TransactionCheckException(TradeErrorCode.BUSINESS_DEAL_ERROR, + "流水<$refno>记账日期<${transaction.accdate}>小于系统的结算日期<$currentSettledate>,不能补账") + } + transaction.status = TradeDict.DTL_STATUS_SUCCESS //置为成功 transactionOnSuccess(transaction, sourcetypeRefno, true) // transaction.checkDate = systemUtilService.accdate @@ -568,7 +572,7 @@ class TransactionServiceImpl : TransactionService { transaction.personDtl.remark = remark } if(transaction.shop){ - transaction.personDtl.remark = remark + transaction.shopDtl.remark = remark } if(transaction.subject){ // diff --git a/payapi/src/main/resources/application.properties b/payapi/src/main/resources/application.properties index eb46e665..16dfbda2 100644 --- a/payapi/src/main/resources/application.properties +++ b/payapi/src/main/resources/application.properties @@ -33,8 +33,7 @@ server.tomcat.uri-encoding=UTF-8 shopbalance.updater.cron=10/* * * * * ? dayend.settletask.cron=0 3/30 2-3 * * ? query.third.transdtl.result.cron=7 0/1 * * * ? -download.ynrcc.chkfile.cron =3 0/10 1 * * ? -#dayend.settletask.cron = 0 0/2 * * * ? +payapi.sourcetype.checker.scheduler=7 3/10 * * * ? ################################################ # user password auth.password.bcrypt.length=10 diff --git a/payapi/src/main/resources/data.sql b/payapi/src/main/resources/data.sql index 0e592a69..556d542a 100644 --- a/payapi/src/main/resources/data.sql +++ b/payapi/src/main/resources/data.sql @@ -480,24 +480,18 @@ VALUES (30, '6602', 2, 'y', 1, NULL, 20190430, 1, '管理费收入', 6, '{tenant -INSERT INTO "tb_sourcetype" ("sourcetype_id", "sourcetype", "checkable", "paydesc", "enable", "charge_enable", -"consume_enable", "anonymous_enable", "reversable", "pay_subjno", "deposite_subjno", "tenantid") -VALUES ('D3820D49DACA49199E36537F6719665F', 'citizenCard', 't', '大理市民卡', 't', 'f', 't', 'f', 't', '112234', '-', '{tenantid}'); -INSERT INTO "tb_sourcetype" ("sourcetype_id", "sourcetype", "checkable", "paydesc", "enable", "charge_enable", -"consume_enable", "anonymous_enable", "reversable", "pay_subjno","deposite_subjno","tenantid") -VALUES ('0997477F40904AD1A2E37FD15345CE00', 'balance', 'f', '账户余额', 't', 'f', 't', 'f', 't', '-', '-', '{tenantid}'); -INSERT INTO "tb_sourcetype" ("sourcetype_id", "sourcetype", "checkable", "paydesc", "enable", "charge_enable", -"consume_enable", "anonymous_enable", "reversable", "pay_subjno","deposite_subjno", "tenantid") -VALUES ('F0CA47ADC0F24DFCA0D95DF4136CC2D0', 'thirdpart', 'f', '其他第三方支付', 't', 't', 'f', 'f', 'f','-','-', '{tenantid}'); -INSERT INTO "tb_sourcetype" ("sourcetype_id", "sourcetype", "checkable", "paydesc", "enable", "charge_enable", -"consume_enable", "anonymous_enable", "reversable", "pay_subjno","deposite_subjno","tenantid") -VALUES ('F5B344726FA24BD896E70DEE3D3F46CA', 'swyktv5', 't', '一卡通支付', 't', 't', 't', 't', 't','-','-', '{tenantid}'); -INSERT INTO "tb_sourcetype" ("sourcetype_id", "sourcetype", "checkable", "paydesc", "enable", "charge_enable", -"consume_enable", "anonymous_enable", "reversable", "pay_subjno","deposite_subjno","tenantid") -VALUES ('28EE54CD3B044CC197D6C5B0E309F8B8', 'alipay', 't', '支付宝', 't', 't', 't', 't', 'f', '112230','112210', '{tenantid}'); -INSERT INTO "tb_sourcetype" ("sourcetype_id", "sourcetype", "checkable", "paydesc", "enable", "charge_enable", -"consume_enable", "anonymous_enable", "reversable", "pay_subjno","deposite_subjno","tenantid") -VALUES ('DAEF88B54B684347B2B83940C38C7671', 'wechat', 't', '微信支付', 't', 't', 't', 't', 'f', '112231','112211', '{tenantid}'); +INSERT INTO "tb_sourcetype" ("sourcetype_id", "sourcetype", "checkable", "paydesc", "enable", "charge_enable", "consume_enable", "anonymous_enable", "reversable", "pay_subjno", "deposite_subjno", "tplusn", "start_chktime", "tenantid") +VALUES ('D3820D49DACA49199E36537F6719665F', 'citizenCard', 't', '大理市民卡', 't', 'f', 't', 'f', 't', '112234', '-', 1, null, '{tenantid}'); +INSERT INTO "tb_sourcetype" ("sourcetype_id", "sourcetype", "checkable", "paydesc", "enable", "charge_enable", "consume_enable", "anonymous_enable", "reversable", "pay_subjno", "deposite_subjno", "tplusn", "start_chktime", "tenantid") +VALUES ('0997477F40904AD1A2E37FD15345CE00', 'balance', 'f', '账户余额', 't', 'f', 't', 'f', 't', '-', '-', 0, null, '{tenantid}'); +INSERT INTO "tb_sourcetype" ("sourcetype_id", "sourcetype", "checkable", "paydesc", "enable", "charge_enable", "consume_enable", "anonymous_enable", "reversable", "pay_subjno", "deposite_subjno", "tplusn", "start_chktime", "tenantid") +VALUES ('F0CA47ADC0F24DFCA0D95DF4136CC2D0', 'thirdpart', 'f', '其他第三方支付', 't', 't', 'f', 'f', 'f','-','-', 0, null, '{tenantid}'); +INSERT INTO "tb_sourcetype" ("sourcetype_id", "sourcetype", "checkable", "paydesc", "enable", "charge_enable", "consume_enable", "anonymous_enable", "reversable", "pay_subjno", "deposite_subjno", "tplusn", "start_chktime", "tenantid") +VALUES ('F5B344726FA24BD896E70DEE3D3F46CA', 'swyktv5', 't', '一卡通支付', 't', 't', 't', 't', 't','-','-', 1, null, '{tenantid}'); +INSERT INTO "tb_sourcetype" ("sourcetype_id", "sourcetype", "checkable", "paydesc", "enable", "charge_enable", "consume_enable", "anonymous_enable", "reversable", "pay_subjno", "deposite_subjno", "tplusn", "start_chktime", "tenantid") +VALUES ('28EE54CD3B044CC197D6C5B0E309F8B8', 'alipay', 't', '支付宝', 't', 't', 't', 't', 'f', '112230','112210', 1, '103000', '{tenantid}'); +INSERT INTO "tb_sourcetype" ("sourcetype_id", "sourcetype", "checkable", "paydesc", "enable", "charge_enable", "consume_enable", "anonymous_enable", "reversable", "pay_subjno", "deposite_subjno", "tplusn", "start_chktime", "tenantid") +VALUES ('DAEF88B54B684347B2B83940C38C7671', 'wechat', 't', '微信支付', 't', 't', 't', 't', 'f', '112231','112211', 1, '103000', '{tenantid}'); -- 支付方式 INSERT INTO TB_SOURCETYPE_CONFIG (ID, SOURCETYPE,CONFIGID,CONFIG_NAME,CONFIG_VALUE,GLOBALFLAG, "tenantid") diff --git a/payapi/src/main/resources/templates/system/thirdchk/chkstatus.html b/payapi/src/main/resources/templates/system/thirdchk/chkstatus.html index 2114a4a7..73f1fb76 100644 --- a/payapi/src/main/resources/templates/system/thirdchk/chkstatus.html +++ b/payapi/src/main/resources/templates/system/thirdchk/chkstatus.html @@ -51,7 +51,7 @@ } }, {field: 'startAccdate', title: '起始日期', width: 110, align: 'center'}, - {field: 'checkFileDate', title: '对账日期', width: 110, align: 'center'}, + {field: 'checkAccdate', title: '对账日期', width: 110, align: 'center'}, { field: 'checkFileOk', title: '下载账单状态', width: 120, align: 'center', templet: function (e) { if (e.checkFileOk) {