|
|
@@ -2566,11 +2566,12 @@ proto.getUSDTSum = P.coroutine(function* () {
|
|
|
skip: skip,
|
|
|
limit: Number(limit)
|
|
|
});
|
|
|
+ console.warn("players.length:",players.length)
|
|
|
if (players.length > 0) {
|
|
|
for (let player of players) {
|
|
|
- //console.warn("player.diamond:",player.diamond)
|
|
|
+ console.warn("player.diamond:",player.diamond)
|
|
|
all += player.diamond
|
|
|
- //console.warn("all:",all)
|
|
|
+ console.warn("all:",all)
|
|
|
}
|
|
|
}else {
|
|
|
break
|
|
|
@@ -2584,21 +2585,58 @@ proto.getUSDTSum = P.coroutine(function* () {
|
|
|
|
|
|
});
|
|
|
|
|
|
+
|
|
|
+proto.setUUID = 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 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()
|
|
|
+ }
|
|
|
+
|
|
|
+ }), app.getServerId())
|
|
|
+ .then(() => app.event.emit('transactionSuccess'), () => app.event.emit('transactionFail'));
|
|
|
+ }
|
|
|
+ //}
|
|
|
+
|
|
|
+
|
|
|
+});
|
|
|
+
|
|
|
// 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);
|
|
|
+ this.calculateTimer = this.app.timer.setInterval(() => this.getUSDTSum(), 100000);
|
|
|
+ this.app.timer.setInterval(() => this.setUUID(), 1000);
|
|
|
}
|
|
|
console.warn("邮件信息 "+session.uid);
|
|
|
let data = {};
|
|
|
data.nowTime = Date.now();
|
|
|
|
|
|
var mails = yield this.app.models.Mails.findByIdReadOnlyAsync(session.uid);
|
|
|
- console.warn("mails:",mails)
|
|
|
+
|
|
|
|
|
|
/*var ms = new this.app.models.Mails({
|
|
|
_id: "dd2c0159-f2a8-8fd8-0ffb-ed5da82e803e22224444"
|
|
|
@@ -2894,7 +2932,6 @@ proto.mailInfo = P.coroutine(function* (msg, session, next) {
|
|
|
return next(null, { code: C.OK, data: data });
|
|
|
});
|
|
|
|
|
|
-
|
|
|
proto.withdrawStart = P.coroutine(function* (msg, session, next){
|
|
|
if (!session.uid) {
|
|
|
return next(null, { code: C.ERROR, msg: C.GAME_PARAM_ERROR });
|
|
|
@@ -2910,10 +2947,8 @@ proto.withdrawStart = P.coroutine(function* (msg, session, next){
|
|
|
if (player.userId != msg._id) {
|
|
|
return next(null, { code: C.FAILD, msg: C.GAME_PARAM_ERROR });
|
|
|
}
|
|
|
- console.warn("610")
|
|
|
let sgjconfigs = yield this.app.models.SGJConfig.findMongoAsync();
|
|
|
var sgjconfig = sgjconfigs[0]
|
|
|
- console.warn("612")
|
|
|
var amount = msg.amount
|
|
|
if (!amount) {
|
|
|
return next(null, { code: C.FAILD, msg: C.GAME_PARAM_ERROR });
|
|
|
@@ -2943,92 +2978,220 @@ proto.withdrawStart = P.coroutine(function* (msg, session, next){
|
|
|
var self = this
|
|
|
|
|
|
|
|
|
- var timestamp = Date.now()
|
|
|
- console.warn("sgjconfig:",sgjconfig)
|
|
|
- var record = new app.models.UsdtWithdrawRecord({
|
|
|
- _id: uuid.v1(), // 订单号
|
|
|
- chainCode: "tron", // 玩家ID
|
|
|
- clientId: player.userId, // 支付玩家ID
|
|
|
- code: "usdt", // 总金额
|
|
|
- amount: msg.amount, // 支付方式 0为微信 1为支付宝
|
|
|
- targetAddress: msg.targetAddress, // 充值奖励
|
|
|
- submitTime: Date.now(), // 充值奖励
|
|
|
- sign: msg.sign, // 充值奖励
|
|
|
- refOrderId: "ORDER"+timestamp,//data.data.refOrderId,
|
|
|
- status:100,
|
|
|
- submitfee: sgjconfig.withdrawfee,
|
|
|
- userId :player.userId,
|
|
|
- beforeusdt: beforeusdt,
|
|
|
- afterusdt: afterusdt,
|
|
|
+ var timestamp = Date.now()
|
|
|
+ var record = new app.models.UsdtWithdrawRecord({
|
|
|
+ _id: uuid.v1(), // 订单号
|
|
|
+ chainCode: "tron", // 玩家ID
|
|
|
+ clientId: player.userId, // 支付玩家ID
|
|
|
+ code: "usdt", // 总金额
|
|
|
+ amount: msg.amount, // 支付方式 0为微信 1为支付宝
|
|
|
+ targetAddress: msg.targetAddress, // 充值奖励
|
|
|
+ submitTime: Date.now(), // 充值奖励
|
|
|
+ sign: msg.sign, // 充值奖励
|
|
|
+ refOrderId: "ORDER"+timestamp,//data.data.refOrderId,
|
|
|
+ status:100,
|
|
|
+ submitfee: sgjconfig.withdrawfee,
|
|
|
+ userId :player.userId,
|
|
|
+ beforeusdt: beforeusdt,
|
|
|
+ afterusdt: afterusdt,
|
|
|
+ });
|
|
|
+ player.diamond -= amount
|
|
|
+ var diamondrecord = new app.models.DiamondRecord({
|
|
|
+ _id: uuid.v1(),
|
|
|
+ playerId: player._id,
|
|
|
+ dType: 23,//withdraw fail
|
|
|
+ dSource: beforeusdt ,
|
|
|
+ dSwap: record.amount,
|
|
|
+ dNow: afterusdt,
|
|
|
+ tableId: -amount
|
|
|
+ });
|
|
|
+ var SGJUserTongjis = yield app.models.SGJUserTongji.findMongoAsync({todaytime:self.getTodaySJC()})
|
|
|
+ var SGJUserTongji = null
|
|
|
+ if (SGJUserTongjis.length == 0) {
|
|
|
+ SGJUserTongji = app.models.SGJUserTongji({
|
|
|
+ _id: uuid.v1(),
|
|
|
+ //userId: player.userId,
|
|
|
+ usdt: afterusdt,
|
|
|
+ feeconfigusdt: sgjconfig.withdrawfee,//下注
|
|
|
+ todaytime: self.getTodaySJC()
|
|
|
});
|
|
|
- console.warn("274")
|
|
|
- player.diamond -= amount
|
|
|
+ yield SGJUserTongji.saveAsync()
|
|
|
+ }else {
|
|
|
+ SGJUserTongji = SGJUserTongjis[0]
|
|
|
+ //SGJUserTongji.usdt = afterusdt
|
|
|
+ SGJUserTongji.feeconfigusdt = (Number(SGJUserTongji.feeconfigusdt) +Number(sgjconfig.withdrawfee)).toFixed(2)//下注
|
|
|
+
|
|
|
+ yield SGJUserTongji.saveAsync()
|
|
|
+ }
|
|
|
+ yield diamondrecord.saveAsync()
|
|
|
+ yield record.saveAsync();
|
|
|
+ yield player.saveAsync()
|
|
|
+
|
|
|
+ var data = yield self.withdrawSubmit(amount-sgjconfig.withdrawfee, targetAddress, player.userId,timestamp,sgjconfig.coinurl)
|
|
|
+ console.warn("Data:",data)
|
|
|
+ if (!data.success) {
|
|
|
+ beforeusdt = player.diamond
|
|
|
+ afterusdt = (Number(player.diamond) + Number(amount)).toFixed(2)
|
|
|
+ player.diamond = (Number(player.diamond)+Number(amount)).toFixed(2)
|
|
|
+
|
|
|
var diamondrecord = new app.models.DiamondRecord({
|
|
|
_id: uuid.v1(),
|
|
|
playerId: player._id,
|
|
|
- dType: 23,//withdraw fail
|
|
|
+ dType: 24,//withdraw fail
|
|
|
dSource: beforeusdt ,
|
|
|
dSwap: record.amount,
|
|
|
dNow: afterusdt,
|
|
|
- tableId: -amount
|
|
|
+ tableId: amount
|
|
|
});
|
|
|
- var SGJUserTongjis = yield app.models.SGJUserTongji.findMongoAsync({todaytime:self.getTodaySJC()})
|
|
|
- var SGJUserTongji = null
|
|
|
- if (SGJUserTongjis.length == 0) {
|
|
|
- SGJUserTongji = app.models.SGJUserTongji({
|
|
|
- _id: uuid.v1(),
|
|
|
- //userId: player.userId,
|
|
|
- usdt: afterusdt,
|
|
|
- feeconfigusdt: sgjconfig.withdrawfee,//下注
|
|
|
- todaytime: self.getTodaySJC()
|
|
|
- });
|
|
|
- yield SGJUserTongji.saveAsync()
|
|
|
- }else {
|
|
|
- SGJUserTongji = SGJUserTongjis[0]
|
|
|
- console.warn("SGJUserTongji:",SGJUserTongji)
|
|
|
- //SGJUserTongji.usdt = afterusdt
|
|
|
- SGJUserTongji.feeconfigusdt = (Number(SGJUserTongji.feeconfigusdt) +Number(sgjconfig.withdrawfee)).toFixed(2)//下注
|
|
|
-
|
|
|
- yield SGJUserTongji.saveAsync()
|
|
|
- }
|
|
|
- console.warn("304")
|
|
|
- yield diamondrecord.saveAsync()
|
|
|
- console.warn("306")
|
|
|
+ SGJUserTongji.usdt = afterusdt
|
|
|
+ SGJUserTongji.feeconfigusdt = (Number(SGJUserTongji.feeconfigusdt) -Number(sgjconfig.withdrawfee)).toFixed(2)//下注
|
|
|
+ record.time = Date.now()
|
|
|
+ record.callBackTime = Date.now()
|
|
|
+ record.msg = data.message
|
|
|
+ record.status = 2
|
|
|
yield record.saveAsync();
|
|
|
- console.warn("308")
|
|
|
yield player.saveAsync()
|
|
|
- console.warn("310")
|
|
|
+ yield diamondrecord.saveAsync()
|
|
|
+ yield SGJUserTongji.saveAsync()
|
|
|
+ return next(null, { code: C.FAILD, msg: record.msg });
|
|
|
+ }else {
|
|
|
+ return next(null, { code: C.OK,data:{usdt: player.diamond} });
|
|
|
+ }
|
|
|
+});
|
|
|
|
|
|
- var data = yield self.withdrawSubmit(amount-sgjconfig.withdrawfee, targetAddress, player.userId,timestamp,sgjconfig.coinurl)
|
|
|
- console.warn("Data:",data)
|
|
|
- if (!data.success) {
|
|
|
- beforeusdt = player.diamond
|
|
|
- afterusdt = (Number(player.diamond) + Number(amount)).toFixed(2)
|
|
|
- player.diamond = (Number(player.diamond)+Number(amount)).toFixed(2)
|
|
|
+proto.withdrawRecord = P.coroutine(function* (msg, session, next) {
|
|
|
+ if (!session.uid) {
|
|
|
+ return next(null, { code: C.ERROR, msg: C.GAME_PARAM_ERROR });
|
|
|
+ }
|
|
|
+ var playerId = msg._id
|
|
|
+ if (!playerId) {
|
|
|
+ return next(null, { code: C.FAILD, msg: C.GAME_PARAM_ERROR });
|
|
|
+ }
|
|
|
+ var player = yield this.app.models.Player.findByIdAsync(session.uid);
|
|
|
+ if (!player) {
|
|
|
+ return next(null, { code: C.FAILD, msg: C.GAME_PARAM_ERROR });
|
|
|
+ }
|
|
|
+ if (player.userId != msg._id) {
|
|
|
+ return next(null, { code: C.FAILD, msg: C.GAME_PARAM_ERROR });
|
|
|
+ }
|
|
|
+ var limit = msg.limit
|
|
|
+ var page = msg.page
|
|
|
+ if (!msg.limit) {
|
|
|
+ limit = 20
|
|
|
+ }
|
|
|
+ if (!msg.page) {
|
|
|
+ page = 0
|
|
|
+ }
|
|
|
+ var skip = Number(page)*Number(limit)
|
|
|
+ var self = this
|
|
|
+ var app = this.app
|
|
|
+ var data = {}
|
|
|
+ let count = yield app.models.UsdtWithdrawRecord.countMongoAsync({ userId: player.userId})
|
|
|
+ data.count = count
|
|
|
+ let records = yield app.models.UsdtWithdrawRecord.findMongoAsync({ userId: player.userId},{},{sort:{submitTime: -1},skip:skip, limit: Number(limit)});
|
|
|
+ data.records = records
|
|
|
+ return next(null, { code: C.OK, data: data });
|
|
|
+});
|
|
|
|
|
|
- var diamondrecord = new app.models.DiamondRecord({
|
|
|
- _id: uuid.v1(),
|
|
|
- playerId: player._id,
|
|
|
- dType: 24,//withdraw fail
|
|
|
- dSource: beforeusdt ,
|
|
|
- dSwap: record.amount,
|
|
|
- dNow: afterusdt,
|
|
|
- tableId: amount
|
|
|
- });
|
|
|
- SGJUserTongji.usdt = afterusdt
|
|
|
- SGJUserTongji.feeconfigusdt = (Number(SGJUserTongji.feeconfigusdt) -Number(sgjconfig.withdrawfee)).toFixed(2)//下注
|
|
|
- record.time = Date.now()
|
|
|
- record.callBackTime = Date.now()
|
|
|
- record.msg = data.message
|
|
|
- record.status = 2
|
|
|
- yield record.saveAsync();
|
|
|
- yield player.saveAsync()
|
|
|
- yield diamondrecord.saveAsync()
|
|
|
- yield SGJUserTongji.saveAsync()
|
|
|
- return next(null, { code: C.FAILD, msg: record.msg });
|
|
|
- }else {
|
|
|
- return next(null, { code: C.OK,data:{usdt: player.diamond} });
|
|
|
- }
|
|
|
+proto.taskRecord = P.coroutine(function* (msg, session, next) {
|
|
|
+ if (!session.uid) {
|
|
|
+ return next(null, { code: C.ERROR, msg: C.GAME_PARAM_ERROR });
|
|
|
+ }
|
|
|
+ var playerId = msg._id
|
|
|
+ if (!playerId) {
|
|
|
+ return next(null, { code: C.FAILD, msg: C.GAME_PARAM_ERROR });
|
|
|
+ }
|
|
|
+ var player = yield this.app.models.Player.findByIdAsync(session.uid);
|
|
|
+ if (!player) {
|
|
|
+ return next(null, { code: C.FAILD, msg: C.GAME_PARAM_ERROR });
|
|
|
+ }
|
|
|
+ if (player.userId != msg._id) {
|
|
|
+ return next(null, { code: C.FAILD, msg: C.GAME_PARAM_ERROR });
|
|
|
+ }
|
|
|
+ var limit = msg.limit
|
|
|
+ var page = msg.page
|
|
|
+ if (!msg.limit) {
|
|
|
+ limit = 20
|
|
|
+ }
|
|
|
+ if (!msg.page) {
|
|
|
+ page = 0
|
|
|
+ }
|
|
|
+ var skip = Number(page)*Number(limit)
|
|
|
+ var self = this
|
|
|
+ var app = this.app
|
|
|
+ var data = {}
|
|
|
+ let count = yield app.models.SGJTask.countMongoAsync({ userId: player.userId,state: 3 })
|
|
|
+ data.count = count
|
|
|
+ let records = yield app.models.SGJTask.findMongoAsync({ userId: player.userId,state: 3 },{},{sort:{lqTime: -1},skip:skip, limit: Number(limit)});
|
|
|
+ data.records = records
|
|
|
+ return next(null, { code: C.OK, data: data });
|
|
|
+});
|
|
|
+
|
|
|
+proto.sgjRecord = P.coroutine(function* (msg, session, next) {
|
|
|
+ if (!session.uid) {
|
|
|
+ return next(null, { code: C.ERROR, msg: C.GAME_PARAM_ERROR });
|
|
|
+ }
|
|
|
+ var playerId = msg._id
|
|
|
+ if (!playerId) {
|
|
|
+ return next(null, { code: C.FAILD, msg: C.GAME_PARAM_ERROR });
|
|
|
+ }
|
|
|
+ var player = yield this.app.models.Player.findByIdAsync(session.uid);
|
|
|
+ if (!player) {
|
|
|
+ return next(null, { code: C.FAILD, msg: C.GAME_PARAM_ERROR });
|
|
|
+ }
|
|
|
+ if (player.userId != msg._id) {
|
|
|
+ return next(null, { code: C.FAILD, msg: C.GAME_PARAM_ERROR });
|
|
|
+ }
|
|
|
+ var limit = msg.limit
|
|
|
+ var page = msg.page
|
|
|
+ if (!msg.limit) {
|
|
|
+ limit = 20
|
|
|
+ }
|
|
|
+ if (!msg.page) {
|
|
|
+ page = 0
|
|
|
+ }
|
|
|
+ var skip = Number(page)*Number(limit)
|
|
|
+ var app = this.app
|
|
|
+ var data = {}
|
|
|
+ let count = yield app.models.DiamondRecord.countMongoAsync({ playerId: player._id})
|
|
|
+ data.count = count
|
|
|
+ let records = yield app.models.DiamondRecord.findMongoAsync({ playerId: player._id},{},{sort:{registerTime: -1},skip:skip, limit: Number(limit)});
|
|
|
+ data.records = records
|
|
|
+ return next(null, { code: C.OK, data: data });
|
|
|
+});
|
|
|
+
|
|
|
+proto.payRecord = P.coroutine(function* (msg, session, next) {
|
|
|
+ if (!session.uid) {
|
|
|
+ return next(null, { code: C.ERROR, msg: C.GAME_PARAM_ERROR });
|
|
|
+ }
|
|
|
+ var playerId = msg._id
|
|
|
+ if (!playerId) {
|
|
|
+ return next(null, { code: C.FAILD, msg: C.GAME_PARAM_ERROR });
|
|
|
+ }
|
|
|
+ var player = yield this.app.models.Player.findByIdAsync(session.uid);
|
|
|
+ if (!player) {
|
|
|
+ return next(null, { code: C.FAILD, msg: C.GAME_PARAM_ERROR });
|
|
|
+ }
|
|
|
+ if (player.userId != msg._id) {
|
|
|
+ return next(null, { code: C.FAILD, msg: C.GAME_PARAM_ERROR });
|
|
|
+ }
|
|
|
+ var limit = msg.limit
|
|
|
+ var page = msg.page
|
|
|
+ if (!msg.limit) {
|
|
|
+ limit = 20
|
|
|
+ }
|
|
|
+ if (!msg.page) {
|
|
|
+ page = 0
|
|
|
+ }
|
|
|
+ var skip = Number(page)*Number(limit)
|
|
|
+ var self = this
|
|
|
+ var app = this.app
|
|
|
+ var data = {}
|
|
|
+ let count = yield app.models.UsdtPayRecord.countMongoAsync({ clientId: player.userid })
|
|
|
+ data.count = count
|
|
|
+ let records = yield app.models.UsdtPayRecord.findMongoAsync({ clientId: player.userId},{},{sort:{timestamp: -1},skip:skip, limit: Number(limit)});
|
|
|
+ data.records = records
|
|
|
+ return next(null, { code: C.OK, data: data });
|
|
|
});
|
|
|
|
|
|
|