Просмотр исходного кода

1、新增直播中康营销奖励
2、新增是否展示购物车

yys 1 неделя назад
Родитель
Сommit
506f1af989

+ 9 - 0
fs-admin/src/main/java/com/fs/live/controller/LiveController.java

@@ -133,6 +133,15 @@ public class LiveController extends BaseController {
         return liveService.updateLiveIsAudit(live);
     }
 
+    /**
+     * 更新直播间购物车显示状态
+     */
+    @PreAuthorize("@ss.hasPermi('live:live:edit')")
+    @PostMapping("/updateShowCart")
+    public R updateShowCart(@RequestBody Live live) {
+        return liveService.updateShowCart(live.getLiveId(), live.getShowCart());
+    }
+
 
 
     /**

+ 4 - 0
fs-live-app/src/main/java/com/fs/live/websocket/service/WebSocketServer.java

@@ -649,6 +649,10 @@ public class WebSocketServer {
                     // 管理员消息插队
                     enqueueMessage(liveId, JSONObject.toJSONString(R.ok().put("data", msg)), true);
                     break;
+                case "showCart":
+                    msg.setOn(true);
+                    enqueueMessage(liveId, JSONObject.toJSONString(R.ok().put("data", msg)), true);
+                    break;
                 case "singleVisible":
                     liveWatchUserService.updateSingleVisible(liveId, msg.getStatus(),msg.getUserId());
                     // 管理员消息插队

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

@@ -136,6 +136,9 @@ public class   Live extends BaseEntity {
     private Long videoDuration;
     private Integer globalVisible;
 
+    /** 是否显示购物车 0否 1是 */
+    private Integer showCart;
+
     private String roomPassword;
 
     // 是否需要秘钥

+ 7 - 5
fs-service/src/main/java/com/fs/live/mapper/LiveCouponMapper.java

@@ -70,8 +70,9 @@ public interface LiveCouponMapper
     List<LiveCoupon> selectLiveCouponByIds(String ids);
 
     @Select("select lc.*,lci.id,lcir.is_show,lcir.goods_id,fsp.product_name,fsp.image " +
-            "from live_coupon_issue_relation lcir left join live_coupon_issue lci " +
-            "left join live_coupon lc on lc.coupon_id=lci.coupon_id on lci.id = lcir.coupon_issue_id  " +
+            "from live_coupon_issue_relation lcir " +
+            "left join live_coupon_issue lci on lci.id = lcir.coupon_issue_id " +
+            "left join live_coupon lc on lc.coupon_id = lci.coupon_id " +
             "left join live_goods lg on lg.goods_id = lcir.goods_id " +
             "left join fs_store_product_scrm fsp on lg.product_id = fsp.product_id " +
             "where lcir.live_id = #{liveId}")
@@ -109,11 +110,12 @@ public interface LiveCouponMapper
     LiveCouponIssue selectLiveCouponIssueByLiveIdAndCouponId(@Param("liveId")Long liveId,@Param("couponId") Long couponId);
 
     @Select("select lc.*,lci.id,lcir.is_show,lcir.goods_id,fsp.product_name,fsp.image " +
-            "from live_coupon_issue_relation lcir left join live_coupon_issue lci " +
-            "left join live_coupon lc on lc.coupon_id=lci.coupon_id on lci.id = lcir.coupon_issue_id  " +
+            "from live_coupon_issue_relation lcir " +
+            "left join live_coupon_issue lci on lci.id = lcir.coupon_issue_id " +
+            "left join live_coupon lc on lc.coupon_id = lci.coupon_id " +
             "left join live_goods lg on lg.goods_id = lcir.goods_id " +
             "left join fs_store_product_scrm fsp on lg.product_id = fsp.product_id " +
-            "where lcir.live_id = #{liveId} and lcir.goods_id is not null")
+            "where lcir.live_id = #{liveId}")
     List<LiveCoupon> listOn(@Param("liveId") Long liveId);
 
     @Update("update live_coupon_issue_relation set is_show = case WHEN coupon_issue_id = #{couponId} THEN 1 else 0 end where live_id = #{liveId}")

+ 3 - 0
fs-service/src/main/java/com/fs/live/mapper/LiveMapper.java

@@ -159,6 +159,9 @@ public interface LiveMapper
     @Update("update live set global_visible = #{status} where live_id = #{liveId}")
     void updateGlobalVisible(@Param("liveId")Long liveId,@Param("status") Integer status);
 
+    @Update("update live set show_cart = #{showCart} where live_id = #{liveId}")
+    void updateShowCart(@Param("liveId") Long liveId, @Param("showCart") Integer showCart);
+
     @Select({"<script>" +
             "select * from live where 1=1 " +
             " <if test='param.companyId!=null' > and company_id = #{param.companyId} </if> and live_type IN (1,2, 3) AND status IN (3, 4) AND is_del = 0 and is_audit=1 " +

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

@@ -211,6 +211,8 @@ public interface ILiveService
 
     void updateGlobalVisible(long liveId, Integer status);
 
+    R updateShowCart(Long liveId, Integer showCart);
+
     String getGotoWxAppLiveLink(String linkStr, String appid);
 
     R liveListAll(PageRequest pageRequest);

+ 25 - 5
fs-service/src/main/java/com/fs/live/service/impl/LiveCouponServiceImpl.java

@@ -11,6 +11,7 @@ import com.github.pagehelper.PageInfo;
 import com.fs.common.core.domain.R;
 import com.fs.common.core.redis.RedisCache;
 import com.fs.common.utils.DateUtils;
+import com.fs.common.utils.DictUtils;
 import com.fs.common.utils.StringUtils;
 import com.fs.live.domain.*;
 import com.fs.live.mapper.LiveCouponIssueMapper;
@@ -189,7 +190,9 @@ public class LiveCouponServiceImpl implements ILiveCouponService
 
     @Override
     public List<LiveCoupon> selectLiveCouponByLiveId(Long liveId) {
-        return liveCouponMapper.selectLiveCouponByLiveId(liveId);
+        return liveCouponMapper.selectLiveCouponByLiveId(liveId).stream()
+                .filter(c -> c.getCouponId() != null)
+                .collect(Collectors.toList());
     }
 
     @Override
@@ -229,10 +232,9 @@ public class LiveCouponServiceImpl implements ILiveCouponService
 
         // 查询优惠券类型
         LiveCoupon liveCoupon = liveCouponMapper.selectLiveCouponById(couponId);
-        boolean isNoThresholdCoupon = liveCoupon != null && liveCoupon.getType() != null && liveCoupon.getType() == 3L;
 
-        // 如果不是无门槛优惠券,需要检查是否绑定了商品
-        if (!isNoThresholdCoupon && ObjectUtil.isEmpty(liveCouponIssueRelation.getGoodsId())) {
+        // 如果不是核销券/无门槛券,需要检查是否绑定了商品
+        if (!isVerifyCouponType(liveCoupon) && ObjectUtil.isEmpty(liveCouponIssueRelation.getGoodsId())) {
             return R.error("未绑定商品,无法发布!");
         }
 
@@ -490,7 +492,25 @@ public class LiveCouponServiceImpl implements ILiveCouponService
 
     @Override
     public List<LiveCoupon> listOn(Long liveId) {
-        return liveCouponMapper.listOn(liveId);
+        return liveCouponMapper.listOn(liveId).stream()
+                .filter(c -> c.getCouponId() != null)
+                .filter(c -> c.getGoodsId() != null || isVerifyCouponType(c))
+                .collect(Collectors.toList());
+    }
+
+    /**
+     * 核销券/无门槛券无需绑定直播商品
+     */
+    private boolean isVerifyCouponType(LiveCoupon coupon) {
+        if (coupon == null || coupon.getType() == null) {
+            return false;
+        }
+        if (coupon.getType() == 3L) {
+            return true;
+        }
+        String typeLabel = DictUtils.getDictLabel("store_coupon_type", String.valueOf(coupon.getType()));
+        return StringUtils.isNotEmpty(typeLabel)
+                && (typeLabel.contains("核销") || typeLabel.contains("代金券"));
     }
 
     /**

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

@@ -593,6 +593,16 @@ public class LiveServiceImpl implements ILiveService
         clearLiveCache(liveId);
     }
 
+    @Override
+    public R updateShowCart(Long liveId, Integer showCart) {
+        if (liveId == null || showCart == null) {
+            return R.error("参数错误");
+        }
+        baseMapper.updateShowCart(liveId, showCart);
+        clearLiveCache(liveId);
+        return R.ok();
+    }
+
     @Override
     public String getGotoWxAppLiveLink(String linkStr, String appId) {
         CloseableHttpClient client = null;

+ 2 - 0
fs-service/src/main/java/com/fs/live/vo/LiveVo.java

@@ -58,6 +58,8 @@ public class LiveVo {
     private Integer previewVideoType;
     private Long previewVideoId;
     private Integer globalVisible;
+    /** 是否显示购物车 0否 1是 */
+    private Integer showCart;
     private Integer liveFlag;
 
     /** 是否开启直播完课积分功能 */

+ 9 - 4
fs-service/src/main/resources/mapper/live/LiveMapper.xml

@@ -33,19 +33,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="idCardUrl"    column="id_card_url"    />
         <result property="liveCodeUrl"    column="live_code_url"    />
         <result property="globalVisible"    column="global_visible"    />
+        <result property="showCart"    column="show_cart"    />
         <result property="roomPassword"    column="room_password"    />
     </resultMap>
 
     <sql id="selectLiveVo">
         select live_id, company_id, company_user_id,talent_id, live_name, is_audit, live_desc, show_type, status, anchor_id, live_type, start_time, finish_time,
                live_img_url, live_config, id_card_url, is_show, is_del, qw_qr_code, rtmp_url, flv_hls_url,
-               create_time, create_by, update_by, update_time, remark,config_json,global_visible,room_password from live
+               create_time, create_by, update_by, update_time, remark,config_json,global_visible,show_cart,room_password from live
     </sql>
 
     <select id="liveList" parameterType="Live" resultMap="LiveResult">
         select a.live_id, a.company_id, a.company_user_id,talent_id, a.live_name, a.is_audit, a.live_desc, a.show_type, a.status, a.anchor_id,
         a.live_type, a.start_time, a.finish_time, a.live_img_url, a.live_config, a.id_card_url, a.is_show, a.is_del, a.qw_qr_code, a.rtmp_url,
-        a.flv_hls_url, a.create_time, a.create_by, a.update_by, a.update_time, a.remark,config_json, b.video_url,c.company_name,b.file_size,a.global_visible
+        a.flv_hls_url, a.create_time, a.create_by, a.update_by, a.update_time, a.remark,config_json, b.video_url,c.company_name,b.file_size,a.global_visible,a.show_cart
         from live
         a
         left join live_video b on a.live_id = b.live_id
@@ -57,7 +58,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <select id="selectReadyStartLiveList" parameterType="Live" resultMap="LiveResult">
         select a.live_id, a.company_id, a.company_user_id,talent_id, a.live_name, a.is_audit, a.live_desc, a.show_type, a.status, a.anchor_id,
         a.live_type, a.start_time, a.finish_time, a.live_img_url, a.live_config, a.id_card_url, a.is_show, a.is_del, a.qw_qr_code, a.rtmp_url,
-        a.flv_hls_url, a.create_time, a.create_by, a.update_by, a.update_time, a.remark,config_json, b.video_url,c.company_name,b.file_size,a.global_visible
+        a.flv_hls_url, a.create_time, a.create_by, a.update_by, a.update_time, a.remark,config_json, b.video_url,c.company_name,b.file_size,a.global_visible,a.show_cart
         from live
         a
         left join live_video b on a.live_id = b.live_id
@@ -71,7 +72,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <select id="selectLiveList" parameterType="com.fs.live.domain.Live" resultMap="LiveResult">
         select a.live_id, a.company_id, a.company_user_id,talent_id, a.live_name, a.is_audit, a.live_desc, a.show_type, a.status, a.anchor_id,
                a.live_type, a.start_time, a.finish_time, a.live_img_url, a.live_config, a.id_card_url, a.is_show, a.is_del, a.qw_qr_code, a.rtmp_url,
-               a.flv_hls_url, a.create_time, a.create_by, a.update_by, a.update_time, a.remark,config_json, b.video_url,a.global_visible,a.room_password
+               a.flv_hls_url, a.create_time, a.create_by, a.update_by, a.update_time, a.remark,config_json, b.video_url,a.global_visible,a.show_cart,a.room_password
                 ,c.live_code_url,IFNULL(d.company_name, '总台') AS company_name,b.file_size
 
         from live a
@@ -162,6 +163,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="isAudit != null">is_audit,</if>
             <if test="idCardUrl != null">id_card_url,</if>
             <if test="globalVisible != null">global_visible,</if>
+            <if test="showCart != null">show_cart,</if>
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="companyId != null">#{companyId},</if>
@@ -191,6 +193,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="isAudit != null">#{isAudit},</if>
             <if test="idCardUrl != null">#{idCardUrl},</if>
             <if test="globalVisible != null">#{globalVisible},</if>
+            <if test="showCart != null">#{showCart},</if>
          </trim>
     </insert>
 
@@ -223,6 +226,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="isAudit != null">is_audit = #{isAudit},</if>
             <if test="idCardUrl != null">id_card_url = #{idCardUrl},</if>
             <if test="globalVisible != null">global_visible = #{globalVisible},</if>
+            <if test="showCart != null">show_cart = #{showCart},</if>
             <if test="roomPassword != null">room_password = #{roomPassword},</if>
         </trim>
         where live_id = #{liveId}
@@ -306,6 +310,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
                 <if test="live.liveConfig != null and live.liveConfig != ''">live_config = #{live.liveConfig},</if>
                 <if test="live.remark != null and live.remark != ''">remark = #{live.remark},</if>
                 <if test="live.globalVisible != null and live.globalVisible != ''">global_visible = #{live.globalVisible},</if>
+                <if test="live.showCart != null and live.showCart != ''">show_cart = #{live.showCart},</if>
                 update_time = NOW()
             </set>
             WHERE live_id = #{live.liveId}