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 3dc9fe1..8032b54 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/controller/ProductController.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/controller/ProductController.java @@ -45,7 +45,7 @@ public class ProductController { @RequestParam(required = false) String code, @RequestParam(required = false) Integer shopId ) { - if (shopId == null && StrUtil.isNotBlank(code)) { + 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/service/ProductService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/ProductService.java index 34eb0a0..8df6bc1 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/ProductService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/ProductService.java @@ -131,7 +131,7 @@ public class ProductService { } } - TbShopInfo shopInfo = tbShopInfoMapper.selectByPrimaryKey(shopId); + 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())); @@ -148,7 +148,7 @@ public class ProductService { concurrentMap.put("shopTableInfo", tbShopTable); concurrentMap.put("storeInfo", shopInfo); concurrentMap.put("distance", distance); - TbShopUser shopUser = tbShopUserMapper.selectByUserIdAndShopId(userId, shopId.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)); @@ -169,7 +169,7 @@ public class ProductService { shopUser.setConsumeNumber(0); shopUser.setLevelConsume(BigDecimal.ZERO); shopUser.setStatus(Byte.parseByte("1")); - shopUser.setShopId(shopId.toString()); + shopUser.setShopId(shopId != null ? shopId.toString() : tbShopTable.getShopId().toString()); shopUser.setUserId(userId); shopUser.setMiniOpenId(openId); shopUser.setCreatedAt(System.currentTimeMillis());