Procházet zdrojové kódy

Merge remote-tracking branch 'origin/master'

why před 3 roky
rodič
revize
193e5e1c6b

+ 11 - 0
src/main/java/com/td/boss/game/complayerland/scheduled/ComPlayerDisasterDateUtil.java

@@ -6,8 +6,15 @@ import cn.hutool.core.date.Week;
 
 import java.util.Date;
 
+/**
+ * 每周是从周日到下周六
+ */
 public class ComPlayerDisasterDateUtil {
 
+    /**
+     * 获取本周开始时间
+     * @return
+     */
     public static Date getBegin() {
         Date now = new Date();
         if (Week.SUNDAY == DateUtil.dayOfWeekEnum(now)) {
@@ -17,6 +24,10 @@ public class ComPlayerDisasterDateUtil {
         }
     }
 
+    /**
+     * 获取本周截止时间
+     * @return
+     */
     public static Date getEnd() {
         Date now = new Date();
         if (Week.SUNDAY == DateUtil.dayOfWeekEnum(now)) {

+ 8 - 10
src/main/java/com/td/boss/game/complayerland/service/ComPlayerDisasterLogServiceImpl.java

@@ -16,13 +16,11 @@ import com.td.boss.game.complayerland.repository.ComPlayerDisasterLogRepository;
 import com.td.boss.game.complayerland.scheduled.ComPlayerDisasterDateUtil;
 import com.td.boss.game.complayerland.vo.ComPlayerDisasterEnum;
 import com.td.boss.game.complayerland.vo.ComPlayerDisasterLogVo;
-import com.td.boss.game.complayers.service.ComPlayersService;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.jpa.domain.Specification;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
-
 import javax.persistence.criteria.CriteriaBuilder;
 import javax.persistence.criteria.CriteriaQuery;
 import javax.persistence.criteria.Predicate;
@@ -35,10 +33,10 @@ import java.util.stream.Collectors;
 @Transactional
 public class ComPlayerDisasterLogServiceImpl extends CommonServiceImpl<ComPlayerDisasterLogVo, ComPlayerDisasterLog, String> implements ComPlayerDisasterLogService {
     @Autowired
-    private ComPlayerDisasterLogRepository comPlayerDisasterLogRepository;
+    private ComPlayerDisasterLogRepository disasterLogRepository;
 
     @Autowired
-    private ComPlayerDisasterProtectedService comPlayerDisasterProtectedService;
+    private ComPlayerDisasterProtectedService disasterProtectedService;
 
     @Autowired
     private ComPlayerDisasterService disasterService;
@@ -62,11 +60,11 @@ public class ComPlayerDisasterLogServiceImpl extends CommonServiceImpl<ComPlayer
     @Override
     public List<ComPlayerDisasterLog> getHistory(String userId) {
         //获取已发生未读的灾难集合
-        List<ComPlayerDisasterLog> list = comPlayerDisasterLogRepository.getUnShowAndEnabled(userId).stream().sorted(Comparator.comparing(ComPlayerDisasterLog::getCreateTime)).collect(Collectors.toList());
+        List<ComPlayerDisasterLog> list = disasterLogRepository.getUnShowAndEnabled(userId).stream().sorted(Comparator.comparing(ComPlayerDisasterLog::getCreateTime)).collect(Collectors.toList());
         log.info("获取灾难记录:{}", JSONUtil.toJsonStr(list));
         //设置成已读
         list.forEach(a -> a.setShow(true));
-        comPlayerDisasterLogRepository.saveAll(list);
+        disasterLogRepository.saveAll(list);
         return list;
     }
 
@@ -105,7 +103,7 @@ public class ComPlayerDisasterLogServiceImpl extends CommonServiceImpl<ComPlayer
             log.info("用户编号:{}本周发生灾难明细:{}", userId, JSONUtil.toJsonStr(disasterLogList));
 
             //灾难明细持久化
-            comPlayerDisasterLogRepository.saveAll(disasterLogList);
+            disasterLogRepository.saveAll(disasterLogList);
         }
     }
 
@@ -175,7 +173,7 @@ public class ComPlayerDisasterLogServiceImpl extends CommonServiceImpl<ComPlayer
     public void ComPlayerDisasterDayTask(ComPlayerDisasterLog disasterLog) {
         Date now = new Date();
         //查询当前人员购买防护历史记录
-        List<ComPlayerDisasterProtected> protectList = comPlayerDisasterProtectedService.getComPlayerDisasterProtectedByUserIdOrderByProtectTimeDesc(disasterLog.getUserId());
+        List<ComPlayerDisasterProtected> protectList = disasterProtectedService.getComPlayerDisasterProtectedByUserIdOrderByProtectTimeDesc(disasterLog.getUserId());
         log.info("用户编号:{},防护历史记录:{}", disasterLog.getUserId(), JSONUtil.toJsonStr(protectList));
         //获得对应灾难类型的防护记录    并得到这个 防护到期时间
         Date protectedDate = protectList.stream()
@@ -205,7 +203,7 @@ public class ComPlayerDisasterLogServiceImpl extends CommonServiceImpl<ComPlayer
         }
 
         log.info("灾难日志:{}", JSONUtil.toJsonStr(disasterLog));
-        comPlayerDisasterLogRepository.save(disasterLog);
+        disasterLogRepository.save(disasterLog);
         //todo 减产接口 减产逻辑
         if (!disasterLog.isProtect()) {
             log.info("灾难结果:减产");
@@ -233,7 +231,7 @@ public class ComPlayerDisasterLogServiceImpl extends CommonServiceImpl<ComPlayer
                 return criteriaBuilder.and(predicates.toArray(new Predicate[predicates.size()]));
             }
         };
-        return comPlayerDisasterLogRepository.findAll(specification);
+        return disasterLogRepository.findAll(specification);
     }
     //endregion
 }

+ 5 - 0
src/main/java/com/td/boss/game/complayerland/service/ComPlayerDisasterProtectedServiceImpl.java

@@ -16,6 +16,11 @@ public class ComPlayerDisasterProtectedServiceImpl extends CommonServiceImpl<Com
     @Autowired
     private ComPlayerDisasterProtectedRepository repository;
 
+    /**
+     * 按照用户编号获取 防护灾难 记录
+     * @param userId
+     * @return
+     */
     public List<ComPlayerDisasterProtected> getComPlayerDisasterProtectedByUserIdOrderByProtectTimeDesc(String userId) {
         return repository.getComPlayerDisasterProtectedsByUserId(userId);
     }