Bläddra i källkod

Merge remote-tracking branch 'origin/zouxuan_saas_2022_0606' into zouxuan_saas_2022_0606

liweifan 3 år sedan
förälder
incheckning
3075918896

+ 1 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/TempBuyFreeLiveTheoryCourseDao.java

@@ -14,4 +14,5 @@ public interface TempBuyFreeLiveTheoryCourseDao extends BaseDAO<Integer, TempBuy
     List<TempBuyFreeLiveTheoryCourse> list(@Param("param") TempBuyFreeLiveTheoryCourse tempBuyFreeLiveTheoryCourse);
     List<TempBuyFreeLiveTheoryCourse> list(@Param("param") TempBuyFreeLiveTheoryCourse tempBuyFreeLiveTheoryCourse);
 
 
 
 
+    TempBuyFreeLiveTheoryCourse findByGoodsIdAndUserId(@Param("liveGoodsId") Integer liveGoodsId, @Param("userId") Integer userId);
 }
 }

+ 1 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/ExportService.java

@@ -264,7 +264,7 @@ public interface ExportService {
     HttpResponseResult exportStudentVipCourseInfo(Map<String, Object> info, List<String> headColumns);
     HttpResponseResult exportStudentVipCourseInfo(Map<String, Object> info, List<String> headColumns);
 
 
     //vip学员课程管理
     //vip学员课程管理
-    HttpResponseResult exportVipStudentCourseManage(Map<String, Object> info, List<String> headColumns);
+    HttpResponseResult exportVipStudentCourseManage(Map<String, Object> info, List<String> headColumns) throws Exception;
 
 
     //学员小课记录导出
     //学员小课记录导出
     HttpResponseResult exportStudentMusicTheoryCourseInfo(Map<String, Object> info, List<String> headColumns);
     HttpResponseResult exportStudentMusicTheoryCourseInfo(Map<String, Object> info, List<String> headColumns);

+ 4 - 8
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ExportServiceImpl.java

@@ -26,10 +26,8 @@ import com.ym.mec.util.date.DateUtil;
 import com.ym.mec.util.excel.POIUtil;
 import com.ym.mec.util.excel.POIUtil;
 import com.ym.mec.util.ini.IniFileUtil;
 import com.ym.mec.util.ini.IniFileUtil;
 import com.ym.mec.util.upload.UploadUtil;
 import com.ym.mec.util.upload.UploadUtil;
-
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
-import org.apache.poi.ss.formula.functions.T;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.boot.system.ApplicationHome;
 import org.springframework.boot.system.ApplicationHome;
@@ -40,7 +38,6 @@ import org.springframework.util.CollectionUtils;
 
 
 import javax.annotation.PostConstruct;
 import javax.annotation.PostConstruct;
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpServletResponse;
-
 import java.io.*;
 import java.io.*;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.InvocationTargetException;
 import java.math.BigDecimal;
 import java.math.BigDecimal;
@@ -51,7 +48,6 @@ import java.util.concurrent.Executors;
 import java.util.function.BiFunction;
 import java.util.function.BiFunction;
 import java.util.function.Function;
 import java.util.function.Function;
 import java.util.stream.Collectors;
 import java.util.stream.Collectors;
-import java.util.stream.Stream;
 
 
 import static com.ym.mec.biz.dal.enums.OrderTypeEnum.OUTORDER;
 import static com.ym.mec.biz.dal.enums.OrderTypeEnum.OUTORDER;
 
 
@@ -178,8 +174,6 @@ public class ExportServiceImpl implements ExportService {
     private SysUserCashAccountLogService sysUserCashAccountLogService;
     private SysUserCashAccountLogService sysUserCashAccountLogService;
     @Autowired
     @Autowired
     private StudentStatisticsService studentStatisticsService;
     private StudentStatisticsService studentStatisticsService;
-    @Autowired
-    private SysTenantConfigService sysTenantConfigService;
 
 
     @Value("${spring.profiles.active:dev}")
     @Value("${spring.profiles.active:dev}")
     private String profiles;
     private String profiles;
@@ -1403,7 +1397,9 @@ public class ExportServiceImpl implements ExportService {
                 e.printStackTrace();
                 e.printStackTrace();
             }
             }
         }, executor);
         }, executor);
-        return BaseController.succeed(managerDownload.getName() + "导出申请已提交,请到【报表中心-下载列表查看】");
+        HttpResponseResult<Object> succeed = BaseController.succeed();
+        succeed.setMsg(managerDownload.getName() + "导出申请已提交,请到【报表中心-下载列表查看】");
+        return succeed;
     }
     }
 
 
     //学员小课记录导出
     //学员小课记录导出
@@ -2729,7 +2725,7 @@ public class ExportServiceImpl implements ExportService {
                     order.setMaintenanceFee(order.getMaintenanceFee());
                     order.setMaintenanceFee(order.getMaintenanceFee());
                     order.setMusicalFee(BigDecimal.ZERO);
                     order.setMusicalFee(BigDecimal.ZERO);
                     order.setTeachingFee(BigDecimal.ZERO);
                     order.setTeachingFee(BigDecimal.ZERO);
-                    order.setOtherFee(BigDecimal.ZERO);
+//                    order.setOtherFee(BigDecimal.ZERO);
                     order.setLeaseFee(BigDecimal.ZERO);
                     order.setLeaseFee(BigDecimal.ZERO);
                     continue;
                     continue;
                 }
                 }

+ 40 - 20
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MemberRankSettingServiceImpl.java

@@ -248,6 +248,7 @@ public class MemberRankSettingServiceImpl extends BaseServiceImpl<Integer, Membe
         if(CollectionUtils.isEmpty(activityDtos)){
         if(CollectionUtils.isEmpty(activityDtos)){
             throw new BizException("当前分部暂未开通活动");
             throw new BizException("当前分部暂未开通活动");
         }
         }
+        logger.error("activeBuy params goodsId: {},liveId: {}",memberPayParamDto.getLiveGoodsId(),memberPayParamDto.getLiveId());
         BigDecimal amount = BigDecimal.ZERO;
         BigDecimal amount = BigDecimal.ZERO;
         Integer activityId = null;
         Integer activityId = null;
         //判断当前商品是否可以购买(库存、上架状态、是否购买过)
         //判断当前商品是否可以购买(库存、上架状态、是否购买过)
@@ -281,23 +282,32 @@ public class MemberRankSettingServiceImpl extends BaseServiceImpl<Integer, Membe
             //扣减库存
             //扣减库存
             liveGoodsService.reduceGoodsStock(memberPayParamDto.getLiveGoodsId(),memberPayParamDto.getLiveId());
             liveGoodsService.reduceGoodsStock(memberPayParamDto.getLiveGoodsId(),memberPayParamDto.getLiveId());
         } else if (memberPayParamDto.getLiveGoodsId() == 2 || memberPayParamDto.getLiveGoodsId() == 3 || memberPayParamDto.getLiveGoodsId() == 4){
         } else if (memberPayParamDto.getLiveGoodsId() == 2 || memberPayParamDto.getLiveGoodsId() == 3 || memberPayParamDto.getLiveGoodsId() == 4){
-            StringBuffer sb = new StringBuffer(RedisKeyConstant.LIVE_GOODS_ZERO_CACHE_KEY).append(memberPayParamDto.getLiveGoodsId());
-            RBucket<List<Integer>> bucket = redissonClient.getBucket(sb.toString());
-            List<Integer> list = bucket.get();
-            if(CollectionUtils.isEmpty(list)){
-                list = new ArrayList<>();
-            }
-            //当前用户是否购买过免费直播课
-            if(list.contains(sysUser.getId())){
+            TempBuyFreeLiveTheoryCourse temp = tempBuyFreeLiveTheoryCourseDao.findByGoodsIdAndUserId(memberPayParamDto.getLiveGoodsId(),student.getUserId());
+            if(Objects.nonNull(temp)){
                 throw new BizException("您已领取过本轮免费直播课");
                 throw new BizException("您已领取过本轮免费直播课");
             }
             }
+//            StringBuffer sb = new StringBuffer(RedisKeyConstant.LIVE_GOODS_ZERO_CACHE_KEY).append(memberPayParamDto.getLiveGoodsId());
+//            RBucket<List<Integer>> bucket = redissonClient.getBucket(sb.toString());
+//            List<Integer> list = bucket.get();
+//            if(CollectionUtils.isEmpty(list)){
+//                list = new ArrayList<>();
+//            }
+//            //当前用户是否购买过免费直播课
+//            if(list.contains(sysUser.getId())){
+//                throw new BizException("您已领取过本轮免费直播课");
+//            }
+            //购买次数是否超过2次
+//            int count = tempBuyFreeLiveTheoryCourseDao.countByUserId(sysUser.getId());
+//            if(count >= 2){
+//                throw new BizException("免费直播课已达到领取次数上限");
+//            }
             //保存购买记录
             //保存购买记录
             tempBuyFreeLiveTheoryCourseDao.insert(
             tempBuyFreeLiveTheoryCourseDao.insert(
                     new TempBuyFreeLiveTheoryCourse(sysUser.getId(),memberPayParamDto.getLiveId(),memberPayParamDto.getLiveGoodsId()));
                     new TempBuyFreeLiveTheoryCourse(sysUser.getId(),memberPayParamDto.getLiveId(),memberPayParamDto.getLiveGoodsId()));
             //扣减库存
             //扣减库存
             liveGoodsService.reduceGoodsStock(memberPayParamDto.getLiveGoodsId(),memberPayParamDto.getLiveId());
             liveGoodsService.reduceGoodsStock(memberPayParamDto.getLiveGoodsId(),memberPayParamDto.getLiveId());
-            list.add(sysUser.getId());
-            bucket.set(list);
+//            list.add(sysUser.getId());
+//            bucket.set(list);
             return BaseController.succeed();
             return BaseController.succeed();
         }else {
         }else {
             throw new BizException("当前商品不可购买");
             throw new BizException("当前商品不可购买");
@@ -350,17 +360,27 @@ public class MemberRankSettingServiceImpl extends BaseServiceImpl<Integer, Membe
                 }
                 }
             }
             }
         } else if (memberPayParamDto.getLiveGoodsId() == 2 || memberPayParamDto.getLiveGoodsId() == 3 || memberPayParamDto.getLiveGoodsId() == 4){
         } else if (memberPayParamDto.getLiveGoodsId() == 2 || memberPayParamDto.getLiveGoodsId() == 3 || memberPayParamDto.getLiveGoodsId() == 4){
-            StringBuffer sb = new StringBuffer(RedisKeyConstant.LIVE_GOODS_ZERO_CACHE_KEY).append(memberPayParamDto.getLiveGoodsId());
-            RBucket<List<Integer>> bucket = redissonClient.getBucket(sb.toString());
-            List<Integer> list = bucket.get();
-            if(CollectionUtils.isEmpty(list)){
-                list = new ArrayList<>();
-            }
-            //当前用户是否购买过免费直播课
-            if(list.contains(sysUser.getId())){
-                succeed.setMsg("您已领取过本轮免费直播课");
-                return succeed;
+            TempBuyFreeLiveTheoryCourse temp = tempBuyFreeLiveTheoryCourseDao.findByGoodsIdAndUserId(memberPayParamDto.getLiveGoodsId(),sysUser.getId());
+            if(Objects.nonNull(temp)){
+                throw new BizException("您已领取过本轮免费直播课");
             }
             }
+//            StringBuffer sb = new StringBuffer(RedisKeyConstant.LIVE_GOODS_ZERO_CACHE_KEY).append(memberPayParamDto.getLiveGoodsId());
+//            RBucket<List<Integer>> bucket = redissonClient.getBucket(sb.toString());
+//            List<Integer> list = bucket.get();
+//            if(CollectionUtils.isEmpty(list)){
+//                list = new ArrayList<>();
+//            }
+//            //当前用户是否购买过免费直播课
+//            if(list.contains(sysUser.getId())){
+//                succeed.setMsg("您已领取过本轮免费直播课");
+//                return succeed;
+//            }
+            //购买次数是否超过2次
+//            int count = tempBuyFreeLiveTheoryCourseDao.countByUserId(sysUser.getId());
+//            if(count >= 2){
+//                succeed.setMsg("免费直播课已达到领取次数上限");
+//                return succeed;
+//            }
         }else {
         }else {
             succeed.setMsg("当前商品不可购买");
             succeed.setMsg("当前商品不可购买");
             return succeed;
             return succeed;

+ 4 - 0
mec-biz/src/main/resources/config/mybatis/TempBuyFreeLiveTheoryCourseMapper.xml

@@ -100,4 +100,8 @@
             </if>
             </if>
         </where>
         </where>
     </select>
     </select>
+    <select id="findByGoodsIdAndUserId" resultMap="TempBuyFreeLiveTheoryCourse">
+        SELECT * FROM temp_buy_free_live_theory_course
+        WHERE user_id_ = #{userId} AND live_goods_id_ = #{liveGoodsId} LIMIT 1 FOR UPDATE
+    </select>
 </mapper>
 </mapper>