From 6f85eea135d278c2564f88d760ad528f7d4c3cb3 Mon Sep 17 00:00:00 2001 From: yang_shj Date: Tue, 15 Mar 2022 10:27:33 +0800 Subject: [PATCH] =?UTF-8?q?feat=200=20=E6=94=AF=E4=BB=98=E5=B7=A5=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../springcloud/constant/ErrorConstant.java | 29 +++++++------- .../service/imp/MerchantServiceImp.java | 39 ++++++++++++++----- 2 files changed, 46 insertions(+), 22 deletions(-) diff --git a/payment-base-app/src/main/java/com/base/springcloud/constant/ErrorConstant.java b/payment-base-app/src/main/java/com/base/springcloud/constant/ErrorConstant.java index 5999c73..1bfeaad 100644 --- a/payment-base-app/src/main/java/com/base/springcloud/constant/ErrorConstant.java +++ b/payment-base-app/src/main/java/com/base/springcloud/constant/ErrorConstant.java @@ -14,19 +14,22 @@ public enum ErrorConstant { USER_LOCKING("RBS00009","账号已被锁定,请联系管理员!"), TOKEN_EXPIRATION_DATE("RBS00010","TOKEN已失效,请重新登录!"), MERCHANT_CONFIGURE_FAIL("RBS00011","商户支付信息配置失败!"), - USER_DEPART_RELATION_NEED("RBS00012","请用户先关联部门信息!"), - SAVE_PAY_DEPART_CONFIG_FAIL("RBS00013","添加部门商户支付配置信息失败!"), - SALE_BILL_INVALID("RBS00014","无有效销售单据!"), - MERCHANT_PAY_CERT_READ_FAIL("RBS00015","支付证书读取失败!"), - PAY_ORDER_NOT_FOUND("RBS00016","无有效支付订单!"), - ORDER_STATE_NOT_SUPPORT_REFUND("RBS00017","订单状态不支持退款!"), - REGISTER_REFUND_FAIL("RBS00018","退款订单登记失败!"), - SYNC_WEC_REFUND_STATE_FAIL("RBS00019","同步微信退款状态失败!"), - BILL_COMPLETE_PAYMENT("RBS00020","销售单据已完成付款!"), - ALL_BILL_COMPLETE_PAYMENT("RBS00021","所有销售单据已完成付款!"), - MISTAKE_TARGET("RBS00022","要提供的对象不是数组!"), - SUPER_REFUND_ORDER_COUNT_FAL("RBS00023","退款订单次数累计失败!"), - SUPER_PAY_ORDER_COUNT_FAL("RBS00024","支付订单次数累计失败!"); + MERCHANT_CONFIGURE_UPD_FAIL("RBS00012","商户支付信息修改失败!"), + MERCHANT_CONFIGURE_DEL_FAIL("RBS00013","商户支付信息删除失败!"), + MERCHANT_CONFIGURE_INVALID("RBS00014","无效商户支付信息配置修改!"), + USER_DEPART_RELATION_NEED("RBS00015","请用户先关联部门信息!"), + SAVE_PAY_DEPART_CONFIG_FAIL("RBS00016","添加部门商户支付配置信息失败!"), + SALE_BILL_INVALID("RBS00017","无有效销售单据!"), + MERCHANT_PAY_CERT_READ_FAIL("RBS00018","支付证书读取失败!"), + PAY_ORDER_NOT_FOUND("RBS00019","无有效支付订单!"), + ORDER_STATE_NOT_SUPPORT_REFUND("RBS00020","订单状态不支持退款!"), + REGISTER_REFUND_FAIL("RBS00021","退款订单登记失败!"), + SYNC_WEC_REFUND_STATE_FAIL("RBS00022","同步微信退款状态失败!"), + BILL_COMPLETE_PAYMENT("RBS00023","销售单据已完成付款!"), + ALL_BILL_COMPLETE_PAYMENT("RBS00024","所有销售单据已完成付款!"), + MISTAKE_TARGET("RBS00025","要提供的对象不是数组!"), + SUPER_REFUND_ORDER_COUNT_FAL("RBS00026","退款订单次数累计失败!"), + SUPER_PAY_ORDER_COUNT_FAL("RBS00027","支付订单次数累计失败!"); private String code; private String message; diff --git a/payment-base-app/src/main/java/com/base/springcloud/service/imp/MerchantServiceImp.java b/payment-base-app/src/main/java/com/base/springcloud/service/imp/MerchantServiceImp.java index eb71bf7..636814c 100644 --- a/payment-base-app/src/main/java/com/base/springcloud/service/imp/MerchantServiceImp.java +++ b/payment-base-app/src/main/java/com/base/springcloud/service/imp/MerchantServiceImp.java @@ -85,12 +85,14 @@ public class MerchantServiceImp implements MerchantService { public void removeMerchantConfig(String mchId) { // 查询商户支付信息配置记录 MerchantConfig merchantConfig = merchantConfigMapper.claimMerchantConfig(mchId); - // 删除证书文件 - delWecWindow(merchantConfig.getCertPath()); + if(!Optional.ofNullable(merchantConfig).isPresent()) + throw new BusinessException(ErrorConstant.MERCHANT_CONFIGURE_INVALID); + // 删除原证书 + removeCertificate(merchantConfig.getCertPath()); // 删除商户支付信息配置记录 int count = merchantConfigMapper.removeMerchantConfig(mchId); if(count > 0) return; - // TODO 抛业务异常 + throw new BusinessException(ErrorConstant.BILL_AMOUNT_ERR); } /** @@ -99,16 +101,35 @@ public class MerchantServiceImp implements MerchantService { */ @Override public void updateMerchantConfig(MerchantConfigBO merchantConfigBO) { - // 证书上传服务器 - //String certPath = uplodWecWindow(merchantConfigBO.getMchId(),merchantConfigBO.getCertFile()); + String mchId = merchantConfigBO.getMchId(); + if(StringUtils.isBlank(mchId)) + throw new BusinessException(ErrorConstant.NULL_OBJ); + // 查询商户信息 + MerchantConfig merchantConfig = merchantConfigMapper.claimMerchantConfig(mchId); + if(!Optional.ofNullable(merchantConfig).isPresent()) + throw new BusinessException(ErrorConstant.MERCHANT_CONFIGURE_INVALID); + // 删除原证书 + removeCertificate(merchantConfig.getCertPath()); + // 新证书上传服务器 + String certPath = uploadCertificate(merchantConfigBO.getCertFile()); // 商户支付信息保存 - MerchantConfig merchantConfig = new MerchantConfig(); - //merchantConfig.setCertPath(certPath); - BeanUtils.copyProperties(merchantConfigBO,merchantConfig); + MerchantConfig updateConfig = new MerchantConfig(); + BeanUtils.copyProperties(merchantConfigBO,updateConfig); + merchantConfig.setCertPath(certPath); merchantConfig.setUpdateTime(new Date()); int count = merchantConfigMapper.updateMerchantConfig(merchantConfig); if(count > 0) return; - // TODO 抛业务异常 + throw new BusinessException(ErrorConstant.MERCHANT_CONFIGURE_UPD_FAIL); + } + + /** + * 移除原证书 + * @param certPath + */ + private void removeCertificate(String certPath) { + if(StringUtils.isBlank(certPath)) + return; + OssBootUtil.deleteUrl(certPath); } /**