|
@@ -40,7 +40,7 @@ var proto = Controller.prototype;
|
|
|
// 路由函数
|
|
// 路由函数
|
|
|
proto.route = function (pathname) {
|
|
proto.route = function (pathname) {
|
|
|
switch (pathname) {
|
|
switch (pathname) {
|
|
|
- case '/withdrawstart.nd': return (query, method, res) => this.withdrawstart(query, method, res);//充值开始
|
|
|
|
|
|
|
+ case '/withdrawstart.nd': return (query, method, res) => this.withdrawstartAsync(query, method, res);//充值开始
|
|
|
case '/clear.nd': return (query, method, res) => this.clearAsync(query, method, res);//充值开始
|
|
case '/clear.nd': return (query, method, res) => this.clearAsync(query, method, res);//充值开始
|
|
|
case '/taskRecord.nd': return (query, method, res) => this.taskRecordAsync(query, method, res);//充值开始
|
|
case '/taskRecord.nd': return (query, method, res) => this.taskRecordAsync(query, method, res);//充值开始
|
|
|
case '/withdrawrecord.nd': return (query, method, res) => this.withdrawRecordAsync(query, method, res);//充值开始
|
|
case '/withdrawrecord.nd': return (query, method, res) => this.withdrawRecordAsync(query, method, res);//充值开始
|
|
@@ -593,6 +593,7 @@ proto.withdrawstartAsync = P.coroutine(function* (query, method, res){
|
|
|
var response = {}
|
|
var response = {}
|
|
|
response.code = "0"
|
|
response.code = "0"
|
|
|
response.message = ""
|
|
response.message = ""
|
|
|
|
|
+ response.usdt = 0
|
|
|
var userid = query["clientId"]
|
|
var userid = query["clientId"]
|
|
|
if (!userid) {
|
|
if (!userid) {
|
|
|
console.warn("userid:",userid)
|
|
console.warn("userid:",userid)
|
|
@@ -620,7 +621,7 @@ proto.withdrawstartAsync = P.coroutine(function* (query, method, res){
|
|
|
}
|
|
}
|
|
|
if (amount < sgjconfig.withdrawlowlimit) {
|
|
if (amount < sgjconfig.withdrawlowlimit) {
|
|
|
response.code = "1"
|
|
response.code = "1"
|
|
|
- response.message = "withdraw must bigger than 10"
|
|
|
|
|
|
|
+ response.message = "withdraw must bigger than " + sgjconfig.withdrawlowlimit
|
|
|
return this.writeOut(response, res);
|
|
return this.writeOut(response, res);
|
|
|
}
|
|
}
|
|
|
var player = players[0]
|
|
var player = players[0]
|
|
@@ -647,11 +648,13 @@ proto.withdrawstartAsync = P.coroutine(function* (query, method, res){
|
|
|
// return this.writeOut(data, res);
|
|
// return this.writeOut(data, res);
|
|
|
//}
|
|
//}
|
|
|
var beforeusdt = player.diamond
|
|
var beforeusdt = player.diamond
|
|
|
- var afterusdt = player.diamond - amount-sgjconfig.withdrawfee
|
|
|
|
|
|
|
+ var afterusdt = player.diamond - amount
|
|
|
var app = this.app
|
|
var app = this.app
|
|
|
var self = this
|
|
var self = this
|
|
|
|
|
|
|
|
return app.memdb.goose.transactionAsync(P.coroutine(function* () {
|
|
return app.memdb.goose.transactionAsync(P.coroutine(function* () {
|
|
|
|
|
+ var timestamp = Date.now()
|
|
|
|
|
+ console.warn("sgjconfig:",sgjconfig)
|
|
|
var record = new app.models.UsdtWithdrawRecord({
|
|
var record = new app.models.UsdtWithdrawRecord({
|
|
|
_id: uuid.v1(), // 订单号
|
|
_id: uuid.v1(), // 订单号
|
|
|
chainCode: "tron", // 玩家ID
|
|
chainCode: "tron", // 玩家ID
|
|
@@ -661,20 +664,20 @@ proto.withdrawstartAsync = P.coroutine(function* (query, method, res){
|
|
|
targetAddress: query["targetAddress"], // 充值奖励
|
|
targetAddress: query["targetAddress"], // 充值奖励
|
|
|
submitTime: Date.now(), // 充值奖励
|
|
submitTime: Date.now(), // 充值奖励
|
|
|
sign: query["sign"], // 充值奖励
|
|
sign: query["sign"], // 充值奖励
|
|
|
- refOrderId: "ORDER"+Date.now(),//data.data.refOrderId,
|
|
|
|
|
|
|
+ refOrderId: "ORDER"+timestamp,//data.data.refOrderId,
|
|
|
status:100,
|
|
status:100,
|
|
|
- withdrawfee: sgjconfig.withdrawfee,
|
|
|
|
|
|
|
+ submitfee: sgjconfig.withdrawfee,
|
|
|
userId :userid,
|
|
userId :userid,
|
|
|
beforeusdt: beforeusdt,
|
|
beforeusdt: beforeusdt,
|
|
|
afterusdt: afterusdt,
|
|
afterusdt: afterusdt,
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
player.diamond -= amount
|
|
player.diamond -= amount
|
|
|
-
|
|
|
|
|
|
|
+ response.usdt = player.diamond
|
|
|
var diamondrecord = new app.models.DiamondRecord({
|
|
var diamondrecord = new app.models.DiamondRecord({
|
|
|
_id: uuid.v1(),
|
|
_id: uuid.v1(),
|
|
|
playerId: player._id,
|
|
playerId: player._id,
|
|
|
- dType: 21,//withdraw fail
|
|
|
|
|
|
|
+ dType: 23,//withdraw fail
|
|
|
dSource: beforeusdt ,
|
|
dSource: beforeusdt ,
|
|
|
dSwap: record.amount,
|
|
dSwap: record.amount,
|
|
|
dNow: afterusdt,
|
|
dNow: afterusdt,
|
|
@@ -702,16 +705,16 @@ proto.withdrawstartAsync = P.coroutine(function* (query, method, res){
|
|
|
yield diamondrecord.saveAsync()
|
|
yield diamondrecord.saveAsync()
|
|
|
yield player.saveAsync()
|
|
yield player.saveAsync()
|
|
|
yield record.saveAsync();
|
|
yield record.saveAsync();
|
|
|
- var data = yield self.withdrawSubmit(amount-sgjconfig.withdrawfee, targetAddress, userid)
|
|
|
|
|
|
|
+ var data = yield self.withdrawSubmit(amount-sgjconfig.withdrawfee, targetAddress, userid,timestamp)
|
|
|
if (!data.success) {
|
|
if (!data.success) {
|
|
|
beforeusdt = player.diamond
|
|
beforeusdt = player.diamond
|
|
|
afterusdt = (Number(player.diamond) + Number(amount)).toFixed(2)
|
|
afterusdt = (Number(player.diamond) + Number(amount)).toFixed(2)
|
|
|
player.diamond = (Number(player.diamond)+Number(amount)).toFixed(2)
|
|
player.diamond = (Number(player.diamond)+Number(amount)).toFixed(2)
|
|
|
-
|
|
|
|
|
|
|
+ response.usdt = player.diamond
|
|
|
var diamondrecord = new app.models.DiamondRecord({
|
|
var diamondrecord = new app.models.DiamondRecord({
|
|
|
_id: uuid.v1(),
|
|
_id: uuid.v1(),
|
|
|
playerId: player._id,
|
|
playerId: player._id,
|
|
|
- dType: 21,//withdraw fail
|
|
|
|
|
|
|
+ dType: 24,//withdraw fail
|
|
|
dSource: beforeusdt ,
|
|
dSource: beforeusdt ,
|
|
|
dSwap: record.amount,
|
|
dSwap: record.amount,
|
|
|
dNow: afterusdt,
|
|
dNow: afterusdt,
|
|
@@ -719,14 +722,17 @@ proto.withdrawstartAsync = P.coroutine(function* (query, method, res){
|
|
|
});
|
|
});
|
|
|
SGJUserTongji.usdt = afterusdt
|
|
SGJUserTongji.usdt = afterusdt
|
|
|
SGJUserTongji.feeconfigusdt = (Number(SGJUserTongji.feeconfigusdt) -Number(sgjconfig.withdrawfee)).toFixed(2)//下注
|
|
SGJUserTongji.feeconfigusdt = (Number(SGJUserTongji.feeconfigusdt) -Number(sgjconfig.withdrawfee)).toFixed(2)//下注
|
|
|
-
|
|
|
|
|
|
|
+ record.time = Date.now()
|
|
|
|
|
+ record.callBackTime = Date.now()
|
|
|
record.msg = data.data.message
|
|
record.msg = data.data.message
|
|
|
record.status = 2
|
|
record.status = 2
|
|
|
yield record.saveAsync();
|
|
yield record.saveAsync();
|
|
|
yield player.saveAsync()
|
|
yield player.saveAsync()
|
|
|
yield diamondrecord.saveAsync()
|
|
yield diamondrecord.saveAsync()
|
|
|
yield SGJUserTongji.saveAsync()
|
|
yield SGJUserTongji.saveAsync()
|
|
|
- return self.writeOut(data, res);
|
|
|
|
|
|
|
+ response.code = "1"
|
|
|
|
|
+ response.message = record.msg
|
|
|
|
|
+ return self.writeOut(response, res);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return self.writeOut(response, res);
|
|
return self.writeOut(response, res);
|
|
@@ -913,10 +919,10 @@ proto.clearAsync = P.coroutine(function* (query, method, res){
|
|
|
|
|
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
-proto.withdrawSubmit = P.coroutine(function* (amount, targetAddress, userid) {
|
|
|
|
|
|
|
+proto.withdrawSubmit = P.coroutine(function* (amount, targetAddress, userid,timestamp) {
|
|
|
// https://bar-coinpay.ala456.com/api/withdraw/submit?additionalAudit=false&amount=0.01&chainCode=tron&refOrderId=ORDER20260228001&targetAddress=TD92sxkgUHHadcoSiHY6Bus5fA9rsAYAKZ×tamp=1772270280000&tokenCode=usdt&userId=123&sign=bfb1d7bf14f5217cac9204b929ca4334
|
|
// https://bar-coinpay.ala456.com/api/withdraw/submit?additionalAudit=false&amount=0.01&chainCode=tron&refOrderId=ORDER20260228001&targetAddress=TD92sxkgUHHadcoSiHY6Bus5fA9rsAYAKZ×tamp=1772270280000&tokenCode=usdt&userId=123&sign=bfb1d7bf14f5217cac9204b929ca4334
|
|
|
|
|
|
|
|
- var timestamp = Date.now()
|
|
|
|
|
|
|
+
|
|
|
var suffix = "additionalAudit=false&amount="+amount+"&chainCode=tron&refOrderId=ORDER"+timestamp+"&targetAddress="+targetAddress+"×tamp="+timestamp+"&tokenCode=usdt&userId="+userid
|
|
var suffix = "additionalAudit=false&amount="+amount+"&chainCode=tron&refOrderId=ORDER"+timestamp+"&targetAddress="+targetAddress+"×tamp="+timestamp+"&tokenCode=usdt&userId="+userid
|
|
|
console.warn("suffix:",suffix)
|
|
console.warn("suffix:",suffix)
|
|
|
var md5str = suffix+"&key=GV8J4nkBNFurtnR288ch2B6300FAy8gu"
|
|
var md5str = suffix+"&key=GV8J4nkBNFurtnR288ch2B6300FAy8gu"
|
|
@@ -1174,8 +1180,9 @@ proto.chargeUsdt = P.coroutine(function* (playerid,amount) {
|
|
|
});
|
|
});
|
|
|
proto.returnUsdt = P.coroutine(function* (playerid,userid,amount) {
|
|
proto.returnUsdt = P.coroutine(function* (playerid,userid,amount) {
|
|
|
this.lconfigCommon = new configCommon(this.app);
|
|
this.lconfigCommon = new configCommon(this.app);
|
|
|
- yield this.lconfigCommon.senMailToPlayer(playerid,userid,15,15,1,1,amount,"sgjSys");
|
|
|
|
|
|
|
+ yield this.lconfigCommon.senMailToPlayer(playerid,userid,23,23,1,1,amount,"sgjSys");
|
|
|
});
|
|
});
|
|
|
|
|
+
|
|
|
proto.withdrawOkAsync = P.coroutine(function* (query, method, res) {
|
|
proto.withdrawOkAsync = P.coroutine(function* (query, method, res) {
|
|
|
//{"hash":"eaf94f7eff192ff4eb49338bc2c5dd286034cf40b73df81dd4990d8ff3dea0bb","refOrderId":"ORDER20240228001","amount":0.01,"status":0,"message":"\u6210\u529F","fees":0,"feesU":0.123322,"timestamp":1772271039176,"sign":"968121dcd20682ab9dc296296b6aca46"}
|
|
//{"hash":"eaf94f7eff192ff4eb49338bc2c5dd286034cf40b73df81dd4990d8ff3dea0bb","refOrderId":"ORDER20240228001","amount":0.01,"status":0,"message":"\u6210\u529F","fees":0,"feesU":0.123322,"timestamp":1772271039176,"sign":"968121dcd20682ab9dc296296b6aca46"}
|
|
|
// delete require.cache[require.resolve('./conf.json')];
|
|
// delete require.cache[require.resolve('./conf.json')];
|
|
@@ -1194,7 +1201,7 @@ proto.withdrawOkAsync = P.coroutine(function* (query, method, res) {
|
|
|
response.message = "验证签名错误"
|
|
response.message = "验证签名错误"
|
|
|
return this.writeOut(response, res);
|
|
return this.writeOut(response, res);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+ console.warn("query:",query)
|
|
|
var self = this;
|
|
var self = this;
|
|
|
var app = this.app;
|
|
var app = this.app;
|
|
|
return app.memdb.goose.transactionAsync(P.coroutine(function* () {
|
|
return app.memdb.goose.transactionAsync(P.coroutine(function* () {
|
|
@@ -1202,19 +1209,22 @@ proto.withdrawOkAsync = P.coroutine(function* (query, method, res) {
|
|
|
let records = yield app.models.UsdtWithdrawRecord.findMongoAsync({ refOrderId: refOrderId });
|
|
let records = yield app.models.UsdtWithdrawRecord.findMongoAsync({ refOrderId: refOrderId });
|
|
|
if (records.length > 0) {
|
|
if (records.length > 0) {
|
|
|
var record = records[0]
|
|
var record = records[0]
|
|
|
- if (record.amount != am) {
|
|
|
|
|
|
|
+ if ((record.amount-record.submifee).toFixed(2) != am.toFixed(2) ) {
|
|
|
response.code = "1"
|
|
response.code = "1"
|
|
|
response.message = "金额不匹配"
|
|
response.message = "金额不匹配"
|
|
|
|
|
+ console.warn("1208")
|
|
|
return self.writeOut(response, res);
|
|
return self.writeOut(response, res);
|
|
|
}
|
|
}
|
|
|
if (record.status == status){
|
|
if (record.status == status){
|
|
|
- response.code = "1"
|
|
|
|
|
|
|
+ response.code = +"1"
|
|
|
response.message = "状态重复"
|
|
response.message = "状态重复"
|
|
|
|
|
+ console.warn("1214")
|
|
|
return self.writeOut(response, res);
|
|
return self.writeOut(response, res);
|
|
|
}
|
|
}
|
|
|
if (record.status != 100){
|
|
if (record.status != 100){
|
|
|
response.code = "1"
|
|
response.code = "1"
|
|
|
response.message = "status already dealed"
|
|
response.message = "status already dealed"
|
|
|
|
|
+ console.warn("1220")
|
|
|
return self.writeOut(response, res);
|
|
return self.writeOut(response, res);
|
|
|
}
|
|
}
|
|
|
record.status = status
|
|
record.status = status
|
|
@@ -1222,6 +1232,7 @@ proto.withdrawOkAsync = P.coroutine(function* (query, method, res) {
|
|
|
record.fees = fees
|
|
record.fees = fees
|
|
|
record.feesU = feesU
|
|
record.feesU = feesU
|
|
|
record.callBackTime = timestamp
|
|
record.callBackTime = timestamp
|
|
|
|
|
+ record.time = timestamp
|
|
|
var player = null
|
|
var player = null
|
|
|
var players = yield app.models.Player.findMongoAsync({ userId: Number(record.userId) });
|
|
var players = yield app.models.Player.findMongoAsync({ userId: Number(record.userId) });
|
|
|
if (record.status != 0) {
|
|
if (record.status != 0) {
|
|
@@ -1234,8 +1245,8 @@ proto.withdrawOkAsync = P.coroutine(function* (query, method, res) {
|
|
|
//only withdraw fail can return money
|
|
//only withdraw fail can return money
|
|
|
var diamondrecord = new app.models.DiamondRecord({
|
|
var diamondrecord = new app.models.DiamondRecord({
|
|
|
_id: uuid.v1(),
|
|
_id: uuid.v1(),
|
|
|
- playerId: player.userId,
|
|
|
|
|
- dType: 21,//withdraw fail
|
|
|
|
|
|
|
+ playerId: player._id,
|
|
|
|
|
+ dType: 24,//withdraw fail
|
|
|
dSource: record.resultbeforeusdt ,
|
|
dSource: record.resultbeforeusdt ,
|
|
|
dSwap: record.amount,
|
|
dSwap: record.amount,
|
|
|
dNow: record.resultafterusdt,
|
|
dNow: record.resultafterusdt,
|
|
@@ -1251,11 +1262,30 @@ proto.withdrawOkAsync = P.coroutine(function* (query, method, res) {
|
|
|
player.cost += am
|
|
player.cost += am
|
|
|
yield player.saveAsync();
|
|
yield player.saveAsync();
|
|
|
}
|
|
}
|
|
|
|
|
+ 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: player.diamond,
|
|
|
|
|
+ withdrawusdt: am,//下注
|
|
|
|
|
+ todaytime: self.getTodaySJC()
|
|
|
|
|
+ });
|
|
|
|
|
+ yield SGJUserTongji.saveAsync()
|
|
|
|
|
+ }else {
|
|
|
|
|
+ SGJUserTongji = SGJUserTongjis[0]
|
|
|
|
|
+ console.warn("SGJUserTongji:",SGJUserTongji)
|
|
|
|
|
+ //SGJUserTongji.usdt = player.diamond,
|
|
|
|
|
+ SGJUserTongji.withdrawusdt = (Number(SGJUserTongji.withdrawusdt) +Number(am)).toFixed(2)//下注
|
|
|
|
|
+
|
|
|
|
|
+ yield SGJUserTongji.saveAsync()
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
yield record.saveAsync();
|
|
yield record.saveAsync();
|
|
|
|
|
|
|
|
if (record.status!==0 && player !== null) {
|
|
if (record.status!==0 && player !== null) {
|
|
|
- self.returnUsdt(player._id,player.userId,record.amount)
|
|
|
|
|
|
|
+ //self.returnUsdt(player._id,player.userId,record.amount)
|
|
|
}
|
|
}
|
|
|
return self.writeOut(response, res);
|
|
return self.writeOut(response, res);
|
|
|
}
|
|
}
|
|
@@ -1368,7 +1398,7 @@ proto.payUsdtAsync = P.coroutine(function* (query,res)
|
|
|
console.warn("958:",958)
|
|
console.warn("958:",958)
|
|
|
yield player.saveAsync();
|
|
yield player.saveAsync();
|
|
|
|
|
|
|
|
- var SGJUserTongjis = yield app.models.SGJUserTongji.findMongoAsync({todaytime:this.getTodaySJC()})
|
|
|
|
|
|
|
+ var SGJUserTongjis = yield app.models.SGJUserTongji.findMongoAsync({todaytime:self.getTodaySJC()})
|
|
|
var SGJUserTongji = null
|
|
var SGJUserTongji = null
|
|
|
if (SGJUserTongjis.length == 0) {
|
|
if (SGJUserTongjis.length == 0) {
|
|
|
SGJUserTongji = app.models.SGJUserTongji({
|
|
SGJUserTongji = app.models.SGJUserTongji({
|