2 Комити ee7eb58652 ... ec914c6ee1

Аутор SHA1 Порука Датум
  刘云鑫 ec914c6ee1 Merge remote-tracking branch 'origin/sit' into sit пре 3 недеља
  刘云鑫 03cbf4b22b feat:微信,支付宝,appid пре 3 недеља

+ 16 - 0
alien-entity/src/main/java/shop/alien/entity/store/StorePaymentConfig.java

@@ -134,6 +134,22 @@ public class StorePaymentConfig {
     @TableField("bank_name")
     private String bankName;
 
+    @ApiModelProperty(value = "商家微信 appid")
+    @TableField("store_wechat_id")
+    private String storeWechatId;
+
+    @ApiModelProperty(value = "商家微信名称")
+    @TableField("store_wechat_name")
+    private String storeWechatName;
+
+    @ApiModelProperty(value = "商家支付宝 appid")
+    @TableField("store_ali_id")
+    private String storeAliId;
+
+    @ApiModelProperty(value = "商家支付宝名称")
+    @TableField("store_ali_name")
+    private String storeAliName;
+
     @ApiModelProperty(value = "删除标记, 0:未删除, 1:已删除")
     @TableField("delete_flag")
     @TableLogic

+ 101 - 1
alien-store/src/main/java/shop/alien/store/controller/StorePaymentConfigController.java

@@ -522,6 +522,106 @@ public class StorePaymentConfigController {
     }
 
     @ApiOperationSupport(order = 12)
+    @ApiOperation(value = "设置收款账号-保存商家微信(展示)", notes = "按 store_user_id 新增或更新 store_wechat_id、store_wechat_name(与支付商户微信配置字段不同)")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "storeUserId", value = "店铺用户ID(store_user.id)", dataType = "int", paramType = "form", required = true),
+            @ApiImplicitParam(name = "storeWechatId", value = "商家微信 appid", dataType = "string", paramType = "form", required = true),
+            @ApiImplicitParam(name = "storeWechatName", value = "商家微信名称", dataType = "string", paramType = "form", required = true)
+    })
+    @PostMapping("/saveMerchantWechatByStoreUserId")
+    public R<Integer> saveMerchantWechatByStoreUserId(
+            @RequestParam Integer storeUserId,
+            @RequestParam String storeWechatId,
+            @RequestParam String storeWechatName) {
+        log.info("StorePaymentConfigController.saveMerchantWechatByStoreUserId storeUserId={}", storeUserId);
+        if (storeUserId == null) {
+            return R.fail("店铺用户ID不能为空");
+        }
+        if (storeWechatId == null || storeWechatId.trim().isEmpty()) {
+            return R.fail("商家微信 appid 不能为空");
+        }
+        if (storeWechatName == null || storeWechatName.trim().isEmpty()) {
+            return R.fail("商家微信名称不能为空");
+        }
+        try {
+            StoreUser storeUser = storeUserService.getById(storeUserId);
+            if (storeUser == null) {
+                return R.fail("店铺用户不存在");
+            }
+            StorePaymentConfig config = storePaymentConfigService.getByStoreUserId(storeUserId);
+            if (config == null) {
+                config = new StorePaymentConfig();
+                config.setStoreId(storeUser.getStoreId());
+                config.setStoreUserId(storeUserId);
+                config.setAppId("");
+                fillCreatedUser(config);
+            } else {
+                fillUpdatedUser(config);
+            }
+            config.setStoreWechatId(storeWechatId.trim());
+            config.setStoreWechatName(storeWechatName.trim());
+            boolean ok = config.getId() == null ? storePaymentConfigService.save(config) : storePaymentConfigService.updateById(config);
+            if (!ok) {
+                return R.fail("保存失败");
+            }
+            return R.data(config.getId());
+        } catch (Exception e) {
+            log.error("保存商家微信信息失败 storeUserId={}", storeUserId, e);
+            return R.fail("保存失败:" + e.getMessage());
+        }
+    }
+
+    @ApiOperationSupport(order = 13)
+    @ApiOperation(value = "设置收款账号-保存商家支付宝(展示)", notes = "按 store_user_id 新增或更新 store_ali_id、store_ali_name(与支付宝应用 appId 等支付配置字段不同)")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "storeUserId", value = "店铺用户ID(store_user.id)", dataType = "int", paramType = "form", required = true),
+            @ApiImplicitParam(name = "storeAliId", value = "商家支付宝 appid", dataType = "string", paramType = "form", required = true),
+            @ApiImplicitParam(name = "storeAliName", value = "商家支付宝名称", dataType = "string", paramType = "form", required = true)
+    })
+    @PostMapping("/saveMerchantAlipayByStoreUserId")
+    public R<Integer> saveMerchantAlipayByStoreUserId(
+            @RequestParam Integer storeUserId,
+            @RequestParam String storeAliId,
+            @RequestParam String storeAliName) {
+        log.info("StorePaymentConfigController.saveMerchantAlipayByStoreUserId storeUserId={}", storeUserId);
+        if (storeUserId == null) {
+            return R.fail("店铺用户ID不能为空");
+        }
+        if (storeAliId == null || storeAliId.trim().isEmpty()) {
+            return R.fail("商家支付宝 appid 不能为空");
+        }
+        if (storeAliName == null || storeAliName.trim().isEmpty()) {
+            return R.fail("商家支付宝名称不能为空");
+        }
+        try {
+            StoreUser storeUser = storeUserService.getById(storeUserId);
+            if (storeUser == null) {
+                return R.fail("店铺用户不存在");
+            }
+            StorePaymentConfig config = storePaymentConfigService.getByStoreUserId(storeUserId);
+            if (config == null) {
+                config = new StorePaymentConfig();
+                config.setStoreId(storeUser.getStoreId());
+                config.setStoreUserId(storeUserId);
+                config.setAppId("");
+                fillCreatedUser(config);
+            } else {
+                fillUpdatedUser(config);
+            }
+            config.setStoreAliId(storeAliId.trim());
+            config.setStoreAliName(storeAliName.trim());
+            boolean ok = config.getId() == null ? storePaymentConfigService.save(config) : storePaymentConfigService.updateById(config);
+            if (!ok) {
+                return R.fail("保存失败");
+            }
+            return R.data(config.getId());
+        } catch (Exception e) {
+            log.error("保存商家支付宝信息失败 storeUserId={}", storeUserId, e);
+            return R.fail("保存失败:" + e.getMessage());
+        }
+    }
+
+    @ApiOperationSupport(order = 14)
     @ApiOperation("分页查询支付配置列表")
     @ApiImplicitParams({
             @ApiImplicitParam(name = "page", value = "页码", dataType = "Integer", paramType = "query", defaultValue = "1"),
@@ -546,7 +646,7 @@ public class StorePaymentConfigController {
         }
     }
 
-    @ApiOperationSupport(order = 13)
+    @ApiOperationSupport(order = 15)
     @ApiOperation(value = "新增/更新微信支付配置信息", notes = "按 storeId 查找配置,存在则更新微信字段;不存在则新建一条仅含 storeId 与微信信息的配置。可传表单+两个证书文件(内容存入表)。")
     @ApiImplicitParams({
             @ApiImplicitParam(name = "storeId", value = "店铺ID", dataType = "int", paramType = "form", required = true),