From d12e2b11189a484c634cf0b8bcbf72d6769509ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=AF=E8=88=AA=E8=80=81=E9=BD=90?= <280645618@qq.com> Date: Wed, 1 Oct 2025 16:59:30 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/qihang-erp.sql | 6 ++-- .../cn/qihangerp/api/dou/DouApiCommon.java | 30 +++++++++------- vue/src/views/shop/online_shop.vue | 4 +-- vue/src/views/shop/platform/index.vue | 34 +++++++++---------- 4 files changed, 40 insertions(+), 34 deletions(-) diff --git a/docs/qihang-erp.sql b/docs/qihang-erp.sql index da49b0e6..bcf74f1f 100644 --- a/docs/qihang-erp.sql +++ b/docs/qihang-erp.sql @@ -11,7 +11,7 @@ Target Server Version : 80043 (8.0.43) File Encoding : 65001 - Date: 01/10/2025 16:44:57 + Date: 01/10/2025 16:59:06 */ SET NAMES utf8mb4; @@ -1296,7 +1296,7 @@ CREATE TABLE `o_shop` ( -- ---------------------------- -- Records of o_shop -- ---------------------------- -INSERT INTO `o_shop` VALUES (1007, '抖店测试', 400, NULL, 9, 1, NULL, '4463798', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 1759307372, 1759307261); +INSERT INTO `o_shop` VALUES (1007, '抖店测试', 400, NULL, 9, 1, NULL, '4463798', NULL, NULL, 'c3tzx2q5p41h7zl69zjws9900002noae-11', NULL, NULL, '070t45roa51h7zl69zjws9900002noae-12', NULL, NULL, NULL, NULL, NULL, 0, 1759307372, 1759307261); -- ---------------------------- -- Table structure for o_shop_daily @@ -1396,7 +1396,7 @@ INSERT INTO `o_shop_platform` VALUES (200, '京东POP', 'JD-POP', '', NULL, 'htt INSERT INTO `o_shop_platform` VALUES (300, '拼多多', 'PDD', '', NULL, 'http://www.qihangerp.cn', 'https://gw-api.pinduoduo.com/api/router', 0, 0, 1); INSERT INTO `o_shop_platform` VALUES (400, '抖店', 'DOUDIAN', '7005157746437834253', '8104c8b8-9085-4a80-9248-629759b4f1a3', 'https://www.qihangerp.cn', 'https://openapi-fxg.jinritemai.com/', 0, 0, 1); INSERT INTO `o_shop_platform` VALUES (500, '微信小店', 'WEISHOP', '', NULL, 'http://www.qihangerp.cn', 'https://api.weixin.qq.com', 0, 0, 1); -INSERT INTO `o_shop_platform` VALUES (999, '线下渠道', 'OFFLINE', NULL, NULL, NULL, NULL, 0, 0, NULL); +INSERT INTO `o_shop_platform` VALUES (999, '其他平台', 'OFFLINE', NULL, NULL, NULL, NULL, 0, 0, NULL); -- ---------------------------- -- Table structure for o_shop_pull_lasttime diff --git a/microservices/dou-api/src/main/java/cn/qihangerp/api/dou/DouApiCommon.java b/microservices/dou-api/src/main/java/cn/qihangerp/api/dou/DouApiCommon.java index a7fa3803..5bc513dd 100644 --- a/microservices/dou-api/src/main/java/cn/qihangerp/api/dou/DouApiCommon.java +++ b/microservices/dou-api/src/main/java/cn/qihangerp/api/dou/DouApiCommon.java @@ -6,6 +6,7 @@ import cn.qihangerp.common.api.ShopApiParams; import cn.qihangerp.common.enums.EnumShopType; import cn.qihangerp.common.enums.HttpStatus; import cn.qihangerp.model.entity.OShopPlatform; +import cn.qihangerp.module.service.OShopPlatformService; import cn.qihangerp.module.service.OShopService; import cn.qihangerp.open.common.ApiResultVo; import cn.qihangerp.sdk.dou.DouTokenApiHelper; @@ -18,7 +19,7 @@ import org.springframework.util.StringUtils; @Component public class DouApiCommon { private final OShopService shopService; -// private final OShopPlatformService platformService; + private final OShopPlatformService platformService; /** * 更新前的检查 @@ -30,24 +31,27 @@ public class DouApiCommon { public ResultVo checkBefore(Long shopId) { var shop = shopService.getById(shopId); if (shop == null) { -// return new ApiResult<>(EnumResultVo.ParamsError.getIndex(), "参数错误,没有找到店铺"); return ResultVo.error(HttpStatus.PARAMS_ERROR, "参数错误,没有找到店铺"); } - if (shop.getType() != EnumShopType.DOU.getIndex()) { return ResultVo.error(HttpStatus.PARAMS_ERROR, "参数错误,店铺不是抖店店铺"); } - if (shop.getSellerId() == null || shop.getSellerId()<=0) { return ResultVo.error(HttpStatus.PARAMS_ERROR, "参数错误,请设置抖店平台店铺ID(shopId)"); } + String appKey = shop.getAppKey(); + String appSecret = shop.getAppSecret(); + if(StringUtils.isEmpty(appKey) || StringUtils.isEmpty(appSecret)) { + OShopPlatform platform = platformService.getById(EnumShopType.DOU.getIndex()); + appKey = platform.getAppKey(); + appSecret = platform.getAppSecret(); + } -// OShopPlatform platform = platformService.getById(EnumShopType.DOU.getIndex()); - if (!StringUtils.hasText(shop.getAppKey())) { + if (!StringUtils.hasText(appKey)) { return ResultVo.error(HttpStatus.PARAMS_ERROR, "店铺配置错误,没有找到AppKey"); } - if (!StringUtils.hasText(shop.getAppSecret())) { + if (!StringUtils.hasText(appSecret)) { return ResultVo.error(HttpStatus.PARAMS_ERROR, "店铺配置错误,没有找到AppSecret"); } // if (!StringUtils.hasText(platform.getRedirectUri())) { @@ -62,29 +66,31 @@ public class DouApiCommon { // } ShopApiParams params = new ShopApiParams(); - params.setAppKey(shop.getAppKey()); - params.setAppSecret(shop.getAppSecret()); - params.setAccessToken(shop.getAccessToken()); + params.setAppKey(appKey); + params.setAppSecret(appSecret); params.setRedirectUri(shop.getApiRedirectUrl()); params.setServerUrl(shop.getApiRequestUrl()); params.setSellerId(shop.getSellerId()); + String accessToken = shop.getAccessToken(); if (!StringUtils.hasText(shop.getAccessToken())) { - ApiResultVo token = DouTokenApiHelper.getToken(shop.getAppKey(), shop.getAppSecret(), shop.getSellerId()); + ApiResultVo token = DouTokenApiHelper.getToken(appKey, appSecret, shop.getSellerId()); if(token.getCode()!=0) { return ResultVo.error(ResultVoEnum.API_FAIL.getIndex(), token.getMsg(), params); }else{ shopService.updateSessionKey(shopId,token.getData().getAccessToken(),token.getData().getRefreshToken()); params.setAccessToken(token.getData().getAccessToken()); + accessToken = token.getData().getAccessToken(); } }else{ ApiResultVo token1= DouTokenApiHelper.refreshToken(shop.getAppKey(),shop.getAppSecret(),shop.getAccessToken(),shop.getRefreshToken()); if(token1.getCode()==0){ shopService.updateSessionKey(shopId,token1.getData().getAccessToken(),token1.getData().getRefreshToken()); params.setAccessToken(token1.getData().getAccessToken()); + accessToken = token1.getData().getAccessToken(); } } - + params.setAccessToken(accessToken); return ResultVo.success(HttpStatus.SUCCESS, params); } diff --git a/vue/src/views/shop/online_shop.vue b/vue/src/views/shop/online_shop.vue index 9427a27e..b5d9f79b 100644 --- a/vue/src/views/shop/online_shop.vue +++ b/vue/src/views/shop/online_shop.vue @@ -260,8 +260,8 @@ export default { type: [{ required: true, message: "请选择平台", trigger: "change" }], sellerId: [{ required: true, message: "不能为空", trigger: "change" }], - appKey: [{ required: true, message: "不能为空", trigger: "change" }], - appSecret: [{ required: true, message: "不能为空", trigger: "change" }], + // appKey: [{ required: true, message: "不能为空", trigger: "change" }], + // appSecret: [{ required: true, message: "不能为空", trigger: "change" }], status: [{ required: true, message: "不能为空", trigger: "change" }], } }; diff --git a/vue/src/views/shop/platform/index.vue b/vue/src/views/shop/platform/index.vue index ac0e5f2d..ebac3328 100644 --- a/vue/src/views/shop/platform/index.vue +++ b/vue/src/views/shop/platform/index.vue @@ -11,7 +11,7 @@ - + @@ -25,27 +25,27 @@ > - - - + + + +