From e30a5e21b30ea64bc8d1e5ac3e5f139ac2e167e2 Mon Sep 17 00:00:00 2001 From: SongZhang <2064194730@qq.com> Date: Thu, 26 Sep 2024 15:40:40 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BA=97=E9=93=BA=E4=BF=A1=E6=81=AF=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E8=8E=B7=E5=8F=96=E5=8F=B0=E6=A1=8Ccode=E9=9D=9E?= =?UTF-8?q?=E5=BF=85=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ProductController.java | 5 ++-- .../service/ProductService.java | 26 ++++++++++++------- 2 files changed, 19 insertions(+), 12 deletions(-) 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..0c97755 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/controller/ProductController.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/controller/ProductController.java @@ -41,9 +41,10 @@ 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 Integer shopId ) { - return productService.queryShopIdByTableCode(userId, openId, code,lat,lng); + return productService.queryShopIdByTableCode(userId, openId, code,lat,lng, shopId); } /** 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..34eb0a0 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); 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)); + if (tbShopTable != null) { + tbShopTable.setOrderId(order == null ? null : order.getId()); + tbShopTable.setChoseCount(order != null && (order.getSeatCount() != null)); + } + concurrentMap.put("shopTableInfo", tbShopTable); concurrentMap.put("storeInfo", shopInfo); concurrentMap.put("distance", distance); - TbShopUser shopUser = tbShopUserMapper.selectByUserIdAndShopId(userId, tbShopTable.getShopId().toString()); + TbShopUser shopUser = tbShopUserMapper.selectByUserIdAndShopId(userId, shopId.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.toString()); shopUser.setUserId(userId); shopUser.setMiniOpenId(openId); shopUser.setCreatedAt(System.currentTimeMillis());