This commit is contained in:
启航老齐 2025-10-01 16:59:30 +08:00
parent f3eddbcbaf
commit d12e2b1118
4 changed files with 40 additions and 34 deletions

View File

@ -11,7 +11,7 @@
Target Server Version : 80043 (8.0.43) Target Server Version : 80043 (8.0.43)
File Encoding : 65001 File Encoding : 65001
Date: 01/10/2025 16:44:57 Date: 01/10/2025 16:59:06
*/ */
SET NAMES utf8mb4; SET NAMES utf8mb4;
@ -1296,7 +1296,7 @@ CREATE TABLE `o_shop` (
-- ---------------------------- -- ----------------------------
-- Records of 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 -- 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 (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 (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 (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 -- Table structure for o_shop_pull_lasttime

View File

@ -6,6 +6,7 @@ import cn.qihangerp.common.api.ShopApiParams;
import cn.qihangerp.common.enums.EnumShopType; import cn.qihangerp.common.enums.EnumShopType;
import cn.qihangerp.common.enums.HttpStatus; import cn.qihangerp.common.enums.HttpStatus;
import cn.qihangerp.model.entity.OShopPlatform; import cn.qihangerp.model.entity.OShopPlatform;
import cn.qihangerp.module.service.OShopPlatformService;
import cn.qihangerp.module.service.OShopService; import cn.qihangerp.module.service.OShopService;
import cn.qihangerp.open.common.ApiResultVo; import cn.qihangerp.open.common.ApiResultVo;
import cn.qihangerp.sdk.dou.DouTokenApiHelper; import cn.qihangerp.sdk.dou.DouTokenApiHelper;
@ -18,7 +19,7 @@ import org.springframework.util.StringUtils;
@Component @Component
public class DouApiCommon { public class DouApiCommon {
private final OShopService shopService; private final OShopService shopService;
// private final OShopPlatformService platformService; private final OShopPlatformService platformService;
/** /**
* 更新前的检查 * 更新前的检查
@ -30,24 +31,27 @@ public class DouApiCommon {
public ResultVo<ShopApiParams> checkBefore(Long shopId) { public ResultVo<ShopApiParams> checkBefore(Long shopId) {
var shop = shopService.getById(shopId); var shop = shopService.getById(shopId);
if (shop == null) { if (shop == null) {
// return new ApiResult<>(EnumResultVo.ParamsError.getIndex(), "参数错误,没有找到店铺");
return ResultVo.error(HttpStatus.PARAMS_ERROR, "参数错误,没有找到店铺"); return ResultVo.error(HttpStatus.PARAMS_ERROR, "参数错误,没有找到店铺");
} }
if (shop.getType() != EnumShopType.DOU.getIndex()) { if (shop.getType() != EnumShopType.DOU.getIndex()) {
return ResultVo.error(HttpStatus.PARAMS_ERROR, "参数错误,店铺不是抖店店铺"); return ResultVo.error(HttpStatus.PARAMS_ERROR, "参数错误,店铺不是抖店店铺");
} }
if (shop.getSellerId() == null || shop.getSellerId()<=0) { if (shop.getSellerId() == null || shop.getSellerId()<=0) {
return ResultVo.error(HttpStatus.PARAMS_ERROR, "参数错误请设置抖店平台店铺IDshopId"); return ResultVo.error(HttpStatus.PARAMS_ERROR, "参数错误请设置抖店平台店铺IDshopId");
} }
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"); return ResultVo.error(HttpStatus.PARAMS_ERROR, "店铺配置错误没有找到AppKey");
} }
if (!StringUtils.hasText(shop.getAppSecret())) { if (!StringUtils.hasText(appSecret)) {
return ResultVo.error(HttpStatus.PARAMS_ERROR, "店铺配置错误没有找到AppSecret"); return ResultVo.error(HttpStatus.PARAMS_ERROR, "店铺配置错误没有找到AppSecret");
} }
// if (!StringUtils.hasText(platform.getRedirectUri())) { // if (!StringUtils.hasText(platform.getRedirectUri())) {
@ -62,29 +66,31 @@ public class DouApiCommon {
// } // }
ShopApiParams params = new ShopApiParams(); ShopApiParams params = new ShopApiParams();
params.setAppKey(shop.getAppKey()); params.setAppKey(appKey);
params.setAppSecret(shop.getAppSecret()); params.setAppSecret(appSecret);
params.setAccessToken(shop.getAccessToken());
params.setRedirectUri(shop.getApiRedirectUrl()); params.setRedirectUri(shop.getApiRedirectUrl());
params.setServerUrl(shop.getApiRequestUrl()); params.setServerUrl(shop.getApiRequestUrl());
params.setSellerId(shop.getSellerId()); params.setSellerId(shop.getSellerId());
String accessToken = shop.getAccessToken();
if (!StringUtils.hasText(shop.getAccessToken())) { if (!StringUtils.hasText(shop.getAccessToken())) {
ApiResultVo<Token> token = DouTokenApiHelper.getToken(shop.getAppKey(), shop.getAppSecret(), shop.getSellerId()); ApiResultVo<Token> token = DouTokenApiHelper.getToken(appKey, appSecret, shop.getSellerId());
if(token.getCode()!=0) { if(token.getCode()!=0) {
return ResultVo.error(ResultVoEnum.API_FAIL.getIndex(), token.getMsg(), params); return ResultVo.error(ResultVoEnum.API_FAIL.getIndex(), token.getMsg(), params);
}else{ }else{
shopService.updateSessionKey(shopId,token.getData().getAccessToken(),token.getData().getRefreshToken()); shopService.updateSessionKey(shopId,token.getData().getAccessToken(),token.getData().getRefreshToken());
params.setAccessToken(token.getData().getAccessToken()); params.setAccessToken(token.getData().getAccessToken());
accessToken = token.getData().getAccessToken();
} }
}else{ }else{
ApiResultVo<Token> token1= DouTokenApiHelper.refreshToken(shop.getAppKey(),shop.getAppSecret(),shop.getAccessToken(),shop.getRefreshToken()); ApiResultVo<Token> token1= DouTokenApiHelper.refreshToken(shop.getAppKey(),shop.getAppSecret(),shop.getAccessToken(),shop.getRefreshToken());
if(token1.getCode()==0){ if(token1.getCode()==0){
shopService.updateSessionKey(shopId,token1.getData().getAccessToken(),token1.getData().getRefreshToken()); shopService.updateSessionKey(shopId,token1.getData().getAccessToken(),token1.getData().getRefreshToken());
params.setAccessToken(token1.getData().getAccessToken()); params.setAccessToken(token1.getData().getAccessToken());
accessToken = token1.getData().getAccessToken();
} }
} }
params.setAccessToken(accessToken);
return ResultVo.success(HttpStatus.SUCCESS, params); return ResultVo.success(HttpStatus.SUCCESS, params);
} }

View File

@ -260,8 +260,8 @@ export default {
type: [{ required: true, message: "请选择平台", trigger: "change" }], type: [{ required: true, message: "请选择平台", trigger: "change" }],
sellerId: [{ required: true, message: "不能为空", trigger: "change" }], sellerId: [{ required: true, message: "不能为空", trigger: "change" }],
appKey: [{ required: true, message: "不能为空", trigger: "change" }], // appKey: [{ required: true, message: "", trigger: "change" }],
appSecret: [{ required: true, message: "不能为空", trigger: "change" }], // appSecret: [{ required: true, message: "", trigger: "change" }],
status: [{ required: true, message: "不能为空", trigger: "change" }], status: [{ required: true, message: "不能为空", trigger: "change" }],
} }
}; };

View File

@ -11,7 +11,7 @@
<!-- <el-table-column type="selection" width="55" align="center" />--> <!-- <el-table-column type="selection" width="55" align="center" />-->
<el-table-column label="ID" align="center" prop="id" width="100"/> <el-table-column label="ID" align="center" prop="id" width="100"/>
<el-table-column label="平台" align="left" prop="name" /> <el-table-column label="平台" align="left" prop="name" />
<!-- <el-table-column label="AppKey" align="left" prop="appKey" />--> <el-table-column label="AppKey" align="left" prop="appKey" />
<!-- <el-table-column label="AppSecret" align="left" prop="appSecret" />--> <!-- <el-table-column label="AppSecret" align="left" prop="appSecret" />-->
<!-- <el-table-column label="回调URL" align="left" prop="redirectUri" />--> <!-- <el-table-column label="回调URL" align="left" prop="redirectUri" />-->
<el-table-column label="接口请求URL" align="left" prop="serverUrl" /> <el-table-column label="接口请求URL" align="left" prop="serverUrl" />
@ -25,27 +25,27 @@
></el-switch> ></el-switch>
</template> </template>
</el-table-column> </el-table-column>
<!-- <el-table-column label="描述" align="center" prop="remark" />--> <el-table-column label="描述" align="center" prop="remark" />
<!-- <el-table-column label="操作" align="center" class-name="small-padding fixed-width">--> <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<!-- <template slot-scope="scope">--> <template slot-scope="scope">
<el-button
v-if="scope.row.id !== 500 && scope.row.id !== 999"
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['shop:shop:edit']"
>设置参数</el-button>
<!-- <el-button--> <!-- <el-button-->
<!-- v-if="scope.row.id !== 500 && scope.row.id !== 999"-->
<!-- size="mini"--> <!-- size="mini"-->
<!-- type="text"--> <!-- type="text"-->
<!-- icon="el-icon-edit"--> <!-- icon="el-icon-location"-->
<!-- @click="handleUpdate(scope.row)"--> <!-- @click="handleUpdate(scope.row)"-->
<!-- v-hasPermi="['shop:shop:edit']"--> <!-- v-hasPermi="['shop:shop:edit']"-->
<!-- >设置参数</el-button>--> <!-- >省市区地址库</el-button>-->
</template>
<!--&lt;!&ndash; <el-button&ndash;&gt;--> </el-table-column>
<!--&lt;!&ndash; size="mini"&ndash;&gt;-->
<!--&lt;!&ndash; type="text"&ndash;&gt;-->
<!--&lt;!&ndash; icon="el-icon-location"&ndash;&gt;-->
<!--&lt;!&ndash; @click="handleUpdate(scope.row)"&ndash;&gt;-->
<!--&lt;!&ndash; v-hasPermi="['shop:shop:edit']"&ndash;&gt;-->
<!--&lt;!&ndash; >省市区地址库</el-button>&ndash;&gt;-->
<!-- </template>-->
<!-- </el-table-column>-->
</el-table> </el-table>
<pagination <pagination