ComPlayerDisasterLogTests.java 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. package com.td.boss;
  2. import cn.hutool.core.date.DateField;
  3. import cn.hutool.core.date.DateUtil;
  4. import cn.hutool.json.JSONUtil;
  5. import com.td.boss.common.pojo.Result;
  6. import com.td.boss.game.comcnttosnb.service.ComCntToSnbService;
  7. import com.td.boss.game.complayerland.pojo.ComPlayerDisasterLog;
  8. import com.td.boss.game.complayerland.service.ComPlayerDisasterLogService;
  9. import com.td.boss.game.complayerland.service.ComPlayerDisasterProtectedService;
  10. import com.td.boss.game.complayerland.vo.ComPlayerDisasterEnum;
  11. import com.td.boss.game.complayerland.vo.ComPlayerDisasterProtectedVo;
  12. import org.junit.jupiter.api.Test;
  13. import org.junit.runner.RunWith;
  14. import org.springframework.beans.factory.annotation.Autowired;
  15. import org.springframework.boot.test.context.SpringBootTest;
  16. import org.springframework.test.context.junit4.SpringRunner;
  17. import java.util.Date;
  18. import java.util.List;
  19. @RunWith(SpringRunner.class)
  20. @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
  21. class ComPlayerDisasterLogTests {
  22. @Autowired
  23. private ComPlayerDisasterLogService comPlayerDisasterLogService;
  24. @Autowired
  25. private ComPlayerDisasterProtectedService comPlayerDisasterProtectedService;
  26. @Autowired
  27. private ComCntToSnbService comCntToSnbService;
  28. private String userId = "4";
  29. /**
  30. * 防护灾难
  31. */
  32. @Test
  33. void playerAddProtected() {
  34. comPlayerDisasterProtectedService.append(userId,ComPlayerDisasterEnum.ziran,30);
  35. comPlayerDisasterProtectedService.append(userId,ComPlayerDisasterEnum.yeshou,30);
  36. comPlayerDisasterProtectedService.append("1003",ComPlayerDisasterEnum.ziran,30);
  37. comPlayerDisasterProtectedService.append("1003",ComPlayerDisasterEnum.yeshou,30);
  38. }
  39. /**
  40. * 获取灾难经历
  41. */
  42. @Test
  43. void getHistory() {
  44. List<ComPlayerDisasterLog> history = comPlayerDisasterLogService.getHistory(userId);
  45. System.out.println(history);
  46. }
  47. /**
  48. * 测试灾难模式
  49. */
  50. @Test
  51. void ComPlayerDisasterWeekTask() {
  52. comPlayerDisasterLogService.asyncDisaster(userId);
  53. }
  54. @Test
  55. void ComPlayerDisasterDayTask() {
  56. for (ComPlayerDisasterLog disasterLog : comPlayerDisasterLogService.getTodayDisasterUnEnabledList()) {
  57. comPlayerDisasterLogService.ComPlayerDisasterDayTask(disasterLog);
  58. }
  59. }
  60. /**
  61. * 获取userid snb领取情况,如果不在特定的列表,data为null
  62. */
  63. @Test
  64. void getCntToSnb() {
  65. // 情况一,在名单中
  66. String json = JSONUtil.toJsonStr(Result.of(comCntToSnbService.findByUserId("952")));
  67. System.out.println(json);
  68. // 情况二,不在名单中
  69. String json2 = JSONUtil.toJsonStr(Result.of(comCntToSnbService.findByUserId("13")));
  70. System.out.println(json2);
  71. }
  72. /**
  73. * userid领取snb
  74. */
  75. @Test
  76. void receiveCntToSnb() {
  77. // Date begin = DateUtil.parse("2022-03-01");
  78. // Date end = DateUtil.parse("2022-03-05");
  79. //
  80. // Integer day = Convert.toInt(DateUtil.betweenDay(begin, end, true));
  81. // System.out.println(DateUtil.format(begin, "yyyy-MM-dd") + " 至 " + DateUtil.format(end, "yyyy-MM-dd") + "相差:" + day + "天");
  82. String json = JSONUtil.toJsonStr(comCntToSnbService.receiveByUserId("13"));
  83. System.out.println(json);
  84. }
  85. }