Jelajahi Sumber

Merge remote-tracking branch 'origin/sit' into sit

# Conflicts:
#	alien-store/src/main/java/shop/alien/store/service/impl/StoreInfoServiceImpl.java
panzhilin 18 jam lalu
induk
melakukan
a2a69515b8

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

@@ -81,6 +81,9 @@ public class LifeDiscountCouponUser extends Model<LifeDiscountCouponUser> {
     @TableField("ub_id")
     private Integer ubId;
 
+     @ApiModelProperty(value = "福利ID")
+     @TableField("welfare_id")
+     private Integer welfareId;
 
     @Override
     protected Serializable pkVal() {

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

@@ -46,6 +46,14 @@ public class StoreImg extends Model<StoreImg> {
     @TableField("img_url")
     private String imgUrl;
 
+    @ApiModelProperty(value = "是否提取图片颜色:0-未提取,1-已提取")
+    @TableField("is_extract")
+    private Integer isExtract;
+
+    @ApiModelProperty(value = "图片颜色码")
+    @TableField("color_code")
+    private String colorCode;
+
     @ApiModelProperty(value = "删除标记, 0:未删除, 1:已删除")
     @TableField("delete_flag")
     @TableLogic

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

@@ -83,6 +83,9 @@ public class StoreMainInfoVo extends StoreInfo {
     @ApiModelProperty(value = "经营许可证照片")
     private List<StoreImg> foodLicenceList;
 
+    @ApiModelProperty(value = "头图列表(包含is_extract字段)")
+    private List<StoreImg> headerImgList;
+
     @ApiModelProperty(value = "是否连锁转义")
     private String isChainStr;
 

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

@@ -525,7 +525,7 @@ public interface LawyerConsultationOrderMapper extends BaseMapper<LawyerConsulta
             "accept_orders_status "+
             "FROM " +
             "lawyer_consultation_order " +
-            "WHERE order_status in (1,2) " +
+            "WHERE order_status in (0,1,2) " +
             " and delete_flag = 0 " +
             "<if test='clientUserId != null'>" +
             "AND client_user_id = #{clientUserId} " +

+ 1 - 1
alien-gateway/src/main/java/shop/alien/gateway/controller/StoreUserController.java

@@ -58,7 +58,7 @@ public class StoreUserController {
                 return R.fail("验证码过期或未发送");
             }
             if (!cacheCode.trim().equals(code.trim())) {
-                return R.fail("验证码错误");
+                return R.fail("验证码错误,请重新输入");
             }
         }
         StoreUser storeUser = storeUserMapper.selectOne(new LambdaQueryWrapper<StoreUser>()

+ 8 - 4
alien-store/src/main/java/shop/alien/store/controller/OperationalActivityController.java

@@ -49,17 +49,21 @@ public class OperationalActivityController {
             @ApiImplicitParam(name = "storeId", value = "商户ID", dataTypeClass = Integer.class, paramType = "query"),
             @ApiImplicitParam(name = "storeName", value = "商户名称(模糊)", dataTypeClass = String.class, paramType = "query"),
             @ApiImplicitParam(name = "pageNum", value = "当前页", dataTypeClass = Integer.class, paramType = "query"),
-            @ApiImplicitParam(name = "pageSize", value = "每页数量", dataTypeClass = Integer.class, paramType = "query")
+            @ApiImplicitParam(name = "pageSize", value = "每页数量", dataTypeClass = Integer.class, paramType = "query"),
+            @ApiImplicitParam(name = "activityStatus", value = "活动状态", dataTypeClass = Integer.class, paramType = "query"),
+            @ApiImplicitParam(name = "activityName", value = "活动名称(模糊)", dataTypeClass = String.class, paramType = "query")
     })
     @GetMapping("/detail")
     public R<IPage<StoreOperationalActivityVO>> pageActivityDetail(
             @RequestParam(value = "storeId", required = false) Integer storeId,
             @RequestParam(value = "storeName", required = false) String storeName,
             @RequestParam(value = "pageNum", required = false) Integer pageNum,
-            @RequestParam(value = "pageSize", required = false) Integer pageSize) {
-        log.info("OperationalActivityController.pageActivityDetail storeId={}, storeName={}, pageNum={}, pageSize={}", storeId, storeName, pageNum, pageSize);
+            @RequestParam(value = "pageSize", required = false) Integer pageSize,
+            @RequestParam(value = "status", required = false) Integer status,
+            @RequestParam(value = "activityName", required = false) String activityName) {
+        log.info("OperationalActivityController.pageActivityDetail storeId={}, storeName={}, pageNum={}, pageSize={}, status={}, activityName={}", storeId, storeName, pageNum, pageSize, status, activityName);
         try {
-            IPage<StoreOperationalActivityVO> result = activityService.pageActivityDetail(storeId, storeName, pageNum, pageSize);
+            IPage<StoreOperationalActivityVO> result = activityService.pageActivityDetail(storeId, storeName, pageNum, pageSize, status, activityName);
             return R.data(result);
         } catch (IllegalArgumentException e) {
             return R.fail(e.getMessage());

+ 99 - 0
alien-store/src/main/java/shop/alien/store/controller/StoreImgController.java

@@ -11,6 +11,8 @@ import shop.alien.entity.store.vo.StoreImgInfoVo;
 import shop.alien.entity.store.vo.StoreImgTypeVo;
 import shop.alien.store.service.StoreImgService;
 import shop.alien.store.service.StoreInfoService;
+import shop.alien.store.util.GroupConstant;
+import shop.alien.store.util.ai.AiImageColorExtractUtil;
 
 import java.util.List;
 
@@ -30,6 +32,7 @@ import java.util.List;
 public class StoreImgController {
     private final StoreImgService storeImgService;
     private final StoreInfoService storeInfoService;
+    private final AiImageColorExtractUtil aiImageColorExtractUtil;
 
     @ApiOperation("获取图片")
     @ApiOperationSupport(order = 1)
@@ -86,6 +89,60 @@ public class StoreImgController {
         log.info("StoreImgController.updateStoreImgModeInfo?result={}", result);
         
         if(!CollectionUtils.isEmpty(storeImgList)){
+            Integer imgType = storeImgInfoVo.getImgType();
+            // 判断是否为多图模式
+            boolean isMultiMode = imgType != null && imgType.equals(GroupConstant.IMG_TYPE_MULTI_MODE);
+            
+            // 如果是多图模式,需要找到第一张图片(imgSort最小的)
+            StoreImg firstImg = null;
+            if (isMultiMode) {
+                firstImg = storeImgList.stream()
+                        .filter(img -> img != null && img.getImgUrl() != null)
+                        .min((img1, img2) -> {
+                            Integer sort1 = img1.getImgSort() != null ? img1.getImgSort() : Integer.MAX_VALUE;
+                            Integer sort2 = img2.getImgSort() != null ? img2.getImgSort() : Integer.MAX_VALUE;
+                            return sort1.compareTo(sort2);
+                        })
+                        .orElse(null);
+            }
+            
+            // 遍历图片列表,设置图片描述,并根据条件提取颜色
+            for (StoreImg storeImg : storeImgList) {
+                if (storeImg != null && storeImg.getImgUrl() != null) {
+                    // 根据图片类型设置图片描述
+                    String imgDescription = getImgDescriptionByType(imgType);
+                    if (imgDescription != null) {
+                        storeImg.setImgDescription(imgDescription);
+                    }
+                    
+                    // 只有当 is_extract=1 时才提取颜色
+                    Integer isExtract = storeImg.getIsExtract();
+                    if (isExtract != null && isExtract == 1) {
+                        // 如果是多图模式,只对第一张图片提取颜色
+                        if (isMultiMode) {
+                            // 判断是否为第一张图片(通过比较imgSort,如果imgSort相同则认为是同一张图片)
+                            boolean isFirstImg = firstImg != null && 
+                                    firstImg.getImgSort() != null && 
+                                    storeImg.getImgSort() != null && 
+                                    firstImg.getImgSort().equals(storeImg.getImgSort());
+                            
+                            if (isFirstImg) {
+                                log.info("多图模式,检测到需要提取第一张图片颜色,imgUrl: {}, imgSort: {}, isExtract: {}", 
+                                        storeImg.getImgUrl(), storeImg.getImgSort(), isExtract);
+                                extractColorForImg(storeImg);
+                            } else {
+                                log.info("多图模式,跳过非第一张图片的颜色提取,imgUrl: {}, imgSort: {}", 
+                                        storeImg.getImgUrl(), storeImg.getImgSort());
+                                // 非第一张图片,保持 is_extract 为 1,但不提取颜色
+                            }
+                        } else {
+                            // 单图模式,正常提取颜色
+                            log.info("单图模式,检测到需要提取图片颜色,imgUrl: {}, isExtract: {}", storeImg.getImgUrl(), isExtract);
+                            extractColorForImg(storeImg);
+                        }
+                    }
+                }
+            }
             Integer id = storeImgList.get(0).getId();
             if (storeImgService.saveOrUpdateBatch(storeImgList)) {
                 // 如果是头图,先设置审核状态为通过(1),然后进行AI审核
@@ -185,4 +242,46 @@ public class StoreImgController {
         log.info("StoreImgController.getByBusinessId?storeId={}&imgType={}&businessId={}", storeId, imgType, businessId);
         return R.data(storeImgService.getByBusinessId(storeId, imgType, businessId));
     }
+
+    /**
+     * 根据图片类型获取图片描述
+     *
+     * @param imgType 图片类型
+     * @return 图片描述
+     */
+    private String getImgDescriptionByType(Integer imgType) {
+        if (imgType == null) {
+            return null;
+        }
+        switch (imgType) {
+            case 20:
+                return "头图单图模式";
+            case 21:
+                return "头图多图模式";
+            default:
+                return null;
+        }
+    }
+
+    /**
+     * 提取图片颜色
+     *
+     * @param storeImg 图片对象
+     */
+    private void extractColorForImg(StoreImg storeImg) {
+        try {
+            String colorCode = aiImageColorExtractUtil.extractCoverColor(storeImg.getImgUrl());
+            if (colorCode != null) {
+                storeImg.setColorCode(colorCode);
+                storeImg.setIsExtract(1); // 提取成功,设置为已提取
+                log.info("成功提取图片颜色码,imgUrl: {}, colorCode: {}", storeImg.getImgUrl(), colorCode);
+            } else {
+                log.warn("提取图片颜色失败,imgUrl: {}", storeImg.getImgUrl());
+                // 提取失败时,保持 is_extract 为 1(表示已尝试提取)
+            }
+        } catch (Exception e) {
+            log.error("提取图片颜色异常,imgUrl: {}", storeImg.getImgUrl(), e);
+            // 异常时,保持 is_extract 为 1(表示已尝试提取)
+        }
+    }
 }

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

@@ -30,7 +30,7 @@ public interface OperationalActivityService {
      * @param pageSize  每页数量
      * @return 活动分页结果
      */
-    IPage<StoreOperationalActivityVO> pageActivityDetail(Integer storeId, String storeName, Integer pageNum, Integer pageSize);
+    IPage<StoreOperationalActivityVO> pageActivityDetail(Integer storeId, String storeName, Integer pageNum, Integer pageSize, Integer activityStatus, String activityName);
 
     /**
      * 根据活动ID获取活动详情

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

@@ -203,9 +203,20 @@ public class LifeDiscountCouponStoreFriendServiceImpl extends ServiceImpl<LifeDi
                     StoreUser friendStoreUser = storeUserList.get(0);
                     String friendPhone = friendStoreUser.getPhone();
                     if(StringUtils.isNotEmpty(friendPhone)){
+                        // 获取发送优惠券的店铺名称
+                        String storeName = userLoginInfo.getUserName(); // 默认使用用户名
+                        // 根据当前登录用户ID查询店铺用户信息
+                        StoreUser currentStoreUser = storeUserMapper.selectById(userLoginInfo.getUserId());
+                        if (currentStoreUser != null && currentStoreUser.getStoreId() != null) {
+                            // 根据storeId查询店铺信息,获取店铺名称
+                            StoreInfo currentStoreInfo = storeInfoMapper.selectById(currentStoreUser.getStoreId());
+                            if (currentStoreInfo != null && currentStoreInfo.getStoreName() != null) {
+                                storeName = currentStoreInfo.getStoreName();
+                            }
+                        }
                         // 发送好友优惠券通知
                         LifeNotice lifeMessage = new LifeNotice();
-                        String text = "您的好友"+userLoginInfo.getUserName()+"送了您"+couponDto.getSingleQty()+"张店铺优惠券,快去使用吧!";
+                        String text = "您的好友"+storeName+"送了您"+couponDto.getSingleQty()+"张店铺优惠券,快去使用吧!";
                         JSONObject jsonObject = new JSONObject();
                         jsonObject.put("message", text);
                         lifeMessage.setReceiverId("store_"+friendPhone);

+ 0 - 6
alien-store/src/main/java/shop/alien/store/service/impl/LifeUserViolationServiceImpl.java

@@ -7,7 +7,6 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.google.common.collect.Lists;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
@@ -20,7 +19,6 @@ import shop.alien.entity.second.SecondGoodsRecord;
 import shop.alien.entity.second.vo.SecondUserViolationDetailVo;
 import shop.alien.entity.store.*;
 import shop.alien.entity.store.dto.LifeUserViolationDto;
-import shop.alien.entity.store.excelVo.LifeUserOrderExcelVo;
 import shop.alien.entity.store.excelVo.LifeUserViolationExcelVO;
 import shop.alien.entity.store.excelVo.util.ExcelGenerator;
 import shop.alien.entity.store.vo.LifeUserViolationVo;
@@ -34,20 +32,16 @@ import shop.alien.store.util.AiUserViolationUtils;
 import shop.alien.store.util.FunctionMagic;
 import shop.alien.util.ali.AliOSSUtil;
 import shop.alien.util.common.EnumUtil;
-import shop.alien.util.common.JwtUtil;
 
 import java.io.File;
 import java.io.IOException;
 import java.text.SimpleDateFormat;
-import java.time.Instant;
 import java.time.ZoneId;
 import java.time.format.DateTimeFormatter;
 import java.util.*;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.stream.Collectors;
 
-import static shop.alien.util.common.constant.Constant.*;
-
 
 /**
  * <p>

+ 11 - 6
alien-store/src/main/java/shop/alien/store/service/impl/OperationalActivityServiceImpl.java

@@ -79,8 +79,8 @@ public class OperationalActivityServiceImpl implements OperationalActivityServic
     }
 
     @Override
-    public IPage<StoreOperationalActivityVO> pageActivityDetail(Integer storeId, String storeName, Integer pageNum, Integer pageSize) {
-        log.info("OperationalActivityServiceImpl.pageActivityDetail: storeId={}, storeName={}, pageNum={}, pageSize={}", storeId, storeName, pageNum, pageSize);
+    public IPage<StoreOperationalActivityVO> pageActivityDetail(Integer storeId, String storeName, Integer pageNum, Integer pageSize, Integer activityStatus, String activityName) {
+        log.info("OperationalActivityServiceImpl.pageActivityDetail: storeId={}, storeName={}, pageNum={}, pageSize={}, activityStatus={}, activityName={}", storeId, storeName, pageNum, pageSize, activityStatus, activityName);
 
 //        if (storeId == null && StringUtils.isBlank(storeName)) {
 //            throw new IllegalArgumentException("请至少提供商户ID或商户名称");
@@ -112,11 +112,16 @@ public class OperationalActivityServiceImpl implements OperationalActivityServic
 //        }
 
         LambdaQueryWrapper<StoreOperationalActivity> wrapper = new LambdaQueryWrapper<>();
-
-
-        if (!storeIds.isEmpty()) {
-            wrapper.in(StoreOperationalActivity::getStoreId, storeIds);
+        if (activityStatus != null) {
+            wrapper.eq(StoreOperationalActivity::getStatus, activityStatus);
         }
+        if (StringUtils.isNotBlank(activityName)) {
+            wrapper.like(StoreOperationalActivity::getActivityName, activityName);
+        }
+//
+//        if (!storeIds.isEmpty()) {
+//            wrapper.in(StoreOperationalActivity::getStoreId, storeIds);
+//        }
         wrapper.eq(StoreOperationalActivity::getDeleteFlag, 0);
         wrapper.orderByDesc(StoreOperationalActivity::getCreatedTime);
 

+ 43 - 5
alien-store/src/main/java/shop/alien/store/service/impl/StoreInfoServiceImpl.java

@@ -240,6 +240,28 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
         storeMainInfoVo.setStoreLabel(storeLabelMapper.selectOne(new LambdaQueryWrapper<StoreLabel>().eq(StoreLabel::getStoreId, id)));
         //营业时间
         storeMainInfoVo.setStoreBusinessInfo(storeBusinessInfoMapper.selectList(new LambdaQueryWrapper<StoreBusinessInfo>().eq(StoreBusinessInfo::getStoreId, id)));
+        //门店头像
+        LambdaQueryWrapper<StoreImg> eq = new LambdaQueryWrapper<StoreImg>().eq(StoreImg::getImgType, 10).eq(StoreImg::getStoreId, id);
+        StoreImg storeImg = storeImgMapper.selectOne(eq);
+        storeMainInfoVo.setHeadImgUrl(storeImg != null ? storeImg.getImgUrl() : "");
+
+        // 查询头图列表(包含is_extract字段)
+        Integer imgMode = storeInfo.getImgMode();
+        Integer headerImgType = null;
+        if (imgMode != null && imgMode == 1) {
+            // 多图模式
+            headerImgType = GroupConstant.IMG_TYPE_MULTI_MODE;
+        } else {
+            // 单图模式(默认)
+            headerImgType = GroupConstant.IMG_TYPE_SINGLE_MODE;
+        }
+        LambdaQueryWrapper<StoreImg> headerImgQueryWrapper = new LambdaQueryWrapper<>();
+        headerImgQueryWrapper.eq(StoreImg::getImgType, headerImgType);
+        headerImgQueryWrapper.eq(StoreImg::getStoreId, id);
+        headerImgQueryWrapper.orderByAsc(StoreImg::getImgSort);
+        List<StoreImg> headerImgList = storeImgMapper.selectList(headerImgQueryWrapper);
+        storeMainInfoVo.setHeaderImgList(headerImgList);
+
         //门店头图(20:头图单图模式, 21:头图多图模式)
         LambdaQueryWrapper<StoreImg> headImgWrapper = new LambdaQueryWrapper<StoreImg>()
                 .in(StoreImg::getImgType, 20, 21)
@@ -819,8 +841,14 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
         List<String> businessTypeNames = new ArrayList<>();
         //获取经营种类名称
         for (String businessType : businessTypes) {
-            StoreDictionary storeDictionary = storeDictionaryMapper.selectOne(new LambdaQueryWrapper<StoreDictionary>().eq(StoreDictionary::getDictId, businessType).eq(StoreDictionary::getParentId, businessSectionName.getId()));
-            businessTypeNames.add(storeDictionary.getDictDetail());
+            StoreDictionary storeDictionary = storeDictionaryMapper.selectOne(new LambdaQueryWrapper<StoreDictionary>()
+                    .eq(StoreDictionary::getDictId, businessType)
+                    .eq(StoreDictionary::getParentId, businessSectionName.getId())
+                    .eq(StoreDictionary::getTypeName, "business_type")
+                    .eq(StoreDictionary::getDeleteFlag, 0));
+            if (storeDictionary != null) {
+                businessTypeNames.add(storeDictionary.getDictDetail());
+            }
         }
 
         StoreInfoVo result = new StoreInfoVo();
@@ -1274,8 +1302,14 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
         List<String> businessTypeNames = new ArrayList<>();
         //获取经营种类名称
         for (String businessType : businessTypes) {
-            StoreDictionary storeDictionary = storeDictionaryMapper.selectOne(new LambdaQueryWrapper<StoreDictionary>().eq(StoreDictionary::getDictId, businessType).eq(StoreDictionary::getParentId, businessSectionName.getId()));
-            businessTypeNames.add(storeDictionary.getDictDetail());
+            StoreDictionary storeDictionary = storeDictionaryMapper.selectOne(new LambdaQueryWrapper<StoreDictionary>()
+                    .eq(StoreDictionary::getDictId, businessType)
+                    .eq(StoreDictionary::getParentId, businessSectionName.getId())
+                    .eq(StoreDictionary::getTypeName, "business_type")
+                    .eq(StoreDictionary::getDeleteFlag, 0));
+            if (storeDictionary != null) {
+                businessTypeNames.add(storeDictionary.getDictDetail());
+            }
         }
 
         StoreInfoVo result = new StoreInfoVo();
@@ -1452,7 +1486,9 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
                 .eq(StoreDictionary::getDictId, parentId)
                 .isNull(StoreDictionary::getParentId));
         List<StoreDictionary> storeDictionaries = storeDictionaryMapper.selectList(new LambdaQueryWrapper<StoreDictionary>()
-                .eq(StoreDictionary::getParentId, businessSection.getId()));
+                .eq(StoreDictionary::getTypeName, "business_type")
+                .eq(StoreDictionary::getParentId, businessSection.getId())
+                .eq(StoreDictionary::getDeleteFlag, 0));
         List<StoreDictionaryVo> voList = new ArrayList<>();
         for (StoreDictionary storeDictionary : storeDictionaries) {
             StoreDictionaryVo vo = new StoreDictionaryVo();
@@ -2564,6 +2600,8 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
                         new LambdaQueryWrapper<StoreDictionary>()
                                 .in(StoreDictionary::getDictId, businessTypes) // 批量匹配id
                                 .eq(StoreDictionary::getParentId, businessSectionDict.getId())
+                                .eq(StoreDictionary::getTypeName, "business_type") // 只查询经营种类,排除擅长标签
+                                .eq(StoreDictionary::getDeleteFlag, 0)
                 );
                 // 转为Map<dictId, StoreDictionary>,方便快速获取
                 Map<String, StoreDictionary> typeDictMap = typeDicts.stream()

+ 7 - 5
alien-store/src/main/java/shop/alien/store/service/impl/StorePlatformBenefitsServiceImpl.java

@@ -202,15 +202,15 @@ public class StorePlatformBenefitsServiceImpl extends ServiceImpl<StorePlatformB
         QueryWrapper<LifeDiscountCouponUser> queryWrapper = new QueryWrapper<>();
         queryWrapper.eq("user_id", userId);
         List<LifeDiscountCouponUser> lifeDiscountCouponUsers = lifeDiscountCouponUserMapper.selectList(queryWrapper);
-        List<Integer> couponIdList = lifeDiscountCouponUsers.stream().filter(x -> x.getCouponId() != null).map(LifeDiscountCouponUser::getCouponId).collect(Collectors.toList());
-        List<Integer> ubIdList = lifeDiscountCouponUsers.stream().filter(x -> x.getUbId() != null).map(LifeDiscountCouponUser::getUbId).collect(Collectors.toList());
-        couponIdList.addAll(ubIdList);
+//        List<Integer> couponIdList = lifeDiscountCouponUsers.stream().filter(x -> x.getCouponId() != null).map(LifeDiscountCouponUser::getCouponId).collect(Collectors.toList());
+//        List<Integer> ubIdList = lifeDiscountCouponUsers.stream().filter(x -> x.getUbId() != null).map(LifeDiscountCouponUser::getUbId).collect(Collectors.toList());
+        List<Integer> welfareIdList = lifeDiscountCouponUsers.stream().filter(x->x.getWelfareId() != null).map(LifeDiscountCouponUser::getWelfareId).collect(Collectors.toList());
         List<StorePlatformBenefitsVo> storePlatformBenefits = benefitsMapper.selectListAndCoupon();
         List<StorePlatformBenefitsVo> result = new ArrayList<>();
         for (StorePlatformBenefitsVo storePlatformBenefit : storePlatformBenefits) {
             StorePlatformBenefitsVo  storePlatformBenefitVo = new StorePlatformBenefitsVo();
             cn.hutool.core.bean.BeanUtil.copyProperties(storePlatformBenefit, storePlatformBenefitVo);
-            if (couponIdList.contains(storePlatformBenefitVo.getId())) {
+            if (welfareIdList.contains(storePlatformBenefitVo.getId())) {
                 storePlatformBenefitVo.setClaimed(true);
             } else {
                 storePlatformBenefitVo.setClaimed(false);
@@ -230,7 +230,7 @@ public class StorePlatformBenefitsServiceImpl extends ServiceImpl<StorePlatformB
         if (benefits.getBusinessId() == null || benefits.getBusinessId().isEmpty()) {
             throw new RuntimeException("优惠券信息不存在");
         }
-
+        // 查询优惠券信息
         LifeDiscountCoupon lifeDiscountCoupon = lifeDiscountCouponMapper.selectById(benefits.getBusinessId());
         if (lifeDiscountCoupon == null) {
             throw new RuntimeException("优惠券不存在");
@@ -263,6 +263,7 @@ public class StorePlatformBenefitsServiceImpl extends ServiceImpl<StorePlatformB
         lifeDiscountCouponUser.setExpirationTime(lifeDiscountCoupon.getEndDate());
         // 设置该优惠券的状态为待使用
         lifeDiscountCouponUser.setStatus(Integer.parseInt(DiscountCouponEnum.WAITING_USED.getValue()));
+        lifeDiscountCouponUser.setWelfareId(benefitsId);
         lifeDiscountCouponUserMapper.insert(lifeDiscountCouponUser);
 
         if (updateResult > 0) {
@@ -310,6 +311,7 @@ public class StorePlatformBenefitsServiceImpl extends ServiceImpl<StorePlatformB
         // 把优惠券记录插入到用户优惠券表中
         LifeDiscountCouponUser lifeDiscountCouponUser = new LifeDiscountCouponUser();
         // 设置该优惠券记录的优惠券 ID
+        lifeDiscountCouponUser.setWelfareId(benefitsId);
         lifeDiscountCouponUser.setUbId(benefits.getId());
         // 设置该优惠券记录的用户 ID 为当前用户 ID
         lifeDiscountCouponUser.setUserId(userId);

+ 108 - 0
alien-store/src/main/java/shop/alien/store/util/ai/AiImageColorExtractUtil.java

@@ -0,0 +1,108 @@
+package shop.alien.store.util.ai;
+
+import com.alibaba.fastjson2.JSONObject;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.http.*;
+import org.springframework.stereotype.Component;
+import org.springframework.util.StringUtils;
+import org.springframework.web.client.HttpClientErrorException;
+import org.springframework.web.client.HttpServerErrorException;
+import org.springframework.web.client.RestTemplate;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * AI 图片封面颜色提取工具类
+ *
+ * @author system
+ * @since 2025-01-XX
+ */
+@Slf4j
+@Component
+@RequiredArgsConstructor
+public class AiImageColorExtractUtil {
+
+    private final RestTemplate restTemplate;
+    private final AiAuthTokenUtil aiAuthTokenUtil;
+
+    @Value("${ai.service.image-color-extract-url}")
+    private String extractColorUrl;
+
+    /**
+     * 提取图片封面颜色
+     *
+     * @param imageUrl 图片URL
+     * @return 颜色码,如果提取失败返回null
+     */
+    public String extractCoverColor(String imageUrl) {
+        if (!StringUtils.hasText(imageUrl)) {
+            log.warn("图片URL为空,无法提取颜色");
+            return null;
+        }
+
+        // 获取AI服务访问令牌
+        String accessToken = aiAuthTokenUtil.getAccessToken();
+        if (!StringUtils.hasText(accessToken)) {
+            log.error("获取AI服务访问令牌失败,无法调用颜色提取接口");
+            return null;
+        }
+
+        try {
+            // 构建请求体
+            Map<String, Object> requestBody = new HashMap<>();
+            requestBody.put("image_url", imageUrl);
+
+            // 构建请求头,添加Authorization
+            HttpHeaders headers = new HttpHeaders();
+            headers.setContentType(MediaType.APPLICATION_JSON);
+            headers.set("Authorization", "Bearer " + accessToken);
+
+            HttpEntity<Map<String, Object>> request = new HttpEntity<>(requestBody, headers);
+
+            log.info("调用AI颜色提取接口,图片URL: {}", imageUrl);
+            ResponseEntity<String> response = restTemplate.postForEntity(extractColorUrl, request, String.class);
+
+            if (response != null && response.getStatusCode() == HttpStatus.OK) {
+                String responseBody = response.getBody();
+                log.info("AI颜色提取接口响应: {}", responseBody);
+
+                if (StringUtils.hasText(responseBody)) {
+                    JSONObject jsonObject = JSONObject.parseObject(responseBody);
+                    if (jsonObject != null) {
+                        Integer code = jsonObject.getInteger("code");
+                        if (code != null && code == 200) {
+                            JSONObject data = jsonObject.getJSONObject("data");
+                            if (data != null) {
+                                String colorCode = data.getString("color_code");
+                                log.info("成功提取图片颜色码: {}", colorCode);
+                                return colorCode;
+                            } else {
+                                log.warn("AI接口返回数据为空");
+                            }
+                        } else {
+                            String message = jsonObject.getString("message");
+                            log.warn("AI接口返回错误,code: {}, message: {}", code, message);
+                        }
+                    }
+                }
+            } else {
+                log.error("AI颜色提取接口调用失败,HTTP状态码: {}", 
+                        response != null ? response.getStatusCode() : "null");
+            }
+        } catch (HttpClientErrorException e) {
+            log.error("调用AI颜色提取接口失败,HTTP客户端错误,状态码: {}, 响应体: {}, 图片URL: {}", 
+                    e.getStatusCode(), e.getResponseBodyAsString(), imageUrl, e);
+        } catch (HttpServerErrorException e) {
+            log.error("调用AI颜色提取接口失败,HTTP服务器错误,状态码: {}, 响应体: {}, 图片URL: {}", 
+                    e.getStatusCode(), e.getResponseBodyAsString(), imageUrl, e);
+        } catch (Exception e) {
+            log.error("调用AI颜色提取接口异常,图片URL: {}", imageUrl, e);
+        }
+
+        return null;
+    }
+}
+