This commit is contained in:
parent
f3eddbcbaf
commit
d12e2b1118
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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<ShopApiParams> 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> token = DouTokenApiHelper.getToken(shop.getAppKey(), shop.getAppSecret(), shop.getSellerId());
|
||||
ApiResultVo<Token> 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<Token> 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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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" }],
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
<!-- <el-table-column type="selection" width="55" align="center" />-->
|
||||
<el-table-column label="ID" align="center" prop="id" width="100"/>
|
||||
<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="回调URL" align="left" prop="redirectUri" />-->
|
||||
<el-table-column label="接口请求URL" align="left" prop="serverUrl" />
|
||||
|
|
@ -25,27 +25,27 @@
|
|||
></el-switch>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<!-- <el-table-column label="描述" align="center" prop="remark" />-->
|
||||
<!-- <el-table-column label="操作" align="center" class-name="small-padding fixed-width">-->
|
||||
<!-- <template slot-scope="scope">-->
|
||||
<el-table-column label="描述" align="center" prop="remark" />
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||
<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-->
|
||||
<!-- v-if="scope.row.id !== 500 && scope.row.id !== 999"-->
|
||||
<!-- size="mini"-->
|
||||
<!-- type="text"-->
|
||||
<!-- icon="el-icon-edit"-->
|
||||
<!-- icon="el-icon-location"-->
|
||||
<!-- @click="handleUpdate(scope.row)"-->
|
||||
<!-- v-hasPermi="['shop:shop:edit']"-->
|
||||
<!-- >设置参数</el-button>-->
|
||||
|
||||
<!--<!– <el-button–>-->
|
||||
<!--<!– size="mini"–>-->
|
||||
<!--<!– type="text"–>-->
|
||||
<!--<!– icon="el-icon-location"–>-->
|
||||
<!--<!– @click="handleUpdate(scope.row)"–>-->
|
||||
<!--<!– v-hasPermi="['shop:shop:edit']"–>-->
|
||||
<!--<!– >省市区地址库</el-button>–>-->
|
||||
<!-- </template>-->
|
||||
<!-- </el-table-column>-->
|
||||
<!-- >省市区地址库</el-button>-->
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<pagination
|
||||
|
|
|
|||
Loading…
Reference in New Issue