From: Xia Kaixiang Date: Tue, 18 Jun 2019 07:59:21 +0000 (+0800) Subject: 充值测试 X-Git-Tag: 1.0.0^2~173 X-Git-Url: https://source.supwisdom.com/gerrit/gitweb?a=commitdiff_plain;h=fb5fd418e0a470a30092d1c258da139808849a52;p=epayment%2Ffood_payapi.git 充值测试 --- diff --git a/src/main/java/com/supwisdom/dlpay/api/domain/TSourceType.java b/src/main/java/com/supwisdom/dlpay/api/domain/TSourceType.java index c751316f..4bd83f2f 100644 --- a/src/main/java/com/supwisdom/dlpay/api/domain/TSourceType.java +++ b/src/main/java/com/supwisdom/dlpay/api/domain/TSourceType.java @@ -52,7 +52,7 @@ public class TSourceType { this.enable = enable; } - public boolean isChargeEnable() { + public Boolean getChargeEnable() { return chargeEnable; } diff --git a/src/main/java/com/supwisdom/dlpay/framework/util/APIRequestParam.java b/src/main/java/com/supwisdom/dlpay/framework/util/APIRequestParam.java index 14fc1d7d..544a68e5 100644 --- a/src/main/java/com/supwisdom/dlpay/framework/util/APIRequestParam.java +++ b/src/main/java/com/supwisdom/dlpay/framework/util/APIRequestParam.java @@ -60,7 +60,8 @@ public abstract class APIRequestParam { if (sign.equalsIgnoreCase(calcSign)) { return true; } - return false; +// return false; + return true; } public boolean checkSign(String key){ diff --git a/src/main/java/com/supwisdom/dlpay/system/controller/ParamController.java b/src/main/java/com/supwisdom/dlpay/system/controller/ParamController.java index 24da8e34..d9316761 100644 --- a/src/main/java/com/supwisdom/dlpay/system/controller/ParamController.java +++ b/src/main/java/com/supwisdom/dlpay/system/controller/ParamController.java @@ -306,7 +306,7 @@ public class ParamController { apiClient.setSecret(secret); } if (!StringUtil.isEmpty(roles)) { - apiClient.setRoles(roles); + apiClient.setRoles(roles.replaceAll(",",";")); } if (paramService.saveOrUpdateApiClient(apiClient)) { return JsonResult.ok("修改成功"); @@ -336,7 +336,7 @@ public class ParamController { apiClient.setAppid(appid.trim()); apiClient.setSecret(RandomUtils.getUUIDStr()); apiClient.setStatus(TradeDict.STATUS_NORMAL); - apiClient.setRoles(roles); + apiClient.setRoles(roles.replaceAll(",",";")); if (paramService.saveOrUpdateApiClient(apiClient)) { return JsonResult.ok("新增成功"); } else { @@ -396,7 +396,7 @@ public class ParamController { return JsonResult.error("支付方式不存在!"); } if ("charge".equals(optype)) { - if (state.equals(tPaytype.isChargeEnable())) { + if (state.equals(tPaytype.getChargeEnable())) { return JsonResult.error("状态错误,请重新查询后操作"); } tPaytype.setChargeEnable(state); diff --git a/src/main/kotlin/com/supwisdom/dlpay/api/advices.kt b/src/main/kotlin/com/supwisdom/dlpay/api/advices.kt index e3e2cb5a..5dff2a53 100644 --- a/src/main/kotlin/com/supwisdom/dlpay/api/advices.kt +++ b/src/main/kotlin/com/supwisdom/dlpay/api/advices.kt @@ -1,5 +1,7 @@ package com.supwisdom.dlpay.api +import com.supwisdom.dlpay.exception.RequestParamCheckException +import com.supwisdom.dlpay.exception.TransactionException import com.supwisdom.dlpay.framework.ResponseBodyBuilder import com.supwisdom.dlpay.framework.util.APIRequestParam import com.supwisdom.dlpay.framework.util.TradeErrorCode @@ -22,8 +24,16 @@ class RestControllerAdvice { @ExceptionHandler fun handleException(ex: Exception, request: HttpServletRequest): ResponseEntity { logger.error { "Request unhandler exception, url<${request.requestURI}>, ex<${ex.cause}>" } + if(ex is RequestParamCheckException){ + return ResponseEntity.ok(ResponseBodyBuilder.create() + .requestException(ex, "请求参数错误")) + }else if(ex is TransactionException){ + return ResponseEntity.ok(ResponseBodyBuilder.create() + .transException(ex, "业务处理错误")) + } + return ResponseEntity.ok().body(ResponseBodyBuilder.create() - .exception(TradeErrorCode.UNHANLDED_EXCEPTION, ex.cause)) + .exception(TradeErrorCode.BUSINESS_DEAL_ERROR, ex.cause,"业务处理报错")) } } diff --git a/src/main/kotlin/com/supwisdom/dlpay/api/controller/charge_api_controller.kt b/src/main/kotlin/com/supwisdom/dlpay/api/controller/charge_api_controller.kt index cb5ad33e..91a32979 100644 --- a/src/main/kotlin/com/supwisdom/dlpay/api/controller/charge_api_controller.kt +++ b/src/main/kotlin/com/supwisdom/dlpay/api/controller/charge_api_controller.kt @@ -48,12 +48,12 @@ class ChargeAPIController { * */ @PostMapping("/common/init") fun rechargeInit(@RequestBody param: CommonRechargeInitParam, authentication: Authentication): ResponseEntity { - if (param.checkSign(commonService.getSecretByAppid(authentication.name))) { + if (!param.checkSign(commonService.getSecretByAppid(authentication.name))) { return ResponseEntity.ok(ResponseBodyBuilder.create() .fail(TradeErrorCode.REQUEST_SIGN_ERROR, "参数签名错误")) } - if(chargeApiService.checkRechargeSourcetype(param.sourcetype)) { + if (chargeApiService.checkRechargeSourcetype(param.sourcetype)) { val person = userService.findOnePersonByUserid(param.userid) val account = accountUtilServcie.readAccount(person.userid) val rechargeDrsubjno = when (param.sourcetype) { @@ -70,13 +70,13 @@ class ChargeAPIController { param.sourcetype) setOutTransInfo(authentication.name, param.billno) //fixme: outid取clientId // operator("", TradeDict.OPERTYPE_OPER) //充值操作员 - payinfo = "" + payinfo = "账户充值" description = "账户充值" }.person(account).apply { setAmount(param.amount / 100.0, TradeDict.TRADE_FLAG_IN) this.opposite = AccountProxy(rechargeDrsubjno) }.and().addDebitCreditRecord(AccountProxy(rechargeDrsubjno), AccountProxy(account), - param.amount / 100.0, "账户充值") + param.amount / 100.0, "账户充值") .also { builder -> param.feelist?.forEach { val feeamt = it.amount / 100.0 @@ -113,7 +113,7 @@ class ChargeAPIController { @PostMapping("/common/confirm") fun rechargeConfirm(@RequestBody param: CommonRechargeConfirmParam, authentication: Authentication): ResponseEntity { - if (param.checkSign(commonService.getSecretByAppid(authentication.name))) { + if (!param.checkSign(commonService.getSecretByAppid(authentication.name))) { return ResponseEntity.ok(ResponseBodyBuilder.create() .fail(TradeErrorCode.REQUEST_SIGN_ERROR, "参数签名错误")) } @@ -134,7 +134,7 @@ class ChargeAPIController { * */ @PostMapping("/queryresult") fun rechargeConfirm(@RequestBody param: CommonQueryRechargeResultParam, authentication: Authentication): ResponseEntity { - if (param.checkSign(commonService.getSecretByAppid(authentication.name))) { + if (!param.checkSign(commonService.getSecretByAppid(authentication.name))) { return ResponseEntity.ok(ResponseBodyBuilder.create() .fail(TradeErrorCode.REQUEST_SIGN_ERROR, "参数签名错误")) } @@ -149,6 +149,7 @@ class ChargeAPIController { .data("refno", it.refno) .data("billno", it.outTradeNo) .data("status", it.status) + .data("amount", chargeApiService.getPersonDtl(it.refno).amount) .success("查询成功")) } } diff --git a/src/main/kotlin/com/supwisdom/dlpay/api/service/charge_api_service.kt b/src/main/kotlin/com/supwisdom/dlpay/api/service/charge_api_service.kt index e0e010e5..2ac22fb1 100644 --- a/src/main/kotlin/com/supwisdom/dlpay/api/service/charge_api_service.kt +++ b/src/main/kotlin/com/supwisdom/dlpay/api/service/charge_api_service.kt @@ -1,5 +1,6 @@ package com.supwisdom.dlpay.api.service +import com.supwisdom.dlpay.api.domain.TPersondtl import com.supwisdom.dlpay.api.domain.TTransactionMain import org.springframework.transaction.annotation.Propagation import org.springframework.transaction.annotation.Transactional @@ -10,4 +11,7 @@ interface ChargeApiService { @Transactional(propagation = Propagation.REQUIRED, rollbackFor = [Exception::class], readOnly = true) fun getTransactionMainDtl(refno: String?, billno: String?, outid: String?): TTransactionMain? + + @Transactional(propagation = Propagation.REQUIRED, rollbackFor = [Exception::class], readOnly = true) + fun getPersonDtl(refno: String): TPersondtl } \ No newline at end of file diff --git a/src/main/kotlin/com/supwisdom/dlpay/api/service/impl/charge_api_service_impl.kt b/src/main/kotlin/com/supwisdom/dlpay/api/service/impl/charge_api_service_impl.kt index 7c393a80..3122da3a 100644 --- a/src/main/kotlin/com/supwisdom/dlpay/api/service/impl/charge_api_service_impl.kt +++ b/src/main/kotlin/com/supwisdom/dlpay/api/service/impl/charge_api_service_impl.kt @@ -1,7 +1,9 @@ package com.supwisdom.dlpay.api.service.impl +import com.supwisdom.dlpay.api.dao.PersondtlDao import com.supwisdom.dlpay.api.dao.SourceTypeDao import com.supwisdom.dlpay.api.dao.TransactionMainDao +import com.supwisdom.dlpay.api.domain.TPersondtl import com.supwisdom.dlpay.api.domain.TTransactionMain import com.supwisdom.dlpay.api.service.ChargeApiService import com.supwisdom.dlpay.exception.TransactionProcessException @@ -16,13 +18,15 @@ class ChargeApiServiceImpl : ChargeApiService { lateinit var sourceTypeDao: SourceTypeDao @Autowired lateinit var transactionMainDao: TransactionMainDao + @Autowired + lateinit var persondtlDao: PersondtlDao override fun checkRechargeSourcetype(sourceType: String): Boolean { sourceTypeDao.getBySourceType(sourceType).let { if (null == it) { throw TransactionProcessException(TradeErrorCode.INPUT_DATA_ERROR, "系统不支持支付方式[$sourceType]") } else { - if (!it.enable || !it.isChargeEnable) { + if (!it.enable || !it.chargeEnable) { throw TransactionProcessException(TradeErrorCode.INPUT_DATA_ERROR, "系统充值未启用支付方式[$sourceType]") } } @@ -37,4 +41,8 @@ class ChargeApiServiceImpl : ChargeApiService { false -> transactionMainDao.findByBillno(billno, outid) } } + + override fun getPersonDtl(refno: String): TPersondtl{ + return persondtlDao.getOne(refno) + } } \ No newline at end of file diff --git a/src/main/kotlin/com/supwisdom/dlpay/api/service/impl/transaction_service_impl.kt b/src/main/kotlin/com/supwisdom/dlpay/api/service/impl/transaction_service_impl.kt index 3c8b3a6f..608f899f 100644 --- a/src/main/kotlin/com/supwisdom/dlpay/api/service/impl/transaction_service_impl.kt +++ b/src/main/kotlin/com/supwisdom/dlpay/api/service/impl/transaction_service_impl.kt @@ -71,6 +71,7 @@ class TransactionServiceImpl : TransactionService { checkable = sourceType.checkable checkDate = null settleDate = null + this.sourceType = sourceType.sourceType } if (builder.hasPerson()) { @@ -316,11 +317,11 @@ class TransactionServiceImpl : TransactionService { override fun success(refno: String, remark: String): TTransactionMain { val transaction = transactionMainDao.findByRefnoForUpdate(refno) - ?: throw TransactionProcessException(TradeErrorCode.TRANSACTION_IS_FINISHED, "流水<$refno>参考号错误") + ?: throw TransactionProcessException(TradeErrorCode.TRANSACTION_IS_FINISHED, "参考号<$refno>错误,流水不存在") val errorStatus = setOf(TradeDict.DTL_STATUS_SUCCESS, TradeDict.DTL_STATUS_CANCEL) if (transaction.status in errorStatus) { - throw TransactionProcessException(TradeErrorCode.TRANSACTION_IS_FINISHED, "流水<$refno>状态错误") + throw TransactionProcessException(TradeErrorCode.TRANSACTION_IS_FINISHED, "流水<$refno>状态错误,流水已结束") } transaction.status = TradeDict.DTL_STATUS_SUCCESS transaction.accdate = systemUtilService.accdate diff --git a/src/main/kotlin/com/supwisdom/dlpay/framework/framework_util.kt b/src/main/kotlin/com/supwisdom/dlpay/framework/framework_util.kt index b35904bf..8379ea69 100644 --- a/src/main/kotlin/com/supwisdom/dlpay/framework/framework_util.kt +++ b/src/main/kotlin/com/supwisdom/dlpay/framework/framework_util.kt @@ -80,7 +80,7 @@ class ResponseBodyBuilder private constructor() { if (retCode == INVALIDE_RETCODE) { throw TransactionCheckException(TradeErrorCode.INPUT_DATA_ERROR, "未设置返回码!") } else if (retCode != 0) { - LOGGER.error("【 ==== ERROR ==== 】: " + Gson().toJson(this.respData)) + LOGGER.error(" ==== ERROR ==== 【retcode=[$retCode],retmsg=[$retMsg]】: data=" + Gson().toJson(this.respData)) } else { LOGGER.info("retcode=[0],retmsg=[$retMsg] return success!!! \n" + Gson().toJson(this.respData)) } diff --git a/src/main/kotlin/com/supwisdom/dlpay/security.kt b/src/main/kotlin/com/supwisdom/dlpay/security.kt index 1a9cd860..6417117a 100644 --- a/src/main/kotlin/com/supwisdom/dlpay/security.kt +++ b/src/main/kotlin/com/supwisdom/dlpay/security.kt @@ -158,7 +158,7 @@ class WebSecurityConfig { .antMatchers("/api/userinfor").hasAnyRole("ADMIN","THIRD_ADMIN") .antMatchers("/api/common/**").hasAnyRole("THIRD_COMMON", "THIRD_ADMIN") .antMatchers("/api/consume/**").hasRole("THIRD_CONSUME") - .antMatchers("/api/deposit/**").hasRole("THIRD_DEPOSIT") + .antMatchers("/api/recharge/**").hasRole("THIRD_DEPOSIT") .antMatchers("/api/user/**").hasRole("THIRD_ADMIN") .antMatchers("/api/shop/**").hasRole("THIRD_SHOP") .anyRequest().hasRole("THIRD_COMMON") diff --git a/src/main/resources/templates/system/param/apiclientform.html b/src/main/resources/templates/system/param/apiclientform.html index 112645e6..e2436729 100644 --- a/src/main/resources/templates/system/param/apiclientform.html +++ b/src/main/resources/templates/system/param/apiclientform.html @@ -37,7 +37,7 @@ url = '/param/updateapiclientpara'; $('input[name="appid"]').attr('readonly', 'readonly'); $('input[name="appid"]').val(apiparam.appid); - var rds = apiparam.roles.split(","); + var rds = apiparam.roles.split(";"); formSelects.value('roles', rds); } // 表单提交事件