用户下单同步修改台桌状态
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
package com.chaozhanggui.system.cashierservice.config;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
@Configuration
|
||||
public class MyBatisPlusConfig {
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,19 @@
|
||||
package com.chaozhanggui.system.cashierservice.constant;
|
||||
|
||||
public interface TableConstant {
|
||||
import lombok.Getter;
|
||||
|
||||
public interface TableConstant {
|
||||
String CART_SEAT_ID = "-999";
|
||||
|
||||
class ShopTable {
|
||||
@Getter
|
||||
public enum State {
|
||||
IDLE("idle"), CLOSED("closed"), PAYING("paying"), PENDING("pending"), USING("using"), CLEANING("cleaning");
|
||||
private final String value;
|
||||
|
||||
State(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -175,14 +175,9 @@ public class UserContoller {
|
||||
|
||||
/**
|
||||
* 获取订阅当前用户店库存预警消息的二维码
|
||||
*
|
||||
* @param shopId
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/subQrCode")
|
||||
public Result getSubQrCode(
|
||||
@RequestParam String shopId
|
||||
) throws Exception {
|
||||
public Result getSubQrCode(@RequestParam String shopId) throws Exception {
|
||||
String url = userService.getSubQrCode(shopId);
|
||||
return Result.successWithData(url);
|
||||
}
|
||||
|
||||
@@ -52,6 +52,8 @@ public class TbShopTable implements Serializable {
|
||||
@TableField(exist = false)
|
||||
private Integer seatNum;
|
||||
|
||||
private Integer autoClear;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.chaozhanggui.system.cashierservice.mpservice;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.chaozhanggui.system.cashierservice.constant.TableConstant;
|
||||
import com.chaozhanggui.system.cashierservice.entity.TbShopTable;
|
||||
|
||||
public interface MpShopTableService extends IService<TbShopTable> {
|
||||
/**
|
||||
* 根据台桌id修改台桌状态
|
||||
* @param tableId qrcode
|
||||
* @param state 状态
|
||||
*/
|
||||
boolean updateStateByQrcode(String tableId, TableConstant.ShopTable.State state);
|
||||
|
||||
/**
|
||||
* 根据qrcode获取台桌
|
||||
* @param tableId qrcode
|
||||
*/
|
||||
TbShopTable selectByQrcode(String tableId);
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.chaozhanggui.system.cashierservice.mpservice.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.chaozhanggui.system.cashierservice.constant.TableConstant;
|
||||
import com.chaozhanggui.system.cashierservice.entity.TbShopTable;
|
||||
import com.chaozhanggui.system.cashierservice.mapper.MpShopTableMapper;
|
||||
import com.chaozhanggui.system.cashierservice.mpservice.MpShopTableService;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
@Primary
|
||||
public class MpShopTableServiceImpl extends ServiceImpl<MpShopTableMapper, TbShopTable> implements MpShopTableService {
|
||||
@Override
|
||||
public boolean updateStateByQrcode(String tableId, TableConstant.ShopTable.State state) {
|
||||
return update(new LambdaUpdateWrapper<TbShopTable>()
|
||||
.eq(TbShopTable::getQrcode, tableId)
|
||||
.set(TbShopTable::getStatus, state.getValue()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public TbShopTable selectByQrcode(String tableId) {
|
||||
return getOne(new LambdaQueryWrapper<TbShopTable>()
|
||||
.eq(TbShopTable::getQrcode, tableId));
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,7 @@ import com.chaozhanggui.system.cashierservice.entity.dto.ChoseEatModelDTO;
|
||||
import com.chaozhanggui.system.cashierservice.entity.dto.ShopEatTypeInfoDTO;
|
||||
import com.chaozhanggui.system.cashierservice.exception.MsgException;
|
||||
import com.chaozhanggui.system.cashierservice.mapper.*;
|
||||
import com.chaozhanggui.system.cashierservice.mpservice.MpShopTableService;
|
||||
import com.chaozhanggui.system.cashierservice.netty.PushToAppChannelHandlerAdapter;
|
||||
import com.chaozhanggui.system.cashierservice.rabbit.RabbitProducer;
|
||||
import com.chaozhanggui.system.cashierservice.redis.RedisCst;
|
||||
@@ -124,10 +125,12 @@ public class CartService {
|
||||
private MpOrderDetailMapper mpOrderDetailMapper;
|
||||
@Autowired
|
||||
private MpShopTableMapper mpShopTableMapper;
|
||||
|
||||
private final MpShopTableService mpShopTableService;
|
||||
@Autowired
|
||||
private MQUtils mQUtils;
|
||||
|
||||
public CartService(TbUserShopMsgMapper tbUserShopMsgMapper, WechatUtil wechatUtil, WxAccountUtil wxAccountUtil, TbShopOpenIdMapper shopOpenIdMapper, ProductService productService, TbProductMapper tbProductMapper, RedisTemplate<String, Object> redisTemplate, StringRedisTemplate stringRedisTemplate, ShopUtils shopUtils) {
|
||||
public CartService(TbUserShopMsgMapper tbUserShopMsgMapper, WechatUtil wechatUtil, WxAccountUtil wxAccountUtil, TbShopOpenIdMapper shopOpenIdMapper, ProductService productService, TbProductMapper tbProductMapper, RedisTemplate<String, Object> redisTemplate, StringRedisTemplate stringRedisTemplate, ShopUtils shopUtils, MpShopTableService mpShopTableService) {
|
||||
this.tbUserShopMsgMapper = tbUserShopMsgMapper;
|
||||
this.wechatUtil = wechatUtil;
|
||||
this.wxAccountUtil = wxAccountUtil;
|
||||
@@ -137,6 +140,7 @@ public class CartService {
|
||||
this.redisTemplate = redisTemplate;
|
||||
this.stringRedisTemplate = stringRedisTemplate;
|
||||
this.shopUtils = shopUtils;
|
||||
this.mpShopTableService = mpShopTableService;
|
||||
}
|
||||
|
||||
|
||||
@@ -1162,6 +1166,11 @@ public class CartService {
|
||||
}
|
||||
}
|
||||
|
||||
// 修改台桌状态
|
||||
if (!shopEatTypeInfoDTO.isTakeout() && StrUtil.isNotBlank(tableId)) {
|
||||
mpShopTableService.updateStateByQrcode(tableId, TableConstant.ShopTable.State.USING);
|
||||
}
|
||||
|
||||
// 发送mq消息
|
||||
JSONObject jsonObject2 = new JSONObject();
|
||||
jsonObject2.put("orderId", orderInfo.getId());
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.chaozhanggui.system.cashierservice.constant.TableConstant;
|
||||
import com.chaozhanggui.system.cashierservice.dao.*;
|
||||
import com.chaozhanggui.system.cashierservice.entity.Enum.OrderUseTypeEnum;
|
||||
import com.chaozhanggui.system.cashierservice.entity.*;
|
||||
@@ -19,6 +20,7 @@ import com.chaozhanggui.system.cashierservice.mapper.MpOrderDetailMapper;
|
||||
import com.chaozhanggui.system.cashierservice.mapper.MpOrderInfoMapper;
|
||||
import com.chaozhanggui.system.cashierservice.model.PayReq;
|
||||
import com.chaozhanggui.system.cashierservice.model.TradeQueryReq;
|
||||
import com.chaozhanggui.system.cashierservice.mpservice.MpShopTableService;
|
||||
import com.chaozhanggui.system.cashierservice.netty.PushToClientChannelHandlerAdapter;
|
||||
import com.chaozhanggui.system.cashierservice.rabbit.RabbitProducer;
|
||||
import com.chaozhanggui.system.cashierservice.redis.RedisCst;
|
||||
@@ -178,8 +180,11 @@ public class PayService {
|
||||
@Autowired
|
||||
private MpCashierCartMapper mpCashierCartMapper;
|
||||
|
||||
public PayService(@Qualifier("tbShopSongOrderServiceImpl") TbShopSongOrderService shopSongOrderService) {
|
||||
private final MpShopTableService mpShopTableService;
|
||||
|
||||
public PayService(@Qualifier("tbShopSongOrderServiceImpl") TbShopSongOrderService shopSongOrderService, MpShopTableService mpShopTableService) {
|
||||
this.shopSongOrderService = shopSongOrderService;
|
||||
this.mpShopTableService = mpShopTableService;
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@@ -520,6 +525,15 @@ public class PayService {
|
||||
stringRedisTemplate.delete(currentOrderKey);
|
||||
}
|
||||
|
||||
// 重置台桌状态
|
||||
if (StrUtil.isNotBlank(orderInfo.getTableId())) {
|
||||
TbShopTable shopTable = mpShopTableService.selectByQrcode(orderInfo.getTableId());
|
||||
if (shopTable.getAutoClear() != null && shopTable.getAutoClear() == 1) {
|
||||
mpShopTableService.updateStateByQrcode(orderInfo.getTableId(), TableConstant.ShopTable.State.IDLE);
|
||||
}else {
|
||||
mpShopTableService.updateStateByQrcode(orderInfo.getTableId(), TableConstant.ShopTable.State.CLEANING);
|
||||
}
|
||||
}
|
||||
return Result.success(CodeEnum.SUCCESS, "1");
|
||||
}
|
||||
|
||||
@@ -1137,6 +1151,16 @@ public class PayService {
|
||||
data.put("orderId", orderInfo.getId());
|
||||
data.put("plat", "miniApp");
|
||||
mQUtils.sendStockSaleMsg(data);
|
||||
|
||||
// 重置台桌状态
|
||||
if (StrUtil.isNotBlank(orderInfo.getTableId())) {
|
||||
TbShopTable shopTable = mpShopTableService.selectByQrcode(orderInfo.getTableId());
|
||||
if (shopTable.getAutoClear() != null && shopTable.getAutoClear() == 1) {
|
||||
mpShopTableService.updateStateByQrcode(orderInfo.getTableId(), TableConstant.ShopTable.State.IDLE);
|
||||
}else {
|
||||
mpShopTableService.updateStateByQrcode(orderInfo.getTableId(), TableConstant.ShopTable.State.CLEANING);
|
||||
}
|
||||
}
|
||||
return "SUCCESS";
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user