新增dou更新授权

This commit is contained in:
启航 2026-01-20 14:34:57 +08:00
parent 08c5783e5c
commit 610b45539b
5 changed files with 91 additions and 2 deletions

View File

@ -98,7 +98,7 @@
<artifactId>open-sdk</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/libs/open-sdk-2.1.8.jar</systemPath>
<systemPath>${project.basedir}/libs/open-sdk-2.1.9.jar</systemPath>
</dependency>
<dependency>

View File

@ -0,0 +1,63 @@
package cn.qihangerp.oms.dou.controller;
import cn.qihangerp.common.AjaxResult;
import cn.qihangerp.common.ResultVoEnum;
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.oms.dou.DouPullRequest;
import cn.qihangerp.open.common.ApiResultVo;
import cn.qihangerp.open.dou.DouTokenApiHelper;
import cn.qihangerp.open.dou.model.Token;
import lombok.AllArgsConstructor;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
@AllArgsConstructor
@RestController
@RequestMapping("/dou/oauth")
public class DouOAuthController {
private final OShopService shopService;
private final OShopPlatformService platformService;
@PostMapping("/update_token")
@ResponseBody
public AjaxResult getToken(@RequestBody DouPullRequest req) {
if(req.getShopId()==null) return AjaxResult.error("缺少参数shopId");
var shop = shopService.getById(req.getShopId());
if (shop == null) {
return AjaxResult.error("没有找到店铺");
}
if (shop.getType() != EnumShopType.DOU.getIndex()) {
return AjaxResult.error(HttpStatus.PARAMS_ERROR, "店铺不是抖店店铺");
}
if (shop.getSellerId() == null || shop.getSellerId()<=0) {
return AjaxResult.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();
}
if (!StringUtils.hasText(appKey)) {
return AjaxResult.error(HttpStatus.PARAMS_ERROR, "店铺配置错误没有找到AppKey");
}
if (!StringUtils.hasText(appSecret)) {
return AjaxResult.error(HttpStatus.PARAMS_ERROR, "店铺配置错误没有找到AppSecret");
}
ApiResultVo<Token> token = DouTokenApiHelper.getToken(appKey, appSecret, shop.getSellerId());
if(token.getCode()!=0) {
return AjaxResult.error(ResultVoEnum.API_FAIL.getIndex(), token.getMsg());
}else{
shopService.updateSessionKey(req.getShopId(), token.getData().getAccessToken());
}
return AjaxResult.success();
}
}

13
vue/src/api/dou/shop.js Normal file
View File

@ -0,0 +1,13 @@
import request from '@/utils/request'
// 更新token
export function updateDouToken(data) {
return request({
url: '/dou/oauth/update_token',
method: 'post',
data: data
})
}

View File

@ -112,7 +112,7 @@
>删除</el-button>
</el-row>
<el-button
v-if="scope.row.type===100 || scope.row.type===200 || scope.row.type===280 || scope.row.type===300"
v-if="scope.row.type===100 || scope.row.type===200 || scope.row.type===280 || scope.row.type===300|| scope.row.type===400"
type="success"
plain
icon="el-icon-refresh"
@ -212,6 +212,7 @@ import { listShop,listPlatform, getShop, delShop, addShop, updateShop } from "@/
import {getJdOAuthUrl, getJdToken} from "@/api/jd/shop";
import {getTaoOAuthUrl,saveSessionKey} from "@/api/tao/shop_api";
import {getPddOAuthUrl,getPddToken} from "@/api/pdd/shop";
import {updateDouToken} from "@/api/dou/shop";
export default {
name: "Shop",
@ -352,6 +353,18 @@ export default {
this.tokenForm.shopId = row.id
this.tokenForm.shopType = row.type
})
}else if(row.type===400){
updateDouToken({shopId:row.id}).then(resp=>{
if(resp.code === 200){
this.$modal.msgSuccess("Token更新成功")
this.getList()
}else{
this.$modal.msgError(resp.msg)
}
})
}else{
this.$modal.msgError('暂时不支持')
}
},