Browse Source

直播数据修改

yuhongqi 2 days ago
parent
commit
1fe08ba323

+ 4 - 0
fs-service/src/main/java/com/fs/his/mapper/FsIntegralCartMapper.java

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.fs.his.domain.FsIntegralCart;
 import com.fs.his.vo.FsIntegralCartVO;
 import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Update;
 
 import java.util.List;
 import java.util.Map;
@@ -35,4 +36,7 @@ public interface FsIntegralCartMapper extends BaseMapper<FsIntegralCart> {
      * @return  删除数量
      */
     int deleteCartByGoodsId(@Param("goodsId") Long goodsId);
+
+    @Update("update fs_integral_cart set integral = #{integral} where goods_id = #{goodsId}")
+    void updateIntegralByGoodsId(@Param("goodsId")Long goodsId,@Param("integral") Long integral);
 }

+ 5 - 0
fs-service/src/main/java/com/fs/his/service/impl/FsIntegralCartServiceImpl.java

@@ -3,6 +3,7 @@ package com.fs.his.service.impl;
 import com.baomidou.mybatisplus.core.conditions.Wrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.fs.common.core.domain.R;
 import com.fs.common.exception.CustomException;
 import com.fs.his.domain.FsIntegralCart;
 import com.fs.his.domain.FsIntegralGoods;
@@ -61,6 +62,10 @@ public class FsIntegralCartServiceImpl extends ServiceImpl<FsIntegralCartMapper,
             log.warn("addOrUpdateCart goods not enough cartNum: {}", goodsId);
             throw new CustomException("库存不足");
         }
+        if (fsIntegralGoods.getStatus() == 0) {
+            log.warn("addOrUpdateCart goods not enable cartNum: {}", goodsId);
+            throw new CustomException("商品停售");
+        }
 
         FsIntegralCart cart = new FsIntegralCart();
         cart.setUserId(userId);

+ 8 - 0
fs-service/src/main/java/com/fs/his/service/impl/FsIntegralGoodsServiceImpl.java

@@ -90,6 +90,14 @@ public class FsIntegralGoodsServiceImpl implements IFsIntegralGoodsService
     @Override
     public int updateFsIntegralGoods(FsIntegralGoods fsIntegralGoods)
     {
+        FsIntegralGoods existGoods = fsIntegralGoodsMapper.selectFsIntegralGoodsByGoodsId(fsIntegralGoods.getGoodsId());
+        if (existGoods == null) {
+            return -1;
+        }
+        // 存在的积分和现在的积分不相等,更新积分购物车的积分
+        if(existGoods.getIntegral() != fsIntegralGoods.getIntegral()) {
+            fsIntegralCartMapper.updateIntegralByGoodsId(fsIntegralGoods.getGoodsId(), fsIntegralGoods.getIntegral());
+        }
         return fsIntegralGoodsMapper.updateFsIntegralGoods(fsIntegralGoods);
     }
 

+ 4 - 1
fs-service/src/main/java/com/fs/his/service/impl/FsIntegralOrderServiceImpl.java

@@ -312,7 +312,7 @@ public class FsIntegralOrderServiceImpl implements IFsIntegralOrderService
             return R.error("积分不足");
         }
         if (integralGoods.getStatus() == 0) {
-            return R.error("商品已经停,请联系客户进行处理!");
+            return R.error("商品已经停,请联系客户进行处理!");
         }
 
         // 减库存
@@ -473,6 +473,9 @@ public class FsIntegralOrderServiceImpl implements IFsIntegralOrderService
             if(integralGoods.getStock() < cart.getCartNum()){
                 throw new CustomException("库存不足");
             }
+            if (integralGoods.getStatus() == 0) {
+                return R.error(integralGoods.getGoodsName() + "商品已经停售,请联系客户进行处理!");
+            }
 
             // 减库存
             if (fsIntegralGoodsMapper.subStock(integralGoods.getGoodsId(), cart.getCartNum()) <= 0) {

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

@@ -794,10 +794,8 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
                         List<LiveWatchLog> logs = liveWatchLogService.selectLiveWatchLogList(queryLog);
                         if (logs != null && !logs.isEmpty()) {
                             for (LiveWatchLog log : logs) {
-                                if (log.getLogType() == null || log.getLogType() != 2) {
-                                    log.setLiveBuy(1);
-                                    liveWatchLogService.updateLiveWatchLog(log);
-                                }
+                                log.setLiveBuy(1);
+                                liveWatchLogService.updateLiveWatchLog(log);
                             }
                         }
                     }

+ 8 - 1
fs-user-app/src/main/java/com/fs/app/controller/live/LiveCompletionPointsController.java

@@ -17,6 +17,7 @@ import com.fs.live.mapper.LiveCompletionPointsRecordMapper;
 import com.fs.live.service.ILiveCompletionPointsRecordService;
 import com.fs.live.service.ILiveService;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.*;
 
 import java.math.BigDecimal;
@@ -181,6 +182,7 @@ public class LiveCompletionPointsController extends AppBaseController {
      * 更新用户看课completionPointsRecordService看课记录里面的时长
      */
     @PostMapping("/update-watch-duration")
+    @Transactional
     public R updateWatchDuration(@RequestParam Long liveId, @RequestParam Long watchDuration) {
         Long userId = Long.parseLong(getUserId());
         
@@ -251,6 +253,8 @@ public class LiveCompletionPointsController extends AppBaseController {
             if (record == null) {
                 // 如果没有记录,先创建记录
                 record = completionPointsRecordService.createCompletionRecord(liveId, userId);
+                record.setWatchDuration(finalWatchDuration);
+                completionPointsRecordMapper.updateRecord(record);
             } else {
                 // 更新现有记录的看课时长
                 Long currentWatchDuration = record.getWatchDuration() != null 
@@ -269,7 +273,10 @@ public class LiveCompletionPointsController extends AppBaseController {
                     record.setCompletionRate(completionRate);
                 }
                 
-                completionPointsRecordMapper.updateRecord(record);
+                int updateResult = completionPointsRecordMapper.updateRecord(record);
+                if (updateResult <= 0) {
+                    return R.error("更新看课时间失败");
+                }
             }
 
             UpdateWatchDurationVO vo = new UpdateWatchDurationVO();