diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/controller/ProductController.java b/src/main/java/com/chaozhanggui/system/cashierservice/controller/ProductController.java index ece7ccb..8032b54 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/controller/ProductController.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/controller/ProductController.java @@ -2,6 +2,7 @@ package com.chaozhanggui.system.cashierservice.controller; import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; import com.alibaba.fastjson.JSONObject; import com.chaozhanggui.system.cashierservice.entity.dto.ChoseCountDTO; import com.chaozhanggui.system.cashierservice.entity.dto.ChoseEatModelDTO; @@ -41,9 +42,13 @@ public class ProductController { @RequestHeader("id") String userId, @RequestParam(required = false) String lat, @RequestParam(required = false) String lng, - @RequestParam("code") String code + @RequestParam(required = false) String code, + @RequestParam(required = false) Integer shopId ) { - return productService.queryShopIdByTableCode(userId, openId, code,lat,lng); + if (shopId == null && StrUtil.isBlank(code)) { + return Result.fail("参数缺失"); + } + return productService.queryShopIdByTableCode(userId, openId, code,lat,lng, shopId); } /** diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbOrderDetail.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbOrderDetail.java index 1936389..d91d8db 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbOrderDetail.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbOrderDetail.java @@ -44,6 +44,7 @@ public class TbOrderDetail implements Serializable { private Integer cartId; private Integer placeNum; private String useType; + private String note; private static final long serialVersionUID = 1L; } diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/netty/PushToAppChannelHandlerAdapter.java b/src/main/java/com/chaozhanggui/system/cashierservice/netty/PushToAppChannelHandlerAdapter.java index 59439fd..26a0c59 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/netty/PushToAppChannelHandlerAdapter.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/netty/PushToAppChannelHandlerAdapter.java @@ -232,6 +232,7 @@ public class PushToAppChannelHandlerAdapter extends NettyChannelHandlerAdapter { @Async public void AppSendInfo(String message, String redisKey,String userId, boolean userFlag) { log.info("netty连接 发送消息 tableId:{} userId:{} userFlag:{} message:{}",redisKey,userId,userFlag, JSONUtil.toJSONString(message)); + log.info("当前已连接队列信息: {}", webSocketMap); if (userFlag) { if (webSocketMap.containsKey(redisKey)) { ConcurrentHashMap webSockets = webSocketMap.get(redisKey); diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/CartService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/CartService.java index 61394dd..a6c6c2e 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/CartService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/CartService.java @@ -354,7 +354,7 @@ public class CartService { } } - redisUtil.saveMessage(tableCartKey, jsonArray.toJSONString()); + redisUtil.saveMessage(tableCartKey, JSONObject.toJSONString(cashierCartArrayList)); // 餐位费 TbCashierCart seatCost = cashierCartArrayList.stream().findFirst().filter(info -> "-999".equals(info.getProductId())).orElse(null); HashMap data = new HashMap<>(); diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/OrderService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/OrderService.java index 458c3ce..c74e180 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/OrderService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/OrderService.java @@ -451,7 +451,6 @@ public class OrderService { public Object orderDetail(Integer orderId) { - TbOrderInfo orderInfo = mpOrderInfoMapper.selectOne(new LambdaQueryWrapper() .eq(TbOrderInfo::getId, orderId)); diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/PayService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/PayService.java index 378aaaf..28ec3e0 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/PayService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/PayService.java @@ -207,7 +207,6 @@ public class PayService { return Result.fail("没有对应的商户"); } - List cashierCarts = tbCashierCartMapper.selectByOrderId(orderId, null); if (ObjectUtil.isEmpty(cashierCarts) || ObjectUtil.isNull(cashierCarts)) { return Result.fail("购物车信息不存在"); @@ -218,17 +217,16 @@ public class PayService { body.append(cashierCart.getName()); } - TbMerchantThirdApply thirdApply = tbMerchantThirdApplyMapper.selectByPrimaryKey(Integer.valueOf(orderInfo.getMerchantId())); if (ObjectUtil.isEmpty(thirdApply) || ObjectUtil.isNull(thirdApply)) { return Result.fail("支付通道不存在"); } - if ("aliPay".equals(payType) && StrUtil.isBlank(thirdApply.getAlipaySmallAppid())) { return Result.fail("店铺未配置支付宝小程序appId"); } + String userId = String.valueOf(TokenUtil.getUserId()); TbOrderPayment payment = tbOrderPaymentMapper.selectByOrderId(orderId); if (ObjectUtil.isEmpty(payment) || payment == null) { payment = new TbOrderPayment(); @@ -287,7 +285,7 @@ public class PayService { tbOrderPaymentMapper.updateByPrimaryKeySelective(payment); orderInfo.setStatus("paying"); orderInfo.setPayOrderNo(payment.getTradeNumber()); - + orderInfo.setUserId(userId); tbOrderInfoMapper.updateByPrimaryKey(orderInfo); //清除缓存购物车数据 @@ -342,7 +340,7 @@ public class PayService { tbOrderPaymentMapper.updateByPrimaryKeySelective(payment); orderInfo.setStatus("paying"); orderInfo.setPayOrderNo(payment.getTradeNumber()); - + orderInfo.setUserId(userId); tbOrderInfoMapper.updateByPrimaryKey(orderInfo); //清除缓存购物车数据 @@ -446,6 +444,7 @@ public class PayService { orderInfo.setPayType("deposit"); orderInfo.setStatus("closed"); orderInfo.setPayOrderNo("deposit".concat(SnowFlakeUtil.generateOrderNo())); + orderInfo.setUserId(String.valueOf(TokenUtil.getUserId())); tbOrderInfoMapper.updateByPrimaryKeySelective(orderInfo); //更新购物车状态 int cartCount = tbCashierCartMapper.updateStatusByOrderId(orderId, "final"); @@ -762,6 +761,7 @@ public class PayService { orderInfo.setPayType("wx_lite"); orderInfo.setPayOrderNo(payment.getTradeNumber()); orderInfo.setPayAmount(orderInfo.getOrderAmount()); + orderInfo.setUserId(String.valueOf(TokenUtil.getUserId())); tbOrderInfoMapper.updateByPrimaryKeySelective(orderInfo); @@ -814,6 +814,7 @@ public class PayService { orderInfo.setPayType("wx_lite"); orderInfo.setPayOrderNo(payment.getTradeNumber()); orderInfo.setPayAmount(orderInfo.getOrderAmount()); + orderInfo.setUserId(String.valueOf(TokenUtil.getUserId())); tbOrderInfoMapper.updateByPrimaryKeySelective(orderInfo); diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/ProductService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/ProductService.java index f3121b4..36d11f8 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/ProductService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/ProductService.java @@ -118,17 +118,20 @@ public class ProductService { return orderInfoList.isEmpty() ? null : orderInfoList.get(0); } - public Result queryShopIdByTableCode(String userId, String openId, String code, String lat, String lng) { - if (StringUtils.isBlank(code)) return Result.fail("桌码信息为空"); + public Result queryShopIdByTableCode(String userId, String openId, String code, String lat, String lng, Integer shopId) { if (StringUtils.isBlank(lat) || lat.equals("undefined")) { lat = "34.343207"; lng = "108.939645"; } - TbShopTable tbShopTable = tbShopTableMapper.selectQRcode(code); - if (tbShopTable == null) { - return Result.fail("台桌信息不存在"); + TbShopTable tbShopTable = null; + if (StrUtil.isNotBlank(code)) { + tbShopTable = tbShopTableMapper.selectQRcode(code); + if (tbShopTable == null) { + return Result.fail("台桌信息不存在"); + } } - TbShopInfo shopInfo = tbShopInfoMapper.selectByPrimaryKey(tbShopTable.getShopId()); + + TbShopInfo shopInfo = tbShopInfoMapper.selectByPrimaryKey(shopId != null ? shopId : tbShopTable.getShopId()); String distance = LocationUtils.getDistanceString( Double.parseDouble(lng), Double.parseDouble(lat), Double.parseDouble(shopInfo.getLng()), Double.parseDouble(shopInfo.getLat())); @@ -137,12 +140,15 @@ public class ProductService { // 获取当前台桌最新订单id ShopEatTypeInfoDTO shopEatTypeInfoDTO = shopUtils.checkEatModel(code, shopInfo.getId()); TbOrderInfo order = getCurrentOrder(shopEatTypeInfoDTO, code, shopInfo.getId()); - tbShopTable.setOrderId(order == null ? null : order.getId()); - tbShopTable.setChoseCount(order != null && (order.getSeatCount() != null)); - concurrentMap.put("shopTableInfo", tbShopTable); + if (tbShopTable != null) { + tbShopTable.setOrderId(order == null ? null : order.getId()); + tbShopTable.setChoseCount(order != null && (order.getSeatCount() != null)); + } + + concurrentMap.put("shopTableInfo", tbShopTable == null ? "" : tbShopTable); concurrentMap.put("storeInfo", shopInfo); concurrentMap.put("distance", distance); - TbShopUser shopUser = tbShopUserMapper.selectByUserIdAndShopId(userId, tbShopTable.getShopId().toString()); + TbShopUser shopUser = tbShopUserMapper.selectByUserIdAndShopId(userId, shopId != null ? shopId.toString() : tbShopTable.getShopId().toString()); try { if (ObjectUtil.isEmpty(shopUser)) { TbUserInfo tbUserInfo = tbUserInfoMapper.selectByPrimaryKey(Integer.valueOf(userId)); @@ -163,7 +169,7 @@ public class ProductService { shopUser.setConsumeNumber(0); shopUser.setLevelConsume(BigDecimal.ZERO); shopUser.setStatus(Byte.parseByte("1")); - shopUser.setShopId(tbShopTable.getShopId().toString()); + shopUser.setShopId(shopId != null ? shopId.toString() : tbShopTable.getShopId().toString()); shopUser.setUserId(userId); shopUser.setMiniOpenId(openId); shopUser.setCreatedAt(System.currentTimeMillis());