From 7b793bb9f2d444d003e4b3b6193ed893fd864b2e Mon Sep 17 00:00:00 2001 From: SongZhang <2064194730@qq.com> Date: Tue, 5 Nov 2024 16:31:23 +0800 Subject: [PATCH 01/26] =?UTF-8?q?feat:=20=E5=85=85=E5=80=BC=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E6=94=AF=E4=BB=98=E5=AE=9D=E5=85=85=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cashierservice/entity/dto/MemberInDTO.java | 2 ++ .../system/cashierservice/service/PayService.java | 14 ++++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/MemberInDTO.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/MemberInDTO.java index 3ac953a..f83b9e7 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/MemberInDTO.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/MemberInDTO.java @@ -23,4 +23,6 @@ public class MemberInDTO { private Integer userCouponId; // 是否使用积分抵扣 private Integer pointsNum ; + private String payType; + } 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 069540e..ca406c0 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/PayService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/PayService.java @@ -1087,6 +1087,11 @@ public class PayService { return Result.fail("支付通道不存在"); } + if ("aliPay".equals(memberInDTO.getPayType()) && StrUtil.isBlank(thirdApply.getAlipaySmallAppid())) { + return Result.fail("店铺未配置支付宝小程序appId"); + } + + // 霸王餐活动充值 BigDecimal payAmount; TbMemberIn memberIn = new TbMemberIn(); @@ -1142,12 +1147,17 @@ public class PayService { } } } else { + String smallAppid = thirdApply.getSmallAppid(); + if ("aliPay".equals(memberInDTO.getPayType())) { + smallAppid = thirdApply.getAlipaySmallAppid(); + } + String convertPayType = "aliPay".equals(memberInDTO.getPayType()) ? "ALIPAY" : "WECHAT"; String orderNo = DateUtils.getsdfTimesSS(); PublicResp publicResp = thirdPayService .scanpay(thirdUrl, thirdApply.getAppId(), "会员充值", "会员充值", payAmount - .multiply(new BigDecimal(100)).longValue(), "WECHAT", - thirdApply.getSmallAppid(), memberInDTO.getOpenId(), ip, orderNo, thirdApply.getStoreId(), + .multiply(new BigDecimal(100)).longValue(), convertPayType, + smallAppid, memberInDTO.getOpenId(), ip, orderNo, thirdApply.getStoreId(), callInBack, null, thirdApply.getAppToken()); if (ObjectUtil.isNotNull(publicResp) && ObjectUtil.isNotEmpty(publicResp)) { if ("000000".equals(publicResp.getCode())) { From 5ebdb1610c835afe1fcc2fc5e97b6cb6c0f92fa6 Mon Sep 17 00:00:00 2001 From: SongZhang <2064194730@qq.com> Date: Tue, 5 Nov 2024 17:15:39 +0800 Subject: [PATCH 02/26] =?UTF-8?q?feat:=20=E5=BA=97=E9=93=BA=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E8=BF=94=E5=9B=9E=E9=9C=B8=E7=8E=8B=E9=A4=90=E7=9B=B8?= =?UTF-8?q?=E5=85=B3=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/cashierservice/entity/TbFreeDineConfig.java | 6 +++--- .../system/cashierservice/service/ProductService.java | 10 +++++++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbFreeDineConfig.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbFreeDineConfig.java index 38d8bc3..9ca87e6 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbFreeDineConfig.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbFreeDineConfig.java @@ -17,7 +17,7 @@ import lombok.Data; @Data public class TbFreeDineConfig implements Serializable { /** - * + * */ @TableId(type = IdType.AUTO) private Integer id; @@ -25,7 +25,7 @@ public class TbFreeDineConfig implements Serializable { /** * 是否启用 */ - private Integer enable; + private Integer enable = 0; /** * 充值多少倍免单 @@ -147,4 +147,4 @@ public class TbFreeDineConfig implements Serializable { sb.append("]"); return sb.toString(); } -} \ No newline at end of file +} 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 71be3ca..0fe39c3 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/ProductService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/ProductService.java @@ -107,9 +107,11 @@ public class ProductService { private RedisUtil redisUtil; @Autowired private StringRedisTemplate stringRedisTemplate; + private final TbFreeDineConfigService freeDineConfigService; - public ProductService(ShopUtils shopUtils) { + public ProductService(ShopUtils shopUtils, TbFreeDineConfigService freeDineConfigService) { this.shopUtils = shopUtils; + this.freeDineConfigService = freeDineConfigService; } private TbOrderInfo getCurrentOrder(ShopEatTypeInfoDTO eatTypeInfoDTO, String tableId, Object shopId) { @@ -167,6 +169,12 @@ public class ProductService { concurrentMap.put("storeInfo", shopInfo); concurrentMap.put("distance", distance); TbShopUser shopUser = tbShopUserMapper.selectByUserIdAndShopId(userId, shopId != null ? shopId.toString() : tbShopTable.getShopId().toString()); + TbFreeDineConfig freeDineConfig = freeDineConfigService.getOne(new LambdaQueryWrapper() + .eq(TbFreeDineConfig::getShopId, shopId)); + if (freeDineConfig == null) { + freeDineConfig = new TbFreeDineConfig(); + } + concurrentMap.put("freeDingConfig", freeDineConfig); try { if (ObjectUtil.isEmpty(shopUser)) { TbUserInfo tbUserInfo = tbUserInfoMapper.selectByPrimaryKey(Integer.valueOf(userId)); From 5285a0875f7f81fc693835f2bba0673e68f55bed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Wed, 6 Nov 2024 09:49:34 +0800 Subject: [PATCH 03/26] =?UTF-8?q?feat:=20=E8=B4=AD=E7=89=A9=E8=BD=A6?= =?UTF-8?q?=E5=8F=8A=E8=AE=A2=E5=8D=95=E5=A2=9E=E5=8A=A0=E4=BC=9A=E5=91=98?= =?UTF-8?q?=E4=BB=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cashierservice/entity/TbCashierCart.java | 14 +++++++++++ .../cashierservice/service/CartService.java | 25 ++++++++++++++----- 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbCashierCart.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbCashierCart.java index 2c3d94b..d397a35 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbCashierCart.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbCashierCart.java @@ -34,6 +34,8 @@ public class TbCashierCart implements Serializable { private String skuName; private BigDecimal salePrice; + // 会员价 + private BigDecimal memberPrice; private BigDecimal packFee; private Integer number; @@ -74,6 +76,9 @@ public class TbCashierCart implements Serializable { // 使用的优惠券id private Integer userCouponId; + // 是否是会员 + private Integer isMember; + private static final long serialVersionUID = 1L; public String getSkuName() { @@ -83,4 +88,13 @@ public class TbCashierCart implements Serializable { return ""; } } + + + public void resetTotalAmount() { + if (isMember != null && isMember == 1) { + totalAmount = BigDecimal.valueOf(totalNumber).multiply(memberPrice).add(packFee); + }else { + totalAmount = BigDecimal.valueOf(totalNumber).multiply(salePrice).add(packFee); + } + } } 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 531a562..fc97e49 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/CartService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/CartService.java @@ -16,6 +16,7 @@ import com.chaozhanggui.system.cashierservice.entity.Enum.PlatformTypeEnum; import com.chaozhanggui.system.cashierservice.entity.Enum.ShopWxMsgTypeEnum; import com.chaozhanggui.system.cashierservice.entity.*; import com.chaozhanggui.system.cashierservice.entity.dto.*; +import com.chaozhanggui.system.cashierservice.entity.vo.ShopUserListVo; import com.chaozhanggui.system.cashierservice.entity.vo.TbUserCouponVo; import com.chaozhanggui.system.cashierservice.exception.MsgException; import com.chaozhanggui.system.cashierservice.mapper.*; @@ -209,7 +210,7 @@ public class CartService { } if (cashierCart.getIsVip().equals((byte) 1)) continue; if ((!TableConstant.CART_SEAT_ID.equals(cashierCart.getProductId()) || !ignoreTableFee) && cashierCart.getNumber() > 0) { - amount = amount.add(new BigDecimal(cashierCart.getTotalNumber()).multiply(cashierCart.getSalePrice().add(cashierCart.getPackFee()))); + amount = amount.add(cashierCart.getTotalAmount()); } } redisUtil.saveMessage(tableCartKey, array.toString(), 60 * 60 * 12L); @@ -410,8 +411,7 @@ public class CartService { if (isVip != null && isVip == 1) { cashierCart.setTotalAmount(BigDecimal.ZERO); } else { - cashierCart.setTotalAmount(new BigDecimal(cashierCart.getTotalNumber()) - .multiply(cashierCart.getSalePrice().add(cashierCart.getPackFee()))); + cashierCart.resetTotalAmount(); } cashierCart.setUpdatedAt(Instant.now().toEpochMilli()); mpCashierCartMapper.updateById(cashierCart); @@ -575,6 +575,12 @@ public class CartService { private TbCashierCart addCart(String productId, String skuId, Integer userId, Integer num, String tableId, String shopId, Integer isVip, String note, boolean isTakeout) throws Exception { try { + // 查询用户信息 + TbShopUser shopUser = shopUserMapper.selectByUserIdAndShopId(String.valueOf(userId), shopId); + if (shopUser == null) { + throw new MsgException("用户不存在"); + } + TbProduct product = productMapper.selectById(Integer.valueOf(productId)); String key = tableId + "-" + shopId; TbProductSkuWithBLOBs productSku = productSkuMapper.selectByPrimaryKey(Integer.valueOf(skuId)); @@ -602,6 +608,7 @@ public class CartService { cashierCart.setNumber(num); cashierCart.setTotalNumber(num); } + cashierCart.setIsMember(Integer.valueOf(shopUser.getIsVip())); cashierCart.setNote(note); cashierCart.setProductId(productId); cashierCart.setSkuId(skuId); @@ -621,6 +628,7 @@ public class CartService { cashierCart.setUpdatedAt(Instant.now().toEpochMilli()); cashierCart.setPackFee(BigDecimal.ZERO); cashierCart.setRefundNumber(0); + cashierCart.setMemberPrice(productSku.getMemberPrice()); cashierCart.setTradeDay(DateUtils.getDay()); // 打包费 if (isTakeout && product.getPackFee() != null) { @@ -632,7 +640,7 @@ public class CartService { cashierCart.setSalePrice(BigDecimal.ZERO); } else { cashierCart.setIsVip((byte) 0); - cashierCart.setTotalAmount(new BigDecimal(cashierCart.getTotalNumber()).multiply(productSku.getSalePrice().add(cashierCart.getPackFee()))); + cashierCart.resetTotalAmount(); } cashierCart.setPlatformType(PlatformTypeEnum.MINI_APP.getValue()); mpCashierCartMapper.insert(cashierCart); @@ -1193,7 +1201,7 @@ public class CartService { } - private OrderCartInfoDTO getCartInfoForOrder(ShopEatTypeInfoDTO shopEatTypeInfoDTO, List allCartList, TbShopTable shopTable) { + private OrderCartInfoDTO getCartInfoForOrder(ShopEatTypeInfoDTO shopEatTypeInfoDTO, List allCartList, TbShopTable shopTable, TbShopUser shopUser) { OrderCartInfoDTO infoDTO = new OrderCartInfoDTO(); // 就餐人数 ArrayList cashierIds = new ArrayList<>(); @@ -1201,6 +1209,9 @@ public class CartService { Integer orderId = null; for (TbCashierCart tbCashierCart : allCartList) { cashierIds.add(tbCashierCart.getId()); + // 设置会员信息及价格 + tbCashierCart.setIsMember(shopUser.getIsVip().intValue()); + tbCashierCart.resetTotalAmount(); if (TableConstant.CashierCart.ID.equals(tbCashierCart.getProductId())) { seatInfo = tbCashierCart; } @@ -1274,6 +1285,8 @@ public class CartService { if (tbUserInfo == null) { MsgException.throwException("生成订单失败"); } + + // 用户信息 TbShopUser tbShopUser = shopUserMapper.selectByUserIdAndShopId(userId, shopId); // 获取当前下单次数和用餐类型 @@ -1293,7 +1306,7 @@ public class CartService { TbShopTable shopTable = getTableInfoByEatType(shopEatTypeInfoDTO); // 获取详细的购物车信息 - OrderCartInfoDTO cartInfoDTO = getCartInfoForOrder(shopEatTypeInfoDTO, cashierCartList, shopTable); + OrderCartInfoDTO cartInfoDTO = getCartInfoForOrder(shopEatTypeInfoDTO, cashierCartList, shopTable, tbShopUser); // 获取订单信息 TbOrderInfo orderInfo = null; From 7bbc7de1f8f0ff5d3d97b596fb813661d7b605ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Wed, 6 Nov 2024 10:01:09 +0800 Subject: [PATCH 04/26] =?UTF-8?q?feat:=20=E8=B4=AD=E7=89=A9=E8=BD=A6?= =?UTF-8?q?=E5=8F=8A=E8=AE=A2=E5=8D=95=E5=A2=9E=E5=8A=A0=E4=BC=9A=E5=91=98?= =?UTF-8?q?=E4=BB=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cashierservice/service/CartService.java | 35 ++++++++----------- 1 file changed, 14 insertions(+), 21 deletions(-) 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 fc97e49..ad36013 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/CartService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/CartService.java @@ -153,7 +153,6 @@ public class CartService { String tableId = jsonObject.getString("tableId"); String shopId = jsonObject.getString("shopId"); Integer userId = jsonObject.getInteger("userId"); - BigDecimal amount = BigDecimal.ZERO; JSONArray array = new JSONArray(); ShopEatTypeInfoDTO shopEatTypeInfoDTO = shopUtils.getEatModel(tableId, shopId); @@ -166,25 +165,6 @@ public class CartService { boolean ignoreTableFee = shopInfo.getIsTableFee() != null && shopInfo.getIsTableFee() == 1; TbCashierCart seatCartInfo = null; -// if (redisUtil.exists(tableCartKey)) { -// JSONArray jsonArray = JSON.parseArray(redisUtil.getMessage(tableCartKey)); -// for (int i = 0; i < jsonArray.size(); i++) { -// JSONObject object = array.getJSONObject(i); -// TbCashierCart cashierCart = JSONUtil.parseJSONStr2T(object.toJSONString(), TbCashierCart.class); -// if ((!TableConstant.CART_SEAT_ID.equals(cashierCart.getProductId()) || !ignoreTableFee) && cashierCart.getNumber() > 0) { -// amount = amount.add(new BigDecimal(cashierCart.getTotalNumber()).multiply(cashierCart.getSalePrice().add(cashierCart.getPackFee()))); -// } -// -// if (TableConstant.CART_SEAT_ID.equals(cashierCart.getProductId())) { -// seatCartInfo = cashierCart; -// if (!ignoreTableFee) { -// array.add(cashierCart); -// } -// }else { -// array.add(cashierCart); -// } -// } -// } else { // 查询购物车所有信息 LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper() @@ -200,6 +180,9 @@ public class CartService { queryWrapper.eq(TbCashierCart::getUserId, userId); } + + BigDecimal amount = BigDecimal.ZERO; + BigDecimal memberAmount = BigDecimal.ZERO; List tbCashierCarts = mpCashierCartMapper.selectList(queryWrapper); if (!CollectionUtils.isEmpty(tbCashierCarts)) { for (TbCashierCart cashierCart : tbCashierCarts) { @@ -210,7 +193,8 @@ public class CartService { } if (cashierCart.getIsVip().equals((byte) 1)) continue; if ((!TableConstant.CART_SEAT_ID.equals(cashierCart.getProductId()) || !ignoreTableFee) && cashierCart.getNumber() > 0) { - amount = amount.add(cashierCart.getTotalAmount()); + amount = amount.add(cashierCart.getSalePrice().multiply(BigDecimal.valueOf(cashierCart.getTotalNumber())).add(cashierCart.getPackFee())); + memberAmount = memberAmount.add(cashierCart.getMemberPrice().multiply(BigDecimal.valueOf(cashierCart.getTotalNumber())).add(cashierCart.getPackFee())); } } redisUtil.saveMessage(tableCartKey, array.toString(), 60 * 60 * 12L); @@ -229,6 +213,7 @@ public class CartService { jsonObject1.put("type", "addCart"); jsonObject1.put("data", array); jsonObject1.put("amount", amount); + jsonObject1.put("memberAmount", memberAmount); PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), tableCartKey, "", false); } @@ -358,6 +343,7 @@ public class CartService { JSONArray jsonArray = new JSONArray(); ArrayList cashierCartArrayList = new ArrayList<>(); BigDecimal amount = BigDecimal.ZERO; + BigDecimal memberAmount = BigDecimal.ZERO; try { if (redisUtil.exists(tableCartKey)) { JSONArray array = JSON.parseArray(redisUtil.getMessage(tableCartKey)); @@ -369,6 +355,7 @@ public class CartService { cashierCart.setPlaceNum(cashierCart.getPlaceNum() == null ? 0 : cashierCart.getPlaceNum()); cashierCartArrayList.add(cashierCart); amount = amount.add(new BigDecimal(cashierCart.getNumber()).multiply(cashierCart.getSalePrice().add(cashierCart.getPackFee()))); + memberAmount = memberAmount.add(new BigDecimal(cashierCart.getNumber()).multiply(cashierCart.getMemberPrice().add(cashierCart.getPackFee()))); } } else { @@ -424,6 +411,7 @@ public class CartService { jsonArray.add(cashierCart); cashierCartArrayList.add(cashierCart); amount = amount.add(new BigDecimal(cashierCart.getTotalNumber()).multiply(cashierCart.getSalePrice().add(cashierCart.getPackFee()))); + memberAmount = memberAmount.add(new BigDecimal(cashierCart.getNumber()).multiply(cashierCart.getMemberPrice().add(cashierCart.getPackFee()))); if ("-999".equals(cashierCart.getProductId())) { hasSeat = true; @@ -435,6 +423,8 @@ public class CartService { jsonObject.getInteger("userId"), buyNum, tableId, shopId, isVip, note, shopEatTypeInfoDTO.isTakeout()); jsonArray.add(cashierCart); amount = amount.add(new BigDecimal(cashierCart.getTotalNumber()).multiply(cashierCart.getSalePrice().add(cashierCart.getPackFee()))); + memberAmount = memberAmount.add(new BigDecimal(cashierCart.getNumber()).multiply(cashierCart.getMemberPrice().add(cashierCart.getPackFee()))); + } } @@ -449,6 +439,8 @@ public class CartService { cashierCartArrayList.add(cashierCart); if (isVip != 1) { amount = amount.add(new BigDecimal(cashierCart.getTotalNumber()).multiply(cashierCart.getSalePrice().add(cashierCart.getPackFee()))); + memberAmount = memberAmount.add(new BigDecimal(cashierCart.getNumber()).multiply(cashierCart.getMemberPrice().add(cashierCart.getPackFee()))); + } } } @@ -469,6 +461,7 @@ public class CartService { data.put("data", jsonArray); data.put("seatFee", BeanUtil.copyProperties(seatCost, TbCashierCart.class)); data.put("amount", amount); + data.put("memberAmount", memberAmount); data.put("reqData", jsonObject); PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(JSONObject.toJSONString(data), tableCartKey, "", false); } catch (Exception e) { From 7b86cbfcb6f0b2c8ce9ae0decac98aee6ee3763d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Wed, 6 Nov 2024 10:11:25 +0800 Subject: [PATCH 05/26] =?UTF-8?q?feat:=20=E8=B4=AD=E7=89=A9=E8=BD=A6?= =?UTF-8?q?=E5=8F=8A=E8=AE=A2=E5=8D=95=E5=A2=9E=E5=8A=A0=E4=BC=9A=E5=91=98?= =?UTF-8?q?=E4=BB=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/cashierservice/service/CartService.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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 ad36013..be853f2 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/CartService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/CartService.java @@ -601,7 +601,7 @@ public class CartService { cashierCart.setNumber(num); cashierCart.setTotalNumber(num); } - cashierCart.setIsMember(Integer.valueOf(shopUser.getIsVip())); + cashierCart.setIsMember(shopUser.getIsVip() == 1 && productSku.getMemberPrice() != null ? 1 : 0); cashierCart.setNote(note); cashierCart.setProductId(productId); cashierCart.setSkuId(skuId); @@ -1203,7 +1203,12 @@ public class CartService { for (TbCashierCart tbCashierCart : allCartList) { cashierIds.add(tbCashierCart.getId()); // 设置会员信息及价格 - tbCashierCart.setIsMember(shopUser.getIsVip().intValue()); + if (shopUser.getIsVip() == 0) { + tbCashierCart.setIsMember(0); + }else { + TbProductSkuWithBLOBs sku = productSkuMapper.selectByPrimaryKey(Integer.valueOf(tbCashierCart.getSkuId())); + tbCashierCart.setIsMember(sku.getMemberPrice() != null ? 1 : 0); + } tbCashierCart.resetTotalAmount(); if (TableConstant.CashierCart.ID.equals(tbCashierCart.getProductId())) { seatInfo = tbCashierCart; From e5e0e2a8257bdb320f380c37e9575268cf0e0ec7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Wed, 6 Nov 2024 13:50:54 +0800 Subject: [PATCH 06/26] =?UTF-8?q?feat:=20=E4=BC=9A=E5=91=98=E4=BB=B7?= =?UTF-8?q?=E7=9B=B8=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/cashierservice/entity/TbCashierCart.java | 2 +- .../system/cashierservice/entity/TbOrderDetail.java | 1 + .../system/cashierservice/service/CartService.java | 7 ++++--- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbCashierCart.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbCashierCart.java index d397a35..f0a7f3c 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbCashierCart.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbCashierCart.java @@ -91,7 +91,7 @@ public class TbCashierCart implements Serializable { public void resetTotalAmount() { - if (isMember != null && isMember == 1) { + if (isMember != null && isMember == 1 && memberPrice.compareTo(BigDecimal.ZERO) > 0) { totalAmount = BigDecimal.valueOf(totalNumber).multiply(memberPrice).add(packFee); }else { totalAmount = BigDecimal.valueOf(totalNumber).multiply(salePrice).add(packFee); 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 d91d8db..90f2f56 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbOrderDetail.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbOrderDetail.java @@ -45,6 +45,7 @@ public class TbOrderDetail implements Serializable { private Integer placeNum; private String useType; private String note; + private BigDecimal memberPrice; private static final long serialVersionUID = 1L; } 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 be853f2..2be9a18 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/CartService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/CartService.java @@ -601,7 +601,7 @@ public class CartService { cashierCart.setNumber(num); cashierCart.setTotalNumber(num); } - cashierCart.setIsMember(shopUser.getIsVip() == 1 && productSku.getMemberPrice() != null ? 1 : 0); + cashierCart.setIsMember(shopUser.getIsVip() == 1 && productSku.getMemberPrice() != null && productSku.getMemberPrice().compareTo(BigDecimal.ZERO) > 0 ? 1 : 0); cashierCart.setNote(note); cashierCart.setProductId(productId); cashierCart.setSkuId(skuId); @@ -621,7 +621,7 @@ public class CartService { cashierCart.setUpdatedAt(Instant.now().toEpochMilli()); cashierCart.setPackFee(BigDecimal.ZERO); cashierCart.setRefundNumber(0); - cashierCart.setMemberPrice(productSku.getMemberPrice()); + cashierCart.setMemberPrice(productSku.getMemberPrice() == null || productSku.getMemberPrice().compareTo(BigDecimal.ZERO) <= 0 ? productSku.getSalePrice() : productSku.getMemberPrice()); cashierCart.setTradeDay(DateUtils.getDay()); // 打包费 if (isTakeout && product.getPackFee() != null) { @@ -1076,6 +1076,7 @@ public class CartService { orderDetail.setProductSkuName(productSku.getSpecSnap()); } + orderDetail.setMemberPrice(cashierCart.getMemberPrice()); orderDetail.setNote(cashierCart.getNote()); orderDetail.setCreateTime(DateUtil.date().toTimestamp()); orderDetail.setNum(cashierCart.getNumber()); @@ -1207,7 +1208,7 @@ public class CartService { tbCashierCart.setIsMember(0); }else { TbProductSkuWithBLOBs sku = productSkuMapper.selectByPrimaryKey(Integer.valueOf(tbCashierCart.getSkuId())); - tbCashierCart.setIsMember(sku.getMemberPrice() != null ? 1 : 0); + tbCashierCart.setIsMember(sku.getMemberPrice() != null && sku.getMemberPrice().compareTo(BigDecimal.ZERO) > 0 ? 1 : 0); } tbCashierCart.resetTotalAmount(); if (TableConstant.CashierCart.ID.equals(tbCashierCart.getProductId())) { From bc21f638e65da80734911cea3ff26885683a5228 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Wed, 6 Nov 2024 13:58:54 +0800 Subject: [PATCH 07/26] =?UTF-8?q?feat:=20=E4=BC=9A=E5=91=98=E4=BB=B7?= =?UTF-8?q?=E7=9B=B8=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/cashierservice/entity/TbCashierCart.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbCashierCart.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbCashierCart.java index f0a7f3c..6d02063 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbCashierCart.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbCashierCart.java @@ -35,7 +35,7 @@ public class TbCashierCart implements Serializable { private BigDecimal salePrice; // 会员价 - private BigDecimal memberPrice; + private BigDecimal memberPrice = BigDecimal.ZERO; private BigDecimal packFee; private Integer number; From 84356ca24554f299f0dc31b338c03bb4c2616629 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Wed, 6 Nov 2024 14:26:37 +0800 Subject: [PATCH 08/26] =?UTF-8?q?fix:=20=E5=88=9B=E5=BB=BA=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/cashierservice/service/CartService.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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 2be9a18..360ea06 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/CartService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/CartService.java @@ -1207,8 +1207,10 @@ public class CartService { if (shopUser.getIsVip() == 0) { tbCashierCart.setIsMember(0); }else { - TbProductSkuWithBLOBs sku = productSkuMapper.selectByPrimaryKey(Integer.valueOf(tbCashierCart.getSkuId())); - tbCashierCart.setIsMember(sku.getMemberPrice() != null && sku.getMemberPrice().compareTo(BigDecimal.ZERO) > 0 ? 1 : 0); + if (!TableConstant.CashierCart.ID.equals(tbCashierCart.getProductId())) { + TbProductSkuWithBLOBs sku = productSkuMapper.selectByPrimaryKey(Integer.valueOf(tbCashierCart.getSkuId())); + tbCashierCart.setIsMember(sku.getMemberPrice() != null && sku.getMemberPrice().compareTo(BigDecimal.ZERO) > 0 ? 1 : 0); + } } tbCashierCart.resetTotalAmount(); if (TableConstant.CashierCart.ID.equals(tbCashierCart.getProductId())) { From 4c4f249ff4c41299bc14aefc8ca14e27e971b6dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Wed, 6 Nov 2024 14:33:18 +0800 Subject: [PATCH 09/26] =?UTF-8?q?fix:=20=E6=94=AF=E4=BB=98=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chaozhanggui/system/cashierservice/service/PayService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 ca406c0..ff16829 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/PayService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/PayService.java @@ -594,7 +594,7 @@ public class PayService { } user.setAmount(user.getAmount().subtract(orderInfo.getOrderAmount())); - user.setConsumeAmount(user.getConsumeAmount().add(orderInfo.getPayAmount())); + user.setConsumeAmount(user.getConsumeAmount().add(orderInfo.getOrderAmount())); user.setConsumeNumber(user.getConsumeNumber() + 1); user.setUpdatedAt(System.currentTimeMillis()); tbShopUserMapper.updateByPrimaryKeySelective(user); From d1ca5179f95b44440e1e09f012a5d24cd40763be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Wed, 6 Nov 2024 14:43:35 +0800 Subject: [PATCH 10/26] =?UTF-8?q?fix:=20=E4=BC=9A=E5=91=98=E4=BB=B7?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chaozhanggui/system/cashierservice/service/CartService.java | 2 +- .../system/cashierservice/service/ProductService.java | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) 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 360ea06..6fa0441 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/CartService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/CartService.java @@ -192,7 +192,7 @@ public class CartService { array.add(cashierCart); } if (cashierCart.getIsVip().equals((byte) 1)) continue; - if ((!TableConstant.CART_SEAT_ID.equals(cashierCart.getProductId()) || !ignoreTableFee) && cashierCart.getNumber() > 0) { + if (!ignoreTableFee && cashierCart.getNumber() > 0) { amount = amount.add(cashierCart.getSalePrice().multiply(BigDecimal.valueOf(cashierCart.getTotalNumber())).add(cashierCart.getPackFee())); memberAmount = memberAmount.add(cashierCart.getMemberPrice().multiply(BigDecimal.valueOf(cashierCart.getTotalNumber())).add(cashierCart.getPackFee())); } 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 0fe39c3..b8b2395 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/ProductService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/ProductService.java @@ -902,6 +902,7 @@ public class ProductService { tbCashierCart.setProductId(TableConstant.CART_SEAT_ID); tbCashierCart.setSkuId(TableConstant.CART_SEAT_ID); tbCashierCart.setPackFee(BigDecimal.ZERO); + tbCashierCart.setMemberPrice(shopInfo.getTableFee()); tbCashierCart.setNumber(choseCountDTO.getNum()); tbCashierCart.setTotalNumber(choseCountDTO.getNum()); tbCashierCart.setUseType(shopEatTypeInfoDTO.getUseType()); From 72b67803396c746ee8ed949a677a65a134ef4e3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Wed, 6 Nov 2024 15:45:36 +0800 Subject: [PATCH 11/26] =?UTF-8?q?fix:=20=E4=BC=9A=E5=91=98=E4=BB=B7?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/cashierservice/controller/ProductController.java | 5 ++++- .../system/cashierservice/service/CartService.java | 2 +- 2 files changed, 5 insertions(+), 2 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 77fcd9a..b50857a 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/controller/ProductController.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/controller/ProductController.java @@ -121,15 +121,18 @@ public class ProductController { public Result choseEatModel(@Validated @RequestBody ChoseEatModelDTO choseEatModelDTO) { List cashierCartList = cartService.choseEatModel(choseEatModelDTO); BigDecimal amount = BigDecimal.ZERO; + BigDecimal memberAmount = BigDecimal.ZERO; ArrayList cashierCarts = new ArrayList<>(); for (TbCashierCart item : cashierCartList) { if (!TableConstant.CART_SEAT_ID.equals(item.getProductId())) { cashierCarts.add(item); } - amount = amount.add(item.getTotalAmount()); + amount = amount.add(item.getSalePrice().multiply(BigDecimal.valueOf(item.getTotalNumber())).add(item.getPackFee())); + memberAmount = memberAmount.add(item.getMemberPrice().multiply(BigDecimal.valueOf(item.getTotalNumber())).add(item.getPackFee())); } HashMap data = new HashMap<>(); data.put("amount", amount); + data.put("memberAmount", amount); data.put("info", cashierCarts); return Result.success(CodeEnum.SUCCESS, data); } 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 6fa0441..76661a1 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/CartService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/CartService.java @@ -192,7 +192,7 @@ public class CartService { array.add(cashierCart); } if (cashierCart.getIsVip().equals((byte) 1)) continue; - if (!ignoreTableFee && cashierCart.getNumber() > 0) { + if ((!ignoreTableFee || !TableConstant.CART_SEAT_ID.equals(cashierCart.getProductId())) && cashierCart.getNumber() > 0) { amount = amount.add(cashierCart.getSalePrice().multiply(BigDecimal.valueOf(cashierCart.getTotalNumber())).add(cashierCart.getPackFee())); memberAmount = memberAmount.add(cashierCart.getMemberPrice().multiply(BigDecimal.valueOf(cashierCart.getTotalNumber())).add(cashierCart.getPackFee())); } From d9d789f49388fd78d3ebda6f291a7b979af30c4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Wed, 6 Nov 2024 15:48:15 +0800 Subject: [PATCH 12/26] =?UTF-8?q?fix:=20=E4=BC=9A=E5=91=98=E4=BB=B7?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/cashierservice/controller/ProductController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 b50857a..ab5edb7 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/controller/ProductController.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/controller/ProductController.java @@ -132,7 +132,7 @@ public class ProductController { } HashMap data = new HashMap<>(); data.put("amount", amount); - data.put("memberAmount", amount); + data.put("memberAmount", memberAmount); data.put("info", cashierCarts); return Result.success(CodeEnum.SUCCESS, data); } From 437e0c4ced89d853105373846a782399a980b046 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Wed, 6 Nov 2024 15:51:12 +0800 Subject: [PATCH 13/26] =?UTF-8?q?fix:=20=E4=BC=9A=E5=91=98=E4=BB=B7?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chaozhanggui/system/cashierservice/service/CartService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 76661a1..00a1a77 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/CartService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/CartService.java @@ -192,7 +192,7 @@ public class CartService { array.add(cashierCart); } if (cashierCart.getIsVip().equals((byte) 1)) continue; - if ((!ignoreTableFee || !TableConstant.CART_SEAT_ID.equals(cashierCart.getProductId())) && cashierCart.getNumber() > 0) { + if ((!TableConstant.CART_SEAT_ID.equals(cashierCart.getProductId())) && cashierCart.getNumber() > 0) { amount = amount.add(cashierCart.getSalePrice().multiply(BigDecimal.valueOf(cashierCart.getTotalNumber())).add(cashierCart.getPackFee())); memberAmount = memberAmount.add(cashierCart.getMemberPrice().multiply(BigDecimal.valueOf(cashierCart.getTotalNumber())).add(cashierCart.getPackFee())); } From e92e0c3c62762087b47e3580db3677c321cfd855 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Wed, 6 Nov 2024 17:01:47 +0800 Subject: [PATCH 14/26] =?UTF-8?q?fix:=20=E6=9C=AA=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E4=BC=9A=E5=91=98=E4=BB=B7=E4=B8=8E=E5=95=86=E5=93=81=E4=BB=B7?= =?UTF-8?q?=E4=BF=9D=E6=8C=81=E4=B8=80=E8=87=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/cashierservice/service/ProductService.java | 4 ++++ 1 file changed, 4 insertions(+) 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 b8b2395..635d0b3 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/ProductService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/ProductService.java @@ -489,6 +489,10 @@ public class ProductService { if (lowMemberPrice == null || lowMemberPrice.compareTo(item.getMemberPrice()) > 0) { lowMemberPrice = item.getMemberPrice(); } + + if (item.getMemberPrice() == null || item.getMemberPrice().compareTo(BigDecimal.ZERO) <= 0) { + item.setMealPrice(item.getSalePrice()); + } } // 销量 it.setStockNumber(sum.intValue()); From 7d86bc5c28d1c988d6f12bf7e7c1685c467d849f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Thu, 7 Nov 2024 09:47:46 +0800 Subject: [PATCH 15/26] =?UTF-8?q?fix:=20=E5=88=87=E6=8D=A2=E5=B0=B1?= =?UTF-8?q?=E9=A4=90=E6=A8=A1=E5=BC=8F=E8=BF=94=E5=9B=9E=E7=9A=84=E4=BB=B7?= =?UTF-8?q?=E6=A0=BC=E4=B8=8D=E5=8C=85=E5=90=AB=E5=AE=A2=E5=BA=A7=E8=B4=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cashierservice/controller/ProductController.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 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 ab5edb7..151cc76 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/controller/ProductController.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/controller/ProductController.java @@ -123,17 +123,21 @@ public class ProductController { BigDecimal amount = BigDecimal.ZERO; BigDecimal memberAmount = BigDecimal.ZERO; ArrayList cashierCarts = new ArrayList<>(); + TbCashierCart seatFee = null; for (TbCashierCart item : cashierCartList) { if (!TableConstant.CART_SEAT_ID.equals(item.getProductId())) { cashierCarts.add(item); + amount = amount.add(item.getSalePrice().multiply(BigDecimal.valueOf(item.getTotalNumber())).add(item.getPackFee())); + memberAmount = memberAmount.add(item.getMemberPrice().multiply(BigDecimal.valueOf(item.getTotalNumber())).add(item.getPackFee())); + }else { + seatFee = item; } - amount = amount.add(item.getSalePrice().multiply(BigDecimal.valueOf(item.getTotalNumber())).add(item.getPackFee())); - memberAmount = memberAmount.add(item.getMemberPrice().multiply(BigDecimal.valueOf(item.getTotalNumber())).add(item.getPackFee())); } HashMap data = new HashMap<>(); data.put("amount", amount); data.put("memberAmount", memberAmount); data.put("info", cashierCarts); + data.put("seatFee", seatFee); return Result.success(CodeEnum.SUCCESS, data); } From 7f34a7fcfae16715abcc35c8f2bcf248fdd883ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Thu, 7 Nov 2024 11:23:00 +0800 Subject: [PATCH 16/26] =?UTF-8?q?fix:=20=E9=A4=90=E4=BD=8D=E8=B4=B9?= =?UTF-8?q?=E6=A0=A1=E9=AA=8C=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/chaozhanggui/system/cashierservice/util/ShopUtils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/util/ShopUtils.java b/src/main/java/com/chaozhanggui/system/cashierservice/util/ShopUtils.java index 24ef19f..4228639 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/util/ShopUtils.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/util/ShopUtils.java @@ -59,7 +59,7 @@ public class ShopUtils { boolean isNoneTable = !hasTable && !isTakeout; - boolean needSeatFee = shopInfo.getIsTableFee() == null || shopInfo.getIsTableFee() == 0; + boolean needSeatFee = !isTakeout && (shopInfo.getIsTableFee() == null || shopInfo.getIsTableFee() == 0); boolean isIncrMasterId = isTakeout || isNoneTable; From 6f94f63697d8e0842404b0caec24bbd204ec625d Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Tue, 29 Oct 2024 18:25:51 +0800 Subject: [PATCH 17/26] =?UTF-8?q?=E5=88=86=E4=BA=AB=E5=A5=BD=E5=8F=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/TbShopShareController.java | 40 +++++ .../cashierservice/dao/TbShopShareMapper.java | 69 ++++++++ .../cashierservice/entity/TbShopShare.java | 129 ++++++++++++++ .../service/TbShopShareService.java | 24 +++ .../service/impl/TbShopCouponServiceImpl.java | 68 ++++---- .../service/impl/TbShopShareServiceImpl.java | 107 ++++++++++++ .../resources/mapper/TbShopShareMapper.xml | 164 ++++++++++++++++++ 7 files changed, 567 insertions(+), 34 deletions(-) create mode 100644 src/main/java/com/chaozhanggui/system/cashierservice/controller/TbShopShareController.java create mode 100644 src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopShareMapper.java create mode 100644 src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopShare.java create mode 100644 src/main/java/com/chaozhanggui/system/cashierservice/service/TbShopShareService.java create mode 100644 src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbShopShareServiceImpl.java create mode 100644 src/main/resources/mapper/TbShopShareMapper.xml diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/controller/TbShopShareController.java b/src/main/java/com/chaozhanggui/system/cashierservice/controller/TbShopShareController.java new file mode 100644 index 0000000..c3f139f --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/controller/TbShopShareController.java @@ -0,0 +1,40 @@ +package com.chaozhanggui.system.cashierservice.controller; + +import com.chaozhanggui.system.cashierservice.service.TbShopShareService; +import com.chaozhanggui.system.cashierservice.sign.Result; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; + +/** + * 店铺分享(TbShopShare)表控制层 + * + * @author ww + * @since 2024-11-07 14:36:27 + */ +@RestController +@RequestMapping("tbShopShare") +public class TbShopShareController { + /** + * 服务对象 + */ + @Resource + private TbShopShareService tbShopShareService; + + + /** + * 通过主键查询单条数据 + * + * @param shopId 主键 + * @return 单条数据 + */ + @GetMapping("getByShopId") + public Result queryById(@RequestParam Integer shopId) { + return Result.successWithData(tbShopShareService.queryByShopId(shopId)); + } + +} + diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopShareMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopShareMapper.java new file mode 100644 index 0000000..a24827a --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopShareMapper.java @@ -0,0 +1,69 @@ +package com.chaozhanggui.system.cashierservice.dao; + +import com.chaozhanggui.system.cashierservice.entity.TbShopShare; +import org.apache.ibatis.annotations.Param; +import org.springframework.data.domain.Pageable; + +import java.util.List; + +/** + * 店铺分享(TbShopShare)表数据库访问层 + * + * @author ww + * @since 2024-11-07 14:36:27 + */ +public interface TbShopShareMapper { + + /** + * 通过ID查询单条数据 + * + * @param id 主键 + * @return 实例对象 + */ + TbShopShare queryById(Integer id); + TbShopShare queryByShopId(Integer shopId); + + /** + * 查询数据 + * + * @param tbShopShare 查询条件 + * @param pageable 分页对象 + * @return 对象列表 + */ + List queryAll(TbShopShare tbShopShare, @Param("pageable") Pageable pageable); + + + /** + * 新增数据 + * + * @param tbShopShare 实例对象 + * @return 影响行数 + */ + int insert(TbShopShare tbShopShare); + + /** + * 批量新增数据(MyBatis原生foreach方法) + * + * @param entities List 实例对象列表 + * @return 影响行数 + */ + int insertBatch(@Param("entities") List entities); + + /** + * 修改数据 + * + * @param tbShopShare 实例对象 + * @return 影响行数 + */ + int update(TbShopShare tbShopShare); + + /** + * 通过主键删除数据 + * + * @param id 主键 + * @return 影响行数 + */ + int deleteById(Integer id); + +} + diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopShare.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopShare.java new file mode 100644 index 0000000..e770a75 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopShare.java @@ -0,0 +1,129 @@ +package com.chaozhanggui.system.cashierservice.entity; + +import cn.hutool.core.collection.CollectionUtil; +import com.baomidou.mybatisplus.annotation.TableField; +import com.chaozhanggui.system.cashierservice.util.JSONUtil; +import lombok.Data; +import org.apache.commons.lang3.StringUtils; + +import java.math.BigDecimal; +import java.util.Date; +import java.io.Serializable; +import java.util.List; + +/** + * 店铺分享(TbShopShare)实体类 + * + * @author ww + * @since 2024-11-07 14:36:27 + */ +@Data +public class TbShopShare implements Serializable { + private static final long serialVersionUID = 955264376724636315L; + + private Integer id; + /** + * 店铺Id + */ + private Integer shopId; + /** + * 标题 + */ + private String title; + /** + * 分享封面图 + */ + private String shareImg; + /** + * 邀请顶部图 + */ + private String invitedImg; + /** + * 被邀顶部图 + */ + private String beInvitedImg; + /** + * 活动开始时间 + */ + private Date startTime; + /** + * 活动结束时间 + */ + private Date endTime; + /** + * 新用户获得券 + */ + private String newCoupon; + /** + * 邀请人数 + */ + private Integer invitedNum; + /** + * 奖励券 + */ + private String rewardCoupon; + /** + * 获取方法 get-新用户领取获得 use-新用户使用获得 + */ + private String getMethod; + /** + * 0 关闭 1 开启 + */ + private Integer status; + + @TableField(exist = false) + private List newCoupons; + + @TableField(exist = false) + private List rewardCoupons; + + public void setNewCoupon(String newCoupon) { + this.newCoupon = newCoupon; + if(StringUtils.isNotBlank(newCoupon)){ + this.newCoupons = JSONUtil.parseListTNewList(newCoupon,ShareCoupons.class); + } + } + + public void setRewardCoupon(String rewardCoupon) { + this.rewardCoupon = rewardCoupon; + if(StringUtils.isNotBlank(rewardCoupon)){ + this.rewardCoupons = JSONUtil.parseListTNewList(rewardCoupon,ShareCoupons.class); + } + } + + public void setNewCoupons(List newCoupons) { + this.newCoupons = newCoupons; + if(CollectionUtil.isNotEmpty(newCoupons)){ + this.newCoupon = JSONUtil.toJSONString(newCoupons); + } + } + + public void setRewardCoupons(List rewardCoupons) { + this.rewardCoupons = rewardCoupons; + if(CollectionUtil.isNotEmpty(rewardCoupons)){ + this.rewardCoupon = JSONUtil.toJSONString(rewardCoupons); + } + } + + @Data + public static class ShareCoupons { + //优惠券Id + private Integer couponId; + //优惠券名称 + private String couponName; + //优惠券数量 + private Integer couponNum; + //1 满减 2 商品 + private Integer type; + //满多少金额 + private Integer fullAmount; + //优惠多少金额 + private Integer discountAmount; + //使用描述 + private String useDetail; + //商品描述 + private List gives; + } + +} + diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/TbShopShareService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/TbShopShareService.java new file mode 100644 index 0000000..998321b --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/TbShopShareService.java @@ -0,0 +1,24 @@ +package com.chaozhanggui.system.cashierservice.service; + +import com.chaozhanggui.system.cashierservice.entity.TbShopShare; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; + +/** + * 店铺分享(TbShopShare)表服务接口 + * + * @author ww + * @since 2024-11-07 14:36:27 + */ +public interface TbShopShareService { + + /** + * 通过ID查询单条数据 + * + * @param shopId 主键 + * @return 实例对象 + */ + TbShopShare queryByShopId(Integer shopId); + + +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbShopCouponServiceImpl.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbShopCouponServiceImpl.java index 91148ae..bf1e314 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbShopCouponServiceImpl.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbShopCouponServiceImpl.java @@ -74,42 +74,42 @@ public class TbShopCouponServiceImpl implements TbShopCouponService { return canUseCoupon; } - private void setCouponInfo( Map coupons, TbUserCouponVo tbUserCouponVo, BigDecimal amount, String week, LocalTime now, DateTimeFormatter formatter) { - JsonObject json = new JsonObject(); - boolean isUse = true; - TbShopCoupon tbShopCoupon = couponMapper.queryById(tbUserCouponVo.getCouponId()); - StringBuilder useRestrictions = new StringBuilder("每天 "); - if (tbShopCoupon.getType().equals(1)) { - if (amount.compareTo(new BigDecimal(tbShopCoupon.getFullAmount())) < 0) { - isUse = false; - } + private void setCouponInfo(Map coupons, TbUserCouponVo tbUserCouponVo, BigDecimal amount, String week, LocalTime now, DateTimeFormatter formatter) { + JsonObject json = new JsonObject(); + boolean isUse = true; + TbShopCoupon tbShopCoupon = couponMapper.queryById(tbUserCouponVo.getCouponId()); + StringBuilder useRestrictions = new StringBuilder("每天 "); + if (tbShopCoupon.getType().equals(1)) { + if (amount.compareTo(new BigDecimal(tbShopCoupon.getFullAmount())) < 0) { + isUse = false; } - if (StringUtils.isNotBlank(tbShopCoupon.getUserDays())) { - String[] split = tbShopCoupon.getUserDays().split(","); - if (split.length != 7) { - useRestrictions = new StringBuilder(tbShopCoupon.getUserDays() + " "); - } - if (!tbShopCoupon.getUserDays().contains(week)) { - isUse = false; - } - } - if (tbShopCoupon.getUseTimeType().equals("custom")) { - if (now.isBefore(tbShopCoupon.getUseStartTime()) || now.isAfter(tbShopCoupon.getUseEndTime())) { - isUse = false; - } - useRestrictions.append( - tbShopCoupon.getUseStartTime().format(formatter) - + "-" - + tbShopCoupon.getUseEndTime().format(formatter)); - } else { - useRestrictions.append("全时段"); - } - useRestrictions.append(" 可用"); - json.addProperty("isUse", isUse); - json.addProperty("useRestrictions", useRestrictions.toString()); - - coupons.put(tbUserCouponVo.getCouponId(), json); } + if (StringUtils.isNotBlank(tbShopCoupon.getUserDays())) { + String[] split = tbShopCoupon.getUserDays().split(","); + if (split.length != 7) { + useRestrictions = new StringBuilder(tbShopCoupon.getUserDays() + " "); + } + if (!tbShopCoupon.getUserDays().contains(week)) { + isUse = false; + } + } + if (tbShopCoupon.getUseTimeType().equals("custom")) { + if (now.isBefore(tbShopCoupon.getUseStartTime()) || now.isAfter(tbShopCoupon.getUseEndTime())) { + isUse = false; + } + useRestrictions.append( + tbShopCoupon.getUseStartTime().format(formatter) + + "-" + + tbShopCoupon.getUseEndTime().format(formatter)); + } else { + useRestrictions.append("全时段"); + } + useRestrictions.append(" 可用"); + json.addProperty("isUse", isUse); + json.addProperty("useRestrictions", useRestrictions.toString()); + + coupons.put(tbUserCouponVo.getCouponId(), json); + } @Override diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbShopShareServiceImpl.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbShopShareServiceImpl.java new file mode 100644 index 0000000..9ba35fc --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbShopShareServiceImpl.java @@ -0,0 +1,107 @@ +package com.chaozhanggui.system.cashierservice.service.impl; + +import cn.hutool.core.collection.CollectionUtil; +import com.chaozhanggui.system.cashierservice.dao.TbCouponProductMapper; +import com.chaozhanggui.system.cashierservice.dao.TbShopCouponMapper; +import com.chaozhanggui.system.cashierservice.dao.TbShopShareMapper; +import com.chaozhanggui.system.cashierservice.entity.TbShopCoupon; +import com.chaozhanggui.system.cashierservice.entity.TbShopShare; +import com.chaozhanggui.system.cashierservice.service.TbShopShareService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.time.format.DateTimeFormatter; + +/** + * 店铺分享(TbShopShare)表服务实现类 + * + * @author ww + * @since 2024-11-07 14:36:27 + */ +@Service("tbShopShareService") +public class TbShopShareServiceImpl implements TbShopShareService { + @Resource + private TbShopShareMapper tbShopShareMapper; + @Autowired + private TbShopCouponMapper couponMapper; + @Autowired + private TbCouponProductMapper couProductMapper; + + /** + * 通过ID查询单条数据 + * + * @param id 主键 + * @return 实例对象 + */ + @Override + public TbShopShare queryByShopId(Integer id) { + TbShopShare tbShopShare = tbShopShareMapper.queryByShopId(id); + if (tbShopShare != null) { + if(CollectionUtil.isNotEmpty(tbShopShare.getNewCoupons())){ + for (TbShopShare.ShareCoupons newCoupon : tbShopShare.getNewCoupons()) { + TbShopCoupon coupon = couponMapper.queryById(newCoupon.getCouponId()); + if (coupon != null) { + if (coupon.getType() == 1) { + //满减 + newCoupon.setType(1); + newCoupon.setFullAmount(coupon.getFullAmount()); + newCoupon.setDiscountAmount(coupon.getDiscountAmount()); + newCoupon.setUseDetail(setCouponInfo(coupon)); + } else if (coupon.getType() == 2) { + //商品 + newCoupon.setType(2); + newCoupon.setUseDetail(setCouponInfo(coupon)); + newCoupon.setGives(couProductMapper.queryProsByActivateId(coupon.getId(), newCoupon.getCouponNum())); + } + } + } + } + if(CollectionUtil.isNotEmpty(tbShopShare.getRewardCoupons())){ + for (TbShopShare.ShareCoupons rewardCoupon : tbShopShare.getRewardCoupons()) { + TbShopCoupon coupon = couponMapper.queryById(rewardCoupon.getCouponId()); + if (coupon != null) { + if (coupon.getType() == 1) { + //满减 + rewardCoupon.setType(1); + rewardCoupon.setFullAmount(coupon.getFullAmount()); + rewardCoupon.setDiscountAmount(coupon.getDiscountAmount()); + rewardCoupon.setUseDetail(setCouponInfo(coupon)); + } else if (coupon.getType() == 2) { + //商品 + rewardCoupon.setType(2); + rewardCoupon.setUseDetail(setCouponInfo(coupon)); + rewardCoupon.setGives(couProductMapper.queryProsByActivateId(coupon.getId(), rewardCoupon.getCouponNum())); + } + } + } + } + } + return tbShopShare; + } + + private String setCouponInfo(TbShopCoupon tbShopCoupon) { + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm:ss"); + StringBuilder useRestrictions = new StringBuilder("每天 "); + if (StringUtils.isNotBlank(tbShopCoupon.getUserDays())) { + String[] split = tbShopCoupon.getUserDays().split(","); + if (split.length != 7) { + useRestrictions = new StringBuilder(tbShopCoupon.getUserDays() + " "); + } + + } + if (tbShopCoupon.getUseTimeType().equals("custom")) { + useRestrictions.append( + tbShopCoupon.getUseStartTime().format(formatter) + + "-" + + tbShopCoupon.getUseEndTime().format(formatter)); + } else { + useRestrictions.append("全时段"); + } + useRestrictions.append(" 可用"); + + return useRestrictions.toString(); + } + +} diff --git a/src/main/resources/mapper/TbShopShareMapper.xml b/src/main/resources/mapper/TbShopShareMapper.xml new file mode 100644 index 0000000..f4734dd --- /dev/null +++ b/src/main/resources/mapper/TbShopShareMapper.xml @@ -0,0 +1,164 @@ + + + + + + + + + + + + + + + + + + + + + + id + , shop_id, title, share_img, invited_img, be_invited_img, start_time, end_time, new_coupon, invited_num, reward_coupon, get_method, status + + + + + + + + + + + + + insert into tb_shop_share(shop_id, title, share_img, invited_img, be_invited_img, start_time, end_time, + new_coupon, invited_num, reward_coupon, get_method, status) + values (#{shopId}, #{title}, #{shareImg}, #{invitedImg}, #{beInvitedImg}, #{startTime}, #{endTime}, + #{newCoupon}, #{invitedNum}, #{rewardCoupon}, #{getMethod}, #{status}) + + + + insert into tb_shop_share(shop_id, title, share_img, invited_img, be_invited_img, start_time, end_time, + new_coupon, invited_num, reward_coupon, get_method, status) + values + + (#{entity.shopId}, #{entity.title}, #{entity.shareImg}, #{entity.invitedImg}, #{entity.beInvitedImg}, + #{entity.startTime}, #{entity.endTime}, #{entity.newCoupon}, #{entity.invitedNum}, #{entity.rewardCoupon}, + #{entity.getMethod}, #{entity.status}) + + + + + + update tb_shop_share + + + shop_id = #{shopId}, + + + title = #{title}, + + + share_img = #{shareImg}, + + + invited_img = #{invitedImg}, + + + be_invited_img = #{beInvitedImg}, + + + start_time = #{startTime}, + + + end_time = #{endTime}, + + + new_coupon = #{newCoupon}, + + + invited_num = #{invitedNum}, + + + reward_coupon = #{rewardCoupon}, + + + get_method = #{getMethod}, + + + status = #{status}, + + + where id = #{id} + + + + + delete + from tb_shop_share + where id = #{id} + + + + From 6a54e8f23a70c052e1457defd38c7b265179c4eb Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Thu, 7 Nov 2024 15:25:37 +0800 Subject: [PATCH 18/26] =?UTF-8?q?=E5=88=86=E4=BA=AB=E5=A5=BD=E5=8F=8B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/TbShopShareController.java | 3 ++- .../cashierservice/entity/TbShopShare.java | 3 +++ .../service/impl/TbShopShareServiceImpl.java | 23 ++++++++----------- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/controller/TbShopShareController.java b/src/main/java/com/chaozhanggui/system/cashierservice/controller/TbShopShareController.java index c3f139f..12bf3da 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/controller/TbShopShareController.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/controller/TbShopShareController.java @@ -2,6 +2,7 @@ package com.chaozhanggui.system.cashierservice.controller; import com.chaozhanggui.system.cashierservice.service.TbShopShareService; import com.chaozhanggui.system.cashierservice.sign.Result; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; @@ -21,7 +22,7 @@ public class TbShopShareController { /** * 服务对象 */ - @Resource + @Autowired private TbShopShareService tbShopShareService; diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopShare.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopShare.java index e770a75..9c3021f 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopShare.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopShare.java @@ -3,6 +3,7 @@ package com.chaozhanggui.system.cashierservice.entity; import cn.hutool.core.collection.CollectionUtil; import com.baomidou.mybatisplus.annotation.TableField; import com.chaozhanggui.system.cashierservice.util.JSONUtil; +import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; import org.apache.commons.lang3.StringUtils; @@ -45,10 +46,12 @@ public class TbShopShare implements Serializable { /** * 活动开始时间 */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") private Date startTime; /** * 活动结束时间 */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") private Date endTime; /** * 新用户获得券 diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbShopShareServiceImpl.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbShopShareServiceImpl.java index 9ba35fc..156b121 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbShopShareServiceImpl.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbShopShareServiceImpl.java @@ -9,6 +9,7 @@ import com.chaozhanggui.system.cashierservice.entity.TbShopShare; import com.chaozhanggui.system.cashierservice.service.TbShopShareService; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Primary; import org.springframework.stereotype.Service; import javax.annotation.Resource; @@ -20,26 +21,22 @@ import java.time.format.DateTimeFormatter; * @author ww * @since 2024-11-07 14:36:27 */ -@Service("tbShopShareService") +@Primary +@Service public class TbShopShareServiceImpl implements TbShopShareService { - @Resource + @Autowired private TbShopShareMapper tbShopShareMapper; @Autowired private TbShopCouponMapper couponMapper; @Autowired private TbCouponProductMapper couProductMapper; - /** - * 通过ID查询单条数据 - * - * @param id 主键 - * @return 实例对象 - */ + @Override - public TbShopShare queryByShopId(Integer id) { - TbShopShare tbShopShare = tbShopShareMapper.queryByShopId(id); + public TbShopShare queryByShopId(Integer shopId) { + TbShopShare tbShopShare = tbShopShareMapper.queryByShopId(shopId); if (tbShopShare != null) { - if(CollectionUtil.isNotEmpty(tbShopShare.getNewCoupons())){ + if (CollectionUtil.isNotEmpty(tbShopShare.getNewCoupons())) { for (TbShopShare.ShareCoupons newCoupon : tbShopShare.getNewCoupons()) { TbShopCoupon coupon = couponMapper.queryById(newCoupon.getCouponId()); if (coupon != null) { @@ -58,7 +55,7 @@ public class TbShopShareServiceImpl implements TbShopShareService { } } } - if(CollectionUtil.isNotEmpty(tbShopShare.getRewardCoupons())){ + if (CollectionUtil.isNotEmpty(tbShopShare.getRewardCoupons())) { for (TbShopShare.ShareCoupons rewardCoupon : tbShopShare.getRewardCoupons()) { TbShopCoupon coupon = couponMapper.queryById(rewardCoupon.getCouponId()); if (coupon != null) { @@ -91,7 +88,7 @@ public class TbShopShareServiceImpl implements TbShopShareService { } } - if (tbShopCoupon.getUseTimeType().equals("custom")) { + if (StringUtils.isNotBlank(tbShopCoupon.getUseTimeType()) && tbShopCoupon.getUseTimeType().equals("custom")) { useRestrictions.append( tbShopCoupon.getUseStartTime().format(formatter) + "-" From ee873e0e7d022ba7d34286c4829cbc110366ef3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Thu, 7 Nov 2024 15:43:22 +0800 Subject: [PATCH 19/26] =?UTF-8?q?fix:=20=E4=BC=9A=E5=91=98=E4=BB=B7?= =?UTF-8?q?=E6=A0=A1=E9=AA=8C=E5=85=A8=E5=B1=80=E5=BC=80=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cashierservice/entity/TbCashierCart.java | 2 +- .../entity/dto/ShopEatTypeInfoDTO.java | 1 + .../cashierservice/service/CartService.java | 37 +++++++++++++------ .../system/cashierservice/util/ShopUtils.java | 3 +- 4 files changed, 29 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbCashierCart.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbCashierCart.java index 6d02063..e7ea0e9 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbCashierCart.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbCashierCart.java @@ -91,7 +91,7 @@ public class TbCashierCart implements Serializable { public void resetTotalAmount() { - if (isMember != null && isMember == 1 && memberPrice.compareTo(BigDecimal.ZERO) > 0) { + if (isMember != null && isMember == 1 && memberPrice != null && memberPrice.compareTo(BigDecimal.ZERO) > 0) { totalAmount = BigDecimal.valueOf(totalNumber).multiply(memberPrice).add(packFee); }else { totalAmount = BigDecimal.valueOf(totalNumber).multiply(salePrice).add(packFee); diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/ShopEatTypeInfoDTO.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/ShopEatTypeInfoDTO.java index 3cb85b8..14b7608 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/ShopEatTypeInfoDTO.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/ShopEatTypeInfoDTO.java @@ -21,5 +21,6 @@ public class ShopEatTypeInfoDTO { private String useType; private boolean isOpenTakeout; private boolean isOpenDineIn; + private boolean isMemberPrice; private String tableId; } 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 00a1a77..f6513dd 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/CartService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/CartService.java @@ -194,7 +194,10 @@ public class CartService { if (cashierCart.getIsVip().equals((byte) 1)) continue; if ((!TableConstant.CART_SEAT_ID.equals(cashierCart.getProductId())) && cashierCart.getNumber() > 0) { amount = amount.add(cashierCart.getSalePrice().multiply(BigDecimal.valueOf(cashierCart.getTotalNumber())).add(cashierCart.getPackFee())); - memberAmount = memberAmount.add(cashierCart.getMemberPrice().multiply(BigDecimal.valueOf(cashierCart.getTotalNumber())).add(cashierCart.getPackFee())); + BigDecimal mPrice = cashierCart.getIsMember() == 1 && cashierCart.getMemberPrice() != null && cashierCart.getMemberPrice().compareTo(BigDecimal.ZERO) > 0 + ? cashierCart.getMemberPrice() : cashierCart.getSalePrice(); + memberAmount = memberAmount.add(mPrice.multiply(BigDecimal.valueOf(cashierCart.getTotalNumber())).add(cashierCart.getPackFee())); + } } redisUtil.saveMessage(tableCartKey, array.toString(), 60 * 60 * 12L); @@ -350,12 +353,14 @@ public class CartService { if (Objects.isNull(array) || array.isEmpty()) { if (type == 1) { TbCashierCart cashierCart = addCart(productId, skuId, - jsonObject.getInteger("userId"), buyNum, tableId, shopId, isVip, note, shopEatTypeInfoDTO.isTakeout()); + jsonObject.getInteger("userId"), buyNum, tableId, shopId, isVip, note, shopEatTypeInfoDTO); jsonArray.add(cashierCart); cashierCart.setPlaceNum(cashierCart.getPlaceNum() == null ? 0 : cashierCart.getPlaceNum()); cashierCartArrayList.add(cashierCart); amount = amount.add(new BigDecimal(cashierCart.getNumber()).multiply(cashierCart.getSalePrice().add(cashierCart.getPackFee()))); - memberAmount = memberAmount.add(new BigDecimal(cashierCart.getNumber()).multiply(cashierCart.getMemberPrice().add(cashierCart.getPackFee()))); + BigDecimal mPrice = cashierCart.getIsMember() == 1 && cashierCart.getMemberPrice() != null && cashierCart.getMemberPrice().compareTo(BigDecimal.ZERO) > 0 + ? cashierCart.getMemberPrice() : cashierCart.getSalePrice(); + memberAmount = memberAmount.add(mPrice.multiply(BigDecimal.valueOf(cashierCart.getTotalNumber())).add(cashierCart.getPackFee())); } } else { @@ -411,7 +416,9 @@ public class CartService { jsonArray.add(cashierCart); cashierCartArrayList.add(cashierCart); amount = amount.add(new BigDecimal(cashierCart.getTotalNumber()).multiply(cashierCart.getSalePrice().add(cashierCart.getPackFee()))); - memberAmount = memberAmount.add(new BigDecimal(cashierCart.getNumber()).multiply(cashierCart.getMemberPrice().add(cashierCart.getPackFee()))); + BigDecimal mPrice = cashierCart.getIsMember() == 1 && cashierCart.getMemberPrice() != null && cashierCart.getMemberPrice().compareTo(BigDecimal.ZERO) > 0 + ? cashierCart.getMemberPrice() : cashierCart.getSalePrice(); + memberAmount = memberAmount.add(mPrice.multiply(BigDecimal.valueOf(cashierCart.getTotalNumber())).add(cashierCart.getPackFee())); if ("-999".equals(cashierCart.getProductId())) { hasSeat = true; @@ -420,10 +427,12 @@ public class CartService { if (flag && type == 1) { TbCashierCart cashierCart = addCart(productId, skuId, - jsonObject.getInteger("userId"), buyNum, tableId, shopId, isVip, note, shopEatTypeInfoDTO.isTakeout()); + jsonObject.getInteger("userId"), buyNum, tableId, shopId, isVip, note, shopEatTypeInfoDTO); jsonArray.add(cashierCart); amount = amount.add(new BigDecimal(cashierCart.getTotalNumber()).multiply(cashierCart.getSalePrice().add(cashierCart.getPackFee()))); - memberAmount = memberAmount.add(new BigDecimal(cashierCart.getNumber()).multiply(cashierCart.getMemberPrice().add(cashierCart.getPackFee()))); + BigDecimal mPrice = cashierCart.getIsMember() == 1 && cashierCart.getMemberPrice() != null && cashierCart.getMemberPrice().compareTo(BigDecimal.ZERO) > 0 + ? cashierCart.getMemberPrice() : cashierCart.getSalePrice(); + memberAmount = memberAmount.add(mPrice.multiply(BigDecimal.valueOf(cashierCart.getTotalNumber())).add(cashierCart.getPackFee())); } @@ -431,7 +440,7 @@ public class CartService { } else { if (type == 1) { TbCashierCart cashierCart = addCart(productId, skuId, - jsonObject.getInteger("userId"), buyNum, tableId, shopId, isVip, note, shopEatTypeInfoDTO.isTakeout()); + jsonObject.getInteger("userId"), buyNum, tableId, shopId, isVip, note, shopEatTypeInfoDTO); if (!TableConstant.CART_SEAT_ID.equals(productId)) { jsonArray.add(cashierCart); } @@ -439,7 +448,9 @@ public class CartService { cashierCartArrayList.add(cashierCart); if (isVip != 1) { amount = amount.add(new BigDecimal(cashierCart.getTotalNumber()).multiply(cashierCart.getSalePrice().add(cashierCart.getPackFee()))); - memberAmount = memberAmount.add(new BigDecimal(cashierCart.getNumber()).multiply(cashierCart.getMemberPrice().add(cashierCart.getPackFee()))); + BigDecimal mPrice = cashierCart.getIsMember() == 1 && cashierCart.getMemberPrice() != null && cashierCart.getMemberPrice().compareTo(BigDecimal.ZERO) > 0 + ? cashierCart.getMemberPrice() : cashierCart.getSalePrice(); + memberAmount = memberAmount.add(mPrice.multiply(BigDecimal.valueOf(cashierCart.getTotalNumber())).add(cashierCart.getPackFee())); } } @@ -566,7 +577,7 @@ public class CartService { } private TbCashierCart addCart(String productId, String skuId, Integer userId, Integer num, - String tableId, String shopId, Integer isVip, String note, boolean isTakeout) throws Exception { + String tableId, String shopId, Integer isVip, String note, ShopEatTypeInfoDTO shopEatTypeInfoDTO) throws Exception { try { // 查询用户信息 TbShopUser shopUser = shopUserMapper.selectByUserIdAndShopId(String.valueOf(userId), shopId); @@ -601,7 +612,6 @@ public class CartService { cashierCart.setNumber(num); cashierCart.setTotalNumber(num); } - cashierCart.setIsMember(shopUser.getIsVip() == 1 && productSku.getMemberPrice() != null && productSku.getMemberPrice().compareTo(BigDecimal.ZERO) > 0 ? 1 : 0); cashierCart.setNote(note); cashierCart.setProductId(productId); cashierCart.setSkuId(skuId); @@ -621,10 +631,13 @@ public class CartService { cashierCart.setUpdatedAt(Instant.now().toEpochMilli()); cashierCart.setPackFee(BigDecimal.ZERO); cashierCart.setRefundNumber(0); - cashierCart.setMemberPrice(productSku.getMemberPrice() == null || productSku.getMemberPrice().compareTo(BigDecimal.ZERO) <= 0 ? productSku.getSalePrice() : productSku.getMemberPrice()); + if (shopEatTypeInfoDTO.isMemberPrice() && shopUser.getIsVip() == 1) { + cashierCart.setMemberPrice(productSku.getMemberPrice()); + cashierCart.setIsMember(1); + } cashierCart.setTradeDay(DateUtils.getDay()); // 打包费 - if (isTakeout && product.getPackFee() != null) { + if (shopEatTypeInfoDTO.isTakeout() && product.getPackFee() != null) { cashierCart.setPackFee(product.getPackFee().multiply(BigDecimal.valueOf(num))); } if (isVip == 1) { diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/util/ShopUtils.java b/src/main/java/com/chaozhanggui/system/cashierservice/util/ShopUtils.java index 4228639..6271551 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/util/ShopUtils.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/util/ShopUtils.java @@ -57,6 +57,7 @@ public class ShopUtils { boolean isDineInBefore = isOpenDineIn && isMunchies && !isTakeout; boolean hasTable = StrUtil.isNotBlank(tableId); boolean isNoneTable = !hasTable && !isTakeout; + boolean isOpenMemberPrice = shopInfo.getIsMemberPrice() != null && shopInfo.getIsMemberPrice() == 1; boolean needSeatFee = !isTakeout && (shopInfo.getIsTableFee() == null || shopInfo.getIsTableFee() == 0); @@ -65,7 +66,7 @@ public class ShopUtils { return new ShopEatTypeInfoDTO(isTakeout, isMunchies, isDineInAfter, isDineInBefore, needSeatFee, isNoneTable, isIncrMasterId, shopInfo, isTakeout ? OrderUseTypeEnum.TAKEOUT.getValue() : - isDineInBefore ? OrderUseTypeEnum.DINE_IN_BEFORE.getValue() : isDineInAfter ? OrderUseTypeEnum.DINE_IN_AFTER.getValue() : null, isOpenTakeout, isOpenDineIn, tableId); + isDineInBefore ? OrderUseTypeEnum.DINE_IN_BEFORE.getValue() : isDineInAfter ? OrderUseTypeEnum.DINE_IN_AFTER.getValue() : null, isOpenTakeout, isOpenDineIn, isOpenMemberPrice, tableId); } public ShopEatTypeInfoDTO getEatModel(String tableId, Object shopId) { From 9a3435565cf5fa3297084c64f36cdbbb703adcf8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Thu, 7 Nov 2024 15:44:40 +0800 Subject: [PATCH 20/26] =?UTF-8?q?fix:=20=E4=BC=9A=E5=91=98=E4=BB=B7?= =?UTF-8?q?=E6=A0=A1=E9=AA=8C=E5=85=A8=E5=B1=80=E5=BC=80=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chaozhanggui/system/cashierservice/util/ShopUtils.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/util/ShopUtils.java b/src/main/java/com/chaozhanggui/system/cashierservice/util/ShopUtils.java index 6271551..12002cf 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/util/ShopUtils.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/util/ShopUtils.java @@ -96,8 +96,10 @@ public class ShopUtils { boolean isOpenDineIn = shopInfo.getEatModel().contains(ShopInfoEatModelEnum.DINE_IN.getValue()); boolean isDineInAfter = isOpenDineIn && !isMunchies && !isTakeout; boolean isDineInBefore = isOpenDineIn && isMunchies && !isTakeout; + boolean isOpenMemberPrice = shopInfo.getIsMemberPrice() != null && shopInfo.getIsMemberPrice() == 1; + return new ShopEatTypeInfoDTO(isTakeout, isMunchies, isDineInAfter, isDineInBefore, needSeatFee, isNoneTable, isIncrMasterId, shopInfo, isTakeout ? OrderUseTypeEnum.TAKEOUT.getValue() : - isDineInBefore ? OrderUseTypeEnum.DINE_IN_BEFORE.getValue() : isDineInAfter ? OrderUseTypeEnum.DINE_IN_AFTER.getValue() : null, isOpenTakeout, isOpenDineIn, tableId); + isDineInBefore ? OrderUseTypeEnum.DINE_IN_BEFORE.getValue() : isDineInAfter ? OrderUseTypeEnum.DINE_IN_AFTER.getValue() : null, isOpenTakeout, isOpenDineIn, isOpenMemberPrice,tableId); } } From 8f95d9a8a15ea68d63fec65b98c4650f7f955050 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Thu, 7 Nov 2024 15:48:19 +0800 Subject: [PATCH 21/26] =?UTF-8?q?fix:=20=E4=BC=9A=E5=91=98=E4=BB=B7?= =?UTF-8?q?=E6=A0=A1=E9=AA=8C=E5=85=A8=E5=B1=80=E5=BC=80=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/cashierservice/service/CartService.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 f6513dd..8d5627f 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/CartService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/CartService.java @@ -358,8 +358,8 @@ public class CartService { cashierCart.setPlaceNum(cashierCart.getPlaceNum() == null ? 0 : cashierCart.getPlaceNum()); cashierCartArrayList.add(cashierCart); amount = amount.add(new BigDecimal(cashierCart.getNumber()).multiply(cashierCart.getSalePrice().add(cashierCart.getPackFee()))); - BigDecimal mPrice = cashierCart.getIsMember() == 1 && cashierCart.getMemberPrice() != null && cashierCart.getMemberPrice().compareTo(BigDecimal.ZERO) > 0 - ? cashierCart.getMemberPrice() : cashierCart.getSalePrice(); + BigDecimal mPrice = cashierCart.getIsMember() != null && cashierCart.getIsMember() == 1 && + cashierCart.getMemberPrice() != null && cashierCart.getMemberPrice().compareTo(BigDecimal.ZERO) > 0 ? cashierCart.getMemberPrice() : cashierCart.getSalePrice(); memberAmount = memberAmount.add(mPrice.multiply(BigDecimal.valueOf(cashierCart.getTotalNumber())).add(cashierCart.getPackFee())); } From 6f75f31e95b2ced9f6934421c71c8738e3fa6b20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Thu, 7 Nov 2024 15:50:14 +0800 Subject: [PATCH 22/26] =?UTF-8?q?fix:=20=E4=BC=9A=E5=91=98=E4=BB=B7?= =?UTF-8?q?=E6=A0=A1=E9=AA=8C=E5=85=A8=E5=B1=80=E5=BC=80=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cashierservice/service/CartService.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) 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 8d5627f..629b88d 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/CartService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/CartService.java @@ -194,8 +194,8 @@ public class CartService { if (cashierCart.getIsVip().equals((byte) 1)) continue; if ((!TableConstant.CART_SEAT_ID.equals(cashierCart.getProductId())) && cashierCart.getNumber() > 0) { amount = amount.add(cashierCart.getSalePrice().multiply(BigDecimal.valueOf(cashierCart.getTotalNumber())).add(cashierCart.getPackFee())); - BigDecimal mPrice = cashierCart.getIsMember() == 1 && cashierCart.getMemberPrice() != null && cashierCart.getMemberPrice().compareTo(BigDecimal.ZERO) > 0 - ? cashierCart.getMemberPrice() : cashierCart.getSalePrice(); + BigDecimal mPrice = cashierCart.getIsMember() != null && cashierCart.getIsMember() == 1 && + cashierCart.getMemberPrice() != null && cashierCart.getMemberPrice().compareTo(BigDecimal.ZERO) > 0 ? cashierCart.getMemberPrice() : cashierCart.getSalePrice(); memberAmount = memberAmount.add(mPrice.multiply(BigDecimal.valueOf(cashierCart.getTotalNumber())).add(cashierCart.getPackFee())); } @@ -416,8 +416,8 @@ public class CartService { jsonArray.add(cashierCart); cashierCartArrayList.add(cashierCart); amount = amount.add(new BigDecimal(cashierCart.getTotalNumber()).multiply(cashierCart.getSalePrice().add(cashierCart.getPackFee()))); - BigDecimal mPrice = cashierCart.getIsMember() == 1 && cashierCart.getMemberPrice() != null && cashierCart.getMemberPrice().compareTo(BigDecimal.ZERO) > 0 - ? cashierCart.getMemberPrice() : cashierCart.getSalePrice(); + BigDecimal mPrice = cashierCart.getIsMember() != null && cashierCart.getIsMember() == 1 && + cashierCart.getMemberPrice() != null && cashierCart.getMemberPrice().compareTo(BigDecimal.ZERO) > 0 ? cashierCart.getMemberPrice() : cashierCart.getSalePrice(); memberAmount = memberAmount.add(mPrice.multiply(BigDecimal.valueOf(cashierCart.getTotalNumber())).add(cashierCart.getPackFee())); if ("-999".equals(cashierCart.getProductId())) { @@ -430,8 +430,8 @@ public class CartService { jsonObject.getInteger("userId"), buyNum, tableId, shopId, isVip, note, shopEatTypeInfoDTO); jsonArray.add(cashierCart); amount = amount.add(new BigDecimal(cashierCart.getTotalNumber()).multiply(cashierCart.getSalePrice().add(cashierCart.getPackFee()))); - BigDecimal mPrice = cashierCart.getIsMember() == 1 && cashierCart.getMemberPrice() != null && cashierCart.getMemberPrice().compareTo(BigDecimal.ZERO) > 0 - ? cashierCart.getMemberPrice() : cashierCart.getSalePrice(); + BigDecimal mPrice = cashierCart.getIsMember() != null && cashierCart.getIsMember() == 1 && + cashierCart.getMemberPrice() != null && cashierCart.getMemberPrice().compareTo(BigDecimal.ZERO) > 0 ? cashierCart.getMemberPrice() : cashierCart.getSalePrice(); memberAmount = memberAmount.add(mPrice.multiply(BigDecimal.valueOf(cashierCart.getTotalNumber())).add(cashierCart.getPackFee())); } @@ -448,8 +448,8 @@ public class CartService { cashierCartArrayList.add(cashierCart); if (isVip != 1) { amount = amount.add(new BigDecimal(cashierCart.getTotalNumber()).multiply(cashierCart.getSalePrice().add(cashierCart.getPackFee()))); - BigDecimal mPrice = cashierCart.getIsMember() == 1 && cashierCart.getMemberPrice() != null && cashierCart.getMemberPrice().compareTo(BigDecimal.ZERO) > 0 - ? cashierCart.getMemberPrice() : cashierCart.getSalePrice(); + BigDecimal mPrice = cashierCart.getIsMember() != null && cashierCart.getIsMember() == 1 && + cashierCart.getMemberPrice() != null && cashierCart.getMemberPrice().compareTo(BigDecimal.ZERO) > 0 ? cashierCart.getMemberPrice() : cashierCart.getSalePrice(); memberAmount = memberAmount.add(mPrice.multiply(BigDecimal.valueOf(cashierCart.getTotalNumber())).add(cashierCart.getPackFee())); } From bc0bcf67a8e9af7f525f4be719da5ee24b0698e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Thu, 7 Nov 2024 15:56:26 +0800 Subject: [PATCH 23/26] =?UTF-8?q?fix:=20=E5=95=86=E5=93=81=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E8=BF=94=E5=9B=9E=E4=BC=9A=E5=91=98=E4=BB=B7=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/cashierservice/service/ProductService.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) 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 635d0b3..ed1ac43 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/ProductService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/ProductService.java @@ -21,6 +21,7 @@ import com.chaozhanggui.system.cashierservice.entity.vo.*; import com.chaozhanggui.system.cashierservice.exception.MsgException; import com.chaozhanggui.system.cashierservice.mapper.MpCashierCartMapper; import com.chaozhanggui.system.cashierservice.mapper.MpOrderInfoMapper; +import com.chaozhanggui.system.cashierservice.mapper.MpShopInfoMapper; import com.chaozhanggui.system.cashierservice.mapper.MpShopTableMapper; import com.chaozhanggui.system.cashierservice.redis.RedisCst; import com.chaozhanggui.system.cashierservice.redis.RedisUtil; @@ -108,6 +109,8 @@ public class ProductService { @Autowired private StringRedisTemplate stringRedisTemplate; private final TbFreeDineConfigService freeDineConfigService; + @Autowired + private MpShopInfoMapper mpShopInfoMapper; public ProductService(ShopUtils shopUtils, TbFreeDineConfigService freeDineConfigService) { this.shopUtils = shopUtils; @@ -224,6 +227,7 @@ public class ProductService { List tbProducts = tbProductMapper.selectIsSpecialty(Integer.valueOf(shopId)); concurrentMap.put("hots", handleDate(tbProducts,true,1,false)); List groupList = tbProductGroupMapper.selectByShopId(shopId, id); + TbShopInfo shopInfo = mpShopInfoMapper.selectById(shopId); if (ObjectUtil.isNotEmpty(groupList) && groupList.size() > 0) { //热销 TbProductGroup hot = new TbProductGroup(); @@ -236,7 +240,7 @@ public class ProductService { String in = g.getProductIds().substring(1, g.getProductIds().length() - 1); if (ObjectUtil.isNotEmpty(in) && ObjectUtil.isNotNull(in)) { List products = tbProductMapper.selectByIdInAndCheck(in); - g.setProducts(handleDate(products,false,g.getIsSale(),false)); + g.setProducts(handleDate(products,false,g.getIsSale(),false, shopInfo)); } else { g.setProducts(new ArrayList<>()); } @@ -450,7 +454,8 @@ public class ProductService { * @param check 是否校验可售 * @return */ - public List handleDate(List products,boolean check,Integer isSale,boolean isVip){ + public List handleDate(List products,boolean check,Integer isSale,boolean isVip, TbShopInfo shopInfo){ + boolean isMemberPrice = shopInfo.getIsMemberPrice() != null && shopInfo.getIsMemberPrice() == 1; if (!CollectionUtils.isEmpty(products)) { products.parallelStream().forEach(it -> { TbShopUnit tbShopUnit = unitMapper.selectByPrimaryKey(Integer.valueOf(it.getUnitId())); @@ -504,7 +509,7 @@ public class ProductService { it.setLowPrice(lowerPrice); // 会员价 - if (lowMemberPrice == null) { + if (lowMemberPrice == null || !isMemberPrice) { lowMemberPrice = BigDecimal.ZERO; } it.setLowMemberPrice(lowMemberPrice); From c8f96e85ef6e6b2ad032e45270a84271fbc7cb47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Thu, 7 Nov 2024 15:57:30 +0800 Subject: [PATCH 24/26] =?UTF-8?q?fix:=20=E5=95=86=E5=93=81=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E8=BF=94=E5=9B=9E=E4=BC=9A=E5=91=98=E4=BB=B7=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/cashierservice/service/ProductService.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 ed1ac43..e5f3460 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/ProductService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/ProductService.java @@ -225,15 +225,15 @@ public class ProductService { Integer id = ObjectUtil.isNotEmpty(productGroupId) ? Integer.valueOf(productGroupId) : null; //招牌菜 List tbProducts = tbProductMapper.selectIsSpecialty(Integer.valueOf(shopId)); - concurrentMap.put("hots", handleDate(tbProducts,true,1,false)); - List groupList = tbProductGroupMapper.selectByShopId(shopId, id); TbShopInfo shopInfo = mpShopInfoMapper.selectById(shopId); + concurrentMap.put("hots", handleDate(tbProducts,true,1,false, shopInfo)); + List groupList = tbProductGroupMapper.selectByShopId(shopId, id); if (ObjectUtil.isNotEmpty(groupList) && groupList.size() > 0) { //热销 TbProductGroup hot = new TbProductGroup(); hot.setName("热销"); List hots = tbProductMapper.selectHot(shopId); - hot.setProducts(handleDate(hots,true,1,false)); + hot.setProducts(handleDate(hots,true,1,false, shopInfo)); //商品 groupList.parallelStream().forEach(g -> { if (g.getUseTime()==1) g.setIsSale(getIsSale(g.getSaleStartTime(),g.getSaleEndTime())); From ac09705e8caba4805b1530c5e1462acb33343d09 Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Thu, 7 Nov 2024 18:27:10 +0800 Subject: [PATCH 25/26] =?UTF-8?q?=E5=88=86=E4=BA=AB=E5=A5=BD=E5=8F=8B=20?= =?UTF-8?q?=E8=BF=9B=E5=85=A5=E9=A1=B5=E9=9D=A2=20=E9=A2=86=E5=8F=96?= =?UTF-8?q?=E4=BC=98=E6=83=A0=E5=88=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cashierservice/auth/LoginFilter.java | 1 + .../controller/TbShopShareController.java | 48 +++- .../dao/TbShopShareRecordMapper.java | 75 +++++ .../cashierservice/dao/TbUserInfoMapper.java | 2 + .../entity/TbActivateInRecord.java | 9 + .../entity/TbShopShareRecord.java | 156 +++++++++++ .../service/TbShopShareRecordService.java | 62 +++++ .../service/impl/TbShopCouponServiceImpl.java | 16 ++ .../impl/TbShopShareRecordServiceImpl.java | 262 ++++++++++++++++++ .../mapper/TbActivateInRecordMapper.xml | 11 +- .../resources/mapper/TbShopShareMapper.xml | 2 + .../mapper/TbShopShareRecordMapper.xml | 160 +++++++++++ .../resources/mapper/TbUserInfoMapper.xml | 8 + 13 files changed, 800 insertions(+), 12 deletions(-) create mode 100644 src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopShareRecordMapper.java create mode 100644 src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopShareRecord.java create mode 100644 src/main/java/com/chaozhanggui/system/cashierservice/service/TbShopShareRecordService.java create mode 100644 src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbShopShareRecordServiceImpl.java create mode 100644 src/main/resources/mapper/TbShopShareRecordMapper.xml diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/auth/LoginFilter.java b/src/main/java/com/chaozhanggui/system/cashierservice/auth/LoginFilter.java index cb6cfc2..5c49993 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/auth/LoginFilter.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/auth/LoginFilter.java @@ -45,6 +45,7 @@ public class LoginFilter implements Filter { "cashierService/home",//首页 "cashierService/order/testMessage",//首页 "cashierService/common/**",//通用接口 + "cashierService/tbShopShare/**",//通用接口 "cashierService/distirict/**",//首页其它接口 // "cashierService/login/**",//登录部分接口不校验 diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/controller/TbShopShareController.java b/src/main/java/com/chaozhanggui/system/cashierservice/controller/TbShopShareController.java index 12bf3da..db76bd7 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/controller/TbShopShareController.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/controller/TbShopShareController.java @@ -1,12 +1,11 @@ package com.chaozhanggui.system.cashierservice.controller; +import com.chaozhanggui.system.cashierservice.entity.TbShopShareRecord; +import com.chaozhanggui.system.cashierservice.service.TbShopShareRecordService; import com.chaozhanggui.system.cashierservice.service.TbShopShareService; import com.chaozhanggui.system.cashierservice.sign.Result; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; @@ -19,12 +18,12 @@ import javax.annotation.Resource; @RestController @RequestMapping("tbShopShare") public class TbShopShareController { - /** - * 服务对象 - */ + @Autowired private TbShopShareService tbShopShareService; + @Autowired + private TbShopShareRecordService tbShopShareRecordService; /** * 通过主键查询单条数据 @@ -37,5 +36,40 @@ public class TbShopShareController { return Result.successWithData(tbShopShareService.queryByShopId(shopId)); } + + /** + * 查询 + * + * @param tbShopShareRecord 筛选条件 + * @return 查询结果 + */ + @GetMapping("record") + public Result queryByPage(TbShopShareRecord tbShopShareRecord) { + return Result.successWithData(tbShopShareRecordService.query(tbShopShareRecord)); + } + + + /** + * 进入页面 + * + * @param tbShopShareRecord 实体 + * @return 新增结果 + */ + @PostMapping("open") + public Result open(@RequestBody TbShopShareRecord tbShopShareRecord) { + return tbShopShareRecordService.insert(tbShopShareRecord); + } + + /** + * 领取优惠券 + * + * @param tbShopShareRecord 实体 + * @return 新增结果 + */ + @PostMapping("receive") + public Result receive(@RequestBody TbShopShareRecord tbShopShareRecord) { + return tbShopShareRecordService.receive(tbShopShareRecord); + } + } diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopShareRecordMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopShareRecordMapper.java new file mode 100644 index 0000000..a48eace --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopShareRecordMapper.java @@ -0,0 +1,75 @@ +package com.chaozhanggui.system.cashierservice.dao; + +import com.chaozhanggui.system.cashierservice.entity.TbShopShareRecord; +import org.apache.ibatis.annotations.Param; +import org.springframework.data.domain.Pageable; + +import java.util.List; + +/** + * (TbShopShareRecord)表数据库访问层 + * + * @author ww + * @since 2024-11-07 15:50:03 + */ +public interface TbShopShareRecordMapper { + + /** + * 通过ID查询单条数据 + * + * @param id 主键 + * @return 实例对象 + */ + TbShopShareRecord queryById(Integer id); + + TbShopShareRecord queryByData( + @Param("shareId") Integer shareId, @Param("shopId") Integer shopId, + @Param("invitedId") Integer invitedId, @Param("beInvitedId") Integer beInvitedId); + + TbShopShareRecord queryByDataByBeInvited( + @Param("shareId") Integer shareId, @Param("shopId") Integer shopId, + @Param("beInvitedId") Integer beInvitedId); + + /** + * 查询数据 + * + * @param tbShopShareRecord 查询条件 + * @return 对象列表 + */ + List query(TbShopShareRecord tbShopShareRecord); + + + /** + * 新增数据 + * + * @param tbShopShareRecord 实例对象 + * @return 影响行数 + */ + int insert(TbShopShareRecord tbShopShareRecord); + + /** + * 批量新增数据(MyBatis原生foreach方法) + * + * @param entities List 实例对象列表 + * @return 影响行数 + */ + int insertBatch(@Param("entities") List entities); + + /** + * 修改数据 + * + * @param tbShopShareRecord 实例对象 + * @return 影响行数 + */ + int update(TbShopShareRecord tbShopShareRecord); + + /** + * 通过主键删除数据 + * + * @param id 主键 + * @return 影响行数 + */ + int deleteById(Integer id); + +} + diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbUserInfoMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbUserInfoMapper.java index 975d431..1802d04 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbUserInfoMapper.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbUserInfoMapper.java @@ -17,6 +17,8 @@ public interface TbUserInfoMapper { TbUserInfo selectByPrimaryKey(Integer id); + String selectNameByPrimaryKey(Integer id); + int updateByPrimaryKeySelective(TbUserInfo record); int updateByPrimaryKey(TbUserInfo record); diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbActivateInRecord.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbActivateInRecord.java index e7385df..e914a25 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbActivateInRecord.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbActivateInRecord.java @@ -73,6 +73,7 @@ public class TbActivateInRecord implements Serializable { private Date updateTime; private String couponJson; + private String source; public Integer getId() { @@ -219,5 +220,13 @@ public class TbActivateInRecord implements Serializable { this.couponJson = couponJson; } + + public String getSource() { + return source; + } + + public void setSource(String source) { + this.source = source; + } } diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopShareRecord.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopShareRecord.java new file mode 100644 index 0000000..36b0a63 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopShareRecord.java @@ -0,0 +1,156 @@ +package com.chaozhanggui.system.cashierservice.entity; + +import java.util.Date; +import java.io.Serializable; + +/** + * (TbShopShareRecord)实体类 + * + * @author ww + * @since 2024-11-07 15:50:04 + */ +public class TbShopShareRecord implements Serializable { + private static final long serialVersionUID = -41620929736900271L; + + private Integer id; + /** + * tb_shop_share 主键Id + */ + private Integer shareId; + /** + * 店铺Id + */ + private Integer shopId; + /** + * 邀请人id + */ + private Integer invitedId; + /** + * 邀请人名称 + */ + private String invitedName; + /** + * 被邀请人Id + */ + private Integer beInvitedId; + /** + * 被邀请人名称 + */ + private String beInvitedName; + /** + * 奖励券获得方式 get/use 领取获得/使用获得 + */ + private String method; + /** + * 1 未领取 2 已领取 3 已使用 + */ + private Integer status; + /** + * 生效时间/获得奖励的时间 + */ + private Date rewardTime; + + private Date createTime; + + private Date updateTime; + + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Integer getShareId() { + return shareId; + } + + public void setShareId(Integer shareId) { + this.shareId = shareId; + } + + public Integer getShopId() { + return shopId; + } + + public void setShopId(Integer shopId) { + this.shopId = shopId; + } + + public Integer getInvitedId() { + return invitedId; + } + + public void setInvitedId(Integer invitedId) { + this.invitedId = invitedId; + } + + public String getInvitedName() { + return invitedName; + } + + public void setInvitedName(String invitedName) { + this.invitedName = invitedName; + } + + public Integer getBeInvitedId() { + return beInvitedId; + } + + public void setBeInvitedId(Integer beInvitedId) { + this.beInvitedId = beInvitedId; + } + + + public String getBeInvitedName() { + return beInvitedName; + } + + public void setBeInvitedName(String beInvitedName) { + this.beInvitedName = beInvitedName; + } + + public String getMethod() { + return method; + } + + public void setMethod(String method) { + this.method = method; + } + + public Integer getStatus() { + return status; + } + + public void setStatus(Integer status) { + this.status = status; + } + + public Date getRewardTime() { + return rewardTime; + } + + public void setRewardTime(Date rewardTime) { + this.rewardTime = rewardTime; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public Date getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(Date updateTime) { + this.updateTime = updateTime; + } + +} + diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/TbShopShareRecordService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/TbShopShareRecordService.java new file mode 100644 index 0000000..c71057c --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/TbShopShareRecordService.java @@ -0,0 +1,62 @@ +package com.chaozhanggui.system.cashierservice.service; + +import com.chaozhanggui.system.cashierservice.entity.TbShopShareRecord; +import com.chaozhanggui.system.cashierservice.sign.Result; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; + +import java.util.List; + +/** + * (TbShopShareRecord)表服务接口 + * + * @author ww + * @since 2024-11-07 15:50:04 + */ +public interface TbShopShareRecordService { + + /** + * 通过ID查询单条数据 + * + * @param id 主键 + * @return 实例对象 + */ + TbShopShareRecord queryById(Integer id); + + /** + * 分页查询 + * + * @param tbShopShareRecord 筛选条件 + * @return 查询结果 + */ + List query(TbShopShareRecord tbShopShareRecord); + + Result receive(TbShopShareRecord tbShopShareRecord); + + /** + * 新增数据 + * + * @param tbShopShareRecord 实例对象 + * @return 实例对象 + */ + Result insert(TbShopShareRecord tbShopShareRecord); + + /** + * 修改数据 + * + * @param tbShopShareRecord 实例对象 + * @return 实例对象 + */ + TbShopShareRecord update(TbShopShareRecord tbShopShareRecord); + + /** + * 通过主键删除数据 + * + * @param id 主键 + * @return 是否成功 + */ + boolean deleteById(Integer id); + + void give(TbShopShareRecord shareRecord, Integer userId); + +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbShopCouponServiceImpl.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbShopCouponServiceImpl.java index bf1e314..f7a0973 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbShopCouponServiceImpl.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbShopCouponServiceImpl.java @@ -7,10 +7,12 @@ import com.chaozhanggui.system.cashierservice.entity.*; import com.chaozhanggui.system.cashierservice.entity.dto.CouponDto; import com.chaozhanggui.system.cashierservice.entity.vo.TbUserCouponVo; import com.chaozhanggui.system.cashierservice.service.TbShopCouponService; +import com.chaozhanggui.system.cashierservice.service.TbShopShareRecordService; import com.chaozhanggui.system.cashierservice.sign.CodeEnum; import com.chaozhanggui.system.cashierservice.sign.Result; import com.google.gson.JsonObject; import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Primary; import org.springframework.stereotype.Service; @@ -43,6 +45,12 @@ public class TbShopCouponServiceImpl implements TbShopCouponService { @Resource private TbActivateOutRecordMapper outRecordMapper; + @Autowired + private TbShopShareRecordMapper shareRecordMapper; + + @Autowired + private TbShopShareRecordService shareRecordService; + @Override public List getActivateCouponByAmount(Integer shopId, String userId, BigDecimal amount) { TbShopUser tbShopUser = shopUserMapper.selectByUserIdAndShopId(userId, String.valueOf(shopId)); @@ -174,6 +182,14 @@ public class TbShopCouponServiceImpl implements TbShopCouponService { public boolean use(Integer shopId, Integer orderId, Integer vipUserId, List param) { for (TbActivateOutRecord outRecord : param) { TbActivateInRecord inRecord = inRecordMapper.queryById(outRecord.getGiveId()); + if (inRecord.getSource().equals("invited")) { + TbShopShareRecord shareRecord = shareRecordMapper.queryById(inRecord.getSourceActId()); + if (shareRecord.getMethod().equals("use")) { + shareRecord.setStatus(3); + shareRecordService.give(shareRecord,shareRecord.getInvitedId()); + shareRecordMapper.update(shareRecord); + } + } inRecord.setOverNum(inRecord.getOverNum() - outRecord.getUseNum()); inRecordMapper.updateOverNum(inRecord.getId(), inRecord.getOverNum()); diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbShopShareRecordServiceImpl.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbShopShareRecordServiceImpl.java new file mode 100644 index 0000000..35ff26a --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbShopShareRecordServiceImpl.java @@ -0,0 +1,262 @@ +package com.chaozhanggui.system.cashierservice.service.impl; + +import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.RandomUtil; +import com.chaozhanggui.system.cashierservice.dao.*; +import com.chaozhanggui.system.cashierservice.entity.*; +import com.chaozhanggui.system.cashierservice.service.TbShopShareRecordService; +import com.chaozhanggui.system.cashierservice.sign.Result; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Primary; +import org.springframework.stereotype.Service; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageImpl; +import org.springframework.data.domain.PageRequest; + +import javax.annotation.Resource; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +/** + * (TbShopShareRecord)表服务实现类 + * + * @author ww + * @since 2024-11-07 15:50:04 + */ +@Primary +@Service +public class TbShopShareRecordServiceImpl implements TbShopShareRecordService { + @Autowired + private TbShopShareMapper tbShopShareMapper; + @Autowired + private TbShopShareRecordMapper tbShopShareRecordMapper; + @Autowired + private TbShopUserMapper shopUserMapper; + @Autowired + private TbCouponProductMapper couProductMapper; + @Autowired + private TbShopCouponMapper couponMapper; + @Autowired + private TbActivateInRecordMapper activateInRecordMapper; + @Autowired + private TbUserInfoMapper userInfoMapper; + + /** + * 通过ID查询单条数据 + * + * @param id 主键 + * @return 实例对象 + */ + @Override + public TbShopShareRecord queryById(Integer id) { + return this.tbShopShareRecordMapper.queryById(id); + } + + /** + * 分页查询 + * + * @param tbShopShareRecord 筛选条件 + * @return 查询结果 + */ + @Override + public List query(TbShopShareRecord tbShopShareRecord) { + List records = tbShopShareRecordMapper.query(tbShopShareRecord); + for (TbShopShareRecord shareRecord : records) { + shareRecord.setBeInvitedName(userInfoMapper.selectNameByPrimaryKey(shareRecord.getBeInvitedId())); + } + return records; + } + + @Override + public Result receive(TbShopShareRecord tbShopShareRecord) { +// TbShopShareRecord query = tbShopShareRecordMapper.queryByDataByBeInvited( +// tbShopShareRecord.getShareId(), tbShopShareRecord.getShopId(), tbShopShareRecord.getBeInvitedId()); + + TbShopShareRecord query = tbShopShareRecordMapper.queryByData( + tbShopShareRecord.getShareId(), tbShopShareRecord.getShopId(), + tbShopShareRecord.getInvitedId(), tbShopShareRecord.getBeInvitedId()); + if (query.getStatus() == 1) { + give(query, query.getBeInvitedId()); + if (query.getMethod().equals("get")) { + give(query, query.getInvitedId()); + } + query.setRewardTime(new Date()); + query.setStatus(2); + query.setUpdateTime(new Date()); + tbShopShareRecordMapper.update(query); + return Result.successWithData("领取成功。"); + } else { + return Result.fail("不可重复领取。"); + } + } + + /** + * 新增数据 + * + * @param tbShopShareRecord 实例对象 + * @return 实例对象 + */ + @Override + public Result insert(TbShopShareRecord tbShopShareRecord) { + TbShopUser shopUserInfo = getShopUserInfo(tbShopShareRecord.getBeInvitedId(), tbShopShareRecord.getShopId()); + TbShopShareRecord query = tbShopShareRecordMapper.queryByData( + tbShopShareRecord.getShareId(), tbShopShareRecord.getShopId(), + tbShopShareRecord.getInvitedId(), tbShopShareRecord.getBeInvitedId()); + if (query == null) { + TbShopShare tbShopShare = tbShopShareMapper.queryById(tbShopShareRecord.getShareId()); + tbShopShareRecord.setMethod(tbShopShare.getGetMethod()); + tbShopShareRecord.setShopId(tbShopShareRecord.getShopId()); + tbShopShareRecord.setCreateTime(new Date()); + tbShopShareRecord.setUpdateTime(new Date()); + }else { + query.setUpdateTime(new Date()); + } + if (shopUserInfo == null) { + if (query != null) { + query.setStatus(1); + tbShopShareRecordMapper.update(query); + } else { + tbShopShareRecord.setStatus(1); + tbShopShareRecordMapper.insert(tbShopShareRecord); + } + saveShopUser(tbShopShareRecord.getBeInvitedId(), tbShopShareRecord.getShopId()); + } else { + if (query != null) { + query.setStatus(0); + tbShopShareRecordMapper.update(query); + } else { + tbShopShareRecord.setStatus(0); + tbShopShareRecordMapper.insert(tbShopShareRecord); + } + } + if (query == null) { + query = tbShopShareRecord; + } + return Result.successWithData(query); + } + + /** + * 修改数据 + * + * @param tbShopShareRecord 实例对象 + * @return 实例对象 + */ + @Override + public TbShopShareRecord update(TbShopShareRecord tbShopShareRecord) { + this.tbShopShareRecordMapper.update(tbShopShareRecord); + return this.queryById(tbShopShareRecord.getId()); + } + + /** + * 通过主键删除数据 + * + * @param id 主键 + * @return 是否成功 + */ + @Override + public boolean deleteById(Integer id) { + return this.tbShopShareRecordMapper.deleteById(id) > 0; + } + + public TbShopUser getShopUserInfo(Integer userId, Integer shopId) { + return shopUserMapper.selectByUserIdAndShopId(userId.toString(), shopId.toString()); + } + + public void saveShopUser(Integer userId, Integer shopId) { + TbUserInfo tbUserInfo = userInfoMapper.selectByPrimaryKey(userId); + TbShopUser shopUser = new TbShopUser(); + shopUser.setName(tbUserInfo.getNickName()); + shopUser.setSex(tbUserInfo.getSex()); + shopUser.setBirthDay(tbUserInfo.getBirthDay()); + shopUser.setLevel(Byte.parseByte("1")); + String dynamicCode = RandomUtil.randomNumbers(8); + shopUser.setCode(dynamicCode); + shopUser.setTelephone(tbUserInfo.getTelephone()); + shopUser.setAmount(BigDecimal.ZERO); + shopUser.setIsVip(Byte.parseByte("0")); + shopUser.setCreditAmount(BigDecimal.ZERO); + shopUser.setConsumeAmount(BigDecimal.ZERO); + shopUser.setConsumeNumber(0); + shopUser.setLevelConsume(BigDecimal.ZERO); + shopUser.setStatus(Byte.parseByte("1")); + shopUser.setShopId(shopId.toString()); + shopUser.setUserId(userId.toString()); + shopUser.setMiniOpenId(tbUserInfo.getMiniAppOpenId()); + shopUser.setCreatedAt(System.currentTimeMillis()); + shopUser.setUpdatedAt(System.currentTimeMillis()); + shopUserMapper.insert(shopUser); + } + + @Override + public void give(TbShopShareRecord shareRecord, Integer userId) { + TbShopShare shopShare = tbShopShareMapper.queryById(shareRecord.getShareId()); + TbShopUser tbShopUser = getShopUserInfo(userId, shareRecord.getShopId()); + if (userId.equals(shareRecord.getInvitedId())) { + giveCoupon(shopShare, tbShopUser, shopShare.getRewardCoupons()); + } else if (userId.equals(shareRecord.getBeInvitedId())) { + giveCoupon(shopShare, tbShopUser, shopShare.getNewCoupons()); + } + } + + public void giveCoupon(TbShopShare shopShare, TbShopUser tbShopUser, List coupons) { + for (TbShopShare.ShareCoupons newCoupon : coupons) { + TbShopCoupon tbShopCoupon = couponMapper.queryById(newCoupon.getCouponId()); + Date start = new Date(); + Date end = new Date(); + if ("fixed".equals(tbShopCoupon.getValidityType())) { + //固定时间 + end = DateUtil.offsetDay(new Date(), tbShopCoupon.getValidDays()); + } else if ("custom".equals(tbShopCoupon.getValidityType())) { + //自定义时间 + start = tbShopCoupon.getValidStartTime(); + end = tbShopCoupon.getValidEndTime(); + } + if (tbShopCoupon != null) { + List actGiveRecords = new ArrayList<>(); + if (tbShopCoupon.getType() == 1) { + //满减 + TbActivateInRecord record = new TbActivateInRecord(); + record.setVipUserId(Integer.valueOf(tbShopUser.getId())); + record.setCouponId(tbShopCoupon.getId()); + record.setName("满" + tbShopCoupon.getFullAmount() + "减" + tbShopCoupon.getDiscountAmount()); + record.setFullAmount(tbShopCoupon.getFullAmount()); + record.setDiscountAmount(tbShopCoupon.getDiscountAmount()); + record.setType(1); + record.setNum(newCoupon.getCouponNum()); + record.setOverNum(newCoupon.getCouponNum()); + record.setShopId(Integer.valueOf(tbShopUser.getShopId())); + record.setSourceActId(shopShare.getId()); + record.setUseStartTime(start); + record.setUseEndTime(end); + record.setSource("invited"); + actGiveRecords.add(record); + } else if (tbShopCoupon.getType() == 2) { + //商品卷 + List tbCouponProducts = couProductMapper.queryAllByCouponId(tbShopCoupon.getId()); + for (TbCouponProduct actPro : tbCouponProducts) { + TbActivateInRecord record = new TbActivateInRecord(); + record.setVipUserId(Integer.valueOf(tbShopUser.getId())); + record.setCouponId(tbShopCoupon.getId()); + record.setName("商品卷"); + record.setType(2); + record.setProId(actPro.getProductId()); + record.setNum(actPro.getNum() * tbShopCoupon.getNumber()); + record.setOverNum(actPro.getNum() * tbShopCoupon.getNumber()); + record.setShopId(Integer.valueOf(tbShopUser.getShopId())); + record.setSourceActId(shopShare.getId()); + record.setUseStartTime(start); + record.setUseEndTime(end); + record.setSource("invited"); + actGiveRecords.add(record); + } + } + activateInRecordMapper.insertBatch(actGiveRecords); + } + } + + } +} diff --git a/src/main/resources/mapper/TbActivateInRecordMapper.xml b/src/main/resources/mapper/TbActivateInRecordMapper.xml index 0c5af4d..c5eafbf 100644 --- a/src/main/resources/mapper/TbActivateInRecordMapper.xml +++ b/src/main/resources/mapper/TbActivateInRecordMapper.xml @@ -21,10 +21,11 @@ + -id, vip_user_id, coupon_id, name, type, pro_id, full_amount, discount_amount, num, over_num, shop_id, source_act_id, source_flow_id, use_start_time, use_end_time, create_time, update_time, coupon_json +id, vip_user_id, coupon_id, name, type, pro_id, full_amount, discount_amount, num, over_num, shop_id, source_act_id, source_flow_id, use_start_time, use_end_time, create_time, update_time, coupon_json,source diff --git a/src/main/resources/mapper/TbShopShareRecordMapper.xml b/src/main/resources/mapper/TbShopShareRecordMapper.xml new file mode 100644 index 0000000..12d0744 --- /dev/null +++ b/src/main/resources/mapper/TbShopShareRecordMapper.xml @@ -0,0 +1,160 @@ + + + + + + + + + + + + + + + + + + + + id + , share_id, shop_id, invited_id, invited_name, be_invited_id, method, status, reward_time, create_time, update_time + + + + + + + + + + + + + + insert into tb_shop_share_record(share_id, shop_id, invited_id, invited_name, be_invited_id, method, status, + reward_time, create_time, update_time) + values (#{shareId}, #{shopId}, #{invitedId}, #{invitedName}, #{beInvitedId}, #{method}, #{status}, + #{rewardTime}, #{createTime}, #{updateTime}) + + + + insert into tb_shop_share_record(share_id, shop_id, invited_id, invited_name, be_invited_id, method, status, + reward_time, create_time, update_time) + values + + (#{entity.shareId}, #{entity.shopId}, #{entity.invitedId}, #{entity.invitedName}, #{entity.beInvitedId}, + #{entity.method}, #{entity.status}, #{entity.rewardTime}, #{entity.createTime}, #{entity.updateTime}) + + + + + + update tb_shop_share_record + + + share_id = #{shareId}, + + + shop_id = #{shopId}, + + + invited_id = #{invitedId}, + + + invited_name = #{invitedName}, + + + be_invited_id = #{beInvitedId}, + + + method = #{method}, + + + status = #{status}, + + + reward_time = #{rewardTime}, + + + create_time = #{createTime}, + + + update_time = #{updateTime}, + + + where id = #{id} + + + + + delete + from tb_shop_share_record + where id = #{id} + + + + diff --git a/src/main/resources/mapper/TbUserInfoMapper.xml b/src/main/resources/mapper/TbUserInfoMapper.xml index 7f5ec68..8945e15 100644 --- a/src/main/resources/mapper/TbUserInfoMapper.xml +++ b/src/main/resources/mapper/TbUserInfoMapper.xml @@ -67,6 +67,14 @@ from tb_user_info where id = #{id,jdbcType=INTEGER} + + + delete from tb_user_info where id = #{id,jdbcType=INTEGER} From 3eaf8990b16edc9d28a07830d6f1867fb6719c64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Fri, 8 Nov 2024 09:45:14 +0800 Subject: [PATCH 26/26] =?UTF-8?q?fix:=20=E8=AE=A2=E5=8D=95=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E4=B8=8D=E5=B1=95=E7=A4=BA=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chaozhanggui/system/cashierservice/service/CartService.java | 1 + 1 file changed, 1 insertion(+) 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 629b88d..61f73a2 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/CartService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/CartService.java @@ -1012,6 +1012,7 @@ public class CartService { orderInfo.setTradeDay(DateUtils.getDay()); orderInfo.setUseType(eatTypeInfoDTO.getUseType()); orderInfo.setCreatedAt(DateUtil.current()); + orderInfo.setOrderType("miniapp"); orderInfo.setProductCouponDiscountAmount(priceDTO.getProductDiscountAmount()); if (seatCart != null) {