From 9d54d50c7beb2e6f0baee23ad0d536eb53d89eec Mon Sep 17 00:00:00 2001
From: peng <peng.com>
Date: 星期一, 25 八月 2025 17:55:06 +0800
Subject: [PATCH] 抽奖活动

---
 framework/src/main/resources/mapper/lmk/PrizeActivityMapper.xml                        |   49 ++++++++++++
 framework/src/main/java/cn/lili/modules/lmk/domain/vo/GrantRecordVO.java               |   31 +++++++
 framework/src/main/java/cn/lili/modules/lmk/domain/vo/PrizeInfoVO.java                 |   20 +++++
 framework/src/main/java/cn/lili/modules/lmk/domain/vo/PrizeRecordTimeVO.java           |    4 
 framework/src/main/java/cn/lili/modules/lmk/service/impl/PrizeDrawServiceImpl.java     |    5 +
 framework/src/main/java/cn/lili/modules/lmk/service/PrizeDrawService.java              |    2 
 framework/src/main/java/cn/lili/modules/lmk/service/impl/PrizeServiceImpl.java         |   49 +++++++++--
 framework/src/main/java/cn/lili/modules/lmk/mapper/PrizeDrawMapper.java                |    3 
 framework/src/main/resources/mapper/lmk/PrizeDrawMapper.xml                            |   20 +++++
 framework/src/main/java/cn/lili/modules/lmk/service/PrizeActivityService.java          |    5 +
 framework/src/main/java/cn/lili/modules/lmk/domain/vo/PrizeDetailVO.java               |   20 +++++
 framework/src/main/java/cn/lili/modules/lmk/domain/vo/PrizeProbabilityVO.java          |    2 
 buyer-api/src/main/java/cn/lili/controller/lmk/PrizeController.java                    |   11 ++
 framework/src/main/resources/mapper/lmk/PrizeRecordMapper.xml                          |    6 
 framework/src/main/java/cn/lili/modules/lmk/mapper/PrizeActivityMapper.java            |    3 
 framework/src/main/java/cn/lili/modules/lmk/service/impl/PrizeActivityServiceImpl.java |    6 +
 framework/src/main/java/cn/lili/modules/lmk/service/PrizeService.java                  |    2 
 17 files changed, 219 insertions(+), 19 deletions(-)

diff --git a/buyer-api/src/main/java/cn/lili/controller/lmk/PrizeController.java b/buyer-api/src/main/java/cn/lili/controller/lmk/PrizeController.java
index d09c64a..543fb74 100644
--- a/buyer-api/src/main/java/cn/lili/controller/lmk/PrizeController.java
+++ b/buyer-api/src/main/java/cn/lili/controller/lmk/PrizeController.java
@@ -1,7 +1,6 @@
 package cn.lili.controller.lmk;
 
 import cn.lili.base.Result;
-import cn.lili.modules.lmk.domain.entity.PrizeRecord;
 import cn.lili.modules.lmk.service.PrizeService;
 import io.swagger.annotations.Api;
 import lombok.RequiredArgsConstructor;
@@ -49,4 +48,14 @@
     public Result prizeInfo(@PathVariable String prizeActivityId) {
         return prizeService.prizeInfo(prizeActivityId);
     }
+    /**
+     * 鑾峰彇鑾峰彇鏈�杩戜腑濂栦俊鎭�
+     *
+     * @param prizeActivityId
+     * @return
+     */
+    @PostMapping("/grantRecord/{prizeActivityId}")
+    public Result grantRecord(@PathVariable String prizeActivityId) {
+        return prizeService.grantRecord(prizeActivityId);
+    }
 }
diff --git a/framework/src/main/java/cn/lili/modules/lmk/domain/vo/GrantRecordVO.java b/framework/src/main/java/cn/lili/modules/lmk/domain/vo/GrantRecordVO.java
new file mode 100644
index 0000000..ee3057a
--- /dev/null
+++ b/framework/src/main/java/cn/lili/modules/lmk/domain/vo/GrantRecordVO.java
@@ -0,0 +1,31 @@
+package cn.lili.modules.lmk.domain.vo;
+
+import com.baomidou.mybatisplus.annotation.FieldStrategy;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.time.LocalDateTime;
+import java.util.Date;
+
+/**
+ * 涓璁板綍
+ */
+@Data
+public class GrantRecordVO {
+    /**
+     * 鏄电О
+     */
+    private String nickname;
+    /**
+     * 濂栧搧鍚嶇О
+     */
+    private String prizeName;
+    /**
+     * 涓鏃堕棿
+     */
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date time;
+}
diff --git a/framework/src/main/java/cn/lili/modules/lmk/domain/vo/PrizeDetailVO.java b/framework/src/main/java/cn/lili/modules/lmk/domain/vo/PrizeDetailVO.java
new file mode 100644
index 0000000..c573e4d
--- /dev/null
+++ b/framework/src/main/java/cn/lili/modules/lmk/domain/vo/PrizeDetailVO.java
@@ -0,0 +1,20 @@
+package cn.lili.modules.lmk.domain.vo;
+
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+/**
+ * 鎶藉娲诲姩濂栧搧淇℃伅
+ */
+public class PrizeDetailVO {
+    private String id;
+    private String activityName;
+    private String activityDes;
+    private String beginTime;
+    private String endTime;
+    private String activityImg;
+    private String activityCover;
+    private List<PrizeInfoVO> prizeInfoVOS;
+}
diff --git a/framework/src/main/java/cn/lili/modules/lmk/domain/vo/PrizeInfoVO.java b/framework/src/main/java/cn/lili/modules/lmk/domain/vo/PrizeInfoVO.java
new file mode 100644
index 0000000..53f201e
--- /dev/null
+++ b/framework/src/main/java/cn/lili/modules/lmk/domain/vo/PrizeInfoVO.java
@@ -0,0 +1,20 @@
+package cn.lili.modules.lmk.domain.vo;
+
+import lombok.Data;
+
+@Data
+/**
+ * 鎶藉娲诲姩濂栧搧淇℃伅
+ */
+public class PrizeInfoVO {
+    private String id;
+    private String prizeId;
+    private String prizeContent;
+    private String maxPreDay;
+    private String prizeProbability;
+    private String remainNum;
+    private String prizeCover;
+    private String prizeDes;
+    private String prizeImg;
+    private String prizeName;
+}
diff --git a/framework/src/main/java/cn/lili/modules/lmk/domain/vo/PrizeProbabilityVO.java b/framework/src/main/java/cn/lili/modules/lmk/domain/vo/PrizeProbabilityVO.java
index 6bce225..48af53d 100644
--- a/framework/src/main/java/cn/lili/modules/lmk/domain/vo/PrizeProbabilityVO.java
+++ b/framework/src/main/java/cn/lili/modules/lmk/domain/vo/PrizeProbabilityVO.java
@@ -6,6 +6,6 @@
 
 @Data
 public class PrizeProbabilityVO {
-    private String prizeId;
+    private String activityPrizeRefId;
     private BigDecimal[][] probability;
 }
diff --git a/framework/src/main/java/cn/lili/modules/lmk/domain/vo/PrizeRecordTimeVO.java b/framework/src/main/java/cn/lili/modules/lmk/domain/vo/PrizeRecordTimeVO.java
index b3896be..de09693 100644
--- a/framework/src/main/java/cn/lili/modules/lmk/domain/vo/PrizeRecordTimeVO.java
+++ b/framework/src/main/java/cn/lili/modules/lmk/domain/vo/PrizeRecordTimeVO.java
@@ -8,9 +8,9 @@
 public class PrizeRecordTimeVO {
 
     /**
-     * 濂栧搧id
+     * 娲诲姩濂栧搧瀵瑰簲id
      */
-    private String prizeId;
+    private String activityPrizeRefId;
 
     /**
      * 娲诲姩id
diff --git a/framework/src/main/java/cn/lili/modules/lmk/mapper/PrizeActivityMapper.java b/framework/src/main/java/cn/lili/modules/lmk/mapper/PrizeActivityMapper.java
index fbf5942..8951e96 100644
--- a/framework/src/main/java/cn/lili/modules/lmk/mapper/PrizeActivityMapper.java
+++ b/framework/src/main/java/cn/lili/modules/lmk/mapper/PrizeActivityMapper.java
@@ -1,6 +1,7 @@
 package cn.lili.modules.lmk.mapper;
 
 import cn.lili.modules.lmk.domain.entity.PrizeActivity;
+import cn.lili.modules.lmk.domain.vo.PrizeDetailVO;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import cn.lili.modules.lmk.domain.vo.PrizeActivityVO;
@@ -31,4 +32,6 @@
     */
     IPage getPage(IPage page, @Param("query") PrizeActivityQuery query);
 
+    PrizeDetailVO prizeInfo(@Param("id") String id);
+
 }
diff --git a/framework/src/main/java/cn/lili/modules/lmk/mapper/PrizeDrawMapper.java b/framework/src/main/java/cn/lili/modules/lmk/mapper/PrizeDrawMapper.java
index ca071ea..c7e4dd6 100644
--- a/framework/src/main/java/cn/lili/modules/lmk/mapper/PrizeDrawMapper.java
+++ b/framework/src/main/java/cn/lili/modules/lmk/mapper/PrizeDrawMapper.java
@@ -1,6 +1,7 @@
 package cn.lili.modules.lmk.mapper;
 
 import cn.lili.modules.lmk.domain.entity.PrizeDraw;
+import cn.lili.modules.lmk.domain.vo.GrantRecordVO;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import cn.lili.modules.lmk.domain.vo.PrizeDrawVO;
@@ -31,4 +32,6 @@
     */
     IPage getPage(IPage page, @Param("query") PrizeDrawQuery query);
 
+    List<GrantRecordVO> grantRecord(@Param("id")String prizeActivityId);
+
 }
diff --git a/framework/src/main/java/cn/lili/modules/lmk/service/PrizeActivityService.java b/framework/src/main/java/cn/lili/modules/lmk/service/PrizeActivityService.java
index 7d7c058..0c957e0 100644
--- a/framework/src/main/java/cn/lili/modules/lmk/service/PrizeActivityService.java
+++ b/framework/src/main/java/cn/lili/modules/lmk/service/PrizeActivityService.java
@@ -1,10 +1,12 @@
 package cn.lili.modules.lmk.service;
 
 import cn.lili.modules.lmk.domain.entity.PrizeActivity;
+import cn.lili.modules.lmk.domain.vo.PrizeDetailVO;
 import com.baomidou.mybatisplus.extension.service.IService;
 import cn.lili.base.Result;
 import cn.lili.modules.lmk.domain.form.PrizeActivityForm;
 import cn.lili.modules.lmk.domain.query.PrizeActivityQuery;
+
 import java.util.List;
 
 /**
@@ -63,4 +65,7 @@
      * @return
      */
     Result all();
+
+    PrizeDetailVO prizeInfo(String id);
+
 }
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 5acc085..40225ad 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
@@ -69,4 +69,6 @@
      * @return
      */
     Result all();
+
+    Result grantRecord(String prizeActivityId);
 }
diff --git a/framework/src/main/java/cn/lili/modules/lmk/service/PrizeService.java b/framework/src/main/java/cn/lili/modules/lmk/service/PrizeService.java
index 7b2cbdb..5e528da 100644
--- a/framework/src/main/java/cn/lili/modules/lmk/service/PrizeService.java
+++ b/framework/src/main/java/cn/lili/modules/lmk/service/PrizeService.java
@@ -12,4 +12,6 @@
 
     Result prizeInfo(String prizeActivityId);
 
+    Result grantRecord( String prizeActivityId);
+
 }
diff --git a/framework/src/main/java/cn/lili/modules/lmk/service/impl/PrizeActivityServiceImpl.java b/framework/src/main/java/cn/lili/modules/lmk/service/impl/PrizeActivityServiceImpl.java
index 1405050..0b5e08f 100644
--- a/framework/src/main/java/cn/lili/modules/lmk/service/impl/PrizeActivityServiceImpl.java
+++ b/framework/src/main/java/cn/lili/modules/lmk/service/impl/PrizeActivityServiceImpl.java
@@ -3,6 +3,7 @@
 import cn.lili.common.utils.StringUtils;
 import cn.lili.modules.lmk.domain.entity.ActivityRefPrize;
 import cn.lili.modules.lmk.domain.vo.ActivityRefPrizeInfoVO;
+import cn.lili.modules.lmk.domain.vo.PrizeDetailVO;
 import cn.lili.modules.lmk.enums.general.PrizeActivityStatusEnum;
 import cn.lili.modules.lmk.service.ActivityRefPrizeService;
 import cn.lili.utils.COSUtil;
@@ -171,4 +172,9 @@
                 .collect(Collectors.toList());
         return Result.ok().data(vos);
     }
+
+    @Override
+    public PrizeDetailVO prizeInfo(String id) {
+        return prizeActivityMapper.prizeInfo(id);
+    }
 }
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 4ee4bc1..365366d 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
@@ -166,4 +166,9 @@
                 .collect(Collectors.toList());
         return Result.ok().data(vos);
     }
+
+    @Override
+    public Result grantRecord(String prizeActivityId) {
+        return Result.ok().data(baseMapper.grantRecord(prizeActivityId));
+    }
 }
diff --git a/framework/src/main/java/cn/lili/modules/lmk/service/impl/PrizeServiceImpl.java b/framework/src/main/java/cn/lili/modules/lmk/service/impl/PrizeServiceImpl.java
index 2da8595..bc0fc1f 100644
--- a/framework/src/main/java/cn/lili/modules/lmk/service/impl/PrizeServiceImpl.java
+++ b/framework/src/main/java/cn/lili/modules/lmk/service/impl/PrizeServiceImpl.java
@@ -8,13 +8,14 @@
 import cn.lili.common.utils.StringUtils;
 import cn.lili.modules.lmk.domain.entity.*;
 import cn.lili.modules.lmk.domain.query.PrizeRecordTimeQuery;
+import cn.lili.modules.lmk.domain.vo.PrizeDetailVO;
 import cn.lili.modules.lmk.domain.vo.PrizeProbabilityVO;
 import cn.lili.modules.lmk.domain.vo.PrizeRecordTimeVO;
 import cn.lili.modules.lmk.enums.general.*;
 import cn.lili.modules.lmk.service.*;
 import cn.lili.mybatis.BaseEntity;
 import cn.lili.rocketmq.RocketmqSendCallbackBuilder;
-import cn.lili.rocketmq.tags.CommentTagsEnum;
+import cn.lili.utils.COSUtil;
 import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
@@ -37,7 +38,6 @@
 import java.time.LocalTime;
 import java.time.ZoneId;
 import java.util.*;
-import java.util.concurrent.TimeUnit;
 import java.util.function.Function;
 import java.util.stream.Collectors;
 
@@ -55,6 +55,7 @@
     private final RedissonClient redissonClient;
     private final RocketmqCustomProperties rocketmqCustomProperties;
     private final RocketMQTemplate rocketMQTemplate;
+    private final COSUtil cosUtil;
     @Override
     @Transactional(rollbackFor = Exception.class)
     public Result prize(String prizeId) {
@@ -167,20 +168,20 @@
         refPrizes = activityRefPrizeService.list(prizeRefQuery);
         canPrizeMap = refPrizes.stream().filter(item -> {
             return item.getRemainNum() > 0;
-        }).collect(Collectors.toMap(ActivityRefPrize::getPrizeId, Function.identity()));
+        }).collect(Collectors.toMap(ActivityRefPrize::getId, Function.identity()));
         prizeRecordTimeQuery = new PrizeRecordTimeQuery();
         prizeRecordTimeQuery.setStartTime(beginTime);
         prizeRecordTimeQuery.setEndTime(endTime);
         prizeRecordTimeQuery.setRecordActivityId(prizeId);
         prizeRecordListByTime = prizeRecordService.getPrizeRecordListByTime(prizeRecordTimeQuery);
         prizeRecordListByTime.stream().filter(item->{
-            return item.getPrizeId() != null;
+            return item.getActivityPrizeRefId() != null;
         }).forEach(item -> {
-            ActivityRefPrize activityRefPrize = canPrizeMap.get(Long.parseLong(item.getPrizeId()));
+            ActivityRefPrize activityRefPrize = canPrizeMap.get(item.getActivityPrizeRefId());
             if (activityRefPrize != null) {
                 //绉婚櫎褰撴棩涓婇檺鐨勫鍝佸苟涓旀坊鍔犲埌涓嶈兘鎶藉鍟嗗搧涓幓
                 if (activityRefPrize.getMaxPreDay() <= item.getTotal()) {
-                    canPrizeMap.remove(Long.parseLong(item.getPrizeId()));
+                    canPrizeMap.remove(item.getActivityPrizeRefId());
                 }
             }
         });
@@ -204,7 +205,7 @@
         BigDecimal probabilityBegin = BigDecimal.ZERO;
         for (ActivityRefPrize item : refPrizeList) {
             PrizeProbabilityVO prizeProbabilityVO = new PrizeProbabilityVO();
-            prizeProbabilityVO.setPrizeId(item.getPrizeId());
+            prizeProbabilityVO.setActivityPrizeRefId(item.getId());
             BigDecimal multiply = item.getPrizeProbability().multiply(BigDecimal.valueOf(100));
             BigDecimal[][] position = {{probabilityBegin, multiply.add(probabilityBegin)}};
             prizeProbabilityVO.setProbability(position);
@@ -217,7 +218,7 @@
             BigDecimal minP = prizeProbabilityVO.getProbability()[0][0];
             BigDecimal maxP = prizeProbabilityVO.getProbability()[0][1];
             if (bigDecimal.compareTo(minP) > 0 && bigDecimal.compareTo(maxP) <= 0) {
-                prizeWon = prizeProbabilityVO.getPrizeId();
+                prizeWon = prizeProbabilityVO.getActivityPrizeRefId();
                 break;
             }
         }
@@ -263,7 +264,7 @@
         if (!update) {
             throw new ServiceException("褰撳墠娲诲姩澶伀鐖嗕簡璇风◢鍚庡啀璇�");
         }
-        PrizeDraw prizeDraw = prizeDrawService.getById(prizeWon);
+        PrizeDraw prizeDraw = prizeDrawService.getById(activityRefPrize.getPrizeId());
         //鍐欏叆鎶藉璁板綍
         PrizeRecord prizeRecord = new PrizeRecord();
         prizeRecord.setUserId(Long.parseLong(userId));
@@ -277,7 +278,7 @@
         prizeRecord.setPrizeNumId(Long.parseLong(waitUserPrize.getId()));
         prizeRecord.setActivityPrizeRefId(Long.parseLong(activityRefPrize.getId()));
         prizeRecord.setDistributeStatus(PrizeDistributeStatusEnum.WAIT.name());
-        prizeRecord.setPrizeId(prizeWon);
+        prizeRecord.setPrizeId(activityRefPrize.getPrizeId());
         prizeRecord.setPrizeName(prizeDraw.getPrizeName());
         prizeRecord.setPrizeActivityCover(prizeActivity.getActivityCover());
         prizeRecord.setPrizeImg(prizeDraw.getPrizeImg());
@@ -328,6 +329,13 @@
         PrizeActivity activity = prizeActivityService.getById(prizeId);
         if (activity == null) {
             throw new RuntimeException("褰撳墠娲诲姩涓嶅瓨鍦�");
+        }
+        Date activityEndtime = activity.getEndTime();
+        if (new Date().after(activityEndtime)) {
+            throw new ServiceException("褰撳墠娲诲姩宸茬粡缁撴潫");
+        }
+        if (!PrizeActivityStatusEnum.ON.name().equals(activity.getEnableStatus())) {
+            throw new ServiceException("娲诲姩杩樻病鏈夊惎鐢�");
         }
         //鑾峰彇鐢ㄦ埛鎶藉娆℃暟
         Integer prizeNum = activity.getPrizeNum();
@@ -408,6 +416,25 @@
 
     @Override
     public Result prizeInfo(String prizeActivityId) {
-        return null;
+        if (StringUtils.isBlank(prizeActivityId)) {
+            return Result.ok().data(0);
+        }
+        PrizeDetailVO data = prizeActivityService.prizeInfo(prizeActivityId);
+        data.getPrizeInfoVOS().forEach(info -> {
+            String prizeImg = info.getPrizeImg();
+            String prizeCover = info.getPrizeCover();
+            if (StringUtils.isNotBlank(prizeImg)&&!prizeImg.contains("http")) {
+                info.setPrizeImg(cosUtil.getPreviewUrl(prizeImg));
+            }
+            if (StringUtils.isNotBlank(prizeCover)&&!prizeCover.contains("http")) {
+                info.setPrizeCover(cosUtil.getPreviewUrl(prizeCover));
+            }
+        });
+        return Result.ok().data(data);
+    }
+
+    @Override
+    public Result grantRecord(String prizeActivityId) {
+        return prizeDrawService.grantRecord(prizeActivityId);
     }
 }
diff --git a/framework/src/main/resources/mapper/lmk/PrizeActivityMapper.xml b/framework/src/main/resources/mapper/lmk/PrizeActivityMapper.xml
index d6b1535..204c4fa 100644
--- a/framework/src/main/resources/mapper/lmk/PrizeActivityMapper.xml
+++ b/framework/src/main/resources/mapper/lmk/PrizeActivityMapper.xml
@@ -64,5 +64,52 @@
         <if test="query.endTime != null">AND LPA.end_time &lt;= #{query.endTime}</if>
 
     </select>
-
+    <resultMap id="prizeInfoMap" type="cn.lili.modules.lmk.domain.vo.PrizeDetailVO">
+        <id property="id" column="id"/>
+        <result property="activityName" column="activity_name"/>
+        <result property="activityDes" column="activity_des"/>
+        <result property="beginTime" column="begin_time"/>
+        <result property="endTime" column="end_time"/>
+        <result property="activityImg" column="activity_img"/>
+        <result property="activityCover" column="activity_cover"/>
+        <collection property="prizeInfoVOS" ofType="cn.lili.modules.lmk.domain.vo.PrizeInfoVO">
+            <id property="id" column="refId"/>
+            <result property="prizeId" column="prizeId"/>
+            <result property="prizeContent" column="prize_content"/>
+            <result property="maxPreDay" column="max_pre_day"/>
+            <result property="prizeProbability" column="prize_probability"/>
+            <result property="remainNum" column="remain_num"/>
+            <result property="prizeCover" column="prize_cover"/>
+            <result property="prizeDes" column="prize_des"/>
+            <result property="prizeImg" column="prize_img"/>
+            <result property="prizeName" column="prize_name"/>
+        </collection>
+     </resultMap>
+    <select id="prizeInfo" resultMap="prizeInfoMap">
+        SELECT lpa.id,
+               lpa.activity_name,
+               lpa.activity_des,
+               lpa.begin_time,
+               lpa.end_time,
+               lpa.activity_img,
+               lpa.activity_cover,
+               larp.id refId,
+               larp.prize_id,
+               larp.prize_content,
+               larp.max_pre_day,
+               larp.prize_probability,
+               larp.remain_num,
+               lpd.prize_cover,
+               lpd.prize_des,
+               lpd.prize_img,
+               lpd.prize_name
+        FROM lmk_prize_activity lpa
+                 JOIN lmk_activity_ref_prize larp ON larp.prize_activity_id = lpa.id
+            AND lpa.delete_flag = 0
+            AND larp.delete_flag = 0
+                 JOIN lmk_prize_draw lpd ON lpd.id = larp.prize_id
+            AND lpd.delete_flag = 0
+            AND larp.delete_flag = 0
+        WHERE lpa.id = #{id}
+    </select>
 </mapper>
diff --git a/framework/src/main/resources/mapper/lmk/PrizeDrawMapper.xml b/framework/src/main/resources/mapper/lmk/PrizeDrawMapper.xml
index eba55c3..b60831e 100644
--- a/framework/src/main/resources/mapper/lmk/PrizeDrawMapper.xml
+++ b/framework/src/main/resources/mapper/lmk/PrizeDrawMapper.xml
@@ -58,5 +58,25 @@
             AND LPD.prize_type = #{query.prizeType}
         </if>
     </select>
+    <resultMap id="grantRecordMap" type="cn.lili.modules.lmk.domain.vo.GrantRecordVO">
+    <result property="nickname" column="nick_name"/>
+    <result property="prizeName" column="prize_name"/>
+    <result property="time" column="create_time"/>
+    </resultMap>
+    <select id="grantRecord" resultMap="grantRecordMap">
+        SELECT
+            nick_name,
+            prize_name,
+            create_time
+        FROM
+            lmk_prize_record
+        WHERE
+            prize_status = 'WIN'
+          AND distribute_status = 'SUCCESS'
+          AND prize_activity_id = #{id}
+        ORDER BY
+            create_time DESC
+        limit 10
+    </select>
 
 </mapper>
diff --git a/framework/src/main/resources/mapper/lmk/PrizeRecordMapper.xml b/framework/src/main/resources/mapper/lmk/PrizeRecordMapper.xml
index a0fc583..bfc4500 100644
--- a/framework/src/main/resources/mapper/lmk/PrizeRecordMapper.xml
+++ b/framework/src/main/resources/mapper/lmk/PrizeRecordMapper.xml
@@ -67,13 +67,13 @@
             LPR.delete_flag = 0
     </select>
     <resultMap id="getPrizeRecordListByTimeMap" type="cn.lili.modules.lmk.domain.vo.PrizeRecordTimeVO">
-        <result property="prizeId" column="prize_id"/>
+        <result property="activityPrizeRefId" column="activity_prize_ref_id"/>
         <result property="prizeActivityId" column="prize_activity_id"/>
         <result property="total" column="total"/>
     </resultMap>
     <select id="getPrizeRecordListByTime" resultMap="getPrizeRecordListByTimeMap">
         SELECT
-            prize_id,
+            activity_prize_ref_id,
             prize_activity_id,
             count(*) total
         FROM
@@ -84,7 +84,7 @@
           AND create_time BETWEEN #{query.startTime}
             AND #{query.endTime}
         GROUP BY
-            prize_id,
+            activity_prize_ref_id,
             prize_activity_id;
     </select>
 </mapper>

--
Gitblit v1.8.0