Просмотр исходного кода

Merge branch 'sit' of http://8.152.195.41:3000/alien/alien_cloud into sit

dujian 1 месяц назад
Родитель
Сommit
b060a48871
53 измененных файлов с 1755 добавлено и 663 удалено
  1. 8 0
      alien-entity/src/main/java/shop/alien/entity/store/LifeDiscountCoupon.java
  2. 7 0
      alien-entity/src/main/java/shop/alien/entity/store/LifeDiscountCouponFriendRule.java
  3. 4 0
      alien-entity/src/main/java/shop/alien/entity/store/LifeUserDynamics.java
  4. 6 0
      alien-entity/src/main/java/shop/alien/entity/store/dto/LifeDiscountCouponDto.java
  5. 3 0
      alien-entity/src/main/java/shop/alien/entity/store/vo/LifeDiscountCouponFriendRuleDetailVo.java
  6. 6 0
      alien-entity/src/main/java/shop/alien/entity/store/vo/LifeDiscountCouponFriendRuleVo.java
  7. 6 0
      alien-entity/src/main/java/shop/alien/entity/store/vo/LifeDiscountCouponVo.java
  8. 3 0
      alien-entity/src/main/java/shop/alien/entity/store/vo/SubAccountVo.java
  9. 1 0
      alien-entity/src/main/java/shop/alien/entity/storePlatform/vo/LifeCouponPlatformVo.java
  10. 6 0
      alien-entity/src/main/java/shop/alien/entity/storePlatform/vo/StoreOperationalActivityVO.java
  11. 23 0
      alien-entity/src/main/java/shop/alien/mapper/CommonCommentMapper.java
  12. 8 1
      alien-entity/src/main/java/shop/alien/mapper/LifeBrowseRecordMapper.java
  13. 5 3
      alien-entity/src/main/java/shop/alien/mapper/LifeDiscountCouponFriendRuleDetailMapper.java
  14. 2 1
      alien-entity/src/main/java/shop/alien/mapper/LifeDiscountCouponMapper.java
  15. 6 2
      alien-entity/src/main/java/shop/alien/mapper/LifeDiscountCouponStoreFriendMapper.java
  16. 1 1
      alien-entity/src/main/java/shop/alien/mapper/LifeUserDynamicsMapper.java
  17. 5 0
      alien-entity/src/main/java/shop/alien/mapper/StoreContractMapper.java
  18. 1 1
      alien-entity/src/main/java/shop/alien/mapper/StoreImgMapper.java
  19. 6 5
      alien-entity/src/main/java/shop/alien/mapper/second/SecondGoodsMapper.java
  20. 2 1
      alien-entity/src/main/resources/mapper/LifeDiscountCouponFriendRuleMapper.xml
  21. 3 0
      alien-entity/src/main/resources/mapper/LifeDiscountCouponMapper.xml
  22. 9 0
      alien-entity/src/main/resources/mapper/StoreContractMapper.xml
  23. 1 0
      alien-entity/src/main/resources/mapper/StorePlatformUserRoleMapper.xml
  24. 125 54
      alien-job/src/main/java/shop/alien/job/store/StoreMembershipCardJob.java
  25. 26 0
      alien-lawyer/src/main/java/shop/alien/lawyer/config/NacosConfig.java
  26. 14 0
      alien-lawyer/src/main/java/shop/alien/lawyer/util/AliSms.java
  27. 2 2
      alien-second/src/main/java/shop/alien/second/service/impl/SecondGoodsServiceImpl.java
  28. 4 3
      alien-store-platform/src/main/java/shop/alien/storeplatform/controller/LifeCouponPlatformController.java
  29. 38 0
      alien-store-platform/src/main/java/shop/alien/storeplatform/controller/StorePlatformUserRoleController.java
  30. 3 0
      alien-store-platform/src/main/java/shop/alien/storeplatform/dto/UpdateAccountDto.java
  31. 2 1
      alien-store-platform/src/main/java/shop/alien/storeplatform/service/LifeDiscountCouponPlatformService.java
  32. 2 0
      alien-store-platform/src/main/java/shop/alien/storeplatform/service/StorePlatformUserRoleService.java
  33. 9 1
      alien-store-platform/src/main/java/shop/alien/storeplatform/service/impl/LifeDiscountCouponPlatformServiceImpl.java
  34. 8 5
      alien-store-platform/src/main/java/shop/alien/storeplatform/service/impl/MerchantAuthServiceImpl.java
  35. 7 1
      alien-store-platform/src/main/java/shop/alien/storeplatform/service/impl/OperationalActivityServiceImpl.java
  36. 10 9
      alien-store-platform/src/main/java/shop/alien/storeplatform/service/impl/StoreContractServiceImpl.java
  37. 18 0
      alien-store-platform/src/main/java/shop/alien/storeplatform/service/impl/StorePlatformUserRoleServiceImpl.java
  38. 61 14
      alien-store/src/main/java/shop/alien/store/aspect/AiAuditAspect.java
  39. 100 35
      alien-store/src/main/java/shop/alien/store/controller/LifeDiscountCouponController.java
  40. 35 17
      alien-store/src/main/java/shop/alien/store/controller/LifeDiscountCouponStoreFriendController.java
  41. 2 2
      alien-store/src/main/java/shop/alien/store/controller/StoreCuisineController.java
  42. 111 26
      alien-store/src/main/java/shop/alien/store/controller/StoreCustomerServiceController.java
  43. 2 2
      alien-store/src/main/java/shop/alien/store/controller/StorePriceController.java
  44. 9 6
      alien-store/src/main/java/shop/alien/store/service/LifeDiscountCouponService.java
  45. 7 2
      alien-store/src/main/java/shop/alien/store/service/LifeDiscountCouponStoreFriendService.java
  46. 75 46
      alien-store/src/main/java/shop/alien/store/service/LifeUserDynamicsService.java
  47. 36 2
      alien-store/src/main/java/shop/alien/store/service/LifeUserOrderService.java
  48. 568 247
      alien-store/src/main/java/shop/alien/store/service/impl/LifeDiscountCouponServiceImpl.java
  49. 97 10
      alien-store/src/main/java/shop/alien/store/service/impl/LifeDiscountCouponStoreFriendServiceImpl.java
  50. 110 84
      alien-store/src/main/java/shop/alien/store/service/impl/StoreClockInServiceImpl.java
  51. 99 15
      alien-store/src/main/java/shop/alien/store/service/impl/StoreCustomerServiceServiceImpl.java
  52. 52 63
      alien-store/src/main/java/shop/alien/store/service/impl/StoreInfoServiceImpl.java
  53. 1 1
      alien-store/src/main/java/shop/alien/store/service/impl/StoreOfficialAlbumServiceImpl.java

+ 8 - 0
alien-entity/src/main/java/shop/alien/entity/store/LifeDiscountCoupon.java

@@ -146,6 +146,14 @@ public class LifeDiscountCoupon extends Model<LifeDiscountCoupon> {
     @TableField("valid_date")
     private LocalDate validDate;
 
+    @ApiModelProperty(value = "优惠券类型:1-满减券,2-折扣券")
+    @TableField("coupon_type")
+    private Integer couponType;
+
+    @ApiModelProperty(value = "折扣率(0-100,用于折扣券,例如80表示8折)")
+    @TableField("discount_rate")
+    private BigDecimal discountRate;
+
     @Override
     protected Serializable pkVal() {
         return this.id;

+ 7 - 0
alien-entity/src/main/java/shop/alien/entity/store/LifeDiscountCouponFriendRule.java

@@ -59,6 +59,13 @@ public class LifeDiscountCouponFriendRule {
     @TableLogic
     private Integer deleteFlag;
 
+    /**
+     * 优惠券类型:1-满减券,2-折扣券(仅优惠券有值,代金券为null)
+     */
+    @ApiModelProperty(value = "优惠券类型:1-满减券,2-折扣券(仅优惠券有值,代金券为null)")
+    @TableField("coupon_type")
+    private Integer couponType;
+
     @TableField(exist = false)
     private List<LifeDiscountCouponFriendRuleDetail> details;
 }

+ 4 - 0
alien-entity/src/main/java/shop/alien/entity/store/LifeUserDynamics.java

@@ -141,4 +141,8 @@ public class LifeUserDynamics {
     @ApiModelProperty(value = "审核失败原因")
     @TableField("reason")
     private String reason;
+
+    @ApiModelProperty(value = "封面图")
+    @TableField("cover_image")
+    private String coverImage;
 }

+ 6 - 0
alien-entity/src/main/java/shop/alien/entity/store/dto/LifeDiscountCouponDto.java

@@ -113,4 +113,10 @@ public class LifeDiscountCouponDto {
 
     @ApiModelProperty(value = "优惠券状态:0:草稿,1:正式")
     private Integer couponStatus;
+
+    @ApiModelProperty(value = "优惠券类型:1-满减券,2-折扣券")
+    private Integer couponType;
+
+    @ApiModelProperty(value = "折扣率(0-100,用于折扣券,例如80表示8折)")
+    private BigDecimal discountRate;
 }

+ 3 - 0
alien-entity/src/main/java/shop/alien/entity/store/vo/LifeDiscountCouponFriendRuleDetailVo.java

@@ -25,4 +25,7 @@ public class LifeDiscountCouponFriendRuleDetailVo extends LifeDiscountCouponFrie
 
     /** 代金券id(type=4 时返回,对应 life_coupon.id) */
     private String voucherId;
+
+    /** 优惠券类型:1-满减券,2-折扣券(仅优惠券有值,代金券为null) */
+    private Integer couponType;
 }

+ 6 - 0
alien-entity/src/main/java/shop/alien/entity/store/vo/LifeDiscountCouponFriendRuleVo.java

@@ -58,5 +58,11 @@ public class LifeDiscountCouponFriendRuleVo extends LifeDiscountCouponFriendRule
     @ApiModelProperty(value = "有效期(优惠券/代金券的结束日期)")
     private Date validDate;
 
+    @ApiModelProperty(value = "优惠券类型:1-满减券,2-折扣券(仅优惠券有值,代金券为null)")
+    private Integer couponType;
+
+    @ApiModelProperty(value = "折扣率(0-100,用于折扣券,例如80表示8折,仅折扣券有值)")
+    private BigDecimal discountRate;
+
     private List<LifeDiscountCouponFriendRuleDetailVo> lifeDiscountCouponFriendRuleDetailVos;
 }

+ 6 - 0
alien-entity/src/main/java/shop/alien/entity/store/vo/LifeDiscountCouponVo.java

@@ -168,6 +168,12 @@ public class LifeDiscountCouponVo {
     @ApiModelProperty(value = "到期日期")
     private LocalDate expirationTime;
 
+    @ApiModelProperty(value = "优惠券类型:1-满减券,2-折扣券")
+    private Integer couponType;
+
+    @ApiModelProperty(value = "折扣率(0-100,用于折扣券,例如80表示8折)")
+    private BigDecimal discountRate;
+
     @ApiModelProperty(value = "创建时间")
     @TableField(value = "created_time")
     @JsonFormat(pattern = "yyyy/MM/dd", timezone = "GMT+8")

+ 3 - 0
alien-entity/src/main/java/shop/alien/entity/store/vo/SubAccountVo.java

@@ -16,6 +16,9 @@ import lombok.Data;
 @ApiModel(value = "SubAccountVo对象", description = "子账号信息VO")
 public class SubAccountVo {
 
+    @ApiModelProperty(value = "中间表id(子账号id)")
+    private Integer id;
+
     @ApiModelProperty(value = "用户ID")
     private Integer userId;
 

+ 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;
 }
 

+ 23 - 0
alien-entity/src/main/java/shop/alien/mapper/CommonCommentMapper.java

@@ -59,6 +59,29 @@ public interface CommonCommentMapper extends BaseMapper<CommonComment> {
     List<CommonCommentVo> getCommentCount(Integer type);
 
     /**
+     * 批量查询评论数量(按sourceId分组统计)
+     * 
+     * @param sourceType 来源类型
+     * @param sourceIds 来源ID列表
+     * @return sourceId -> commentCount 的映射列表
+     */
+    @Select("<script>" +
+            "SELECT cc.source_id AS sourceId, COUNT(*) AS commentCount " +
+            "FROM common_comment cc " +
+            "WHERE cc.source_type = #{sourceType} " +
+            "AND cc.delete_flag = 0 " +
+            "<if test='sourceIds != null and sourceIds.size() > 0'>" +
+            "AND cc.source_id IN " +
+            "<foreach collection='sourceIds' item='id' open='(' separator=',' close=')'>" +
+            "#{id}" +
+            "</foreach>" +
+            "</if>" +
+            "GROUP BY cc.source_id" +
+            "</script>")
+    List<CommonCommentVo> batchGetCommentCount(@Param("sourceType") Integer sourceType, 
+                                                @Param("sourceIds") List<Integer> sourceIds);
+
+    /**
      * 批量逻辑删除评论(使用原生 SQL 绕过 @TableLogic 注解限制)
      *
      * @param sourceType 来源类型

+ 8 - 1
alien-entity/src/main/java/shop/alien/mapper/LifeBrowseRecordMapper.java

@@ -30,7 +30,14 @@ public interface LifeBrowseRecordMapper extends BaseMapper<LifeBrowseRecord> {
             "Order by lbr.liulan_time desc")
     List<Map<String, Object>> getGroupBuyBrowseRecordByUserId(String userId);
 
-    @Select("select lbr.id,lud.*,lud.id dynamicsId,lbr.liulan_date liulanDate\n" +
+    @Select("select lbr.id, lud.id dynamicsId, IFNULL(lud.cover_image, '') coverImage, lbr.liulan_date liulanDate, " +
+            "lud.phone_id phoneId, lud.title, lud.context, lud.image_path imagePath, lud.address, " +
+            "lud.address_context addressContext, lud.address_name addressName, lud.liulan_count liulanCount, " +
+            "lud.dianzan_count dianzanCount, lud.type, lud.draft, lud.created_time createdTime, lud.updated_time updatedTime, " +
+            "lud.address_province addressProvince, lud.top_status topStatus, lud.top_time topTime, " +
+            "lud.enable_status enableStatus, lud.expert_id expertId, lud.business_id businessId, " +
+            "lud.transfer_count transferCount, lud.reality_count realityCount, lud.check_flag checkFlag, " +
+            "lud.ai_task_id aiTaskId, lud.reason, lud.delete_flag deleteFlag\n" +
             "from life_browse_record lbr \n" +
             "inner join life_user_dynamics lud on lud.id = lbr.dynamics_id \n" +
             "and lud.delete_flag = 0 and lbr.delete_flag = 0 \n" +

+ 5 - 3
alien-entity/src/main/java/shop/alien/mapper/LifeDiscountCouponFriendRuleDetailMapper.java

@@ -8,7 +8,6 @@ import shop.alien.entity.store.LifeDiscountCouponFriendRuleDetail;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import shop.alien.entity.store.vo.LifeDiscountCouponFriendRuleDetailVo;
 import shop.alien.entity.store.vo.LifeDiscountCouponFriendRuleVo;
-import shop.alien.entity.store.vo.LifeGroupBuyThaliVo;
 
 import java.util.List;
 
@@ -22,7 +21,7 @@ public interface LifeDiscountCouponFriendRuleDetailMapper extends BaseMapper<Lif
 
     void insertList(List<LifeDiscountCouponFriendRuleDetail> lifeDiscountCouponFriendRuleDetailList);
 
-    @Select("select si.store_name storeName,ldc.name couponName,ldc.id couponId,sum(ldcsf.single_qty) couponNum,ldcsf.friend_store_user_id friendStoreUserId from life_discount_coupon_store_friend ldcsf left join life_discount_coupon ldc on ldcsf.coupon_id = ldc.id left join store_user su on ldcsf.friend_store_user_id = su.id left join store_info si on su.store_id = si.id ${ew.customSqlSegment}")
+    @Select("select si.store_name storeName,ldc.name couponName,ldc.id couponId,ldc.coupon_type couponType,sum(ldcsf.single_qty) couponNum,ldcsf.friend_store_user_id friendStoreUserId from life_discount_coupon_store_friend ldcsf left join life_discount_coupon ldc on ldcsf.coupon_id = ldc.id left join store_user su on ldcsf.friend_store_user_id = su.id left join store_info si on su.store_id = si.id ${ew.customSqlSegment}")
     List<LifeDiscountCouponFriendRuleDetailVo> getReceivedFriendCouponList(@Param(Constants.WRAPPER) QueryWrapper<LifeDiscountCouponFriendRuleDetailVo> queryWrapper);
 
     /** 查询收到的代金券列表(life_coupon,voucher_id 不为空) */
@@ -35,7 +34,9 @@ public interface LifeDiscountCouponFriendRuleDetailMapper extends BaseMapper<Lif
             "COALESCE(c.end_get_date, v.end_date) AS endDate, " +
             "COALESCE(c.name, v.name) AS couponName, " +
             "c.id AS couponId, " +
-            "d.voucher_id AS voucherId " +
+            "d.voucher_id AS voucherId, " +
+            "COALESCE(a.coupon_type, c.coupon_type) AS couponType, " +
+            "c.discount_rate AS discountRate " +
             "FROM life_discount_coupon_friend_rule a " +
             "INNER JOIN life_discount_coupon_friend_rule_detail d ON d.rule_id = a.id " +
             "LEFT JOIN life_discount_coupon c ON d.coupon_id = c.id " +
@@ -45,6 +46,7 @@ public interface LifeDiscountCouponFriendRuleDetailMapper extends BaseMapper<Lif
     List<LifeDiscountCouponFriendRuleVo> getRuleList(@Param("storeId") String storeId);
 
     @Select("SELECT a.*, c.name as couponName, c.id as couponId, " +
+            "c.coupon_type as couponType, " +
             "si_friend.store_name AS storeName, " +
             "(SELECT sum(single_qty) FROM life_discount_coupon_store_friend b " +
             "WHERE b.friend_store_user_id = a.friend_store_user_id AND b.coupon_id = a.coupon_id AND b.store_user_id = a.store_id) couponNum " +

+ 2 - 1
alien-entity/src/main/java/shop/alien/mapper/LifeDiscountCouponMapper.java

@@ -72,7 +72,8 @@ public interface LifeDiscountCouponMapper extends BaseMapper<LifeDiscountCoupon>
      * @param storeId      店铺ID
      * @param couponStatus 券状态
      * @param type         类型,可为 null(不按 type 过滤)
+     * @param couponType   优惠券类型:1=满减券,2=折扣券,可为 null(不按 couponType 过滤)
      * @return 符合条件的 life_discount_coupon 列表
      */
-    List<LifeDiscountCoupon> selectListSingleTable(@Param("storeId") String storeId, @Param("couponStatus") Integer couponStatus, @Param("type") Integer type);
+    List<LifeDiscountCoupon> selectListSingleTable(@Param("storeId") String storeId, @Param("couponStatus") Integer couponStatus, @Param("type") Integer type, @Param("couponType") Integer couponType);
 }

+ 6 - 2
alien-entity/src/main/java/shop/alien/mapper/LifeDiscountCouponStoreFriendMapper.java

@@ -43,7 +43,9 @@ public interface LifeDiscountCouponStoreFriendMapper extends BaseMapper<LifeDisc
             "ldc.id couponId,\n" +
             "ldcsf.single_qty couponNum,\n" +
             "1 as type,\n" +
-            "null as voucherId\n" +
+            "null as voucherId,\n" +
+            "ldc.coupon_type couponType,\n" +
+            "ldc.discount_rate discountRate\n" +
             "from  life_discount_coupon_store_friend ldcsf\n" +
             "left join life_discount_coupon ldc\n" +
             "on ldc.id = ldcsf.coupon_id and ldc.delete_flag = 0\n" +
@@ -75,7 +77,9 @@ public interface LifeDiscountCouponStoreFriendMapper extends BaseMapper<LifeDisc
             "ldc.id couponId,\n" +
             "ldcsf.single_qty couponNum,\n" +
             "1 as type,\n" +
-            "null as voucherId\n" +
+            "null as voucherId,\n" +
+            "ldc.coupon_type couponType,\n" +
+            "ldc.discount_rate discountRate\n" +
             "from  life_discount_coupon_store_friend ldcsf\n" +
             "left join life_discount_coupon ldc\n" +
             "on ldc.id = ldcsf.coupon_id and ldc.delete_flag = 0\n" +

+ 1 - 1
alien-entity/src/main/java/shop/alien/mapper/LifeUserDynamicsMapper.java

@@ -19,7 +19,7 @@ public interface LifeUserDynamicsMapper extends BaseMapper<LifeUserDynamics> {
             "select lud.id, lud.top_status, lud.top_time, lud.title, lud.phone_id phoneId, " +
             "lud.context, lud.image_path, lud.address, lud.address_name, lud.address_context, " +
             "lud.liulan_count, lud.dianzan_count, lud.type, lud.created_time, substring_index(lud.phone_id, '_', 1) flag, " +
-            "substring_index(lud.phone_id, '_', -1) phone, lud.draft , lud.address_province, lud.transfer_count " +
+            "substring_index(lud.phone_id, '_', -1) phone, lud.draft , lud.address_province, lud.transfer_count, lud.cover_image " +
             "from life_user_dynamics lud " +
             "where lud.delete_flag = 0 and lud.enable_status = 0 and lud.draft = 0 and " +
             "not exists (select 1 from life_user_violation luv where luv.delete_flag = 0 and luv.processing_status = 1 " +

+ 5 - 0
alien-entity/src/main/java/shop/alien/mapper/StoreContractMapper.java

@@ -1,5 +1,6 @@
 package shop.alien.mapper;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -8,6 +9,8 @@ import org.apache.ibatis.annotations.Param;
 import shop.alien.entity.store.StoreContract;
 import shop.alien.entity.store.vo.StoreContractVo;
 
+import java.util.List;
+
 /**
  * 合同 Mapper 接口
  *
@@ -32,5 +35,7 @@ public interface StoreContractMapper extends BaseMapper<StoreContract> {
             @Param("status") Integer status,
             @Param("storeId") Integer storeId
     );
+
+    String selectSigningStatus(@Param("storeId") Integer storeId);
 }
 

+ 1 - 1
alien-entity/src/main/java/shop/alien/mapper/StoreImgMapper.java

@@ -75,7 +75,7 @@ public interface StoreImgMapper extends BaseMapper<StoreImg> {
             "#{albumId}" +
             "</foreach>" +
             "</if>" +
-            "ORDER BY si.updated_time DESC" +
+            "ORDER BY si.img_sort ASC" +
             "</script>")
     List<StoreImg> selectOfficialAlbumImgWithName(@Param("storeId") Integer storeId,
                                                    @Param("imgType") Integer imgType,

+ 6 - 5
alien-entity/src/main/java/shop/alien/mapper/second/SecondGoodsMapper.java

@@ -2,16 +2,13 @@ package shop.alien.mapper.second;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.baomidou.mybatisplus.core.toolkit.Constants;
-import org.apache.ibatis.annotations.Mapper; // 引入 Mapper 注解
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.Constants;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Select;
 import shop.alien.entity.second.SecondGoods;
-import shop.alien.entity.second.SecondShield;
 import shop.alien.entity.second.vo.SecondGoodsVo;
 import shop.alien.entity.second.vo.SellGoodsVo;
-import shop.alien.entity.store.StoreInfo;
 
 import java.util.List;
 
@@ -99,8 +96,12 @@ public interface SecondGoodsMapper extends BaseMapper<SecondGoods> {
             "sg.*, " +
             "sgc1.category_name as categoryOneName, " +
             "sgc2.category_name as categoryTwoName, "+
-            "ROUND(ST_Distance_Sphere(ST_GeomFromText(CONCAT('POINT(',#{currentLongitude},' ',#{currentLatitude} , ')' )), ST_GeomFromText(CONCAT('POINT(', REPLACE(sg.position, ',', ' '), ')' ))) / 1000, 2) AS distance "+
+            "ROUND(ST_Distance_Sphere(ST_GeomFromText(CONCAT('POINT(',#{currentLongitude},' ',#{currentLatitude} , ')' )), ST_GeomFromText(CONCAT('POINT(', REPLACE(sg.position, ',', ' '), ')' ))) / 1000, 2) AS distance, "+
+            "CONCAT('user_', u.user_phone) as user_phone"+
             " FROM second_goods sg " +
+            "inner join life_user u " +
+            "on u.id =  sg.user_id " +
+            "and u.delete_flag = 0 " +
             "left JOIN second_goods_category sgc1 " +
             "on sg.category_one_id = sgc1.id " +
             "left JOIN second_goods_category sgc2 " +

+ 2 - 1
alien-entity/src/main/resources/mapper/LifeDiscountCouponFriendRuleMapper.xml

@@ -10,9 +10,10 @@
             <result property="moneyLow" column="money_low" />
             <result property="moneyHigh" column="money_high" />
             <result property="deleteFlag" column="delete_flag" />
+            <result property="couponType" column="coupon_type" />
     </resultMap>
 
     <sql id="Base_Column_List">
-        id,ac_name,money_low,money_high,delete_flag
+        id,ac_name,money_low,money_high,delete_flag,coupon_type
     </sql>
 </mapper>

+ 3 - 0
alien-entity/src/main/resources/mapper/LifeDiscountCouponMapper.xml

@@ -50,6 +50,9 @@
         <if test="type != null">
           AND type = #{type}
         </if>
+        <if test="couponType != null">
+          AND coupon_type = #{couponType}
+        </if>
     </select>
 
 </mapper>

+ 9 - 0
alien-entity/src/main/resources/mapper/StoreContractMapper.xml

@@ -81,4 +81,13 @@
         ORDER BY cm.created_time DESC
     </select>
 
+    <select id="selectSigningStatus" resultType="java.lang.String">
+        SELECT signing_status
+        FROM store_contract
+        WHERE store_id = #{storeId}
+        AND delete_flag = 0
+        ORDER BY created_time DESC
+        LIMIT 1
+    </select>
+
 </mapper>

+ 1 - 0
alien-entity/src/main/resources/mapper/StorePlatformUserRoleMapper.xml

@@ -7,6 +7,7 @@
     <!-- 根据店铺ID查询子账号列表(连表查询) -->
     <select id="querySubAccounts" resultType="shop.alien.entity.store.vo.SubAccountVo">
         SELECT
+            spur.id AS id,
             sur.id AS userId,
             spur.account_name AS accountName,
             sur.phone AS phone,

+ 125 - 54
alien-job/src/main/java/shop/alien/job/store/StoreMembershipCardJob.java

@@ -122,78 +122,149 @@ public class StoreMembershipCardJob {
     @XxlJob("cancellationOfBusinessJob")
     public void cancellationOfBusinessJob() {
         log.info("删除已申请注销超过7天的商家与用户: " + new Date());
+        int successCount = 0;
+        int failCount = 0;
 
-        // 获取全部申请注销的商家
+        // 获取全部申请注销的商家用户
         List<StoreUser> storeUsers = storeUserMapper.selectList(new LambdaQueryWrapper<StoreUser>().eq(StoreUser::getLogoutFlag, LOGOUT_FLAY));
         for (StoreUser storeUser : storeUsers) {
-            if (null != storeUser.getLogoutTime()) {
-                // 获取申请注销时间
-                Date logoutTime = storeUser.getLogoutTime();
-                // 获取申请注销 8 天后的时间
-                Calendar calendar = Calendar.getInstance();
-                calendar.setTime(logoutTime);
-                calendar.add(Calendar.DAY_OF_YEAR, 8);
-                Date sevenDay = calendar.getTime();
-                // 获取当前时间
-                Date date = new Date();
-                if (date.compareTo(sevenDay) >= 0) {
-                    // 删除已过注销时间的商家
-                    storeUserMapper.deleteById(storeUser.getId());
-                    alienStoreFeign.delMer(Boolean.TRUE, storeUser.getId().toString());
-                    //删除用户redis中的token
-                    baseRedisService.delete("store_" + storeUser.getPhone());
+            try {
+                if (null != storeUser.getLogoutTime()) {
+                    // 获取申请注销时间
+                    Date logoutTime = storeUser.getLogoutTime();
+                    // 获取申请注销 7 天后的时间(与通知一致)
+                    Calendar calendar = Calendar.getInstance();
+                    calendar.setTime(logoutTime);
+                    calendar.add(Calendar.DAY_OF_YEAR, 7);
+                    Date sevenDay = calendar.getTime();
+                    // 获取当前时间
+                    Date date = new Date();
+                    if (date.compareTo(sevenDay) >= 0) {
+                        // 删除已过注销时间的商家用户
+                        log.info("删除已注销超过7天的商家用户: userId={}, phone={}, logoutTime={}", 
+                                storeUser.getId(), storeUser.getPhone(), logoutTime);
+                        storeUserMapper.deleteById(storeUser.getId());
+                        alienStoreFeign.delMer(Boolean.TRUE, storeUser.getId().toString());
+                        //删除用户redis中的token
+                        baseRedisService.delete("store_" + storeUser.getPhone());
+                        successCount++;
+                    }
                 }
+            } catch (Exception e) {
+                failCount++;
+                log.error("删除商家用户失败: userId={}, phone={}, error={}", 
+                        storeUser.getId(), storeUser.getPhone(), e.getMessage(), e);
             }
         }
+        
+        // 获取全部申请注销的店铺
         List<StoreInfo> storeInfos = storeInfoMapper.selectList(new LambdaQueryWrapper<StoreInfo>().eq(StoreInfo::getLogoutFlag, LOGOUT_FLAY));
         for (StoreInfo storeInfo : storeInfos) {
-            if (null != storeInfo.getLogoutTime()) {
-                // 获取申请注销时间
-                Date logoutTime = storeInfo.getLogoutTime();
-                // 获取申请注销 8 天后的时间
-                Calendar calendar = Calendar.getInstance();
-                calendar.setTime(logoutTime);
-                calendar.add(Calendar.DAY_OF_YEAR, 8);
-                Date sevenDay = calendar.getTime();
-                // 获取当前时间
-                Date date = new Date();
-                if (date.compareTo(sevenDay) >= 0) {
-                    //删除该账号的店铺
-                    storeInfoMapper.deleteById(storeInfo.getId());
-                    StoreUser storeUser = storeUserMapper.selectOne(new LambdaQueryWrapper<StoreUser>().eq(StoreUser::getStoreId, storeInfo.getId()));
-                    if (storeUser != null) {
-                        storeUser.setStoreId(null);
-                        storeUserMapper.updateById(storeUser);
-                        LambdaQueryWrapper<LifeFans> queryWrapper = new LambdaQueryWrapper<LifeFans>().eq(LifeFans::getFollowedId, "store_" + storeUser.getPhone())
-                                .or().eq(LifeFans::getFansId, "store_" + storeUser.getPhone());
-                        lifeFansMapper.delete(queryWrapper);
+            try {
+                if (null != storeInfo.getLogoutTime()) {
+                    // 获取申请注销时间
+                    Date logoutTime = storeInfo.getLogoutTime();
+                    // 获取申请注销 7 天后的时间(与通知一致)
+                    Calendar calendar = Calendar.getInstance();
+                    calendar.setTime(logoutTime);
+                    calendar.add(Calendar.DAY_OF_YEAR, 7);
+                    Date sevenDay = calendar.getTime();
+                    // 获取当前时间
+                    Date date = new Date();
+                    if (date.compareTo(sevenDay) >= 0) {
+                        log.info("开始删除已注销超过7天的店铺: storeId={}, storeName={}, logoutTime={}", 
+                                storeInfo.getId(), storeInfo.getStoreName(), logoutTime);
+                        
+                        // 先清理关联的商户用户注销状态,确保可以重新入驻
+                        List<StoreUser> relatedStoreUsers = storeUserMapper.selectList(
+                                new LambdaQueryWrapper<StoreUser>().eq(StoreUser::getStoreId, storeInfo.getId()));
+                        int deletedUsers = 0;
+                        int deletedFans = 0;
+                        
+                        for (StoreUser storeUser : relatedStoreUsers) {
+                            try {
+                                // 清理注销标记和时间,允许重新入驻
+                                storeUser.setLogoutFlag(0);
+                                storeUser.setLogoutTime(null);
+                                storeUser.setStoreId(null);  // 解除店铺绑定
+                                storeUserMapper.updateById(storeUser);
+                                deletedUsers++;
+                                log.info("清理商户用户注销状态: userId={}, phone={}", storeUser.getId(), storeUser.getPhone());
+                            } catch (Exception e) {
+                                log.error("清理商户用户注销状态失败: userId={}, phone={}, error={}", 
+                                        storeUser.getId(), storeUser.getPhone(), e.getMessage(), e);
+                            }
+                        }
+                        
+                        // 清理粉丝关系
+                        for (StoreUser storeUser : relatedStoreUsers) {
+                            try {
+                                if (storeUser.getPhone() != null) {
+                                    LambdaQueryWrapper<LifeFans> queryWrapper = new LambdaQueryWrapper<LifeFans>()
+                                            .eq(LifeFans::getFollowedId, "store_" + storeUser.getPhone())
+                                            .or().eq(LifeFans::getFansId, "store_" + storeUser.getPhone());
+                                    int deleted = lifeFansMapper.delete(queryWrapper);
+                                    deletedFans += deleted;
+                                }
+                            } catch (Exception e) {
+                                log.error("清理粉丝关系失败: userId={}, phone={}, error={}", 
+                                        storeUser.getId(), storeUser.getPhone(), e.getMessage(), e);
+                            }
+                        }
+                        
+                        // 清理Redis地理位置(通过Feign调用)
+                        try {
+                            alienStoreFeign.delMer(Boolean.TRUE, storeInfo.getId().toString());
+                        } catch (Exception e) {
+                            log.warn("清理Redis地理位置失败: storeId={}, error={}", storeInfo.getId(), e.getMessage());
+                        }
+                        
+                        // 最后删除店铺记录
+                        storeInfoMapper.deleteById(storeInfo.getId());
+                        successCount++;
+                        log.info("店铺删除完成: storeId={}, deletedUsers={}, deletedFans={}", 
+                                storeInfo.getId(), deletedUsers, deletedFans);
                     }
                 }
+            } catch (Exception e) {
+                failCount++;
+                log.error("删除店铺失败: storeId={}, storeName={}, error={}", 
+                        storeInfo.getId(), storeInfo.getStoreName(), e.getMessage(), e);
             }
         }
 
         // 获取全部申请注销的用户
         List<LifeUser> lifeUsers = lifeUserMapper.selectList(new LambdaQueryWrapper<LifeUser>().eq(LifeUser::getLogoutFlag, LOGOUT_FLAY));
         for (LifeUser lifeUser : lifeUsers) {
-            if (null != lifeUser.getLogoutTime()) {
-                // 获取申请注销时间
-                Date logoutTime = lifeUser.getLogoutTime();
-                // 获取申请注销 7 天后的时间
-                Calendar calendar = Calendar.getInstance();
-                calendar.setTime(logoutTime);
-                calendar.add(Calendar.DAY_OF_YEAR, 7);
-                Date sevenDay = calendar.getTime();
-                // 获取当前时间
-                Date date = new Date();
-                if (date.compareTo(sevenDay) >= 0) {
-                    // 删除已过注销时间的用户
-                    lifeUserMapper.deleteById(lifeUser.getId());
-                    // 清理粉丝
-                    LambdaQueryWrapper<LifeFans> queryWrapper = new LambdaQueryWrapper<LifeFans>().eq(LifeFans::getFollowedId, "user_" + lifeUser.getUserPhone())
-                            .or().eq(LifeFans::getFansId, "user_" + lifeUser.getUserPhone());
-                    lifeFansMapper.delete(queryWrapper);
+            try {
+                if (null != lifeUser.getLogoutTime()) {
+                    // 获取申请注销时间
+                    Date logoutTime = lifeUser.getLogoutTime();
+                    // 获取申请注销 7 天后的时间
+                    Calendar calendar = Calendar.getInstance();
+                    calendar.setTime(logoutTime);
+                    calendar.add(Calendar.DAY_OF_YEAR, 7);
+                    Date sevenDay = calendar.getTime();
+                    // 获取当前时间
+                    Date date = new Date();
+                    if (date.compareTo(sevenDay) >= 0) {
+                        // 删除已过注销时间的用户
+                        lifeUserMapper.deleteById(lifeUser.getId());
+                        // 清理粉丝
+                        LambdaQueryWrapper<LifeFans> queryWrapper = new LambdaQueryWrapper<LifeFans>()
+                                .eq(LifeFans::getFollowedId, "user_" + lifeUser.getUserPhone())
+                                .or().eq(LifeFans::getFansId, "user_" + lifeUser.getUserPhone());
+                        lifeFansMapper.delete(queryWrapper);
+                        successCount++;
+                    }
                 }
+            } catch (Exception e) {
+                failCount++;
+                log.error("删除用户失败: userId={}, phone={}, error={}", 
+                        lifeUser.getId(), lifeUser.getUserPhone(), e.getMessage(), e);
             }
         }
+        
+        log.info("定时任务执行完成: 成功={}, 失败={}", successCount, failCount);
     }
 }

+ 26 - 0
alien-lawyer/src/main/java/shop/alien/lawyer/config/NacosConfig.java

@@ -0,0 +1,26 @@
+package shop.alien.lawyer.config;
+
+import lombok.Data;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.cloud.context.config.annotation.RefreshScope;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+
+/**
+ * @author ssk
+ * @version 1.0
+ * @date 2025/11/6 13:39
+ */
+@Data
+@Component
+@RefreshScope
+public class NacosConfig {
+
+    /**
+     * 测试手机号
+     */
+    @Value("${ali.sms.testPhone}")
+    private List<String> testPhone;
+
+}

+ 14 - 0
alien-lawyer/src/main/java/shop/alien/lawyer/util/AliSms.java

@@ -10,6 +10,7 @@ import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Component;
 import shop.alien.entity.store.StoreVerificationCode;
+import shop.alien.lawyer.config.NacosConfig;
 import shop.alien.mapper.StoreVerificationCodeMapper;
 import shop.alien.util.common.RandomCreateUtil;
 import shop.alien.lawyer.config.BaseRedisService;
@@ -33,6 +34,8 @@ public class AliSms {
 
     private final StoreVerificationCodeMapper storeVerificationCodeMapper;
 
+    private final NacosConfig nacosConfig;
+
     @Value("${ali.sms.accessKeyId}")
     private String accessKeyId;
 
@@ -60,12 +63,23 @@ public class AliSms {
             // -----------------测试用手机号--------------------------------------------------------------------------------------------
             List<String> phoneList = Arrays.asList("19999990001", "19999990002", "19999990003", "19999990004", "19999990005", "19999990006", "19999990007", "19999990008", "19999990009", "19999990010",
                     "16666660001", "16666660002", "16666660003", "16666660004", "16666660005", "16666660006", "16666660007", "16666660008", "16666660009", "16666660010",
+                    "18888880001", "18888880002", "18888880003", "18888880004", "18888880005", "18888880006", "18888880007", "18888880008", "18888880009", "18888880010",
                     "17777770001","17777770002","17777770003","17777770004","17777770005","17777770006","17777770007","17777770008","17777770009","17777770010");
             if (phoneList.contains(phone)) {
                 // 验证码发送成功,将验证码保存到redis中 设置60秒过期
                 baseRedisService.setString("verification_lawyer_"+phone,"123456",Long.valueOf(300));
                 return 123456;
             }
+
+
+            //走nacos配置,测试用  优化版本,暂时还是用之前的,直接写死
+//            if (nacosConfig.getTestPhone().contains(phone)) {
+//                // 验证码发送成功,将验证码保存到redis中 设置60秒过期
+//                baseRedisService.setString("verification_lawyer_"+phone,"123456",Long.valueOf(300));
+//                return 123456;
+//            }
+
+
             // -----------------测试用手机号--------------------------------------------------------------------------------------------
 
             Config config = new Config()

+ 2 - 2
alien-second/src/main/java/shop/alien/second/service/impl/SecondGoodsServiceImpl.java

@@ -4,7 +4,6 @@ import cn.hutool.core.collection.CollectionUtil;
 import com.alibaba.fastjson2.JSON;
 import com.alibaba.fastjson2.JSONArray;
 import com.alibaba.fastjson2.JSONObject;
-import com.alipay.api.domain.GoodsVO;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
@@ -1464,7 +1463,8 @@ public class SecondGoodsServiceImpl extends ServiceImpl<SecondGoodsMapper, Secon
         queryWrapper.notIn(CollectionUtil.isNotEmpty(shieldedGoodsIds), "sg.id", shieldedGoodsIds)
                 .notIn(CollectionUtil.isNotEmpty(userIdList), "sg.user_id", userIdList)
                 .eq("sg.goods_status", SecondGoodsStatusEnum.LISTED.getCode())// 3-上架
-                .eq("sg.delete_flag", Constants.DeleteFlag.NOT_DELETED);
+                .eq("sg.delete_flag", Constants.DeleteFlag.NOT_DELETED)
+                .isNull("sg.trade_id");
         // 添加对 searchData 的模糊查询
         if (!StringUtils.isEmpty(secondGoodsVo.getSearchData())) {
             String searchData = "%" + secondGoodsVo.getSearchData() + "%";

+ 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);

+ 38 - 0
alien-store-platform/src/main/java/shop/alien/storeplatform/controller/StorePlatformUserRoleController.java

@@ -243,6 +243,44 @@ public class StorePlatformUserRoleController {
         return R.fail("更新子账号信息失败");
     }
 
+
+
+    @ApiOperation("更新子账号信息")
+    @ApiOperationSupport(order = 10)
+    @PlatformOperationLog(
+            module = "账号操作记录",
+            type = "修改子账号",
+            content = "修改子账号,用户ID:#{#p0.userId},手机号:#{#p0.phone},账号名:#{#p0.accountName}"
+    )
+    @PostMapping("/updateSubAccountNew")
+    public R<String> updateSubAccountNew(@RequestBody UpdateAccountDto updateAccountDto) {
+        log.info("StorePlatformUserRoleController.updateSubAccount?userId={}, phone={}, accountName={}, storeId={}, roleId={}",
+                updateAccountDto.getUserId(), updateAccountDto.getPhone(), updateAccountDto.getAccountName(),
+                updateAccountDto.getStoreId(), updateAccountDto.getRoleId());
+
+        if (updateAccountDto.getUserId() == null) {
+            return R.fail("用户ID不能为空");
+        }
+        if (updateAccountDto.getStoreId() == null) {
+            return R.fail("店铺ID不能为空");
+        }
+
+        boolean result = storePlatformUserRoleService.updateSubAccountNew(
+                updateAccountDto.getUserId(),
+                updateAccountDto.getPhone(),
+                updateAccountDto.getAccountName(),
+                updateAccountDto.getStoreId(),
+                updateAccountDto.getRoleId(),
+                updateAccountDto.getId()
+        );
+        if (result) {
+            return R.success("更新子账号信息成功");
+        }
+        return R.fail("更新子账号信息失败");
+    }
+
+
+
     @ApiOperation("查询所有子账号信息(分页)")
     @ApiOperationSupport(order = 11)
     @ApiImplicitParams({

+ 3 - 0
alien-store-platform/src/main/java/shop/alien/storeplatform/dto/UpdateAccountDto.java

@@ -14,6 +14,9 @@ import lombok.Data;
 @ApiModel(value = "UpdateAccountDto", description = "更新子账号请求参数")
 public class UpdateAccountDto {
 
+    @ApiModelProperty(value = "中间表id(子账号id)")
+    private Integer id;
+
     @ApiModelProperty(value = "用户ID", required = true)
     private Integer userId;
 

+ 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);
 
 }
 

+ 2 - 0
alien-store-platform/src/main/java/shop/alien/storeplatform/service/StorePlatformUserRoleService.java

@@ -123,6 +123,8 @@ public interface StorePlatformUserRoleService extends IService<StorePlatformUser
      */
     boolean updateSubAccount(Integer userId, String phone, String accountName, Integer storeId, Long roleId);
 
+    boolean updateSubAccountNew(Integer userId, String phone, String accountName, Integer storeId, Long roleId,Integer id);
+
     /**
      * 查询所有子账号信息(包含主账号电话)- 分页查询
      * 查询 store_platform_user_role 表中所有的数据

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

@@ -177,6 +177,10 @@ public class LifeDiscountCouponPlatformServiceImpl extends ServiceImpl<LifeDisco
             LifeDiscountCoupon lifeDiscountCoupon = new LifeDiscountCoupon();
             lifeDiscountCoupon.setId(Integer.parseInt(lifeDiscountCouponDto.getCouponId()));
             BeanUtils.copyProperties(lifeDiscountCouponDto, lifeDiscountCoupon);
+            // 如果最低消费为null,设置为0(表示无门槛)
+            if (lifeDiscountCoupon.getMinimumSpendingAmount() == null) {
+                lifeDiscountCoupon.setMinimumSpendingAmount(BigDecimal.ZERO);
+            }
 
             // 根据开始领取时间判断可领取状态
             // 判断是否在领取时间内
@@ -442,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<>();
@@ -452,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();
         //如果根据类型查询

+ 8 - 5
alien-store-platform/src/main/java/shop/alien/storeplatform/service/impl/MerchantAuthServiceImpl.java

@@ -51,11 +51,12 @@ public class MerchantAuthServiceImpl implements MerchantAuthService {
                        .eq(LifeUser::getLogoutFlag, 0);  // 只查询未注销的用户
             size = lifeUserMapper.selectCount(userWrapper);
         } else {
-            // 商家端:查询已入驻或审核中的商家
-            // 1. 先根据身份证和姓名查询商户用户
+            // 商家端:查询已入驻或审核中的商家(排除已注销和审核失败的店铺)
+            // 1. 先根据身份证和姓名查询商户用户(排除已注销的用户)
             LambdaQueryWrapper<StoreUser> storeUserWrapper = new LambdaQueryWrapper<>();
             storeUserWrapper.eq(StoreUser::getIdCard, idCard)
-                           .eq(StoreUser::getName, name);
+                           .eq(StoreUser::getName, name)
+                           .eq(StoreUser::getLogoutFlag, 0);  // 排除已注销的商户用户
             List<StoreUser> storeUserList = storeUserMapper.selectList(storeUserWrapper);
             
             // 2. 获取这些商户用户绑定的店铺ID
@@ -64,11 +65,13 @@ public class MerchantAuthServiceImpl implements MerchantAuthService {
                     .filter(Objects::nonNull)  // 过滤掉空的店铺ID
                     .collect(Collectors.toList());
             
-            // 3. 如果有店铺ID,查询非审核失败状态的店铺
+            // 3. 如果有店铺ID,查询非审核失败且非注销状态的店铺
             if (!storeIds.isEmpty()) {
                 LambdaQueryWrapper<StoreInfo> storeInfoWrapper = new LambdaQueryWrapper<>();
                 storeInfoWrapper.in(StoreInfo::getId, storeIds)
-                               .notIn(StoreInfo::getStoreApplicationStatus, 2);  // 排除审核失败的店铺(状态2)
+                               .notIn(StoreInfo::getStoreApplicationStatus, 2)  // 排除审核失败的店铺(状态2)
+                               .eq(StoreInfo::getLogoutFlag, 0)  // 排除已注销的店铺(logoutFlag=0表示未注销)
+                               .ne(StoreInfo::getStoreStatus, -1);  // 排除注销中状态的店铺(storeStatus=-1表示注销中)
                 size = storeInfoMapper.selectCount(storeInfoWrapper);
             }
         }

+ 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());
+                }
             }
         }
 

+ 10 - 9
alien-store-platform/src/main/java/shop/alien/storeplatform/service/impl/StoreContractServiceImpl.java

@@ -200,22 +200,23 @@ public class StoreContractServiceImpl implements StoreContractService {
             if (storeId == null) {
                 return R.fail("店铺ID不能为空");
             }
+            String contracts = storeContractMapper.selectSigningStatus(storeId);
 
             // 根据店铺ID查询最新的合同(按创建时间倒序)
-            List<StoreContract> contracts = storeContractMapper.selectList(
-                    new LambdaQueryWrapper<StoreContract>()
-                            .eq(StoreContract::getStoreId, storeId.longValue())
-                            .eq(StoreContract::getDeleteFlag, 0)
-                            .orderByDesc(StoreContract::getCreatedTime)
-                            .last("LIMIT 1")
-            );
+//            List<StoreContract> contracts = storeContractMapper.selectList(
+//                    new LambdaQueryWrapper<StoreContract>()
+//                            .eq(StoreContract::getStoreId, storeId.longValue())
+//                            .eq(StoreContract::getDeleteFlag, 0)
+//                            .orderByDesc(StoreContract::getCreatedTime)
+//                            .last("LIMIT 1")
+//            );
 
             if (contracts == null || contracts.isEmpty()) {
                 return R.fail("该店铺暂无合同");
             }
 
-            StoreContract contract = contracts.get(0);
-            String signingStatus = contract.getSigningStatus();
+//            StoreContract contract = contracts.get(0);
+            String signingStatus = contracts;
             // 将字符串状态转换为数字:已签署=1, 未签署=0, 已到期=2
             Integer statusValue = null;
             if (signingStatus != null) {

+ 18 - 0
alien-store-platform/src/main/java/shop/alien/storeplatform/service/impl/StorePlatformUserRoleServiceImpl.java

@@ -780,6 +780,24 @@ public class StorePlatformUserRoleServiceImpl extends ServiceImpl<StorePlatformU
     }
 
     @Override
+    public boolean updateSubAccountNew(Integer userId, String phone, String accountName, Integer storeId, Long roleId,Integer id) {
+        LambdaUpdateWrapper<StorePlatformUserRole> deleteWrapper = new LambdaUpdateWrapper<>();
+        deleteWrapper.eq(StorePlatformUserRole::getUserId, userId)
+                .eq(StorePlatformUserRole::getId, id)
+                .set(StorePlatformUserRole::getDeleteFlag, 1);
+        int deleteResult = storePlatformUserRoleMapper.update(null, deleteWrapper);
+        if (deleteResult > 0) {
+            log.info("成功删除角色关联记录: userId={}, storeId={}, roleId={}", userId, storeId, roleId);
+           R<String> A =createAccountAndAssignRole(phone, accountName, storeId, roleId);
+           if (A.getCode()==200){
+               return true;
+           }
+        }
+
+        return false;
+    }
+
+    @Override
     public IPage<SubAccountListVo> queryAllSubAccounts(Integer pageNum, Integer pageSize, String accountId, String phone, Integer status) {
         try {
             // 创建分页对象

+ 61 - 14
alien-store/src/main/java/shop/alien/store/aspect/AiAuditAspect.java

@@ -1,3 +1,4 @@
+/*
 package shop.alien.store.aspect;
 
 import com.alibaba.fastjson.JSON;
@@ -13,13 +14,17 @@ import shop.alien.entity.store.StorePrice;
 import shop.alien.entity.store.dto.CuisineComboDto;
 import shop.alien.store.util.ai.AiContentModerationUtil;
 
+import java.lang.reflect.Field;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
+import java.util.StringJoiner;
 
+*/
 /**
  * AI 审核切面:拦截美食与通用价目新增/修改接口
- */
+ *//*
+
 @Slf4j
 @Aspect
 @Component
@@ -29,9 +34,11 @@ public class AiAuditAspect {
 
     private final AiContentModerationUtil aiContentModerationUtil;
 
-    /**
+    */
+/**
      * 仅拦截美食新增/修改与通用价目新增/修改接口
-     */
+     *//*
+
     @Pointcut(
             "execution(* shop.alien.store.controller.StoreCuisineController.addCuisineCombo(..))"
                     + " || execution(* shop.alien.store.controller.StoreCuisineController.updateCuisineCombo(..))"
@@ -41,14 +48,16 @@ public class AiAuditAspect {
         // pointcut definition
     }
 
-    /**
+    */
+/**
      * 环绕通知:组合请求参数,获取AI token,并设置审核状态
-     */
+     *//*
+
     @Around("aiAuditPointcut()")
     public Object around(ProceedingJoinPoint joinPoint) throws Throwable {
         Object[] args = joinPoint.getArgs();
 
-        String payload = JSON.toJSONString(args);
+        String payload = extractFieldValues(args);
         log.info("AI审核切面拦截方法: {}, payload={}", joinPoint.getSignature().toShortString(), payload);
 
         List<String> imageUrls = extractImageUrls(args);
@@ -62,9 +71,11 @@ public class AiAuditAspect {
         return joinPoint.proceed(args);
     }
 
-    /**
+    */
+/**
      * AI审核调用:使用文本审核(图片列表暂为空)
-     */
+     *//*
+
     private boolean performAiAudit(String payload, List<String> imageUrls, Object[] args) {
         try {
             // token 目前仅预留,如后续需要可添加到header或payload
@@ -88,9 +99,11 @@ public class AiAuditAspect {
         }
     }
 
-    /**
+    */
+/**
      将审核结果写入入参的status字段(通过=1,不通过=2)
-     */
+     *//*
+
     private void applyStatus(Object[] args, boolean passed) {
         int status = passed ? 1 : 2;
         for (Object arg : args) {
@@ -105,9 +118,11 @@ public class AiAuditAspect {
         }
     }
 
-    /**
+    */
+/**
      * 将审核失败原因写入入参
-     */
+     *//*
+
     private void applyFailureReason(Object[] args, String reason) {
         String safeReason = reason != null ? reason : "审核未通过";
         for (Object arg : args) {
@@ -122,9 +137,40 @@ public class AiAuditAspect {
         }
     }
 
-    /**
+    */
+/**
+     * 通过反射提取所有参数对象的字段值,用空格拼接成纯文本
+     *//*
+
+    private String extractFieldValues(Object[] args) {
+        StringJoiner joiner = new StringJoiner(" ");
+        for (Object arg : args) {
+            if (arg == null) {
+                continue;
+            }
+            for (Field field : arg.getClass().getDeclaredFields()) {
+                field.setAccessible(true);
+                try {
+                    Object value = field.get(arg);
+                    if (value != null) {
+                        String str = String.valueOf(value);
+                        if (!str.isEmpty()) {
+                            joiner.add(str);
+                        }
+                    }
+                } catch (IllegalAccessException e) {
+                    // skip
+                }
+            }
+        }
+        return joiner.toString();
+    }
+
+    */
+/**
      * 从入参中提取图片URL列表;images字段为JSON字符串数组
-     */
+     *//*
+
     private List<String> extractImageUrls(Object[] args) {
         for (Object arg : args) {
             if (arg instanceof CuisineComboDto) {
@@ -153,3 +199,4 @@ public class AiAuditAspect {
     }
 }
 
+*/

+ 100 - 35
alien-store/src/main/java/shop/alien/store/controller/LifeDiscountCouponController.java

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import io.swagger.annotations.*;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
+import org.springframework.util.StringUtils;
 import org.springframework.web.bind.annotation.*;
 import shop.alien.entity.result.R;
 import shop.alien.entity.store.LifeDiscountCoupon;
@@ -139,17 +140,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 +160,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,39 +183,67 @@ 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),
+    @ApiImplicitParams({@ApiImplicitParam(name = "page", value = "分页页数", dataType = "Integer", paramType = "query", required = false),
+            @ApiImplicitParam(name = "size", value = "分页条数", dataType = "Integer", paramType = "query", required = false),
             @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) {
         try {
-            List<LifeDiscountCouponVo> storeCouponList = lifeDiscountCouponService.getUserCouponList(userLoginInfo, page, size, tabType, type);
+            // 参数校验
+            if (StringUtils.isEmpty(tabType)) {
+                return R.fail("分页类型不能为空");
+            }
+            if (page < 1) {
+                page = 1;
+            }
+            if (size < 1 || size > 100) {
+                size = 10;
+            }
+            if (type != null && type != 1 && type != 4) {
+                return R.fail("券类型参数错误,必须为1(优惠券)或4(代金券)");
+            }
+            if (couponType != null && couponType != 1 && couponType != 2) {
+                return R.fail("优惠券类型参数错误,必须为1(满减券)或2(折扣券)");
+            }
+            
+            log.info("LifeDiscountCouponController.getUserCouponList?userId={}, tabType={}, page={}, size={}, type={}, couponType={}", 
+                    userLoginInfo.getUserId(), tabType, page, size, type, couponType);
+            
+            List<LifeDiscountCouponVo> storeCouponList = lifeDiscountCouponService.getUserCouponList(
+                    userLoginInfo, page, size, tabType, type, couponType);
             return R.data(storeCouponList);
+        } catch (IllegalArgumentException e) {
+            log.error("LifeDiscountCouponController.getUserCouponList 参数错误, userId={}, error={}", 
+                    userLoginInfo != null ? userLoginInfo.getUserId() : "unknown", e.getMessage(), e);
+            return R.fail(e.getMessage());
         } catch (Exception e) {
-            log.error("LifeDiscountCouponController.getUserCouponList ERROR Msg={}", e.getMessage());
+            log.error("LifeDiscountCouponController.getUserCouponList ERROR, userId={}, error={}", 
+                    userLoginInfo != null ? userLoginInfo.getUserId() : "unknown", e.getMessage(), e);
             return R.fail("查询失败");
         }
     }
 
-    @ApiOperation("获取该店铺所有优惠券(分页), 好友优惠券")
+    @ApiOperation("获取该店铺所有优惠券(分页), 好友优惠券。couponType=1仅满减券,couponType=2仅折扣券,不传返回全部优惠券")
     @ApiOperationSupport(order = 10)
     @GetMapping("/getStoreAllCouponList")
-    @ApiImplicitParams({@ApiImplicitParam(name = "page", value = "分页页数", dataType = "String", paramType = "query", required = true),
-            @ApiImplicitParam(name = "size", value = "分页条数", dataType = "String", paramType = "query", required = true),
+    @ApiImplicitParams({@ApiImplicitParam(name = "page", value = "分页页数", dataType = "Integer", paramType = "query", required = false),
+            @ApiImplicitParam(name = "size", value = "分页条数", dataType = "Integer", paramType = "query", required = false),
             @ApiImplicitParam(name = "storeId", value = "商户id", dataType = "String", paramType = "query", required = true),
             @ApiImplicitParam(name = "couponName", value = "优惠券名称", dataType = "String", paramType = "query", required = false),
-            @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 = "tab", value = "分页类型(0:全部,1:进行中,2:已结束,3:草稿,4:未开始,5:已下架,6:已清库)", dataType = "String", paramType = "query", required = true),
+            @ApiImplicitParam(name = "couponsFromType", required = false, value = "查询类型(1:我的优惠券,2:好友的优惠券)", dataType = "Integer", paramType = "query"),
+            @ApiImplicitParam(name = "couponStatus", required = false, value = "优惠券状态(0:草稿,1:正式)", dataType = "Integer", paramType = "query"),
+            @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,32 +252,64 @@ 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);
         try {
-            IPage<LifeDiscountCouponVo> storeCouponList = lifeDiscountCouponService.getStoreAllCouponList(storeId, userLoginInfo, page, size, couponName, tab, couponsFromType, couponStatus);
+            // 参数校验
+            if (StringUtils.isEmpty(storeId)) {
+                return R.fail("商户id不能为空");
+            }
+            if (StringUtils.isEmpty(tab)) {
+                return R.fail("分页类型不能为空");
+            }
+            if (page < 1) {
+                page = 1;
+            }
+            if (size < 1 || size > 100) {
+                size = 10;
+            }
+            if (couponsFromType != 1 && couponsFromType != 2) {
+                couponsFromType = 1;
+            }
+            if (couponStatus != 0 && couponStatus != 1) {
+                couponStatus = 1;
+            }
+            if (couponType != null && couponType != 1 && couponType != 2) {
+                return R.fail("优惠券类型参数错误,必须为1(满减券)或2(折扣券)");
+            }
+            
+            log.info("LifeDiscountCouponController.getStoreAllCouponList?storeId={}, couponName={}, tab={}, page={}, size={}, couponsFromType={}, couponStatus={}, couponType={}", 
+                    storeId, couponName, tab, page, size, couponsFromType, couponStatus, couponType);
+            
+            IPage<LifeDiscountCouponVo> storeCouponList = lifeDiscountCouponService.getStoreAllCouponList(
+                    storeId, userLoginInfo, page, size, couponName, tab, couponsFromType, couponStatus, couponType);
             return R.data(storeCouponList);
+        } catch (IllegalArgumentException e) {
+            log.error("LifeDiscountCouponController.getStoreAllCouponList 参数错误, storeId={}, error={}", storeId, e.getMessage(), e);
+            return R.fail(e.getMessage());
         } catch (Exception e) {
-            log.error("LifeDiscountCouponController.getStoreCouponList ERROR Msg={}", e.getMessage());
+            log.error("LifeDiscountCouponController.getStoreAllCouponList ERROR, storeId={}, error={}", storeId, e.getMessage(), e);
             return R.fail("查询失败");
         }
     }
 
-    @ApiOperation("获取该店铺所有优惠券 代金券(不分页)")
+    @ApiOperation("获取该店铺所有优惠券 代金券(不分页)。couponType=1仅满减券,couponType=2仅折扣券,不传返回全部优惠券")
     @ApiOperationSupport(order = 11)
     @GetMapping("/getStoreAllCouponListPaginateNot")
     @ApiImplicitParams({
             @ApiImplicitParam(name = "storeId", value = "商户id", dataType = "String", paramType = "query", required = true),
-            @ApiImplicitParam(name = "type", value = "类型:1-优惠券(默认),4-代金券", dataType = "Integer", paramType = "query")
+            @ApiImplicitParam(name = "type", value = "类型:1-优惠券(默认),4-代金券", dataType = "Integer", paramType = "query"),
+            @ApiImplicitParam(name = "couponType", value = "优惠券类型:1=仅满减券,2=仅折扣券,不传=全部优惠券(可选,仅当type不为4时有效)", dataType = "Integer", paramType = "query", required = false)
     })
     public R<List<LifeDiscountCouponVo>> getStoreAllCouponListPaginateNot(@ApiIgnore @TokenInfo UserLoginInfo userLoginInfo,
                                                                           @RequestParam(value = "storeId") String storeId,@RequestParam(value = "status", required = false) String status,
                                                                           @RequestParam(value = "couponStatus", defaultValue = "1", required = false) int couponStatus,
-                                                                          @RequestParam(value = "type", defaultValue = "1", required = false) Integer type) {
-        log.info("LifeDiscountCouponController.getStoreAllCouponListPaginateNot?storeId={}, status={}, couponStatus={}, type={}", storeId, status, couponStatus, type);
+                                                                          @RequestParam(value = "type", defaultValue = "1", required = false) Integer type,
+                                                                          @RequestParam(value = "couponType", required = false) Integer couponType) {
+        log.info("LifeDiscountCouponController.getStoreAllCouponListPaginateNot?storeId={}, status={}, couponStatus={}, type={}, couponType={}", storeId, status, couponStatus, type, couponType);
         try {
-            List<LifeDiscountCouponVo> storeCouponList = lifeDiscountCouponService.getStoreAllCouponListPaginateNot(status, storeId, userLoginInfo, couponStatus, type);
+            List<LifeDiscountCouponVo> storeCouponList = lifeDiscountCouponService.getStoreAllCouponListPaginateNot(status, storeId, userLoginInfo, couponStatus, type, couponType);
             return R.data(storeCouponList);
         } catch (Exception e) {
             log.error("LifeDiscountCouponController.getStoreAllCouponListPaginateNot ERROR Msg={}", e.getMessage());
@@ -289,7 +354,7 @@ public class LifeDiscountCouponController {
                                                                          @RequestParam(value = "couponStatus", defaultValue = "1", required = false) int couponStatus) {
         log.info("LifeDiscountCouponController.getMyCreatedDiscountCouponList?storeId={}", storeId);
         try {
-            List<LifeDiscountCouponVo> list = lifeDiscountCouponService.getStoreAllCouponListPaginateNot(status, storeId, userLoginInfo, couponStatus, 1);
+            List<LifeDiscountCouponVo> list = lifeDiscountCouponService.getStoreAllCouponListPaginateNot(status, storeId, userLoginInfo, couponStatus, 1, null);
             return R.data(list);
         } catch (Exception e) {
             log.error("LifeDiscountCouponController.getMyCreatedDiscountCouponList ERROR Msg={}", e.getMessage());
@@ -311,7 +376,7 @@ public class LifeDiscountCouponController {
                                                                  @RequestParam(value = "couponStatus", defaultValue = "1", required = false) int couponStatus) {
         log.info("LifeDiscountCouponController.getMyCreatedVoucherList?storeId={}", storeId);
         try {
-            List<LifeDiscountCouponVo> list = lifeDiscountCouponService.getStoreAllCouponListPaginateNot(status, storeId, userLoginInfo, couponStatus, 4);
+            List<LifeDiscountCouponVo> list = lifeDiscountCouponService.getStoreAllCouponListPaginateNot(status, storeId, userLoginInfo, couponStatus, 4, null);
             return R.data(list);
         } catch (Exception e) {
             log.error("LifeDiscountCouponController.getMyCreatedVoucherList ERROR Msg={}", e.getMessage());

+ 35 - 17
alien-store/src/main/java/shop/alien/store/controller/LifeDiscountCouponStoreFriendController.java

@@ -16,6 +16,7 @@ import shop.alien.store.annotation.TrackEvent;
 import shop.alien.store.service.LifeDiscountCouponStoreFriendService;
 import shop.alien.util.common.TokenInfo;
 import springfox.documentation.annotations.ApiIgnore;
+import org.apache.commons.lang3.StringUtils;
 
 import java.util.List;
 import java.util.Map;
@@ -160,43 +161,60 @@ 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("查询赠券规则")
-    @ApiImplicitParams({@ApiImplicitParam(name = "storeId", value = "当前登录店铺id", dataType = "String", paramType = "query", required = true)
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "storeId", value = "当前登录店铺id", dataType = "String", paramType = "query", required = true),
+            @ApiImplicitParam(name = "acName", value = "活动名称(模糊查询,可选)", dataType = "String", paramType = "query", required = false),
+            @ApiImplicitParam(name = "status", value = "状态:0-启用,1-禁用(可选)", dataType = "String", paramType = "query", required = false)
     })
     @GetMapping("/getRuleList")
-    public R<List<LifeDiscountCouponFriendRuleVo>> getRuleList(@RequestParam(value = "storeId") String storeId, String acName, String status) {
-        log.info("LifeDiscountCouponStoreFriendController.getRuleList?storeId={},name={},status={}", storeId, acName, status);
-        return R.data(lifeDiscountCouponStoreFriendService.getRuleList(storeId, acName, status));
+    public R<List<LifeDiscountCouponFriendRuleVo>> getRuleList(@RequestParam(value = "storeId") String storeId,
+                                                                @RequestParam(value = "acName", required = false) String acName,
+                                                                @RequestParam(value = "status", required = false) String status) {
+        log.info("LifeDiscountCouponStoreFriendController.getRuleList?storeId={},acName={},status={}", storeId, acName, status);
+        try {
+            if (StringUtils.isEmpty(storeId)) {
+                return R.fail("店铺ID不能为空");
+            }
+            return R.data(lifeDiscountCouponStoreFriendService.getRuleList(storeId, acName, status));
+        } catch (Exception e) {
+            log.error("LifeDiscountCouponStoreFriendController.getRuleList ERROR Msg={}", e.getMessage(), e);
+            return R.fail("查询失败:" + e.getMessage());
+        }
     }
 
-    @ApiOperation("查询赠券记录(商户送给商户券)。queryType=1查询我收到的,queryType=2查询我送出的。type=4仅代金券,不传返回全部(优惠券+代金券)")
+    @ApiOperation("查询赠券记录(商户送给商户券)。queryType=1查询我收到的,queryType=2查询我送出的。type=4仅代金券,不传返回全部(优惠券+代金券)。couponType=1仅满减券,couponType=2仅折扣券,不传返回全部优惠券")
     @ApiImplicitParams({
             @ApiImplicitParam(name = "storeUserId", value = "当前登录店铺用户id(必填)", dataType = "String", paramType = "query", required = true),
             @ApiImplicitParam(name = "queryType", value = "查询类型:1=我收到的(所有好友赠送给我的),2=我送出的(我送给所有好友的)(必填)", dataType = "Integer", paramType = "query", required = true),
             @ApiImplicitParam(name = "storeName", value = "店铺名称模糊查询(可选)", dataType = "String", paramType = "query", required = false),
-            @ApiImplicitParam(name = "type", value = "4=仅代金券,不传=全部(优惠券+代金券)(可选)", dataType = "Integer", 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("/getReceivedSendFriendCouponList")
     public R<List<LifeDiscountCouponFriendRuleVo>> getReceivedSendFriendCouponList(@RequestParam(value = "storeUserId") String storeUserId,
                                                                                    @RequestParam(value = "queryType") Integer queryType,
                                                                                    @RequestParam(value = "storeName", required = false) String storeName,
-                                                                                   @RequestParam(value = "type", required = false) Integer type) {
-        log.info("LifeDiscountCouponStoreFriendController.getReceivedSendFriendCouponList?storeUserId={},queryType={},storeName={},type={}", storeUserId, queryType, storeName, type);
-        return R.data(lifeDiscountCouponStoreFriendService.getReceivedSendFriendCouponList(storeUserId, queryType, storeName, type));
+                                                                                   @RequestParam(value = "type", required = false) Integer type,
+                                                                                   @RequestParam(value = "couponType", required = false) Integer couponType) {
+        log.info("LifeDiscountCouponStoreFriendController.getReceivedSendFriendCouponList?storeUserId={},queryType={},storeName={},type={},couponType={}", storeUserId, queryType, storeName, type, couponType);
+        return R.data(lifeDiscountCouponStoreFriendService.getReceivedSendFriendCouponList(storeUserId, queryType, storeName, type, couponType));
 
 
 

+ 2 - 2
alien-store/src/main/java/shop/alien/store/controller/StoreCuisineController.java

@@ -162,7 +162,7 @@ public class StoreCuisineController {
                 
                 LambdaUpdateWrapper<StoreCuisine> auditUpdateWrapper = new LambdaUpdateWrapper<>();
                 auditUpdateWrapper.eq(StoreCuisine::getId, savedCuisine.getId());
-                auditUpdateWrapper.set(StoreCuisine::getRejectionReason, null);
+                auditUpdateWrapper.set(StoreCuisine::getRejectionReason, auditResult.getFailureReason());
                 auditUpdateWrapper.set(StoreCuisine::getAuditTime, new Date());
                 
                 if (auditResult.isPassed()) {
@@ -290,7 +290,7 @@ public class StoreCuisineController {
                 
                 LambdaUpdateWrapper<StoreCuisine> auditUpdateWrapper = new LambdaUpdateWrapper<>();
                 auditUpdateWrapper.eq(StoreCuisine::getId, updatedCuisine.getId());
-                auditUpdateWrapper.set(StoreCuisine::getRejectionReason, null);
+                auditUpdateWrapper.set(StoreCuisine::getRejectionReason, auditResult.getFailureReason());
                 auditUpdateWrapper.set(StoreCuisine::getAuditTime, new Date());
                 
                 if (auditResult.isPassed()) {

+ 111 - 26
alien-store/src/main/java/shop/alien/store/controller/StoreCustomerServiceController.java

@@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import io.swagger.annotations.*;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
+import org.springframework.util.CollectionUtils;
+import org.springframework.util.StringUtils;
 import org.springframework.web.bind.annotation.*;
 import shop.alien.entity.result.R;
 import shop.alien.entity.store.AiIntelligentAssistant;
@@ -36,11 +38,19 @@ public class StoreCustomerServiceController {
     @ApiImplicitParams({@ApiImplicitParam(name = "question", value = "问题关键字", dataType = "String", paramType = "query", required = true)})
     @GetMapping("/getByQuestion")
     public R<StoreCustomerService> getByQuestion(@RequestParam String question) {
-        StoreCustomerService result = storeCustomerServiceService.getByQuestion(question);
-        if (null == result) {
-            return R.fail("暂未搜索到相应答案");
+        try {
+            if (!StringUtils.hasText(question)) {
+                return R.fail("问题关键字不能为空");
+            }
+            StoreCustomerService result = storeCustomerServiceService.getByQuestion(question);
+            if (result == null) {
+                return R.fail("暂未搜索到相应答案");
+            }
+            return R.data(result);
+        } catch (Exception e) {
+            log.error("StoreCustomerServiceController.getByQuestion ERROR, question={}, error={}", question, e.getMessage(), e);
+            return R.fail("查询失败");
         }
-        return R.data(result);
     }
 
     @ApiOperation("获取随机问题")
@@ -49,8 +59,19 @@ public class StoreCustomerServiceController {
     , @ApiImplicitParam(name = "limit", value = "数量", dataType = "Integer", paramType = "query", required = true)})
     @GetMapping("/getRandList")
     public R<List<StoreCustomerService>> getRandList(@RequestParam String type, @RequestParam Integer limit) {
-        List<StoreCustomerService> result = storeCustomerServiceService.getRandList(type,limit);
-        return R.data(result);
+        try {
+            if (!StringUtils.hasText(type)) {
+                return R.fail("类型不能为空");
+            }
+            if (limit == null || limit <= 0) {
+                return R.fail("数量必须大于0");
+            }
+            List<StoreCustomerService> result = storeCustomerServiceService.getRandList(type, limit);
+            return R.data(result);
+        } catch (Exception e) {
+            log.error("StoreCustomerServiceController.getRandList ERROR, type={}, limit={}, error={}", type, limit, e.getMessage(), e);
+            return R.fail("查询失败");
+        }
     }
 
     @ApiOperation("删除问题")
@@ -58,9 +79,17 @@ public class StoreCustomerServiceController {
     @ApiImplicitParams({@ApiImplicitParam(name = "id", value = "id", dataType = "String", paramType = "query", required = true)
             })
     @GetMapping("/delStoreCustomerService")
-    public R delStoreCustomerService(@RequestParam String id) {
-        storeCustomerServiceService.delStoreCustomerService(id);
-        return R.data("删除成功");
+    public R<String> delStoreCustomerService(@RequestParam String id) {
+        try {
+            if (!StringUtils.hasText(id)) {
+                return R.fail("id不能为空");
+            }
+            storeCustomerServiceService.delStoreCustomerService(id);
+            return R.data("删除成功");
+        } catch (Exception e) {
+            log.error("StoreCustomerServiceController.delStoreCustomerService ERROR, id={}, error={}", id, e.getMessage(), e);
+            return R.fail("删除失败");
+        }
     }
 
     @ApiOperation("中台-问题列表")
@@ -71,21 +100,40 @@ public class StoreCustomerServiceController {
             @ApiImplicitParam(name = "type", value = "类型(1/商家/2用户)", dataType = "String", paramType = "query", required = false),
     })
     @GetMapping("/getStoreCustomerServicePage")
-    private R<IPage<StoreCustomerService>> getStoreCustomerServicePage(@RequestParam(value = "page", defaultValue = "1") int page,
+    public R<IPage<StoreCustomerService>> getStoreCustomerServicePage(@RequestParam(value = "page", defaultValue = "1") int page,
                                                        @RequestParam(value = "size", defaultValue = "10") int size,
                                                        @RequestParam(value = "question", required = false) String question,
                                                        @RequestParam(value = "type", required = false) String type) {
-        log.info("StoreCustomerServiceController.getStoreCustomerServicePage?page={},size={},question={},type={}", page, size, question, type);
-        return R.data(storeCustomerServiceService.getStoreCustomerServicePage(page, size, question, type));
+        try {
+            if (page < 1) {
+                page = 1;
+            }
+            if (size < 1 || size > 100) {
+                size = 10;
+            }
+            log.info("StoreCustomerServiceController.getStoreCustomerServicePage?page={},size={},question={},type={}", page, size, question, type);
+            return R.data(storeCustomerServiceService.getStoreCustomerServicePage(page, size, question, type));
+        } catch (Exception e) {
+            log.error("StoreCustomerServiceController.getStoreCustomerServicePage ERROR, page={}, size={}, error={}", page, size, e.getMessage(), e);
+            return R.fail("查询失败");
+        }
     }
 
     @ApiOperation("中台-保存问题")
     @ApiOperationSupport(order = 5)
     @PostMapping("/saveStoreCustomerService")
     public R<StoreCustomerService> saveStoreCustomerService(@RequestBody StoreCustomerService storeCustomerService) {
-        log.info("StoreCustomerServiceController.saveStoreCustomerService?storeCustomerService={}", storeCustomerService.toString());
-        StoreCustomerService saved = storeCustomerServiceService.saveStoreCustomerService(storeCustomerService);
-        return R.data(saved);
+        try {
+            if (storeCustomerService == null) {
+                return R.fail("参数不能为空");
+            }
+            log.info("StoreCustomerServiceController.saveStoreCustomerService?storeCustomerService={}", storeCustomerService);
+            StoreCustomerService saved = storeCustomerServiceService.saveStoreCustomerService(storeCustomerService);
+            return R.data(saved);
+        } catch (Exception e) {
+            log.error("StoreCustomerServiceController.saveStoreCustomerService ERROR, storeCustomerService={}, error={}", storeCustomerService, e.getMessage(), e);
+            return R.fail("保存失败");
+        }
     }
 
     @ApiOperation("id查询问题")
@@ -94,28 +142,65 @@ public class StoreCustomerServiceController {
     })
     @GetMapping("/getById")
     public R<StoreCustomerService> getById(@RequestParam String id) {
-        log.info("StoreCustomerServiceController.getById?id={}", id);
-        StoreCustomerService saved = storeCustomerServiceService.getById(id);
-        return R.data(saved);
+        try {
+            if (!StringUtils.hasText(id)) {
+                return R.fail("id不能为空");
+            }
+            log.info("StoreCustomerServiceController.getById?id={}", id);
+            StoreCustomerService saved = storeCustomerServiceService.getById(id);
+            if (saved == null) {
+                return R.fail("未找到对应的问题");
+            }
+            return R.data(saved);
+        } catch (Exception e) {
+            log.error("StoreCustomerServiceController.getById ERROR, id={}, error={}", id, e.getMessage(), e);
+            return R.fail("查询失败");
+        }
     }
 
     @ApiOperation("保存聊天")
-    @ApiOperationSupport(order = 5)
+    @ApiOperationSupport(order = 7)
     @PostMapping("/saveAiIntelligentAssistant")
     public R<List<AiIntelligentAssistant>> saveAiIntelligentAssistant(@RequestBody List<AiIntelligentAssistant> aiIntelligentAssistants) {
-        log.info("StoreCustomerServiceController.saveAiIntelligentAssistant?aiIntelligentAssistants={}", aiIntelligentAssistants.toString());
-        List<AiIntelligentAssistant> saved = storeCustomerServiceService.saveAiIntelligentAssistant(aiIntelligentAssistants);
-        return R.data(saved);
+        try {
+            if (CollectionUtils.isEmpty(aiIntelligentAssistants)) {
+                return R.fail("聊天记录不能为空");
+            }
+            log.info("StoreCustomerServiceController.saveAiIntelligentAssistant?size={}", aiIntelligentAssistants.size());
+            List<AiIntelligentAssistant> saved = storeCustomerServiceService.saveAiIntelligentAssistant(aiIntelligentAssistants);
+            return R.data(saved);
+        } catch (Exception e) {
+            log.error("StoreCustomerServiceController.saveAiIntelligentAssistant ERROR, size={}, error={}", 
+                    aiIntelligentAssistants != null ? aiIntelligentAssistants.size() : 0, e.getMessage(), e);
+            return R.fail("保存失败");
+        }
     }
 
     @ApiOperation("查询聊天记录")
-    @ApiOperationSupport(order = 2)
+    @ApiOperationSupport(order = 8)
     @ApiImplicitParams({@ApiImplicitParam(name = "userId", value = "用户id)", dataType = "String", paramType = "query", required = true)
             , @ApiImplicitParam(name = "time", value = "时间", dataType = "String", paramType = "query", required = true)
             , @ApiImplicitParam(name = "talkSource", value = "1平台使用/2商户运营", dataType = "Integer", paramType = "query", required = true)})
     @GetMapping("/selectAiIntelligentAssistant")
-    public R<List<AiIntelligentAssistant>> selectAiIntelligentAssistant(@RequestParam String userId, @RequestParam String time,@RequestParam Integer talkSource) {
-        List<AiIntelligentAssistant> result = storeCustomerServiceService.selectAiIntelligentAssistant(userId,time,talkSource);
-        return R.data(result);
+    public R<List<AiIntelligentAssistant>> selectAiIntelligentAssistant(@RequestParam String userId, 
+                                                                         @RequestParam String time,
+                                                                         @RequestParam Integer talkSource) {
+        try {
+            if (!StringUtils.hasText(userId)) {
+                return R.fail("用户id不能为空");
+            }
+            if (!StringUtils.hasText(time)) {
+                return R.fail("时间参数不能为空");
+            }
+            if (talkSource == null || (talkSource != 1 && talkSource != 2)) {
+                return R.fail("talkSource参数错误,必须为1或2");
+            }
+            List<AiIntelligentAssistant> result = storeCustomerServiceService.selectAiIntelligentAssistant(userId, time, talkSource);
+            return R.data(result);
+        } catch (Exception e) {
+            log.error("StoreCustomerServiceController.selectAiIntelligentAssistant ERROR, userId={}, time={}, talkSource={}, error={}", 
+                    userId, time, talkSource, e.getMessage(), e);
+            return R.fail("查询失败");
+        }
     }
 }

+ 2 - 2
alien-store/src/main/java/shop/alien/store/controller/StorePriceController.java

@@ -192,7 +192,7 @@ public class StorePriceController {
                 
                 LambdaUpdateWrapper<StorePrice> auditUpdateWrapper = new LambdaUpdateWrapper<>();
                 auditUpdateWrapper.eq(StorePrice::getId, savedPrice.getId());
-                auditUpdateWrapper.set(StorePrice::getRejectionReason, null);
+                auditUpdateWrapper.set(StorePrice::getRejectionReason, auditResult.getFailureReason());
                 auditUpdateWrapper.set(StorePrice::getAuditTime, new Date());
                 
                 if (auditResult.isPassed()) {
@@ -321,7 +321,7 @@ public class StorePriceController {
                 
                 LambdaUpdateWrapper<StorePrice> auditUpdateWrapper = new LambdaUpdateWrapper<>();
                 auditUpdateWrapper.eq(StorePrice::getId, updatedPrice.getId());
-                auditUpdateWrapper.set(StorePrice::getRejectionReason, null);
+                auditUpdateWrapper.set(StorePrice::getRejectionReason, auditResult.getFailureReason());
                 auditUpdateWrapper.set(StorePrice::getAuditTime, new Date());
                 
                 if (auditResult.isPassed()) {

+ 9 - 6
alien-store/src/main/java/shop/alien/store/service/LifeDiscountCouponService.java

@@ -53,30 +53,33 @@ 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);
 
     /**
      * 获取所有优惠券列表(不分页)
      * @param type 类型:1-优惠券(默认),4-代金券
      */
-    List<LifeDiscountCouponVo> getStoreAllCouponListPaginateNot(String status, String storeId, UserLoginInfo userLoginInfo, int couponStatus, Integer type);
+    List<LifeDiscountCouponVo> getStoreAllCouponListPaginateNot(String status, String storeId, UserLoginInfo userLoginInfo, int couponStatus, Integer type, Integer couponType);
 
     /**
      * 获取优惠券规则

+ 7 - 2
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);
 
@@ -68,9 +72,10 @@ public interface LifeDiscountCouponStoreFriendService extends IService<LifeDisco
      * @param queryType 查询类型:1=我收到的(所有好友赠送给我的),2=我送出的(我送给所有好友的)(必填)
      * @param storeName 店铺名称模糊查询(可选)
      * @param type 4=仅代金券,不传=全部(优惠券+代金券)(可选)
+     * @param couponType 优惠券类型:1=仅满减券,2=仅折扣券,不传=全部优惠券(可选,仅当type不为4时有效)
      * @return 赠券列表
      */
-    List<LifeDiscountCouponFriendRuleVo> getReceivedSendFriendCouponList(String storeUserId, Integer queryType, String storeName, Integer type);
+    List<LifeDiscountCouponFriendRuleVo> getReceivedSendFriendCouponList(String storeUserId, Integer queryType, String storeName, Integer type, Integer couponType);
 
     /**
      * 好评送券:用户好评且AI审核通过后,按运营活动配置的优惠券/代金券ID发放到用户券包,发放成功后扣减库存;按券类型发送对应通知。

+ 75 - 46
alien-store/src/main/java/shop/alien/store/service/LifeUserDynamicsService.java

@@ -392,68 +392,97 @@ public class LifeUserDynamicsService extends ServiceImpl<LifeUserDynamicsMapper,
     }
 
     public List<LifeUserDynamicsVo> getStoreUserDynamics(String storePhone, String userType, String loginPhone) {
-            LambdaQueryWrapper<LifeUserDynamics> lambdaQueryWrapper = new LambdaQueryWrapper<>();
-            lambdaQueryWrapper.eq(LifeUserDynamics :: getPhoneId, storePhone);
-            List<LifeUserDynamics> lifeUserDynamics = lifeUserDynamicsMapper.selectList(lambdaQueryWrapper);
+            // 动态列表与点赞记录并行查询
+            CompletableFuture<List<LifeUserDynamics>> dynamicsFuture = CompletableFuture.supplyAsync(() -> {
+                LambdaQueryWrapper<LifeUserDynamics> lambdaQueryWrapper = new LambdaQueryWrapper<>();
+                lambdaQueryWrapper.eq(LifeUserDynamics::getPhoneId, storePhone);
+                return lifeUserDynamicsMapper.selectList(lambdaQueryWrapper);
+            });
+            CompletableFuture<Set<String>> likeSetFuture = CompletableFuture.supplyAsync(() -> {
+                LambdaQueryWrapper<LifeLikeRecord> likeWrapper = new LambdaQueryWrapper<>();
+                likeWrapper.eq(LifeLikeRecord::getType, "2");
+                if (userType.equals("1")) {
+                    likeWrapper.eq(LifeLikeRecord::getDianzanId, "user_" + loginPhone);
+                } else {
+                    likeWrapper.eq(LifeLikeRecord::getDianzanId, "store_" + loginPhone);
+                }
+                List<LifeLikeRecord> lifeLikeList = lifeLikeRecordMapper.selectList(likeWrapper);
+                return lifeLikeList.stream().map(LifeLikeRecord::getHuifuId).collect(Collectors.toSet());
+            });
+
+            List<LifeUserDynamics> lifeUserDynamics = dynamicsFuture.join();
+            Set<String> likeSet = likeSetFuture.join();
+
             List<LifeUserDynamicsVo> lifeUserDynamicsVos = lifeUserDynamics.stream()
                 .map(dynamics -> {
                     LifeUserDynamicsVo vo = new LifeUserDynamicsVo();
                     BeanUtils.copyProperties(dynamics, vo);
-                    // 特殊字段处理
                     return vo;
                 })
                 .collect(Collectors.toList());
 
-            // 查询我的点赞记录,构建点赞ID列表
-            LambdaQueryWrapper<LifeLikeRecord> likeWrapper = new LambdaQueryWrapper<>();
-            likeWrapper.eq(LifeLikeRecord::getType, "2");
-            if(userType.equals("1")){
-                likeWrapper.eq(LifeLikeRecord::getDianzanId, "user_"+loginPhone);
-            }else{
-                likeWrapper.eq(LifeLikeRecord::getDianzanId, "store_"+loginPhone);
-            }
-            List<LifeLikeRecord> lifeLikeList = lifeLikeRecordMapper.selectList(likeWrapper);
-            List<String> likeList = lifeLikeList.stream().map(LifeLikeRecord::getHuifuId).collect(Collectors.toList());
-         for (LifeUserDynamicsVo vo : lifeUserDynamicsVos) {
-            if (likeList.contains(String.valueOf(vo.getId()))) {
-                vo.setIsLike("1");
-            } else {
-                vo.setIsLike("0");
-            }
-            
-            // 查询用户名称和头像
-            String phoneId = vo.getPhoneId();
-            if (StringUtils.hasText(phoneId)) {
-                if (phoneId.startsWith("user_")) {
-                    // 用户类型
-                    String userPhone = phoneId.substring(5);
-                    LifeUser lifeUser = lifeUserService.getUserByPhone(userPhone);
-                    if (lifeUser != null) {
-                        vo.setUserName(lifeUser.getUserName());
-                        vo.setUserImage(lifeUser.getUserImage());
+            // 收集所有 phoneId,批量查询用户/商户信息,消除 N+1
+            Set<String> userPhones = new HashSet<>();
+            Set<String> storePhones = new HashSet<>();
+            for (LifeUserDynamicsVo vo : lifeUserDynamicsVos) {
+                String phoneId = vo.getPhoneId();
+                if (StringUtils.hasText(phoneId)) {
+                    if (phoneId.startsWith("user_")) {
+                        userPhones.add(phoneId.substring(5));
+                    } else if (phoneId.startsWith("store_")) {
+                        storePhones.add(phoneId.substring(6));
                     }
-                } else if (phoneId.startsWith("store_")) {
-                    // 商户类型
-                    String storePhoneNum = phoneId.substring(6);
-                    StoreUserVo storeUser = storeUserService.getUserByPhone(storePhoneNum);
-                    if (storeUser != null) {
-                        // 查询店铺信息获取店铺名称
-                        if (storeUser.getStoreId() != null) {
-                            StoreInfo storeInfo = storeInfoMapper.selectById(storeUser.getStoreId());
-                            if (storeInfo != null && StringUtils.hasText(storeInfo.getStoreName())) {
-                                vo.setUserName(storeInfo.getStoreName());
+                }
+            }
+
+            // 批量查询 LifeUser、StoreUser
+            Map<String, LifeUser> userByPhoneMap = CollectionUtils.isEmpty(userPhones) ? Collections.emptyMap()
+                    : lifeUserMapper.selectList(new LambdaQueryWrapper<LifeUser>().in(LifeUser::getUserPhone, userPhones))
+                            .stream().collect(Collectors.toMap(LifeUser::getUserPhone, u -> u, (a, b) -> a));
+            List<StoreUser> storeUserList = CollectionUtils.isEmpty(storePhones) ? Collections.emptyList()
+                    : storeUserService.list(new LambdaQueryWrapper<StoreUser>().in(StoreUser::getPhone, storePhones));
+            Map<String, StoreUser> storeUserByPhoneMap = storeUserList.stream().collect(Collectors.toMap(StoreUser::getPhone, u -> u, (a, b) -> a));
+
+            // 批量查询店铺信息
+            List<Integer> storeIds = storeUserList.stream().map(StoreUser::getStoreId).filter(Objects::nonNull).distinct().collect(Collectors.toList());
+            Map<Integer, StoreInfo> storeInfoMap = CollectionUtils.isEmpty(storeIds) ? Collections.emptyMap()
+                    : storeInfoMapper.selectBatchIds(storeIds).stream().collect(Collectors.toMap(StoreInfo::getId, s -> s, (a, b) -> a));
+
+            for (LifeUserDynamicsVo vo : lifeUserDynamicsVos) {
+                if (likeSet.contains(String.valueOf(vo.getId()))) {
+                    vo.setIsLike("1");
+                } else {
+                    vo.setIsLike("0");
+                }
+
+                String phoneId = vo.getPhoneId();
+                if (StringUtils.hasText(phoneId)) {
+                    if (phoneId.startsWith("user_")) {
+                        String userPhone = phoneId.substring(5);
+                        LifeUser lifeUser = userByPhoneMap.get(userPhone);
+                        if (lifeUser != null) {
+                            vo.setUserName(lifeUser.getUserName());
+                            vo.setUserImage(lifeUser.getUserImage());
+                        }
+                    } else if (phoneId.startsWith("store_")) {
+                        String storePhoneNum = phoneId.substring(6);
+                        StoreUser storeUser = storeUserByPhoneMap.get(storePhoneNum);
+                        if (storeUser != null) {
+                            if (storeUser.getStoreId() != null) {
+                                StoreInfo storeInfo = storeInfoMap.get(storeUser.getStoreId());
+                                if (storeInfo != null && StringUtils.hasText(storeInfo.getStoreName())) {
+                                    vo.setUserName(storeInfo.getStoreName());
+                                } else {
+                                    vo.setUserName(storeUser.getNickName());
+                                }
                             } else {
                                 vo.setUserName(storeUser.getNickName());
                             }
-                        } else {
-                            vo.setUserName(storeUser.getNickName());
+                            vo.setUserImage(storeUser.getHeadImg());
                         }
-                        // 设置商户头像
-                        vo.setUserImage(storeUser.getHeadImg());
                     }
                 }
             }
-        }
             return lifeUserDynamicsVos;
     }
 

+ 36 - 2
alien-store/src/main/java/shop/alien/store/service/LifeUserOrderService.java

@@ -803,8 +803,42 @@ public class LifeUserOrderService extends ServiceImpl<LifeUserOrderMapper, LifeU
             lifeDiscountCouponUser.setUseTime(date);
             lifeDiscountCouponUserMapper.updateById(lifeDiscountCouponUser);
             lifeDiscountCoupon = lifeDiscountCouponMapper.selectById(lifeDiscountCouponUser.getCouponId());
-            avgDiscountCouponPrice = lifeDiscountCoupon.getNominalValue().divide(countDecimal, 2, RoundingMode.DOWN);
-            avgDiscountCouponLastPrice = lifeDiscountCoupon.getNominalValue().subtract(avgDiscountCouponPrice.multiply(countDecimal.subtract(BigDecimal.ONE)));
+            
+            // 根据优惠券类型计算优惠金额
+            Integer couponType = lifeDiscountCoupon.getCouponType();
+            if (couponType == null || couponType == 1) {
+                // 满减券(默认类型,兼容旧数据):直接使用面值作为减免金额
+                BigDecimal nominalValue = lifeDiscountCoupon.getNominalValue();
+                if (nominalValue == null) {
+                    nominalValue = BigDecimal.ZERO;
+                }
+                avgDiscountCouponPrice = nominalValue.divide(countDecimal, 2, RoundingMode.DOWN);
+                avgDiscountCouponLastPrice = nominalValue.subtract(avgDiscountCouponPrice.multiply(countDecimal.subtract(BigDecimal.ONE)));
+            } else if (couponType == 2) {
+                // 折扣券:根据订单金额和折扣率计算优惠金额
+                // 注意:totalPrice 是使用优惠券后的价格,需要反推原始价格
+                // 如果折扣率为 discountRate(例如80表示8折),则:
+                // 原始价格 = 优惠后价格 / (discountRate / 100)
+                // 优惠金额 = 原始价格 - 优惠后价格
+                BigDecimal discountRate = lifeDiscountCoupon.getDiscountRate();
+                if (discountRate == null || discountRate.compareTo(BigDecimal.ZERO) <= 0 || discountRate.compareTo(new BigDecimal(100)) > 0) {
+                    // 折扣率无效,使用0作为优惠金额
+                    avgDiscountCouponPrice = BigDecimal.ZERO;
+                    avgDiscountCouponLastPrice = BigDecimal.ZERO;
+                } else {
+                    // 计算原始订单总金额(使用优惠券前)
+                    BigDecimal originalTotalPrice = totalPrice.divide(discountRate.divide(new BigDecimal(100), 4, RoundingMode.HALF_UP), 2, RoundingMode.HALF_UP);
+                    // 计算总优惠金额
+                    BigDecimal totalDiscountAmount = originalTotalPrice.subtract(totalPrice);
+                    // 平均分配到每个券上
+                    avgDiscountCouponPrice = totalDiscountAmount.divide(countDecimal, 2, RoundingMode.DOWN);
+                    avgDiscountCouponLastPrice = totalDiscountAmount.subtract(avgDiscountCouponPrice.multiply(countDecimal.subtract(BigDecimal.ONE)));
+                }
+            } else {
+                // 未知类型,使用0作为优惠金额
+                avgDiscountCouponPrice = BigDecimal.ZERO;
+                avgDiscountCouponLastPrice = BigDecimal.ZERO;
+            }
         }
 
         for (int i = 0; i < buyCount; i++) {

Разница между файлами не показана из-за своего большого размера
+ 568 - 247
alien-store/src/main/java/shop/alien/store/service/impl/LifeDiscountCouponServiceImpl.java


+ 97 - 10
alien-store/src/main/java/shop/alien/store/service/impl/LifeDiscountCouponStoreFriendServiceImpl.java

@@ -30,6 +30,7 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Date;
 import java.util.HashMap;
+import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.stream.Collectors;
@@ -536,7 +537,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 +555,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 {
@@ -564,35 +569,59 @@ public class LifeDiscountCouponStoreFriendServiceImpl extends ServiceImpl<LifeDi
 
     @Override
     public List<LifeDiscountCouponFriendRuleVo> getRuleList(String storeId, String acName, String status) {
+        // 参数校验
         if (StringUtils.isEmpty(storeId)) {
+            log.warn("getRuleList 参数错误:storeId 不能为空");
             return new ArrayList<>();
         }
+        
+        // 查询规则列表(一个规则可能关联多个优惠券,会返回多条记录)
         List<LifeDiscountCouponFriendRuleVo> ruleList = lifeDiscountCouponFriendRuleDetailMapper.getRuleList(storeId);
         if (ruleList == null) {
             ruleList = new ArrayList<>();
         }
+        
+        // 计算状态:根据结束日期判断活动是否已结束
+        // 状态:0-启用(活动进行中),1-禁用(活动已结束)
         if (ObjectUtils.isNotEmpty(ruleList)) {
             Date now = new Date();
             ruleList.forEach(i -> {
                 if (i.getEndDate() != null) {
+                    // 如果结束日期在当前时间之后,活动进行中(启用)
+                    // 如果结束日期在当前时间之前或等于,活动已结束(禁用)
                     i.setStatus(i.getEndDate().after(now) ? "0" : "1");
                 } else {
-                    i.setStatus(null);
+                    // 如果结束日期为null,视为永久有效,状态为启用
+                    i.setStatus("0");
                 }
             });
         }
+        
+        // 按规则ID分组去重:同一个规则ID只保留第一条记录(避免一个规则关联多个优惠券时重复展示)
+        Map<Integer, LifeDiscountCouponFriendRuleVo> ruleMap = new LinkedHashMap<>();
+        for (LifeDiscountCouponFriendRuleVo rule : ruleList) {
+            if (rule.getId() != null && !ruleMap.containsKey(rule.getId())) {
+                ruleMap.put(rule.getId(), rule);
+            }
+        }
+        ruleList = new ArrayList<>(ruleMap.values());
+        
+        // 根据活动名称过滤(模糊查询)
         if (StringUtils.isNotEmpty(acName)) {
-            String name = acName;
+            String name = acName.trim();
             ruleList = ruleList.stream()
                     .filter(i -> i.getAcName() != null && i.getAcName().contains(name))
                     .collect(Collectors.toList());
         }
+        
+        // 根据状态过滤
         if (StringUtils.isNotEmpty(status)) {
-            String s = status;
+            String s = status.trim();
             ruleList = ruleList.stream()
                     .filter(i -> i.getStatus() != null && i.getStatus().equals(s))
                     .collect(Collectors.toList());
         }
+        
         return ruleList;
     }
 
@@ -604,6 +633,17 @@ public class LifeDiscountCouponStoreFriendServiceImpl extends ServiceImpl<LifeDi
         if (ObjectUtils.isNotEmpty(lifeDiscountCouponFriendRule)) {
             List<LifeDiscountCouponFriendRuleDetailVo> lifeDiscountCouponFriendRuleDetails = lifeDiscountCouponFriendRuleDetailMapper.getDetailList(lifeDiscountCouponFriendRule.getId().toString());
             ruleVo.setLifeDiscountCouponFriendRuleDetailVos(lifeDiscountCouponFriendRuleDetails);
+            
+            // 如果规则表中没有 couponType,尝试从关联的优惠券中获取
+            if (ruleVo.getCouponType() == null && ObjectUtils.isNotEmpty(lifeDiscountCouponFriendRuleDetails)) {
+                // 查找第一个优惠券(非代金券)的 couponType
+                for (LifeDiscountCouponFriendRuleDetailVo detail : lifeDiscountCouponFriendRuleDetails) {
+                    if (detail.getCouponId() != null && detail.getCouponType() != null) {
+                        ruleVo.setCouponType(detail.getCouponType());
+                        break;
+                    }
+                }
+            }
         }
         return ruleVo;
     }
@@ -614,7 +654,7 @@ public class LifeDiscountCouponStoreFriendServiceImpl extends ServiceImpl<LifeDi
     private static final Integer TYPE_VOUCHER = 4;
 
     @Override
-    public List<LifeDiscountCouponFriendRuleVo> getReceivedSendFriendCouponList(String storeUserId, Integer queryType, String storeName, Integer type) {
+    public List<LifeDiscountCouponFriendRuleVo> getReceivedSendFriendCouponList(String storeUserId, Integer queryType, String storeName, Integer type, Integer couponType) {
         // 参数校验
         if (StringUtils.isEmpty(storeUserId)) {
             log.warn("getReceivedSendFriendCouponList 参数错误:storeUserId 不能为空");
@@ -624,6 +664,11 @@ public class LifeDiscountCouponStoreFriendServiceImpl extends ServiceImpl<LifeDi
             log.warn("getReceivedSendFriendCouponList 参数错误:queryType 必须为 1 或 2,当前值={}", queryType);
             return new ArrayList<>();
         }
+        // 校验couponType参数(1=满减券,2=折扣券)
+        if (couponType != null && couponType != 1 && couponType != 2) {
+            log.warn("getReceivedSendFriendCouponList 参数错误:couponType 必须为 1(满减券)或 2(折扣券),当前值={}", couponType);
+            return new ArrayList<>();
+        }
 
         // 判断是否仅查询代金券
         boolean voucherOnly = TYPE_VOUCHER.equals(type);
@@ -637,7 +682,7 @@ public class LifeDiscountCouponStoreFriendServiceImpl extends ServiceImpl<LifeDi
         // queryType = 2: 我送出的(我送给所有好友的)-> friend_store_user_id = 我的店铺用户ID(我是送券的用户)
         boolean isReceivedByMe = (queryType == 1);
 
-        return queryCouponList(isReceivedByMe, storeUserId, storeName, type, voucherOnly);
+        return queryCouponList(isReceivedByMe, storeUserId, storeName, type, voucherOnly, couponType);
     }
 
     /**
@@ -648,9 +693,10 @@ public class LifeDiscountCouponStoreFriendServiceImpl extends ServiceImpl<LifeDi
      * @param storeName       店铺名称(模糊查询)
      * @param type            类型参数(4=代金券,其他=优惠券,null=全部)
      * @param voucherOnly     是否仅查询代金券
+     * @param couponType      优惠券类型(1=满减券,2=折扣券,null=全部优惠券)
      * @return 赠券列表
      */
-    private List<LifeDiscountCouponFriendRuleVo> queryCouponList(boolean isReceivedByMe, String storeUserId, String storeName, Integer type, boolean voucherOnly) {
+    private List<LifeDiscountCouponFriendRuleVo> queryCouponList(boolean isReceivedByMe, String storeUserId, String storeName, Integer type, boolean voucherOnly, Integer couponType) {
         List<LifeDiscountCouponFriendRuleVo> result;
         
         // 仅查询代金券
@@ -664,6 +710,10 @@ public class LifeDiscountCouponStoreFriendServiceImpl extends ServiceImpl<LifeDi
             // 查询优惠券
             QueryWrapper<LifeDiscountCouponFriendRuleVo> couponQuery = buildBaseQueryWrapper(isReceivedByMe, storeUserId, storeName);
             couponQuery.isNotNull("ldcsf.coupon_id");
+            // 如果指定了优惠券类型(满减券或折扣券),添加筛选条件
+            if (couponType != null) {
+                couponQuery.eq("ldc.coupon_type", couponType);
+            }
             List<LifeDiscountCouponFriendRuleVo> couponList = isReceivedByMe
                     ? lifeDiscountCouponStoreFriendMapper.getReceivedSendFriendCouponList(couponQuery)
                     : lifeDiscountCouponStoreFriendMapper.getReceivedSendFriendCouponListwzhy(couponQuery);
@@ -896,6 +946,7 @@ public class LifeDiscountCouponStoreFriendServiceImpl extends ServiceImpl<LifeDi
         int grantedVoucher = 0;
         String couponName = null;  // 优惠券名称
         String voucherName = null;  // 代金券名称
+        LifeDiscountCoupon lifeDiscountCoupon = null;  // 保存优惠券对象,用于通知消息
 
         // 按优惠券ID发放:发放1张,扣减库存,发优惠券通知
         if (couponId != null && couponId > 0) {
@@ -907,7 +958,12 @@ public class LifeDiscountCouponStoreFriendServiceImpl extends ServiceImpl<LifeDi
                     lifeDiscountCouponUser.setCouponId(coupon.getId());
                     lifeDiscountCouponUser.setUserId(commenterUserId);
                     lifeDiscountCouponUser.setReceiveTime(new Date());
-                    lifeDiscountCouponUser.setExpirationTime(coupon.getValidDate());
+                    // 设置过期时间:优先使用validDate,如果为null则使用endDate
+                    LocalDate expirationTime = coupon.getValidDate();
+                    if (expirationTime == null && coupon.getEndDate() != null) {
+                        expirationTime = coupon.getEndDate();
+                    }
+                    lifeDiscountCouponUser.setExpirationTime(expirationTime);
                     lifeDiscountCouponUser.setStatus(Integer.parseInt(DiscountCouponEnum.WAITING_USED.getValue()));
                     lifeDiscountCouponUser.setDeleteFlag(0);
                     lifeDiscountCouponUserMapper.insert(lifeDiscountCouponUser);
@@ -915,6 +971,7 @@ public class LifeDiscountCouponStoreFriendServiceImpl extends ServiceImpl<LifeDi
                     lifeDiscountCouponMapper.updateById(coupon);
                     grantedCoupon = 1;
                     couponName = coupon.getName();  // 保存优惠券名称
+                    lifeDiscountCoupon = coupon;  // 保存优惠券对象,用于通知消息
                 } catch (Exception e) {
                     log.error("发放优惠券失败,userId={}, storeId={}, couponId={}, error={}", userId, storeId, couponId, e.getMessage(), e);
                 }
@@ -953,12 +1010,42 @@ public class LifeDiscountCouponStoreFriendServiceImpl extends ServiceImpl<LifeDi
                 LifeNotice couponNotice = new LifeNotice();
                 couponNotice.setSenderId("system");
                 couponNotice.setReceiverId("user_" + lifeUser.getUserPhone());
-                // 明确标注是优惠券,并包含券的具体名称
-                String couponText = "您对店铺「" + storeInfo.getStoreName() + "」的好评已通过审核,已为您发放优惠券「" + couponName + "」,快去我的券包查看吧~";
+                
+                // 构建优惠券详情信息
+                String couponDetailText = "";
+                if (lifeDiscountCoupon != null) {
+                    Integer couponType = lifeDiscountCoupon.getCouponType();
+                    if (couponType != null && couponType == 2) {
+                        // 折扣券
+                        BigDecimal discountRate = lifeDiscountCoupon.getDiscountRate();
+                        if (discountRate != null) {
+                            couponDetailText = "(" + discountRate + "折";
+                            if (lifeDiscountCoupon.getMinimumSpendingAmount() != null) {
+                                couponDetailText += ",满" + lifeDiscountCoupon.getMinimumSpendingAmount() + "可用";
+                            }
+                            couponDetailText += ")";
+                        }
+                    } else {
+                        // 满减券(默认)
+                        if (lifeDiscountCoupon.getNominalValue() != null) {
+                            couponDetailText = "(满减" + lifeDiscountCoupon.getNominalValue() + "元";
+                            if (lifeDiscountCoupon.getMinimumSpendingAmount() != null) {
+                                couponDetailText += ",满" + lifeDiscountCoupon.getMinimumSpendingAmount() + "可用";
+                            }
+                            couponDetailText += ")";
+                        }
+                    }
+                }
+                
+                // 明确标注是优惠券,并包含券的具体名称和详情
+                String couponText = "您对店铺「" + storeInfo.getStoreName() + "」的好评已通过审核,已为您发放优惠券「" + couponName + "」" + couponDetailText + ",快去我的券包查看吧~";
                 JSONObject couponJson = new JSONObject();
                 couponJson.put("message", couponText);
                 couponJson.put("couponType", "优惠券");  // 明确标识券类型
                 couponJson.put("couponName", couponName);  // 券名称
+                if (lifeDiscountCoupon != null) {
+                    couponJson.put("couponTypeValue", lifeDiscountCoupon.getCouponType());  // 优惠券类型值(1-满减券,2-折扣券)
+                }
                 couponNotice.setContext(couponJson.toJSONString());
                 couponNotice.setNoticeType(1);
                 couponNotice.setTitle("好评送优惠券");  // 标题明确标注是优惠券

+ 110 - 84
alien-store/src/main/java/shop/alien/store/service/impl/StoreClockInServiceImpl.java

@@ -69,6 +69,8 @@ public class StoreClockInServiceImpl extends ServiceImpl<StoreClockInMapper, Sto
 
     private final CommonCommentService commonCommentService;
 
+    private final CommonCommentMapper commonCommentMapper;
+
     private final WebSocketProcess webSocketProcess;
 
     // 初始化线程池
@@ -132,15 +134,19 @@ public class StoreClockInServiceImpl extends ServiceImpl<StoreClockInMapper, Sto
     @Override
     public IPage<StoreClockInVo> getStoreClockInList(Integer userId, int page, int size, String phoneId, int mySelf,Integer storeId) {
         IPage<StoreClockIn> iPage = new Page<>(page, size);
-        // 查询我的点赞
+        
+        // 优化:提前查询所有需要的数据,避免在循环中查询
+        // 查询我的点赞 - 使用Set提高查找效率
         LambdaQueryWrapper<LifeLikeRecord> likeWrapper = new LambdaQueryWrapper<>();
         likeWrapper.eq(LifeLikeRecord::getDianzanId, phoneId);
         likeWrapper.eq(LifeLikeRecord::getType, "5");
         List<LifeLikeRecord> lifeLikeList = lifeLikeRecordMapper.selectList(likeWrapper);
-        List<String> likeList = lifeLikeList.stream().map(LifeLikeRecord::getHuifuId).collect(Collectors.toList());
-
+        Set<String> likeSet = lifeLikeList.stream()
+                .map(LifeLikeRecord::getHuifuId)
+                .collect(Collectors.toSet());
 
-        if(StringUtils.isNotBlank(String.valueOf(storeId)) && !String.valueOf(storeId).equals("null")){
+        // 优化:使用Objects.nonNull判断storeId
+        if (Objects.nonNull(storeId)) {
             IPage<StoreClockInVo> storeClockInIPage1 = storeClockInMapper.getStoreClockInList(iPage, new QueryWrapper<StoreClockIn>()
                     .eq("clock.store_id", storeId)
                     .eq("clock.delete_flag", 0)
@@ -155,15 +161,24 @@ public class StoreClockInServiceImpl extends ServiceImpl<StoreClockInMapper, Sto
                                                     .eq("clock.user_id", userId)
                                     ))
                     .orderByDesc("created_time"));
-            storeClockInIPage1.getRecords().forEach(vo -> {
-                if (likeList.contains(String.valueOf(vo.getId()))) {
-                    vo.setIsLike("1");
-                } else {
-                    vo.setIsLike("0");
-                }
-            });
+            
+            List<StoreClockInVo> records = storeClockInIPage1.getRecords();
+            if (!records.isEmpty()) {
+                // 批量查询评论数量
+                List<Integer> clockInIds = records.stream()
+                        .map(StoreClockInVo::getId)
+                        .collect(Collectors.toList());
+                Map<Integer, Integer> commentCountMap = batchGetCommentCountMap(clockInIds);
+                
+                records.forEach(vo -> {
+                    vo.setIsLike(likeSet.contains(String.valueOf(vo.getId())) ? "1" : "0");
+                    vo.setCommentCount(commentCountMap.getOrDefault(vo.getId(), 0));
+                    setStoreTypeNew(vo);
+                });
+            }
             return storeClockInIPage1;
         }
+        
         QueryWrapper<StoreClockIn> wrapper = new QueryWrapper<>();
         wrapper.eq(1 == mySelf, "clock.user_id", userId);
         wrapper.isNotNull(0 == mySelf, "clock.img_url");
@@ -181,96 +196,107 @@ public class StoreClockInServiceImpl extends ServiceImpl<StoreClockInMapper, Sto
         wrapper.orderByDesc("clock.created_time");
 
         IPage<StoreClockInVo> storeClockInIPage = storeClockInMapper.getStoreClockInList(iPage, wrapper);
+        List<StoreClockInVo> records = storeClockInIPage.getRecords();
+        
+        if (records.isEmpty()) {
+            return storeClockInIPage;
+        }
 
-        // 查询我的关注
+        // 优化:批量查询所有需要的数据
+        // 查询我的关注 - 使用Set提高查找效率
         LambdaQueryWrapper<LifeFans> lifeFansWrapper = new LambdaQueryWrapper<>();
         lifeFansWrapper.eq(LifeFans::getFansId, phoneId);
         List<LifeFans> lifeFansList = lifeFansMapper.selectList(lifeFansWrapper);
-        List<String> followList = lifeFansList.stream().map(LifeFans::getFollowedId).collect(Collectors.toList());
+        Set<String> followSet = lifeFansList.stream()
+                .map(LifeFans::getFollowedId)
+                .collect(Collectors.toSet());
 
-        // 查询我的粉丝
+        // 查询我的粉丝 - 使用Set提高查找效率
         lifeFansWrapper = new LambdaQueryWrapper<>();
         lifeFansWrapper.eq(LifeFans::getFollowedId, phoneId);
         lifeFansList = lifeFansMapper.selectList(lifeFansWrapper);
-        List<String> fansList = lifeFansList.stream().map(LifeFans::getFansId).collect(Collectors.toList());
+        Set<String> fansSet = lifeFansList.stream()
+                .map(LifeFans::getFansId)
+                .collect(Collectors.toSet());
 
-
-
-        // 查询我的收藏
+        // 查询我的收藏 - 使用Set提高查找效率
         LambdaQueryWrapper<LifeCollect> collectWrapper = new LambdaQueryWrapper<>();
         collectWrapper.eq(LifeCollect::getUserId, String.valueOf(userId));
         List<LifeCollect> lifeCollectList = lifeCollectMapper.selectList(collectWrapper);
-        List<String> collectList = lifeCollectList.stream().map(LifeCollect::getStoreId).collect(Collectors.toList());
-
-
-        storeClockInIPage.getRecords().forEach(vo -> {
-            if (followList.contains(vo.getPhoneId())) {
-                vo.setIsFollowThis("1");
-            } else {
-                vo.setIsFollowThis("0");
-            }
-            if (fansList.contains(vo.getPhoneId())) {
-                vo.setIsFollowMe("1");
-            } else {
-                vo.setIsFollowMe("0");
-            }
-            if (likeList.contains(String.valueOf(vo.getId()))) {
-                vo.setIsLike("1");
-            } else {
-                vo.setIsLike("0");
-            }
-            if (collectList.contains(String.valueOf(vo.getStoreId()))) {
-                vo.setIsCollect("1");
-            } else {
-                vo.setIsCollect("0");
-            }
-
-//            // 该用户的打卡记录
-//            LambdaQueryWrapper<StoreClockIn> clockInWrapper = new LambdaQueryWrapper<>();
-//            clockInWrapper.eq(StoreClockIn::getUserId, vo.getUserId());
-//            List<StoreClockIn> clockInList = storeClockInMapper.selectList(clockInWrapper);
-//
-//            Set<Integer> clockInSet = clockInList.stream().map(StoreClockIn::getStoreId).collect(Collectors.toSet());
-//            // 该用户今天打卡记录
-//            Set<Integer> clockInTodaySet = clockInList.stream().filter(item -> item.getCreatedTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDate().equals(LocalDate.now())).map(StoreClockIn::getStoreId).collect(Collectors.toSet());
-//
-//            // 在该店铺的打卡次数
-//            Map<Integer, Long> clockInStoreNumMap = clockInList.stream().collect(Collectors.groupingBy(StoreClockIn::getStoreId, Collectors.counting()));
-//
-//            // 该用户打卡的所有店铺次数(一个店铺只算一次)
-//            int clockInNum = (int) clockInList.stream().map(StoreClockIn::getStoreId).distinct().count();
-//
-//            // 是否在该店铺打过卡
-//            if (clockInSet.contains(vo.getStoreId())){
-//                vo.setClockInStore("1");
-//            } else {
-//                vo.setClockInStore("0");
-//            }
-//            // 今天是否在该店铺打过卡
-//            if (clockInTodaySet.contains(vo.getStoreId())){
-//                vo.setClockInStoreToday("1");
-//            } else {
-//                vo.setClockInStoreToday("0");
-//            }
-//            // 在该店铺打卡次数clockInStoreNum
-//            vo.setClockInStoreNum(clockInStoreNumMap.get(vo.getStoreId()));
-//            // 打卡次数
-//            vo.setClockInNum(clockInNum);
-            Map<String, Object> commitCount = commonCommentService.getCommitCount(vo.getId(), CommentSourceTypeEnum.CLOCK_IN_COMMENT.getType(), userId.toString(), null);
-            vo.setCommentCount(Integer.parseInt(commitCount.get("commentCount").toString()));
-            if(Arrays.asList("酒吧", "KTV", "洗浴汗蒸", "按摩足疗").contains(vo.getBusinessSectionName())){
-                vo.setStoreTypeNew(1);
-            } else if (Arrays.asList("丽人美发", "运动健身").contains(vo.getBusinessSectionName())){
-                vo.setStoreTypeNew(2);
-            } else if (Arrays.asList("特色美食").contains(vo.getBusinessSectionName())){
-                vo.setStoreTypeNew(3);
-            }
+        Set<String> collectSet = lifeCollectList.stream()
+                .map(LifeCollect::getStoreId)
+                .collect(Collectors.toSet());
+
+        // 优化:批量查询评论数量,避免N+1问题
+        List<Integer> clockInIds = records.stream()
+                .map(StoreClockInVo::getId)
+                .collect(Collectors.toList());
+        Map<Integer, Integer> commentCountMap = batchGetCommentCountMap(clockInIds);
+
+        // 优化:使用Set进行O(1)查找,而不是List的O(n)查找
+        records.forEach(vo -> {
+            vo.setIsFollowThis(followSet.contains(vo.getPhoneId()) ? "1" : "0");
+            vo.setIsFollowMe(fansSet.contains(vo.getPhoneId()) ? "1" : "0");
+            vo.setIsLike(likeSet.contains(String.valueOf(vo.getId())) ? "1" : "0");
+            vo.setIsCollect(collectSet.contains(String.valueOf(vo.getStoreId())) ? "1" : "0");
+            vo.setCommentCount(commentCountMap.getOrDefault(vo.getId(), 0));
+            setStoreTypeNew(vo);
         });
 
-
         return storeClockInIPage;
     }
 
+    /**
+     * 批量查询评论数量
+     * 
+     * @param clockInIds 打卡记录ID列表
+     * @return 打卡记录ID -> 评论数量的映射
+     */
+    private Map<Integer, Integer> batchGetCommentCountMap(List<Integer> clockInIds) {
+        if (clockInIds == null || clockInIds.isEmpty()) {
+            return Collections.emptyMap();
+        }
+        
+        try {
+            List<shop.alien.entity.store.vo.CommonCommentVo> commentCountList = 
+                    commonCommentMapper.batchGetCommentCount(
+                            CommentSourceTypeEnum.CLOCK_IN_COMMENT.getType(), 
+                            clockInIds
+                    );
+            
+            return commentCountList.stream()
+                    .filter(item -> item.getSourceId() != null && item.getCommentCount() != null)
+                    .collect(Collectors.toMap(
+                            item -> item.getSourceId().intValue(),
+                            item -> item.getCommentCount(),
+                            (existing, replacement) -> existing
+                    ));
+        } catch (Exception e) {
+            log.error("批量查询评论数量失败", e);
+            return Collections.emptyMap();
+        }
+    }
+
+    /**
+     * 设置店铺类型
+     * 
+     * @param vo 打卡记录VO
+     */
+    private void setStoreTypeNew(StoreClockInVo vo) {
+        String businessSectionName = vo.getBusinessSectionName();
+        if (businessSectionName == null) {
+            return;
+        }
+        
+        if (Arrays.asList("酒吧", "KTV", "洗浴汗蒸", "按摩足疗").contains(businessSectionName)) {
+            vo.setStoreTypeNew(1);
+        } else if (Arrays.asList("丽人美发", "运动健身").contains(businessSectionName)) {
+            vo.setStoreTypeNew(2);
+        } else if (Arrays.asList("特色美食").contains(businessSectionName)) {
+            vo.setStoreTypeNew(3);
+        }
+    }
+
     @Override
     public int deleteClockIn(Integer id) {
         return storeClockInMapper.deleteById(id);

+ 99 - 15
alien-store/src/main/java/shop/alien/store/service/impl/StoreCustomerServiceServiceImpl.java

@@ -5,18 +5,21 @@ 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.text.SimpleDateFormat;
 import java.util.ArrayList;
+import java.util.Calendar;
 import java.util.Date;
 import java.util.List;
+import java.util.stream.Collectors;
 
 /**
  * <p>
@@ -36,9 +39,15 @@ public class StoreCustomerServiceServiceImpl extends ServiceImpl<StoreCustomerSe
 
     @Override
     public StoreCustomerService getByQuestion(String question) {
+        if (StringUtils.isEmpty(question)) {
+            return null;
+        }
         LambdaQueryWrapper<StoreCustomerService> lambdaQueryWrapper = new LambdaQueryWrapper<>();
-        List<StoreCustomerService> list = storeCustomerServiceMapper.selectList(lambdaQueryWrapper);
-        return list.stream().filter(item -> item.getQuestion().contains(question)).findFirst().orElse(null);
+        lambdaQueryWrapper.like(StoreCustomerService::getQuestion, question)
+                .eq(StoreCustomerService::getDeleteFlag, 0)
+                .orderByDesc(StoreCustomerService::getCreatedTime)
+                .last("limit 1");
+        return storeCustomerServiceMapper.selectOne(lambdaQueryWrapper);
     }
 
     @Override
@@ -77,6 +86,13 @@ public class StoreCustomerServiceServiceImpl extends ServiceImpl<StoreCustomerSe
 
     @Override
     public List<StoreCustomerService> getRandList(String type, Integer limit) {
+        if (StringUtils.isEmpty(type) || limit == null || limit <= 0) {
+            return new ArrayList<>();
+        }
+        // 限制最大查询数量,防止SQL注入和性能问题
+        if (limit > 100) {
+            limit = 100;
+        }
         LambdaQueryWrapper<StoreCustomerService> lambdaQueryWrapper = new LambdaQueryWrapper<>();
         lambdaQueryWrapper.eq(StoreCustomerService::getType, type)
                 .eq(StoreCustomerService::getDeleteFlag, 0)
@@ -86,34 +102,102 @@ public class StoreCustomerServiceServiceImpl extends ServiceImpl<StoreCustomerSe
 
     @Override
     public List<AiIntelligentAssistant> saveAiIntelligentAssistant(List<AiIntelligentAssistant> aiIntelligentAssistants) {
+        if (aiIntelligentAssistants == null || aiIntelligentAssistants.isEmpty()) {
+            return new ArrayList<>();
+        }
+        Date now = new Date();
         for (AiIntelligentAssistant aiIntelligentAssistant : aiIntelligentAssistants) {
+            if (aiIntelligentAssistant == null) {
+                continue;
+            }
             aiIntelligentAssistant.setDeleteFlag(0);
-            if (aiIntelligentAssistant.getType() != 0) {
-                aiIntelligentAssistant.setCreatedTime(new Date());
-                aiIntelligentAssistant.setUpdatedTime(new Date());
+            if (aiIntelligentAssistant.getType() != null && aiIntelligentAssistant.getType() != 0) {
+                aiIntelligentAssistant.setCreatedTime(now);
+                aiIntelligentAssistant.setUpdatedTime(now);
             }
         }
-        aiIntelligentAssistantMapper.insertList(aiIntelligentAssistants);
-        return aiIntelligentAssistants;
+        // 过滤掉null值
+        List<AiIntelligentAssistant> validList = aiIntelligentAssistants.stream()
+                .filter(item -> item != null)
+                .collect(Collectors.toList());
+        if (validList.isEmpty()) {
+            return new ArrayList<>();
+        }
+        aiIntelligentAssistantMapper.insertList(validList);
+        return validList;
     }
 
+    /**
+     * 查询聊天记录
+     * 只返回最近7天内的记录
+     */
     @Override
-    public List<AiIntelligentAssistant> selectAiIntelligentAssistant(String userId,String time,Integer talkSource) {
+    public List<AiIntelligentAssistant> selectAiIntelligentAssistant(String userId, String time, Integer talkSource) {
+        // 参数校验
+        if (StringUtils.isEmpty(userId) || StringUtils.isEmpty(time) || talkSource == null) {
+            return new 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();
+        
+        // 确保查询时间不早于7天前
+        if (queryTime.before(sevenDaysAgo)) {
+            queryTime = sevenDaysAgo;
+        }
+        
+        // 查找最后一个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之间的记录
+            Date markPointTime = aiIntelligentAssistant.getCreatedTime();
+            // 确保标记点时间不早于7天前
+            if (markPointTime.before(sevenDaysAgo)) {
+                markPointTime = sevenDaysAgo;
+            }
+            
+            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<>();
     }
 }

+ 52 - 63
alien-store/src/main/java/shop/alien/store/service/impl/StoreInfoServiceImpl.java

@@ -393,13 +393,20 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
         if (storeMainInfoVo.getRenewContractStatus() == 1) {
             storeMainInfoVo.setRenewContractStatus(0);
         }
-        if (storeMainInfoVo.getStoreStatus() == -1) {
+        // 处理注销状态:如果已超过7天,店铺应该已被定时任务删除,这里只处理7天内的倒计时
+        if (storeMainInfoVo.getStoreStatus() == -1 && storeMainInfoVo.getLogoutTime() != null) {
             LocalDateTime localDateTime = storeMainInfoVo.getLogoutTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
             LocalDateTime future = localDateTime.plusDays(7);
             LocalDateTime now = LocalDateTime.now();
             Duration duration = Duration.between(now, future);
             long correct = duration.toMillis();
-            storeMainInfoVo.setCountdown(correct);
+            // 如果倒计时已过期(小于0),说明已超过7天,店铺应该已被删除,不设置倒计时
+            if (correct > 0) {
+                storeMainInfoVo.setCountdown(correct);
+            } else {
+                // 超过7天,倒计时设为0,前端应该提示店铺已注销
+                storeMainInfoVo.setCountdown(0);
+            }
         }
         //存入门店地址
         storeMainInfoVo.setStoreAddress(storeInfo.getStoreAddress());
@@ -2745,6 +2752,25 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
         LambdaQueryWrapper<StoreInfo> storeUserLambdaQueryWrapper = new LambdaQueryWrapper<>();
         storeUserLambdaQueryWrapper.eq(StoreInfo::getId, storeInfo.getId());
         StoreInfo storeIn = storeInfoMapper.selectOne(storeUserLambdaQueryWrapper);
+        
+        // 检查店铺是否存在
+        if (storeIn == null) {
+            throw new IllegalArgumentException("店铺不存在或已被删除");
+        }
+        
+        // 检查是否超过7天冷静期
+        if (storeIn.getLogoutTime() != null) {
+            Date logoutTime = storeIn.getLogoutTime();
+            Calendar calendar = Calendar.getInstance();
+            calendar.setTime(logoutTime);
+            calendar.add(Calendar.DAY_OF_YEAR, 7);
+            Date sevenDaysLater = calendar.getTime();
+            Date now = new Date();
+            if (now.after(sevenDaysLater)) {
+                throw new IllegalArgumentException("已超过7天冷静期,无法取消注销");
+            }
+        }
+        
         // 修改注销标记为0
         storeIn.setLogoutFlag(0);
         // 注销状态变为可用
@@ -7497,7 +7523,6 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
         String name = holidayName.trim();
 
         try {
-            // 元旦:1月1日,通常3天假期(1月1日-1月3日)
             if (name.contains("元旦")) {
                 return new LocalDate[]{
                     LocalDate.of(year, 1, 1),
@@ -7505,21 +7530,16 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
                 };
             }
 
-            // 春节:农历正月初一,通常7天假期
             if (name.contains("春节")) {
-                // 春节日期每年不同,这里提供近几年的数据,建议使用农历工具精确计算
-                // 2024年春节:2月10日(农历正月初一)-2月16日
-                // 2025年春节:1月29日(农历正月初一)-2月4日
-                // 2026年春节:2月17日(农历正月初一)-2月23日
-                if (year == 2024) {
+                if (year == 2028) {
                     return new LocalDate[]{
-                        LocalDate.of(year, 2, 10),
-                        LocalDate.of(year, 2, 16)
+                        LocalDate.of(year, 1, 25),
+                        LocalDate.of(year, 2, 2)
                     };
-                } else if (year == 2025) {
+                } else if (year == 2027) {
                     return new LocalDate[]{
-                        LocalDate.of(year, 1, 29),
-                        LocalDate.of(year, 2, 4)
+                        LocalDate.of(year, 2, 5),
+                        LocalDate.of(year, 2, 13)
                     };
                 } else if (year == 2026) {
                     return new LocalDate[]{
@@ -7527,7 +7547,6 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
                         LocalDate.of(year, 2, 23)
                     };
                 } else {
-                    // 默认:根据年份大致估算(建议使用农历工具精确计算)
                     return new LocalDate[]{
                         LocalDate.of(year, 2, 10),
                         LocalDate.of(year, 2, 16)
@@ -7535,42 +7554,34 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
                 }
             }
 
-            // 情人节:2月14日,1天
             if (name.contains("情人节")) {
                 LocalDate date = LocalDate.of(year, 2, 14);
                 return new LocalDate[]{date, date};
             }
 
-            // 元宵节:农历正月十五,1天(通常在2月或3月)
             if (name.contains("元宵")) {
-                // 元宵节是春节后的第15天,这里简化处理
-                // 2024年元宵节:2月24日,2025年元宵节:2月12日,2026年元宵节:3月4日
-                if (year == 2024) {
-                    LocalDate date = LocalDate.of(year, 2, 24);
+                if (year == 2028) {
+                    LocalDate date = LocalDate.of(year, 2, 9);
                     return new LocalDate[]{date, date};
-                } else if (year == 2025) {
-                    LocalDate date = LocalDate.of(year, 2, 12);
+                } else if (year == 2027) {
+                    LocalDate date = LocalDate.of(year, 2, 20);
                     return new LocalDate[]{date, date};
                 } else if (year == 2026) {
-                    LocalDate date = LocalDate.of(year, 3, 4);
+                    LocalDate date = LocalDate.of(year, 3, 3);
                     return new LocalDate[]{date, date};
                 } else {
-                    // 默认:大致在2月底3月初
                     LocalDate date = LocalDate.of(year, 2, 24);
                     return new LocalDate[]{date, date};
                 }
             }
 
-            // 清明节:通常4月4日或5日,通常3天假期
             if (name.contains("清明")) {
-                // 清明节通常在4月4日或5日,这里以4月4日为基准,包含前后各1天
                 return new LocalDate[]{
                     LocalDate.of(year, 4, 4),
                     LocalDate.of(year, 4, 6)
                 };
             }
 
-            // 劳动节:5月1日,通常5天假期(5月1日-5月5日)
             if (name.contains("劳动") || name.contains("五一")) {
                 return new LocalDate[]{
                     LocalDate.of(year, 5, 1),
@@ -7578,25 +7589,19 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
                 };
             }
 
-            // 儿童节:6月1日,1天
             if (name.contains("儿童")) {
                 LocalDate date = LocalDate.of(year, 6, 1);
                 return new LocalDate[]{date, date};
             }
 
-            // 端午节:农历五月初五,通常3天假期
             if (name.contains("端午")) {
-                // 端午节通常在6月,这里提供近几年的数据
-                // 2024年端午节:6月10日,2025年端午节:5月31日,2026年端午节:6月19日
-                if (year == 2024) {
+                if (year == 2028) {
                     return new LocalDate[]{
-                        LocalDate.of(year, 6, 10),
-                        LocalDate.of(year, 6, 12)
+                        LocalDate.of(year, 6, 27)
                     };
-                } else if (year == 2025) {
+                } else if (year == 2027) {
                     return new LocalDate[]{
-                        LocalDate.of(year, 5, 31),
-                        LocalDate.of(year, 6, 2)
+                        LocalDate.of(year, 6, 9)
                     };
                 } else if (year == 2026) {
                     return new LocalDate[]{
@@ -7604,7 +7609,6 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
                         LocalDate.of(year, 6, 21)
                     };
                 } else {
-                    // 默认:大致在6月中旬
                     return new LocalDate[]{
                         LocalDate.of(year, 6, 10),
                         LocalDate.of(year, 6, 12)
@@ -7612,39 +7616,30 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
                 }
             }
 
-            // 七夕:农历七月初七,1天(通常在8月)
             if (name.contains("七夕")) {
-                // 七夕通常在8月,这里提供近几年的数据
-                // 2024年七夕:8月10日,2025年七夕:7月31日,2026年七夕:8月20日
-                if (year == 2024) {
-                    LocalDate date = LocalDate.of(year, 8, 10);
+                if (year == 2028) {
+                    LocalDate date = LocalDate.of(year, 8, 26);
                     return new LocalDate[]{date, date};
-                } else if (year == 2025) {
-                    LocalDate date = LocalDate.of(year, 7, 31);
+                } else if (year == 2027) {
+                    LocalDate date = LocalDate.of(year, 8, 8);
                     return new LocalDate[]{date, date};
                 } else if (year == 2026) {
-                    LocalDate date = LocalDate.of(year, 8, 20);
+                    LocalDate date = LocalDate.of(year, 8, 19);
                     return new LocalDate[]{date, date};
                 } else {
-                    // 默认:大致在8月上旬
                     LocalDate date = LocalDate.of(year, 8, 10);
                     return new LocalDate[]{date, date};
                 }
             }
 
-            // 中秋节:农历八月十五,通常3天假期
             if (name.contains("中秋")) {
-                // 中秋节通常在9月或10月,这里提供近几年的数据
-                // 2024年中秋节:9月17日,2025年中秋节:10月6日,2026年中秋节:9月25日
-                if (year == 2024) {
+                if (year == 2028) {
                     return new LocalDate[]{
-                        LocalDate.of(year, 9, 17),
-                        LocalDate.of(year, 9, 19)
+                        LocalDate.of(year, 10, 3)
                     };
-                } else if (year == 2025) {
+                } else if (year == 2027) {
                     return new LocalDate[]{
-                        LocalDate.of(year, 10, 6),
-                        LocalDate.of(year, 10, 8)
+                        LocalDate.of(year, 9, 15)
                     };
                 } else if (year == 2026) {
                     return new LocalDate[]{
@@ -7652,7 +7647,6 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
                         LocalDate.of(year, 9, 27)
                     };
                 } else {
-                    // 默认:大致在9月下旬
                     return new LocalDate[]{
                         LocalDate.of(year, 9, 29),
                         LocalDate.of(year, 10, 1)
@@ -7660,7 +7654,6 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
                 }
             }
 
-            // 国庆节:10月1日,通常7天假期(10月1日-10月7日)
             if (name.contains("国庆")) {
                 return new LocalDate[]{
                     LocalDate.of(year, 10, 1),
@@ -7668,20 +7661,16 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
                 };
             }
 
-            // 冬至:通常12月21日或22日,1天
             if (name.contains("冬至")) {
-                // 冬至通常在12月21日或22日,这里统一为12月22日
                 LocalDate date = LocalDate.of(year, 12, 22);
                 return new LocalDate[]{date, date};
             }
 
-            // 平安夜:12月24日,1天
             if (name.contains("平安夜")) {
                 LocalDate date = LocalDate.of(year, 12, 24);
                 return new LocalDate[]{date, date};
             }
 
-            // 圣诞节:12月25日,1天
             if (name.contains("圣诞")) {
                 LocalDate date = LocalDate.of(year, 12, 25);
                 return new LocalDate[]{date, date};

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

@@ -288,7 +288,7 @@ public class StoreOfficialAlbumServiceImpl extends ServiceImpl<StoreOfficialAlbu
                     return result;
                 }
             }
-            
+            videoQueryWrapper.orderByAsc(StoreVideo::getImgSort);
             List<StoreVideo> videoList = storeVideoMapper.selectList(videoQueryWrapper);
             StoreOfficialAlbumImgVo result = new StoreOfficialAlbumImgVo();
             result.setVideoList(videoList);

Некоторые файлы не были показаны из-за большого количества измененных файлов