支付回调
获取数据列表接口问题 token有效期 及 续期 订单详情 为null的情况 根据桌码获取shopid接口调整 首页 默认值
This commit is contained in:
parent
c85f82f385
commit
fefb4c3a85
|
|
@ -14,6 +14,7 @@ import org.springframework.context.ApplicationContext;
|
||||||
import org.mybatis.spring.annotation.MapperScan;
|
import org.mybatis.spring.annotation.MapperScan;
|
||||||
import org.springframework.context.annotation.EnableAspectJAutoProxy;
|
import org.springframework.context.annotation.EnableAspectJAutoProxy;
|
||||||
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
|
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
|
||||||
|
import org.springframework.scheduling.annotation.EnableAsync;
|
||||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||||
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
@ -26,11 +27,12 @@ import java.net.Socket;
|
||||||
@EnableScheduling
|
@EnableScheduling
|
||||||
@EntityScan(basePackageClasses = {Shell.class})
|
@EntityScan(basePackageClasses = {Shell.class})
|
||||||
@MapperScan(basePackageClasses ={Shell.class} )
|
@MapperScan(basePackageClasses ={Shell.class} )
|
||||||
@ComponentScan(basePackageClasses ={Shell.class})
|
//@ComponentScan(basePackageClasses ={Shell.class})
|
||||||
@EnableTransactionManagement
|
@EnableTransactionManagement
|
||||||
@EnableAspectJAutoProxy(proxyTargetClass = true)
|
@EnableAspectJAutoProxy(proxyTargetClass = true)
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@EnableWebSocket
|
@EnableWebSocket
|
||||||
|
@EnableAsync
|
||||||
public class Shell {
|
public class Shell {
|
||||||
|
|
||||||
private static Logger logger = LoggerFactory.getLogger(Shell.class);
|
private static Logger logger = LoggerFactory.getLogger(Shell.class);
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ import com.chaozhanggui.system.cashierservice.util.TokenUtil;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.scheduling.annotation.Async;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import javax.servlet.*;
|
import javax.servlet.*;
|
||||||
|
|
@ -36,7 +37,7 @@ public class LoginFilter implements Filter {
|
||||||
// 忽略静态资源
|
// 忽略静态资源
|
||||||
"css/**",
|
"css/**",
|
||||||
"js/**",
|
"js/**",
|
||||||
"cashierService/websocket/table/**",//websocket
|
"cashierService/websocket/table",//websocket
|
||||||
"cashierService/phoneValidateCode",//验证码
|
"cashierService/phoneValidateCode",//验证码
|
||||||
"cashierService/tbPlatformDict",//获取菜单
|
"cashierService/tbPlatformDict",//获取菜单
|
||||||
"cashierService/location/**",//高德 获取行政区域
|
"cashierService/location/**",//高德 获取行政区域
|
||||||
|
|
@ -45,7 +46,10 @@ public class LoginFilter implements Filter {
|
||||||
"cashierService/order/testMessage",//首页
|
"cashierService/order/testMessage",//首页
|
||||||
"cashierService/common/**",//通用接口
|
"cashierService/common/**",//通用接口
|
||||||
"cashierService/distirict/**",//首页其它接口
|
"cashierService/distirict/**",//首页其它接口
|
||||||
"cashierService/login/**",//登录部分接口不校验
|
|
||||||
|
// "cashierService/login/**",//登录部分接口不校验
|
||||||
|
"cashierService/login/wx/**",//登录部分接口不校验
|
||||||
|
"cashierService/login/app/login",//登录部分接口不校验
|
||||||
"cashierService/product/queryProduct",
|
"cashierService/product/queryProduct",
|
||||||
"cashierService/product/queryProductSku",
|
"cashierService/product/queryProductSku",
|
||||||
"cashierService/product/productInfo",
|
"cashierService/product/productInfo",
|
||||||
|
|
@ -95,16 +99,18 @@ public class LoginFilter implements Filter {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String message = "";
|
String message = "";
|
||||||
|
String tokenKey="";
|
||||||
if(environment.equals("app")){
|
if(environment.equals("app")){
|
||||||
//获取当前登录人的用户id
|
//获取当前登录人的用户id
|
||||||
String loginName = TokenUtil.parseParamFromToken(token).getString("userId");
|
String userId = TokenUtil.parseParamFromToken(token).getString("userId");
|
||||||
|
tokenKey=RedisCst.ONLINE_APP_USER.concat(userId);
|
||||||
//获取redis中的token
|
//获取redis中的token
|
||||||
message = redisUtil.getMessage(RedisCst.ONLINE_APP_USER.concat(loginName));
|
|
||||||
}else if(environment.equals("wx")){
|
}else if(environment.equals("wx")){
|
||||||
//获取当前登录人的用户id
|
//获取当前登录人的用户id
|
||||||
String openId = TokenUtil.parseParamFromToken(token).getString("openId");
|
String openId = TokenUtil.parseParamFromToken(token).getString("openId");
|
||||||
message = redisUtil.getMessage(RedisCst.ONLINE_USER.concat(openId));
|
tokenKey=RedisCst.ONLINE_USER.concat(openId);
|
||||||
}
|
}
|
||||||
|
message = redisUtil.getMessage(tokenKey);
|
||||||
if (StringUtils.isBlank(message)) {
|
if (StringUtils.isBlank(message)) {
|
||||||
Result result = new Result(CodeEnum.TOKEN_EXPIRED);
|
Result result = new Result(CodeEnum.TOKEN_EXPIRED);
|
||||||
String jsonString = JSONObject.toJSONString(result);
|
String jsonString = JSONObject.toJSONString(result);
|
||||||
|
|
@ -131,9 +137,19 @@ public class LoginFilter implements Filter {
|
||||||
response.getWriter().flush();//流里边的缓存刷出
|
response.getWriter().flush();//流里边的缓存刷出
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
checkRenewal(tokenKey);
|
||||||
chain.doFilter(req, resp);
|
chain.doFilter(req, resp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Async
|
||||||
|
public void checkRenewal(String tokenKey) {
|
||||||
|
// 判断是否续期token,计算token的过期时间
|
||||||
|
long time = redisUtil.getRemainingTime(tokenKey);
|
||||||
|
if(time<60*60*24*10L){
|
||||||
|
redisUtil.setKeyExpirationTime(tokenKey,60*60*24*30L);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 判断url请求是否配置在urls列表中
|
* 判断url请求是否配置在urls列表中
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -4,11 +4,12 @@ import com.chaozhanggui.system.cashierservice.dao.TbPlatformDictMapper;
|
||||||
import com.chaozhanggui.system.cashierservice.entity.TbPlatformDict;
|
import com.chaozhanggui.system.cashierservice.entity.TbPlatformDict;
|
||||||
import com.chaozhanggui.system.cashierservice.entity.vo.DistrictVo;
|
import com.chaozhanggui.system.cashierservice.entity.vo.DistrictVo;
|
||||||
import com.chaozhanggui.system.cashierservice.exception.MsgException;
|
import com.chaozhanggui.system.cashierservice.exception.MsgException;
|
||||||
|
import com.chaozhanggui.system.cashierservice.redis.RedisCst;
|
||||||
|
import com.chaozhanggui.system.cashierservice.redis.RedisUtil;
|
||||||
import com.chaozhanggui.system.cashierservice.service.FileService;
|
import com.chaozhanggui.system.cashierservice.service.FileService;
|
||||||
import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
|
import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
|
||||||
import com.chaozhanggui.system.cashierservice.sign.Result;
|
import com.chaozhanggui.system.cashierservice.sign.Result;
|
||||||
import com.chaozhanggui.system.cashierservice.util.LocationUtils;
|
import com.chaozhanggui.system.cashierservice.util.LocationUtils;
|
||||||
import com.chaozhanggui.system.cashierservice.util.RedisUtils;
|
|
||||||
import com.chaozhanggui.system.cashierservice.util.StringUtil;
|
import com.chaozhanggui.system.cashierservice.util.StringUtil;
|
||||||
import com.chaozhanggui.system.cashierservice.util.ValidateCodeUtil;
|
import com.chaozhanggui.system.cashierservice.util.ValidateCodeUtil;
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
|
|
@ -16,12 +17,13 @@ import com.fasterxml.jackson.databind.JsonNode;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.scheduling.annotation.Async;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通用接口
|
* 通用接口
|
||||||
|
|
@ -34,8 +36,9 @@ import java.util.concurrent.TimeUnit;
|
||||||
public class CommonController {
|
public class CommonController {
|
||||||
|
|
||||||
private final ValidateCodeUtil validateCodeUtil;
|
private final ValidateCodeUtil validateCodeUtil;
|
||||||
@Resource
|
|
||||||
private RedisUtils redisUtils;
|
@Autowired
|
||||||
|
private RedisUtil redisUtil;
|
||||||
@Resource
|
@Resource
|
||||||
private TbPlatformDictMapper platformDictMapper;
|
private TbPlatformDictMapper platformDictMapper;
|
||||||
@Resource
|
@Resource
|
||||||
|
|
@ -52,15 +55,24 @@ public class CommonController {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@GetMapping("/phoneValidateCode")
|
@GetMapping("/phoneValidateCode")
|
||||||
public Result verifyPhoneIsExist(@RequestParam String phone) {
|
public Result phoneValidateCode(@RequestParam String phone) {
|
||||||
if (StringUtils.isBlank(phone)) {
|
if (StringUtils.isBlank(phone)) {
|
||||||
return Result.fail("手机号不可为空!");
|
return Result.fail("手机号不可为空!");
|
||||||
}
|
}
|
||||||
|
// 检查手机号格式是否正确
|
||||||
|
if (!isValidPhoneNumber(phone)) {
|
||||||
|
return Result.fail("手机号格式不正确!");
|
||||||
|
}
|
||||||
|
// 检查手机号请求次数是否超出限制
|
||||||
|
Result isOk = isRequestLimit(phone);
|
||||||
|
if (!isOk.getCode().equals("0")) {
|
||||||
|
return isOk;
|
||||||
|
}
|
||||||
String random = StringUtil.random(6);
|
String random = StringUtil.random(6);
|
||||||
validateCodeUtil.requestValidateCodeAli(phone, random);
|
validateCodeUtil.requestValidateCodeAli(phone, random);
|
||||||
//存入缓存
|
//存入缓存
|
||||||
try {
|
try {
|
||||||
redisUtils.set(phone, random, ONE_MINUTE, TimeUnit.SECONDS);
|
redisUtil.saveMessage(phone, random, 60L);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new MsgException("验证码发送失败");
|
throw new MsgException("验证码发送失败");
|
||||||
}
|
}
|
||||||
|
|
@ -119,4 +131,50 @@ public class CommonController {
|
||||||
public Result upload(MultipartFile file) throws Exception {
|
public Result upload(MultipartFile file) throws Exception {
|
||||||
return new Result(CodeEnum.SUCCESS, fileService.uploadFile(file));
|
return new Result(CodeEnum.SUCCESS, fileService.uploadFile(file));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 检查手机号格式是否正确的方法
|
||||||
|
private boolean isValidPhoneNumber(String phone) {
|
||||||
|
return phone.matches("^1[3-9]\\d{9}$");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查手机号请求次数是否超出限制的方法
|
||||||
|
public Result isRequestLimit(String phone) {
|
||||||
|
Object count = redisUtil.getMessage(RedisCst.PHONE_LIMIT + phone);
|
||||||
|
if (count != null && Integer.valueOf(count.toString()) >= 5) {
|
||||||
|
return Result.fail("请求次数超出限制!,请半小时后重试");
|
||||||
|
}
|
||||||
|
long time = redisUtil.getRemainingTime(phone);
|
||||||
|
if (time > 0) {
|
||||||
|
return Result.fail("请" + time + "秒后重试");
|
||||||
|
}
|
||||||
|
refreshPhoneLimit(phone,count != null);
|
||||||
|
return Result.success(CodeEnum.SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 从 Redis 中获取手机号码的请求次数的方法
|
||||||
|
@Async
|
||||||
|
public void refreshPhoneLimit(String phone,boolean isExist) {
|
||||||
|
if (isExist) {
|
||||||
|
phoneRequestrinc(RedisCst.PHONE_LIMIT + phone);
|
||||||
|
} else {
|
||||||
|
phoneRequestset(RedisCst.PHONE_LIMIT + phone);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 存储手机号和请求次数的对应关系 时间 半小时
|
||||||
|
*/
|
||||||
|
public void phoneRequestset(String key) {
|
||||||
|
// 使用 Hash 结构存储手机号和请求次数的对应关系 时间 半小时
|
||||||
|
redisUtil.saveMessage(key, "1", 60*30L);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将手机号码的请求次数加1
|
||||||
|
*/
|
||||||
|
public void phoneRequestrinc(String key) {
|
||||||
|
// 将手机号码的请求次数加1
|
||||||
|
redisUtil.getIncrNum(key, "2");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -38,7 +38,10 @@ public class OrderController {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@GetMapping ("/orderInfo")
|
@GetMapping ("/orderInfo")
|
||||||
private Result orderInfo(@RequestParam Integer orderId){
|
private Result orderInfo(@RequestParam(required = false) Integer orderId){
|
||||||
|
if (orderId==null) {
|
||||||
|
return Result.fail("请返回首页订单列表查看");
|
||||||
|
}
|
||||||
return orderService.orderInfo(orderId);
|
return orderService.orderInfo(orderId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,10 +30,10 @@ public class ProductController {
|
||||||
* @return shopid
|
* @return shopid
|
||||||
*/
|
*/
|
||||||
@RequestMapping("queryShopIdByTableCode")
|
@RequestMapping("queryShopIdByTableCode")
|
||||||
public Result queryShopIdByTableCode(@RequestHeader String token, @RequestParam("code") String code) {
|
public Result queryShopIdByTableCode(
|
||||||
JSONObject jsonObject = TokenUtil.parseParamFromToken(token);
|
@RequestHeader("openId") String openId,
|
||||||
String userId = jsonObject.getString("userId");
|
@RequestHeader("id") String userId,
|
||||||
String openId = jsonObject.getString("openId");
|
@RequestParam("code") String code) {
|
||||||
return productService.queryShopIdByTableCode(userId, openId, code);
|
return productService.queryShopIdByTableCode(userId, openId, code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,8 +20,6 @@ public interface TbCashierCartMapper {
|
||||||
|
|
||||||
int updateByPrimaryKeySelective(TbCashierCart record);
|
int updateByPrimaryKeySelective(TbCashierCart record);
|
||||||
|
|
||||||
int updateByPrimaryKey(TbCashierCart record);
|
|
||||||
|
|
||||||
|
|
||||||
List<TbCashierCart> selectALlByMasterId(@Param("masterId") String masterId, @Param("status") String status);
|
List<TbCashierCart> selectALlByMasterId(@Param("masterId") String masterId, @Param("status") String status);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
package com.chaozhanggui.system.cashierservice.entity.dto;
|
package com.chaozhanggui.system.cashierservice.entity.dto;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -27,4 +27,28 @@ public class HomeBaseDto extends BasePageDto{
|
||||||
private String distanceInKm;
|
private String distanceInKm;
|
||||||
|
|
||||||
private Integer isPage = 1;
|
private Integer isPage = 1;
|
||||||
|
|
||||||
|
public void setLat(String lat) {
|
||||||
|
if (StringUtils.isBlank(lat) || lat.equals("undefined")) {
|
||||||
|
this.lat = "34.343207";
|
||||||
|
}else {
|
||||||
|
this.lat = lat;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLng(String lng) {
|
||||||
|
if (StringUtils.isBlank(lng) || lng.equals("undefined")) {
|
||||||
|
this.lng = "108.939645";
|
||||||
|
}else {
|
||||||
|
this.lng = lng;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAddress(String address) {
|
||||||
|
if (StringUtils.isBlank(address) || address.equals("undefined")) {
|
||||||
|
this.address = "西安市";
|
||||||
|
}else {
|
||||||
|
this.address = address;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ public class CartConsumer {
|
||||||
@RabbitListener(queues = {"${queue}"})
|
@RabbitListener(queues = {"${queue}"})
|
||||||
public void listener(String message) {
|
public void listener(String message) {
|
||||||
try {
|
try {
|
||||||
|
log.info("监听数据进入 "+message);
|
||||||
JSONObject jsonObject = JSON.parseObject(message);
|
JSONObject jsonObject = JSON.parseObject(message);
|
||||||
String tableId = jsonObject.getString("tableId");
|
String tableId = jsonObject.getString("tableId");
|
||||||
String shopId = jsonObject.getString("shopId");
|
String shopId = jsonObject.getString("shopId");
|
||||||
|
|
@ -70,7 +71,8 @@ public class CartConsumer {
|
||||||
cartService.clearCart(jsonObject);
|
cartService.clearCart(jsonObject);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.getMessage();
|
log.info("数据处理失败:{}",e.getMessage());
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ public class RedisCst {
|
||||||
|
|
||||||
//在线用户
|
//在线用户
|
||||||
public static final String ONLINE_USER = "ONLINE_USER:";
|
public static final String ONLINE_USER = "ONLINE_USER:";
|
||||||
|
public static final String PHONE_LIMIT = "PHONE_LIMIT:";
|
||||||
public static final String ONLINE_APP_USER = "ONLINE_APP_USER:";
|
public static final String ONLINE_APP_USER = "ONLINE_APP_USER:";
|
||||||
public static final String LDBL_APP_VERSION = "LDBL_APP_VERSION:";
|
public static final String LDBL_APP_VERSION = "LDBL_APP_VERSION:";
|
||||||
public static final String TABLE_CART = "TABLE:CART:";
|
public static final String TABLE_CART = "TABLE:CART:";
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,5 @@
|
||||||
package com.chaozhanggui.system.cashierservice.redis;
|
package com.chaozhanggui.system.cashierservice.redis;
|
||||||
|
|
||||||
import com.chaozhanggui.system.cashierservice.socket.AppWebSocketServer;
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
|
@ -112,7 +110,7 @@ public class RedisUtil{
|
||||||
* @author wgc
|
* @author wgc
|
||||||
* @date 2018-12-19 19:49
|
* @date 2018-12-19 19:49
|
||||||
*/
|
*/
|
||||||
public Integer saveMessage(String key, String message, int expire) {
|
public Integer saveMessage(String key, String message, Long expire) {
|
||||||
Jedis jedis = null;
|
Jedis jedis = null;
|
||||||
try {
|
try {
|
||||||
if (StringUtils.isEmpty(key)) {
|
if (StringUtils.isEmpty(key)) {
|
||||||
|
|
@ -162,6 +160,53 @@ public class RedisUtil{
|
||||||
}
|
}
|
||||||
return flag;
|
return flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过key 获取数据的剩余存活时间
|
||||||
|
*/
|
||||||
|
public long getRemainingTime(String key) {
|
||||||
|
Jedis jedis = null;
|
||||||
|
long remainingTime = -1;
|
||||||
|
try {
|
||||||
|
// 从jedis池中获取一个jedis实例
|
||||||
|
jedis = pool.getResource();
|
||||||
|
if (database != 0) {
|
||||||
|
jedis.select(database);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取键的剩余生存时间
|
||||||
|
remainingTime = jedis.ttl(key);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} finally {
|
||||||
|
// 释放对象池,即获取jedis实例使用后要将对象还回去
|
||||||
|
if (jedis != null) {
|
||||||
|
jedis.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return remainingTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setKeyExpirationTime(String key, long seconds) {
|
||||||
|
Jedis jedis = null;
|
||||||
|
try {
|
||||||
|
// 从jedis池中获取一个jedis实例
|
||||||
|
jedis = pool.getResource();
|
||||||
|
if (database != 0) {
|
||||||
|
jedis.select(database);
|
||||||
|
}
|
||||||
|
// 设置键的存活时间
|
||||||
|
jedis.expire(key, seconds);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} finally {
|
||||||
|
// 释放对象池,即获取jedis实例使用后要将对象还回去
|
||||||
|
if (jedis != null) {
|
||||||
|
jedis.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param key
|
* @param key
|
||||||
* @param message
|
* @param message
|
||||||
|
|
|
||||||
|
|
@ -104,6 +104,7 @@ public class CartService {
|
||||||
TbCashierCart cashierCart = JSONUtil.parseJSONStr2T(object.toJSONString(), TbCashierCart.class);
|
TbCashierCart cashierCart = JSONUtil.parseJSONStr2T(object.toJSONString(), TbCashierCart.class);
|
||||||
if (cashierCart.getNumber() > 0) {
|
if (cashierCart.getNumber() > 0) {
|
||||||
cashierCart.setTotalAmount(new BigDecimal(cashierCart.getTotalNumber()).multiply(cashierCart.getSalePrice().add(cashierCart.getPackFee())));
|
cashierCart.setTotalAmount(new BigDecimal(cashierCart.getTotalNumber()).multiply(cashierCart.getSalePrice().add(cashierCart.getPackFee())));
|
||||||
|
cashierCart.setUserId(jsonObject.getIntValue("userId"));
|
||||||
if (StringUtils.isNotEmpty(cashierCart.getStatus())) {
|
if (StringUtils.isNotEmpty(cashierCart.getStatus())) {
|
||||||
cashierCart.setStatus("create");
|
cashierCart.setStatus("create");
|
||||||
}
|
}
|
||||||
|
|
@ -150,6 +151,7 @@ public class CartService {
|
||||||
|
|
||||||
private TbCashierCart addCart(String productId, String skuId, Integer userId, Integer num, String tableId, String shopId) throws Exception {
|
private TbCashierCart addCart(String productId, String skuId, Integer userId, Integer num, String tableId, String shopId) throws Exception {
|
||||||
try {
|
try {
|
||||||
|
//productId 235 skuId 85 userId 78 num 1 tableId 55246240 shopId 10
|
||||||
TbProduct product = productMapper.selectById(Integer.valueOf(productId));
|
TbProduct product = productMapper.selectById(Integer.valueOf(productId));
|
||||||
String key=tableId+"-"+shopId;
|
String key=tableId+"-"+shopId;
|
||||||
if (Objects.isNull(product)) {
|
if (Objects.isNull(product)) {
|
||||||
|
|
@ -182,7 +184,6 @@ public class CartService {
|
||||||
cashierCart.setSkuName(productSku.getSpecSnap());
|
cashierCart.setSkuName(productSku.getSpecSnap());
|
||||||
cashierCart.setIsPack("false");
|
cashierCart.setIsPack("false");
|
||||||
cashierCart.setIsGift("false");
|
cashierCart.setIsGift("false");
|
||||||
cashierCart.setUserId(userId);
|
|
||||||
cashierCart.setStatus("create");
|
cashierCart.setStatus("create");
|
||||||
cashierCart.setType((byte) 0);
|
cashierCart.setType((byte) 0);
|
||||||
cashierCart.setSalePrice(productSku.getSalePrice());
|
cashierCart.setSalePrice(productSku.getSalePrice());
|
||||||
|
|
@ -694,7 +695,7 @@ public class CartService {
|
||||||
jsonObject1.put("type", jsonObject.getString("type"));
|
jsonObject1.put("type", jsonObject.getString("type"));
|
||||||
jsonObject1.put("data", orderInfo);
|
jsonObject1.put("data", orderInfo);
|
||||||
redisUtil.deleteByKey(RedisCst.TABLE_CART.concat(jsonObject.getString("tableId")).concat("-").concat(shopId));
|
redisUtil.deleteByKey(RedisCst.TABLE_CART.concat(jsonObject.getString("tableId")).concat("-").concat(shopId));
|
||||||
redisUtil.saveMessage(RedisCst.TABLE_ORDER.concat(orderInfo.getOrderNo()), JSONObject.toJSONString(orderInfo), 24 * 60 * 60);
|
redisUtil.saveMessage(RedisCst.TABLE_ORDER.concat(orderInfo.getOrderNo()), JSONObject.toJSONString(orderInfo), 24 * 60 * 60L);
|
||||||
AppWebSocketServer.AppSendInfo(jsonObject1,key, jsonObject.getString("userId"), true);
|
AppWebSocketServer.AppSendInfo(jsonObject1,key, jsonObject.getString("userId"), true);
|
||||||
JSONObject jsonObject12 = new JSONObject();
|
JSONObject jsonObject12 = new JSONObject();
|
||||||
jsonObject12.put("status", "success");
|
jsonObject12.put("status", "success");
|
||||||
|
|
|
||||||
|
|
@ -125,7 +125,7 @@ public class LoginService {
|
||||||
try {
|
try {
|
||||||
map.put("token", token);
|
map.put("token", token);
|
||||||
map.put("userInfo", userInfo);
|
map.put("userInfo", userInfo);
|
||||||
redisUtil.saveMessage(RedisCst.ONLINE_USER.concat(openId), JSON.toJSONString(map));
|
redisUtil.saveMessage(RedisCst.ONLINE_USER.concat(openId), JSON.toJSONString(map),60*60*24*30L);
|
||||||
//redis里 获取要关注的公众号信息
|
//redis里 获取要关注的公众号信息
|
||||||
//userInfo 某字段存储关注公众号的标识
|
//userInfo 某字段存储关注公众号的标识
|
||||||
// userInfo.get
|
// userInfo.get
|
||||||
|
|
|
||||||
|
|
@ -312,9 +312,10 @@ public class PayService {
|
||||||
return Result.fail("未获取到用户信息");
|
return Result.fail("未获取到用户信息");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(StringUtils.isBlank(userInfo.getPwd())){
|
||||||
|
// return Result.fail("支付密码未设置");
|
||||||
|
return Result.success(CodeEnum.SUCCESS,"3");
|
||||||
|
}
|
||||||
if(!userInfo.getPwd().equals(MD5Utils.md5(pwd))){
|
if(!userInfo.getPwd().equals(MD5Utils.md5(pwd))){
|
||||||
return Result.fail("支付密码错误");
|
return Result.fail("支付密码错误");
|
||||||
}
|
}
|
||||||
|
|
@ -332,12 +333,14 @@ public class PayService {
|
||||||
|
|
||||||
|
|
||||||
TbShopUser user = tbShopUserMapper.selectByPrimaryKey(memberId);
|
TbShopUser user = tbShopUserMapper.selectByPrimaryKey(memberId);
|
||||||
if (ObjectUtil.isEmpty(user) || !"1".equals(user.getIsVip().toString())) {
|
if (ObjectUtil.isEmpty(user) || user.getIsVip()==null || !"1".equals(user.getIsVip().toString())) {
|
||||||
return Result.failCode("会员卡余额不足","1");
|
// return Result.failCode("会员卡余额不足","1");
|
||||||
|
return Result.success(CodeEnum.SUCCESS,"4");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (N.gt(orderInfo.getOrderAmount(), user.getAmount())) {
|
if (N.gt(orderInfo.getOrderAmount(), user.getAmount())) {
|
||||||
return Result.failCode("会员卡余额不足","2");
|
// return Result.failCode("会员卡余额不足","2");
|
||||||
|
return Result.success(CodeEnum.SUCCESS,"2");
|
||||||
}
|
}
|
||||||
|
|
||||||
user.setAmount(user.getAmount().subtract(orderInfo.getOrderAmount()));
|
user.setAmount(user.getAmount().subtract(orderInfo.getOrderAmount()));
|
||||||
|
|
@ -382,7 +385,7 @@ public class PayService {
|
||||||
|
|
||||||
producer.printMechine(orderId);
|
producer.printMechine(orderId);
|
||||||
|
|
||||||
return Result.success(CodeEnum.SUCCESS);
|
return Result.success(CodeEnum.SUCCESS,"1");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -75,31 +75,36 @@ public class ProductService {
|
||||||
}
|
}
|
||||||
|
|
||||||
TbShopUser tbShopUser = tbShopUserMapper.selectByUserIdAndShopId(userId, shopId);
|
TbShopUser tbShopUser = tbShopUserMapper.selectByUserIdAndShopId(userId, shopId);
|
||||||
if (ObjectUtil.isEmpty(tbShopUser)) {
|
try{
|
||||||
TbUserInfo tbUserInfo = tbUserInfoMapper.selectByPrimaryKey(Integer.valueOf(userId));
|
if (ObjectUtil.isEmpty(tbShopUser)) {
|
||||||
tbShopUser = new TbShopUser();
|
TbUserInfo tbUserInfo = tbUserInfoMapper.selectByPrimaryKey(Integer.valueOf(userId));
|
||||||
tbShopUser.setName(tbUserInfo.getNickName());
|
tbShopUser = new TbShopUser();
|
||||||
tbShopUser.setSex(tbUserInfo.getSex());
|
tbShopUser.setName(tbUserInfo.getNickName());
|
||||||
tbShopUser.setBirthDay(tbUserInfo.getBirthDay());
|
tbShopUser.setSex(tbUserInfo.getSex());
|
||||||
tbShopUser.setLevel(Byte.parseByte("1"));
|
tbShopUser.setBirthDay(tbUserInfo.getBirthDay());
|
||||||
tbShopUser.setCode(RandomUtil.randomNumbers(8));
|
tbShopUser.setLevel(Byte.parseByte("1"));
|
||||||
tbShopUser.setTelephone(tbUserInfo.getTelephone());
|
tbShopUser.setCode(RandomUtil.randomNumbers(8));
|
||||||
tbShopUser.setAmount(BigDecimal.ZERO);
|
tbShopUser.setTelephone(tbUserInfo.getTelephone());
|
||||||
tbShopUser.setIsVip(Byte.parseByte("0"));
|
tbShopUser.setAmount(BigDecimal.ZERO);
|
||||||
tbShopUser.setCreditAmount(BigDecimal.ZERO);
|
tbShopUser.setIsVip(Byte.parseByte("0"));
|
||||||
tbShopUser.setConsumeAmount(BigDecimal.ZERO);
|
tbShopUser.setCreditAmount(BigDecimal.ZERO);
|
||||||
tbShopUser.setConsumeNumber(0);
|
tbShopUser.setConsumeAmount(BigDecimal.ZERO);
|
||||||
tbShopUser.setLevelConsume(BigDecimal.ZERO);
|
tbShopUser.setConsumeNumber(0);
|
||||||
tbShopUser.setStatus(Byte.parseByte("1"));
|
tbShopUser.setLevelConsume(BigDecimal.ZERO);
|
||||||
tbShopUser.setShopId(shopId);
|
tbShopUser.setStatus(Byte.parseByte("1"));
|
||||||
tbShopUser.setUserId(userId);
|
tbShopUser.setShopId(shopId);
|
||||||
tbShopUser.setMiniOpenId(openId);
|
tbShopUser.setUserId(userId);
|
||||||
tbShopUser.setCreatedAt(System.currentTimeMillis());
|
tbShopUser.setMiniOpenId(openId);
|
||||||
tbShopUser.setUpdatedAt(System.currentTimeMillis());
|
tbShopUser.setCreatedAt(System.currentTimeMillis());
|
||||||
tbShopUserMapper.insert(tbShopUser);
|
tbShopUser.setUpdatedAt(System.currentTimeMillis());
|
||||||
} else {
|
tbShopUserMapper.insert(tbShopUser);
|
||||||
tbShopUser.setUpdatedAt(System.currentTimeMillis());
|
} else {
|
||||||
tbShopUserMapper.updateByPrimaryKey(tbShopUser);
|
tbShopUser.setUpdatedAt(System.currentTimeMillis());
|
||||||
|
tbShopUserMapper.updateByPrimaryKey(tbShopUser);
|
||||||
|
}
|
||||||
|
}catch (Exception e){
|
||||||
|
log.info("通过桌码获取shopId 进行用户绑定错误:{}",e.getMessage());
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return Result.success(CodeEnum.SUCCESS, shopId);
|
return Result.success(CodeEnum.SUCCESS, shopId);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ import java.util.*;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
@ServerEndpoint(value = "/websocket/table/{tableId}/{shopId}/{userId}", encoders = WebSocketCustomEncoding.class)
|
@ServerEndpoint(value = "/websocket/table", encoders = WebSocketCustomEncoding.class)
|
||||||
@Component
|
@Component
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Data
|
@Data
|
||||||
|
|
@ -56,10 +56,6 @@ public class AppWebSocketServer {
|
||||||
//一个 AppWebSocketServer 就是一个用户,一个tableId下有一个 List<AppWebSocketServer> 也就是多个用户
|
//一个 AppWebSocketServer 就是一个用户,一个tableId下有一个 List<AppWebSocketServer> 也就是多个用户
|
||||||
private static HashMap<String, ConcurrentHashMap<String, AppWebSocketServer>> webSocketMap = new HashMap<>();
|
private static HashMap<String, ConcurrentHashMap<String, AppWebSocketServer>> webSocketMap = new HashMap<>();
|
||||||
public static ConcurrentHashMap<String, Set<String>> userMap = new ConcurrentHashMap<>();
|
public static ConcurrentHashMap<String, Set<String>> userMap = new ConcurrentHashMap<>();
|
||||||
// private static ConcurrentHashMap<String, AppWebSocketServer> userSocketMap = new ConcurrentHashMap<>();
|
|
||||||
//购物车的记录,用于第一次扫码的人同步购物车
|
|
||||||
// private static ConcurrentHashMap<String, List<JSONObject>> recordMap = new ConcurrentHashMap<>();
|
|
||||||
// private static ConcurrentHashMap<String, Session> sessionMap = new ConcurrentHashMap<>();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 与某个客户端的连接会话,需要通过它来给客户端发送数据
|
* 与某个客户端的连接会话,需要通过它来给客户端发送数据
|
||||||
|
|
@ -85,9 +81,16 @@ public class AppWebSocketServer {
|
||||||
* 连接建立成功调用的方法
|
* 连接建立成功调用的方法
|
||||||
*/
|
*/
|
||||||
@OnOpen
|
@OnOpen
|
||||||
public void onOpen(Session session, @PathParam("tableId") String tableId, @PathParam("shopId") String shopId, @PathParam("userId") String userId) {
|
public void onOpen(Session session) {
|
||||||
log.info("建立连接参数 tableId:{} shopId:{} userId:{}",tableId,shopId,userId);
|
|
||||||
this.session = session;
|
this.session = session;
|
||||||
|
log.info("建立连接开始");
|
||||||
|
// public void onOpen(Session session, @PathParam("tableId") String tableId, @PathParam("shopId") String shopId, @PathParam("userId") String userId) {
|
||||||
|
Map<String, String> queryParams = getParamMap();
|
||||||
|
String tableId = queryParams.get("tableId");
|
||||||
|
String shopId = queryParams.get("shopId");
|
||||||
|
String userId = queryParams.get("userId");
|
||||||
|
|
||||||
|
log.info("建立连接参数 tableId:{} shopId:{} userId:{}",tableId,shopId,userId);
|
||||||
this.tableId = tableId;
|
this.tableId = tableId;
|
||||||
this.shopId = shopId;
|
this.shopId = shopId;
|
||||||
this.userId = userId;
|
this.userId = userId;
|
||||||
|
|
@ -115,13 +118,13 @@ public class AppWebSocketServer {
|
||||||
webSocketMap.put(key,userSocketMap);
|
webSocketMap.put(key,userSocketMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (userMap.containsKey(key)) {
|
if (userMap.containsKey(tableId)) {
|
||||||
Set<String> userSet = userMap.get(key);
|
Set<String> userSet = userMap.get(tableId);
|
||||||
userSet.add(userId);
|
userSet.add(userId);
|
||||||
} else {
|
} else {
|
||||||
Set<String> userSet = new HashSet<>();
|
Set<String> userSet = new HashSet<>();
|
||||||
userSet.add(userId);
|
userSet.add(userId);
|
||||||
userMap.put(key,userSet);
|
userMap.put(tableId,userSet);
|
||||||
}
|
}
|
||||||
String mes = redisUtils.getMessage(RedisCst.TABLE_CART.concat(key));
|
String mes = redisUtils.getMessage(RedisCst.TABLE_CART.concat(key));
|
||||||
if (StringUtils.isEmpty(mes)) {
|
if (StringUtils.isEmpty(mes)) {
|
||||||
|
|
@ -166,8 +169,8 @@ public class AppWebSocketServer {
|
||||||
userSocketMap.remove(userId);
|
userSocketMap.remove(userId);
|
||||||
log.info("存在的 {}用户数3为:{}",key,userSocketMap.size());
|
log.info("存在的 {}用户数3为:{}",key,userSocketMap.size());
|
||||||
}
|
}
|
||||||
if (userMap.containsKey(tableId + "-" + shopId)){
|
if (userMap.containsKey(tableId)){
|
||||||
Set<String> userSet = userMap.get(tableId + "-" + shopId);
|
Set<String> userSet = userMap.get(tableId);
|
||||||
userSet.remove(userId);
|
userSet.remove(userId);
|
||||||
// if (userSet.isEmpty()){
|
// if (userSet.isEmpty()){
|
||||||
// userMap.remove(tableId + "-" + shopId);
|
// userMap.remove(tableId + "-" + shopId);
|
||||||
|
|
@ -182,8 +185,7 @@ public class AppWebSocketServer {
|
||||||
*/
|
*/
|
||||||
@OnMessage
|
@OnMessage
|
||||||
public void onMessage(String message, Session session) {
|
public void onMessage(String message, Session session) {
|
||||||
|
log.info("接收消息 tableId:{} shopId:{} userId:{} message:{}",this.tableId,this.shopId,this.userId,message);
|
||||||
log.info("接收消息:"+message);
|
|
||||||
//可以群发消息
|
//可以群发消息
|
||||||
//消息保存到数据库、redis
|
//消息保存到数据库、redis
|
||||||
if (StringUtils.isNotBlank(message) && !message.equals("undefined")) {
|
if (StringUtils.isNotBlank(message) && !message.equals("undefined")) {
|
||||||
|
|
@ -196,10 +198,10 @@ public class AppWebSocketServer {
|
||||||
//追加发送人(防止串改)
|
//追加发送人(防止串改)
|
||||||
jsonObject.put("tableId", this.tableId);
|
jsonObject.put("tableId", this.tableId);
|
||||||
jsonObject.put("shopId", this.shopId);
|
jsonObject.put("shopId", this.shopId);
|
||||||
log.info("tableId:"+this.tableId);
|
// log.info("tableId:"+this.tableId);
|
||||||
log.info("shopId:"+this.shopId);
|
// log.info("shopId:"+this.shopId);
|
||||||
if (userMap.containsKey(tableId + "-" + shopId)) {
|
if (userMap.containsKey(tableId)) {
|
||||||
Set<String> userSet = userMap.get(tableId + "-" + shopId);
|
Set<String> userSet = userMap.get(tableId);
|
||||||
userSet.add(userId);
|
userSet.add(userId);
|
||||||
}
|
}
|
||||||
if (webSocketMap.containsKey(tableId+"-"+shopId)) {
|
if (webSocketMap.containsKey(tableId+"-"+shopId)) {
|
||||||
|
|
@ -258,6 +260,7 @@ public class AppWebSocketServer {
|
||||||
@OnError
|
@OnError
|
||||||
public void onError(Session session, Throwable error) throws IOException {
|
public void onError(Session session, Throwable error) throws IOException {
|
||||||
log.error("用户错误:" + this.tableId + ",原因:" + error.getMessage());
|
log.error("用户错误:" + this.tableId + ",原因:" + error.getMessage());
|
||||||
|
// error.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -289,7 +292,7 @@ public class AppWebSocketServer {
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
public static void AppSendInfo(Object message, String tableId,String userId, boolean userFlag) throws IOException {
|
public static void AppSendInfo(Object message, String tableId,String userId, boolean userFlag) throws IOException {
|
||||||
log.info("发送消息 tableId:{} \n userId:{}\n userFlag:{}\n message:{}",tableId,userId,userFlag,JSONUtil.toJSONString(message));
|
log.info("发送消息 tableId:{} userId:{} userFlag:{} message:{}",tableId,userId,userFlag,JSONUtil.toJSONString(message));
|
||||||
if (userFlag) {
|
if (userFlag) {
|
||||||
if (webSocketMap.containsKey(tableId)) {
|
if (webSocketMap.containsKey(tableId)) {
|
||||||
ConcurrentHashMap<String, AppWebSocketServer> userSocketMap = webSocketMap.get(tableId);
|
ConcurrentHashMap<String, AppWebSocketServer> userSocketMap = webSocketMap.get(tableId);
|
||||||
|
|
@ -325,6 +328,26 @@ public class AppWebSocketServer {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Map<String,String> getParamMap(){
|
||||||
|
// 获取连接建立时传递的参数
|
||||||
|
Map<String, List<String>> queryParams = session.getRequestParameterMap();
|
||||||
|
// 创建新的Map来存储转换后的参数
|
||||||
|
Map<String, String> parameterMap = new HashMap<>();
|
||||||
|
|
||||||
|
// 遍历原始参数Map的键值对
|
||||||
|
for (Map.Entry<String, List<String>> entry : queryParams.entrySet()) {
|
||||||
|
String key = entry.getKey();
|
||||||
|
List<String> values = entry.getValue();
|
||||||
|
|
||||||
|
// 如果值列表不为空,则将第一个值作为键的值存储在新的Map中
|
||||||
|
if (!values.isEmpty()) {
|
||||||
|
String value = values.get(0);
|
||||||
|
parameterMap.put(key, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return parameterMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// public static synchronized ConcurrentHashMap<String, Set<AppWebSocketServer>> getWebSocketMap() {
|
// public static synchronized ConcurrentHashMap<String, Set<AppWebSocketServer>> getWebSocketMap() {
|
||||||
// return AppWebSocketServer.webSocketMap;
|
// return AppWebSocketServer.webSocketMap;
|
||||||
|
|
|
||||||
|
|
@ -286,6 +286,11 @@ public class RedisUtils {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Long strincrement(String key, long delta) {
|
||||||
|
return stringRedisTemplate.opsForValue().increment(key, delta);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 普通缓存放入并设置时间
|
* 普通缓存放入并设置时间
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,12 @@
|
||||||
package com.chaozhanggui.system.cashierservice.util;
|
package com.chaozhanggui.system.cashierservice.util;
|
||||||
|
|
||||||
import cn.hutool.core.util.IdUtil;
|
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import io.jsonwebtoken.Claims;
|
import io.jsonwebtoken.Claims;
|
||||||
import io.jsonwebtoken.JwtBuilder;
|
|
||||||
import io.jsonwebtoken.Jwts;
|
import io.jsonwebtoken.Jwts;
|
||||||
import io.jsonwebtoken.SignatureAlgorithm;
|
import io.jsonwebtoken.SignatureAlgorithm;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
@ -25,7 +21,7 @@ public class TokenUtil {
|
||||||
/**
|
/**
|
||||||
* 设置过期时间
|
* 设置过期时间
|
||||||
*/
|
*/
|
||||||
public static final long EXPIRE_DATE=24*60*60*1000*365;
|
public static final long EXPIRE_DATE=24L*60*60*1000*365;
|
||||||
/**
|
/**
|
||||||
* token秘钥
|
* token秘钥
|
||||||
*/
|
*/
|
||||||
|
|
@ -65,10 +61,10 @@ public class TokenUtil {
|
||||||
* @param claims
|
* @param claims
|
||||||
* @return String
|
* @return String
|
||||||
*/
|
*/
|
||||||
private static String generateToken(Map<String, Object> claims) throws Exception {
|
private static String generateToken(Map<String, Object> claims) {
|
||||||
return Jwts.builder()
|
return Jwts.builder()
|
||||||
.setClaims(claims)
|
.setClaims(claims)
|
||||||
// .setExpiration(new Date(System.currentTimeMillis()+EXPIRE_DATE))
|
.setExpiration(new Date(System.currentTimeMillis()+EXPIRE_DATE))
|
||||||
.setIssuedAt(new Date())
|
.setIssuedAt(new Date())
|
||||||
.signWith(SignatureAlgorithm.HS256,TOKEN_SECRET)
|
.signWith(SignatureAlgorithm.HS256,TOKEN_SECRET)
|
||||||
.compact();
|
.compact();
|
||||||
|
|
@ -117,12 +113,13 @@ public class TokenUtil {
|
||||||
jsonObject = (JSONObject) JSONObject.toJSON(claims);
|
jsonObject = (JSONObject) JSONObject.toJSON(claims);
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
jsonObject.put("status","-4");
|
jsonObject.put("status","-4");
|
||||||
|
jsonObject.put("message","token解析失败了");
|
||||||
log.info("token解析失败{}",e.getMessage());
|
log.info("token解析失败{}",e.getMessage());
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return jsonObject;
|
return jsonObject;
|
||||||
}
|
}
|
||||||
// public static void main(String[] args){
|
// public static void main(String[] args) throws Exception {
|
||||||
// System.out.println(refreshToken("eyJhbGciOiJIUzUxMiJ9.eyJleHAiOjE1OTY4Nzc5MjEsInN1YiI6ImRkZGRkIiwiaWF0IjoxNTk2Njk3OTIxfQ.lrg3KF9h9izbmyD2q5onqnZIKBqanWy9xCcroFpjxPKmJz6kz27G9lVlFpVanrL1I4SFf3Dz3q3Xu01DX2T_dw"));
|
// System.out.println(refreshToken("eyJhbGciOiJIUzUxMiJ9.eyJleHAiOjE1OTY4Nzc5MjEsInN1YiI6ImRkZGRkIiwiaWF0IjoxNTk2Njk3OTIxfQ.lrg3KF9h9izbmyD2q5onqnZIKBqanWy9xCcroFpjxPKmJz6kz27G9lVlFpVanrL1I4SFf3Dz3q3Xu01DX2T_dw"));
|
||||||
// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
// Calendar cld = Calendar.getInstance();
|
// Calendar cld = Calendar.getInstance();
|
||||||
|
|
|
||||||
|
|
@ -58,8 +58,11 @@ ysk:
|
||||||
callBackGroupurl: https://wxcashiertest.sxczgkj.cn/cashierService/notify/notifyCallBackGroup
|
callBackGroupurl: https://wxcashiertest.sxczgkj.cn/cashierService/notify/notifyCallBackGroup
|
||||||
callBackIn: https://p40312246f.goho.co/cashierService/notify/memberInCallBack
|
callBackIn: https://p40312246f.goho.co/cashierService/notify/memberInCallBack
|
||||||
default: 18710449883
|
default: 18710449883
|
||||||
|
thirdPay:
|
||||||
|
callInBack: https://wxcashiertest.sxczgkj.cn/cashierService/notify/fstmemberInCallBack
|
||||||
|
callFSTBack: https://wxcashiertest.sxczgkj.cn/cashierService/notify/notifyfstCallBack
|
||||||
server:
|
server:
|
||||||
port: 9889
|
port: 9888
|
||||||
prod: dev1
|
prod: dev1
|
||||||
queue: cart_queue_putdev1
|
queue: cart_queue_putdev1
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -55,6 +55,9 @@ ysk:
|
||||||
callBackGroupurl: https://wxcashiertest.sxczgkj.cn/cashierService/notify/notifyCallBackGroup
|
callBackGroupurl: https://wxcashiertest.sxczgkj.cn/cashierService/notify/notifyCallBackGroup
|
||||||
callBackIn: https://p40312246f.goho.co/cashierService/notify/memberInCallBack
|
callBackIn: https://p40312246f.goho.co/cashierService/notify/memberInCallBack
|
||||||
default: 18710449883
|
default: 18710449883
|
||||||
|
thirdPay:
|
||||||
|
callInBack: https://wxcashiertest.sxczgkj.cn/cashierService/notify/fstmemberInCallBack
|
||||||
|
callFSTBack: https://wxcashiertest.sxczgkj.cn/cashierService/notify/notifyfstCallBack
|
||||||
server:
|
server:
|
||||||
port: 9889
|
port: 9889
|
||||||
prod: devyhq
|
prod: devyhq
|
||||||
|
|
|
||||||
|
|
@ -57,6 +57,9 @@ ysk:
|
||||||
callBackGroupurl: https://cashier.sxczgkj.cn/cashierService/notify/notifyCallBackGroup
|
callBackGroupurl: https://cashier.sxczgkj.cn/cashierService/notify/notifyCallBackGroup
|
||||||
callBackIn: https://cashier.sxczgkj.cn/cashierService/notify/memberInCallBack
|
callBackIn: https://cashier.sxczgkj.cn/cashierService/notify/memberInCallBack
|
||||||
default: 19191703856
|
default: 19191703856
|
||||||
|
thirdPay:
|
||||||
|
callInBack: https://cashier.sxczgkj.cn${server.servlet.context-path}notify/fstmemberInCallBack
|
||||||
|
callFSTBack: https://cashier.sxczgkj.cn${server.servlet.context-path}notify/notifyfstCallBack
|
||||||
prod: prod1
|
prod: prod1
|
||||||
queue: cart_queue_putprod1
|
queue: cart_queue_putprod1
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -57,6 +57,9 @@ ysk:
|
||||||
callBackGroupurl: https://cashier.sxczgkj.cn/cashierService/notify/notifyCallBackGroup
|
callBackGroupurl: https://cashier.sxczgkj.cn/cashierService/notify/notifyCallBackGroup
|
||||||
callBackIn: https://cashier.sxczgkj.cn/cashierService/notify/memberInCallBack
|
callBackIn: https://cashier.sxczgkj.cn/cashierService/notify/memberInCallBack
|
||||||
default: 19191703856
|
default: 19191703856
|
||||||
|
thirdPay:
|
||||||
|
callInBack: https://cashier.sxczgkj.cn${server.servlet.context-path}notify/fstmemberInCallBack
|
||||||
|
callFSTBack: https://cashier.sxczgkj.cn${server.servlet.context-path}notify/notifyfstCallBack
|
||||||
prod: prod2
|
prod: prod2
|
||||||
queue: cart_queue_putprod2
|
queue: cart_queue_putprod2
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,8 @@ wx:
|
||||||
custom:
|
custom:
|
||||||
appId: wxd88fffa983758a30
|
appId: wxd88fffa983758a30
|
||||||
secrete: a34a61adc0602118b49400baa8812454
|
secrete: a34a61adc0602118b49400baa8812454
|
||||||
|
# appId: wxc2bb94c0ddda1032
|
||||||
|
# secrete: 5fe6b30f688ae461561250ed3e3db35b
|
||||||
# 卓尔
|
# 卓尔
|
||||||
# appId: wx0dcea6001b0a8fb4
|
# appId: wx0dcea6001b0a8fb4
|
||||||
# secrete: ba42423cce61f93f02519ff3030ceb1c
|
# secrete: ba42423cce61f93f02519ff3030ceb1c
|
||||||
|
|
@ -60,6 +62,4 @@ aliyun:
|
||||||
|
|
||||||
thirdPay:
|
thirdPay:
|
||||||
payType: fushangtong
|
payType: fushangtong
|
||||||
callInBack: https://cashier.sxczgkj.cn${server.servlet.context-path}notify/fstmemberInCallBack
|
|
||||||
callFSTBack: https://cashier.sxczgkj.cn${server.servlet.context-path}notify/notifyfstCallBack
|
|
||||||
url: https://paymentapi.sxczgkj.cn
|
url: https://paymentapi.sxczgkj.cn
|
||||||
|
|
|
||||||
|
|
@ -310,6 +310,9 @@
|
||||||
<if test="updatedAt != null">
|
<if test="updatedAt != null">
|
||||||
updated_at = #{updatedAt,jdbcType=BIGINT},
|
updated_at = #{updatedAt,jdbcType=BIGINT},
|
||||||
</if>
|
</if>
|
||||||
|
<if test="userId != null">
|
||||||
|
user_id=#{userId,jdbcType=INTEGER},
|
||||||
|
</if>
|
||||||
<if test="pendingAt != null">
|
<if test="pendingAt != null">
|
||||||
pending_at = #{pendingAt,jdbcType=BIGINT},
|
pending_at = #{pendingAt,jdbcType=BIGINT},
|
||||||
</if>
|
</if>
|
||||||
|
|
@ -322,30 +325,7 @@
|
||||||
</set>
|
</set>
|
||||||
where id = #{id,jdbcType=INTEGER}
|
where id = #{id,jdbcType=INTEGER}
|
||||||
</update>
|
</update>
|
||||||
<update id="updateByPrimaryKey" parameterType="com.chaozhanggui.system.cashierservice.entity.TbCashierCart">
|
|
||||||
update tb_cashier_cart
|
|
||||||
set master_id = #{masterId,jdbcType=VARCHAR},
|
|
||||||
order_id = #{orderId,jdbcType=VARCHAR},
|
|
||||||
ref_order_id = #{refOrderId,jdbcType=VARCHAR},
|
|
||||||
total_amount = #{totalAmount,jdbcType=DECIMAL},
|
|
||||||
product_id = #{productId,jdbcType=VARCHAR},
|
|
||||||
cover_img = #{coverImg,jdbcType=VARCHAR},
|
|
||||||
is_sku = #{isSku,jdbcType=TINYINT},
|
|
||||||
sku_id = #{skuId,jdbcType=VARCHAR},
|
|
||||||
name = #{name,jdbcType=VARCHAR},
|
|
||||||
sale_price = #{salePrice,jdbcType=DECIMAL},
|
|
||||||
number = #{number,jdbcType=REAL},
|
|
||||||
total_number = #{totalNumber,jdbcType=REAL},
|
|
||||||
refund_number = #{refundNumber,jdbcType=REAL},
|
|
||||||
category_id = #{categoryId,jdbcType=VARCHAR},
|
|
||||||
status = #{status,jdbcType=VARCHAR},
|
|
||||||
type = #{type,jdbcType=TINYINT},
|
|
||||||
merchant_id = #{merchantId,jdbcType=VARCHAR},
|
|
||||||
shop_id = #{shopId,jdbcType=VARCHAR},
|
|
||||||
created_at = #{createdAt,jdbcType=BIGINT},
|
|
||||||
updated_at = #{updatedAt,jdbcType=BIGINT}
|
|
||||||
where id = #{id,jdbcType=INTEGER}
|
|
||||||
</update>
|
|
||||||
<update id="updateStatus">
|
<update id="updateStatus">
|
||||||
update tb_cashier_cart set status = #{status} where id = #{id}
|
update tb_cashier_cart set status = #{status} where id = #{id}
|
||||||
</update>
|
</update>
|
||||||
|
|
|
||||||
|
|
@ -924,6 +924,7 @@
|
||||||
AND t.product_id = #{productId}
|
AND t.product_id = #{productId}
|
||||||
AND t.`status` = 'create'
|
AND t.`status` = 'create'
|
||||||
AND t.table_id = #{code}
|
AND t.table_id = #{code}
|
||||||
|
AND user_id IN
|
||||||
<foreach collection="list" index="index" item="item" open="(" separator="," close=")">
|
<foreach collection="list" index="index" item="item" open="(" separator="," close=")">
|
||||||
#{item}
|
#{item}
|
||||||
</foreach>
|
</foreach>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue