From bd9e6d9b7f673c5f55ef40b42b37ecd78ab36893 Mon Sep 17 00:00:00 2001
From: zxl <763096477@qq.com>
Date: 星期二, 19 八月 2025 15:56:33 +0800
Subject: [PATCH] 奖品

---
 framework/src/main/java/cn/lili/modules/lmk/domain/query/PrizeDrawQuery.java              |    8 ++
 framework/src/main/java/cn/lili/modules/lmk/service/ActivityRefPrizeService.java          |   14 ++++
 framework/src/main/java/cn/lili/modules/lmk/domain/vo/PrizeDrawVO.java                    |    3 +
 framework/src/main/java/cn/lili/modules/lmk/service/impl/PrizeDrawServiceImpl.java        |   52 +++++++++++++++++
 manager-api/src/main/java/cn/lili/controller/lmk/PrizeDrawController.java                 |   56 ++++++++++++++++++
 framework/src/main/java/cn/lili/modules/lmk/domain/entity/PrizeDraw.java                  |    2 
 framework/src/main/java/cn/lili/modules/lmk/service/PrizeDrawService.java                 |    7 ++
 framework/src/main/resources/mapper/lmk/PrizeDrawMapper.xml                               |    6 ++
 framework/src/main/java/cn/lili/modules/lmk/service/impl/ActivityRefPrizeServiceImpl.java |   21 +++++++
 9 files changed, 167 insertions(+), 2 deletions(-)

diff --git a/framework/src/main/java/cn/lili/modules/lmk/domain/entity/PrizeDraw.java b/framework/src/main/java/cn/lili/modules/lmk/domain/entity/PrizeDraw.java
index 795b0bc..e30c0e9 100644
--- a/framework/src/main/java/cn/lili/modules/lmk/domain/entity/PrizeDraw.java
+++ b/framework/src/main/java/cn/lili/modules/lmk/domain/entity/PrizeDraw.java
@@ -28,7 +28,7 @@
 
     @TableField("coupon_id")
     /** 浼樻儬鍗穒d */
-    private Long couponId;
+    private String couponId;
 
     @TableField("prize_content")
     /** 濂栧搧鍐呭 */
diff --git a/framework/src/main/java/cn/lili/modules/lmk/domain/query/PrizeDrawQuery.java b/framework/src/main/java/cn/lili/modules/lmk/domain/query/PrizeDrawQuery.java
index 7c996b2..8ade3da 100644
--- a/framework/src/main/java/cn/lili/modules/lmk/domain/query/PrizeDrawQuery.java
+++ b/framework/src/main/java/cn/lili/modules/lmk/domain/query/PrizeDrawQuery.java
@@ -18,5 +18,13 @@
 @Data
 @ApiModel(value = "PrizeDraw鏌ヨ鍙傛暟", description = "鎶藉娲诲姩濂栧搧鏌ヨ鍙傛暟")
 public class PrizeDrawQuery extends AbsQuery {
+    /**
+     * 濂栧搧鍚�
+     */
+    private String prizeName;
+    /**
+     * 濂栧搧绫诲瀷
+     */
+    private String prizeType;
 }
 
diff --git a/framework/src/main/java/cn/lili/modules/lmk/domain/vo/PrizeDrawVO.java b/framework/src/main/java/cn/lili/modules/lmk/domain/vo/PrizeDrawVO.java
index d1308fe..f390f3c 100644
--- a/framework/src/main/java/cn/lili/modules/lmk/domain/vo/PrizeDrawVO.java
+++ b/framework/src/main/java/cn/lili/modules/lmk/domain/vo/PrizeDrawVO.java
@@ -48,6 +48,9 @@
     @ApiModelProperty("濂栧搧鍥剧墖")
     private String prizeImg;
 
+    private String prizeCoverUrl;
+
+    private String prizeImgUrl;
     public static PrizeDrawVO getVoByEntity(@NonNull PrizeDraw entity, PrizeDrawVO vo) {
         if(vo == null) {
             vo = new PrizeDrawVO();
diff --git a/framework/src/main/java/cn/lili/modules/lmk/service/ActivityRefPrizeService.java b/framework/src/main/java/cn/lili/modules/lmk/service/ActivityRefPrizeService.java
index 1516fed..458a27d 100644
--- a/framework/src/main/java/cn/lili/modules/lmk/service/ActivityRefPrizeService.java
+++ b/framework/src/main/java/cn/lili/modules/lmk/service/ActivityRefPrizeService.java
@@ -16,6 +16,20 @@
 public interface ActivityRefPrizeService extends IService<ActivityRefPrize> {
 
     /**
+     * 鏍规嵁鎶藉娲诲姩id 杩斿洖濂栧搧闆嗗悎
+     * @param prizeActivityId
+     * @return
+     */
+    Result getActivityRefPrizeByActivityId(String prizeActivityId);
+
+    /**
+     * 鏇村叿濂栧搧id娲诲姩鐩稿叧娲诲姩
+     * @param prizeId
+     * @return
+     */
+    Result getPrizeByIdAndPrizeActivityId(String prizeId);
+
+    /**
      * 娣诲姞
      * @param form
      * @return
diff --git a/framework/src/main/java/cn/lili/modules/lmk/service/PrizeDrawService.java b/framework/src/main/java/cn/lili/modules/lmk/service/PrizeDrawService.java
index eda1c76..5acc085 100644
--- a/framework/src/main/java/cn/lili/modules/lmk/service/PrizeDrawService.java
+++ b/framework/src/main/java/cn/lili/modules/lmk/service/PrizeDrawService.java
@@ -14,6 +14,12 @@
  * @since 2025-08-14
  */
 public interface PrizeDrawService extends IService<PrizeDraw> {
+    /**
+     * 杩斿洖鑳藉惁淇敼锛屼互鍙婅嫢鏄紭鎯犲姷绫诲瀷锛岃繑鍥炰紭鎯犲姷淇℃伅銆�
+     * @param prizeDrawId
+     * @return
+     */
+    Result canUpDatePrizeDraw(String prizeDrawId);
 
     /**
      * 娣诲姞
@@ -22,6 +28,7 @@
      */
     Result add(PrizeDrawForm form);
 
+
     /**
      * 淇敼
      * @param form
diff --git a/framework/src/main/java/cn/lili/modules/lmk/service/impl/ActivityRefPrizeServiceImpl.java b/framework/src/main/java/cn/lili/modules/lmk/service/impl/ActivityRefPrizeServiceImpl.java
index 27abbd0..99abf59 100644
--- a/framework/src/main/java/cn/lili/modules/lmk/service/impl/ActivityRefPrizeServiceImpl.java
+++ b/framework/src/main/java/cn/lili/modules/lmk/service/impl/ActivityRefPrizeServiceImpl.java
@@ -5,6 +5,7 @@
 import cn.lili.modules.lmk.mapper.ActivityRefPrizeMapper;
 import cn.lili.modules.lmk.service.ActivityRefPrizeService;
 import cn.lili.base.Result;
+import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import cn.lili.modules.lmk.domain.form.ActivityRefPrizeForm;
 import cn.lili.modules.lmk.domain.vo.ActivityRefPrizeVO;
@@ -14,6 +15,7 @@
 import cn.lili.utils.PageUtil;
 import org.springframework.beans.BeanUtils;
 import org.springframework.util.Assert;
+import org.springframework.util.CollectionUtils;
 
 import java.util.List;
 import java.util.stream.Collectors;
@@ -30,6 +32,25 @@
 
     private final ActivityRefPrizeMapper activityRefPrizeMapper;
 
+    @Override
+    public Result getActivityRefPrizeByActivityId(String prizeActivityId){
+        List<ActivityRefPrize> activityRefPrizeList = new LambdaQueryChainWrapper<>(baseMapper)
+                .eq(ActivityRefPrize::getPrizeActivityId,prizeActivityId)
+                .eq(ActivityRefPrize::getDeleteFlag,Boolean.FALSE)
+                .list();
+        return Result.ok().data(activityRefPrizeList);
+    }
+
+    @Override
+    public Result getPrizeByIdAndPrizeActivityId(String prizeId){
+        List<ActivityRefPrize> activityRefPrizeList = new LambdaQueryChainWrapper<>(baseMapper)
+                .eq(ActivityRefPrize::getPrizeId,prizeId)
+                .eq(ActivityRefPrize::getDeleteFlag,Boolean.FALSE)
+                .list();
+        return Result.ok().data(activityRefPrizeList);
+    }
+
+
     /**
      * 娣诲姞
      * @param form
diff --git a/framework/src/main/java/cn/lili/modules/lmk/service/impl/PrizeDrawServiceImpl.java b/framework/src/main/java/cn/lili/modules/lmk/service/impl/PrizeDrawServiceImpl.java
index e2936a7..dc2d489 100644
--- a/framework/src/main/java/cn/lili/modules/lmk/service/impl/PrizeDrawServiceImpl.java
+++ b/framework/src/main/java/cn/lili/modules/lmk/service/impl/PrizeDrawServiceImpl.java
@@ -1,5 +1,11 @@
 package cn.lili.modules.lmk.service.impl;
 
+import cn.lili.common.utils.StringUtils;
+import cn.lili.modules.lmk.domain.entity.ActivityRefPrize;
+import cn.lili.modules.lmk.service.ActivityRefPrizeService;
+import cn.lili.modules.promotion.entity.vos.CouponVO;
+import cn.lili.modules.promotion.service.CouponService;
+import cn.lili.utils.COSUtil;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import cn.lili.modules.lmk.domain.entity.PrizeDraw;
 import cn.lili.modules.lmk.mapper.PrizeDrawMapper;
@@ -14,7 +20,9 @@
 import cn.lili.utils.PageUtil;
 import org.springframework.beans.BeanUtils;
 import org.springframework.util.Assert;
+import org.springframework.util.CollectionUtils;
 
+import java.util.ArrayList;
 import java.util.List;
 import java.util.stream.Collectors;
 
@@ -29,6 +37,41 @@
 public class PrizeDrawServiceImpl extends ServiceImpl<PrizeDrawMapper, PrizeDraw> implements PrizeDrawService {
 
     private final PrizeDrawMapper prizeDrawMapper;
+
+    private final ActivityRefPrizeService activityRefPrizeService;
+
+    private final CouponService couponService;
+
+    private final COSUtil cOSUtil;
+
+    @Override
+    public Result canUpDatePrizeDraw(String prizeDrawId) {
+        PrizeDraw prizeDraw = baseMapper.selectById(prizeDrawId);
+        CouponVO detail = new CouponVO();
+        if (StringUtils.isNotBlank(prizeDraw.getCouponId())){
+             detail = couponService.getDetail(prizeDraw.getCouponId());
+        }
+        Result result = Result.ok();
+        result.data(detail);
+        Object data = activityRefPrizeService.getPrizeByIdAndPrizeActivityId(prizeDrawId).get("data");
+
+        if (data instanceof List<?>) {
+            List<?> rawList = (List<?>) data;
+            List<ActivityRefPrize> list = new ArrayList<>();
+            for (Object item : rawList) {
+                if (item instanceof ActivityRefPrize) {
+                    list.add((ActivityRefPrize) item);
+                }
+            }
+            if (CollectionUtils.isEmpty(list)) {
+                return result.put("state",true);
+            }else{
+                return result.put("state",false);
+            }
+            // 浣跨敤 list
+        }
+        return result.put("state",false);
+    }
 
     /**
      * 娣诲姞
@@ -50,7 +93,6 @@
     @Override
     public Result update(PrizeDrawForm form) {
         PrizeDraw entity = baseMapper.selectById(form.getId());
-
         // 涓虹┖鎶汭llegalArgumentException锛屽仛鍏ㄥ眬寮傚父澶勭悊
         Assert.notNull(entity, "璁板綍涓嶅瓨鍦�");
         BeanUtils.copyProperties(form, entity);
@@ -89,6 +131,14 @@
     public Result page(PrizeDrawQuery query) {
         IPage<PrizeDrawVO> page = PageUtil.getPage(query, PrizeDrawVO.class);
         baseMapper.getPage(page, query);
+        for (PrizeDrawVO vo : page.getRecords()) {
+            if (vo.getPrizeCover() != null && StringUtils.isNotBlank(vo.getPrizeCover())){
+                vo.setPrizeCoverUrl(cOSUtil.getPreviewUrl(vo.getPrizeCover()));
+            }
+            if (vo.getPrizeImg() != null && StringUtils.isNotBlank(vo.getPrizeImg())){
+                vo.setPrizeImgUrl(cOSUtil.getPreviewUrl(vo.getPrizeImg()));
+            }
+        }
         return Result.ok().data(page.getRecords()).total(page.getTotal());
     }
 
diff --git a/framework/src/main/resources/mapper/lmk/PrizeDrawMapper.xml b/framework/src/main/resources/mapper/lmk/PrizeDrawMapper.xml
index b6363b6..eba55c3 100644
--- a/framework/src/main/resources/mapper/lmk/PrizeDrawMapper.xml
+++ b/framework/src/main/resources/mapper/lmk/PrizeDrawMapper.xml
@@ -51,6 +51,12 @@
             lmk_prize_draw LPD
         WHERE
             LPD.delete_flag = 0
+        <if test="query.prizeName != null and query.prizeName != ''">
+            AND LPD.prize_name like concat('%',#{query.prizeName},'%')
+        </if>
+        <if test="query.prizeType != null and query.prizeType != ''">
+            AND LPD.prize_type = #{query.prizeType}
+        </if>
     </select>
 
 </mapper>
diff --git a/manager-api/src/main/java/cn/lili/controller/lmk/PrizeDrawController.java b/manager-api/src/main/java/cn/lili/controller/lmk/PrizeDrawController.java
new file mode 100644
index 0000000..656120f
--- /dev/null
+++ b/manager-api/src/main/java/cn/lili/controller/lmk/PrizeDrawController.java
@@ -0,0 +1,56 @@
+package cn.lili.controller.lmk;
+
+
+import cn.lili.base.Result;
+import cn.lili.modules.lmk.domain.entity.ActivityRefPrize;
+import cn.lili.modules.lmk.domain.form.PrizeDrawForm;
+import cn.lili.modules.lmk.domain.query.PrizeDrawQuery;
+import cn.lili.modules.lmk.service.ActivityRefPrizeService;
+import cn.lili.modules.lmk.service.PrizeDrawService;
+import lombok.RequiredArgsConstructor;
+import org.springframework.util.CollectionUtils;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * lmk-shop-java
+ *
+ * @author : zxl
+ * @date : 2025-08-18 15:49
+ **/
+@Validated
+@RequiredArgsConstructor
+@RestController
+@RequestMapping("/manager/lmk/prizeDraw")
+public class PrizeDrawController {
+    private final PrizeDrawService prizeDrawService;
+    private final ActivityRefPrizeService activityRefPrizeService;
+    @GetMapping
+    public Result getPage(PrizeDrawQuery query){
+        return prizeDrawService.page(query);
+    }
+    @GetMapping("/{id}")
+    public Result detail(@PathVariable("id") String id){
+        return prizeDrawService.detail(id);
+    }
+    @PutMapping
+    public Result edit(@RequestBody PrizeDrawForm form){
+        return prizeDrawService.update(form);
+    }
+    @PostMapping
+    public Result add(@RequestBody PrizeDrawForm form){
+        return prizeDrawService.add(form);
+    }
+    @DeleteMapping("/{id}")
+    public Result del(@PathVariable("id") String id){
+        return prizeDrawService.removeById(id);
+    }
+
+    @GetMapping("/canUpDatePrizeDraw/{id}")
+    public Result canUpDatePrizeDraw(@PathVariable("id") String id){
+        return prizeDrawService.canUpDatePrizeDraw(id);
+    }
+}

--
Gitblit v1.8.0