添加视频号商铺拉取、关联

This commit is contained in:
启航 2024-06-11 15:25:44 +08:00
parent b145e7e082
commit bcd29a614e
18 changed files with 282 additions and 86 deletions

View File

@ -32,7 +32,7 @@ public class GoodsApiController {
private final WeiApiCommon apiCommon;
private final WeiGoodsService weiGoodsService;
@RequestMapping(value = "/pull_list", method = RequestMethod.POST)
@RequestMapping(value = "/pull_goods_list", method = RequestMethod.POST)
public AjaxResult pullList(@RequestBody PullRequest params) throws Exception {
if (params.getShopId() == null || params.getShopId() <= 0) {
// return ApiResul new ApiResult(HttpStatus.PARAMS_ERROR, "参数错误没有店铺Id");

View File

@ -0,0 +1,45 @@
package com.qihang.wei.controller;
import com.qihang.common.bo.LinkErpGoodsSkuBo;
import com.qihang.common.common.AjaxResult;
import com.qihang.common.common.PageQuery;
import com.qihang.common.common.PageResult;
import com.qihang.common.common.TableDataInfo;
import com.qihang.security.common.BaseController;
import com.qihang.wei.domain.OmsWeiGoodsSku;
import com.qihang.wei.service.OmsWeiGoodsSkuService;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
@RequestMapping("/goods")
@RestController
@AllArgsConstructor
public class GoodsController extends BaseController {
private final OmsWeiGoodsSkuService skuService;
@RequestMapping(value = "/skuList", method = RequestMethod.GET)
public TableDataInfo skuList(OmsWeiGoodsSku bo, PageQuery pageQuery) {
PageResult<OmsWeiGoodsSku> result = skuService.queryPageList(bo, pageQuery);
return getDataTable(result);
}
/**
*
*/
@GetMapping(value = "/sku/{id}")
public AjaxResult getSkuInfo(@PathVariable("id") Long id)
{
return AjaxResult.success(skuService.getById(id));
}
@PostMapping(value = "/sku/linkErp")
public AjaxResult linkErp(@RequestBody LinkErpGoodsSkuBo bo)
{
OmsWeiGoodsSku sku = new OmsWeiGoodsSku();
sku.setId(bo.getId());
sku.setErpGoodsSkuId(Long.parseLong(bo.getErpGoodsSkuId()));
skuService.updateById(sku);
return success();
}
}

View File

@ -8,6 +8,7 @@ import cn.qihangerp.open.wei.vo.Token;
import com.qihang.common.common.ResultVo;
import com.qihang.common.enums.EnumShopType;
import com.qihang.common.enums.HttpStatus;
import com.qihang.wei.service.SShopPlatformService;
import com.qihang.wei.service.SShopService;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Component;
@ -17,6 +18,7 @@ import org.springframework.util.StringUtils;
@Component
public class WeiApiCommon {
private final SShopService shopService;
private final SShopPlatformService platformService;
/**
* 更新前的检查
*
@ -29,27 +31,26 @@ public class WeiApiCommon {
if (shop == null) {
return ResultVo.error(HttpStatus.PARAMS_ERROR,"参数错误,没有找到店铺");
}
if (shop.getType() != EnumShopType.WEI.getIndex()) {
if (shop.getPlatform() != EnumShopType.WEI.getIndex()) {
return ResultVo.error(HttpStatus.PARAMS_ERROR, "参数错误店铺不是JD店铺");
}
if(!StringUtils.hasText(shop.getAppkey())) {
if(!StringUtils.hasText(shop.getAppKey())) {
return ResultVo.error(HttpStatus.PARAMS_ERROR, "平台配置错误没有找到AppKey");
}
if(!StringUtils.hasText(shop.getAppsercet())) {
if(!StringUtils.hasText(shop.getAppSercet())) {
return ResultVo.error(HttpStatus.PARAMS_ERROR, "第三方平台配置错误没有找到AppSercet");
}
// var platform =skuService.selectShopSettingById(EnumShopType.WEI.getIndex());
// if(!StringUtils.hasText(platform.getse())) {
// return ResultVo.error(HttpStatus.PARAMS_ERROR, "第三方平台配置错误没有找到ServerUrl");
// }
var platform =platformService.getById(EnumShopType.WEI.getIndex());
if(!StringUtils.hasText(platform.getServerUrl())) {
return ResultVo.error(HttpStatus.PARAMS_ERROR, "第三方平台配置错误没有找到ServerUrl");
}
ShopApiParams params = new ShopApiParams();
params.setAppKey(shop.getAppkey());
params.setAppSecret(shop.getAppsercet());
params.setAccessToken(shop.getSessionkey());
params.setApiRequestUrl(shop.getApiRequestUrl());
// params.setServerUrl(platform.getServerUrl());
params.setSellerId(shop.getSelleruserid().toString());
params.setAppKey(shop.getAppKey());
params.setAppSecret(shop.getAppSercet());
params.setAccessToken(shop.getAccessToken());
params.setServerUrl(platform.getServerUrl());
params.setSellerId(shop.getSellerShopId().toString());
if (!StringUtils.hasText(params.getAccessToken())) {

View File

@ -12,7 +12,7 @@ public class OmsWeiGoodsSku implements Serializable {
/**
*
*/
private Long id;
private String id;
/**
* 店铺id

View File

@ -1,10 +1,11 @@
package com.qihang.wei.domain;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
/**
* 数据中心-店铺
* 电商平台店铺表
* @TableName s_shop
*/
@Data
@ -22,7 +23,7 @@ public class SShop implements Serializable {
/**
* 店铺别名
*/
private String nickname;
private String nickName;
/**
* 标识
@ -37,32 +38,22 @@ public class SShop implements Serializable {
/**
* 对应第三方平台Id
*/
private Integer type;
private Integer platform;
/**
* 店铺url
*/
private String url;
private String shopUrl;
/**
* 排序
*/
private Integer ordernum;
private Integer orderNum;
/**
* 是否删除0否1是
*/
private Integer isdelete;
/**
* 是否显示(0是1否
*/
private Integer isshow;
/**
* 更新时间
*/
private Long modifyOn;
private Integer isDelete;
/**
* 描述
@ -70,34 +61,29 @@ public class SShop implements Serializable {
private String remark;
/**
* 第三方平台店铺id淘宝天猫开放平台使用
* 第三方平台店铺id
*/
private Long selleruserid;
private Long sellerShopId;
/**
* 卖家userId
* Appkey(微信视频号小店专用)
*/
private String selleruseridstr;
private String appKey;
/**
* Appsercet(微信视频号小店专用)
*/
private String appSercet;
/**
* 第三方平台sessionKeyaccess_token
*/
private String sessionkey;
private String accessToken;
/**
* Appkey
* accessToken到期
*/
private String appkey;
/**
* Appsercet
*/
private String appsercet;
/**
* 到期
*/
private Long expiresIn;
private Long accessExpiresIn;
/**
* access_token开始时间
@ -115,9 +101,14 @@ public class SShop implements Serializable {
private Long refreshTokenTimeout;
/**
* 请求url
* 创建时间
*/
private String apiRequestUrl;
private Date createTime;
/**
* 更新时间
*/
private Date updateTime;
private static final long serialVersionUID = 1L;
}

View File

@ -0,0 +1,59 @@
package com.qihang.wei.domain;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
/**
* 电商平台配置表
* @TableName s_shop_platform
*/
@Data
public class SShopPlatform implements Serializable {
/**
* 主键
*/
private Integer id;
/**
* 平台名
*/
private String name;
/**
* appKey
*/
private String appKey;
/**
* appSecret
*/
private String appSecret;
/**
* 描述
*/
private String remark;
/**
* 服务url
*/
private String serverUrl;
/**
* 回调url
*/
private String redirectUrl;
/**
* 创建时间
*/
private Date createTime;
/**
* 更新时间
*/
private Date updateTime;
private static final long serialVersionUID = 1L;
}

View File

@ -5,8 +5,8 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @author TW
* @description 针对表s_shop(数据中心-店铺)的数据库操作Mapper
* @createDate 2024-06-03 14:14:56
* @description 针对表s_shop(电商平台店铺表)的数据库操作Mapper
* @createDate 2024-06-11 15:13:13
* @Entity com.qihang.wei.domain.SShop
*/
public interface SShopMapper extends BaseMapper<SShop> {

View File

@ -0,0 +1,18 @@
package com.qihang.wei.mapper;
import com.qihang.wei.domain.SShopPlatform;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @author TW
* @description 针对表s_shop_platform(电商平台配置表)的数据库操作Mapper
* @createDate 2024-06-11 15:13:13
* @Entity com.qihang.wei.domain.SShopPlatform
*/
public interface SShopPlatformMapper extends BaseMapper<SShopPlatform> {
}

View File

@ -1,5 +1,7 @@
package com.qihang.wei.service;
import com.qihang.common.common.PageQuery;
import com.qihang.common.common.PageResult;
import com.qihang.wei.domain.OmsWeiGoodsSku;
import com.baomidou.mybatisplus.extension.service.IService;
@ -9,5 +11,5 @@ import com.baomidou.mybatisplus.extension.service.IService;
* @createDate 2024-06-03 16:51:29
*/
public interface OmsWeiGoodsSkuService extends IService<OmsWeiGoodsSku> {
PageResult<OmsWeiGoodsSku> queryPageList(OmsWeiGoodsSku bo, PageQuery pageQuery);
}

View File

@ -0,0 +1,13 @@
package com.qihang.wei.service;
import com.qihang.wei.domain.SShopPlatform;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* @author TW
* @description 针对表s_shop_platform(电商平台配置表)的数据库操作Service
* @createDate 2024-06-11 15:13:13
*/
public interface SShopPlatformService extends IService<SShopPlatform> {
}

View File

@ -5,11 +5,10 @@ import com.baomidou.mybatisplus.extension.service.IService;
/**
* @author TW
* @description 针对表s_shop(数据中心-店铺)的数据库操作Service
* @createDate 2024-06-03 14:14:56
* @description 针对表s_shop(电商平台店铺表)的数据库操作Service
* @createDate 2024-06-11 15:13:13
*/
public interface SShopService extends IService<SShop> {
SShop selectShopById(Long shopId);
void updateSessionKey(Long shopId, String sessionKey);
}

View File

@ -1,9 +1,14 @@
package com.qihang.wei.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qihang.common.common.PageQuery;
import com.qihang.common.common.PageResult;
import com.qihang.wei.domain.OmsWeiGoodsSku;
import com.qihang.wei.service.OmsWeiGoodsSkuService;
import com.qihang.wei.mapper.OmsWeiGoodsSkuMapper;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
/**
@ -11,10 +16,22 @@ import org.springframework.stereotype.Service;
* @description 针对表oms_wei_goods_sku的数据库操作Service实现
* @createDate 2024-06-03 16:51:29
*/
@AllArgsConstructor
@Service
public class OmsWeiGoodsSkuServiceImpl extends ServiceImpl<OmsWeiGoodsSkuMapper, OmsWeiGoodsSku>
implements OmsWeiGoodsSkuService{
private final OmsWeiGoodsSkuMapper mapper;
@Override
public PageResult<OmsWeiGoodsSku> queryPageList(OmsWeiGoodsSku bo, PageQuery pageQuery) {
LambdaQueryWrapper<OmsWeiGoodsSku> queryWrapper = new LambdaQueryWrapper<OmsWeiGoodsSku>()
.eq(bo.getShopId()!=null,OmsWeiGoodsSku::getShopId,bo.getShopId())
;
Page<OmsWeiGoodsSku> page = mapper.selectPage(pageQuery.build(), queryWrapper);
return PageResult.build(page);
}
}

View File

@ -0,0 +1,22 @@
package com.qihang.wei.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qihang.wei.domain.SShopPlatform;
import com.qihang.wei.service.SShopPlatformService;
import com.qihang.wei.mapper.SShopPlatformMapper;
import org.springframework.stereotype.Service;
/**
* @author TW
* @description 针对表s_shop_platform(电商平台配置表)的数据库操作Service实现
* @createDate 2024-06-11 15:13:13
*/
@Service
public class SShopPlatformServiceImpl extends ServiceImpl<SShopPlatformMapper, SShopPlatform>
implements SShopPlatformService{
}

View File

@ -9,8 +9,8 @@ import org.springframework.stereotype.Service;
/**
* @author TW
* @description 针对表s_shop(数据中心-店铺)的数据库操作Service实现
* @createDate 2024-06-03 14:14:56
* @description 针对表s_shop(电商平台店铺表)的数据库操作Service实现
* @createDate 2024-06-11 15:13:13
*/
@AllArgsConstructor
@Service
@ -26,7 +26,7 @@ public class SShopServiceImpl extends ServiceImpl<SShopMapper, SShop>
public void updateSessionKey(Long shopId, String sessionKey) {
SShop shop = new SShop();
shop.setId(shopId);
shop.setSessionkey(sessionKey);
shop.setAccessToken(sessionKey);
mapper.updateById(shop);
}
}

View File

@ -7,36 +7,33 @@
<resultMap id="BaseResultMap" type="com.qihang.wei.domain.SShop">
<id property="id" column="id" jdbcType="INTEGER"/>
<result property="name" column="name" jdbcType="VARCHAR"/>
<result property="nickname" column="nickName" jdbcType="VARCHAR"/>
<result property="nickName" column="nick_name" jdbcType="VARCHAR"/>
<result property="ename" column="ename" jdbcType="VARCHAR"/>
<result property="company" column="company" jdbcType="VARCHAR"/>
<result property="type" column="type" jdbcType="INTEGER"/>
<result property="url" column="url" jdbcType="VARCHAR"/>
<result property="ordernum" column="orderNum" jdbcType="INTEGER"/>
<result property="isdelete" column="isDelete" jdbcType="INTEGER"/>
<result property="isshow" column="isShow" jdbcType="INTEGER"/>
<result property="modifyOn" column="modify_on" jdbcType="BIGINT"/>
<result property="platform" column="platform" jdbcType="INTEGER"/>
<result property="shopUrl" column="shop_url" jdbcType="VARCHAR"/>
<result property="orderNum" column="order_num" jdbcType="INTEGER"/>
<result property="isDelete" column="is_delete" jdbcType="INTEGER"/>
<result property="remark" column="remark" jdbcType="VARCHAR"/>
<result property="selleruserid" column="sellerUserId" jdbcType="BIGINT"/>
<result property="selleruseridstr" column="sellerUserIdStr" jdbcType="VARCHAR"/>
<result property="sessionkey" column="sessionKey" jdbcType="VARCHAR"/>
<result property="appkey" column="appkey" jdbcType="VARCHAR"/>
<result property="appsercet" column="appSercet" jdbcType="VARCHAR"/>
<result property="expiresIn" column="expires_in" jdbcType="BIGINT"/>
<result property="sellerShopId" column="seller_shop_id" jdbcType="BIGINT"/>
<result property="appKey" column="app_key" jdbcType="VARCHAR"/>
<result property="appSercet" column="app_sercet" jdbcType="VARCHAR"/>
<result property="accessToken" column="access_token" jdbcType="VARCHAR"/>
<result property="accessExpiresIn" column="access_expires_in" jdbcType="BIGINT"/>
<result property="accessTokenBegin" column="access_token_begin" jdbcType="BIGINT"/>
<result property="refreshToken" column="refresh_token" jdbcType="VARCHAR"/>
<result property="refreshTokenTimeout" column="refresh_token_timeout" jdbcType="BIGINT"/>
<result property="apiRequestUrl" column="api_request_url" jdbcType="VARCHAR"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id,name,nickName,
ename,company,type,
url,orderNum,isDelete,
isShow,modify_on,remark,
sellerUserId,sellerUserIdStr,sessionKey,
appkey,appSercet,expires_in,
id,name,nick_name,
ename,company,platform,
shop_url,order_num,is_delete,
remark,seller_shop_id,app_key,
app_sercet,access_token,access_expires_in,
access_token_begin,refresh_token,refresh_token_timeout,
api_request_url
create_time,update_time
</sql>
</mapper>

View File

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.qihang.wei.mapper.SShopPlatformMapper">
<resultMap id="BaseResultMap" type="com.qihang.wei.domain.SShopPlatform">
<id property="id" column="id" jdbcType="INTEGER"/>
<result property="name" column="name" jdbcType="VARCHAR"/>
<result property="appKey" column="app_key" jdbcType="VARCHAR"/>
<result property="appSecret" column="app_secret" jdbcType="VARCHAR"/>
<result property="remark" column="remark" jdbcType="VARCHAR"/>
<result property="serverUrl" column="server_url" jdbcType="VARCHAR"/>
<result property="redirectUrl" column="redirect_url" jdbcType="VARCHAR"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id,name,app_key,
app_secret,remark,server_url,
redirect_url,create_time,update_time
</sql>
</mapper>

View File

@ -43,3 +43,11 @@ export function pullGoodsList(data) {
data: data
})
}
export function linkErpGoodsSkuId(data) {
return request({
url: '/wei-api/goods/sku/linkErp',
method: 'post',
data: data
})
}

View File

@ -76,7 +76,7 @@
<el-table-column label="销售价" align="center" prop="salePrice" >
<template slot-scope="scope">{{scope.row.salePrice / 100}}</template>
</el-table-column>
<el-table-column label="ERP SKU ID" align="center" prop="erpSkuId" />
<el-table-column label="ERP SKU ID" align="center" prop="erpGoodsSkuId" />
<el-table-column label="状态" align="center" prop="status" >
<template slot-scope="scope">
<el-tag size="small" v-if="scope.row.status === 5">销售中</el-tag>
@ -108,8 +108,8 @@
<!-- 添加或修改商品管理对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="120px">
<el-form-item label="ERP商品SkuId" prop="erpSkuId">
<el-input v-model.number="form.erpSkuId" placeholder="请输入ERP商品SkuId" />
<el-form-item label="ERP商品SkuId" prop="erpGoodsSkuId">
<el-input v-model.number="form.erpGoodsSkuId" placeholder="请输入ERP商品SkuId" />
</el-form-item>
</el-form>
@ -125,7 +125,7 @@
import '@riophae/vue-treeselect/dist/vue-treeselect.css'
import {listShop} from "@/api/shop/shop";
import {pullGoodsList,listGoodsSku} from "@/api/wei/goods";
import {pullGoodsList,listGoodsSku,getGoodsSku,linkErpGoodsSkuId} from "@/api/wei/goods";
import {MessageBox} from "element-ui";
export default {
@ -167,7 +167,7 @@ export default {
id: [
{ required: true, message: "不能为空", trigger: "change" }
],
erpSkuId: [
erpGoodsSkuId: [
{ required: true, message: "不能为空", trigger: "blur" }
],
}