Bladeren bron

处理代码

lutong 1 maand geleden
bovenliggende
commit
120e43e3d8

+ 1 - 0
alien-entity/src/main/java/shop/alien/entity/storePlatform/vo/LifeCouponPlatformVo.java

@@ -23,6 +23,7 @@ public class LifeCouponPlatformVo {
     // 优惠券列表
     public Integer couponsFromType; // 默认1
     public Integer couponStatus;//优惠券状态:1:进行中 2:已结束 3:草稿
+    public Integer discountCouponType; // 优惠券类型:1=满减券,2=折扣券,不传=全部优惠券
 
     // 优惠券还是代金券
     public Integer couponType; // 1代金券 2优惠券

+ 6 - 0
alien-entity/src/main/java/shop/alien/entity/storePlatform/vo/StoreOperationalActivityVO.java

@@ -72,5 +72,11 @@ public class StoreOperationalActivityVO extends StoreOperationalActivity {
 
     @ApiModelProperty(value = "优惠券类型:1-优惠券, 2-红包, 3-平台优惠券, 4-代金券")
     private Integer couponType;
+
+    @ApiModelProperty(value = "优惠券类型(满减券/折扣券):1=满减券,2=折扣券(仅当优惠券存在时有值)")
+    private Integer discountCouponType;
+
+    @ApiModelProperty(value = "折扣率(0-100,用于折扣券,例如80表示8折,仅折扣券有值)")
+    private java.math.BigDecimal discountRate;
 }
 

+ 4 - 3
alien-store-platform/src/main/java/shop/alien/storeplatform/controller/LifeCouponPlatformController.java

@@ -251,7 +251,7 @@ public class LifeCouponPlatformController {
      * @author alien-cloud
      * @date 2025-11-18
      */
-    @ApiOperation("代金劵/优惠券列表")
+    @ApiOperation("代金劵/优惠券列表。discountCouponType=1仅满减券,discountCouponType=2仅折扣券,不传返回全部优惠券")
     @PostMapping("/getCouponList")
     private R<DiscountCouponPlatformVo> getCouponList(@ApiIgnore @TokenInfo UserLoginInfo userLoginInfo,
                                                       @RequestBody LifeCouponPlatformVo lifeCouponPlatformVo) {
@@ -260,12 +260,13 @@ public class LifeCouponPlatformController {
             return R.data(null, "当前用户未入驻!!!");
         }
         DiscountCouponPlatformVo vo = new DiscountCouponPlatformVo();
-        if (lifeCouponPlatformVo.getCouponType() == 1) {
+        // couponType: 1=代金券,2=优惠券,null或其他=优惠券(默认)
+        if (lifeCouponPlatformVo.getCouponType() != null && lifeCouponPlatformVo.getCouponType() == 1) {
             vo.setCouponList(lifeCouponService.getCouponListAsDiscountVo(lifeCouponPlatformVo.getPageNum(), lifeCouponPlatformVo.getPageSize(), lifeCouponPlatformVo.getStoreId(),
                     lifeCouponPlatformVo.getStatus(), lifeCouponPlatformVo.getName()));
         } else {
             vo.setDiscountList(lifeDiscountCouponPlatformService.getStoreAllCouponList(lifeCouponPlatformVo.getStoreId(), userLoginInfo,
-                    lifeCouponPlatformVo.getPageNum(), lifeCouponPlatformVo.getPageSize(), lifeCouponPlatformVo.getName(), lifeCouponPlatformVo.getCouponsFromType(), lifeCouponPlatformVo.getCouponStatus()));
+                    lifeCouponPlatformVo.getPageNum(), lifeCouponPlatformVo.getPageSize(), lifeCouponPlatformVo.getName(), lifeCouponPlatformVo.getCouponsFromType(), lifeCouponPlatformVo.getCouponStatus(), lifeCouponPlatformVo.getDiscountCouponType()));
         }
 
         return R.data(vo);

+ 2 - 1
alien-store-platform/src/main/java/shop/alien/storeplatform/service/LifeDiscountCouponPlatformService.java

@@ -89,9 +89,10 @@ public interface LifeDiscountCouponPlatformService extends IService<LifeDiscount
      * @param couponName 优惠券名称(模糊查询)
      * @param couponsFromType 优惠券来源类型
      * @param couponStatus 优惠券状态(1:进行中, 2:已结束, 3:已暂停)
+     * @param discountCouponType 优惠券类型:1=满减券,2=折扣券,null=全部优惠券
      * @return IPage<LifeDiscountCouponVo> 分页优惠券列表
      */
-    IPage<LifeDiscountCouponVo> getStoreAllCouponList(String storeId, UserLoginInfo userLoginInfo, int page, int size, String couponName, Integer couponsFromType, Integer couponStatus);
+    IPage<LifeDiscountCouponVo> getStoreAllCouponList(String storeId, UserLoginInfo userLoginInfo, int page, int size, String couponName, Integer couponsFromType, Integer couponStatus, Integer discountCouponType);
 
 }
 

+ 5 - 1
alien-store-platform/src/main/java/shop/alien/storeplatform/service/impl/LifeDiscountCouponPlatformServiceImpl.java

@@ -446,7 +446,7 @@ public class LifeDiscountCouponPlatformServiceImpl extends ServiceImpl<LifeDisco
      * @return IPage<LifeDiscountCouponVo> 分页优惠券列表
      */
     @Override
-    public IPage<LifeDiscountCouponVo> getStoreAllCouponList(String storeId, UserLoginInfo userLoginInfo, int page, int size, String couponName, Integer couponsFromType, Integer couponStatus) {
+    public IPage<LifeDiscountCouponVo> getStoreAllCouponList(String storeId, UserLoginInfo userLoginInfo, int page, int size, String couponName, Integer couponsFromType, Integer couponStatus, Integer discountCouponType) {
 
         IPage<LifeDiscountCoupon> iPage = new Page<>(page, size);
         List<LifeDiscountCouponVo> lifeDiscountCouponVos = new ArrayList<>();
@@ -456,6 +456,10 @@ public class LifeDiscountCouponPlatformServiceImpl extends ServiceImpl<LifeDisco
         if (!StringUtils.isEmpty(couponName)) {
             lifeDiscountCouponLambdaQueryWrapper.like(LifeDiscountCoupon::getName, couponName);
         }
+        //如果指定了优惠券类型(满减券或折扣券),添加筛选条件
+        if (discountCouponType != null) {
+            lifeDiscountCouponLambdaQueryWrapper.eq(LifeDiscountCoupon::getCouponType, discountCouponType);
+        }
         //获取当日日期
         Date now = new Date();
         //如果根据类型查询

+ 7 - 1
alien-store-platform/src/main/java/shop/alien/storeplatform/service/impl/OperationalActivityServiceImpl.java

@@ -494,11 +494,17 @@ public class OperationalActivityServiceImpl implements OperationalActivityServic
             vo.setStatusName("已结束");
         }
 
-        // 设置优惠券名称(判空处理)
+        // 设置优惠券名称和类型(判空处理)
         if (activity.getCouponId() != null) {
             LifeDiscountCoupon coupon = lifeDiscountCouponMapper.selectById(activity.getCouponId());
             if (coupon != null) {
                 vo.setCouponName(coupon.getName());
+                // 设置优惠券类型(满减券/折扣券):1=满减券,2=折扣券
+                vo.setDiscountCouponType(coupon.getCouponType());
+                // 如果是折扣券,设置折扣率
+                if (coupon.getCouponType() != null && coupon.getCouponType() == 2) {
+                    vo.setDiscountRate(coupon.getDiscountRate());
+                }
             }
         }
 

+ 27 - 19
alien-store/src/main/java/shop/alien/store/controller/LifeDiscountCouponController.java

@@ -139,17 +139,19 @@ public class LifeDiscountCouponController {
         return lifeDiscountCouponUserService.receiveCoupon(lifeDiscountCouponUserDto);
     }
 
-    @ApiOperation("获取该用户该店铺优惠券列表")
+    @ApiOperation("获取该用户该店铺优惠券列表。couponType=1仅满减券,couponType=2仅折扣券,不传返回全部优惠券")
     @ApiOperationSupport(order = 7)
     @GetMapping("/getStoreUserCouponList")
     @ApiImplicitParams({
-            @ApiImplicitParam(name = "storeId", value = "商户id", dataType = "String", paramType = "query", required = true)
+            @ApiImplicitParam(name = "storeId", value = "商户id", dataType = "String", paramType = "query", required = true),
+            @ApiImplicitParam(name = "couponType", value = "优惠券类型:1=仅满减券,2=仅折扣券,不传=全部优惠券(可选)", dataType = "Integer", paramType = "query", required = false)
     })
     public R<List<LifeDiscountCouponVo>> getStoreUserCouponList(@ApiIgnore @TokenInfo UserLoginInfo userLoginInfo,
-                                                                @RequestParam(value = "storeId") String storeId) {
-        log.info("LifeDiscountCouponController.getStoreUserCouponList?storeId={}", storeId);
+                                                                @RequestParam(value = "storeId") String storeId,
+                                                                @RequestParam(value = "couponType", required = false) Integer couponType) {
+        log.info("LifeDiscountCouponController.getStoreUserCouponList?storeId={}, couponType={}", storeId, couponType);
         try {
-            List<LifeDiscountCouponVo> storeCouponList = lifeDiscountCouponService.getStoreUserCouponList(storeId, userLoginInfo);
+            List<LifeDiscountCouponVo> storeCouponList = lifeDiscountCouponService.getStoreUserCouponList(storeId, userLoginInfo, couponType);
             return R.data(storeCouponList);
         } catch (Exception e) {
             log.error("LifeDiscountCouponController.getStoreUserCouponList ERROR Msg={}", e.getMessage());
@@ -157,20 +159,22 @@ public class LifeDiscountCouponController {
         }
     }
 
-    @ApiOperation("获取该用户该店铺优惠券已领可用不可用列表")
+    @ApiOperation("获取该用户该店铺优惠券已领可用不可用列表。couponType=1仅满减券,couponType=2仅折扣券,不传返回全部优惠券")
     @ApiOperationSupport(order = 8)
     @GetMapping("/getStoreUserUsableCouponList")
     @ApiImplicitParams({
             @ApiImplicitParam(name = "storeId", value = "商户id", dataType = "String", paramType = "query", required = true),
-            @ApiImplicitParam(name = "amount", value = "消费金额", dataType = "String", paramType = "query", required = true)
+            @ApiImplicitParam(name = "amount", value = "消费金额", dataType = "String", paramType = "query", required = true),
+            @ApiImplicitParam(name = "couponType", value = "优惠券类型:1=仅满减券,2=仅折扣券,不传=全部优惠券(可选)", dataType = "Integer", paramType = "query", required = false)
     })
     public R<Map> getStoreUserUsableCouponList(@ApiIgnore @TokenInfo UserLoginInfo userLoginInfo,
                                                @RequestParam(value = "storeId") String storeId,
-                                               @RequestParam(value = "amount") BigDecimal amount
+                                               @RequestParam(value = "amount") BigDecimal amount,
+                                               @RequestParam(value = "couponType", required = false) Integer couponType
     ) {
-        log.info("LifeDiscountCouponController.getStoreUserUsableCouponList?storeId={}", storeId);
+        log.info("LifeDiscountCouponController.getStoreUserUsableCouponList?storeId={}, couponType={}", storeId, couponType);
         try {
-            return R.data(lifeDiscountCouponService.getStoreUserUsableCouponList(storeId, userLoginInfo, amount));
+            return R.data(lifeDiscountCouponService.getStoreUserUsableCouponList(storeId, userLoginInfo, amount, couponType));
         } catch (Exception e) {
             log.error("LifeDiscountCouponController.getStoreUserUsableCouponList ERROR Msg={}", e.getMessage());
             return R.fail("查询失败");
@@ -178,22 +182,24 @@ public class LifeDiscountCouponController {
     }
 
 
-    @ApiOperation("获取该用户所有的优惠券列表")
+    @ApiOperation("获取该用户所有的优惠券列表。couponType=1仅满减券,couponType=2仅折扣券,不传返回全部优惠券")
     @ApiOperationSupport(order = 9)
     @GetMapping("/getUserCouponList")
     @ApiImplicitParams({@ApiImplicitParam(name = "page", value = "分页页数", dataType = "String", paramType = "query", required = true),
             @ApiImplicitParam(name = "size", value = "分页条数", dataType = "String", paramType = "query", required = true),
             @ApiImplicitParam(name = "tabType", value = "分页类型(0:全部(未使用),1:即将过期,2:已使用,3:已过期)", dataType = "String", paramType = "query", required = true),
-            @ApiImplicitParam(name = "type", value = "券类型(不传:优惠券+代金券都返回,1:仅优惠券查 life_discount_coupon,4:仅代金券查 life_coupon)", dataType = "Integer", paramType = "query", required = false)
+            @ApiImplicitParam(name = "type", value = "券类型(不传:优惠券+代金券都返回,1:仅优惠券查 life_discount_coupon,4:仅代金券查 life_coupon)", dataType = "Integer", paramType = "query", required = false),
+            @ApiImplicitParam(name = "couponType", value = "优惠券类型:1=仅满减券,2=仅折扣券,不传=全部优惠券(可选,仅当type不为4时有效)", dataType = "Integer", paramType = "query", required = false)
     })
     public R<List<LifeDiscountCouponVo>> getUserCouponList(@ApiIgnore @TokenInfo UserLoginInfo userLoginInfo,
                                                            @RequestParam(value = "tabType") String tabType,
                                                            @RequestParam(defaultValue = "1") int page,
                                                            @RequestParam(defaultValue = "10") int size,
-                                                           @RequestParam(required = false) Integer type) {
-        log.info("LifeDiscountCouponController.getUserCouponList");
+                                                           @RequestParam(required = false) Integer type,
+                                                           @RequestParam(value = "couponType", required = false) Integer couponType) {
+        log.info("LifeDiscountCouponController.getUserCouponList?couponType={}", couponType);
         try {
-            List<LifeDiscountCouponVo> storeCouponList = lifeDiscountCouponService.getUserCouponList(userLoginInfo, page, size, tabType, type);
+            List<LifeDiscountCouponVo> storeCouponList = lifeDiscountCouponService.getUserCouponList(userLoginInfo, page, size, tabType, type, couponType);
             return R.data(storeCouponList);
         } catch (Exception e) {
             log.error("LifeDiscountCouponController.getUserCouponList ERROR Msg={}", e.getMessage());
@@ -201,7 +207,7 @@ public class LifeDiscountCouponController {
         }
     }
 
-    @ApiOperation("获取该店铺所有优惠券(分页), 好友优惠券")
+    @ApiOperation("获取该店铺所有优惠券(分页), 好友优惠券。couponType=1仅满减券,couponType=2仅折扣券,不传返回全部优惠券")
     @ApiOperationSupport(order = 10)
     @GetMapping("/getStoreAllCouponList")
     @ApiImplicitParams({@ApiImplicitParam(name = "page", value = "分页页数", dataType = "String", paramType = "query", required = true),
@@ -211,6 +217,7 @@ public class LifeDiscountCouponController {
             @ApiImplicitParam(name = "tab", value = "分页类型(0:全部(传其他也查全部),1:进行中,2:已结束)", dataType = "String", paramType = "query", required = true),
             @ApiImplicitParam(name = "couponsFromType", required = false, value = "查询类型(1:我的优惠券,2:好友的优惠券)"),
             @ApiImplicitParam(name = "couponStatus", required = false, value = "优惠券状态(0:草稿,1:正式)"),
+            @ApiImplicitParam(name = "couponType", value = "优惠券类型:1=仅满减券,2=仅折扣券,不传=全部优惠券(可选)", dataType = "Integer", paramType = "query", required = false),
     })
     public R<IPage<LifeDiscountCouponVo>> getStoreAllCouponList(@ApiIgnore @TokenInfo UserLoginInfo userLoginInfo,
                                                                 @RequestParam(defaultValue = "1") int page,
@@ -219,11 +226,12 @@ public class LifeDiscountCouponController {
                                                                 @RequestParam(value = "couponName", required = false) String couponName,
                                                                 @RequestParam(value = "tab") String tab,
                                                                 @RequestParam(value = "couponsFromType", defaultValue = "1") int couponsFromType,
-                                                                @RequestParam(value = "couponStatus", defaultValue = "1", required = false) int couponStatus
+                                                                @RequestParam(value = "couponStatus", defaultValue = "1", required = false) int couponStatus,
+                                                                @RequestParam(value = "couponType", required = false) Integer couponType
     ) {
-        log.info("LifeDiscountCouponController.getStoreAllCouponList?storeId={}, couponName={}, tab={}, page={}, size={}, couponStatus={}", storeId, couponName, tab, page, size, couponStatus);
+        log.info("LifeDiscountCouponController.getStoreAllCouponList?storeId={}, couponName={}, tab={}, page={}, size={}, couponStatus={}, couponType={}", storeId, couponName, tab, page, size, couponStatus, couponType);
         try {
-            IPage<LifeDiscountCouponVo> storeCouponList = lifeDiscountCouponService.getStoreAllCouponList(storeId, userLoginInfo, page, size, couponName, tab, couponsFromType, couponStatus);
+            IPage<LifeDiscountCouponVo> storeCouponList = lifeDiscountCouponService.getStoreAllCouponList(storeId, userLoginInfo, page, size, couponName, tab, couponsFromType, couponStatus, couponType);
             return R.data(storeCouponList);
         } catch (Exception e) {
             log.error("LifeDiscountCouponController.getStoreCouponList ERROR Msg={}", e.getMessage());

+ 10 - 8
alien-store/src/main/java/shop/alien/store/controller/LifeDiscountCouponStoreFriendController.java

@@ -160,18 +160,20 @@ public class LifeDiscountCouponStoreFriendController {
         return R.data(lifeDiscountCouponStoreFriendService.getRuleById(id));
     }
 
-    @ApiOperation("查询好友赠券。type=4 返回代金券,否则返回优惠券")
+    @ApiOperation("获取收到的好友优惠券列表。couponType=1仅满减券,couponType=2仅折扣券,不传返回全部优惠券。type=4 返回代金券,否则返回优惠券")
+    @GetMapping("/getReceivedFriendCouponList")
     @ApiImplicitParams({
-            @ApiImplicitParam(name = "storeId", value = "当前登录店铺id", dataType = "String", paramType = "query", required = true),
-            @ApiImplicitParam(name = "friendStoreUserId", value = "选中好友店铺用户id", dataType = "String", paramType = "query", required = false),
-            @ApiImplicitParam(name = "type", value = "4=代金券,其他=优惠券", dataType = "Integer", paramType = "query", required = false)
+            @ApiImplicitParam(name = "storeId", value = "店铺id", dataType = "String", paramType = "query", required = true),
+            @ApiImplicitParam(name = "friendStoreUserId", value = "好友店铺用户id", dataType = "String", paramType = "query", required = false),
+            @ApiImplicitParam(name = "type", value = "类型:4=仅代金券,不传=全部(优惠券+代金券)(可选)", dataType = "Integer", paramType = "query", required = false),
+            @ApiImplicitParam(name = "couponType", value = "优惠券类型:1=仅满减券,2=仅折扣券,不传=全部优惠券(可选,仅当type不为4时有效)", dataType = "Integer", paramType = "query", required = false)
     })
-    @GetMapping("/getReceivedFriendCouponList")
     public R<List<LifeDiscountCouponFriendRuleDetailVo>> getReceivedFriendCouponList(@RequestParam(value = "storeId") String storeId,
                                                                                      @RequestParam(value = "friendStoreUserId", required = false) String friendStoreUserId,
-                                                                                     @RequestParam(value = "type", required = false) Integer type) {
-        log.info("LifeDiscountCouponStoreFriendController.getReceivedFriendCouponList?storeId={},friendStoreUserId={},type={}", storeId, friendStoreUserId, type);
-        return R.data(lifeDiscountCouponStoreFriendService.getReceivedFriendCouponList(storeId, friendStoreUserId, type));
+                                                                                     @RequestParam(value = "type", required = false) Integer type,
+                                                                                     @RequestParam(value = "couponType", required = false) Integer couponType) {
+        log.info("LifeDiscountCouponStoreFriendController.getReceivedFriendCouponList?storeId={},friendStoreUserId={},type={},couponType={}", storeId, friendStoreUserId, type, couponType);
+        return R.data(lifeDiscountCouponStoreFriendService.getReceivedFriendCouponList(storeId, friendStoreUserId, type, couponType));
     }
 
     @ApiOperation("查询赠券规则")

+ 8 - 5
alien-store/src/main/java/shop/alien/store/service/LifeDiscountCouponService.java

@@ -53,24 +53,27 @@ public interface LifeDiscountCouponService extends IService<LifeDiscountCoupon>
 
     /**
      * 获取该用户该店铺优惠券列表
+     * @param couponType 优惠券类型:1=满减券,2=折扣券,null=全部优惠券
      */
-    List<LifeDiscountCouponVo> getStoreUserCouponList(String storeId, UserLoginInfo userLoginInfo);
+    List<LifeDiscountCouponVo> getStoreUserCouponList(String storeId, UserLoginInfo userLoginInfo, Integer couponType);
 
     /**
-     * 获取该用户该店铺优惠券列表
+     * 获取该用户该店铺优惠券已领可用不可用列表
+     * @param couponType 优惠券类型:1=满减券,2=折扣券,null=全部优惠券
      */
-    Map getStoreUserUsableCouponList(String storeId, UserLoginInfo userLoginInfo, BigDecimal amount);
+    Map getStoreUserUsableCouponList(String storeId, UserLoginInfo userLoginInfo, BigDecimal amount, Integer couponType);
 
     /**
      * 获取该用户优惠券列表
      * @param type 不传:优惠券+代金券都返回;1:仅优惠券(查 life_discount_coupon);4:仅代金券(查 life_coupon)
+     * @param couponType 优惠券类型:1=满减券,2=折扣券,null=全部优惠券(仅当type不为4时有效)
      */
-    List<LifeDiscountCouponVo> getUserCouponList(UserLoginInfo userLoginInfo, int page, int size, String tabType, Integer type);
+    List<LifeDiscountCouponVo> getUserCouponList(UserLoginInfo userLoginInfo, int page, int size, String tabType, Integer type, Integer couponType);
 
     /**
      * 获取所有优惠券列表(分页)
      */
-    IPage<LifeDiscountCouponVo> getStoreAllCouponList(String storeId, UserLoginInfo userLoginInfo, int page, int size, String couponName, String tab, int couponsFromType, int couponStatus);
+    IPage<LifeDiscountCouponVo> getStoreAllCouponList(String storeId, UserLoginInfo userLoginInfo, int page, int size, String couponName, String tab, int couponsFromType, int couponStatus, Integer couponType);
 
     /**
      * 获取所有优惠券列表(不分页)

+ 5 - 1
alien-store/src/main/java/shop/alien/store/service/LifeDiscountCouponStoreFriendService.java

@@ -56,7 +56,11 @@ public interface LifeDiscountCouponStoreFriendService extends IService<LifeDisco
     /**
      * 查询收到的赠券列表。type=4 返回代金券(life_coupon),否则返回优惠券(life_discount_coupon)
      */
-    List<LifeDiscountCouponFriendRuleDetailVo> getReceivedFriendCouponList(String storeId, String friendStoreUserId, Integer type);
+    /**
+     * 获取收到的好友优惠券列表
+     * @param couponType 优惠券类型:1=满减券,2=折扣券,null=全部优惠券(仅当type不为4时有效)
+     */
+    List<LifeDiscountCouponFriendRuleDetailVo> getReceivedFriendCouponList(String storeId, String friendStoreUserId, Integer type, Integer couponType);
 
     List<LifeDiscountCouponFriendRuleVo> getRuleList(String storeId, String acName, String status);
 

+ 38 - 12
alien-store/src/main/java/shop/alien/store/service/impl/LifeDiscountCouponServiceImpl.java

@@ -398,26 +398,31 @@ public class LifeDiscountCouponServiceImpl extends ServiceImpl<LifeDiscountCoupo
     }
 
     @Override
-    public List<LifeDiscountCouponVo> getStoreUserCouponList(String storeId, UserLoginInfo userLoginInfo) {
+    public List<LifeDiscountCouponVo> getStoreUserCouponList(String storeId, UserLoginInfo userLoginInfo, Integer couponType) {
         List<LifeDiscountCouponVo> lifeDiscountCouponVos = new ArrayList<>();
         try {
             LocalDateTime now = LocalDateTime.now();
             //根据店铺id查询该店铺的优惠券,状态是开启领取的券
-            List<LifeDiscountCoupon> lifeDiscountCoupons = lifeDiscountCouponMapper.selectList(new LambdaQueryWrapper<LifeDiscountCoupon>()
+            LambdaQueryWrapper<LifeDiscountCoupon> queryWrapper = new LambdaQueryWrapper<LifeDiscountCoupon>()
                     .eq(LifeDiscountCoupon::getStoreId, storeId).eq(LifeDiscountCoupon::getGetStatus, "1") //还有库存
                     .ge(LifeDiscountCoupon::getEndGetDate, LocalDate.now())
-                    .orderByDesc(LifeDiscountCoupon::getAttentionCanReceived));
+                    .orderByDesc(LifeDiscountCoupon::getAttentionCanReceived);
+            //如果指定了优惠券类型(满减券或折扣券),添加筛选条件
+            if (couponType != null) {
+                queryWrapper.eq(LifeDiscountCoupon::getCouponType, couponType);
+            }
+            List<LifeDiscountCoupon> lifeDiscountCoupons = lifeDiscountCouponMapper.selectList(queryWrapper);
             //根据优惠券列表查询该优惠券是否领取过
             for (LifeDiscountCoupon lifeDiscountCoupon : lifeDiscountCoupons) {
                 LifeDiscountCouponVo lifeDiscountCouponVo = new LifeDiscountCouponVo();
                 lifeDiscountCouponVo.setCouponId(lifeDiscountCoupon.getId());
                 BeanUtils.copyProperties(lifeDiscountCoupon, lifeDiscountCouponVo);
                 //查询该人员该卡券是否达到限领数量
-                LambdaQueryWrapper<LifeDiscountCouponUser> queryWrapper = new LambdaQueryWrapper<>();
-                queryWrapper.eq(LifeDiscountCouponUser::getCouponId, lifeDiscountCoupon.getId());
-                queryWrapper.eq(LifeDiscountCouponUser::getUserId, userLoginInfo.getUserId());
-                queryWrapper.orderByDesc(LifeDiscountCouponUser::getReceiveTime);
-                List<LifeDiscountCouponUser> lifeDiscountCouponUsers = lifeDiscountCouponUserMapper.selectList(queryWrapper);
+                LambdaQueryWrapper<LifeDiscountCouponUser> userQueryWrapper = new LambdaQueryWrapper<>();
+                userQueryWrapper.eq(LifeDiscountCouponUser::getCouponId, lifeDiscountCoupon.getId());
+                userQueryWrapper.eq(LifeDiscountCouponUser::getUserId, userLoginInfo.getUserId());
+                userQueryWrapper.orderByDesc(LifeDiscountCouponUser::getReceiveTime);
+                List<LifeDiscountCouponUser> lifeDiscountCouponUsers = lifeDiscountCouponUserMapper.selectList(userQueryWrapper);
                 String specifiedDay = lifeDiscountCoupon.getSpecifiedDay();
                 Date receiveDay = null;
 
@@ -482,7 +487,7 @@ public class LifeDiscountCouponServiceImpl extends ServiceImpl<LifeDiscountCoupo
     }
 
     @Override
-    public Map getStoreUserUsableCouponList(String storeId, UserLoginInfo userLoginInfo, BigDecimal amount) {
+    public Map getStoreUserUsableCouponList(String storeId, UserLoginInfo userLoginInfo, BigDecimal amount, Integer couponType) {
         HashMap<String, List> result = new HashMap<>();
         List<LifeDiscountCouponVo> canUseLifeDiscountCouponVos = new ArrayList<>();
         List<LifeDiscountCouponVo> forbidUseLifeDiscountCouponVos = new ArrayList<>();
@@ -516,6 +521,13 @@ public class LifeDiscountCouponServiceImpl extends ServiceImpl<LifeDiscountCoupo
         for (LifeDiscountCouponUser lifeDiscountCouponUser : lifeDiscountCouponUserList) {
             //查询该优惠券属于哪个店铺
             LifeDiscountCoupon lifeDiscountCoupon = lifeDiscountCouponMapper.selectById(lifeDiscountCouponUser.getCouponId());
+            if (lifeDiscountCoupon == null) {
+                continue;
+            }
+            //如果指定了优惠券类型,进行筛选
+            if (couponType != null && !couponType.equals(lifeDiscountCoupon.getCouponType())) {
+                continue;
+            }
             String couponStoreId = lifeDiscountCoupon.getStoreId();
             if (null != couponStoreId && couponStoreId.equals(storeId)) {
                 lifeDiscountCouponUsers.add(lifeDiscountCouponUser);
@@ -648,7 +660,7 @@ public class LifeDiscountCouponServiceImpl extends ServiceImpl<LifeDiscountCoupo
     }
 
     @Override
-    public List<LifeDiscountCouponVo> getUserCouponList(UserLoginInfo userLoginInfo, int page, int size, String tabType, Integer type) {
+    public List<LifeDiscountCouponVo> getUserCouponList(UserLoginInfo userLoginInfo, int page, int size, String tabType, Integer type, Integer couponType) {
         List<LifeDiscountCouponVo> lifeDiscountCouponVos = new ArrayList<>();
         IPage<LifeDiscountCouponUser> iPage = new Page<>(page, size);
         LambdaQueryWrapper<LifeDiscountCouponUser> queryWrapper = new LambdaQueryWrapper<>();
@@ -774,7 +786,13 @@ public class LifeDiscountCouponServiceImpl extends ServiceImpl<LifeDiscountCoupo
 
         // type=1 或 type=null:优惠券(或混合),查 life_discount_coupon
         List<Integer> couponIdList = records.stream().map(LifeDiscountCouponUser::getCouponId).filter(Objects::nonNull).collect(Collectors.toList());
-        List<LifeDiscountCoupon> lifeDiscountCoupons = lifeDiscountCouponMapper.selectList(new QueryWrapper<LifeDiscountCoupon>().lambda().in(!couponIdList.isEmpty(), LifeDiscountCoupon::getId, couponIdList));
+        LambdaQueryWrapper<LifeDiscountCoupon> couponQueryWrapper = new LambdaQueryWrapper<LifeDiscountCoupon>()
+                .in(!couponIdList.isEmpty(), LifeDiscountCoupon::getId, couponIdList);
+        //如果指定了优惠券类型(满减券或折扣券),添加筛选条件
+        if (couponType != null) {
+            couponQueryWrapper.eq(LifeDiscountCoupon::getCouponType, couponType);
+        }
+        List<LifeDiscountCoupon> lifeDiscountCoupons = lifeDiscountCouponMapper.selectList(couponQueryWrapper);
         if (type != null && type == 1 && lifeDiscountCoupons.isEmpty()) {
             return lifeDiscountCouponVos;
         }
@@ -875,7 +893,7 @@ public class LifeDiscountCouponServiceImpl extends ServiceImpl<LifeDiscountCoupo
     }
 
     @Override
-    public IPage<LifeDiscountCouponVo> getStoreAllCouponList(String storeId, UserLoginInfo userLoginInfo, int page, int size, String couponName, String tab, int couponsFromType, int couponStatus) {
+    public IPage<LifeDiscountCouponVo> getStoreAllCouponList(String storeId, UserLoginInfo userLoginInfo, int page, int size, String couponName, String tab, int couponsFromType, int couponStatus, Integer couponType) {
 
         if (couponsFromType == 1) {
             IPage<LifeDiscountCoupon> iPage = new Page<>(page, size);
@@ -886,6 +904,10 @@ public class LifeDiscountCouponServiceImpl extends ServiceImpl<LifeDiscountCoupo
             if (!StringUtils.isEmpty(couponName)) {
                 lifeDiscountCouponLambdaQueryWrapper.like(LifeDiscountCoupon::getName, couponName);
             }
+            //如果指定了优惠券类型(满减券或折扣券),添加筛选条件
+            if (couponType != null) {
+                lifeDiscountCouponLambdaQueryWrapper.eq(LifeDiscountCoupon::getCouponType, couponType);
+            }
             //获取当日日期
             Date now = new Date();
             //如果根据类型查询
@@ -969,6 +991,10 @@ public class LifeDiscountCouponServiceImpl extends ServiceImpl<LifeDiscountCoupo
             if (!StringUtils.isEmpty(couponName)) {
                 friendLifeDiscountCouponQueryWrapper.like("ldc.name", couponName);
             }
+            //如果指定了优惠券类型(满减券或折扣券),添加筛选条件
+            if (couponType != null) {
+                friendLifeDiscountCouponQueryWrapper.eq("ldc.coupon_type", couponType);
+            }
             //获取当日日期
             Date now = new Date();
             //如果根据类型查询

+ 5 - 1
alien-store/src/main/java/shop/alien/store/service/impl/LifeDiscountCouponStoreFriendServiceImpl.java

@@ -536,7 +536,7 @@ public class LifeDiscountCouponStoreFriendServiceImpl extends ServiceImpl<LifeDi
      * @return 领取的优惠券列表
      */
     @Override
-    public List<LifeDiscountCouponFriendRuleDetailVo> getReceivedFriendCouponList(String storeId, String friendStoreUserId, Integer type) {
+    public List<LifeDiscountCouponFriendRuleDetailVo> getReceivedFriendCouponList(String storeId, String friendStoreUserId, Integer type, Integer couponType) {
         QueryWrapper<LifeDiscountCouponFriendRuleDetailVo> queryWrapper = new QueryWrapper<>();
         queryWrapper.eq("ldcsf.store_user_id", storeId);
         queryWrapper.eq("ldcsf.delete_flag", 0);
@@ -554,6 +554,10 @@ public class LifeDiscountCouponStoreFriendServiceImpl extends ServiceImpl<LifeDi
         // 优惠券:保持原逻辑,只查 release_type=1
         queryWrapper.eq("ldcsf.release_type", 1);
         queryWrapper.isNotNull("ldcsf.coupon_id");
+        //如果指定了优惠券类型(满减券或折扣券),添加筛选条件
+        if (couponType != null) {
+            queryWrapper.eq("ldc.coupon_type", couponType);
+        }
         if (StringUtils.isEmpty(friendStoreUserId)) {
             queryWrapper.groupBy("ldcsf.friend_store_user_id").orderByDesc("couponNum");
         } else {

+ 51 - 8
alien-store/src/main/java/shop/alien/store/service/impl/StoreCustomerServiceServiceImpl.java

@@ -5,16 +5,17 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
 import com.baomidou.mybatisplus.core.toolkit.StringUtils;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import lombok.RequiredArgsConstructor;
+import org.springframework.stereotype.Service;
 import shop.alien.entity.store.AiIntelligentAssistant;
 import shop.alien.entity.store.StoreCustomerService;
 import shop.alien.mapper.AiIntelligentAssistantMapper;
 import shop.alien.mapper.StoreCustomerServiceMapper;
 import shop.alien.store.service.StoreCustomerServiceService;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import org.springframework.stereotype.Service;
 
-import java.util.ArrayList;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
 import java.util.Date;
 import java.util.List;
 
@@ -99,21 +100,63 @@ public class StoreCustomerServiceServiceImpl extends ServiceImpl<StoreCustomerSe
 
     @Override
     public List<AiIntelligentAssistant> selectAiIntelligentAssistant(String userId,String time,Integer talkSource) {
+        // 参数校验
+        if (StringUtils.isEmpty(userId) || StringUtils.isEmpty(time) || talkSource == null) {
+            return new java.util.ArrayList<>();
+        }
+        
+        // 解析time字符串为Date类型
+        Date queryTime;
+        try {
+            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+            queryTime = sdf.parse(time);
+        } catch (Exception e) {
+            // 如果解析失败,使用当前时间
+            queryTime = new Date();
+        }
+        
+        // 计算7天前的时间
+        Date now = new Date();
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(now);
+        calendar.add(Calendar.DAY_OF_YEAR, -7);
+        Date sevenDaysAgo = calendar.getTime();
+        
+        // 查找最后一个type=0的记录作为分页标记点(限制在7天内)
         LambdaQueryWrapper<AiIntelligentAssistant> last = new LambdaQueryWrapper<AiIntelligentAssistant>()
-                .lt(AiIntelligentAssistant::getCreatedTime, time)
+                .lt(AiIntelligentAssistant::getCreatedTime, queryTime)
+                .ge(AiIntelligentAssistant::getCreatedTime, sevenDaysAgo) // 只查询7天内的记录
                 .eq(AiIntelligentAssistant::getDeleteFlag, 0)
-                .eq(AiIntelligentAssistant::getType, 0).eq(AiIntelligentAssistant::getTalkSource, talkSource).eq(AiIntelligentAssistant::getUserId, userId).orderByDesc(AiIntelligentAssistant::getCreatedTime).last("limit 1");
+                .eq(AiIntelligentAssistant::getType, 0)
+                .eq(AiIntelligentAssistant::getTalkSource, talkSource)
+                .eq(AiIntelligentAssistant::getUserId, userId)
+                .orderByDesc(AiIntelligentAssistant::getCreatedTime)
+                .last("limit 1");
         AiIntelligentAssistant aiIntelligentAssistant = aiIntelligentAssistantMapper.selectOne(last);
+        
         if (ObjectUtils.isNotEmpty(aiIntelligentAssistant)) {
+            // 找到了标记点,从标记点开始查询到time之间的记录
+            // 由于标记点查询已经限制了7天内,所以标记点时间一定不早于7天前
+            Date markPointTime = aiIntelligentAssistant.getCreatedTime();
+            
+            LambdaQueryWrapper<AiIntelligentAssistant> queryWrapper = new LambdaQueryWrapper<AiIntelligentAssistant>()
+                    .ge(AiIntelligentAssistant::getCreatedTime, markPointTime)
+                    .lt(AiIntelligentAssistant::getCreatedTime, queryTime)
+                    .eq(AiIntelligentAssistant::getDeleteFlag, 0)
+                    .eq(AiIntelligentAssistant::getUserId, userId)
+                    .eq(AiIntelligentAssistant::getTalkSource, talkSource)
+                    .orderByAsc(AiIntelligentAssistant::getCreatedTime);
+            return aiIntelligentAssistantMapper.selectList(queryWrapper);
+        } else {
+            // 如果找不到type=0的标记点,直接查询7天内的所有记录(支持首次加载)
             LambdaQueryWrapper<AiIntelligentAssistant> queryWrapper = new LambdaQueryWrapper<AiIntelligentAssistant>()
-                    .ge(AiIntelligentAssistant::getCreatedTime, aiIntelligentAssistant.getCreatedTime())
-                    .lt(AiIntelligentAssistant::getCreatedTime, time)
+                    .ge(AiIntelligentAssistant::getCreatedTime, sevenDaysAgo)
+                    .lt(AiIntelligentAssistant::getCreatedTime, queryTime)
                     .eq(AiIntelligentAssistant::getDeleteFlag, 0)
                     .eq(AiIntelligentAssistant::getUserId, userId)
                     .eq(AiIntelligentAssistant::getTalkSource, talkSource)
                     .orderByAsc(AiIntelligentAssistant::getCreatedTime);
             return aiIntelligentAssistantMapper.selectList(queryWrapper);
         }
-        return new ArrayList<>();
     }
 }