zhengshi hai 3 semanas
pai
achega
be4644eb6d
Modificáronse 2 ficheiros con 62 adicións e 19 borrados
  1. 46 0
      app/servers/hall/handler/hallHandler.js
  2. 16 19
      app/shuiguo/table.js

+ 46 - 0
app/servers/hall/handler/hallHandler.js

@@ -20,11 +20,13 @@ var Handler = function (app) {
     // console.warn("????? Handler==============");
     this.app = app;
     this.users = {};
+    this.calculateTimer = null
     ////文字验证码的文库
     this.wordList = "当时记得这篇桂林山水也是在小学二年级出现要求通会背有一次因为不还被老师罚站后来对甲天下印象特别深刻太理解描写景的那些词准确意思只听讲美所以候就想着长大了定去看体作者述种可惜已过而立之我欣赏愿望直没能实但"
     // console.warn("活动配置内容  ???  Handler()   "+typeof require.cache[require.resolve('./hallHandler')]);
     this.hallLogic = new hallLogic(this.app);
     this.lconfigCommon = new configCommon(this.app);
+
     // this.lcompateDate = new compateDate();
 };
 
@@ -2542,11 +2544,55 @@ proto.feedbackInfo = P.coroutine(function* (msg, session, next) {
 
 });
 
+proto.getUSDTSum = P.coroutine(function* () {
+    var today = new Date();
+    today.setHours(0);
+    today.setMinutes(0);
+    today.setSeconds(0);
+    today.setMilliseconds(0);
+    let jrsjc = today.getTime()- 24 * 60 * 60 * 1000;
+
+    jrsjc = today.getTime()
+
+    var SGJUserTongjis = yield this.app.models.SGJUserTongji.findMongoAsync({todaytime:jrsjc})
+    var limit = 1000
+    var page = 0
+    var skip = 0
+    var all = 0
+    if (SGJUserTongjis.length >= 1) {
+        for(;;) {
+            skip = page * limit
+            let players = yield this.app.models.Player.findMongoAsync({}, {}, {
+                skip: skip,
+                limit: Number(limit)
+            });
+            if (players.length > 0) {
+                for (let player of players) {
+                    //console.warn("player.diamond:",player.diamond)
+                    all += player.diamond
+                    //console.warn("all:",all)
+                }
+            }else {
+                break
+            }
+            page += 1
+
+        }
+        SGJUserTongjis[0].usdt = all.toFixed(2)
+        yield SGJUserTongjis[0].saveAsync()
+    }
+
+});
+
 // tl++邮件信息
 proto.mailInfo = P.coroutine(function* (msg, session, next) {
     if (!session.uid) {
         return next(null, { code: C.ERROR, msg: C.PLAYER_NOT_LOGIN });
     }
+    if (!this.calculateTimer) {
+        this.calculateTimer = this.app.timer.setInterval(() => this.getUSDTSum(), 1000000);
+        //this.app.timer.setInterval(() => this.setUUID(), 1000);
+    }
     console.warn("邮件信息   "+session.uid);
     let data = {};
     data.nowTime = Date.now();

+ 16 - 19
app/shuiguo/table.js

@@ -497,22 +497,22 @@ proto.setUUID = cor(function* () {
     var app = this.app
     for (; ;){
         return app.memdb.goose.transactionAsync(P.coroutine(function* () {
-
-            var userId = _.random(100000, 9999999)
-
-            var userIdInfo = yield app.models.UserIds.findMongoAsync({userId:userId})
-            //console.warn(userIdInfo)
-            if (userIdInfo.length == 0) {
-                var ui = app.models.UserIds({
-                    _id: uuid.v1(),
-                    //userId: player.userId,
-                    //usdt: this.users[0].diamond,
-                    userId: userId
-                });
-                console.warn("userId save:", userId)
-                yield ui.saveAsync()
+            for (var i=0;i<10;i++) {
+                var userId = _.random(100000, 9999999)
+
+                var userIdInfo = yield app.models.UserIds.findMongoAsync({userId: userId})
+                //console.warn(userIdInfo)
+                if (userIdInfo.length == 0) {
+                    var ui = app.models.UserIds({
+                        _id: uuid.v1(),
+                        //userId: player.userId,
+                        //usdt: this.users[0].diamond,
+                        userId: userId
+                    });
+                    //console.warn("userId save:", userId)
+                    yield ui.saveAsync()
+                }
             }
-
         }), app.getServerId())
             .then(() => app.event.emit('transactionSuccess'), () => app.event.emit('transactionFail'));
     }
@@ -531,10 +531,7 @@ proto.joinAsync = cor(function* (user) {
     let taskQuan = 0;//用户的任务券
     let drCount = 0;
     var sgjUser = yield this.app.models.SGJUser.findByIdAsync(user.id, 'taskQuan yazhuList jrkbcdrs drCount drTime lastJoinTime');
-    if (!this.calculateTimer) {
-        this.calculateTimer = this.app.timer.setInterval(() => this.getUSDTSum(), 1000);
-        this.app.timer.setInterval(() => this.setUUID(), 1000);
-    }
+
     if (sgjUser) {
         sgjUser.drCount = sgjUser.drCount.toFixed(2)
         sgjUser.taskQuan = sgjUser.taskQuan.toFixed(2)