新增视频号小店接口
This commit is contained in:
parent
9c59152ddf
commit
ddba9c98ce
|
|
@ -1,14 +1,25 @@
|
|||
package com.qihang.api;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.nacos.common.model.RestResult;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.springframework.cloud.gateway.filter.GatewayFilterChain;
|
||||
import org.springframework.cloud.gateway.filter.GlobalFilter;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.core.io.buffer.DataBuffer;
|
||||
import org.springframework.core.io.buffer.DataBufferFactory;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.server.reactive.ServerHttpResponse;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.server.ServerWebExchange;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
@Configuration
|
||||
public class TokenFilter implements GlobalFilter, Ordered {
|
||||
private static final String TOKEN_HEADER = "Authorization";
|
||||
|
|
@ -17,9 +28,9 @@ public class TokenFilter implements GlobalFilter, Ordered {
|
|||
@Override
|
||||
public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
|
||||
String token = exchange.getRequest().getHeaders().getFirst(TOKEN_HEADER);
|
||||
System.out.println("Token:"+token);
|
||||
// System.out.println("Token:"+token);
|
||||
String url = exchange.getRequest().getURI().getPath();
|
||||
System.out.println("intercept " + url);
|
||||
// System.out.println("intercept " + url);
|
||||
if(url.equals("/api/sys-api/login") || url.equals("/api/sys-api/getInfo") || url.equals("/api/sys-api/logout")){
|
||||
// 登录页面 放行
|
||||
return chain.filter(exchange);
|
||||
|
|
@ -27,7 +38,21 @@ public class TokenFilter implements GlobalFilter, Ordered {
|
|||
// TODO: 统一鉴权处理
|
||||
if(!StringUtils.hasText(token)){
|
||||
exchange.getResponse().setStatusCode(HttpStatus.UNAUTHORIZED);
|
||||
return exchange.getResponse().setComplete();
|
||||
ServerHttpResponse response = exchange.getResponse();
|
||||
DataBufferFactory bufferFactory = response.bufferFactory();
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
// 要写入的数据对象,会自动转为json格式
|
||||
DataBuffer wrap = null;
|
||||
try {
|
||||
wrap = bufferFactory.wrap(objectMapper.writeValueAsBytes(new RestResult<>(401, "缺少Authorization值")));
|
||||
DataBuffer finalWrap = wrap;
|
||||
return response.writeWith(Mono.fromSupplier(() -> finalWrap));
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
|
||||
// return exchange.getResponse().setComplete();
|
||||
}
|
||||
return chain.filter(exchange);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,6 +59,12 @@ spring:
|
|||
- Path=/api/pdd-api/**
|
||||
filters:
|
||||
- StripPrefix=2
|
||||
- id: wei_api_route
|
||||
uri: lb://wei-api
|
||||
predicates:
|
||||
- Path=/api/wei-api/**
|
||||
filters:
|
||||
- StripPrefix=2
|
||||
# - TokenFilter
|
||||
# default-filters:
|
||||
# - TokenFilter
|
||||
|
|
|
|||
|
|
@ -158,6 +158,12 @@ public class AjaxResult extends HashMap<String, Object>
|
|||
return new AjaxResult(HttpStatus.ERROR, msg, data);
|
||||
}
|
||||
|
||||
public static AjaxResult error(int code ,String msg, Object data)
|
||||
{
|
||||
return new AjaxResult(code, msg, data);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 返回错误消息
|
||||
*
|
||||
|
|
|
|||
|
|
@ -11,7 +11,8 @@ public enum EnumShopType {
|
|||
TAO("淘宝天猫", 1),
|
||||
JD("京东", 2),
|
||||
DOUDIAN("抖音", 3),
|
||||
PDD("拼多多", 4);
|
||||
PDD("拼多多", 4),
|
||||
WEI("视频号小店", 5);
|
||||
private String name;
|
||||
private int index;
|
||||
|
||||
|
|
|
|||
|
|
@ -47,6 +47,10 @@
|
|||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-undertow</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-webflux</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
||||
|
|
@ -56,7 +60,21 @@
|
|||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.qihang</groupId>
|
||||
<artifactId>security</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>8.0.33</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-spring-boot3-starter</artifactId>
|
||||
<version>3.5.5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,19 @@
|
|||
package com.qihang.wei.config;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.DbType;
|
||||
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
|
||||
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
@MapperScan("com.qihang.wei.mapper")
|
||||
public class MybatisPlusConfig {
|
||||
@Bean
|
||||
public MybatisPlusInterceptor mybatisPlusInterceptor() {
|
||||
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
|
||||
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL)); //注意使用哪种数据库
|
||||
return interceptor;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
package com.qihang.wei.controller;
|
||||
|
||||
import com.qihang.common.common.AjaxResult;
|
||||
import com.qihang.common.enums.HttpStatus;
|
||||
import com.qihang.wei.openApi.ApiCommon;
|
||||
import com.qihang.wei.openApi.PullRequest;
|
||||
import com.qihang.wei.openApi.bo.GoodsApiBo;
|
||||
import com.qihang.wei.openApi.service.GoodsApiService;
|
||||
import com.qihang.wei.openApi.vo.GoodsListVo;
|
||||
import com.qihang.wei.utils.RemoteUtil;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@RequestMapping("/goods")
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
public class GoodsApiController {
|
||||
private final ApiCommon apiCommon;
|
||||
@RequestMapping(value = "/pull_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");
|
||||
return AjaxResult.error(HttpStatus.PARAMS_ERROR, "参数错误,没有店铺Id");
|
||||
}
|
||||
Date currDateTime = new Date();
|
||||
long startTime = System.currentTimeMillis();
|
||||
var checkResult = apiCommon.checkBefore(params.getShopId());
|
||||
if (checkResult.getCode() != HttpStatus.SUCCESS) {
|
||||
return AjaxResult.error(checkResult.getCode(), checkResult.getMsg(), checkResult.getData());
|
||||
}
|
||||
String accessToken = checkResult.getData().getAccessToken();
|
||||
String serverUrl = checkResult.getData().getServerUrl();
|
||||
String appKey = checkResult.getData().getAppKey();
|
||||
String appSecret = checkResult.getData().getAppSecret();
|
||||
GoodsApiService remoting = RemoteUtil.Remoting("https://api.weixin.qq.com", GoodsApiService.class);
|
||||
GoodsApiBo apiBo = new GoodsApiBo();
|
||||
apiBo.setPage_size(10);
|
||||
GoodsListVo res = remoting.getGoodsList(accessToken, apiBo);
|
||||
|
||||
|
||||
return AjaxResult.success();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,131 @@
|
|||
package com.qihang.wei.controller;
|
||||
|
||||
import com.qihang.common.common.AjaxResult;
|
||||
import com.qihang.common.common.ApiResult;
|
||||
import com.qihang.common.common.ResultVoEnum;
|
||||
import com.qihang.common.enums.EnumShopType;
|
||||
import com.qihang.common.enums.HttpStatus;
|
||||
import com.qihang.common.mq.MqMessage;
|
||||
import com.qihang.common.mq.MqType;
|
||||
import com.qihang.common.mq.MqUtils;
|
||||
import com.qihang.wei.openApi.ApiCommon;
|
||||
import com.qihang.wei.openApi.PullRequest;
|
||||
import com.qihang.wei.openApi.bo.CreateTimeRangeBo;
|
||||
import com.qihang.wei.openApi.bo.GoodsApiBo;
|
||||
import com.qihang.wei.openApi.bo.OrderListBo;
|
||||
import com.qihang.wei.openApi.service.GoodsApiService;
|
||||
import com.qihang.wei.openApi.service.OrderApiService;
|
||||
import com.qihang.wei.openApi.vo.GoodsListVo;
|
||||
import com.qihang.wei.openApi.vo.OrderListVo;
|
||||
import com.qihang.wei.utils.RemoteUtil;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
|
||||
@RequestMapping("/order")
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
public class OrderApiController {
|
||||
private final ApiCommon apiCommon;
|
||||
private final MqUtils mqUtils;
|
||||
|
||||
|
||||
@RequestMapping(value = "/pull_list", method = RequestMethod.POST)
|
||||
public AjaxResult pullList(@RequestBody PullRequest params) throws Exception {
|
||||
if (params.getShopId() == null || params.getShopId() <= 0) {
|
||||
return AjaxResult.error(HttpStatus.PARAMS_ERROR, "参数错误,没有店铺Id");
|
||||
}
|
||||
|
||||
Date currDateTime = new Date();
|
||||
long beginTime = System.currentTimeMillis();
|
||||
|
||||
var checkResult = apiCommon.checkBefore(params.getShopId());
|
||||
if (checkResult.getCode() != HttpStatus.SUCCESS) {
|
||||
return AjaxResult.error(checkResult.getCode(), checkResult.getMsg(),checkResult.getData());
|
||||
}
|
||||
String accessToken = checkResult.getData().getAccessToken();
|
||||
String serverUrl = checkResult.getData().getServerUrl();
|
||||
String appKey = checkResult.getData().getAppKey();
|
||||
String appSecret = checkResult.getData().getAppSecret();
|
||||
OrderApiService remoting = RemoteUtil.Remoting("https://api.weixin.qq.com", OrderApiService.class);
|
||||
OrderListBo apiBo = new OrderListBo();
|
||||
apiBo.setPage_size(100);
|
||||
CreateTimeRangeBo tbo= new CreateTimeRangeBo();
|
||||
tbo.setStart_time(1710864001L);
|
||||
tbo.setEnd_time(1710917798L);
|
||||
apiBo.setCreate_time_range(tbo);
|
||||
|
||||
OrderListVo orderList = remoting.getOrderList(accessToken, apiBo);
|
||||
|
||||
// 获取最后更新时间
|
||||
LocalDateTime startTime = null;
|
||||
LocalDateTime endTime = null;
|
||||
// SysShopPullLasttime lasttime = pullLasttimeService.getLasttimeByShop(params.getShopId(), "ORDER");
|
||||
// if(lasttime == null){
|
||||
// endTime = LocalDateTime.now();
|
||||
// startTime = endTime.minusDays(1);
|
||||
// }else{
|
||||
// startTime = lasttime.getLasttime().minusHours(1);//取上次结束一个小时前
|
||||
// endTime = startTime.plusDays(1);//取24小时
|
||||
// if(endTime.isAfter(LocalDateTime.now())){
|
||||
// endTime = LocalDateTime.now();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// //第一次获取
|
||||
// ApiResult<JdOrder> upResult = OrderApiHelper.pullOrder(startTime,endTime,1L,100L,serverUrl,appKey,appSecret,accessToken);
|
||||
// int insertSuccess = 0;//新增成功的订单
|
||||
// int totalError = 0;
|
||||
// int hasExistOrder = 0;//已存在的订单数
|
||||
// //循环插入订单数据到数据库
|
||||
// for (var order : upResult.getList()) {
|
||||
// //插入订单数据
|
||||
// var result = orderService.saveOrder(params.getShopId(), order);
|
||||
// if (result.getCode() == ResultVoEnum.DataExist.getIndex()) {
|
||||
// //已经存在
|
||||
// hasExistOrder++;
|
||||
// mqUtils.sendApiMessage(MqMessage.build(EnumShopType.JD,MqType.ORDER_MESSAGE,order.getOrderId()));
|
||||
// } else if (result.getCode() == ResultVoEnum.SUCCESS.getIndex()) {
|
||||
// insertSuccess++;
|
||||
// mqUtils.sendApiMessage(MqMessage.build(EnumShopType.JD,MqType.ORDER_MESSAGE,order.getOrderId()));
|
||||
// } else {
|
||||
// totalError++;
|
||||
// }
|
||||
// }
|
||||
// if(lasttime == null){
|
||||
// // 新增
|
||||
// SysShopPullLasttime insertLasttime = new SysShopPullLasttime();
|
||||
// insertLasttime.setShopId(params.getShopId());
|
||||
// insertLasttime.setCreateTime(new Date());
|
||||
// insertLasttime.setLasttime(endTime);
|
||||
// insertLasttime.setPullType("ORDER");
|
||||
// pullLasttimeService.save(insertLasttime);
|
||||
//
|
||||
// }else {
|
||||
// // 修改
|
||||
// SysShopPullLasttime updateLasttime = new SysShopPullLasttime();
|
||||
// updateLasttime.setId(lasttime.getId());
|
||||
// updateLasttime.setUpdateTime(new Date());
|
||||
// updateLasttime.setLasttime(endTime);
|
||||
// pullLasttimeService.updateById(updateLasttime);
|
||||
// }
|
||||
// SysShopPullLogs logs = new SysShopPullLogs();
|
||||
// logs.setShopType(EnumShopType.JD.getIndex());
|
||||
// logs.setShopId(params.getShopId());
|
||||
// logs.setPullType("ORDER");
|
||||
// logs.setPullWay("主动拉取");
|
||||
// logs.setPullParams("{startTime:"+startTime+",endTime:"+endTime+"}");
|
||||
// logs.setPullResult("{insertSuccess:"+insertSuccess+",hasExistOrder:"+hasExistOrder+",totalError:"+totalError+"}");
|
||||
// logs.setPullTime(currDateTime);
|
||||
// logs.setDuration(System.currentTimeMillis() - beginTime);
|
||||
// pullLogsService.save(logs);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,417 @@
|
|||
package com.qihang.wei.domain;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 数据中心-店铺
|
||||
* @TableName sys_shop
|
||||
*/
|
||||
public class SysShop implements Serializable {
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 店铺名
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 对应第三方平台Id
|
||||
*/
|
||||
private Integer type;
|
||||
|
||||
/**
|
||||
* 店铺url
|
||||
*/
|
||||
private String url;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
private Integer sort;
|
||||
|
||||
/**
|
||||
* 状态(1正常2已删除)
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private Long modifyOn;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 第三方平台店铺id,淘宝天猫开放平台使用
|
||||
*/
|
||||
private Long sellerId;
|
||||
|
||||
/**
|
||||
* Appkey
|
||||
*/
|
||||
private String appKey;
|
||||
|
||||
/**
|
||||
* Appsercet
|
||||
*/
|
||||
private String appSercet;
|
||||
|
||||
/**
|
||||
* 第三方平台sessionKey(access_token)
|
||||
*/
|
||||
private String accessToken;
|
||||
|
||||
/**
|
||||
* 到期
|
||||
*/
|
||||
private Long expiresIn;
|
||||
|
||||
/**
|
||||
* access_token开始时间
|
||||
*/
|
||||
private Long accessTokenBegin;
|
||||
|
||||
/**
|
||||
* 刷新token
|
||||
*/
|
||||
private String refreshToken;
|
||||
|
||||
/**
|
||||
* 刷新token过期时间
|
||||
*/
|
||||
private Long refreshTokenTimeout;
|
||||
|
||||
/**
|
||||
* 请求url
|
||||
*/
|
||||
private String apiRequestUrl;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* 店铺名
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* 店铺名
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* 对应第三方平台Id
|
||||
*/
|
||||
public Integer getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* 对应第三方平台Id
|
||||
*/
|
||||
public void setType(Integer type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
/**
|
||||
* 店铺url
|
||||
*/
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
/**
|
||||
* 店铺url
|
||||
*/
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
public Integer getSort() {
|
||||
return sort;
|
||||
}
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
public void setSort(Integer sort) {
|
||||
this.sort = sort;
|
||||
}
|
||||
|
||||
/**
|
||||
* 状态(1正常2已删除)
|
||||
*/
|
||||
public Integer getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* 状态(1正常2已删除)
|
||||
*/
|
||||
public void setStatus(Integer status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
public Long getModifyOn() {
|
||||
return modifyOn;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
public void setModifyOn(Long modifyOn) {
|
||||
this.modifyOn = modifyOn;
|
||||
}
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
public String getRemark() {
|
||||
return remark;
|
||||
}
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
public void setRemark(String remark) {
|
||||
this.remark = remark;
|
||||
}
|
||||
|
||||
/**
|
||||
* 第三方平台店铺id,淘宝天猫开放平台使用
|
||||
*/
|
||||
public Long getSellerId() {
|
||||
return sellerId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 第三方平台店铺id,淘宝天猫开放平台使用
|
||||
*/
|
||||
public void setSellerId(Long sellerId) {
|
||||
this.sellerId = sellerId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Appkey
|
||||
*/
|
||||
public String getAppKey() {
|
||||
return appKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Appkey
|
||||
*/
|
||||
public void setAppKey(String appKey) {
|
||||
this.appKey = appKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Appsercet
|
||||
*/
|
||||
public String getAppSercet() {
|
||||
return appSercet;
|
||||
}
|
||||
|
||||
/**
|
||||
* Appsercet
|
||||
*/
|
||||
public void setAppSercet(String appSercet) {
|
||||
this.appSercet = appSercet;
|
||||
}
|
||||
|
||||
/**
|
||||
* 第三方平台sessionKey(access_token)
|
||||
*/
|
||||
public String getAccessToken() {
|
||||
return accessToken;
|
||||
}
|
||||
|
||||
/**
|
||||
* 第三方平台sessionKey(access_token)
|
||||
*/
|
||||
public void setAccessToken(String accessToken) {
|
||||
this.accessToken = accessToken;
|
||||
}
|
||||
|
||||
/**
|
||||
* 到期
|
||||
*/
|
||||
public Long getExpiresIn() {
|
||||
return expiresIn;
|
||||
}
|
||||
|
||||
/**
|
||||
* 到期
|
||||
*/
|
||||
public void setExpiresIn(Long expiresIn) {
|
||||
this.expiresIn = expiresIn;
|
||||
}
|
||||
|
||||
/**
|
||||
* access_token开始时间
|
||||
*/
|
||||
public Long getAccessTokenBegin() {
|
||||
return accessTokenBegin;
|
||||
}
|
||||
|
||||
/**
|
||||
* access_token开始时间
|
||||
*/
|
||||
public void setAccessTokenBegin(Long accessTokenBegin) {
|
||||
this.accessTokenBegin = accessTokenBegin;
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新token
|
||||
*/
|
||||
public String getRefreshToken() {
|
||||
return refreshToken;
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新token
|
||||
*/
|
||||
public void setRefreshToken(String refreshToken) {
|
||||
this.refreshToken = refreshToken;
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新token过期时间
|
||||
*/
|
||||
public Long getRefreshTokenTimeout() {
|
||||
return refreshTokenTimeout;
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新token过期时间
|
||||
*/
|
||||
public void setRefreshTokenTimeout(Long refreshTokenTimeout) {
|
||||
this.refreshTokenTimeout = refreshTokenTimeout;
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求url
|
||||
*/
|
||||
public String getApiRequestUrl() {
|
||||
return apiRequestUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求url
|
||||
*/
|
||||
public void setApiRequestUrl(String apiRequestUrl) {
|
||||
this.apiRequestUrl = apiRequestUrl;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object that) {
|
||||
if (this == that) {
|
||||
return true;
|
||||
}
|
||||
if (that == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != that.getClass()) {
|
||||
return false;
|
||||
}
|
||||
SysShop other = (SysShop) that;
|
||||
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
|
||||
&& (this.getName() == null ? other.getName() == null : this.getName().equals(other.getName()))
|
||||
&& (this.getType() == null ? other.getType() == null : this.getType().equals(other.getType()))
|
||||
&& (this.getUrl() == null ? other.getUrl() == null : this.getUrl().equals(other.getUrl()))
|
||||
&& (this.getSort() == null ? other.getSort() == null : this.getSort().equals(other.getSort()))
|
||||
&& (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus()))
|
||||
&& (this.getModifyOn() == null ? other.getModifyOn() == null : this.getModifyOn().equals(other.getModifyOn()))
|
||||
&& (this.getRemark() == null ? other.getRemark() == null : this.getRemark().equals(other.getRemark()))
|
||||
&& (this.getSellerId() == null ? other.getSellerId() == null : this.getSellerId().equals(other.getSellerId()))
|
||||
&& (this.getAppKey() == null ? other.getAppKey() == null : this.getAppKey().equals(other.getAppKey()))
|
||||
&& (this.getAppSercet() == null ? other.getAppSercet() == null : this.getAppSercet().equals(other.getAppSercet()))
|
||||
&& (this.getAccessToken() == null ? other.getAccessToken() == null : this.getAccessToken().equals(other.getAccessToken()))
|
||||
&& (this.getExpiresIn() == null ? other.getExpiresIn() == null : this.getExpiresIn().equals(other.getExpiresIn()))
|
||||
&& (this.getAccessTokenBegin() == null ? other.getAccessTokenBegin() == null : this.getAccessTokenBegin().equals(other.getAccessTokenBegin()))
|
||||
&& (this.getRefreshToken() == null ? other.getRefreshToken() == null : this.getRefreshToken().equals(other.getRefreshToken()))
|
||||
&& (this.getRefreshTokenTimeout() == null ? other.getRefreshTokenTimeout() == null : this.getRefreshTokenTimeout().equals(other.getRefreshTokenTimeout()))
|
||||
&& (this.getApiRequestUrl() == null ? other.getApiRequestUrl() == null : this.getApiRequestUrl().equals(other.getApiRequestUrl()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
|
||||
result = prime * result + ((getName() == null) ? 0 : getName().hashCode());
|
||||
result = prime * result + ((getType() == null) ? 0 : getType().hashCode());
|
||||
result = prime * result + ((getUrl() == null) ? 0 : getUrl().hashCode());
|
||||
result = prime * result + ((getSort() == null) ? 0 : getSort().hashCode());
|
||||
result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode());
|
||||
result = prime * result + ((getModifyOn() == null) ? 0 : getModifyOn().hashCode());
|
||||
result = prime * result + ((getRemark() == null) ? 0 : getRemark().hashCode());
|
||||
result = prime * result + ((getSellerId() == null) ? 0 : getSellerId().hashCode());
|
||||
result = prime * result + ((getAppKey() == null) ? 0 : getAppKey().hashCode());
|
||||
result = prime * result + ((getAppSercet() == null) ? 0 : getAppSercet().hashCode());
|
||||
result = prime * result + ((getAccessToken() == null) ? 0 : getAccessToken().hashCode());
|
||||
result = prime * result + ((getExpiresIn() == null) ? 0 : getExpiresIn().hashCode());
|
||||
result = prime * result + ((getAccessTokenBegin() == null) ? 0 : getAccessTokenBegin().hashCode());
|
||||
result = prime * result + ((getRefreshToken() == null) ? 0 : getRefreshToken().hashCode());
|
||||
result = prime * result + ((getRefreshTokenTimeout() == null) ? 0 : getRefreshTokenTimeout().hashCode());
|
||||
result = prime * result + ((getApiRequestUrl() == null) ? 0 : getApiRequestUrl().hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(getClass().getSimpleName());
|
||||
sb.append(" [");
|
||||
sb.append("Hash = ").append(hashCode());
|
||||
sb.append(", id=").append(id);
|
||||
sb.append(", name=").append(name);
|
||||
sb.append(", type=").append(type);
|
||||
sb.append(", url=").append(url);
|
||||
sb.append(", sort=").append(sort);
|
||||
sb.append(", status=").append(status);
|
||||
sb.append(", modifyOn=").append(modifyOn);
|
||||
sb.append(", remark=").append(remark);
|
||||
sb.append(", sellerId=").append(sellerId);
|
||||
sb.append(", appKey=").append(appKey);
|
||||
sb.append(", appSercet=").append(appSercet);
|
||||
sb.append(", accessToken=").append(accessToken);
|
||||
sb.append(", expiresIn=").append(expiresIn);
|
||||
sb.append(", accessTokenBegin=").append(accessTokenBegin);
|
||||
sb.append(", refreshToken=").append(refreshToken);
|
||||
sb.append(", refreshTokenTimeout=").append(refreshTokenTimeout);
|
||||
sb.append(", apiRequestUrl=").append(apiRequestUrl);
|
||||
sb.append(", serialVersionUID=").append(serialVersionUID);
|
||||
sb.append("]");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
package com.qihang.wei.mapper;
|
||||
|
||||
import com.qihang.wei.domain.SysShop;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* @author TW
|
||||
* @description 针对表【sys_shop(数据中心-店铺)】的数据库操作Mapper
|
||||
* @createDate 2024-03-20 13:33:19
|
||||
* @Entity com.qihang.wei.domain.SysShop
|
||||
*/
|
||||
public interface SysShopMapper extends BaseMapper<SysShop> {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,130 @@
|
|||
package com.qihang.wei.mapper;
|
||||
|
||||
import com.qihang.security.entity.SysUser;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户表 数据层
|
||||
*
|
||||
* @author qihang
|
||||
*/
|
||||
@Mapper
|
||||
public interface SysUserMapper
|
||||
{
|
||||
/**
|
||||
* 根据条件分页查询用户列表
|
||||
*
|
||||
* @param sysUser 用户信息
|
||||
* @return 用户信息集合信息
|
||||
*/
|
||||
public List<SysUser> selectUserList(SysUser sysUser);
|
||||
|
||||
/**
|
||||
* 根据条件分页查询已配用户角色列表
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 用户信息集合信息
|
||||
*/
|
||||
public List<SysUser> selectAllocatedList(SysUser user);
|
||||
|
||||
/**
|
||||
* 根据条件分页查询未分配用户角色列表
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 用户信息集合信息
|
||||
*/
|
||||
public List<SysUser> selectUnallocatedList(SysUser user);
|
||||
|
||||
/**
|
||||
* 通过用户名查询用户
|
||||
*
|
||||
* @param userName 用户名
|
||||
* @return 用户对象信息
|
||||
*/
|
||||
public SysUser selectUserByUserName(String userName);
|
||||
|
||||
/**
|
||||
* 通过用户ID查询用户
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 用户对象信息
|
||||
*/
|
||||
public SysUser selectUserById(Long userId);
|
||||
|
||||
/**
|
||||
* 新增用户信息
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertUser(SysUser user);
|
||||
|
||||
/**
|
||||
* 修改用户信息
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateUser(SysUser user);
|
||||
|
||||
/**
|
||||
* 修改用户头像
|
||||
*
|
||||
* @param userName 用户名
|
||||
* @param avatar 头像地址
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateUserAvatar(@Param("userName") String userName, @Param("avatar") String avatar);
|
||||
|
||||
/**
|
||||
* 重置用户密码
|
||||
*
|
||||
* @param userName 用户名
|
||||
* @param password 密码
|
||||
* @return 结果
|
||||
*/
|
||||
public int resetUserPwd(@Param("userName") String userName, @Param("password") String password);
|
||||
|
||||
/**
|
||||
* 通过用户ID删除用户
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteUserById(Long userId);
|
||||
|
||||
/**
|
||||
* 批量删除用户信息
|
||||
*
|
||||
* @param userIds 需要删除的用户ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteUserByIds(Long[] userIds);
|
||||
|
||||
/**
|
||||
* 校验用户名称是否唯一
|
||||
*
|
||||
* @param userName 用户名称
|
||||
* @return 结果
|
||||
*/
|
||||
public SysUser checkUserNameUnique(String userName);
|
||||
|
||||
/**
|
||||
* 校验手机号码是否唯一
|
||||
*
|
||||
* @param phonenumber 手机号码
|
||||
* @return 结果
|
||||
*/
|
||||
public SysUser checkPhoneUnique(String phonenumber);
|
||||
|
||||
/**
|
||||
* 校验email是否唯一
|
||||
*
|
||||
* @param email 用户邮箱
|
||||
* @return 结果
|
||||
*/
|
||||
public SysUser checkEmailUnique(String email);
|
||||
}
|
||||
|
|
@ -0,0 +1,101 @@
|
|||
package com.qihang.wei.openApi;
|
||||
|
||||
import com.qihang.common.api.ShopApiParams;
|
||||
import com.qihang.common.common.ApiResult;
|
||||
import com.qihang.common.enums.EnumShopType;
|
||||
import com.qihang.common.enums.HttpStatus;
|
||||
|
||||
import com.qihang.wei.openApi.service.TokenApiService;
|
||||
import com.qihang.wei.openApi.vo.Token;
|
||||
import com.qihang.wei.service.SysShopService;
|
||||
import com.qihang.wei.utils.RemoteUtil;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
@AllArgsConstructor
|
||||
@Component
|
||||
public class ApiCommon {
|
||||
private final SysShopService shopService;
|
||||
/**
|
||||
* 更新前的检查
|
||||
*
|
||||
* @param shopId
|
||||
* @return
|
||||
* @throws
|
||||
*/
|
||||
public ApiResult<ShopApiParams> checkBefore(Integer shopId) {
|
||||
var shop = shopService.selectShopById(shopId);
|
||||
if (shop == null) {
|
||||
// return new ApiResult<>(EnumResultVo.ParamsError.getIndex(), "参数错误,没有找到店铺");
|
||||
return ApiResult.build(HttpStatus.PARAMS_ERROR,"参数错误,没有找到店铺");
|
||||
}
|
||||
|
||||
if (shop.getType() != EnumShopType.WEI.getIndex()) {
|
||||
return ApiResult.build(HttpStatus.PARAMS_ERROR, "参数错误,店铺不是JD店铺");
|
||||
}
|
||||
|
||||
if(!StringUtils.hasText(shop.getAppKey())) {
|
||||
return ApiResult.build(HttpStatus.PARAMS_ERROR, "平台配置错误,没有找到AppKey");
|
||||
}
|
||||
if(!StringUtils.hasText(shop.getAppSercet())) {
|
||||
return ApiResult.build(HttpStatus.PARAMS_ERROR, "第三方平台配置错误,没有找到AppSercet");
|
||||
}
|
||||
// if(!StringUtils.hasText(platform.getRedirectUri())) {
|
||||
// return ApiResult.build(HttpStatus.PARAMS_ERROR, "第三方平台配置错误,没有找到RedirectUri");
|
||||
// }
|
||||
// if(!StringUtils.hasText(platform.getServerUrl())) {
|
||||
// return ApiResult.build(HttpStatus.PARAMS_ERROR, "第三方平台配置错误,没有找到ServerUrl");
|
||||
// }
|
||||
|
||||
// if(shop.getSellerId() == null || shop.getSellerId() <= 0) {
|
||||
// return com.qihang.tao.common.ApiResult.build(HttpStatus.PARAMS_ERROR, "第三方平台配置错误,没有找到SellerUserId");
|
||||
// }
|
||||
|
||||
ShopApiParams params = new ShopApiParams();
|
||||
params.setAppKey(shop.getAppKey());
|
||||
params.setAppSecret(shop.getAppSercet());
|
||||
params.setAccessToken(shop.getAccessToken());
|
||||
// params.setTokenRequestUrl(platform.getRedirectUri());
|
||||
params.setApiRequestUrl(shop.getApiRequestUrl());
|
||||
// params.setServerUrl(platform.getServerUrl());
|
||||
params.setSellerId(shop.getSellerId().toString());
|
||||
if (!StringUtils.hasText(shop.getAccessToken())) {
|
||||
String tokenUrl = "https://api.weixin.qq.com/cgi-bin";
|
||||
// String s = "/token?grant_type=client_credential&appid="+params.getAppKey()+"&secret="+params.getAppSecret();
|
||||
TokenApiService remoting = RemoteUtil.Remoting(tokenUrl, TokenApiService.class);
|
||||
Token token = remoting.getToken("client_credential",params.getAppKey(),params.getAppSecret());
|
||||
params.setAccessToken(token.getAccess_token());
|
||||
shopService.updateSessionKey(shopId,token.getAccess_token());
|
||||
// return ApiResult.build(HttpStatus.UNAUTHORIZED, "Token已过期,请重新授权", params);
|
||||
}
|
||||
|
||||
/****************先查询卖家对不对***************/
|
||||
// TaobaoClient client = new DefaultTaobaoClient(url, appkey, secret);
|
||||
// UserSellerGetRequest reqSeller = new UserSellerGetRequest();
|
||||
// reqSeller.setFields("nick,user_id");
|
||||
// UserSellerGetResponse rsp = client.execute(reqSeller, sessionKey);
|
||||
// if(StringUtils.hasText(rsp.getErrorCode())){
|
||||
// if(rsp.getErrorCode().equals("27")){
|
||||
// return new ApiResult<>(EnumResultVo.TokenFail.getIndex(), "Token已过期,请重新授权",params);
|
||||
// }
|
||||
// else if(rsp.getErrorCode().equals("11")){
|
||||
// if(rsp.getSubCode().equals("isv.permission-api-package-limit"))
|
||||
// return new ApiResult<>(EnumResultVo.ParamsError.getIndex(), "请检查淘宝用户API:taobao.user.seller.get是否具有访问权限",params);
|
||||
// return new ApiResult<>(EnumResultVo.ParamsError.getIndex(), rsp.getSubCode(),params);
|
||||
// }
|
||||
// else if(rsp.getErrorCode().equals("25")){
|
||||
// return new ApiResult<>(EnumResultVo.ParamsError.getIndex(), "无效签名!请检查SessionKey、appKey、appSecret是否匹配",params);
|
||||
// } else
|
||||
// return new ApiResult<>(EnumResultVo.ParamsError.getIndex(), "参数错误!"+(StringUtils.hasText(rsp.getSubMsg()) ? rsp.getSubMsg(): rsp.getMsg()));
|
||||
// }
|
||||
// if(rsp.getUser() == null || rsp.getUser().getUserId() == null){
|
||||
// return new ApiResult<>(EnumResultVo.ParamsError.getIndex(), "参数错误!请设置店铺SellerUserId值!",params);
|
||||
// }
|
||||
// else if (shop.getSellerUserId().longValue() != rsp.getUser().getUserId().longValue()) {
|
||||
// return new ApiResult<>(EnumResultVo.TokenFail.getIndex(), "当前用户是:" + rsp.getUser().getNick() + ",请重新授权",params);
|
||||
// }
|
||||
return ApiResult.build(HttpStatus.SUCCESS,"",params);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,231 @@
|
|||
//package com.qihang.wei.openApi;
|
||||
//
|
||||
//import com.qihang.common.common.ApiResult;
|
||||
//import com.qihang.common.enums.HttpStatus;
|
||||
//
|
||||
//import org.slf4j.Logger;
|
||||
//import org.slf4j.LoggerFactory;
|
||||
//import org.springframework.beans.BeanUtils;
|
||||
//
|
||||
//import java.time.LocalDateTime;
|
||||
//import java.time.format.DateTimeFormatter;
|
||||
//import java.util.ArrayList;
|
||||
//import java.util.List;
|
||||
//
|
||||
//public class OrderApiHelper {
|
||||
// private static Logger log = LoggerFactory.getLogger(OrderApiHelper.class);
|
||||
//
|
||||
// private static final String ORDER_FIELDS = "venderId,orderId,orderType,payType,orderTotalPrice,orderSellerPrice,orderPayment,freightPrice,sellerDiscount,orderState,orderStateRemark,deliveryType,invoiceCode,orderRemark,orderStartTime,orderEndTime,venderRemark,balanceUsed,pin,returnOrder,paymentConfirmTime,waybill,logisticsId,modified,directParentOrderId,parentOrderId,orderSource,storeOrder,realPin,open_id,open_id_buyer,invoiceInfo,invoiceEasyInfo,itemInfoList,isShipmenttype,scDT,idSopShipmenttype,orderStartTime,consigneeInfo,orderMarkDesc";
|
||||
//
|
||||
// /**
|
||||
// * 更新订单(循环分页)
|
||||
// *
|
||||
// * @param pageNo
|
||||
// * @param pageSize
|
||||
// * @param accessToken
|
||||
// * @return
|
||||
// */
|
||||
// public static ApiResult<JdOrder> pullOrder(LocalDateTime startTime,LocalDateTime endTime,Long pageNo, Long pageSize, String serverUrl, String appKey, String appSecret, String accessToken) throws Exception {
|
||||
// String startTimeStr = startTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||
// String endTimeStr = endTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||
//
|
||||
// log.info("=======开始全量JD拉取订单{},参数日期:{}-{}=========",LocalDateTime.now(),startTimeStr,endTimeStr);
|
||||
//
|
||||
// JdClient client=new DefaultJdClient(serverUrl,accessToken,appKey,appSecret);
|
||||
// PopOrderEnSearchRequest request =new PopOrderEnSearchRequest();
|
||||
// request.setStartDate(startTimeStr);
|
||||
// request.setEndDate(endTimeStr);
|
||||
//// request.setOrderState("WAIT_SELLER_STOCK_OUT,WAIT_GOODS_RECEIVE_CONFIRM,WAIT_SELLER_DELIVERY,PAUSE,FINISHED_L,TRADE_CANCELED,LOCKED,POP_ORDER_PAUSE");
|
||||
//// request.setOrderState("");
|
||||
// request.setOrderState("ALL");
|
||||
//// request.setOptionalFields("orderId,venderId");
|
||||
//// request.setSourceId("JOS");
|
||||
// request.setOptionalFields(ORDER_FIELDS);
|
||||
// request.setPage(pageNo.toString());
|
||||
// request.setPageSize(pageSize.toString());
|
||||
// request.setSortType(1);
|
||||
// request.setDateType(0);
|
||||
// PopOrderEnSearchResponse response=client.execute(request);
|
||||
// if(response.getSearchorderinfoResult() == null || response.getSearchorderinfoResult().getApiResult() == null) {
|
||||
// return ApiResult.build(HttpStatus.ERROR, "接口调用错误" );
|
||||
// }
|
||||
// if(!response.getSearchorderinfoResult().getApiResult().getSuccess()){
|
||||
// return ApiResult.build(HttpStatus.ERROR, "接口调用错误:"+ response.getSearchorderinfoResult().getApiResult().getChineseErrCode());
|
||||
// }
|
||||
// if(response.getSearchorderinfoResult().getOrderTotal() == 0){
|
||||
// return ApiResult.build(0, new ArrayList<>());
|
||||
// }
|
||||
// //组合的订单列表
|
||||
// List<JdOrder> orderList = new ArrayList<>();
|
||||
//
|
||||
// for (var trade : response.getSearchorderinfoResult().getOrderInfoList()) {
|
||||
// //组装订单
|
||||
//// var order = OrderAssembleHelper.assembleOrder(trade);
|
||||
// JdOrder order = new JdOrder();
|
||||
// BeanUtils.copyProperties(trade,order);
|
||||
// order.setProvince(trade.getConsigneeInfo().getProvince());
|
||||
// order.setProvinceId(trade.getConsigneeInfo().getProvinceId());
|
||||
// order.setCity(trade.getConsigneeInfo().getCity());
|
||||
// order.setCityId(trade.getConsigneeInfo().getCityId());
|
||||
// order.setCounty(trade.getConsigneeInfo().getCounty());
|
||||
// order.setCountyId(trade.getConsigneeInfo().getCountyId());
|
||||
// order.setTown(trade.getConsigneeInfo().getTown());
|
||||
// order.setTownId(trade.getConsigneeInfo().getTownId());
|
||||
// order.setFullAddress(trade.getConsigneeInfo().getFullAddress());
|
||||
// order.setFullname(trade.getConsigneeInfo().getFullname());
|
||||
// order.setTelephone(trade.getConsigneeInfo().getTelephone());
|
||||
// order.setMobile(trade.getConsigneeInfo().getMobile());
|
||||
// List<JdOrderItem> items = new ArrayList<>();
|
||||
// for (var item : trade.getItemInfoList()) {
|
||||
// JdOrderItem it = new JdOrderItem();
|
||||
// BeanUtils.copyProperties(item,it);
|
||||
// items.add(it);
|
||||
// }
|
||||
// order.setItems(items);
|
||||
//// order.setOrderId(trade.getOrderId());
|
||||
//// order.setVenderId(trade.getVenderId());
|
||||
//// order.setOrderType(trade.getOrderType());
|
||||
//// order.setPayType(trade.getPayType());
|
||||
//// order.setOrderTotalPrice(trade.getOrderTotalPrice());
|
||||
//// order.setOrderSellerPrice(trade.getOrderSellerPrice());
|
||||
//// order.setOrderPayment(trade.getOrderPayment());
|
||||
//// order.setFreightPrice(trade.getFreightPrice());
|
||||
//
|
||||
//
|
||||
// orderList.add(order);
|
||||
// }
|
||||
//
|
||||
// return ApiResult.build(response.getSearchorderinfoResult().getOrderTotal(), orderList);
|
||||
//
|
||||
//
|
||||
//// TradesSoldGetRequest req = new TradesSoldGetRequest();
|
||||
//// req.setFields(ORDER_FIELDS);
|
||||
////// req.setStartCreated(DateUtil.stringtoDate("2019-11-27 00:00:00"));
|
||||
////// req.setEndCreated(DateUtil.stringtoDate("2019-12-04 23:59:59"));
|
||||
////// req.setStatus("WAIT_SELLER_SEND_GOODS");
|
||||
////// req.setBuyerNick("美丽的你美丽的我");
|
||||
//// req.setType("fixed");//一口价
|
||||
////// req.setExtType("service");
|
||||
////// req.setRateStatus("RATE_UNBUYER");
|
||||
////// req.setTag("time_card");
|
||||
//// req.setPageNo(pageNo);
|
||||
//// req.setPageSize(pageSize);
|
||||
////// req.setUseHasNext(true);
|
||||
////// req.setBuyerOpenId("AAHm5d-EAAeGwJedwSHpg8bT");
|
||||
//// TradesSoldGetResponse rsp = client.execute(req, sessionKey);
|
||||
////// System.out.println(rsp.getBody());
|
||||
//// if(StringUtils.hasText(rsp.getErrorCode())){
|
||||
//// if(rsp.getErrorCode().equals("27")){
|
||||
////// return new ApiResult(HttpStatus.UNAUTHORIZED, "Token已过期,请重新授权");
|
||||
//// return ApiResult.build(HttpStatus.UNAUTHORIZED, "Token已过期,请重新授权");
|
||||
//// }
|
||||
//// }
|
||||
//// if (rsp.getTrades() == null) {
|
||||
//// //接口查询错误
|
||||
////// return new ApiResult(500, "接口调用错误:" + rsp.getMsg() + rsp.getSubMsg());
|
||||
//// return ApiResult.build(HttpStatus.ERROR, "接口调用错误:" + rsp.getMsg() + rsp.getSubMsg());
|
||||
//// }
|
||||
////
|
||||
//// //组合的订单列表
|
||||
//// List<TaoOrder> orderList = new ArrayList<>();
|
||||
////
|
||||
//// //有数据
|
||||
//// for (var trade : rsp.getTrades()) {
|
||||
//// try {
|
||||
//// //组装订单
|
||||
//// var order = OrderAssembleHelper.assembleOrder(trade);
|
||||
////
|
||||
////// TopOaidDecryptRequest req1 = new TopOaidDecryptRequest();
|
||||
////// List<TopOaidDecryptRequest.ReceiverQuery> list2 = new ArrayList<TopOaidDecryptRequest.ReceiverQuery>();
|
||||
//////
|
||||
////// TopOaidDecryptRequest.ReceiverQuery obj3 = new TopOaidDecryptRequest.ReceiverQuery();
|
||||
////// list2.add(obj3);
|
||||
////// obj3.setOaid("1bhibPTekQ9Vico6BCjHicSUS6j5e9RRZkeyPzqeo41ibibkp5UTVZQC2wdLEQ0BssjpbscJyZy");
|
||||
////// obj3.setTid("3796207345637527441");
|
||||
////// obj3.setScene("1006");
|
||||
////// obj3.setSecretNoDays(15L);
|
||||
//////
|
||||
////// req1.setQueryList(list2);
|
||||
////// TopOaidDecryptResponse rsp1 = client.execute(req1, sessionKey);
|
||||
////// System.out.println(rsp1.getBody());
|
||||
////
|
||||
//// orderList.add(order);
|
||||
////
|
||||
//// } catch (Exception e) {
|
||||
//// }
|
||||
//// }
|
||||
//
|
||||
//// return new ApiResult(rsp.getTotalResults().intValue(), orderList);
|
||||
//// return ApiResult.build(0, new ArrayList<>());
|
||||
// }
|
||||
//
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * 增量获取淘宝开放平台天猫订单
|
||||
// *
|
||||
// * @param pageNo
|
||||
// * @param pageSize
|
||||
// * @param sessionKey
|
||||
// * @return
|
||||
// * @throws ApiException
|
||||
// */
|
||||
//// public static ApiResult<TaoOrder> pullIncrementOrder(Long pageNo, Long pageSize, String url, String appKey, String appSecret, String sessionKey) throws ApiException {
|
||||
//// log.info("=======开增量拉取订单{}=========",LocalDateTime.now());
|
||||
//// // 取当前时间30分钟前
|
||||
//// LocalDateTime endTime = LocalDateTime.now();
|
||||
//// LocalDateTime startTime = endTime.minus(60*24, ChronoUnit.MINUTES);
|
||||
////
|
||||
////
|
||||
//// TaobaoClient client = new DefaultTaobaoClient(url, appKey, appSecret);
|
||||
//// TradesSoldIncrementGetRequest req = new TradesSoldIncrementGetRequest();
|
||||
//// req.setFields(ORDER_FIELDS);
|
||||
////
|
||||
//// req.setStartModified(Date.from(startTime.toInstant(ZoneOffset.UTC)));
|
||||
//// req.setEndModified(Date.from(endTime.toInstant(ZoneOffset.UTC)));
|
||||
//// req.setType("fixed");//一口价
|
||||
////// req.setExtType("service");
|
||||
////// req.setRateStatus("RATE_UNBUYER");
|
||||
////// req.setTag("time_card");
|
||||
//// req.setPageNo(pageNo);
|
||||
//// req.setPageSize(pageSize);
|
||||
//// req.setUseHasNext(true);
|
||||
////// req.setUseHasNext(true);
|
||||
////// req.setBuyerOpenId("AAHm5d-EAAeGwJedwSHpg8bT");
|
||||
//// TradesSoldIncrementGetResponse rsp = client.execute(req, sessionKey);
|
||||
////
|
||||
////
|
||||
//// if (rsp.getTrades() == null) {
|
||||
//// if (!StringUtils.isEmpty(rsp.getErrorCode())) {
|
||||
//// //接口查询错误
|
||||
////// return new ApiResult(500, "接口调用错误:" + rsp.getMsg() + rsp.getSubMsg());
|
||||
//// return ApiResult.build(HttpStatus.ERROR,"接口调用错误:" + rsp.getMsg() + rsp.getSubMsg());
|
||||
//// }
|
||||
//// log.info("========增量拉取订单:无订单,{}==========",LocalDateTime.now());
|
||||
////// return new ApiResult(0, new ArrayList());
|
||||
//// return ApiResult.build(0,new ArrayList<>());
|
||||
//// }
|
||||
////
|
||||
//// //组合的订单列表
|
||||
//// List<TaoOrder> orderList = new ArrayList<>();
|
||||
//// //有数据
|
||||
//// for (var trade : rsp.getTrades()) {
|
||||
//// //组装订单
|
||||
//// orderList.add(OrderAssembleHelper.assembleOrder(trade));
|
||||
//// }
|
||||
//// // 有分页,继续拉取
|
||||
//// while (rsp.getHasNext()) {
|
||||
//// pageNo++;
|
||||
//// req.setPageNo(pageNo);
|
||||
//// rsp = client.execute(req, sessionKey);
|
||||
//// //有数据
|
||||
//// for (var trade : rsp.getTrades()) {
|
||||
//// //组装订单
|
||||
//// orderList.add(OrderAssembleHelper.assembleOrder(trade));
|
||||
//// }
|
||||
//// }
|
||||
////// return new ApiResult(orderList.size(), orderList);
|
||||
//// return ApiResult.build(orderList.size(),orderList);
|
||||
//// }
|
||||
//
|
||||
// }
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
package com.qihang.wei.openApi;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class PullRequest {
|
||||
private Integer shopId;//店铺Id
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
package com.qihang.wei.openApi.bo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class CreateTimeRangeBo {
|
||||
private Long start_time;
|
||||
private Long end_time;
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
package com.qihang.wei.openApi.bo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class GoodsApiBo {
|
||||
private Integer status;
|
||||
private Integer page_size;
|
||||
private String next_key;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
package com.qihang.wei.openApi.bo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class OrderListBo {
|
||||
private CreateTimeRangeBo create_time_range;
|
||||
private Integer page_size;
|
||||
private String next_key;
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
package com.qihang.wei.openApi.service;
|
||||
|
||||
import com.qihang.wei.openApi.bo.GoodsApiBo;
|
||||
import com.qihang.wei.openApi.vo.GoodsListVo;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.service.annotation.HttpExchange;
|
||||
import org.springframework.web.service.annotation.PostExchange;
|
||||
|
||||
@HttpExchange
|
||||
public interface GoodsApiService {
|
||||
@PostExchange("/channels/ec/product/list/get")
|
||||
GoodsListVo getGoodsList(@RequestParam String access_token, @RequestBody GoodsApiBo bo);
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
package com.qihang.wei.openApi.service;
|
||||
|
||||
import com.qihang.wei.openApi.bo.OrderListBo;
|
||||
import com.qihang.wei.openApi.vo.GoodsListVo;
|
||||
import com.qihang.wei.openApi.vo.OrderListVo;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.service.annotation.HttpExchange;
|
||||
import org.springframework.web.service.annotation.PostExchange;
|
||||
|
||||
@HttpExchange
|
||||
public interface OrderApiService {
|
||||
@PostExchange("/channels/ec/order/list/get")
|
||||
OrderListVo getOrderList(@RequestParam String access_token, @RequestBody OrderListBo bo);
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
package com.qihang.wei.openApi.service;
|
||||
|
||||
|
||||
import com.qihang.wei.openApi.vo.Token;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.service.annotation.GetExchange;
|
||||
import org.springframework.web.service.annotation.HttpExchange;
|
||||
|
||||
@HttpExchange
|
||||
public interface TokenApiService {
|
||||
|
||||
@GetExchange("/token")
|
||||
Token getToken(@RequestParam String grant_type, @RequestParam String appid, @RequestParam String secret);
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
package com.qihang.wei.openApi.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class BaseResVo {
|
||||
private Integer errcode;
|
||||
private String errmsg;
|
||||
private String next_key;
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
package com.qihang.wei.openApi.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class GoodsListVo extends BaseResVo {
|
||||
|
||||
private Long[] product_ids;
|
||||
|
||||
private Integer total_num;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
package com.qihang.wei.openApi.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class OrderListVo extends BaseResVo {
|
||||
|
||||
private Long[] order_id_list;
|
||||
|
||||
private boolean has_more;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
package com.qihang.wei.openApi.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class Token {
|
||||
private String access_token;
|
||||
private Long expires_in;
|
||||
private Integer errcode;
|
||||
private String errmsg;
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
package com.qihang.wei.service;
|
||||
|
||||
import com.qihang.wei.domain.SysShop;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* @author TW
|
||||
* @description 针对表【sys_shop(数据中心-店铺)】的数据库操作Service
|
||||
* @createDate 2024-03-20 13:33:19
|
||||
*/
|
||||
public interface SysShopService extends IService<SysShop> {
|
||||
SysShop selectShopById(Integer shopId);
|
||||
|
||||
void updateSessionKey(Integer shopId,String sessionKey);
|
||||
}
|
||||
|
|
@ -0,0 +1,298 @@
|
|||
package com.qihang.wei.service;
|
||||
|
||||
import com.qihang.common.common.ServiceException;
|
||||
import com.qihang.common.constant.UserConstants;
|
||||
import com.qihang.common.utils.StringUtils;
|
||||
import com.qihang.security.entity.SysUser;
|
||||
import com.qihang.security.service.ISysUserService;
|
||||
import com.qihang.wei.mapper.SysUserMapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户 业务层处理
|
||||
*
|
||||
* @author qihang
|
||||
*/
|
||||
@Service
|
||||
public class SysUserServiceImpl implements ISysUserService
|
||||
{
|
||||
private static final Logger log = LoggerFactory.getLogger(SysUserServiceImpl.class);
|
||||
|
||||
@Autowired
|
||||
private SysUserMapper userMapper;
|
||||
|
||||
/**
|
||||
* 根据条件分页查询用户列表
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 用户信息集合信息
|
||||
*/
|
||||
@Override
|
||||
public List<SysUser> selectUserList(SysUser user)
|
||||
{
|
||||
return userMapper.selectUserList(user);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据条件分页查询已分配用户角色列表
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 用户信息集合信息
|
||||
*/
|
||||
@Override
|
||||
public List<SysUser> selectAllocatedList(SysUser user)
|
||||
{
|
||||
return userMapper.selectAllocatedList(user);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据条件分页查询未分配用户角色列表
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 用户信息集合信息
|
||||
*/
|
||||
@Override
|
||||
public List<SysUser> selectUnallocatedList(SysUser user)
|
||||
{
|
||||
return userMapper.selectUnallocatedList(user);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过用户名查询用户
|
||||
*
|
||||
* @param userName 用户名
|
||||
* @return 用户对象信息
|
||||
*/
|
||||
@Override
|
||||
public SysUser selectUserByUserName(String userName)
|
||||
{
|
||||
return userMapper.selectUserByUserName(userName);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过用户ID查询用户
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 用户对象信息
|
||||
*/
|
||||
@Override
|
||||
public SysUser selectUserById(Long userId)
|
||||
{
|
||||
return userMapper.selectUserById(userId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验用户名称是否唯一
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public boolean checkUserNameUnique(SysUser user)
|
||||
{
|
||||
Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId();
|
||||
SysUser info = userMapper.checkUserNameUnique(user.getUserName());
|
||||
if (StringUtils.isNotNull(info) && info.getUserId().longValue() != userId.longValue())
|
||||
{
|
||||
return UserConstants.NOT_UNIQUE;
|
||||
}
|
||||
return UserConstants.UNIQUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验手机号码是否唯一
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean checkPhoneUnique(SysUser user)
|
||||
{
|
||||
Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId();
|
||||
SysUser info = userMapper.checkPhoneUnique(user.getPhonenumber());
|
||||
if (StringUtils.isNotNull(info) && info.getUserId().longValue() != userId.longValue())
|
||||
{
|
||||
return UserConstants.NOT_UNIQUE;
|
||||
}
|
||||
return UserConstants.UNIQUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验email是否唯一
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean checkEmailUnique(SysUser user)
|
||||
{
|
||||
Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId();
|
||||
SysUser info = userMapper.checkEmailUnique(user.getEmail());
|
||||
if (StringUtils.isNotNull(info) && info.getUserId().longValue() != userId.longValue())
|
||||
{
|
||||
return UserConstants.NOT_UNIQUE;
|
||||
}
|
||||
return UserConstants.UNIQUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验用户是否允许操作
|
||||
*
|
||||
* @param user 用户信息
|
||||
*/
|
||||
@Override
|
||||
public void checkUserAllowed(SysUser user)
|
||||
{
|
||||
if (StringUtils.isNotNull(user.getUserId()) && user.isAdmin())
|
||||
{
|
||||
throw new ServiceException("不允许操作超级管理员用户");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增保存用户信息
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public int insertUser(SysUser user)
|
||||
{
|
||||
// 新增用户信息
|
||||
int rows = userMapper.insertUser(user);
|
||||
// // 新增用户岗位关联
|
||||
// insertUserPost(user);
|
||||
// // 新增用户与角色管理
|
||||
// insertUserRole(user);
|
||||
return rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册用户信息
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public boolean registerUser(SysUser user)
|
||||
{
|
||||
return userMapper.insertUser(user) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改保存用户信息
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public int updateUser(SysUser user)
|
||||
{
|
||||
Long userId = user.getUserId();
|
||||
// // 删除用户与角色关联
|
||||
// userRoleMapper.deleteUserRoleByUserId(userId);
|
||||
// // 新增用户与角色管理
|
||||
// insertUserRole(user);
|
||||
// // 删除用户与岗位关联
|
||||
// userPostMapper.deleteUserPostByUserId(userId);
|
||||
// 新增用户与岗位管理
|
||||
// insertUserPost(user);
|
||||
return userMapper.updateUser(user);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 修改用户状态
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateUserStatus(SysUser user)
|
||||
{
|
||||
return userMapper.updateUser(user);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改用户基本信息
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateUserProfile(SysUser user)
|
||||
{
|
||||
return userMapper.updateUser(user);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改用户头像
|
||||
*
|
||||
* @param userName 用户名
|
||||
* @param avatar 头像地址
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public boolean updateUserAvatar(String userName, String avatar)
|
||||
{
|
||||
return userMapper.updateUserAvatar(userName, avatar) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置用户密码
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int resetPwd(SysUser user)
|
||||
{
|
||||
return userMapper.updateUser(user);
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置用户密码
|
||||
*
|
||||
* @param userName 用户名
|
||||
* @param password 密码
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int resetUserPwd(String userName, String password)
|
||||
{
|
||||
return userMapper.resetUserPwd(userName, password);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 通过用户ID删除用户
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public int deleteUserById(Long userId)
|
||||
{
|
||||
// // 删除用户与角色关联
|
||||
// userRoleMapper.deleteUserRoleByUserId(userId);
|
||||
// // 删除用户与岗位表
|
||||
// userPostMapper.deleteUserPostByUserId(userId);
|
||||
return userMapper.deleteUserById(userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkUserDataScope(Long userId) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
package com.qihang.wei.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.qihang.wei.domain.SysShop;
|
||||
import com.qihang.wei.service.SysShopService;
|
||||
import com.qihang.wei.mapper.SysShopMapper;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author TW
|
||||
* @description 针对表【sys_shop(数据中心-店铺)】的数据库操作Service实现
|
||||
* @createDate 2024-03-20 13:33:19
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@Service
|
||||
public class SysShopServiceImpl extends ServiceImpl<SysShopMapper, SysShop>
|
||||
implements SysShopService{
|
||||
private SysShopMapper mapper;
|
||||
@Override
|
||||
public SysShop selectShopById(Integer shopId) {
|
||||
return mapper.selectById(shopId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSessionKey(Integer shopId, String sessionKey) {
|
||||
SysShop shop = new SysShop();
|
||||
shop.setId(shopId);
|
||||
shop.setAccessToken(sessionKey);
|
||||
mapper.updateById(shop);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
package com.qihang.wei.utils;
|
||||
|
||||
import org.springframework.web.reactive.function.client.WebClient;
|
||||
import org.springframework.web.reactive.function.client.support.WebClientAdapter;
|
||||
import org.springframework.web.service.invoker.HttpServiceProxyFactory;
|
||||
|
||||
public class RemoteUtil {
|
||||
|
||||
/**
|
||||
* 远程调用方法 模板代码
|
||||
* @param url 调用的地址
|
||||
* @param serviceType 返回的类型
|
||||
*/
|
||||
public static <S> S Remoting(String url, Class<S> serviceType){
|
||||
WebClient client = WebClient.builder().baseUrl(url).build();
|
||||
HttpServiceProxyFactory factory = HttpServiceProxyFactory.builder(WebClientAdapter.forClient(client)).build();
|
||||
return factory.createClient(serviceType);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
<?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.SysShopMapper">
|
||||
|
||||
<resultMap id="BaseResultMap" type="com.qihang.wei.domain.SysShop">
|
||||
<id property="id" column="id" jdbcType="INTEGER"/>
|
||||
<result property="name" column="name" jdbcType="VARCHAR"/>
|
||||
<result property="type" column="type" jdbcType="INTEGER"/>
|
||||
<result property="url" column="url" jdbcType="VARCHAR"/>
|
||||
<result property="sort" column="sort" jdbcType="INTEGER"/>
|
||||
<result property="status" column="status" jdbcType="INTEGER"/>
|
||||
<result property="modifyOn" column="modify_on" jdbcType="BIGINT"/>
|
||||
<result property="remark" column="remark" jdbcType="VARCHAR"/>
|
||||
<result property="sellerId" column="seller_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="expiresIn" column="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"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
id,name,type,
|
||||
url,sort,status,
|
||||
modify_on,remark,seller_id,
|
||||
app_key,app_sercet,access_token,
|
||||
expires_in,access_token_begin,refresh_token,
|
||||
refresh_token_timeout,api_request_url
|
||||
</sql>
|
||||
</mapper>
|
||||
|
|
@ -0,0 +1,195 @@
|
|||
<?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.SysUserMapper">
|
||||
|
||||
<resultMap type="SysUser" id="SysUserResult">
|
||||
<id property="userId" column="user_id" />
|
||||
<result property="deptId" column="dept_id" />
|
||||
<result property="userName" column="user_name" />
|
||||
<result property="nickName" column="nick_name" />
|
||||
<result property="email" column="email" />
|
||||
<result property="phonenumber" column="phonenumber" />
|
||||
<result property="sex" column="sex" />
|
||||
<result property="avatar" column="avatar" />
|
||||
<result property="password" column="password" />
|
||||
<result property="status" column="status" />
|
||||
<result property="delFlag" column="del_flag" />
|
||||
<result property="loginIp" column="login_ip" />
|
||||
<result property="loginDate" column="login_date" />
|
||||
|
||||
</resultMap>
|
||||
|
||||
|
||||
|
||||
|
||||
<sql id="selectUserVo">
|
||||
select u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.avatar, u.phonenumber, u.password, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark
|
||||
|
||||
from sys_user u
|
||||
</sql>
|
||||
|
||||
<select id="selectUserList" parameterType="SysUser" resultMap="SysUserResult">
|
||||
select u.user_id, u.dept_id, u.nick_name, u.user_name, u.email, u.avatar, u.phonenumber, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark, d.dept_name, d.leader from sys_user u
|
||||
left join sys_dept d on u.dept_id = d.dept_id
|
||||
where u.del_flag = '0'
|
||||
<if test="userId != null and userId != 0">
|
||||
AND u.user_id = #{userId}
|
||||
</if>
|
||||
<if test="userName != null and userName != ''">
|
||||
AND u.user_name like concat('%', #{userName}, '%')
|
||||
</if>
|
||||
<if test="status != null and status != ''">
|
||||
AND u.status = #{status}
|
||||
</if>
|
||||
<if test="phonenumber != null and phonenumber != ''">
|
||||
AND u.phonenumber like concat('%', #{phonenumber}, '%')
|
||||
</if>
|
||||
<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
|
||||
AND date_format(u.create_time,'%y%m%d') >= date_format(#{params.beginTime},'%y%m%d')
|
||||
</if>
|
||||
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
|
||||
AND date_format(u.create_time,'%y%m%d') <= date_format(#{params.endTime},'%y%m%d')
|
||||
</if>
|
||||
<if test="deptId != null and deptId != 0">
|
||||
AND (u.dept_id = #{deptId} OR u.dept_id IN ( SELECT t.dept_id FROM sys_dept t WHERE find_in_set(#{deptId}, ancestors) ))
|
||||
</if>
|
||||
<!-- 数据范围过滤 -->
|
||||
${params.dataScope}
|
||||
</select>
|
||||
|
||||
<select id="selectAllocatedList" parameterType="SysUser" resultMap="SysUserResult">
|
||||
select distinct u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.phonenumber, u.status, u.create_time
|
||||
from sys_user u
|
||||
left join sys_dept d on u.dept_id = d.dept_id
|
||||
left join sys_user_role ur on u.user_id = ur.user_id
|
||||
left join sys_role r on r.role_id = ur.role_id
|
||||
where u.del_flag = '0' and r.role_id = #{roleId}
|
||||
<if test="userName != null and userName != ''">
|
||||
AND u.user_name like concat('%', #{userName}, '%')
|
||||
</if>
|
||||
<if test="phonenumber != null and phonenumber != ''">
|
||||
AND u.phonenumber like concat('%', #{phonenumber}, '%')
|
||||
</if>
|
||||
<!-- 数据范围过滤 -->
|
||||
${params.dataScope}
|
||||
</select>
|
||||
|
||||
<select id="selectUnallocatedList" parameterType="SysUser" resultMap="SysUserResult">
|
||||
select distinct u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.phonenumber, u.status, u.create_time
|
||||
from sys_user u
|
||||
left join sys_dept d on u.dept_id = d.dept_id
|
||||
left join sys_user_role ur on u.user_id = ur.user_id
|
||||
left join sys_role r on r.role_id = ur.role_id
|
||||
where u.del_flag = '0' and (r.role_id != #{roleId} or r.role_id IS NULL)
|
||||
and u.user_id not in (select u.user_id from sys_user u inner join sys_user_role ur on u.user_id = ur.user_id and ur.role_id = #{roleId})
|
||||
<if test="userName != null and userName != ''">
|
||||
AND u.user_name like concat('%', #{userName}, '%')
|
||||
</if>
|
||||
<if test="phonenumber != null and phonenumber != ''">
|
||||
AND u.phonenumber like concat('%', #{phonenumber}, '%')
|
||||
</if>
|
||||
<!-- 数据范围过滤 -->
|
||||
${params.dataScope}
|
||||
</select>
|
||||
|
||||
<select id="selectUserByUserName" parameterType="String" resultMap="SysUserResult">
|
||||
<include refid="selectUserVo"/>
|
||||
where u.user_name = #{userName} and u.del_flag = '0'
|
||||
</select>
|
||||
|
||||
<select id="selectUserById" parameterType="Long" resultMap="SysUserResult">
|
||||
<include refid="selectUserVo"/>
|
||||
where u.user_id = #{userId}
|
||||
</select>
|
||||
|
||||
<select id="checkUserNameUnique" parameterType="String" resultMap="SysUserResult">
|
||||
select user_id, user_name from sys_user where user_name = #{userName} and del_flag = '0' limit 1
|
||||
</select>
|
||||
|
||||
<select id="checkPhoneUnique" parameterType="String" resultMap="SysUserResult">
|
||||
select user_id, phonenumber from sys_user where phonenumber = #{phonenumber} and del_flag = '0' limit 1
|
||||
</select>
|
||||
|
||||
<select id="checkEmailUnique" parameterType="String" resultMap="SysUserResult">
|
||||
select user_id, email from sys_user where email = #{email} and del_flag = '0' limit 1
|
||||
</select>
|
||||
|
||||
<insert id="insertUser" parameterType="SysUser" useGeneratedKeys="true" keyProperty="userId">
|
||||
insert into sys_user(
|
||||
<if test="userId != null and userId != 0">user_id,</if>
|
||||
<if test="deptId != null and deptId != 0">dept_id,</if>
|
||||
<if test="userName != null and userName != ''">user_name,</if>
|
||||
<if test="nickName != null and nickName != ''">nick_name,</if>
|
||||
<if test="email != null and email != ''">email,</if>
|
||||
<if test="avatar != null and avatar != ''">avatar,</if>
|
||||
<if test="phonenumber != null and phonenumber != ''">phonenumber,</if>
|
||||
<if test="sex != null and sex != ''">sex,</if>
|
||||
<if test="password != null and password != ''">password,</if>
|
||||
<if test="status != null and status != ''">status,</if>
|
||||
<if test="createBy != null and createBy != ''">create_by,</if>
|
||||
<if test="remark != null and remark != ''">remark,</if>
|
||||
create_time
|
||||
)values(
|
||||
<if test="userId != null and userId != ''">#{userId},</if>
|
||||
<if test="deptId != null and deptId != ''">#{deptId},</if>
|
||||
<if test="userName != null and userName != ''">#{userName},</if>
|
||||
<if test="nickName != null and nickName != ''">#{nickName},</if>
|
||||
<if test="email != null and email != ''">#{email},</if>
|
||||
<if test="avatar != null and avatar != ''">#{avatar},</if>
|
||||
<if test="phonenumber != null and phonenumber != ''">#{phonenumber},</if>
|
||||
<if test="sex != null and sex != ''">#{sex},</if>
|
||||
<if test="password != null and password != ''">#{password},</if>
|
||||
<if test="status != null and status != ''">#{status},</if>
|
||||
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
||||
<if test="remark != null and remark != ''">#{remark},</if>
|
||||
current_timestamp()
|
||||
)
|
||||
</insert>
|
||||
|
||||
<update id="updateUser" parameterType="SysUser">
|
||||
update sys_user
|
||||
<set>
|
||||
<if test="deptId != null and deptId != 0">dept_id = #{deptId},</if>
|
||||
<if test="userName != null and userName != ''">user_name = #{userName},</if>
|
||||
<if test="nickName != null and nickName != ''">nick_name = #{nickName},</if>
|
||||
<if test="email != null ">email = #{email},</if>
|
||||
<if test="phonenumber != null ">phonenumber = #{phonenumber},</if>
|
||||
<if test="sex != null and sex != ''">sex = #{sex},</if>
|
||||
<if test="avatar != null and avatar != ''">avatar = #{avatar},</if>
|
||||
<if test="password != null and password != ''">password = #{password},</if>
|
||||
<if test="status != null and status != ''">status = #{status},</if>
|
||||
<if test="loginIp != null and loginIp != ''">login_ip = #{loginIp},</if>
|
||||
<if test="loginDate != null">login_date = #{loginDate},</if>
|
||||
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
update_time = current_timestamp()
|
||||
</set>
|
||||
where user_id = #{userId}
|
||||
</update>
|
||||
|
||||
<update id="updateUserStatus" parameterType="SysUser">
|
||||
update sys_user set status = #{status} where user_id = #{userId}
|
||||
</update>
|
||||
|
||||
<update id="updateUserAvatar" parameterType="SysUser">
|
||||
update sys_user set avatar = #{avatar} where user_name = #{userName}
|
||||
</update>
|
||||
|
||||
<update id="resetUserPwd" parameterType="SysUser">
|
||||
update sys_user set password = #{password} where user_name = #{userName}
|
||||
</update>
|
||||
|
||||
<delete id="deleteUserById" parameterType="Long">
|
||||
update sys_user set del_flag = '2' where user_id = #{userId}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteUserByIds" parameterType="Long">
|
||||
update sys_user set del_flag = '2' where user_id in
|
||||
<foreach collection="array" item="userId" open="(" separator="," close=")">
|
||||
#{userId}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue