Преглед на файлове

开奖次数,0点清空

kk преди 1 месец
родител
ревизия
f844df08ff

+ 6 - 0
game-business/src/main/java/com/game/business/mapper/AppGameItemMapper.java

@@ -76,4 +76,10 @@ public interface AppGameItemMapper extends BaseMapper<AppGameItem> {
      * @return 结果
      */
     public int deleteAppGameItemByIds(Long[] ids);
+
+    /**
+     * 清空游戏选项开奖次数
+     * @return
+     */
+    public int emptyLotteryCount();
 }

+ 2 - 0
game-business/src/main/java/com/game/business/service/IAppGameItemService.java

@@ -84,4 +84,6 @@ public interface IAppGameItemService extends IService<AppGameItem> {
      * @return 结果
      */
     public int deleteAppGameItemById(Long id);
+
+    public boolean emptyLotteryCount();
 }

+ 6 - 0
game-business/src/main/java/com/game/business/service/impl/AppGameItemServiceImpl.java

@@ -119,4 +119,10 @@ public class AppGameItemServiceImpl extends ServiceImpl<AppGameItemMapper, AppGa
     public int deleteAppGameItemById(Long id) {
         return appGameItemMapper.deleteAppGameItemById(id);
     }
+
+    @Override
+    @DataSource(DataSourceType.SLAVE)
+    public boolean emptyLotteryCount() {
+        return appGameItemMapper.emptyLotteryCount() > 0;
+    }
 }

+ 19 - 0
game-business/src/main/java/com/game/business/task/AppGameItemTask.java

@@ -0,0 +1,19 @@
+package com.game.business.task;
+
+import com.game.business.service.IAppGameItemService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+
+@Component
+public class AppGameItemTask {
+
+    @Autowired
+    private IAppGameItemService appGameItemService;
+
+
+    @Scheduled(cron = "0 0 0 * * ?")
+    public void appGameItemTask(){
+        appGameItemService.emptyLotteryCount();
+    }
+}

+ 4 - 0
game-business/src/main/resources/mapper/business/AppGameItemMapper.xml

@@ -87,4 +87,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         where game_id = #{gameId} and item_location = #{itemLocation} and consecutive &lt; #{consecutive}
     </update>
 
+    <update id="emptyLotteryCount">
+        update app_game_item set lottery_count = 0 where lottery_count > 0
+    </update>
+
 </mapper>