Forráskód Böngészése

直播红包及抽奖逻辑代码

chenguo 2 napja
szülő
commit
099544b485
38 módosított fájl, 967 hozzáadás és 236 törlés
  1. 40 6
      fs-admin/src/main/java/com/fs/live/controller/LiveGoodsController.java
  2. 35 1
      fs-admin/src/main/java/com/fs/live/controller/LiveLotteryConfController.java
  3. 41 10
      fs-admin/src/main/java/com/fs/live/controller/LiveRedConfController.java
  4. 9 14
      fs-admin/src/main/java/com/fs/live/controller/LiveSensitiveWordsController.java
  5. 18 2
      fs-live-app/src/main/java/com/fs/app/controller/LiveRedController.java
  6. 60 0
      fs-live-app/src/main/java/com/fs/app/controller/LiveUserGiftController.java
  7. 0 2
      fs-service/src/main/java/com/fs/live/domain/LiveEventConf.java
  8. 7 7
      fs-service/src/main/java/com/fs/live/domain/LiveLotteryConf.java
  9. 0 3
      fs-service/src/main/java/com/fs/live/domain/LiveLotteryRecord.java
  10. 2 4
      fs-service/src/main/java/com/fs/live/domain/LiveLotteryRegistration.java
  11. 9 6
      fs-service/src/main/java/com/fs/live/domain/LiveRedConf.java
  12. 65 0
      fs-service/src/main/java/com/fs/live/domain/LiveUserGift.java
  13. 0 6
      fs-service/src/main/java/com/fs/live/domain/LiveUserLotteryRecord.java
  14. 1 5
      fs-service/src/main/java/com/fs/live/domain/LiveUserRedRecord.java
  15. 36 7
      fs-service/src/main/java/com/fs/live/mapper/LiveLotteryConfMapper.java
  16. 36 7
      fs-service/src/main/java/com/fs/live/mapper/LiveRedConfMapper.java
  17. 19 0
      fs-service/src/main/java/com/fs/live/mapper/LiveUserGiftMapper.java
  18. 26 7
      fs-service/src/main/java/com/fs/live/mapper/LiveUserRedRecordMapper.java
  19. 29 0
      fs-service/src/main/java/com/fs/live/param/RedPO.java
  20. 19 7
      fs-service/src/main/java/com/fs/live/service/ILiveLotteryConfService.java
  21. 22 7
      fs-service/src/main/java/com/fs/live/service/ILiveRedConfService.java
  22. 1 0
      fs-service/src/main/java/com/fs/live/service/ILiveUserFollowService.java
  23. 14 0
      fs-service/src/main/java/com/fs/live/service/ILiveUserGiftService.java
  24. 12 7
      fs-service/src/main/java/com/fs/live/service/ILiveUserLotteryRecordService.java
  25. 2 2
      fs-service/src/main/java/com/fs/live/service/impl/LiveDataServiceImpl.java
  26. 23 7
      fs-service/src/main/java/com/fs/live/service/impl/LiveGiftServiceImpl.java
  27. 60 7
      fs-service/src/main/java/com/fs/live/service/impl/LiveLotteryConfServiceImpl.java
  28. 195 7
      fs-service/src/main/java/com/fs/live/service/impl/LiveRedConfServiceImpl.java
  29. 6 1
      fs-service/src/main/java/com/fs/live/service/impl/LiveUserFollowServiceImpl.java
  30. 19 0
      fs-service/src/main/java/com/fs/live/service/impl/LiveUserGiftServiceImpl.java
  31. 64 8
      fs-service/src/main/java/com/fs/live/service/impl/LiveUserLotteryRecordServiceImpl.java
  32. 11 11
      fs-service/src/main/resources/mapper/live/LiveEventConfMapper.xml
  33. 16 15
      fs-service/src/main/resources/mapper/live/LiveLotteryConfMapper.xml
  34. 13 10
      fs-service/src/main/resources/mapper/live/LiveLotteryRecordMapper.xml
  35. 10 18
      fs-service/src/main/resources/mapper/live/LiveLotteryRegistrationMapper.xml
  36. 20 22
      fs-service/src/main/resources/mapper/live/LiveRedConfMapper.xml
  37. 14 10
      fs-service/src/main/resources/mapper/live/LiveUserLotteryRecordMapper.xml
  38. 13 10
      fs-service/src/main/resources/mapper/live/LiveUserRedRecordMapper.xml

+ 40 - 6
fs-admin/src/main/java/com/fs/live/controller/LiveGoodsController.java

@@ -4,16 +4,22 @@ import com.fs.common.annotation.Log;
 import com.fs.common.core.controller.BaseController;
 import com.fs.common.core.domain.AjaxResult;
 import com.fs.common.core.domain.R;
+import com.fs.common.core.domain.model.LoginUser;
 import com.fs.common.core.page.TableDataInfo;
 import com.fs.common.enums.BusinessType;
+import com.fs.common.utils.SecurityUtils;
 import com.fs.common.utils.poi.ExcelUtil;
+import com.fs.company.domain.CompanyUser;
+import com.fs.company.service.ICompanyUserService;
 import com.fs.live.domain.LiveGoods;
 import com.fs.live.service.ILiveGoodsService;
+import com.fs.live.vo.LiveGoodsVo;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
 
 import java.util.List;
+import java.util.Map;
 
 /**
  * 直播商品Controller
@@ -28,15 +34,22 @@ public class LiveGoodsController extends BaseController
     @Autowired
     private ILiveGoodsService liveGoodsService;
 
+    @Autowired
+    private ICompanyUserService companyUserService;
+
     /**
      * 查询直播商品列表
      */
     @PreAuthorize("@ss.hasPermi('live:liveGoods:list')")
     @GetMapping("/list")
-    public TableDataInfo list(LiveGoods liveGoods)
+    public TableDataInfo list(LiveGoods liveGoods, @RequestParam(value = "liveId", required = true) Long liveId)
     {
+        // 设置企业ID和企业用户ID
+        setCompanyId(liveGoods);
+        liveGoods.setLiveId(liveId);
+
         startPage();
-        List<LiveGoods> list = liveGoodsService.selectLiveGoodsList(liveGoods);
+        List<LiveGoodsVo> list = liveGoodsService.selectProductListByLiveId(liveGoods);
         return getDataTable(list);
     }
 
@@ -48,6 +61,9 @@ public class LiveGoodsController extends BaseController
     @GetMapping("/export")
     public AjaxResult export(LiveGoods liveGoods)
     {
+        // 设置企业ID和企业用户ID
+        setCompanyId(liveGoods);
+
         List<LiveGoods> list = liveGoodsService.selectLiveGoodsList(liveGoods);
         ExcelUtil<LiveGoods> util = new ExcelUtil<LiveGoods>(LiveGoods.class);
         return util.exportExcel(list, "直播商品数据");
@@ -60,7 +76,8 @@ public class LiveGoodsController extends BaseController
     @GetMapping(value = "/{goodsId}")
     public AjaxResult getInfo(@PathVariable("goodsId") Long goodsId)
     {
-        return AjaxResult.success(liveGoodsService.selectLiveGoodsByGoodsId(goodsId));
+        //CompanyUser user = SecurityUtils.getLoginUser().getUser();
+        return AjaxResult.success();
     }
 
     /**
@@ -69,9 +86,12 @@ public class LiveGoodsController extends BaseController
     @PreAuthorize("@ss.hasPermi('live:liveGoods:add')")
     @Log(title = "直播商品", businessType = BusinessType.INSERT)
     @PostMapping
-    public AjaxResult add(@RequestBody LiveGoods liveGoods)
+    public AjaxResult add(@RequestBody Map<String, Object> payload)
     {
-        return toAjax(liveGoodsService.insertLiveGoods(liveGoods));
+        LoginUser loginUser = SecurityUtils.getLoginUser();
+        CompanyUser companyUser = companyUserService.selectCompanyUserById(loginUser.getUser().getUserId());
+        //CompanyUser user = loginUser.getUser();
+        return toAjax(liveGoodsService.insertLiveGoods(payload,companyUser));
     }
 
     /**
@@ -90,12 +110,26 @@ public class LiveGoodsController extends BaseController
      */
     @PreAuthorize("@ss.hasPermi('live:liveGoods:remove')")
     @Log(title = "直播商品", businessType = BusinessType.DELETE)
-	@DeleteMapping("/{goodsIds}")
+    @DeleteMapping("/{goodsIds}")
     public AjaxResult remove(@PathVariable Long[] goodsIds)
     {
         return toAjax(liveGoodsService.deleteLiveGoodsByGoodsIds(goodsIds));
     }
 
+    /**
+     * 设置企业ID 企业用户ID
+     * @param liveGoods 直播商品
+     */
+    private void setCompanyId(LiveGoods liveGoods) {
+        // 设置企业ID 企业用户ID
+        LoginUser loginUser = SecurityUtils.getLoginUser();
+        CompanyUser companyUser = companyUserService.selectCompanyUserById(loginUser.getUser().getUserId());
+        liveGoods.setCompanyId(companyUser.getCompanyId());
+        liveGoods.setCompanyUserId(companyUser.getUserId());
+    }
+
+
+
     /**
      * 获取直播店铺
      * */

+ 35 - 1
fs-admin/src/main/java/com/fs/live/controller/LiveLotteryConfController.java

@@ -22,7 +22,7 @@ import com.fs.common.core.page.TableDataInfo;
 
 /**
  * 直播抽奖配置Controller
- * 
+ *
  * @author fs
  * @date 2025-07-17
  */
@@ -100,4 +100,38 @@ public class LiveLotteryConfController extends BaseController
     {
         return toAjax(liveLotteryConfService.deleteLiveLotteryConfByLotteryIds(lotteryIds));
     }
+
+    @GetMapping("/{id}")
+    public LiveLotteryConf getById(@PathVariable Long id) {
+        return liveLotteryConfService.getById(id);
+    }
+
+    @GetMapping("/live/{liveId}")
+    public List<LiveLotteryConf> getByLiveId(@PathVariable Long liveId) {
+        return liveLotteryConfService.getByLiveId(liveId);
+    }
+
+    @PostMapping
+    public void create(@RequestBody LiveLotteryConf conf) {
+        liveLotteryConfService.create(conf);
+    }
+
+    @PutMapping
+    public void update(@RequestBody LiveLotteryConf conf) {
+        liveLotteryConfService.update(conf);
+    }
+
+    @DeleteMapping("/{id}")
+    public void delete(@PathVariable Long id) {
+        liveLotteryConfService.delete(id);
+    }
+
+    /**
+     * 发起抽奖
+     * */
+    @GetMapping("/start/{lotteryId}")
+    public String  start(@PathVariable Long lotteryId) {
+       return liveLotteryConfService.startLottery(lotteryId,getUserId());
+    }
+
 }

+ 41 - 10
fs-admin/src/main/java/com/fs/live/controller/LiveRedConfController.java

@@ -1,16 +1,11 @@
 package com.fs.live.controller;
 
 import java.util.List;
+
+import com.fs.live.param.RedPO;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.PutMapping;
-import org.springframework.web.bind.annotation.DeleteMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 import com.fs.common.annotation.Log;
 import com.fs.common.core.controller.BaseController;
 import com.fs.common.core.domain.AjaxResult;
@@ -22,12 +17,12 @@ import com.fs.common.core.page.TableDataInfo;
 
 /**
  * 直播红包记录配置Controller
- * 
+ *
  * @author fs
  * @date 2025-07-17
  */
 @RestController
-@RequestMapping("/live/liveRedConf")
+@RequestMapping("/app/live/liveRedConf")
 public class LiveRedConfController extends BaseController
 {
     @Autowired
@@ -100,4 +95,40 @@ public class LiveRedConfController extends BaseController
     {
         return toAjax(liveRedConfService.deleteLiveRedConfByRedIds(redIds));
     }
+
+    @GetMapping("/{id}")
+    public LiveRedConf getById(@PathVariable Long id) {
+        return liveRedConfService.getById(id);
+    }
+
+    @GetMapping("/live/{liveId}")
+    public List<LiveRedConf> getByLiveId(@PathVariable Long liveId) {
+        return liveRedConfService.getByLiveId(liveId);
+    }
+
+    @PostMapping
+    public void create(@RequestBody LiveRedConf conf) {
+        liveRedConfService.create(conf);
+    }
+
+    @PutMapping
+    public void update(@RequestBody LiveRedConf conf) {
+        liveRedConfService.update(conf);
+    }
+
+    @DeleteMapping("/{id}")
+    public void delete(@PathVariable Long id) {
+        liveRedConfService.delete(id);
+    }
+
+    /**
+     * 点击发放红包
+     * */
+    @PostMapping("/start/{redId}")
+    public String start(@PathVariable String redId) {
+        return liveRedConfService.start(redId,getUserId());
+    }
+
+
+
 }

+ 9 - 14
fs-admin/src/main/java/com/fs/live/controller/LiveSensitiveWordsController.java

@@ -1,28 +1,22 @@
 package com.fs.live.controller;
 
-import java.util.List;
-import org.springframework.security.access.prepost.PreAuthorize;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.PutMapping;
-import org.springframework.web.bind.annotation.DeleteMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
 import com.fs.common.annotation.Log;
 import com.fs.common.core.controller.BaseController;
 import com.fs.common.core.domain.AjaxResult;
+import com.fs.common.core.page.TableDataInfo;
 import com.fs.common.enums.BusinessType;
+import com.fs.common.utils.poi.ExcelUtil;
 import com.fs.live.domain.LiveSensitiveWords;
 import com.fs.live.service.ILiveSensitiveWordsService;
-import com.fs.common.utils.poi.ExcelUtil;
-import com.fs.common.core.page.TableDataInfo;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
 
 /**
  * 直播间敏感词过滤Controller
- * 
+ *
  * @author fs
  * @date 2025-07-08
  */
@@ -76,6 +70,7 @@ public class LiveSensitiveWordsController extends BaseController
     @PostMapping
     public AjaxResult add(@RequestBody LiveSensitiveWords liveSensitiveWords)
     {
+
         return toAjax(liveSensitiveWordsService.insertLiveSensitiveWords(liveSensitiveWords));
     }
 

+ 18 - 2
fs-live-app/src/main/java/com/fs/app/controller/LiveRedController.java

@@ -1,13 +1,29 @@
 package com.fs.app.controller;
 
+import com.fs.app.annotation.Login;
+import com.fs.live.param.RedPO;
+import com.fs.live.service.ILiveRedConfService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 @RestController
 @RequestMapping("/app/live/liveRed")
-public class LiveRedController {
+public class LiveRedController extends AppBaseController{
+
+    @Autowired
+    private ILiveRedConfService liveRedConfService;
 
     /**
-     * 抢红包
+     * 领取红包
      * */
+    @Login
+    @PostMapping("/claim")
+    public boolean claim(@RequestBody RedPO red) {
+        red.setUserId(Long.parseLong(getUserId()));
+        return liveRedConfService.claimRedPacket(red);
+    }
+
 }

+ 60 - 0
fs-live-app/src/main/java/com/fs/app/controller/LiveUserGiftController.java

@@ -0,0 +1,60 @@
+package com.fs.app.controller;
+
+import com.fs.app.annotation.Login;
+import com.fs.common.core.redis.RedisCache;
+import com.fs.his.domain.FsUser;
+import com.fs.his.service.IFsUserService;
+import com.fs.live.domain.LiveGift;
+import com.fs.live.domain.LiveUserGift;
+import com.fs.live.service.ILiveGiftService;
+import com.fs.live.service.ILiveUserGiftService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+@RestController
+@RequestMapping("/app/live/liveUserGift")
+public class LiveUserGiftController extends AppBaseController{
+
+    @Autowired
+    private ILiveUserGiftService liveUserGiftService;
+
+    @Autowired
+    private ILiveGiftService liveGiftService;
+
+    @Autowired
+    private RedisCache redisCache;
+
+    @Autowired
+    private IFsUserService  fsUserService;
+
+    /**
+     *给直播间送礼物
+     */
+    @Login
+    @PostMapping("/send")
+    @Transactional
+    public String send(@RequestBody LiveUserGift liveUserGift) {
+        liveUserGift.setUserId(Long.parseLong(getUserId()));
+        long giftValue;
+        List<LiveGift> liveGifts = redisCache.getCacheList("liveGift");
+        LiveGift liveGift = liveGifts.stream().filter(gift ->
+                gift.getGiftId().equals(liveUserGift.getGiftId()))
+                .findFirst().orElse(null);
+        if (liveGift == null) {
+            return "礼物信息不存在";
+        }else{
+            giftValue = liveGift.getPrice().longValue() * liveUserGift.getCn();
+        }
+        FsUser user=fsUserService.selectFsUserByUserId(liveUserGift.getUserId());
+        if (user.getIntegral() < giftValue) {
+            return "账户余额不足";
+        }
+        user.setIntegral(user.getIntegral() - giftValue);
+        fsUserService.updateFsUser(user);
+        return liveUserGiftService.save(liveUserGift)?"赠送礼物成功":"赠送礼物失败";
+    }
+
+}

+ 0 - 2
fs-service/src/main/java/com/fs/live/domain/LiveEventConf.java

@@ -37,8 +37,6 @@ public class LiveEventConf extends BaseEntity{
     @Excel(name = "关联红包ID")
     private Long redId;
 
-    /** 修改日期 */
-    private Date udpateTime;
 
 
 }

+ 7 - 7
fs-service/src/main/java/com/fs/live/domain/LiveLotteryConf.java

@@ -29,6 +29,10 @@ public class LiveLotteryConf extends BaseEntity{
     @Excel(name = "商品ID")
     private Long productId;
 
+    /** 抽奖状态*/
+    @Excel(name = "抽奖状态 0:未开始 1:进行中 2:已结束")
+    private String lotteryStatus;
+
     /** 奖品等级 */
     @Excel(name = "奖品等级")
     private Long prizeLevel;
@@ -50,21 +54,17 @@ public class LiveLotteryConf extends BaseEntity{
     private Long require;
 
     /** 参与抽奖方式 2/3对应的配置,2:送礼数量,以最低档位礼物为单位 3:指定商品Id及数量,|竖线分割 */
-    @Excel(name = "参与抽奖方式 2/3对应的配置,2:送礼数量,以最低档位礼物为单位 3:指定商品Id及数量,|竖线分割")
+    @Excel(name = "参与抽奖方式 2/3对应的配置,礼物/商品Id竖线分割数量")
     private String requireConf;
 
     /** 持续时间 单位:分 */
     @Excel(name = "持续时间 单位:分")
     private Long duration;
 
-    /** 描述/标题 */
-    @Excel(name = "描述/标题")
+    /** 描述 */
+    @Excel(name = "描述")
     private String desc;
 
-    /** 修改日期 */
-    @JsonFormat(pattern = "yyyy-MM-dd")
-    @Excel(name = "修改日期", width = 30, dateFormat = "yyyy-MM-dd")
-    private Date udpateTime;
 
 
 }

+ 0 - 3
fs-service/src/main/java/com/fs/live/domain/LiveLotteryRecord.java

@@ -19,7 +19,6 @@ import lombok.EqualsAndHashCode;
 public class LiveLotteryRecord extends BaseEntity{
 
     /** 抽奖ID */
-    @Excel(name = "抽奖ID")
     private Long lotteryId;
 
     /** 直播间ID */
@@ -30,8 +29,6 @@ public class LiveLotteryRecord extends BaseEntity{
     @Excel(name = "抽奖状态 0:未开始 1:进行中 2:已结束")
     private Long lotteryStauts;
 
-    /** 修改日期 */
-    private Date udpateTime;
 
 
 }

+ 2 - 4
fs-service/src/main/java/com/fs/live/domain/LiveLotteryRegistration.java

@@ -19,6 +19,7 @@ import lombok.EqualsAndHashCode;
 public class LiveLotteryRegistration extends BaseEntity{
 
     /** 登记ID */
+    @Excel(name = "登记ID")
     private Long registrationId;
 
     /** 直播间ID */
@@ -37,10 +38,7 @@ public class LiveLotteryRegistration extends BaseEntity{
     @Excel(name = "奖品等级")
     private Long rizeLevel;
 
-    /** 修改日期 */
-    @JsonFormat(pattern = "yyyy-MM-dd")
-    @Excel(name = "修改日期", width = 30, dateFormat = "yyyy-MM-dd")
-    private Date udpateTime;
+
 
 
 }

+ 9 - 6
fs-service/src/main/java/com/fs/live/domain/LiveRedConf.java

@@ -1,6 +1,8 @@
 package com.fs.live.domain;
 
 import java.util.Date;
+
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.fs.common.annotation.Excel;
@@ -22,8 +24,8 @@ public class LiveRedConf extends BaseEntity{
     private Long redId;
 
     /** 红包状态 0:未发放 1:已发放 2:已结束 */
-    @Excel(name = "红包状态 0:未发放 1:发放 2:已结束")
-    private Long redStauts;
+    @Excel(name = "红包状态 0:未发放 1:发放 2:已结束")
+    private Long redStatus;
 
     /** 有效时间 单位:分 */
     @Excel(name = "有效时间 单位:分")
@@ -37,8 +39,8 @@ public class LiveRedConf extends BaseEntity{
     @Excel(name = "直播间ID")
     private Long liveId;
 
-    /** 红包数量 */
-    @Excel(name = "红包数量")
+    /** 红包金额 */
+    @Excel(name = "红包金额")
     private Long redNum;
 
     /** 可中奖份量 */
@@ -53,8 +55,9 @@ public class LiveRedConf extends BaseEntity{
     @Excel(name = "描述")
     private String desc;
 
-    /** 修改日期 */
-    private Date udpateTime;
+    /** 剩余红包数 */
+    @TableField(exist = false)
+    private Integer remaining;
 
 
 }

+ 65 - 0
fs-service/src/main/java/com/fs/live/domain/LiveUserGift.java

@@ -0,0 +1,65 @@
+package com.fs.live.domain;
+
+import java.util.Date;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.fs.common.annotation.Excel;
+import lombok.Data;
+import com.fs.common.core.domain.BaseEntity;
+import lombok.EqualsAndHashCode;
+
+/**
+ * 用户礼物记录对象 live_user_gift
+ *
+ * @author fs
+ * @date 2025-07-17
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class LiveUserGift extends BaseEntity {
+
+    /**
+     * 主键ID
+     */
+    @TableId
+    private Long id;
+
+    /**
+     * 用户ID
+     */
+    @Excel(name = "用户ID")
+    private Long userId;
+
+    /**
+     * 礼物ID
+     */
+    @Excel(name = "礼物ID")
+    private Long giftId;
+
+    /**
+     * 礼物名称
+     */
+    @Excel(name = "礼物名称")
+    private String giftName;
+
+    /**
+     * 礼物数量
+     */
+    @Excel(name = "礼物数量")
+    private Long cn;
+
+    /**
+     * 送礼时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @Excel(name = "送礼时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
+    private Date giftTime;
+
+    /**
+     * 直播间ID
+     */
+    @Excel(name = "直播间ID")
+    private Long liveId;
+
+
+}

+ 0 - 6
fs-service/src/main/java/com/fs/live/domain/LiveUserLotteryRecord.java

@@ -19,7 +19,6 @@ import lombok.EqualsAndHashCode;
 public class LiveUserLotteryRecord extends BaseEntity{
 
     /** $column.columnComment */
-    @Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
     private Long id;
 
     /** 抽奖ID */
@@ -38,10 +37,5 @@ public class LiveUserLotteryRecord extends BaseEntity{
     @Excel(name = "商品ID")
     private Long productId;
 
-    /** 修改日期 */
-    @JsonFormat(pattern = "yyyy-MM-dd")
-    @Excel(name = "修改日期", width = 30, dateFormat = "yyyy-MM-dd")
-    private Date udpateTime;
-
 
 }

+ 1 - 5
fs-service/src/main/java/com/fs/live/domain/LiveUserRedRecord.java

@@ -19,7 +19,6 @@ import lombok.EqualsAndHashCode;
 public class LiveUserRedRecord extends BaseEntity{
 
     /** $column.columnComment */
-    @Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
     private Long id;
 
     /** 抽奖ID */
@@ -38,10 +37,7 @@ public class LiveUserRedRecord extends BaseEntity{
     @Excel(name = "芳华币数量")
     private Long integral;
 
-    /** 修改日期 */
-    @JsonFormat(pattern = "yyyy-MM-dd")
-    @Excel(name = "修改日期", width = 30, dateFormat = "yyyy-MM-dd")
-    private Date udpateTime;
+
 
 
 }

+ 36 - 7
fs-service/src/main/java/com/fs/live/mapper/LiveLotteryConfMapper.java

@@ -3,17 +3,19 @@ package com.fs.live.mapper;
 import java.util.List;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.fs.live.domain.LiveLotteryConf;
+import org.apache.ibatis.annotations.*;
 
 /**
  * 直播抽奖配置Mapper接口
- * 
+ *
  * @author fs
  * @date 2025-07-17
  */
+@Mapper
 public interface LiveLotteryConfMapper extends BaseMapper<LiveLotteryConf>{
     /**
      * 查询直播抽奖配置
-     * 
+     *
      * @param lotteryId 直播抽奖配置主键
      * @return 直播抽奖配置
      */
@@ -21,7 +23,7 @@ public interface LiveLotteryConfMapper extends BaseMapper<LiveLotteryConf>{
 
     /**
      * 查询直播抽奖配置列表
-     * 
+     *
      * @param liveLotteryConf 直播抽奖配置
      * @return 直播抽奖配置集合
      */
@@ -29,7 +31,7 @@ public interface LiveLotteryConfMapper extends BaseMapper<LiveLotteryConf>{
 
     /**
      * 新增直播抽奖配置
-     * 
+     *
      * @param liveLotteryConf 直播抽奖配置
      * @return 结果
      */
@@ -37,7 +39,7 @@ public interface LiveLotteryConfMapper extends BaseMapper<LiveLotteryConf>{
 
     /**
      * 修改直播抽奖配置
-     * 
+     *
      * @param liveLotteryConf 直播抽奖配置
      * @return 结果
      */
@@ -45,7 +47,7 @@ public interface LiveLotteryConfMapper extends BaseMapper<LiveLotteryConf>{
 
     /**
      * 删除直播抽奖配置
-     * 
+     *
      * @param lotteryId 直播抽奖配置主键
      * @return 结果
      */
@@ -53,9 +55,36 @@ public interface LiveLotteryConfMapper extends BaseMapper<LiveLotteryConf>{
 
     /**
      * 批量删除直播抽奖配置
-     * 
+     *
      * @param lotteryIds 需要删除的数据主键集合
      * @return 结果
      */
     int deleteLiveLotteryConfByLotteryIds(Long[] lotteryIds);
+
+    @Select("SELECT * FROM live_lottery_conf WHERE lottery_id = #{lotteryId}")
+    LiveLotteryConf selectById(Long lotteryId);
+
+    @Select("SELECT * FROM live_lottery_conf WHERE live_id = #{liveId}")
+    List<LiveLotteryConf> selectByLiveId(Long liveId);
+
+    @Insert({
+            "INSERT INTO live_lottery_conf (live_id, product_id, prize_level, per_lottery_num,total_lots, total_send, `require`, " +
+                    "require_conf, duration, `desc`, create_time)"+
+            "VALUES (#{liveId}, #{productId}, #{prizeLevel}, #{perLotteryNum},#{totalLots}, #{totalSend}, #{require}, " +
+                    "#{requireConf}, #{duration}, #{desc},NOW())"})
+    @Options(useGeneratedKeys = true, keyProperty = "lotteryId")
+    int insert(LiveLotteryConf conf);
+
+    @Update({
+            "UPDATE live_lottery_conf SET live_id = #{liveId}, product_id = #{productId},"+
+            "prize_level = #{prizeLevel}, per_lottery_num = #{perLotteryNum},"+
+            "total_lots = #{totalLots}, total_send = #{totalSend}, `require` = #{require},"+
+            "require_conf = #{requireConf}, duration = #{duration}, `desc` = #{desc},"+
+            "update_time = NOW() ,lottery_status = #{lotteryStatus}"+
+            "WHERE lottery_id = #{lotteryId}"
+    })
+    void updateAll(LiveLotteryConf conf);
+
+    @Delete("DELETE FROM live_lottery_conf WHERE lottery_id = #{lotteryId}")
+    void deleteById(Long lotteryId);
 }

+ 36 - 7
fs-service/src/main/java/com/fs/live/mapper/LiveRedConfMapper.java

@@ -3,17 +3,19 @@ package com.fs.live.mapper;
 import java.util.List;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.fs.live.domain.LiveRedConf;
+import org.apache.ibatis.annotations.*;
 
 /**
  * 直播红包记录配置Mapper接口
- * 
+ *
  * @author fs
  * @date 2025-07-17
  */
+@Mapper
 public interface LiveRedConfMapper extends BaseMapper<LiveRedConf>{
     /**
      * 查询直播红包记录配置
-     * 
+     *
      * @param redId 直播红包记录配置主键
      * @return 直播红包记录配置
      */
@@ -21,7 +23,7 @@ public interface LiveRedConfMapper extends BaseMapper<LiveRedConf>{
 
     /**
      * 查询直播红包记录配置列表
-     * 
+     *
      * @param liveRedConf 直播红包记录配置
      * @return 直播红包记录配置集合
      */
@@ -29,7 +31,7 @@ public interface LiveRedConfMapper extends BaseMapper<LiveRedConf>{
 
     /**
      * 新增直播红包记录配置
-     * 
+     *
      * @param liveRedConf 直播红包记录配置
      * @return 结果
      */
@@ -37,7 +39,7 @@ public interface LiveRedConfMapper extends BaseMapper<LiveRedConf>{
 
     /**
      * 修改直播红包记录配置
-     * 
+     *
      * @param liveRedConf 直播红包记录配置
      * @return 结果
      */
@@ -45,7 +47,7 @@ public interface LiveRedConfMapper extends BaseMapper<LiveRedConf>{
 
     /**
      * 删除直播红包记录配置
-     * 
+     *
      * @param redId 直播红包记录配置主键
      * @return 结果
      */
@@ -53,9 +55,36 @@ public interface LiveRedConfMapper extends BaseMapper<LiveRedConf>{
 
     /**
      * 批量删除直播红包记录配置
-     * 
+     *
      * @param redIds 需要删除的数据主键集合
      * @return 结果
      */
     int deleteLiveRedConfByRedIds(Long[] redIds);
+
+    @Select("SELECT * FROM live_red_conf WHERE red_id = #{redId}")
+    LiveRedConf selectById(Long redId);
+
+    @Select("SELECT * FROM live_red_conf WHERE live_id = #{liveId}")
+    List<LiveRedConf> selectByLiveId(Long liveId);
+
+    @Insert({
+            "INSERT INTO live_red_conf (red_stauts, duration, red_type, live_id, red_num,"+
+            "total_lots, total_send, `desc`, create_time, update_time, create_by, update_by)"+
+            "VALUES (#{redStatus}, #{duration}, #{redType}, #{liveId}, #{redNum},"+
+            "#{totalLots}, #{totalSend}, #{desc}, NOW(), null, null, null)"
+    })
+    @Options(useGeneratedKeys = true, keyProperty = "redId")
+    int insert(LiveRedConf conf);
+
+    @Update({
+            "UPDATE live_red_conf SET red_stauts = #{redStatus}, duration = #{duration},"+
+            "red_type = #{redType}, live_id = #{liveId}, red_num = #{redNum},"+
+            "total_lots = #{totalLots}, total_send = #{totalSend}, `desc` = #{desc},"+
+            "update_time = NOW()"+
+            "WHERE red_id = #{redId}"
+    })
+    void update(LiveRedConf conf);
+
+    @Delete("DELETE FROM live_red_conf WHERE red_id = #{redId}")
+    void deleteById(Long redId);
 }

+ 19 - 0
fs-service/src/main/java/com/fs/live/mapper/LiveUserGiftMapper.java

@@ -0,0 +1,19 @@
+package com.fs.live.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.fs.live.domain.LiveRedConf;
+import com.fs.live.domain.LiveUserGift;
+import org.apache.ibatis.annotations.*;
+
+import java.util.List;
+
+/**
+ * 直播礼物记录配置Mapper接口
+ *
+ * @author fs
+ * @date 2025-07-17
+ */
+@Mapper
+public interface LiveUserGiftMapper extends BaseMapper<LiveUserGift>{
+
+}

+ 26 - 7
fs-service/src/main/java/com/fs/live/mapper/LiveUserRedRecordMapper.java

@@ -3,17 +3,22 @@ package com.fs.live.mapper;
 import java.util.List;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.fs.live.domain.LiveUserRedRecord;
+import org.apache.ibatis.annotations.Insert;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Options;
+import org.apache.ibatis.annotations.Select;
 
 /**
  * 直播用户红包记录Mapper接口
- * 
+ *
  * @author fs
  * @date 2025-07-17
  */
+@Mapper
 public interface LiveUserRedRecordMapper extends BaseMapper<LiveUserRedRecord>{
     /**
      * 查询直播用户红包记录
-     * 
+     *
      * @param id 直播用户红包记录主键
      * @return 直播用户红包记录
      */
@@ -21,7 +26,7 @@ public interface LiveUserRedRecordMapper extends BaseMapper<LiveUserRedRecord>{
 
     /**
      * 查询直播用户红包记录列表
-     * 
+     *
      * @param liveUserRedRecord 直播用户红包记录
      * @return 直播用户红包记录集合
      */
@@ -29,7 +34,7 @@ public interface LiveUserRedRecordMapper extends BaseMapper<LiveUserRedRecord>{
 
     /**
      * 新增直播用户红包记录
-     * 
+     *
      * @param liveUserRedRecord 直播用户红包记录
      * @return 结果
      */
@@ -37,7 +42,7 @@ public interface LiveUserRedRecordMapper extends BaseMapper<LiveUserRedRecord>{
 
     /**
      * 修改直播用户红包记录
-     * 
+     *
      * @param liveUserRedRecord 直播用户红包记录
      * @return 结果
      */
@@ -45,7 +50,7 @@ public interface LiveUserRedRecordMapper extends BaseMapper<LiveUserRedRecord>{
 
     /**
      * 删除直播用户红包记录
-     * 
+     *
      * @param id 直播用户红包记录主键
      * @return 结果
      */
@@ -53,9 +58,23 @@ public interface LiveUserRedRecordMapper extends BaseMapper<LiveUserRedRecord>{
 
     /**
      * 批量删除直播用户红包记录
-     * 
+     *
      * @param ids 需要删除的数据主键集合
      * @return 结果
      */
     int deleteLiveUserRedRecordByIds(Long[] ids);
+
+    @Select("SELECT * FROM live_user_red_record WHERE red_id = #{redId}")
+    List<LiveUserRedRecord> selectByRedId(Long redId);
+
+    @Select("SELECT * FROM live_user_red_record WHERE user_id = #{userId}")
+    List<LiveUserRedRecord> selectByUserId(Long userId);
+
+    @Insert({
+            "INSERT INTO live_user_red_record (red_id, live_id, user_id, integral,"+
+            "create_time, update_time, create_by, update_by)"+
+            "VALUES (#{redId}, #{liveId}, #{userId}, #{integral}, NOW(), null, null, null)"
+    })
+    @Options(useGeneratedKeys = true, keyProperty = "id")
+    int insert(LiveUserRedRecord record);
 }

+ 29 - 0
fs-service/src/main/java/com/fs/live/param/RedPO.java

@@ -0,0 +1,29 @@
+package com.fs.live.param;
+
+import lombok.Data;
+
+@Data
+public class RedPO {
+
+    /**
+     * 直播间id
+     * */
+    private Long liveId;
+
+    /**
+     * 红包id
+     * */
+    private Long redId;
+
+    /**
+     * 红包金额
+     * */
+    private Long integral;
+
+    /**
+     * 用户Id
+     * */
+    private Long userId;
+
+
+}

+ 19 - 7
fs-service/src/main/java/com/fs/live/service/ILiveLotteryConfService.java

@@ -6,14 +6,14 @@ import com.fs.live.domain.LiveLotteryConf;
 
 /**
  * 直播抽奖配置Service接口
- * 
+ *
  * @author fs
  * @date 2025-07-17
  */
 public interface ILiveLotteryConfService extends IService<LiveLotteryConf>{
     /**
      * 查询直播抽奖配置
-     * 
+     *
      * @param lotteryId 直播抽奖配置主键
      * @return 直播抽奖配置
      */
@@ -21,7 +21,7 @@ public interface ILiveLotteryConfService extends IService<LiveLotteryConf>{
 
     /**
      * 查询直播抽奖配置列表
-     * 
+     *
      * @param liveLotteryConf 直播抽奖配置
      * @return 直播抽奖配置集合
      */
@@ -29,7 +29,7 @@ public interface ILiveLotteryConfService extends IService<LiveLotteryConf>{
 
     /**
      * 新增直播抽奖配置
-     * 
+     *
      * @param liveLotteryConf 直播抽奖配置
      * @return 结果
      */
@@ -37,7 +37,7 @@ public interface ILiveLotteryConfService extends IService<LiveLotteryConf>{
 
     /**
      * 修改直播抽奖配置
-     * 
+     *
      * @param liveLotteryConf 直播抽奖配置
      * @return 结果
      */
@@ -45,7 +45,7 @@ public interface ILiveLotteryConfService extends IService<LiveLotteryConf>{
 
     /**
      * 批量删除直播抽奖配置
-     * 
+     *
      * @param lotteryIds 需要删除的直播抽奖配置主键集合
      * @return 结果
      */
@@ -53,9 +53,21 @@ public interface ILiveLotteryConfService extends IService<LiveLotteryConf>{
 
     /**
      * 删除直播抽奖配置信息
-     * 
+     *
      * @param lotteryId 直播抽奖配置主键
      * @return 结果
      */
     int deleteLiveLotteryConfByLotteryId(Long lotteryId);
+
+    LiveLotteryConf getById(Long lotteryId);
+
+    List<LiveLotteryConf> getByLiveId(Long liveId);
+
+    void create(LiveLotteryConf conf);
+
+    void update(LiveLotteryConf conf);
+
+    void delete(Long lotteryId);
+
+    String startLottery(Long lotteryId, Long userId);
 }

+ 22 - 7
fs-service/src/main/java/com/fs/live/service/ILiveRedConfService.java

@@ -3,17 +3,18 @@ package com.fs.live.service;
 import java.util.List;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.fs.live.domain.LiveRedConf;
+import com.fs.live.param.RedPO;
 
 /**
  * 直播红包记录配置Service接口
- * 
+ *
  * @author fs
  * @date 2025-07-17
  */
 public interface ILiveRedConfService extends IService<LiveRedConf>{
     /**
      * 查询直播红包记录配置
-     * 
+     *
      * @param redId 直播红包记录配置主键
      * @return 直播红包记录配置
      */
@@ -21,7 +22,7 @@ public interface ILiveRedConfService extends IService<LiveRedConf>{
 
     /**
      * 查询直播红包记录配置列表
-     * 
+     *
      * @param liveRedConf 直播红包记录配置
      * @return 直播红包记录配置集合
      */
@@ -29,7 +30,7 @@ public interface ILiveRedConfService extends IService<LiveRedConf>{
 
     /**
      * 新增直播红包记录配置
-     * 
+     *
      * @param liveRedConf 直播红包记录配置
      * @return 结果
      */
@@ -37,7 +38,7 @@ public interface ILiveRedConfService extends IService<LiveRedConf>{
 
     /**
      * 修改直播红包记录配置
-     * 
+     *
      * @param liveRedConf 直播红包记录配置
      * @return 结果
      */
@@ -45,7 +46,7 @@ public interface ILiveRedConfService extends IService<LiveRedConf>{
 
     /**
      * 批量删除直播红包记录配置
-     * 
+     *
      * @param redIds 需要删除的直播红包记录配置主键集合
      * @return 结果
      */
@@ -53,9 +54,23 @@ public interface ILiveRedConfService extends IService<LiveRedConf>{
 
     /**
      * 删除直播红包记录配置信息
-     * 
+     *
      * @param redId 直播红包记录配置主键
      * @return 结果
      */
     int deleteLiveRedConfByRedId(Long redId);
+
+    LiveRedConf getById(Long redId);
+
+    List<LiveRedConf> getByLiveId(Long liveId);
+
+    void create(LiveRedConf conf);
+
+    void update(LiveRedConf conf);
+
+    void delete(Long redId);
+
+    boolean claimRedPacket(RedPO red);
+
+    String start(String redId, Long userId);
 }

+ 1 - 0
fs-service/src/main/java/com/fs/live/service/ILiveUserFollowService.java

@@ -63,4 +63,5 @@ public interface ILiveUserFollowService extends IService<LiveUserFollow>{
 
     void deleteLiveUserFollowByLiveIdAndUserId(Long liveId, Long userId);
 
+    boolean isFollow(Long liveId, Long userId);
 }

+ 14 - 0
fs-service/src/main/java/com/fs/live/service/ILiveUserGiftService.java

@@ -0,0 +1,14 @@
+package com.fs.live.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.fs.live.domain.LiveUserGift;
+
+/**
+ * 直播红包记录配置Service接口
+ *
+ * @author fs
+ * @date 2025-07-17
+ */
+public interface ILiveUserGiftService extends IService<LiveUserGift>{
+
+}

+ 12 - 7
fs-service/src/main/java/com/fs/live/service/ILiveUserLotteryRecordService.java

@@ -6,14 +6,14 @@ import com.fs.live.domain.LiveUserLotteryRecord;
 
 /**
  * 直播用户中奖记录Service接口
- * 
+ *
  * @author fs
  * @date 2025-07-17
  */
 public interface ILiveUserLotteryRecordService extends IService<LiveUserLotteryRecord>{
     /**
      * 查询直播用户中奖记录
-     * 
+     *
      * @param id 直播用户中奖记录主键
      * @return 直播用户中奖记录
      */
@@ -21,7 +21,7 @@ public interface ILiveUserLotteryRecordService extends IService<LiveUserLotteryR
 
     /**
      * 查询直播用户中奖记录列表
-     * 
+     *
      * @param liveUserLotteryRecord 直播用户中奖记录
      * @return 直播用户中奖记录集合
      */
@@ -29,7 +29,7 @@ public interface ILiveUserLotteryRecordService extends IService<LiveUserLotteryR
 
     /**
      * 新增直播用户中奖记录
-     * 
+     *
      * @param liveUserLotteryRecord 直播用户中奖记录
      * @return 结果
      */
@@ -37,7 +37,7 @@ public interface ILiveUserLotteryRecordService extends IService<LiveUserLotteryR
 
     /**
      * 修改直播用户中奖记录
-     * 
+     *
      * @param liveUserLotteryRecord 直播用户中奖记录
      * @return 结果
      */
@@ -45,7 +45,7 @@ public interface ILiveUserLotteryRecordService extends IService<LiveUserLotteryR
 
     /**
      * 批量删除直播用户中奖记录
-     * 
+     *
      * @param ids 需要删除的直播用户中奖记录主键集合
      * @return 结果
      */
@@ -53,9 +53,14 @@ public interface ILiveUserLotteryRecordService extends IService<LiveUserLotteryR
 
     /**
      * 删除直播用户中奖记录信息
-     * 
+     *
      * @param id 直播用户中奖记录主键
      * @return 结果
      */
     int deleteLiveUserLotteryRecordById(Long id);
+
+    /**
+     * 用户点击报名抽奖
+     */
+    String userLottery(Long liveId, Long lotteryId, String userId);
 }

+ 2 - 2
fs-service/src/main/java/com/fs/live/service/impl/LiveDataServiceImpl.java

@@ -438,7 +438,7 @@ public class LiveDataServiceImpl extends ServiceImpl<LiveDataMapper, LiveData> i
         if (productId != null) {
             //查询用户是否收藏过该产品
             List<LiveUserFavorite> liveUserFavorites = liveUserFavoriteService.selectByIds(productId, storeId, liveId, userId);
-            if (liveUserFavorites != null) {
+            if (liveUserFavorites != null && !liveUserFavorites.isEmpty()) {
                 liveUserFavoriteService.deleteLiveUserFavoriteByIds(productId,storeId,liveId,userId);
                 return "取消收藏成功";
             }
@@ -453,7 +453,7 @@ public class LiveDataServiceImpl extends ServiceImpl<LiveDataMapper, LiveData> i
         }
         //查询用户是否收藏过该店铺
         List<LiveUserFavorite> liveUserFavorites = liveUserFavoriteService.selectByIds(null, storeId, liveId, userId);
-        if (liveUserFavorites != null) {
+        if (liveUserFavorites != null && !liveUserFavorites.isEmpty()) {
             liveUserFavoriteService.deleteLiveUserFavoriteByIds(null,storeId,liveId,userId);
             return "取消收藏成功";
         }

+ 23 - 7
fs-service/src/main/java/com/fs/live/service/impl/LiveGiftServiceImpl.java

@@ -2,24 +2,40 @@ package com.fs.live.service.impl;
 
 import java.util.List;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.fs.common.core.redis.RedisCache;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.fs.live.mapper.LiveGiftMapper;
 import com.fs.live.domain.LiveGift;
 import com.fs.live.service.ILiveGiftService;
 
+import javax.annotation.PostConstruct;
+
 /**
  * 直播间礼物配置Service业务层处理
- * 
+ *
  * @author fs
  * @date 2025-07-08
  */
 @Service
 public class LiveGiftServiceImpl extends ServiceImpl<LiveGiftMapper, LiveGift> implements ILiveGiftService {
 
+    @Autowired
+    private RedisCache redisCache;
+
+    @PostConstruct
+    public void init() {
+        loadGifts();
+    }
+
+    private void loadGifts() {
+        List<LiveGift> liveGifts = baseMapper.selectList(null);
+        redisCache.setCacheList("liveGift", liveGifts);
+    }
+
     /**
      * 查询直播间礼物配置
-     * 
+     *
      * @param giftId 直播间礼物配置主键
      * @return 直播间礼物配置
      */
@@ -31,7 +47,7 @@ public class LiveGiftServiceImpl extends ServiceImpl<LiveGiftMapper, LiveGift> i
 
     /**
      * 查询直播间礼物配置列表
-     * 
+     *
      * @param liveGift 直播间礼物配置
      * @return 直播间礼物配置
      */
@@ -43,7 +59,7 @@ public class LiveGiftServiceImpl extends ServiceImpl<LiveGiftMapper, LiveGift> i
 
     /**
      * 新增直播间礼物配置
-     * 
+     *
      * @param liveGift 直播间礼物配置
      * @return 结果
      */
@@ -55,7 +71,7 @@ public class LiveGiftServiceImpl extends ServiceImpl<LiveGiftMapper, LiveGift> i
 
     /**
      * 修改直播间礼物配置
-     * 
+     *
      * @param liveGift 直播间礼物配置
      * @return 结果
      */
@@ -67,7 +83,7 @@ public class LiveGiftServiceImpl extends ServiceImpl<LiveGiftMapper, LiveGift> i
 
     /**
      * 批量删除直播间礼物配置
-     * 
+     *
      * @param giftIds 需要删除的直播间礼物配置主键
      * @return 结果
      */
@@ -79,7 +95,7 @@ public class LiveGiftServiceImpl extends ServiceImpl<LiveGiftMapper, LiveGift> i
 
     /**
      * 删除直播间礼物配置信息
-     * 
+     *
      * @param giftId 直播间礼物配置主键
      * @return 结果
      */

+ 60 - 7
fs-service/src/main/java/com/fs/live/service/impl/LiveLotteryConfServiceImpl.java

@@ -1,5 +1,6 @@
 package com.fs.live.service.impl;
 
+import java.util.Date;
 import java.util.List;
 import com.fs.common.utils.DateUtils;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -8,19 +9,23 @@ import org.springframework.stereotype.Service;
 import com.fs.live.mapper.LiveLotteryConfMapper;
 import com.fs.live.domain.LiveLotteryConf;
 import com.fs.live.service.ILiveLotteryConfService;
+import org.springframework.transaction.annotation.Transactional;
 
 /**
  * 直播抽奖配置Service业务层处理
- * 
+ *
  * @author fs
  * @date 2025-07-17
  */
 @Service
 public class LiveLotteryConfServiceImpl extends ServiceImpl<LiveLotteryConfMapper, LiveLotteryConf> implements ILiveLotteryConfService {
 
+    @Autowired
+    private LiveLotteryConfMapper mapper;
+
     /**
      * 查询直播抽奖配置
-     * 
+     *
      * @param lotteryId 直播抽奖配置主键
      * @return 直播抽奖配置
      */
@@ -32,7 +37,7 @@ public class LiveLotteryConfServiceImpl extends ServiceImpl<LiveLotteryConfMappe
 
     /**
      * 查询直播抽奖配置列表
-     * 
+     *
      * @param liveLotteryConf 直播抽奖配置
      * @return 直播抽奖配置
      */
@@ -44,7 +49,7 @@ public class LiveLotteryConfServiceImpl extends ServiceImpl<LiveLotteryConfMappe
 
     /**
      * 新增直播抽奖配置
-     * 
+     *
      * @param liveLotteryConf 直播抽奖配置
      * @return 结果
      */
@@ -57,7 +62,7 @@ public class LiveLotteryConfServiceImpl extends ServiceImpl<LiveLotteryConfMappe
 
     /**
      * 修改直播抽奖配置
-     * 
+     *
      * @param liveLotteryConf 直播抽奖配置
      * @return 结果
      */
@@ -69,7 +74,7 @@ public class LiveLotteryConfServiceImpl extends ServiceImpl<LiveLotteryConfMappe
 
     /**
      * 批量删除直播抽奖配置
-     * 
+     *
      * @param lotteryIds 需要删除的直播抽奖配置主键
      * @return 结果
      */
@@ -81,13 +86,61 @@ public class LiveLotteryConfServiceImpl extends ServiceImpl<LiveLotteryConfMappe
 
     /**
      * 删除直播抽奖配置信息
-     * 
+     *
      * @param lotteryId 直播抽奖配置主键
      * @return 结果
      */
     @Override
+    @Transactional
     public int deleteLiveLotteryConfByLotteryId(Long lotteryId)
     {
         return baseMapper.deleteLiveLotteryConfByLotteryId(lotteryId);
     }
+
+    @Override
+    @Transactional
+    public LiveLotteryConf getById(Long lotteryId) {
+        return mapper.selectById(lotteryId);
+    }
+
+    @Override
+    @Transactional
+    public List<LiveLotteryConf> getByLiveId(Long liveId) {
+        return mapper.selectByLiveId(liveId);
+    }
+
+    @Override
+    @Transactional
+    public void create(LiveLotteryConf conf) {
+        mapper.insert(conf);
+    }
+
+    @Override
+    @Transactional
+    public void update(LiveLotteryConf conf) {
+        mapper.updateAll(conf);
+    }
+
+    @Override
+    @Transactional
+    public void delete(Long lotteryId) {
+        mapper.deleteById(lotteryId);
+    }
+
+    @Override
+    public String startLottery(Long lotteryId, Long userId) {
+        LiveLotteryConf conf = mapper.selectById(lotteryId);
+        if (conf == null)
+            return "抽奖不存在";
+        if (!"0".equals(conf.getLotteryStatus()))
+            return "抽奖已开始";
+        //抽奖状态
+        conf.setLotteryStatus("1");
+        //修改时间
+        conf.setUpdateTime(new Date());
+        //修改人
+        conf.setUpdateBy(userId.toString());
+        mapper.updateAll(conf);
+        return "开始抽奖成功";
+    }
 }

+ 195 - 7
fs-service/src/main/java/com/fs/live/service/impl/LiveRedConfServiceImpl.java

@@ -1,26 +1,46 @@
 package com.fs.live.service.impl;
 
+import java.util.Collections;
+import java.util.Date;
 import java.util.List;
+import java.util.UUID;
+import java.util.concurrent.ThreadLocalRandom;
+import java.util.concurrent.TimeUnit;
+
+import com.fs.common.core.redis.RedisCache;
 import com.fs.common.utils.DateUtils;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.fs.live.domain.LiveUserRedRecord;
+import com.fs.live.mapper.LiveUserRedRecordMapper;
+import com.fs.live.param.RedPO;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.script.DefaultRedisScript;
 import org.springframework.stereotype.Service;
 import com.fs.live.mapper.LiveRedConfMapper;
 import com.fs.live.domain.LiveRedConf;
 import com.fs.live.service.ILiveRedConfService;
+import org.springframework.transaction.annotation.Transactional;
 
 /**
  * 直播红包记录配置Service业务层处理
- * 
+ *
  * @author fs
  * @date 2025-07-17
  */
 @Service
 public class LiveRedConfServiceImpl extends ServiceImpl<LiveRedConfMapper, LiveRedConf> implements ILiveRedConfService {
 
+    @Autowired
+    private LiveUserRedRecordMapper userRedRecordMapper;
+
+    @Autowired
+    private RedisCache redisCache;
+
+    private static final String REDPACKET_REMAININGLOTS_KEY = "live:red:remainingLots:";
+    private static final String REDPACKET_REMAININGNUM_KEY = "live:red:remainingNum:";
     /**
      * 查询直播红包记录配置
-     * 
+     *
      * @param redId 直播红包记录配置主键
      * @return 直播红包记录配置
      */
@@ -32,7 +52,7 @@ public class LiveRedConfServiceImpl extends ServiceImpl<LiveRedConfMapper, LiveR
 
     /**
      * 查询直播红包记录配置列表
-     * 
+     *
      * @param liveRedConf 直播红包记录配置
      * @return 直播红包记录配置
      */
@@ -44,7 +64,7 @@ public class LiveRedConfServiceImpl extends ServiceImpl<LiveRedConfMapper, LiveR
 
     /**
      * 新增直播红包记录配置
-     * 
+     *
      * @param liveRedConf 直播红包记录配置
      * @return 结果
      */
@@ -57,7 +77,7 @@ public class LiveRedConfServiceImpl extends ServiceImpl<LiveRedConfMapper, LiveR
 
     /**
      * 修改直播红包记录配置
-     * 
+     *
      * @param liveRedConf 直播红包记录配置
      * @return 结果
      */
@@ -69,7 +89,7 @@ public class LiveRedConfServiceImpl extends ServiceImpl<LiveRedConfMapper, LiveR
 
     /**
      * 批量删除直播红包记录配置
-     * 
+     *
      * @param redIds 需要删除的直播红包记录配置主键
      * @return 结果
      */
@@ -81,7 +101,7 @@ public class LiveRedConfServiceImpl extends ServiceImpl<LiveRedConfMapper, LiveR
 
     /**
      * 删除直播红包记录配置信息
-     * 
+     *
      * @param redId 直播红包记录配置主键
      * @return 结果
      */
@@ -90,4 +110,172 @@ public class LiveRedConfServiceImpl extends ServiceImpl<LiveRedConfMapper, LiveR
     {
         return baseMapper.deleteLiveRedConfByRedId(redId);
     }
+
+    @Override
+    @Transactional
+    public LiveRedConf getById(Long redId) {
+        return baseMapper.selectById(redId);
+    }
+
+    @Override
+    @Transactional
+    public List<LiveRedConf> getByLiveId(Long liveId) {
+        return baseMapper.selectByLiveId(liveId);
+    }
+
+    @Override
+    @Transactional
+    public void create(LiveRedConf conf) {
+        baseMapper.insert(conf);
+    }
+
+    @Override
+    @Transactional
+    public void update(LiveRedConf conf) {
+        baseMapper.update(conf);
+    }
+
+    @Override
+    @Transactional
+    public void delete(Long redId) {
+        baseMapper.deleteById(redId);
+    }
+
+    /**
+     * 用户领取红包
+     */
+    @Override
+    @Transactional
+    public boolean claimRedPacket(RedPO red) {
+        String lockKey = REDPACKET_REMAININGLOTS_KEY + red.getRedId();
+        List<String> keyList = Collections.emptyList();
+        keyList.add(lockKey);
+
+        try {
+            //获取红包锁
+            if (!tryLock(lockKey, red.getUserId().toString(), 5)) {
+                return false;
+            }
+
+            LiveRedConf conf = baseMapper.selectById(red.getRedId());
+            if (conf == null || conf.getRedStatus() != 1) {
+                return false;
+            }
+            //redis剩余红包数
+            Integer remaining = getRemaining(red.getRedId());
+            if (remaining <= 0) {
+                return false;
+            }
+            //剩余金额
+            //Integer remainingNum = getRemainingNum(red.getRedId());
+            conf.setRemaining(remaining);
+            Long integral = calculateIntegralAverage(conf);
+            conf.setTotalSend(conf.getTotalSend() + 1);
+
+
+
+            // 更新数据库和缓存
+            baseMapper.update(conf);
+            decreaseRemainingLotsIfPossible(red.getRedId());
+            //decreaseRemainingNumIfPossible(red.getRedId(),integral);
+
+            // 记录用户红包
+            LiveUserRedRecord record = new LiveUserRedRecord();
+            record.setRedId(red.getRedId());
+            record.setLiveId(red.getLiveId());
+            record.setUserId(red.getUserId());
+            record.setIntegral(integral);
+            userRedRecordMapper.insert(record);
+
+            // WebSocket 通知
+            //String msg = String.format("用户 %d 抢到了红包 %d,获得 %d 芳华币", userId, redId, integral);
+            //WebSocketServer.notifyUsers(msg);
+
+            return true;
+        } finally {
+            releaseLock(keyList, red.getUserId().toString());
+        }
+    }
+
+    @Override
+    public String start(String redId, Long userId) {
+        LiveRedConf conf = baseMapper.selectById(redId);
+        if (conf != null && conf.getRedStatus() == 0) {
+            conf.setRedStatus(1L);
+            conf.setUpdateTime(new Date());
+            conf.setUpdateBy(userId.toString());
+            baseMapper.update(conf);
+            return "红包发放成功";
+        }
+        return "红包发放失败";
+    }
+
+    // 初始化剩余数量
+    public void initRemainingLots(Long redId, Integer totalLots) {
+        String key = REDPACKET_REMAININGLOTS_KEY + redId;
+        redisCache.setCacheObject(key, totalLots.toString());
+    }
+    // 初始化剩余金额
+    public void initRemainingNum(Long redId, Long redNum) {
+        String key = REDPACKET_REMAININGNUM_KEY + redId;
+        redisCache.setCacheObject(key, redNum.toString());
+    }
+
+    // 获取剩余数量
+    public Integer getRemaining(Long redId) {
+        String key = REDPACKET_REMAININGLOTS_KEY + redId;
+        String value = redisCache.getCacheObject(key);
+        return value == null ? 0 : Integer.parseInt(value);
+    }
+    // 获取剩余数量
+    public Integer getRemainingNum(Long redId) {
+        String key = REDPACKET_REMAININGNUM_KEY + redId;
+        String value = redisCache.getCacheObject(key);
+        return value == null ? 0 : Integer.parseInt(value);
+    }
+
+    // 减少剩余数量(原子操作)
+    public void decreaseRemainingLotsIfPossible(Long redId) {
+        String key = REDPACKET_REMAININGLOTS_KEY + redId;
+        redisCache.incrementCacheValue(key, -1);
+    }
+    // 减少剩余数量(原子操作)
+    public void decreaseRemainingNumIfPossible(Long redId, Long integral) {
+        String key = REDPACKET_REMAININGNUM_KEY + redId;
+        redisCache.incrementCacheValue(key, -integral);
+    }
+
+    public boolean tryLock(String lockKey, String clientId, long expireTime) {
+        Boolean success = redisCache.setIfAbsent(lockKey, clientId, expireTime, TimeUnit.SECONDS);
+        return Boolean.TRUE.equals(success);
+    }
+
+    public void releaseLock(List<String> lockKey, String clientId) {
+        String script = "if redis.call('get', KEYS[1]) == ARGV[1] then return redis.call('del', KEYS[1]) else return 0 end";
+        redisCache.redisTemplate.execute(new DefaultRedisScript<>(script, Long.class), lockKey, clientId);
+    }
+
+    private Long calculateIntegralRandom(LiveRedConf conf) {
+        if (conf.getTotalSend() >= conf.getTotalLots()) {
+            return 0L; // 已发完
+        }
+        //剩余红包个数
+        long remainingLots = conf.getTotalLots() - conf.getTotalSend();
+        //剩余红包金额
+        int remainingNum = getRemainingNum(conf.getRedId());
+        if (remainingLots == 1){
+            return (long) remainingNum;
+        }
+        long avgIntegral = remainingNum / remainingLots;
+        long minIntegral = avgIntegral / 3 == 0 ? 1 : avgIntegral / 3;
+        long maxIntegral = avgIntegral * 3 >= remainingNum ? remainingNum : avgIntegral * 3;
+        return ThreadLocalRandom.current().nextLong(minIntegral, maxIntegral + 1);
+    }
+
+    private Long calculateIntegralAverage(LiveRedConf conf) {
+        if (conf.getTotalSend() >= conf.getTotalLots()) {
+            return 0L; // 已发完
+        }
+        return conf.getRedNum() / conf.getTotalLots();
+    }
 }

+ 6 - 1
fs-service/src/main/java/com/fs/live/service/impl/LiveUserFollowServiceImpl.java

@@ -3,7 +3,6 @@ package com.fs.live.service.impl;
 import java.util.List;
 import com.fs.common.utils.DateUtils;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.fs.live.mapper.LiveUserFollowMapper;
 import com.fs.live.domain.LiveUserFollow;
@@ -101,4 +100,10 @@ public class LiveUserFollowServiceImpl extends ServiceImpl<LiveUserFollowMapper,
     public void deleteLiveUserFollowByLiveIdAndUserId(Long liveId, Long userId) {
         baseMapper.deleteLiveUserFollowByLiveIdAndUserId(liveId, userId);
     }
+
+    @Override
+    public boolean isFollow(Long liveId, Long userId) {
+        LiveUserFollow liveUserFollow = baseMapper.selectLiveUserFollowByLiveIdAndUserId(liveId, userId);
+        return liveUserFollow != null;
+    }
 }

+ 19 - 0
fs-service/src/main/java/com/fs/live/service/impl/LiveUserGiftServiceImpl.java

@@ -0,0 +1,19 @@
+package com.fs.live.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.fs.live.domain.LiveUserGift;
+import com.fs.live.mapper.LiveUserGiftMapper;
+import com.fs.live.service.ILiveUserGiftService;
+import org.springframework.stereotype.Service;
+
+/**
+ * 直播红包记录配置Service业务层处理
+ *
+ * @author fs
+ * @date 2025-07-17
+ */
+@Service
+public class LiveUserGiftServiceImpl extends ServiceImpl<LiveUserGiftMapper, LiveUserGift> implements ILiveUserGiftService {
+
+
+}

+ 64 - 8
fs-service/src/main/java/com/fs/live/service/impl/LiveUserLotteryRecordServiceImpl.java

@@ -1,26 +1,40 @@
 package com.fs.live.service.impl;
 
+import java.util.Date;
 import java.util.List;
 import com.fs.common.utils.DateUtils;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.fs.erp.dto.sdk.wangdian.utils.StringUtils;
+import com.fs.live.domain.LiveLotteryConf;
+import com.fs.live.service.*;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.fs.live.mapper.LiveUserLotteryRecordMapper;
 import com.fs.live.domain.LiveUserLotteryRecord;
-import com.fs.live.service.ILiveUserLotteryRecordService;
 
 /**
  * 直播用户中奖记录Service业务层处理
- * 
+ *
  * @author fs
  * @date 2025-07-17
  */
 @Service
 public class LiveUserLotteryRecordServiceImpl extends ServiceImpl<LiveUserLotteryRecordMapper, LiveUserLotteryRecord> implements ILiveUserLotteryRecordService {
 
+    @Autowired
+    private ILiveLotteryConfService liveLotteryConfService;
+
+    @Autowired
+    private ILiveUserFollowService liveUserFollowService;
+
+    @Autowired
+    private ILiveOrderService liveOrderService;
+
+    @Autowired
+    private ILiveGiftService liveGiftService;
     /**
      * 查询直播用户中奖记录
-     * 
+     *
      * @param id 直播用户中奖记录主键
      * @return 直播用户中奖记录
      */
@@ -32,7 +46,7 @@ public class LiveUserLotteryRecordServiceImpl extends ServiceImpl<LiveUserLotter
 
     /**
      * 查询直播用户中奖记录列表
-     * 
+     *
      * @param liveUserLotteryRecord 直播用户中奖记录
      * @return 直播用户中奖记录
      */
@@ -44,7 +58,7 @@ public class LiveUserLotteryRecordServiceImpl extends ServiceImpl<LiveUserLotter
 
     /**
      * 新增直播用户中奖记录
-     * 
+     *
      * @param liveUserLotteryRecord 直播用户中奖记录
      * @return 结果
      */
@@ -57,7 +71,7 @@ public class LiveUserLotteryRecordServiceImpl extends ServiceImpl<LiveUserLotter
 
     /**
      * 修改直播用户中奖记录
-     * 
+     *
      * @param liveUserLotteryRecord 直播用户中奖记录
      * @return 结果
      */
@@ -69,7 +83,7 @@ public class LiveUserLotteryRecordServiceImpl extends ServiceImpl<LiveUserLotter
 
     /**
      * 批量删除直播用户中奖记录
-     * 
+     *
      * @param ids 需要删除的直播用户中奖记录主键
      * @return 结果
      */
@@ -81,7 +95,7 @@ public class LiveUserLotteryRecordServiceImpl extends ServiceImpl<LiveUserLotter
 
     /**
      * 删除直播用户中奖记录信息
-     * 
+     *
      * @param id 直播用户中奖记录主键
      * @return 结果
      */
@@ -90,4 +104,46 @@ public class LiveUserLotteryRecordServiceImpl extends ServiceImpl<LiveUserLotter
     {
         return baseMapper.deleteLiveUserLotteryRecordById(id);
     }
+
+    @Override
+    public String userLottery(Long liveId, Long lotteryId, String userId) {
+        if (StringUtils.isEmpty(userId))
+            return "请先登录";
+        //获取抽奖配置
+        LiveLotteryConf liveLotteryConf = liveLotteryConfService.getById(lotteryId);
+        //update_time含义修改为抽奖开始时间 查看抽奖时间是否过期
+        Date expireTime = DateUtils.addMinutes(liveLotteryConf.getUpdateTime(), liveLotteryConf.getDuration().intValue());
+        if (expireTime.before(new Date())){
+            return "本轮抽奖已经结束啦";
+        }
+        //参与条件检测
+        switch (liveLotteryConf.getRequire().intValue()){
+            case 0:
+                //"参与抽奖方式 0:在线观众参与";
+                break;
+            case 1:
+                //"参与抽奖方式 1:关注参与";
+                if (liveUserFollowService.isFollow(liveId, Long.parseLong(userId)))
+                    break;
+                return "请先关注";
+            case 2:
+
+                //"参与抽奖方式 2:送礼参与";
+                //return "暂不支持";
+                //if (liveGiftService.isGift(liveId, Long.parseLong(userId)))
+            case 3:
+                //"参与抽奖方式 3:下单参与";
+                break;
+        }
+        //插入记录表
+        LiveUserLotteryRecord liveUserLotteryRecord = new LiveUserLotteryRecord();
+        liveUserLotteryRecord.setLotteryId(lotteryId);
+        liveUserLotteryRecord.setLiveId(liveId);
+        liveUserLotteryRecord.setUserId(Long.parseLong(userId));
+        liveUserLotteryRecord.setCreateTime(new Date());
+        baseMapper.insert(liveUserLotteryRecord);
+        return "参与成功";
+    }
+
+
 }

+ 11 - 11
fs-service/src/main/resources/mapper/live/LiveEventConfMapper.xml

@@ -3,7 +3,7 @@
 PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.fs.live.mapper.LiveEventConfMapper">
-    
+
     <resultMap type="LiveEventConf" id="LiveEventConfResult">
         <result property="eventId"    column="event_id"    />
         <result property="liveId"    column="live_id"    />
@@ -11,29 +11,29 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="triggerCount"    column="trigger_count"    />
         <result property="redId"    column="red_id"    />
         <result property="createTime"    column="create_time"    />
-        <result property="udpateTime"    column="udpate_time"    />
+        <result property="udpateTime"    column="update_time"    />
         <result property="createBy"    column="create_by"    />
         <result property="updateBy"    column="update_by"    />
     </resultMap>
 
     <sql id="selectLiveEventConfVo">
-        select event_id, live_id, event_type, trigger_count, red_id, create_time, udpate_time, create_by, update_by from live_event_conf
+        select event_id, live_id, event_type, trigger_count, red_id, create_time, update_time, create_by, update_by from live_event_conf
     </sql>
 
     <select id="selectLiveEventConfList" parameterType="LiveEventConf" resultMap="LiveEventConfResult">
         <include refid="selectLiveEventConfVo"/>
-        <where>  
+        <where>
             <if test="liveId != null "> and live_id = #{liveId}</if>
             <if test="eventType != null "> and event_type = #{eventType}</if>
-            <if test="createTime != null "> and create_time = #{createTime}</if>
+            <if test="triggerCount != null "> and trigger_count = #{triggerCount}</if>
         </where>
     </select>
-    
+
     <select id="selectLiveEventConfByEventId" parameterType="Long" resultMap="LiveEventConfResult">
         <include refid="selectLiveEventConfVo"/>
         where event_id = #{eventId}
     </select>
-        
+
     <insert id="insertLiveEventConf" parameterType="LiveEventConf" useGeneratedKeys="true" keyProperty="eventId">
         insert into live_event_conf
         <trim prefix="(" suffix=")" suffixOverrides=",">
@@ -42,7 +42,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="triggerCount != null">trigger_count,</if>
             <if test="redId != null">red_id,</if>
             <if test="createTime != null">create_time,</if>
-            <if test="udpateTime != null">udpate_time,</if>
+            <if test="udpateTime != null">update_time,</if>
             <if test="createBy != null">create_by,</if>
             <if test="updateBy != null">update_by,</if>
          </trim>
@@ -66,7 +66,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="triggerCount != null">trigger_count = #{triggerCount},</if>
             <if test="redId != null">red_id = #{redId},</if>
             <if test="createTime != null">create_time = #{createTime},</if>
-            <if test="udpateTime != null">udpate_time = #{udpateTime},</if>
+            <if test="udpateTime != null">update_time = #{udpateTime},</if>
             <if test="createBy != null">create_by = #{createBy},</if>
             <if test="updateBy != null">update_by = #{updateBy},</if>
         </trim>
@@ -78,9 +78,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </delete>
 
     <delete id="deleteLiveEventConfByEventIds" parameterType="String">
-        delete from live_event_conf where event_id in 
+        delete from live_event_conf where event_id in
         <foreach item="eventId" collection="array" open="(" separator="," close=")">
             #{eventId}
         </foreach>
     </delete>
-</mapper>
+</mapper>

+ 16 - 15
fs-service/src/main/resources/mapper/live/LiveLotteryConfMapper.xml

@@ -3,7 +3,7 @@
 PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.fs.live.mapper.LiveLotteryConfMapper">
-    
+
     <resultMap type="LiveLotteryConf" id="LiveLotteryConfResult">
         <result property="lotteryId"    column="lottery_id"    />
         <result property="liveId"    column="live_id"    />
@@ -17,31 +17,32 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="duration"    column="duration"    />
         <result property="desc"    column="desc"    />
         <result property="createTime"    column="create_time"    />
-        <result property="udpateTime"    column="udpate_time"    />
+        <result property="udpateTime"    column="update_time"    />
         <result property="createBy"    column="create_by"    />
         <result property="updateBy"    column="update_by"    />
     </resultMap>
 
     <sql id="selectLiveLotteryConfVo">
-        select lottery_id, live_id, product_id, prize_level, per_lottery_num, total_lots, total_send, require, require_conf, duration, desc, create_time, udpate_time, create_by, update_by from live_lottery_conf
+        select lottery_id, live_id, product_id, prize_level, per_lottery_num, total_lots, total_send, `require`, require_conf, duration, `desc`, create_time, update_time, create_by, update_by from live_lottery_conf
     </sql>
 
     <select id="selectLiveLotteryConfList" parameterType="LiveLotteryConf" resultMap="LiveLotteryConfResult">
         <include refid="selectLiveLotteryConfVo"/>
-        <where>  
+        <where>
             <if test="liveId != null "> and live_id = #{liveId}</if>
             <if test="productId != null "> and product_id = #{productId}</if>
             <if test="prizeLevel != null "> and prize_level = #{prizeLevel}</if>
-            <if test="require != null "> and require = #{require}</if>
+            <if test="require != null "> and `require` = #{require}</if>
+            <if test="desc != null  and desc != ''"> and `desc` = #{desc}</if>
             <if test="createTime != null "> and create_time = #{createTime}</if>
         </where>
     </select>
-    
+
     <select id="selectLiveLotteryConfByLotteryId" parameterType="Long" resultMap="LiveLotteryConfResult">
         <include refid="selectLiveLotteryConfVo"/>
         where lottery_id = #{lotteryId}
     </select>
-        
+
     <insert id="insertLiveLotteryConf" parameterType="LiveLotteryConf" useGeneratedKeys="true" keyProperty="lotteryId">
         insert into live_lottery_conf
         <trim prefix="(" suffix=")" suffixOverrides=",">
@@ -51,12 +52,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="perLotteryNum != null">per_lottery_num,</if>
             <if test="totalLots != null">total_lots,</if>
             <if test="totalSend != null">total_send,</if>
-            <if test="require != null">require,</if>
+            <if test="require != null">`require`,</if>
             <if test="requireConf != null">require_conf,</if>
             <if test="duration != null">duration,</if>
-            <if test="desc != null and desc != ''">desc,</if>
+            <if test="desc != null and desc != ''">`desc`,</if>
             <if test="createTime != null">create_time,</if>
-            <if test="udpateTime != null">udpate_time,</if>
+            <if test="udpateTime != null">update_time,</if>
             <if test="createBy != null">create_by,</if>
             <if test="updateBy != null">update_by,</if>
          </trim>
@@ -87,12 +88,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="perLotteryNum != null">per_lottery_num = #{perLotteryNum},</if>
             <if test="totalLots != null">total_lots = #{totalLots},</if>
             <if test="totalSend != null">total_send = #{totalSend},</if>
-            <if test="require != null">require = #{require},</if>
+            <if test="require != null">`require` = #{require},</if>
             <if test="requireConf != null">require_conf = #{requireConf},</if>
             <if test="duration != null">duration = #{duration},</if>
-            <if test="desc != null and desc != ''">desc = #{desc},</if>
+            <if test="desc != null and desc != ''">`desc` = #{desc},</if>
             <if test="createTime != null">create_time = #{createTime},</if>
-            <if test="udpateTime != null">udpate_time = #{udpateTime},</if>
+            <if test="udpateTime != null">update_time = #{udpateTime},</if>
             <if test="createBy != null">create_by = #{createBy},</if>
             <if test="updateBy != null">update_by = #{updateBy},</if>
         </trim>
@@ -104,9 +105,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </delete>
 
     <delete id="deleteLiveLotteryConfByLotteryIds" parameterType="String">
-        delete from live_lottery_conf where lottery_id in 
+        delete from live_lottery_conf where lottery_id in
         <foreach item="lotteryId" collection="array" open="(" separator="," close=")">
             #{lotteryId}
         </foreach>
     </delete>
-</mapper>
+</mapper>

+ 13 - 10
fs-service/src/main/resources/mapper/live/LiveLotteryRecordMapper.xml

@@ -3,39 +3,42 @@
 PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.fs.live.mapper.LiveLotteryRecordMapper">
-    
+
     <resultMap type="LiveLotteryRecord" id="LiveLotteryRecordResult">
         <result property="lotteryId"    column="lottery_id"    />
         <result property="liveId"    column="live_id"    />
         <result property="lotteryStauts"    column="lottery_stauts"    />
         <result property="createTime"    column="create_time"    />
-        <result property="udpateTime"    column="udpate_time"    />
+        <result property="udpateTime"    column="update_time"    />
         <result property="createBy"    column="create_by"    />
         <result property="updateBy"    column="update_by"    />
     </resultMap>
 
     <sql id="selectLiveLotteryRecordVo">
-        select lottery_id, live_id, lottery_stauts, create_time, udpate_time, create_by, update_by from live_lottery_record
+        select lottery_id, live_id, lottery_stauts, create_time, update_time, create_by, update_by from live_lottery_record
     </sql>
 
     <select id="selectLiveLotteryRecordList" parameterType="LiveLotteryRecord" resultMap="LiveLotteryRecordResult">
         <include refid="selectLiveLotteryRecordVo"/>
-        <where>  
+        <where>
+            <if test="liveId != null "> and live_id = #{liveId}</if>
+            <if test="lotteryStauts != null "> and lottery_stauts = #{lotteryStauts}</if>
+            <if test="udpateTime != null "> and update_time = #{udpateTime}</if>
         </where>
     </select>
-    
+
     <select id="selectLiveLotteryRecordByLotteryId" parameterType="Long" resultMap="LiveLotteryRecordResult">
         <include refid="selectLiveLotteryRecordVo"/>
         where lottery_id = #{lotteryId}
     </select>
-        
+
     <insert id="insertLiveLotteryRecord" parameterType="LiveLotteryRecord" useGeneratedKeys="true" keyProperty="lotteryId">
         insert into live_lottery_record
         <trim prefix="(" suffix=")" suffixOverrides=",">
             <if test="liveId != null">live_id,</if>
             <if test="lotteryStauts != null">lottery_stauts,</if>
             <if test="createTime != null">create_time,</if>
-            <if test="udpateTime != null">udpate_time,</if>
+            <if test="udpateTime != null">update_time,</if>
             <if test="createBy != null">create_by,</if>
             <if test="updateBy != null">update_by,</if>
          </trim>
@@ -55,7 +58,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="liveId != null">live_id = #{liveId},</if>
             <if test="lotteryStauts != null">lottery_stauts = #{lotteryStauts},</if>
             <if test="createTime != null">create_time = #{createTime},</if>
-            <if test="udpateTime != null">udpate_time = #{udpateTime},</if>
+            <if test="udpateTime != null">update_time = #{udpateTime},</if>
             <if test="createBy != null">create_by = #{createBy},</if>
             <if test="updateBy != null">update_by = #{updateBy},</if>
         </trim>
@@ -67,9 +70,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </delete>
 
     <delete id="deleteLiveLotteryRecordByLotteryIds" parameterType="String">
-        delete from live_lottery_record where lottery_id in 
+        delete from live_lottery_record where lottery_id in
         <foreach item="lotteryId" collection="array" open="(" separator="," close=")">
             #{lotteryId}
         </foreach>
     </delete>
-</mapper>
+</mapper>

+ 10 - 18
fs-service/src/main/resources/mapper/live/LiveLotteryRegistrationMapper.xml

@@ -3,7 +3,7 @@
 PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.fs.live.mapper.LiveLotteryRegistrationMapper">
-    
+
     <resultMap type="LiveLotteryRegistration" id="LiveLotteryRegistrationResult">
         <result property="registrationId"    column="registration_id"    />
         <result property="liveId"    column="live_id"    />
@@ -11,34 +11,26 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="isWin"    column="is_win"    />
         <result property="rizeLevel"    column="rize_level"    />
         <result property="createTime"    column="create_time"    />
-        <result property="udpateTime"    column="udpate_time"    />
+        <result property="udpateTime"    column="update_time"    />
         <result property="createBy"    column="create_by"    />
         <result property="updateBy"    column="update_by"    />
     </resultMap>
 
     <sql id="selectLiveLotteryRegistrationVo">
-        select registration_id, live_id, user_id, is_win, rize_level, create_time, udpate_time, create_by, update_by from live_lottery_registration
+        select registration_id, live_id, user_id, is_win, rize_level, create_time, update_time, create_by, update_by from live_lottery_registration
     </sql>
 
     <select id="selectLiveLotteryRegistrationList" parameterType="LiveLotteryRegistration" resultMap="LiveLotteryRegistrationResult">
         <include refid="selectLiveLotteryRegistrationVo"/>
-        <where>  
-            <if test="liveId != null "> and live_id = #{liveId}</if>
-            <if test="userId != null "> and user_id = #{userId}</if>
-            <if test="isWin != null "> and is_win = #{isWin}</if>
-            <if test="rizeLevel != null "> and rize_level = #{rizeLevel}</if>
-            <if test="createTime != null "> and create_time = #{createTime}</if>
-            <if test="udpateTime != null "> and udpate_time = #{udpateTime}</if>
-            <if test="createBy != null "> and create_by = #{createBy}</if>
-            <if test="updateBy != null "> and update_by = #{updateBy}</if>
+        <where>
         </where>
     </select>
-    
+
     <select id="selectLiveLotteryRegistrationByRegistrationId" parameterType="Long" resultMap="LiveLotteryRegistrationResult">
         <include refid="selectLiveLotteryRegistrationVo"/>
         where registration_id = #{registrationId}
     </select>
-        
+
     <insert id="insertLiveLotteryRegistration" parameterType="LiveLotteryRegistration" useGeneratedKeys="true" keyProperty="registrationId">
         insert into live_lottery_registration
         <trim prefix="(" suffix=")" suffixOverrides=",">
@@ -47,7 +39,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="isWin != null">is_win,</if>
             <if test="rizeLevel != null">rize_level,</if>
             <if test="createTime != null">create_time,</if>
-            <if test="udpateTime != null">udpate_time,</if>
+            <if test="udpateTime != null">update_time,</if>
             <if test="createBy != null">create_by,</if>
             <if test="updateBy != null">update_by,</if>
          </trim>
@@ -71,7 +63,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="isWin != null">is_win = #{isWin},</if>
             <if test="rizeLevel != null">rize_level = #{rizeLevel},</if>
             <if test="createTime != null">create_time = #{createTime},</if>
-            <if test="udpateTime != null">udpate_time = #{udpateTime},</if>
+            <if test="udpateTime != null">update_time = #{udpateTime},</if>
             <if test="createBy != null">create_by = #{createBy},</if>
             <if test="updateBy != null">update_by = #{updateBy},</if>
         </trim>
@@ -83,9 +75,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </delete>
 
     <delete id="deleteLiveLotteryRegistrationByRegistrationIds" parameterType="String">
-        delete from live_lottery_registration where registration_id in 
+        delete from live_lottery_registration where registration_id in
         <foreach item="registrationId" collection="array" open="(" separator="," close=")">
             #{registrationId}
         </foreach>
     </delete>
-</mapper>
+</mapper>

+ 20 - 22
fs-service/src/main/resources/mapper/live/LiveRedConfMapper.xml

@@ -3,10 +3,10 @@
 PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.fs.live.mapper.LiveRedConfMapper">
-    
+
     <resultMap type="LiveRedConf" id="LiveRedConfResult">
         <result property="redId"    column="red_id"    />
-        <result property="redStauts"    column="red_stauts"    />
+        <result property="redStatus"    column="red_stauts"    />
         <result property="duration"    column="duration"    />
         <result property="redType"    column="red_type"    />
         <result property="liveId"    column="live_id"    />
@@ -15,52 +15,50 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="totalSend"    column="total_send"    />
         <result property="desc"    column="desc"    />
         <result property="createTime"    column="create_time"    />
-        <result property="udpateTime"    column="udpate_time"    />
+        <result property="udpateTime"    column="update_time"    />
         <result property="createBy"    column="create_by"    />
         <result property="updateBy"    column="update_by"    />
     </resultMap>
 
     <sql id="selectLiveRedConfVo">
-        select red_id, red_stauts, duration, red_type, live_id, red_num, total_lots, total_send, desc, create_time, udpate_time, create_by, update_by from live_red_conf
+        select red_id, red_stauts, duration, red_type, live_id, red_num, total_lots, total_send, `desc`, create_time, update_time, create_by, update_by from live_red_conf
     </sql>
 
     <select id="selectLiveRedConfList" parameterType="LiveRedConf" resultMap="LiveRedConfResult">
         <include refid="selectLiveRedConfVo"/>
-        <where>  
-            <if test="redStauts != null "> and red_stauts = #{redStauts}</if>
-            <if test="duration != null "> and duration = #{duration}</if>
+        <where>
+            <if test="redStatus != null "> and red_stauts = #{redStatus}</if>
             <if test="redType != null "> and red_type = #{redType}</if>
             <if test="liveId != null "> and live_id = #{liveId}</if>
-            <if test="redNum != null "> and red_num = #{redNum}</if>
-            <if test="totalLots != null "> and total_lots = #{totalLots}</if>
-            <if test="totalSend != null "> and total_send = #{totalSend}</if>
-            <if test="desc != null  and desc != ''"> and desc = #{desc}</if>
+            <if test="desc != null  and desc != ''"> and `desc` = #{desc}</if>
+            <if test="createTime != null "> and create_time = #{createTime}</if>
+            <if test="udpateTime != null "> and update_time = #{udpateTime}</if>
         </where>
     </select>
-    
+
     <select id="selectLiveRedConfByRedId" parameterType="Long" resultMap="LiveRedConfResult">
         <include refid="selectLiveRedConfVo"/>
         where red_id = #{redId}
     </select>
-        
+
     <insert id="insertLiveRedConf" parameterType="LiveRedConf" useGeneratedKeys="true" keyProperty="redId">
         insert into live_red_conf
         <trim prefix="(" suffix=")" suffixOverrides=",">
-            <if test="redStauts != null">red_stauts,</if>
+            <if test="redStatus != null">red_stauts,</if>
             <if test="duration != null">duration,</if>
             <if test="redType != null">red_type,</if>
             <if test="liveId != null">live_id,</if>
             <if test="redNum != null">red_num,</if>
             <if test="totalLots != null">total_lots,</if>
             <if test="totalSend != null">total_send,</if>
-            <if test="desc != null and desc != ''">desc,</if>
+            <if test="desc != null and desc != ''">`desc`,</if>
             <if test="createTime != null">create_time,</if>
-            <if test="udpateTime != null">udpate_time,</if>
+            <if test="udpateTime != null">update_time,</if>
             <if test="createBy != null">create_by,</if>
             <if test="updateBy != null">update_by,</if>
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
-            <if test="redStauts != null">#{redStauts},</if>
+            <if test="redStatus != null">#{redStatus},</if>
             <if test="duration != null">#{duration},</if>
             <if test="redType != null">#{redType},</if>
             <if test="liveId != null">#{liveId},</if>
@@ -78,16 +76,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <update id="updateLiveRedConf" parameterType="LiveRedConf">
         update live_red_conf
         <trim prefix="SET" suffixOverrides=",">
-            <if test="redStauts != null">red_stauts = #{redStauts},</if>
+            <if test="redStatus != null">red_stauts = #{redStatus},</if>
             <if test="duration != null">duration = #{duration},</if>
             <if test="redType != null">red_type = #{redType},</if>
             <if test="liveId != null">live_id = #{liveId},</if>
             <if test="redNum != null">red_num = #{redNum},</if>
             <if test="totalLots != null">total_lots = #{totalLots},</if>
             <if test="totalSend != null">total_send = #{totalSend},</if>
-            <if test="desc != null and desc != ''">desc = #{desc},</if>
+            <if test="desc != null and desc != ''">`desc` = #{desc},</if>
             <if test="createTime != null">create_time = #{createTime},</if>
-            <if test="udpateTime != null">udpate_time = #{udpateTime},</if>
+            <if test="udpateTime != null">update_time = #{udpateTime},</if>
             <if test="createBy != null">create_by = #{createBy},</if>
             <if test="updateBy != null">update_by = #{updateBy},</if>
         </trim>
@@ -99,9 +97,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </delete>
 
     <delete id="deleteLiveRedConfByRedIds" parameterType="String">
-        delete from live_red_conf where red_id in 
+        delete from live_red_conf where red_id in
         <foreach item="redId" collection="array" open="(" separator="," close=")">
             #{redId}
         </foreach>
     </delete>
-</mapper>
+</mapper>

+ 14 - 10
fs-service/src/main/resources/mapper/live/LiveUserLotteryRecordMapper.xml

@@ -3,7 +3,7 @@
 PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.fs.live.mapper.LiveUserLotteryRecordMapper">
-    
+
     <resultMap type="LiveUserLotteryRecord" id="LiveUserLotteryRecordResult">
         <result property="id"    column="id"    />
         <result property="lotteryId"    column="lottery_id"    />
@@ -11,26 +11,30 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="userId"    column="user_id"    />
         <result property="productId"    column="product_id"    />
         <result property="createTime"    column="create_time"    />
-        <result property="udpateTime"    column="udpate_time"    />
+        <result property="udpateTime"    column="update_time"    />
         <result property="createBy"    column="create_by"    />
         <result property="updateBy"    column="update_by"    />
     </resultMap>
 
     <sql id="selectLiveUserLotteryRecordVo">
-        select id, lottery_id, live_id, user_id, product_id, create_time, udpate_time, create_by, update_by from live_user_lottery_record
+        select id, lottery_id, live_id, user_id, product_id, create_time, update_time, create_by, update_by from live_user_lottery_record
     </sql>
 
     <select id="selectLiveUserLotteryRecordList" parameterType="LiveUserLotteryRecord" resultMap="LiveUserLotteryRecordResult">
         <include refid="selectLiveUserLotteryRecordVo"/>
-        <where>  
+        <where>
+            <if test="liveId != null "> and live_id = #{liveId}</if>
+            <if test="userId != null "> and user_id = #{userId}</if>
+            <if test="productId != null "> and product_id = #{productId}</if>
+            <if test="createTime != null "> and create_time = #{createTime}</if>
         </where>
     </select>
-    
+
     <select id="selectLiveUserLotteryRecordById" parameterType="Long" resultMap="LiveUserLotteryRecordResult">
         <include refid="selectLiveUserLotteryRecordVo"/>
         where id = #{id}
     </select>
-        
+
     <insert id="insertLiveUserLotteryRecord" parameterType="LiveUserLotteryRecord" useGeneratedKeys="true" keyProperty="id">
         insert into live_user_lottery_record
         <trim prefix="(" suffix=")" suffixOverrides=",">
@@ -39,7 +43,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="userId != null">user_id,</if>
             <if test="productId != null">product_id,</if>
             <if test="createTime != null">create_time,</if>
-            <if test="udpateTime != null">udpate_time,</if>
+            <if test="udpateTime != null">update_time,</if>
             <if test="createBy != null">create_by,</if>
             <if test="updateBy != null">update_by,</if>
          </trim>
@@ -63,7 +67,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="userId != null">user_id = #{userId},</if>
             <if test="productId != null">product_id = #{productId},</if>
             <if test="createTime != null">create_time = #{createTime},</if>
-            <if test="udpateTime != null">udpate_time = #{udpateTime},</if>
+            <if test="udpateTime != null">update_time = #{udpateTime},</if>
             <if test="createBy != null">create_by = #{createBy},</if>
             <if test="updateBy != null">update_by = #{updateBy},</if>
         </trim>
@@ -75,9 +79,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </delete>
 
     <delete id="deleteLiveUserLotteryRecordByIds" parameterType="String">
-        delete from live_user_lottery_record where id in 
+        delete from live_user_lottery_record where id in
         <foreach item="id" collection="array" open="(" separator="," close=")">
             #{id}
         </foreach>
     </delete>
-</mapper>
+</mapper>

+ 13 - 10
fs-service/src/main/resources/mapper/live/LiveUserRedRecordMapper.xml

@@ -3,7 +3,7 @@
 PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.fs.live.mapper.LiveUserRedRecordMapper">
-    
+
     <resultMap type="LiveUserRedRecord" id="LiveUserRedRecordResult">
         <result property="id"    column="id"    />
         <result property="redId"    column="red_id"    />
@@ -11,26 +11,29 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="userId"    column="user_id"    />
         <result property="integral"    column="integral"    />
         <result property="createTime"    column="create_time"    />
-        <result property="udpateTime"    column="udpate_time"    />
+        <result property="udpateTime"    column="update_time"    />
         <result property="createBy"    column="create_by"    />
         <result property="updateBy"    column="update_by"    />
     </resultMap>
 
     <sql id="selectLiveUserRedRecordVo">
-        select id, red_id, live_id, user_id, integral, create_time, udpate_time, create_by, update_by from live_user_red_record
+        select id, red_id, live_id, user_id, integral, create_time, update_time, create_by, update_by from live_user_red_record
     </sql>
 
     <select id="selectLiveUserRedRecordList" parameterType="LiveUserRedRecord" resultMap="LiveUserRedRecordResult">
         <include refid="selectLiveUserRedRecordVo"/>
-        <where>  
+        <where>
+            <if test="liveId != null "> and live_id = #{liveId}</if>
+            <if test="userId != null "> and user_id = #{userId}</if>
+            <if test="createTime != null "> and create_time = #{createTime}</if>
         </where>
     </select>
-    
+
     <select id="selectLiveUserRedRecordById" parameterType="Long" resultMap="LiveUserRedRecordResult">
         <include refid="selectLiveUserRedRecordVo"/>
         where id = #{id}
     </select>
-        
+
     <insert id="insertLiveUserRedRecord" parameterType="LiveUserRedRecord" useGeneratedKeys="true" keyProperty="id">
         insert into live_user_red_record
         <trim prefix="(" suffix=")" suffixOverrides=",">
@@ -39,7 +42,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="userId != null">user_id,</if>
             <if test="integral != null">integral,</if>
             <if test="createTime != null">create_time,</if>
-            <if test="udpateTime != null">udpate_time,</if>
+            <if test="udpateTime != null">update_time,</if>
             <if test="createBy != null">create_by,</if>
             <if test="updateBy != null">update_by,</if>
          </trim>
@@ -63,7 +66,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="userId != null">user_id = #{userId},</if>
             <if test="integral != null">integral = #{integral},</if>
             <if test="createTime != null">create_time = #{createTime},</if>
-            <if test="udpateTime != null">udpate_time = #{udpateTime},</if>
+            <if test="udpateTime != null">update_time = #{udpateTime},</if>
             <if test="createBy != null">create_by = #{createBy},</if>
             <if test="updateBy != null">update_by = #{updateBy},</if>
         </trim>
@@ -75,9 +78,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </delete>
 
     <delete id="deleteLiveUserRedRecordByIds" parameterType="String">
-        delete from live_user_red_record where id in 
+        delete from live_user_red_record where id in
         <foreach item="id" collection="array" open="(" separator="," close=")">
             #{id}
         </foreach>
     </delete>
-</mapper>
+</mapper>