From 7be5d2354fe78f2cf46d7dd463a73f5a27c52eee Mon Sep 17 00:00:00 2001 From: SongZhang <2064194730@qq.com> Date: Sat, 31 Aug 2024 16:47:12 +0800 Subject: [PATCH 01/10] =?UTF-8?q?1.=E5=88=9B=E5=BB=BA=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E5=90=8C=E6=AD=A5=E4=BF=9D=E5=AD=98=E7=94=A8=E6=88=B7id=202.?= =?UTF-8?q?=E4=BB=A3=E5=AE=A2=E4=B8=8B=E5=8D=95=E8=AE=A2=E5=8D=95=E4=B8=8D?= =?UTF-8?q?=E9=87=8D=E5=A4=8D=E5=87=BA=E7=A5=A8=203.=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E6=94=AF=E4=BB=98=E5=AE=8C=E6=AF=95=E6=B8=85=E6=A5=9A=E5=BD=93?= =?UTF-8?q?=E5=89=8D=E5=8F=B0=E6=A1=8C=E7=BC=93=E5=AD=98=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cashierservice/entity/TbOrderInfo.java | 4 +- .../rabbit/PrintMechineConsumer.java | 10 +++ .../system/cashierservice/redis/RedisCst.java | 7 ++ .../cashierservice/service/CartService.java | 8 ++- .../cashierservice/service/PayService.java | 28 ++++++-- .../resources/mapper/TbOrderInfoMapper.xml | 67 ++++++++++--------- 6 files changed, 85 insertions(+), 39 deletions(-) diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbOrderInfo.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbOrderInfo.java index 3f34ec1..8a08964 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbOrderInfo.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbOrderInfo.java @@ -103,6 +103,8 @@ public class TbOrderInfo implements Serializable { private String isWinner; private String shopName; + private String useType; + //根据状态返回 需付款 已付款 未付款 已退 private String description; @@ -188,4 +190,4 @@ public class TbOrderInfo implements Serializable { this.createdAt = System.currentTimeMillis(); this.isAccepted = 1; } -} \ No newline at end of file +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/PrintMechineConsumer.java b/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/PrintMechineConsumer.java index 1657918..0844c1f 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/PrintMechineConsumer.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/PrintMechineConsumer.java @@ -1,6 +1,8 @@ package com.chaozhanggui.system.cashierservice.rabbit; +import cn.hutool.core.util.ArrayUtil; import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; import com.alibaba.fastjson.JSONObject; import com.chaozhanggui.system.cashierservice.dao.*; import com.chaozhanggui.system.cashierservice.entity.*; @@ -18,6 +20,7 @@ import org.springframework.stereotype.Component; import org.springframework.stereotype.Service; import java.util.ArrayList; +import java.util.Arrays; import java.util.Date; import java.util.List; @@ -74,6 +77,9 @@ public class PrintMechineConsumer { return; } + log.info("打印机列表,{}", ArrayUtil.toString(list)); + log.info("待打印订单信息, {}", orderInfo); + list.parallelStream().forEach(tbPrintMachineWithBLOBs->{ if (!"network".equals(tbPrintMachineWithBLOBs.getConnectionType())) { log.error("非网络打印机:{},{}",tbPrintMachineWithBLOBs.getAddress(),tbPrintMachineWithBLOBs.getConnectionType()); @@ -184,6 +190,10 @@ public class PrintMechineConsumer { cashierCarts = tbCashierCartMapper.selectByOrderId(orderId,"final"); if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) { + // 取餐号不为空为代客下单 + if ("postPay".equals(orderInfo.getUseType())) { + return; + } cashierCarts.parallelStream().forEach(it -> { String categoryId; diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/redis/RedisCst.java b/src/main/java/com/chaozhanggui/system/cashierservice/redis/RedisCst.java index d305be3..e83e9c2 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/redis/RedisCst.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/redis/RedisCst.java @@ -26,4 +26,11 @@ public class RedisCst { public static final String CREATE_ORDER_LOCK = "CREATE_ORDER_LOCK:"; public static final String SEND_STOCK_WARN_MSG = "SEND_STOCK_WARN_MSG:"; public static final String SONG_PAY_LOCK = "song_pay_lock:"; + + static String CURRENT_TABLE_ORDER = "CURRENT_TABLE_ORDER:"; + + + public static String getCurrentOrderKey(String tableId, String shopId) { + return CURRENT_TABLE_ORDER + shopId + ":" + 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 833db96..2e65900 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/CartService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/CartService.java @@ -25,6 +25,7 @@ import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; @@ -93,6 +94,8 @@ public class CartService { private final RedisTemplate redisTemplate; + private final StringRedisTemplate stringRedisTemplate; + @Autowired private TbProskuConMapper tbProskuConMapper; @@ -100,7 +103,7 @@ public class CartService { @Autowired TbConsInfoMapper tbConsInfoMapper; - public CartService(TbUserShopMsgMapper tbUserShopMsgMapper, WechatUtil wechatUtil, WxAccountUtil wxAccountUtil, TbShopOpenIdMapper shopOpenIdMapper, ProductService productService, TbProductMapper tbProductMapper, RedisTemplate redisTemplate) { + public CartService(TbUserShopMsgMapper tbUserShopMsgMapper, WechatUtil wechatUtil, WxAccountUtil wxAccountUtil, TbShopOpenIdMapper shopOpenIdMapper, ProductService productService, TbProductMapper tbProductMapper, RedisTemplate redisTemplate, StringRedisTemplate stringRedisTemplate) { this.tbUserShopMsgMapper = tbUserShopMsgMapper; this.wechatUtil = wechatUtil; this.wxAccountUtil = wxAccountUtil; @@ -108,6 +111,7 @@ public class CartService { this.productService = productService; this.tbProductMapper = tbProductMapper; this.redisTemplate = redisTemplate; + this.stringRedisTemplate = stringRedisTemplate; } public void initCart(JSONObject jsonObject) { @@ -708,6 +712,7 @@ public class CartService { orderInfo.setIsBuyCoupon(isBuyYhq); orderInfo.setIsUseCoupon(isuseYhq); orderInfo.setRemark(remark); + orderInfo.setUserId(userId); orderInfoMapper.updateByPrimaryKeySelective(orderInfo); } else { @@ -719,6 +724,7 @@ public class CartService { orderInfo.setIsUseCoupon(isuseYhq); orderInfo.setUserCouponAmount(couponAmount); orderInfo.setRemark(remark); + orderInfo.setUserId(userId); JSONObject object = new JSONObject(); String outNumber = redisUtil.getMessage(RedisCst.OUT_NUMBER.concat(jsonObject.getString("shopId"))); 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 0b2b1cc..3e832ae 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/PayService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/PayService.java @@ -31,6 +31,7 @@ import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Value; +import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -158,6 +159,8 @@ public class PayService { private final TbShopSongOrderService shopSongOrderService; @Autowired private MQUtils mQUtils; + @Autowired + private StringRedisTemplate stringRedisTemplate; public PayService(@Qualifier("tbShopSongOrderServiceImpl") TbShopSongOrderService shopSongOrderService) { this.shopSongOrderService = shopSongOrderService; @@ -330,6 +333,7 @@ public class PayService { if (ObjectUtil.isEmpty(orderInfo)) { return Result.fail("订单信息不存在"); } + if (System.currentTimeMillis() - orderInfo.getCreatedAt() > 60 * 15 * 1000) { return Result.fail("订单十五分钟内有效,当前已超时,请重新下单。"); } @@ -432,10 +436,12 @@ public class PayService { baObj.put("time",flow.getCreateTime()); producer.balance(baObj.toString()); - - - - + // 为代客下单清楚当前台桌最新订单 + String currentOrderKey = RedisCst.getCurrentOrderKey(orderInfo.getTableId(), orderInfo.getShopId()); + String currentOrderId = stringRedisTemplate.opsForValue().get(currentOrderKey); + if (currentOrderId != null && currentOrderId.equals(orderId)) { + stringRedisTemplate.delete(currentOrderKey); + } return Result.success(CodeEnum.SUCCESS, "1"); } @@ -916,6 +922,13 @@ public class PayService { sendOrderToClient(orderInfo); redisUtil.deleteByKey(RedisCst.ORDER_EXPIRED.concat(orderInfo.getId().toString())); + // 为代客下单清除当前台桌最新订单 + String currentOrderKey = RedisCst.getCurrentOrderKey(orderInfo.getTableId(), orderInfo.getShopId()); + String currentOrderId = stringRedisTemplate.opsForValue().get(currentOrderKey); + if (currentOrderId != null && currentOrderId.equals(orderInfo.getId().toString())) { + stringRedisTemplate.delete(currentOrderKey); + } + // 发送mq消息并保存库存记录 JSONObject data = new JSONObject(); data.put("orderId", orderInfo.getId()); @@ -967,6 +980,13 @@ public class PayService { sendOrderToClient(orderInfo); redisUtil.deleteByKey(RedisCst.ORDER_EXPIRED.concat(orderInfo.getId().toString())); + // 为代客下单清楚当前台桌最新订单 + String currentOrderKey = RedisCst.getCurrentOrderKey(orderInfo.getTableId(), orderInfo.getShopId()); + String currentOrderId = stringRedisTemplate.opsForValue().get(currentOrderKey); + if (currentOrderId != null && currentOrderId.equals(orderInfo.getId().toString())) { + stringRedisTemplate.delete(currentOrderKey); + } + // 发送mq消息并保存库存记录 JSONObject data = new JSONObject(); data.put("orderId", orderInfo.getId()); diff --git a/src/main/resources/mapper/TbOrderInfoMapper.xml b/src/main/resources/mapper/TbOrderInfoMapper.xml index 5ee9c7d..97196ca 100644 --- a/src/main/resources/mapper/TbOrderInfoMapper.xml +++ b/src/main/resources/mapper/TbOrderInfoMapper.xml @@ -51,17 +51,17 @@ - id, order_no, settlement_amount, pack_fee, origin_amount, product_amount, amount, - refund_amount, pay_type, pay_amount, order_amount, freight_amount, discount_ratio, - discount_amount, table_id, small_change, send_type, order_type, product_type, status, - billing_id, merchant_id, shop_id, is_vip, member_id, user_id, product_score, deduct_score, - user_coupon_id, user_coupon_amount, refund_able, paid_time, is_effect, is_group, + id, order_no, settlement_amount, pack_fee, origin_amount, product_amount, amount, + refund_amount, pay_type, pay_amount, order_amount, freight_amount, discount_ratio, + discount_amount, table_id, small_change, send_type, order_type, product_type, status, + billing_id, merchant_id, shop_id, is_vip, member_id, user_id, product_score, deduct_score, + user_coupon_id, user_coupon_amount, refund_able, paid_time, is_effect, is_group, updated_at, `system_time`, created_at, is_accepted, pay_order_no,trade_day,`source`, remark,master_id,`table_name`,is_buy_coupon,is_use_coupon,out_number @@ -72,32 +72,32 @@ - insert into tb_order_info (id, order_no, settlement_amount, - pack_fee, origin_amount, product_amount, - amount, refund_amount, pay_type, - pay_amount, order_amount, freight_amount, - discount_ratio, discount_amount, table_id, - small_change, send_type, order_type, - product_type, status, billing_id, - merchant_id, shop_id, is_vip, - member_id, user_id, product_score, - deduct_score, user_coupon_id, user_coupon_amount, - refund_able, paid_time, is_effect, - is_group, updated_at, system_time, + insert into tb_order_info (id, order_no, settlement_amount, + pack_fee, origin_amount, product_amount, + amount, refund_amount, pay_type, + pay_amount, order_amount, freight_amount, + discount_ratio, discount_amount, table_id, + small_change, send_type, order_type, + product_type, status, billing_id, + merchant_id, shop_id, is_vip, + member_id, user_id, product_score, + deduct_score, user_coupon_id, user_coupon_amount, + refund_able, paid_time, is_effect, + is_group, updated_at, system_time, created_at, is_accepted, pay_order_no,trade_day,source,remark,master_id,table_name,is_buy_coupon,is_use_coupon,out_number ) - values (#{id,jdbcType=INTEGER}, #{orderNo,jdbcType=VARCHAR}, #{settlementAmount,jdbcType=DECIMAL}, - #{packFee,jdbcType=DECIMAL}, #{originAmount,jdbcType=DECIMAL}, #{productAmount,jdbcType=DECIMAL}, - #{amount,jdbcType=DECIMAL}, #{refundAmount,jdbcType=DECIMAL}, #{payType,jdbcType=VARCHAR}, - #{payAmount,jdbcType=DECIMAL}, #{orderAmount,jdbcType=DECIMAL}, #{freightAmount,jdbcType=DECIMAL}, - #{discountRatio,jdbcType=DECIMAL}, #{discountAmount,jdbcType=DECIMAL}, #{tableId,jdbcType=VARCHAR}, - #{smallChange,jdbcType=DECIMAL}, #{sendType,jdbcType=VARCHAR}, #{orderType,jdbcType=VARCHAR}, - #{productType,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR}, #{billingId,jdbcType=VARCHAR}, - #{merchantId,jdbcType=VARCHAR}, #{shopId,jdbcType=VARCHAR}, #{isVip,jdbcType=TINYINT}, - #{memberId,jdbcType=VARCHAR}, #{userId,jdbcType=VARCHAR}, #{productScore,jdbcType=INTEGER}, - #{deductScore,jdbcType=INTEGER}, #{userCouponId,jdbcType=VARCHAR}, #{userCouponAmount,jdbcType=DECIMAL}, - #{refundAble,jdbcType=TINYINT}, #{paidTime,jdbcType=BIGINT}, #{isEffect,jdbcType=TINYINT}, - #{isGroup,jdbcType=TINYINT}, #{updatedAt,jdbcType=BIGINT}, #{systemTime,jdbcType=BIGINT}, + values (#{id,jdbcType=INTEGER}, #{orderNo,jdbcType=VARCHAR}, #{settlementAmount,jdbcType=DECIMAL}, + #{packFee,jdbcType=DECIMAL}, #{originAmount,jdbcType=DECIMAL}, #{productAmount,jdbcType=DECIMAL}, + #{amount,jdbcType=DECIMAL}, #{refundAmount,jdbcType=DECIMAL}, #{payType,jdbcType=VARCHAR}, + #{payAmount,jdbcType=DECIMAL}, #{orderAmount,jdbcType=DECIMAL}, #{freightAmount,jdbcType=DECIMAL}, + #{discountRatio,jdbcType=DECIMAL}, #{discountAmount,jdbcType=DECIMAL}, #{tableId,jdbcType=VARCHAR}, + #{smallChange,jdbcType=DECIMAL}, #{sendType,jdbcType=VARCHAR}, #{orderType,jdbcType=VARCHAR}, + #{productType,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR}, #{billingId,jdbcType=VARCHAR}, + #{merchantId,jdbcType=VARCHAR}, #{shopId,jdbcType=VARCHAR}, #{isVip,jdbcType=TINYINT}, + #{memberId,jdbcType=VARCHAR}, #{userId,jdbcType=VARCHAR}, #{productScore,jdbcType=INTEGER}, + #{deductScore,jdbcType=INTEGER}, #{userCouponId,jdbcType=VARCHAR}, #{userCouponAmount,jdbcType=DECIMAL}, + #{refundAble,jdbcType=TINYINT}, #{paidTime,jdbcType=BIGINT}, #{isEffect,jdbcType=TINYINT}, + #{isGroup,jdbcType=TINYINT}, #{updatedAt,jdbcType=BIGINT}, #{systemTime,jdbcType=BIGINT}, #{createdAt,jdbcType=BIGINT}, #{isAccepted,jdbcType=TINYINT}, #{payOrderNo,jdbcType=VARCHAR}, #{tradeDay,jdbcType=VARCHAR}, #{source,jdbcType=INTEGER}, #{remark,jdbcType=VARCHAR}, #{masterId,jdbcType=VARCHAR}, #{tableName,jdbcType=VARCHAR}, #{isBuyCoupon,jdbcType=VARCHAR}, #{isUseCoupon,jdbcType=VARCHAR},#{outNumber,jdbcType=VARCHAR} @@ -486,9 +486,10 @@ is_buy_coupon = #{isBuyCoupon,jdbcType=VARCHAR}, - - is_use_coupon = #{isUseCoupon,jdbcType=VARCHAR}, + + user_id = #{userId,jdbcType=VARCHAR}, + where id = #{id,jdbcType=INTEGER} @@ -576,4 +577,4 @@ left join tb_user_info tui on tui.id = toi.user_id where toi.user_id = #{userId} - \ No newline at end of file + From 119b6ba9c7163aed4a2d8bfb810bca0a2606c863 Mon Sep 17 00:00:00 2001 From: SongZhang <2064194730@qq.com> Date: Mon, 2 Sep 2024 10:31:56 +0800 Subject: [PATCH 02/10] =?UTF-8?q?1.=E4=B8=8B=E5=8D=95=E4=B8=8D=E6=89=93?= =?UTF-8?q?=E7=A5=A8=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cashierservice/rabbit/PrintMechineConsumer.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/PrintMechineConsumer.java b/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/PrintMechineConsumer.java index 0844c1f..436d07e 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/PrintMechineConsumer.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/PrintMechineConsumer.java @@ -190,12 +190,14 @@ public class PrintMechineConsumer { cashierCarts = tbCashierCartMapper.selectByOrderId(orderId,"final"); if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) { - // 取餐号不为空为代客下单 - if ("postPay".equals(orderInfo.getUseType())) { - return; - } + cashierCarts.parallelStream().forEach(it -> { + // 取餐号不为空为代客下单 + if ("postPay".equals(orderInfo.getUseType()) && StrUtil.isNotBlank(it.getMasterId())) { + return; + } + String categoryId; if(ObjectUtil.isEmpty(it.getCategoryId())){ categoryId= tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId(); From b3850469eca947c80bd1e3da71333489eff62371 Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Mon, 2 Sep 2024 15:30:32 +0800 Subject: [PATCH 03/10] =?UTF-8?q?=E4=BC=9A=E5=91=98=E5=95=86=E5=93=81=20?= =?UTF-8?q?=E4=BC=98=E6=83=A0=E5=8D=B7=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/TbUserCouponsController.java | 32 +++++++++ .../dao/TbActivateInRecordMapper.java | 3 + .../dao/TbActivateOutRecordMapper.java | 3 + .../dao/TbUserCouponsMapper.java | 3 + .../cashierservice/entity/TbUserCoupons.java | 3 +- .../entity/dto/UserCouponDto.java | 11 +++ .../entity/vo/UserCouponVo.java | 33 +++++++++ .../cashierservice/service/CartService.java | 23 +----- .../service/TbUserCouponsService.java | 22 ++++++ .../impl/TbUserCouponsServiceImpl.java | 70 +++++++++++++++++++ .../mapper/TbActivateInRecordMapper.xml | 13 ++++ .../mapper/TbActivateOutRecordMapper.xml | 14 ++++ .../resources/mapper/TbShopUserMapper.xml | 4 ++ .../resources/mapper/TbUserCouponsMapper.xml | 32 ++++++++- 14 files changed, 240 insertions(+), 26 deletions(-) create mode 100644 src/main/java/com/chaozhanggui/system/cashierservice/controller/TbUserCouponsController.java create mode 100644 src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/UserCouponDto.java create mode 100644 src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/UserCouponVo.java create mode 100644 src/main/java/com/chaozhanggui/system/cashierservice/service/TbUserCouponsService.java create mode 100644 src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbUserCouponsServiceImpl.java diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/controller/TbUserCouponsController.java b/src/main/java/com/chaozhanggui/system/cashierservice/controller/TbUserCouponsController.java new file mode 100644 index 0000000..508867a --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/controller/TbUserCouponsController.java @@ -0,0 +1,32 @@ +package com.chaozhanggui.system.cashierservice.controller; + +import com.chaozhanggui.system.cashierservice.entity.dto.UserCouponDto; +import com.chaozhanggui.system.cashierservice.service.TbUserCouponsService; +import com.chaozhanggui.system.cashierservice.sign.Result; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + + +@RestController +@RequestMapping("userConpons") +public class TbUserCouponsController { + /** + * 服务对象 + */ + @Autowired + private TbUserCouponsService tbUserCouponsService; + + /** + * 查询优惠卷 + * @param conponDto + * @return + */ + @RequestMapping("find") + public Result queryByPage(@RequestBody UserCouponDto conponDto) { + return tbUserCouponsService.queryByPage(conponDto); + } + +} + diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbActivateInRecordMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbActivateInRecordMapper.java index 7a5a8f8..86ad0ee 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbActivateInRecordMapper.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbActivateInRecordMapper.java @@ -2,6 +2,8 @@ package com.chaozhanggui.system.cashierservice.dao; import com.chaozhanggui.system.cashierservice.entity.TbActivateInRecord; import com.chaozhanggui.system.cashierservice.entity.TbProduct; +import com.chaozhanggui.system.cashierservice.entity.TbUserCoupons; +import com.chaozhanggui.system.cashierservice.entity.vo.UserCouponVo; import org.apache.ibatis.annotations.Param; import java.util.List; @@ -31,6 +33,7 @@ public interface TbActivateInRecordMapper { List queryAll(TbActivateInRecord tbActivateInRecord); List queryByVipIdAndShopId(@Param("vipUserId") Integer vipUserId, @Param("shopId") Integer shopId); + List queryVipPro(@Param("vipUserId") Integer vipUserId, @Param("shopId") Integer shopId); int queryByVipIdAndShopIdAndProId(@Param("vipUserId") Integer vipUserId, @Param("shopId") Integer shopId,@Param("productId") Integer productId); List queryAllByVipIdAndShopIdAndProId(@Param("vipUserId") Integer vipUserId, @Param("shopId") Integer shopId,@Param("productId") Integer productId); diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbActivateOutRecordMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbActivateOutRecordMapper.java index b2b9dcd..23c1983 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbActivateOutRecordMapper.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbActivateOutRecordMapper.java @@ -1,6 +1,7 @@ package com.chaozhanggui.system.cashierservice.dao; import com.chaozhanggui.system.cashierservice.entity.TbActivateOutRecord; +import com.chaozhanggui.system.cashierservice.entity.vo.UserCouponVo; import org.apache.ibatis.annotations.Param; import java.util.List; @@ -29,6 +30,8 @@ public interface TbActivateOutRecordMapper { */ List queryAll(TbActivateOutRecord tbActivateOutRecord); + List queryVipPro(@Param("vipUserId") Integer vipUserId, @Param("shopId") Integer shopId); + /** * 新增数据 diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbUserCouponsMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbUserCouponsMapper.java index 192a2e3..8306b65 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbUserCouponsMapper.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbUserCouponsMapper.java @@ -1,6 +1,8 @@ package com.chaozhanggui.system.cashierservice.dao; import com.chaozhanggui.system.cashierservice.entity.TbUserCoupons; +import com.chaozhanggui.system.cashierservice.entity.dto.UserCouponDto; +import com.chaozhanggui.system.cashierservice.entity.vo.UserCouponVo; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; import org.springframework.stereotype.Component; @@ -18,6 +20,7 @@ public interface TbUserCouponsMapper { int insertSelective(TbUserCoupons record); TbUserCoupons selectByPrimaryKey(Integer id); + List queryAllSelective(UserCouponDto record); int updateByPrimaryKeySelective(TbUserCoupons record); diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbUserCoupons.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbUserCoupons.java index 6f59527..13d7029 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbUserCoupons.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbUserCoupons.java @@ -7,10 +7,11 @@ import java.math.BigDecimal; import java.util.Date; @Data -public class TbUserCoupons implements Serializable { +public class TbUserCoupons implements Serializable{ private Integer id; private String userId; + private String detail; private Integer orderId; private BigDecimal couponsPrice; diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/UserCouponDto.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/UserCouponDto.java new file mode 100644 index 0000000..b53d03f --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/UserCouponDto.java @@ -0,0 +1,11 @@ +package com.chaozhanggui.system.cashierservice.entity.dto; + +import lombok.Data; + +@Data +public class UserCouponDto extends BasePageDto{ + private Integer userId; + private Integer status; + private Integer shopId; + +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/UserCouponVo.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/UserCouponVo.java new file mode 100644 index 0000000..553002f --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/UserCouponVo.java @@ -0,0 +1,33 @@ +package com.chaozhanggui.system.cashierservice.entity.vo; + +import lombok.Data; + +import java.math.BigDecimal; + +@Data +public class UserCouponVo { + /** + * 2 会员商品卷 + */ + private Integer type; + /** + * 卷描述 + */ + private String detail; + /** + * 优惠金额 + */ + private BigDecimal couponsPrice = BigDecimal.ZERO; + /** + * 多少可用 + */ + private BigDecimal couponsAmount = BigDecimal.ZERO; + /** + * 数量 + */ + private Integer num; + /** + * 卷状态 0 未使用 + */ + private String status; +} 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 2e65900..63b6d84 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/CartService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/CartService.java @@ -654,28 +654,7 @@ public class CartService { couponAmount = userCoupons.getCouponsAmount(); } else { TbUserCoupons userCoupons = userCouponsMapper.selectByPrimaryKey(couponsId); - if (Objects.isNull(userCoupons) || !userCoupons.getStatus().equals("0")) { - log.info("开始处理订单"); - JSONObject jsonObject1 = new JSONObject(); - jsonObject1.put("status", "fail"); - jsonObject1.put("msg", "优惠券已使用"); - jsonObject1.put("type", jsonObject.getString("type")); - jsonObject1.put("data", ""); - PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), key, jsonObject.getString("userId"), true); - log.info("消息推送"); - return; - } - if (N.gt(userCoupons.getCouponsAmount(), totalAmount)) { - log.info("开始处理订单"); - JSONObject jsonObject1 = new JSONObject(); - jsonObject1.put("status", "fail"); - jsonObject1.put("msg", "订单金额小于优惠价金额"); - jsonObject1.put("type", jsonObject.getString("type")); - jsonObject1.put("data", ""); - PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), key, jsonObject.getString("userId"), true); - log.info("消息推送"); - return; - } + totalAmount = totalAmount.subtract(userCoupons.getCouponsAmount()); userCoupons.setStatus("1"); userCoupons.setEndTime(DateUtils.getNewDate(new Date(), 5, 30)); diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/TbUserCouponsService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/TbUserCouponsService.java new file mode 100644 index 0000000..c687d0a --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/TbUserCouponsService.java @@ -0,0 +1,22 @@ +package com.chaozhanggui.system.cashierservice.service; + +import com.chaozhanggui.system.cashierservice.entity.dto.UserCouponDto; +import com.chaozhanggui.system.cashierservice.sign.Result; + +/** + * (TbUserCoupons)表服务接口 + * + * @author ww + * @since 2024-09-02 13:38:20 + */ +public interface TbUserCouponsService { + + /** + * 分页查询 + * + * @param tbUserCoupons 筛选条件 + * @return 查询结果 + */ + Result queryByPage(UserCouponDto tbUserCoupons); + +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbUserCouponsServiceImpl.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbUserCouponsServiceImpl.java new file mode 100644 index 0000000..41744c4 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbUserCouponsServiceImpl.java @@ -0,0 +1,70 @@ +package com.chaozhanggui.system.cashierservice.service.impl; + +import com.chaozhanggui.system.cashierservice.dao.TbActivateInRecordMapper; +import com.chaozhanggui.system.cashierservice.dao.TbActivateOutRecordMapper; +import com.chaozhanggui.system.cashierservice.dao.TbShopUserMapper; +import com.chaozhanggui.system.cashierservice.dao.TbUserCouponsMapper; +import com.chaozhanggui.system.cashierservice.entity.dto.UserCouponDto; +import com.chaozhanggui.system.cashierservice.entity.vo.ShopUserListVo; +import com.chaozhanggui.system.cashierservice.entity.vo.UserCouponVo; +import com.chaozhanggui.system.cashierservice.service.TbUserCouponsService; +import com.chaozhanggui.system.cashierservice.sign.CodeEnum; +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.util.CollectionUtils; + +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.List; + +/** + * (TbUserCoupons)表服务实现类 + * + * @author ww + * @since 2024-09-02 13:38:20 + */ +@Primary +@Service +public class TbUserCouponsServiceImpl implements TbUserCouponsService { + @Resource + private TbUserCouponsMapper tbUserCouponsMapper; + @Resource + private TbActivateInRecordMapper inRecordMapper; + @Resource + private TbActivateOutRecordMapper outRecordMapper; + @Autowired + private TbShopUserMapper tbShopUserMapper; + + + /** + * 分页查询 + * @return 查询结果 + */ + @Override + public Result queryByPage(UserCouponDto couponDto) { +// PageHelper.startPage(couponDto.getPage(), couponDto.getSize()); +// List result = tbUserCouponsMapper.queryAllSelective(couponDto); +// return new Result(CodeEnum.SUCCESS, new PageInfo<>(result)); +// List result = tbUserCouponsMapper.queryAllSelective(couponDto); + List result = new ArrayList<>(); + List tbShopUsers = tbShopUserMapper.selectByUserId(couponDto.getUserId().toString(), couponDto.getShopId()==null?null:couponDto.getShopId().toString()); + if (!CollectionUtils.isEmpty(tbShopUsers)) { + tbShopUsers.forEach(s -> { + if (couponDto.getStatus()==null || (couponDto.getStatus() != null && couponDto.getStatus() != 0)) { + List unuseCoupon = inRecordMapper.queryVipPro(s.getMemberId().intValue(), s.getShopId().intValue()); + result.addAll(unuseCoupon); + } + if (couponDto.getStatus()==null || (couponDto.getStatus() != null && couponDto.getStatus() != 1)) { + List useCoupon = outRecordMapper.queryVipPro(s.getMemberId().intValue(), s.getShopId().intValue()); + result.addAll(useCoupon); + } + }); + } + + return new Result(CodeEnum.SUCCESS, result); + } + +} + diff --git a/src/main/resources/mapper/TbActivateInRecordMapper.xml b/src/main/resources/mapper/TbActivateInRecordMapper.xml index aa51b93..d5e9e89 100644 --- a/src/main/resources/mapper/TbActivateInRecordMapper.xml +++ b/src/main/resources/mapper/TbActivateInRecordMapper.xml @@ -39,6 +39,19 @@ group by tb_activate_in_record.pro_id + + + + + + + diff --git a/src/main/resources/mapper/TbUserCouponsMapper.xml b/src/main/resources/mapper/TbUserCouponsMapper.xml index b746d3c..cd27c4b 100644 --- a/src/main/resources/mapper/TbUserCouponsMapper.xml +++ b/src/main/resources/mapper/TbUserCouponsMapper.xml @@ -4,6 +4,7 @@ + @@ -13,7 +14,7 @@ - id, user_id, coupons_price, coupons_amount, status, create_time, update_time, end_time,is_double + id, user_id, detail, coupons_price, coupons_amount, status, create_time, update_time, end_time,is_double + + + - - delete from tb_order_info - where id = #{id,jdbcType=INTEGER} - + + + + + + update tb_order_info + set is_del = 1 + where id = #{id,jdbcType=INTEGER} + @@ -550,6 +555,7 @@ where user_id = #{userId} and order_type='miniapp' + and is_del != 1 From fd184ba8359a293715b9a281c97c9acae06c183a Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Mon, 2 Sep 2024 17:08:59 +0800 Subject: [PATCH 05/10] =?UTF-8?q?=E4=BC=98=E6=83=A0=E5=8D=B7=E5=88=97?= =?UTF-8?q?=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cashierservice/service/impl/TbUserCouponsServiceImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbUserCouponsServiceImpl.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbUserCouponsServiceImpl.java index 41744c4..bcf02ec 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbUserCouponsServiceImpl.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbUserCouponsServiceImpl.java @@ -52,11 +52,11 @@ public class TbUserCouponsServiceImpl implements TbUserCouponsService { List tbShopUsers = tbShopUserMapper.selectByUserId(couponDto.getUserId().toString(), couponDto.getShopId()==null?null:couponDto.getShopId().toString()); if (!CollectionUtils.isEmpty(tbShopUsers)) { tbShopUsers.forEach(s -> { - if (couponDto.getStatus()==null || (couponDto.getStatus() != null && couponDto.getStatus() != 0)) { + if (couponDto.getStatus()==null || (couponDto.getStatus() != null && couponDto.getStatus() == 0)) { List unuseCoupon = inRecordMapper.queryVipPro(s.getMemberId().intValue(), s.getShopId().intValue()); result.addAll(unuseCoupon); } - if (couponDto.getStatus()==null || (couponDto.getStatus() != null && couponDto.getStatus() != 1)) { + if (couponDto.getStatus()==null || (couponDto.getStatus() != null && couponDto.getStatus() == 1)) { List useCoupon = outRecordMapper.queryVipPro(s.getMemberId().intValue(), s.getShopId().intValue()); result.addAll(useCoupon); } From 9a9e43ba71d811fe6df2118b4f9ab88c4350061d Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Mon, 2 Sep 2024 17:59:44 +0800 Subject: [PATCH 06/10] =?UTF-8?q?=E4=BC=98=E6=83=A0=E5=8D=B7=E5=88=97?= =?UTF-8?q?=E8=A1=A8=20=E6=B7=BB=E5=8A=A0=20=E5=BA=97=E9=93=BA=E5=90=8D?= =?UTF-8?q?=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dao/TbActivateInRecordMapper.java | 2 +- .../dao/TbActivateOutRecordMapper.java | 2 +- .../cashierservice/entity/vo/UserCouponVo.java | 1 + .../service/impl/TbUserCouponsServiceImpl.java | 13 +++++++------ .../mapper/TbActivateInRecordMapper.xml | 18 +++++++++++------- .../mapper/TbActivateOutRecordMapper.xml | 13 +++++++++---- 6 files changed, 30 insertions(+), 19 deletions(-) diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbActivateInRecordMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbActivateInRecordMapper.java index 86ad0ee..df4b1d5 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbActivateInRecordMapper.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbActivateInRecordMapper.java @@ -33,7 +33,7 @@ public interface TbActivateInRecordMapper { List queryAll(TbActivateInRecord tbActivateInRecord); List queryByVipIdAndShopId(@Param("vipUserId") Integer vipUserId, @Param("shopId") Integer shopId); - List queryVipPro(@Param("vipUserId") Integer vipUserId, @Param("shopId") Integer shopId); + List queryVipPro(@Param("vipUserId") Integer vipUserId, @Param("shopId") Integer shopId,@Param("shopName")String shopName); int queryByVipIdAndShopIdAndProId(@Param("vipUserId") Integer vipUserId, @Param("shopId") Integer shopId,@Param("productId") Integer productId); List queryAllByVipIdAndShopIdAndProId(@Param("vipUserId") Integer vipUserId, @Param("shopId") Integer shopId,@Param("productId") Integer productId); diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbActivateOutRecordMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbActivateOutRecordMapper.java index 23c1983..7b8b5ba 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbActivateOutRecordMapper.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbActivateOutRecordMapper.java @@ -30,7 +30,7 @@ public interface TbActivateOutRecordMapper { */ List queryAll(TbActivateOutRecord tbActivateOutRecord); - List queryVipPro(@Param("vipUserId") Integer vipUserId, @Param("shopId") Integer shopId); + List queryVipPro(@Param("vipUserId") Integer vipUserId, @Param("shopId") Integer shopId, @Param("shopName") String shopName); /** diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/UserCouponVo.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/UserCouponVo.java index 553002f..8dfec49 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/UserCouponVo.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/UserCouponVo.java @@ -14,6 +14,7 @@ public class UserCouponVo { * 卷描述 */ private String detail; + private String shopName; /** * 优惠金额 */ diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbUserCouponsServiceImpl.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbUserCouponsServiceImpl.java index bcf02ec..5236c6c 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbUserCouponsServiceImpl.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbUserCouponsServiceImpl.java @@ -1,9 +1,7 @@ package com.chaozhanggui.system.cashierservice.service.impl; -import com.chaozhanggui.system.cashierservice.dao.TbActivateInRecordMapper; -import com.chaozhanggui.system.cashierservice.dao.TbActivateOutRecordMapper; -import com.chaozhanggui.system.cashierservice.dao.TbShopUserMapper; -import com.chaozhanggui.system.cashierservice.dao.TbUserCouponsMapper; +import com.chaozhanggui.system.cashierservice.dao.*; +import com.chaozhanggui.system.cashierservice.entity.TbShopInfo; import com.chaozhanggui.system.cashierservice.entity.dto.UserCouponDto; import com.chaozhanggui.system.cashierservice.entity.vo.ShopUserListVo; import com.chaozhanggui.system.cashierservice.entity.vo.UserCouponVo; @@ -36,6 +34,8 @@ public class TbUserCouponsServiceImpl implements TbUserCouponsService { private TbActivateOutRecordMapper outRecordMapper; @Autowired private TbShopUserMapper tbShopUserMapper; + @Autowired + private TbShopInfoMapper tbShopInfoMapper; /** @@ -52,12 +52,13 @@ public class TbUserCouponsServiceImpl implements TbUserCouponsService { List tbShopUsers = tbShopUserMapper.selectByUserId(couponDto.getUserId().toString(), couponDto.getShopId()==null?null:couponDto.getShopId().toString()); if (!CollectionUtils.isEmpty(tbShopUsers)) { tbShopUsers.forEach(s -> { + TbShopInfo shopInfo = tbShopInfoMapper.selectByPrimaryKey(s.getShopId().intValue()); if (couponDto.getStatus()==null || (couponDto.getStatus() != null && couponDto.getStatus() == 0)) { - List unuseCoupon = inRecordMapper.queryVipPro(s.getMemberId().intValue(), s.getShopId().intValue()); + List unuseCoupon = inRecordMapper.queryVipPro(s.getMemberId().intValue(), s.getShopId().intValue(),shopInfo.getShopName()); result.addAll(unuseCoupon); } if (couponDto.getStatus()==null || (couponDto.getStatus() != null && couponDto.getStatus() == 1)) { - List useCoupon = outRecordMapper.queryVipPro(s.getMemberId().intValue(), s.getShopId().intValue()); + List useCoupon = outRecordMapper.queryVipPro(s.getMemberId().intValue(), s.getShopId().intValue(),shopInfo.getShopName()); result.addAll(useCoupon); } }); diff --git a/src/main/resources/mapper/TbActivateInRecordMapper.xml b/src/main/resources/mapper/TbActivateInRecordMapper.xml index d5e9e89..6d9ad84 100644 --- a/src/main/resources/mapper/TbActivateInRecordMapper.xml +++ b/src/main/resources/mapper/TbActivateInRecordMapper.xml @@ -40,15 +40,19 @@ diff --git a/src/main/resources/mapper/TbActivateOutRecordMapper.xml b/src/main/resources/mapper/TbActivateOutRecordMapper.xml index 278b4fd..9e50eca 100644 --- a/src/main/resources/mapper/TbActivateOutRecordMapper.xml +++ b/src/main/resources/mapper/TbActivateOutRecordMapper.xml @@ -29,10 +29,15 @@