浏览代码

1、迁移直播优惠卷领取记录

yys 2 周之前
父节点
当前提交
0d5b749b36

+ 79 - 0
fs-company/src/main/java/com/fs/company/controller/live/LiveCouponUserController.java

@@ -0,0 +1,79 @@
+package com.fs.company.controller.live;
+
+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.page.TableDataInfo;
+import com.fs.common.enums.BusinessType;
+import com.fs.common.utils.poi.ExcelUtil;
+import com.fs.framework.security.SecurityUtils;
+import com.fs.live.domain.LiveCouponUser;
+import com.fs.live.param.LiveCouponVerifyParam;
+import com.fs.live.service.ILiveCouponService;
+import com.fs.live.service.ILiveCouponUserService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+/**
+ * 优惠券发放记录Controller(销售端)
+ */
+@RestController
+@RequestMapping("/live/coupon/user")
+public class LiveCouponUserController extends BaseController
+{
+    @Autowired
+    private ILiveCouponUserService liveCouponUserService;
+
+    @Autowired
+    private ILiveCouponService liveCouponService;
+
+    /**
+     * 查询优惠券发放记录列表
+     * 仅返回 fs_user.bind_company_user_id = 当前销售 的优惠券
+     */
+    @GetMapping("/list")
+    public TableDataInfo list(LiveCouponUser liveCouponUser)
+    {
+        liveCouponUser.getParams().put("bindCompanyUserId", SecurityUtils.getLoginUser().getUser().getUserId());
+        startPage();
+        List<LiveCouponUser> list = liveCouponUserService.selectLiveCouponUserList(liveCouponUser);
+        return getDataTable(list);
+    }
+
+    /**
+     * 导出优惠券发放记录列表
+     */
+    @Log(title = "优惠券发放记录", businessType = BusinessType.EXPORT)
+    @GetMapping("/export")
+    public AjaxResult export(LiveCouponUser liveCouponUser)
+    {
+        liveCouponUser.getParams().put("bindCompanyUserId", SecurityUtils.getLoginUser().getUser().getUserId());
+        List<LiveCouponUser> list = liveCouponUserService.selectLiveCouponUserList(liveCouponUser);
+        ExcelUtil<LiveCouponUser> util = new ExcelUtil<LiveCouponUser>(LiveCouponUser.class);
+        return util.exportExcel(list, "优惠券发放记录");
+    }
+
+    /**
+     * 获取优惠券发放记录详细信息
+     */
+    @GetMapping(value = "/{id}")
+    public AjaxResult getInfo(@PathVariable("id") Long id)
+    {
+        return AjaxResult.success(liveCouponUserService.selectLiveCouponUserById(id));
+    }
+
+    /**
+     * 销售端核销优惠券
+     */
+    @Log(title = "优惠券核销", businessType = BusinessType.UPDATE)
+    @PostMapping("/verify")
+    public R verify(@RequestBody LiveCouponVerifyParam param)
+    {
+        Long verifyUserId = SecurityUtils.getLoginUser().getUser().getUserId();
+        param.setVerifyUserId(verifyUserId);
+        return liveCouponService.verifyCoupon(param);
+    }
+}

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

@@ -521,8 +521,8 @@ public class LiveServiceImpl implements ILiveService
             LiveVideo liveVideo = videos.get(0);
             byId.setVideoUrl(liveVideo.getVideoUrl());
 
-            // 汇总所有视频时长,而非只取第一个
-            long totalDuration = videos.stream()
+            // 汇总所有视频时长,而非只取第一个(用 Long 避免三元表达式对 null duration 拆箱 NPE)
+            Long totalDuration = videos.stream()
                     .filter(v -> v.getDuration() != null)
                     .mapToLong(LiveVideo::getDuration)
                     .sum();

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

@@ -63,15 +63,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <select id="selectLiveCouponUserList" parameterType="LiveCouponUser" resultMap="LiveCouponUserResult">
 
         select cou.id, cou.coupon_id, cou.user_id, cou.coupon_title, cou.coupon_price, cou.use_min_price, cou.create_time, cou.update_time, cou.limit_time, cou.use_time, cou.type, cou.status, cou.is_fail, cou.is_del,cou.goods_id,
-        u.nick_name,u.phone
+        cou.verify_code, cou.verify_user_id, cou.verify_time
 
         from live_coupon_user as  cou
          left join fs_user u on cou.user_id=u.user_id
 
         <where>
+            and (cou.is_del is null or cou.is_del = 0)
             <if test="couponId != null "> and cou.coupon_id = #{couponId}</if>
             <if test="userId != null "> and cou.user_id = #{userId}</if>
-            <if test="couponTitle != null  and couponTitle != ''"> and cou.coupon_title = #{couponTitle}</if>
+            <if test="couponTitle != null  and couponTitle != ''"> and cou.coupon_title like concat('%', #{couponTitle}, '%')</if>
             <if test="couponPrice != null "> and cou.coupon_price = #{couponPrice}</if>
             <if test="useMinPrice != null "> and cou.use_min_price = #{useMinPrice}</if>
             <if test="limitTime != null "> and cou.limit_time = #{limitTime}</if>
@@ -83,7 +84,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="goodsId != null "> and cou.goods_id = #{goodsId}</if>
             <if test="verifyCode != null and verifyCode != ''"> and cou.verify_code = #{verifyCode}</if>
             <if test="verifyUserId != null "> and cou.verify_user_id = #{verifyUserId}</if>
+            <if test="params.bindCompanyUserId != null"> and u.bind_company_user_id = #{params.bindCompanyUserId}</if>
+            <if test="params.beginTime != null and params.beginTime != ''">
+                and date_format(cou.create_time,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d')
+            </if>
+            <if test="params.endTime != null and params.endTime != ''">
+                and date_format(cou.create_time,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d')
+            </if>
         </where>
+        order by cou.create_time desc
     </select>
 
     <select id="selectLiveCouponUserDetailList" parameterType="com.fs.live.param.CouponPO" resultMap="LiveCouponUserDetailVoResult">