Merge branch 'refs/heads/dev'
This commit is contained in:
commit
31ca409423
|
|
@ -1 +1,12 @@
|
||||||
/target/
|
### IDEA ###
|
||||||
|
/target/**/*
|
||||||
|
/log/*
|
||||||
|
.idea/*
|
||||||
|
*.iml
|
||||||
|
*/target/*
|
||||||
|
*/*.iml
|
||||||
|
/.gradle/
|
||||||
|
/application.pid
|
||||||
|
/target/*
|
||||||
|
**.jar
|
||||||
|
**.log
|
||||||
|
|
@ -38,6 +38,9 @@ public interface TbProductMapper {
|
||||||
|
|
||||||
void updateStockById(@Param("productId") String productId, @Param("num") Integer num);
|
void updateStockById(@Param("productId") String productId, @Param("num") Integer num);
|
||||||
|
|
||||||
@Update("update tb_product set stock_number=stock_number-#{num} WHERE id=#{id} and stock_number-#{num} > 0")
|
@Update("update tb_product set stock_number=stock_number-#{num} WHERE id=#{id} and stock_number-#{num} >= 0")
|
||||||
int decrStock(@Param("id") String id, @Param("num") Integer num);
|
int decrStock(@Param("id") String id, @Param("num") Integer num);
|
||||||
|
|
||||||
|
@Update("update tb_product set stock_number=stock_number-#{num} WHERE id=#{id}")
|
||||||
|
int decrStockUnCheck(@Param("id") String id, @Param("num") Integer num);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,9 @@ public interface TbProductSkuMapper {
|
||||||
List<TbProductSku> selectSkus(@Param("list") List<String> productId);
|
List<TbProductSku> selectSkus(@Param("list") List<String> productId);
|
||||||
List<TbProductSku> selectSku(@Param("productId") String productId);
|
List<TbProductSku> selectSku(@Param("productId") String productId);
|
||||||
|
|
||||||
@Update("update tb_product_sku set stock_number=stock_number-#{num} WHERE id=#{id} and stock_number-#{num} > 0")
|
@Update("update tb_product_sku set stock_number=stock_number-#{num} WHERE id=#{id} and stock_number-#{num} >= 0")
|
||||||
int decrStock(@Param("id") String id, @Param("num") Integer num);
|
int decrStock(@Param("id") String id, @Param("num") Integer num);
|
||||||
|
|
||||||
|
@Update("update tb_product_sku set stock_number=stock_number-#{num} WHERE id=#{id}")
|
||||||
|
int decrStockUnCheck(@Param("id") String id, @Param("num") Integer num);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,36 +1,33 @@
|
||||||
package com.chaozhanggui.system.cashierservice.dao;
|
package com.chaozhanggui.system.cashierservice.dao;
|
||||||
|
|
||||||
import com.chaozhanggui.system.cashierservice.entity.TbUserShopMsg;
|
import com.chaozhanggui.system.cashierservice.entity.TbUserShopMsg;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
import org.apache.ibatis.annotations.Select;
|
import org.apache.ibatis.annotations.Select;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Administrator
|
|
||||||
* @description 针对表【tb_user_shop_msg】的数据库操作Mapper
|
|
||||||
* @createDate 2024-06-28 09:55:30
|
|
||||||
* @Entity com.chaozhanggui.system.cashierservice.entity.TbUserShopMsg
|
|
||||||
*/
|
|
||||||
@Component
|
@Component
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface TbUserShopMsgMapper {
|
public interface TbUserShopMsgMapper {
|
||||||
int deleteByPrimaryKey(Integer shopId);
|
int deleteByPrimaryKey(Integer id);
|
||||||
|
|
||||||
int deleteByPrimaryKey(Long id);
|
|
||||||
|
|
||||||
int insert(TbUserShopMsg record);
|
int insert(TbUserShopMsg record);
|
||||||
|
|
||||||
int insertSelective(TbUserShopMsg record);
|
int insertSelective(TbUserShopMsg record);
|
||||||
|
|
||||||
TbUserShopMsg selectByPrimaryKey(Integer shopId);
|
TbUserShopMsg selectByPrimaryKey(Integer id);
|
||||||
TbUserShopMsg selectByPrimaryKey(Long id);
|
|
||||||
|
|
||||||
int updateByPrimaryKeySelective(TbUserShopMsg record);
|
int updateByPrimaryKeySelective(TbUserShopMsg record);
|
||||||
|
|
||||||
int updateByPrimaryKey(TbUserShopMsg record);
|
int updateByPrimaryKey(TbUserShopMsg record);
|
||||||
|
|
||||||
|
|
||||||
@Select("select * from tb_user_shop_msg where shop_id=#{shopId}")
|
@Select("select * from tb_user_shop_msg where shop_id=#{shopId}")
|
||||||
TbUserShopMsg selectByShopId(@Param("shopId") String shopId);
|
TbUserShopMsg selectByShopId(@Param("shopId") String shopId);
|
||||||
|
|
||||||
|
TbUserShopMsg selectByShopIdAndOpenId(@Param("shopId") Integer shopId,@Param("openId") String openId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,8 @@ import java.io.Serializable;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
public class TbUserShopMsg implements Serializable {
|
public class TbUserShopMsg implements Serializable {
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
private Integer shopId;
|
private Integer shopId;
|
||||||
|
|
||||||
private String openId;
|
private String openId;
|
||||||
|
|
@ -18,6 +20,14 @@ public class TbUserShopMsg implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
public Integer getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(Integer id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
public Integer getShopId() {
|
public Integer getShopId() {
|
||||||
return shopId;
|
return shopId;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -197,6 +197,34 @@ public class PushToAppChannelHandlerAdapter extends NettyChannelHandlerAdapter {
|
||||||
sendMessage(ctx, str);
|
sendMessage(ctx, str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送给当前用户以外的用户
|
||||||
|
*/
|
||||||
|
@Async
|
||||||
|
public void AppSendInfo(String message, String tableId, String userId) {
|
||||||
|
log.info("netty连接 发送消息 除当前用户 tableId:{} userId:{}", tableId, userId);
|
||||||
|
if (webSocketMap.containsKey(tableId)) {
|
||||||
|
ConcurrentHashMap<String, ChannelHandlerContext> webSockets = webSocketMap.get(tableId);
|
||||||
|
if (!webSockets.isEmpty()) {
|
||||||
|
for (String user : webSockets.keySet()) {
|
||||||
|
if (StringUtils.isNotBlank(userId) && userId.equals(user)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
ChannelHandlerContext ctx = webSockets.get(user);
|
||||||
|
if (ctx != null) {
|
||||||
|
sendMesToApp(message, ctx);
|
||||||
|
} else {
|
||||||
|
log.info("netty连接 发送消息 除当前用户 userId:{} 失败", user);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
log.info("netty连接 发送消息 除当前用户 tableId:{} 失败", tableId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Async
|
@Async
|
||||||
public void AppSendInfo(String message, String tableId,String userId, boolean userFlag) {
|
public void AppSendInfo(String message, String tableId,String userId, boolean userFlag) {
|
||||||
log.info("netty连接 发送消息 tableId:{} userId:{} userFlag:{} message:{}",tableId,userId,userFlag, JSONUtil.toJSONString(message));
|
log.info("netty连接 发送消息 tableId:{} userId:{} userFlag:{} message:{}",tableId,userId,userFlag, JSONUtil.toJSONString(message));
|
||||||
|
|
|
||||||
|
|
@ -2,17 +2,20 @@ package com.chaozhanggui.system.cashierservice.netty;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.chaozhanggui.system.cashierservice.netty.config.NettyChannelHandlerAdapter;
|
import com.chaozhanggui.system.cashierservice.netty.config.NettyChannelHandlerAdapter;
|
||||||
import com.chaozhanggui.system.cashierservice.util.JSONUtil;
|
|
||||||
import io.netty.channel.ChannelHandler.Sharable;
|
import io.netty.channel.ChannelHandler.Sharable;
|
||||||
import io.netty.channel.ChannelHandlerContext;
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
|
import io.netty.handler.codec.http.websocketx.TextWebSocketFrame;
|
||||||
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.scheduling.annotation.Async;
|
import org.springframework.scheduling.annotation.Async;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.*;
|
||||||
import java.util.Map;
|
import java.util.concurrent.*;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
|
import io.netty.util.concurrent.Future;
|
||||||
|
import io.netty.util.concurrent.GenericFutureListener;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -32,7 +35,10 @@ public class PushToClientChannelHandlerAdapter extends NettyChannelHandlerAdapte
|
||||||
* [ctx, shopId:clientId]
|
* [ctx, shopId:clientId]
|
||||||
*/
|
*/
|
||||||
private static Map<ChannelHandlerContext, String> clientIdMap = new ConcurrentHashMap<>();
|
private static Map<ChannelHandlerContext, String> clientIdMap = new ConcurrentHashMap<>();
|
||||||
|
private static Map<String,Queue<JSONObject>> retryQueue = new HashMap<>();
|
||||||
|
private static ConcurrentHashMap<String, AtomicInteger> retryCounts = new ConcurrentHashMap<>();
|
||||||
|
private ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(3);
|
||||||
|
int maxRetryAttempts = 5;
|
||||||
|
|
||||||
private String clientId = "";
|
private String clientId = "";
|
||||||
private String shopId = "";
|
private String shopId = "";
|
||||||
|
|
@ -51,8 +57,8 @@ public class PushToClientChannelHandlerAdapter extends NettyChannelHandlerAdapte
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void channelInactive(ChannelHandlerContext ctx) {
|
public void channelInactive(ChannelHandlerContext ctx) {
|
||||||
log.info("netty连接client 长连接关闭:{}, {}",clientId,shopId);
|
log.info("netty连接client 长连接关闭:{}, {}", clientId, shopId);
|
||||||
ctx.close();
|
ctx.close();
|
||||||
removeCtx(ctx);
|
removeCtx(ctx);
|
||||||
}
|
}
|
||||||
|
|
@ -68,9 +74,6 @@ public class PushToClientChannelHandlerAdapter extends NettyChannelHandlerAdapte
|
||||||
ConcurrentHashMap<String, ChannelHandlerContext> tableMap = webSocketMap.get(split[0]);
|
ConcurrentHashMap<String, ChannelHandlerContext> tableMap = webSocketMap.get(split[0]);
|
||||||
if (tableMap != null && !tableMap.isEmpty() && tableMap.size() > 0) {
|
if (tableMap != null && !tableMap.isEmpty() && tableMap.size() > 0) {
|
||||||
tableMap.remove(split[1]);
|
tableMap.remove(split[1]);
|
||||||
if (tableMap.isEmpty() || tableMap.size() == 0) {
|
|
||||||
webSocketMap.remove(split[0]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
clientIdMap.remove(ctx);
|
clientIdMap.remove(ctx);
|
||||||
|
|
@ -92,43 +95,49 @@ public class PushToClientChannelHandlerAdapter extends NettyChannelHandlerAdapte
|
||||||
JSONObject jsonObject = new JSONObject();
|
JSONObject jsonObject = new JSONObject();
|
||||||
if (StringUtils.isNotEmpty(msg)) {
|
if (StringUtils.isNotEmpty(msg)) {
|
||||||
jsonObject = JSONObject.parseObject(msg);
|
jsonObject = JSONObject.parseObject(msg);
|
||||||
}else {
|
} else {
|
||||||
log.info("netty连接client 接收到空数据:{}",msg);
|
log.info("netty连接client 接收到空数据:{}", msg);
|
||||||
}
|
}
|
||||||
String type = jsonObject.getString("type");
|
String type = jsonObject.getString("type");
|
||||||
if(type.equals("heartbeat")){//心跳
|
if (type.equals("heartbeat")) {//心跳
|
||||||
log.info("netty连接client 接收到心跳数据:shop:{} clientId:{} meg:{}",shopId,clientId,msg);
|
log.info("netty连接client 接收到心跳数据:shop:{} clientId:{} meg:{}", shopId, clientId, msg);
|
||||||
}else {
|
} else {
|
||||||
if (type.equals("connect")) {
|
if (type.equals("connect")) {
|
||||||
String clientId = jsonObject.getString("clientId");
|
String clientId = jsonObject.getString("clientId");
|
||||||
String shopId = jsonObject.getString("shopId");
|
String shopId = jsonObject.getString("shopId");
|
||||||
if (StringUtils.isBlank(type) || StringUtils.isBlank(shopId) || StringUtils.isBlank(clientId)) {
|
if (StringUtils.isBlank(type) || StringUtils.isBlank(shopId) || StringUtils.isBlank(clientId)) {
|
||||||
log.info("netty连接client 建立连接请求失败:{}",jsonObject);
|
log.info("netty连接client 建立连接请求失败:{}", jsonObject);
|
||||||
channelInactive(ctx);
|
channelInactive(ctx);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
log.info("netty连接client 接收到数据 建立连接参数 param:{}", jsonObject);
|
||||||
log.info("netty连接client 接收到数据 建立连接参数 param:{}",jsonObject);
|
this.clientId = clientId;
|
||||||
this.clientId=clientId;
|
this.shopId = shopId;
|
||||||
this.shopId=shopId;
|
webSocketMap.computeIfAbsent(shopId, k -> new ConcurrentHashMap<>()).put(clientId, ctx);
|
||||||
if (webSocketMap.containsKey(shopId)) {
|
|
||||||
ConcurrentHashMap<String, ChannelHandlerContext> clientSocketMap = webSocketMap.get(shopId);
|
|
||||||
ChannelHandlerContext channelHandlerContext = clientSocketMap.get(clientId);
|
|
||||||
if (channelHandlerContext != null) {
|
|
||||||
channelHandlerContext.close();
|
|
||||||
}
|
|
||||||
clientSocketMap.put(clientId, ctx);
|
|
||||||
} else {
|
|
||||||
ConcurrentHashMap<String, ChannelHandlerContext> clientSocketMap = new ConcurrentHashMap<>();
|
|
||||||
clientSocketMap.put(clientId, ctx);
|
|
||||||
webSocketMap.put(shopId,clientSocketMap);
|
|
||||||
}
|
|
||||||
clientIdMap.put(ctx, shopId + ":" + clientId);
|
clientIdMap.put(ctx, shopId + ":" + clientId);
|
||||||
JSONObject jsonObject1 = new JSONObject();
|
JSONObject jsonObject1 = new JSONObject();
|
||||||
jsonObject1.put("status", "success");
|
jsonObject1.put("status", "success");
|
||||||
jsonObject1.put("msg", "连接成功");
|
jsonObject1.put("msg", "连接成功");
|
||||||
jsonObject1.put("type", "connect");
|
jsonObject1.put("type", "connect");
|
||||||
sendMesToApp(jsonObject1.toString(), ctx);
|
sendMesToApp(jsonObject1.toString(), ctx);
|
||||||
|
}else if(type.equals("send")){
|
||||||
|
String orderNo = jsonObject.getString("orderNo");
|
||||||
|
// log.info("netty连接client 接收到send 数据 param:{} orderNo:{} shopId:{}", jsonObject,orderNo,shopId);
|
||||||
|
if (retryQueue.containsKey(shopId)) {
|
||||||
|
// 获取内层Map
|
||||||
|
Queue<JSONObject> queue = retryQueue.get(shopId);
|
||||||
|
if (queue != null) {
|
||||||
|
Iterator<JSONObject> iterator = queue.iterator();
|
||||||
|
while (iterator.hasNext()) {
|
||||||
|
JSONObject customObject = iterator.next();
|
||||||
|
// log.info("netty连接client 接收到send 数据 retryQueue数据:{}", customObject);
|
||||||
|
if (customObject.getJSONObject("orderInfo").getString("orderNo").equals(orderNo)) {
|
||||||
|
iterator.remove();
|
||||||
|
retryCounts.remove(orderNo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//业务逻辑代码处理框架。。。
|
//业务逻辑代码处理框架。。。
|
||||||
|
|
@ -139,53 +148,96 @@ public class PushToClientChannelHandlerAdapter extends NettyChannelHandlerAdapte
|
||||||
sendMessage(ctx, str);
|
sendMessage(ctx, str);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param message 发送的消息内容
|
|
||||||
* @param shopId 店铺Id
|
|
||||||
* @param clientId 客户端Id
|
|
||||||
* @param userFlag
|
|
||||||
* 为true 单发给clientId
|
|
||||||
* 为false 群发 shopId为空 发给所有人
|
|
||||||
*/
|
|
||||||
@Async
|
@Async
|
||||||
public void AppSendInfo(String message, String shopId,String clientId, boolean userFlag) {
|
public void sendMesToApp(String shopId,String orderNo,JSONObject str, ChannelHandlerContext ctx) {
|
||||||
log.info("netty连接client 发送消息 shopId:{} clientId:{} userFlag:{} message:{}",shopId,clientId,userFlag, JSONUtil.toJSONString(message));
|
ctx.channel().writeAndFlush(new TextWebSocketFrame(str.toString())).addListener((GenericFutureListener<Future<? super Void>>) future -> {
|
||||||
if (userFlag) {
|
if (!future.isSuccess()) {
|
||||||
if (webSocketMap.containsKey(shopId)) {
|
if (shopId != null) {
|
||||||
ConcurrentHashMap<String, ChannelHandlerContext> webSockets = webSocketMap.get(shopId);
|
retryQueue.computeIfAbsent(shopId, k -> new ConcurrentLinkedQueue<>()).offer(str);
|
||||||
if(!webSockets.isEmpty()){
|
scheduleRetry(shopId,orderNo);
|
||||||
if (StringUtils.isNotBlank(clientId)) {
|
|
||||||
ChannelHandlerContext ctx = webSockets.get(clientId);
|
|
||||||
if (ctx != null) {
|
|
||||||
sendMesToApp(message,ctx);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
});
|
||||||
if (StringUtils.isEmpty(shopId)) {
|
}
|
||||||
// 向所有用户发送信息
|
|
||||||
for (ConcurrentHashMap<String, ChannelHandlerContext> value : webSocketMap.values()) {
|
/**
|
||||||
for (ChannelHandlerContext ctx : value.values()) {
|
* @param message 发送的消息内容
|
||||||
sendMesToApp(message,ctx);
|
* @param shopId 店铺Id
|
||||||
}
|
// * @param clientId 客户端Id
|
||||||
}
|
// * @param userFlag 为true 单发给clientId
|
||||||
} else if (webSocketMap.containsKey(shopId)) {
|
* 为false 群发 shopId为空 发给所有人
|
||||||
ConcurrentHashMap<String, ChannelHandlerContext> webSockets = webSocketMap.get(shopId);
|
*/
|
||||||
if(!webSockets.isEmpty()) {
|
// @Async
|
||||||
for (String user : webSockets.keySet()) {
|
// public void AppSendInfo(String message, String shopId,String clientId, boolean userFlag) {
|
||||||
ChannelHandlerContext ctx = webSockets.get(user);
|
// log.info("netty连接client 发送消息 shopId:{} clientId:{} userFlag:{} message:{}",shopId,clientId,userFlag, JSONUtil.toJSONString(message));
|
||||||
if (ctx != null) {
|
// if (userFlag) {
|
||||||
log.info("netty连接client 发送消息 桌码群发 clientId:{}",user);
|
// if (webSocketMap.containsKey(shopId)) {
|
||||||
sendMesToApp(message,ctx);
|
// ConcurrentHashMap<String, ChannelHandlerContext> webSockets = webSocketMap.get(shopId);
|
||||||
}else {
|
// if(!webSockets.isEmpty()){
|
||||||
log.info("netty连接client 发送消息 桌码群发 clientId:{} 失败",user);
|
// if (StringUtils.isNotBlank(clientId)) {
|
||||||
}
|
// ChannelHandlerContext ctx = webSockets.get(clientId);
|
||||||
}
|
// if (ctx != null) {
|
||||||
}else {
|
// sendMesToApp(message,ctx);
|
||||||
log.info("netty连接client 发送消息 桌码群发 clientId:{} 失败",clientId);
|
// }
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// } else {
|
||||||
|
// if (StringUtils.isEmpty(shopId)) {
|
||||||
|
// // 向所有用户发送信息
|
||||||
|
// for (ConcurrentHashMap<String, ChannelHandlerContext> value : webSocketMap.values()) {
|
||||||
|
// for (ChannelHandlerContext ctx : value.values()) {
|
||||||
|
// sendMesToApp(message,ctx);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// } else if (webSocketMap.containsKey(shopId)) {
|
||||||
|
// ConcurrentHashMap<String, ChannelHandlerContext> webSockets = webSocketMap.get(shopId);
|
||||||
|
// if((!webSockets.isEmpty() && !webSockets.keySet().isEmpty())) {
|
||||||
|
// for (String user : webSockets.keySet()) {
|
||||||
|
// ChannelHandlerContext ctx = webSockets.get(user);
|
||||||
|
// if (ctx != null) {
|
||||||
|
// log.info("netty连接client 发送消息 桌码群发 clientId:{}",user);
|
||||||
|
// sendMesToApp(message,ctx);
|
||||||
|
// }else {
|
||||||
|
// log.info("netty连接client 发送消息 桌码群发 clientId:{} 失败",user);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }else {
|
||||||
|
// log.info("netty连接client 发送消息 桌码群发 clientId:{} 失败",clientId);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
public void AppSendInfoV1(String shopId, String orderNo, JSONObject message) {
|
||||||
|
log.info("netty连接client 发送消息 shopId:{} clientId:{} userFlag:{} message:{}", shopId, message.get("orderInfo"));
|
||||||
|
retryQueue.computeIfAbsent(shopId, k -> new ConcurrentLinkedQueue<>()).offer(message);
|
||||||
|
scheduleRetry(shopId, orderNo);
|
||||||
|
ConcurrentHashMap<String, ChannelHandlerContext> webSockets = webSocketMap.get(shopId);
|
||||||
|
if (webSockets != null) {
|
||||||
|
for (ChannelHandlerContext ctx : webSockets.values()) {
|
||||||
|
sendMesToApp(shopId, orderNo, message, ctx);
|
||||||
|
log.info("netty连接client 向:{}发送消息", shopId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 定时重试方法
|
||||||
|
private void scheduleRetry(String shopId,String orderNo) {
|
||||||
|
// log.info("定时重发");
|
||||||
|
scheduler.schedule(() -> {
|
||||||
|
Queue<JSONObject> shopRetryQueue = retryQueue.get(shopId);
|
||||||
|
if (shopRetryQueue != null) {
|
||||||
|
JSONObject message = shopRetryQueue.poll();
|
||||||
|
if (message != null) {
|
||||||
|
AtomicInteger retryCount = retryCounts.computeIfAbsent(orderNo, k -> new AtomicInteger(0));
|
||||||
|
int currentRetryCount = retryCount.incrementAndGet();
|
||||||
|
if (currentRetryCount <= maxRetryAttempts) {
|
||||||
|
AppSendInfoV1(shopId,orderNo,message);
|
||||||
|
} else {
|
||||||
|
log.error("重试次数超过最大限制,放弃重试。shopId: {}, orderNo: {}", shopId, orderNo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 4, TimeUnit.SECONDS);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -301,30 +301,39 @@ public class CartService {
|
||||||
jsonObject1.put("status", "fail");
|
jsonObject1.put("status", "fail");
|
||||||
jsonObject1.put("msg", "该商品不存在");
|
jsonObject1.put("msg", "该商品不存在");
|
||||||
jsonObject1.put("data", new ArrayList<>());
|
jsonObject1.put("data", new ArrayList<>());
|
||||||
|
jsonObject1.put("reqData", jsonObject);
|
||||||
|
|
||||||
PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), key, jsonObject.getString("userId"), true);
|
PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), key, jsonObject.getString("userId"), true);
|
||||||
log.error("该商品不存在 productId:{}", productId);
|
log.error("该商品不存在 productId:{}", productId);
|
||||||
throw new MsgException("该商品不存在");
|
throw new MsgException("该商品不存在");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Integer buyNum = jsonObject.getInteger("num");
|
||||||
|
|
||||||
String skuId = jsonObject.getString("skuId");
|
String skuId = jsonObject.getString("skuId");
|
||||||
if (tbProduct.getIsStock() == 1) {
|
if (tbProduct.getIsStock() == 1) {
|
||||||
// 1:共享库存 0:独立库存
|
// 1:共享库存 0:独立库存
|
||||||
if (Integer.valueOf(tbProduct.getIsDistribute()).equals(1)) {
|
if (Integer.valueOf(tbProduct.getIsDistribute()).equals(1)) {
|
||||||
if (tbProduct.getIsPauseSale().equals(1)) {//是否售罄
|
if (tbProduct.getIsPauseSale() == 1 || tbProduct.getStockNumber() - buyNum < 0) {//是否售罄
|
||||||
JSONObject jsonObject1 = new JSONObject();
|
JSONObject jsonObject1 = new JSONObject();
|
||||||
jsonObject1.put("status", "fail");
|
jsonObject1.put("status", "fail");
|
||||||
jsonObject1.put("msg", "该商品已售罄");
|
jsonObject1.put("msg", "该商品已售罄");
|
||||||
jsonObject1.put("data", new ArrayList<>());
|
jsonObject1.put("data", new ArrayList<>());
|
||||||
|
jsonObject1.put("reqData", jsonObject);
|
||||||
|
|
||||||
PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), key, jsonObject.getString("userId"), true);
|
PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), key, jsonObject.getString("userId"), true);
|
||||||
log.error("该商品已售罄 productId:{}", productId);
|
log.error("该商品已售罄 productId:{}", productId);
|
||||||
throw new MsgException("该商品已售罄");
|
throw new MsgException("该商品已售罄");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = productSkuMapper.selectByPrimaryKey(Integer.valueOf(skuId));
|
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = productSkuMapper.selectByPrimaryKey(Integer.valueOf(skuId));
|
||||||
if(tbProductSkuWithBLOBs.getIsPauseSale().equals(1)){//是否售罄
|
if(tbProductSkuWithBLOBs.getIsPauseSale() == 1 || tbProductSkuWithBLOBs.getStockNumber() - buyNum < 0){//是否售罄
|
||||||
JSONObject jsonObject1 = new JSONObject();
|
JSONObject jsonObject1 = new JSONObject();
|
||||||
jsonObject1.put("status", "fail");
|
jsonObject1.put("status", "fail");
|
||||||
jsonObject1.put("msg", "该商品已售罄");
|
jsonObject1.put("msg", "该商品已售罄");
|
||||||
jsonObject1.put("data", new ArrayList<>());
|
jsonObject1.put("data", new ArrayList<>());
|
||||||
|
jsonObject1.put("reqData", jsonObject);
|
||||||
|
|
||||||
PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), key, jsonObject.getString("userId"), true);
|
PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), key, jsonObject.getString("userId"), true);
|
||||||
log.error("该商品已售罄 productId:{}", productId);
|
log.error("该商品已售罄 productId:{}", productId);
|
||||||
throw new MsgException("该商品已售罄");
|
throw new MsgException("该商品已售罄");
|
||||||
|
|
@ -333,7 +342,6 @@ public class CartService {
|
||||||
}
|
}
|
||||||
JSONArray jsonArray = new JSONArray();
|
JSONArray jsonArray = new JSONArray();
|
||||||
BigDecimal amount = BigDecimal.ZERO;
|
BigDecimal amount = BigDecimal.ZERO;
|
||||||
Integer buyNum = jsonObject.getInteger("num");
|
|
||||||
|
|
||||||
if (redisUtil.exists(RedisCst.TABLE_CART.concat(jsonObject.getString("tableId").concat("-").concat(shopId)))) {
|
if (redisUtil.exists(RedisCst.TABLE_CART.concat(jsonObject.getString("tableId").concat("-").concat(shopId)))) {
|
||||||
JSONArray array = JSON.parseArray(redisUtil.getMessage(RedisCst.TABLE_CART.concat(jsonObject.getString("tableId").concat("-").concat(shopId))));
|
JSONArray array = JSON.parseArray(redisUtil.getMessage(RedisCst.TABLE_CART.concat(jsonObject.getString("tableId").concat("-").concat(shopId))));
|
||||||
|
|
@ -387,6 +395,8 @@ public class CartService {
|
||||||
jsonObject1.put("type", jsonObject.getString("type"));
|
jsonObject1.put("type", jsonObject.getString("type"));
|
||||||
jsonObject1.put("data", jsonArray);
|
jsonObject1.put("data", jsonArray);
|
||||||
jsonObject1.put("amount", amount);
|
jsonObject1.put("amount", amount);
|
||||||
|
jsonObject1.put("reqData", jsonObject);
|
||||||
|
|
||||||
PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), jsonObject.getString("tableId").concat("-").concat(shopId), "", false);
|
PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), jsonObject.getString("tableId").concat("-").concat(shopId), "", false);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("长链接错误 createCart{}", e.getMessage());
|
log.error("长链接错误 createCart{}", e.getMessage());
|
||||||
|
|
@ -553,18 +563,26 @@ public class CartService {
|
||||||
log.info("开始修改库存,商品id:{},商品名:{}", tbProduct1.getId(), tbProduct1.getName());
|
log.info("开始修改库存,商品id:{},商品名:{}", tbProduct1.getId(), tbProduct1.getName());
|
||||||
// 修改库存
|
// 修改库存
|
||||||
try {
|
try {
|
||||||
productService.updateStock(tbProduct.getProductId(), tbProduct.getId(), cashierCart.getNumber(), tbProduct1.getIsDistribute() == 1);
|
if (tbProduct1.getIsStock() == 1) {
|
||||||
|
productService.updateStock(tbProduct.getProductId(), tbProduct.getId(), cashierCart.getNumber(), tbProduct1.getIsDistribute() == 1);
|
||||||
|
}else {
|
||||||
|
productService.updateStockAndNoCheck(tbProduct.getProductId(), tbProduct.getId(), cashierCart.getNumber(), tbProduct1.getIsDistribute() == 1);
|
||||||
|
}
|
||||||
}catch (Exception e) {
|
}catch (Exception e) {
|
||||||
JSONObject jsonObject1 = new JSONObject();
|
JSONObject jsonObject1 = new JSONObject();
|
||||||
jsonObject1.put("status", "fail");
|
jsonObject1.put("status", "fail");
|
||||||
jsonObject1.put("msg", "商品库存不足" + tbProduct1.getName());
|
jsonObject1.put("msg", "商品库存不足" + tbProduct1.getName());
|
||||||
jsonObject1.put("data", new ArrayList<>());
|
jsonObject1.put("data", new ArrayList<>());
|
||||||
PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), key, jsonObject.getString("userId"), true);
|
|
||||||
|
|
||||||
PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), key, jsonObject.getString("userId"), true);
|
PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), key, jsonObject.getString("userId"), true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 发送判断耗材是否耗尽消息
|
||||||
|
JSONObject objectMsg=new JSONObject();
|
||||||
|
objectMsg.put("skuId",Integer.valueOf(cashierCart.getSkuId()));
|
||||||
|
objectMsg.put("shopId",Integer.valueOf(cashierCart.getShopId()));
|
||||||
|
producer.con_msg(objectMsg.toString());
|
||||||
|
|
||||||
totalAmount = totalAmount.add(cashierCart.getTotalAmount());
|
totalAmount = totalAmount.add(cashierCart.getTotalAmount());
|
||||||
packAMount = packAMount.add(cashierCart.getPackFee());
|
packAMount = packAMount.add(cashierCart.getPackFee());
|
||||||
originAmount = originAmount.add(cashierCart.getTotalAmount());
|
originAmount = originAmount.add(cashierCart.getTotalAmount());
|
||||||
|
|
@ -759,7 +777,7 @@ public class CartService {
|
||||||
jsonObject2.put("orderId", orderInfo.getId());
|
jsonObject2.put("orderId", orderInfo.getId());
|
||||||
jsonObject2.put("type", "create");
|
jsonObject2.put("type", "create");
|
||||||
jsonObject2.put("cartId", cashierCart.getId());
|
jsonObject2.put("cartId", cashierCart.getId());
|
||||||
log.info("开始发送mq消息,消耗库存,消息内容:{}", jsonObject2);
|
log.info("开始发送mq消息,消耗耗材,消息内容:{}", jsonObject2);
|
||||||
producer.cons(jsonObject2.toString());
|
producer.cons(jsonObject2.toString());
|
||||||
}
|
}
|
||||||
redisUtil.saveMessage(RedisCst.TABLE_CART.concat(jsonObject.getString("tableId")).concat("-").concat(shopId), array.toJSONString());
|
redisUtil.saveMessage(RedisCst.TABLE_CART.concat(jsonObject.getString("tableId")).concat("-").concat(shopId), array.toJSONString());
|
||||||
|
|
@ -778,7 +796,8 @@ public class CartService {
|
||||||
jsonObject12.put("amount", BigDecimal.ZERO);
|
jsonObject12.put("amount", BigDecimal.ZERO);
|
||||||
|
|
||||||
jsonObject12.put("data", new JSONArray());
|
jsonObject12.put("data", new JSONArray());
|
||||||
PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject12.toString(), jsonObject.getString("tableId").concat("-").concat(shopId), "", false);
|
// PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject12.toString(), jsonObject.getString("tableId").concat("-").concat(shopId), "", false);
|
||||||
|
PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject12.toString(), jsonObject.getString("tableId").concat("-").concat(shopId), jsonObject.getString("userId"));
|
||||||
redisUtil.saveMessage(RedisCst.ORDER_EXPIRED.concat(orderId.toString()), orderId.toString(), 60 * 16L);
|
redisUtil.saveMessage(RedisCst.ORDER_EXPIRED.concat(orderId.toString()), orderId.toString(), 60 * 16L);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -65,22 +65,16 @@ public class LoginService {
|
||||||
|
|
||||||
|
|
||||||
public Result wxBusinessLogin(String openId,String shopId){
|
public Result wxBusinessLogin(String openId,String shopId){
|
||||||
TbUserShopMsg shopMsg= tbUserShopMsgMapper.selectByPrimaryKey(Integer.valueOf(shopId));
|
TbUserShopMsg shopMsg= tbUserShopMsgMapper.selectByShopIdAndOpenId(Integer.valueOf(shopId),openId);
|
||||||
if(Objects.isNull(shopMsg)){
|
if(Objects.isNull(shopMsg)){
|
||||||
shopMsg=new TbUserShopMsg();
|
shopMsg=new TbUserShopMsg();
|
||||||
|
|
||||||
shopMsg.setShopId(Integer.valueOf(shopId));
|
shopMsg.setShopId(Integer.valueOf(shopId));
|
||||||
shopMsg.setOpenId(openId);
|
shopMsg.setOpenId(openId);
|
||||||
shopMsg.setCreateTime(new Date());
|
shopMsg.setCreateTime(new Date());
|
||||||
shopMsg.setStatus("1");
|
shopMsg.setStatus("1");
|
||||||
|
|
||||||
|
|
||||||
tbUserShopMsgMapper.insert(shopMsg);
|
tbUserShopMsgMapper.insert(shopMsg);
|
||||||
}else {
|
|
||||||
shopMsg.setOpenId(openId);
|
|
||||||
shopMsg.setUpdateTime(new Date());
|
|
||||||
tbUserShopMsgMapper.updateByPrimaryKey(shopMsg);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 为商家绑定openid
|
// 为商家绑定openid
|
||||||
if (shopOpenIdMapper.countByOpenId(openId) == null) {
|
if (shopOpenIdMapper.countByOpenId(openId) == null) {
|
||||||
TbShopOpenId shopOpenId = new TbShopOpenId();
|
TbShopOpenId shopOpenId = new TbShopOpenId();
|
||||||
|
|
|
||||||
|
|
@ -1208,7 +1208,7 @@ public class PayService {
|
||||||
// e.printStackTrace();
|
// e.printStackTrace();
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
PushToClientChannelHandlerAdapter.getInstance().AppSendInfo(client.toString(), orderInfo.getShopId(), "", false);
|
PushToClientChannelHandlerAdapter.getInstance().AppSendInfoV1(orderInfo.getShopId(),orderInfo.getOrderNo(), client);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -465,4 +465,16 @@ public class ProductService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void updateStockAndNoCheck(String id, Integer skuId, Integer buyNum, boolean isDistribute) {
|
||||||
|
if (isDistribute) {
|
||||||
|
if (tbProductMapper.decrStockUnCheck(String.valueOf(id), buyNum) < 1) {
|
||||||
|
throw new MsgException("库存不足,下单失败");
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
if (tbProductSkuMapper.decrStockUnCheck(String.valueOf(skuId), buyNum) < 1) {
|
||||||
|
throw new MsgException("库存不足,下单失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -59,18 +59,19 @@ logging:
|
||||||
file:
|
file:
|
||||||
# 切记,该文件表示正在产出日志的日志文件。并不会打包,当文件大于max-file-size,会根据file-name-pattern格式打包
|
# 切记,该文件表示正在产出日志的日志文件。并不会打包,当文件大于max-file-size,会根据file-name-pattern格式打包
|
||||||
# 名称为log/cashier-client.log文件夹会在项目根目录下,打包后会在启动包同目录下;名称为/log/cashier-client.log的文件夹会在项目所在磁盘的跟目录下
|
# 名称为log/cashier-client.log文件夹会在项目根目录下,打包后会在启动包同目录下;名称为/log/cashier-client.log的文件夹会在项目所在磁盘的跟目录下
|
||||||
name: log/cashierService.log
|
name: wx.log
|
||||||
logback:
|
logback:
|
||||||
rollingpolicy:
|
rollingpolicy:
|
||||||
# 单文件的大小,默认10M, 超过之后打包成一个日志文件
|
# 单文件的大小,默认10M, 超过之后打包成一个日志文件
|
||||||
max-file-size: 10MB
|
max-file-size: 50MB
|
||||||
# 日志保存的天数
|
# 日志保存的天数
|
||||||
max-history: 30
|
max-history: 30
|
||||||
# 打包文件格式,默认: ${LOG_FILE}.%d{yyyy-MM-dd}.%i.gz,书写格式为:文件路径/文件名.%i.文件后缀,其中%i不可省去,否则无日志显示
|
# 打包文件格式,默认: ${LOG_FILE}.%d{yyyy-MM-dd}.%i.gz,书写格式为:文件路径/文件名.%i.文件后缀,其中%i不可省去,否则无日志显示
|
||||||
# 例如: 日期为:2021/11/5 ,则打包文件之后为: log/ota.2021-11-05.0.gz,0表示日志的第一部分,后续就是,1,2,3...
|
# 例如: 日期为:2021/11/5 ,则打包文件之后为: log/ota.2021-11-05.0.gz,0表示日志的第一部分,后续就是,1,2,3...
|
||||||
# 如果是压缩包,里面会多一个名log/ota.2021-11-05.0的日志文件
|
# 如果是压缩包,里面会多一个名log/ota.2021-11-05.0的日志文件
|
||||||
# 如下面的例子,打包之后为: log/2021-11/cashier-client.2020-11-5.0.log,这是一个日志文件
|
# 如下面的例子,打包之后为: log/2021-11/cashier-client.2020-11-5.0.log,这是一个日志文件
|
||||||
file-name-pattern: log/%d{yyyy-MM}/cashierService.%d{yyyy-MM-dd}.%i.log
|
# file-name-pattern: log/%d{yyyy-MM}/cashierService.%d{yyyy-MM-dd}.%i.log
|
||||||
|
file-name-pattern: log/%d{yyyy-MM}/cashierService.%d{yyyy-MM-dd}.%i.log.gz
|
||||||
#阿里云相关配置
|
#阿里云相关配置
|
||||||
aliyun:
|
aliyun:
|
||||||
keyid: LTAI5tPdEfYSZcqHbjCrtPRD
|
keyid: LTAI5tPdEfYSZcqHbjCrtPRD
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@
|
||||||
|
|
||||||
<!-- 要生成的表tableName是数据库中的表名或视图名 domainObjectName是实体类名-->
|
<!-- 要生成的表tableName是数据库中的表名或视图名 domainObjectName是实体类名-->
|
||||||
<!-- <table tableName="%" schema="fycashier" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" ></table>-->
|
<!-- <table tableName="%" schema="fycashier" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" ></table>-->
|
||||||
<table tableName="tb_shop_user_flow" domainObjectName="TbShopUserFlow"
|
<table tableName="tb_user_shop_msg" domainObjectName="TbUserShopMsg"
|
||||||
enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false"
|
enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false"
|
||||||
enableSelectByExample="false" selectByExampleQueryId="false" >
|
enableSelectByExample="false" selectByExampleQueryId="false" >
|
||||||
</table>
|
</table>
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,8 @@
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="com.chaozhanggui.system.cashierservice.dao.TbUserShopMsgMapper">
|
<mapper namespace="com.chaozhanggui.system.cashierservice.dao.TbUserShopMsgMapper">
|
||||||
<resultMap id="BaseResultMap" type="com.chaozhanggui.system.cashierservice.entity.TbUserShopMsg">
|
<resultMap id="BaseResultMap" type="com.chaozhanggui.system.cashierservice.entity.TbUserShopMsg">
|
||||||
<id column="shop_id" jdbcType="INTEGER" property="shopId" />
|
<id column="id" jdbcType="INTEGER" property="id" />
|
||||||
|
<result column="shop_id" jdbcType="INTEGER" property="shopId" />
|
||||||
<result column="open_id" jdbcType="VARCHAR" property="openId" />
|
<result column="open_id" jdbcType="VARCHAR" property="openId" />
|
||||||
<result column="remark" jdbcType="VARCHAR" property="remark" />
|
<result column="remark" jdbcType="VARCHAR" property="remark" />
|
||||||
<result column="status" jdbcType="VARCHAR" property="status" />
|
<result column="status" jdbcType="VARCHAR" property="status" />
|
||||||
|
|
@ -10,29 +11,32 @@
|
||||||
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
|
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
|
||||||
</resultMap>
|
</resultMap>
|
||||||
<sql id="Base_Column_List">
|
<sql id="Base_Column_List">
|
||||||
shop_id, open_id, remark, status, create_time, update_time
|
id, shop_id, open_id, remark, status, create_time, update_time
|
||||||
</sql>
|
</sql>
|
||||||
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
|
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
|
||||||
select
|
select
|
||||||
<include refid="Base_Column_List" />
|
<include refid="Base_Column_List" />
|
||||||
from tb_user_shop_msg
|
from tb_user_shop_msg
|
||||||
where shop_id = #{shopId,jdbcType=INTEGER}
|
where id = #{id,jdbcType=INTEGER}
|
||||||
</select>
|
</select>
|
||||||
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
|
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
|
||||||
delete from tb_user_shop_msg
|
delete from tb_user_shop_msg
|
||||||
where shop_id = #{shopId,jdbcType=INTEGER}
|
where id = #{id,jdbcType=INTEGER}
|
||||||
</delete>
|
</delete>
|
||||||
<insert id="insert" parameterType="com.chaozhanggui.system.cashierservice.entity.TbUserShopMsg">
|
<insert id="insert" parameterType="com.chaozhanggui.system.cashierservice.entity.TbUserShopMsg">
|
||||||
insert into tb_user_shop_msg (shop_id, open_id, remark,
|
insert into tb_user_shop_msg (id, shop_id, open_id,
|
||||||
status, create_time, update_time
|
remark, status, create_time,
|
||||||
)
|
update_time)
|
||||||
values (#{shopId,jdbcType=INTEGER}, #{openId,jdbcType=VARCHAR}, #{remark,jdbcType=VARCHAR},
|
values (#{id,jdbcType=INTEGER}, #{shopId,jdbcType=INTEGER}, #{openId,jdbcType=VARCHAR},
|
||||||
#{status,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}
|
#{remark,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP},
|
||||||
)
|
#{updateTime,jdbcType=TIMESTAMP})
|
||||||
</insert>
|
</insert>
|
||||||
<insert id="insertSelective" parameterType="com.chaozhanggui.system.cashierservice.entity.TbUserShopMsg">
|
<insert id="insertSelective" parameterType="com.chaozhanggui.system.cashierservice.entity.TbUserShopMsg">
|
||||||
insert into tb_user_shop_msg
|
insert into tb_user_shop_msg
|
||||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="id != null">
|
||||||
|
id,
|
||||||
|
</if>
|
||||||
<if test="shopId != null">
|
<if test="shopId != null">
|
||||||
shop_id,
|
shop_id,
|
||||||
</if>
|
</if>
|
||||||
|
|
@ -53,6 +57,9 @@
|
||||||
</if>
|
</if>
|
||||||
</trim>
|
</trim>
|
||||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="id != null">
|
||||||
|
#{id,jdbcType=INTEGER},
|
||||||
|
</if>
|
||||||
<if test="shopId != null">
|
<if test="shopId != null">
|
||||||
#{shopId,jdbcType=INTEGER},
|
#{shopId,jdbcType=INTEGER},
|
||||||
</if>
|
</if>
|
||||||
|
|
@ -76,6 +83,9 @@
|
||||||
<update id="updateByPrimaryKeySelective" parameterType="com.chaozhanggui.system.cashierservice.entity.TbUserShopMsg">
|
<update id="updateByPrimaryKeySelective" parameterType="com.chaozhanggui.system.cashierservice.entity.TbUserShopMsg">
|
||||||
update tb_user_shop_msg
|
update tb_user_shop_msg
|
||||||
<set>
|
<set>
|
||||||
|
<if test="shopId != null">
|
||||||
|
shop_id = #{shopId,jdbcType=INTEGER},
|
||||||
|
</if>
|
||||||
<if test="openId != null">
|
<if test="openId != null">
|
||||||
open_id = #{openId,jdbcType=VARCHAR},
|
open_id = #{openId,jdbcType=VARCHAR},
|
||||||
</if>
|
</if>
|
||||||
|
|
@ -92,15 +102,20 @@
|
||||||
update_time = #{updateTime,jdbcType=TIMESTAMP},
|
update_time = #{updateTime,jdbcType=TIMESTAMP},
|
||||||
</if>
|
</if>
|
||||||
</set>
|
</set>
|
||||||
where shop_id = #{shopId,jdbcType=INTEGER}
|
where id = #{id,jdbcType=INTEGER}
|
||||||
</update>
|
</update>
|
||||||
<update id="updateByPrimaryKey" parameterType="com.chaozhanggui.system.cashierservice.entity.TbUserShopMsg">
|
<update id="updateByPrimaryKey" parameterType="com.chaozhanggui.system.cashierservice.entity.TbUserShopMsg">
|
||||||
update tb_user_shop_msg
|
update tb_user_shop_msg
|
||||||
set open_id = #{openId,jdbcType=VARCHAR},
|
set shop_id = #{shopId,jdbcType=INTEGER},
|
||||||
|
open_id = #{openId,jdbcType=VARCHAR},
|
||||||
remark = #{remark,jdbcType=VARCHAR},
|
remark = #{remark,jdbcType=VARCHAR},
|
||||||
status = #{status,jdbcType=VARCHAR},
|
status = #{status,jdbcType=VARCHAR},
|
||||||
create_time = #{createTime,jdbcType=TIMESTAMP},
|
create_time = #{createTime,jdbcType=TIMESTAMP},
|
||||||
update_time = #{updateTime,jdbcType=TIMESTAMP}
|
update_time = #{updateTime,jdbcType=TIMESTAMP}
|
||||||
where shop_id = #{shopId,jdbcType=INTEGER}
|
where id = #{id,jdbcType=INTEGER}
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
|
<select id="selectByShopIdAndOpenId" resultMap="BaseResultMap">
|
||||||
|
select * from tb_user_shop_msg where shop_id=#{shopId} and open_id=#{openId}
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
Loading…
Reference in New Issue