Переглянути джерело

feat : 接口对接修改

bilingfeng 2 роки тому
батько
коміт
5fe509f2f8

+ 8 - 0
game-module/game-manage/src/main/java/com/zanxiang/manage/controller/PayMerchantController.java

@@ -59,4 +59,12 @@ public class PayMerchantController {
     public ResultVO<Boolean> statusUpdate(@RequestParam Long id, @RequestParam Integer status) {
         return new ResultVO<>(payMerchantService.statusUpdate(id, status));
     }
+
+    @ApiOperation(value = "商户密钥变更")
+    @PatchMapping(value = "/secret/key/update")
+    @PreAuthorize(permissionKey = "manage:payMerchant:secretKeyUpdate")
+    @ApiResponses(value = {@ApiResponse(code = 200, message = "成功", response = Boolean.class)})
+    public ResultVO<Boolean> secretKeyUpdate(@RequestParam Long id, @RequestParam String secretKey) {
+        return new ResultVO<>(payMerchantService.secretKeyUpdate(id, secretKey));
+    }
 }

+ 9 - 0
game-module/game-manage/src/main/java/com/zanxiang/manage/service/IPayMerchantService.java

@@ -49,6 +49,15 @@ public interface IPayMerchantService extends IService<PayMerchant> {
      */
     boolean statusUpdate(Long id, Integer status);
 
+    /**
+     * 密钥更新
+     *
+     * @param id        id
+     * @param secretKey 秘密密钥
+     * @return boolean
+     */
+    boolean secretKeyUpdate(Long id, String secretKey);
+
     /**
      * 删除通过id
      *

+ 23 - 0
game-module/game-manage/src/main/java/com/zanxiang/manage/service/impl/PayMerchantServiceImpl.java

@@ -189,6 +189,29 @@ public class PayMerchantServiceImpl extends ServiceImpl<PayMerchantMapper, PayMe
                 .eq(PayMerchant::getId, id));
     }
 
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public boolean secretKeyUpdate(Long id, String secretKey) {
+        PayMerchant payMerchant = super.getById(id);
+        if (payMerchant == null) {
+            throw new BaseException("参数错误, 商户信息不存在");
+        }
+        Map<String, String> configMap = new HashMap<>(4);
+        if (Objects.equals(payMerchant.getPayWayId().intValue(), PayWayEnum.ALI_PAY.getPayWayId())) {
+            configMap.put("protocol", "https");
+            configMap.put("gatewayHost", "openapi.alipay.com");
+            configMap.put("signType", "RSA2");
+            configMap.put("alipayPublicKey", secretKey);
+        }
+        if (Objects.equals(payMerchant.getPayWayId().intValue(), PayWayEnum.WX_PAY.getPayWayId())) {
+            configMap.put("mchId", payMerchant.getMerchantNo());
+            configMap.put("apiKey", secretKey);
+            configMap.put("signType", "MD5");
+        }
+        payMerchant.setPayConfig(JsonUtil.toString(configMap));
+        return super.updateById(payMerchant);
+    }
+
     @Override
     @Transactional(rollbackFor = Exception.class)
     public boolean deleteById(Long id) {