field("a.*,b.email") ->join("user b","a.user_id=b.id","left") ->where('a.tron_address', '<>', '') ->where('a.curr_id', 1) ->where('a.jtupdatetime',"<",$nowtime) ->where('a.regtime',">",time()-3600) ->limit(20) ->order('a.jtupdatetime','asc') ->select(); if(empty($user)){ echo "empty"; } $txid = Db::name('app_detailed') ->where('cart', '1') ->where('type', '1') ->select(); $txidarr = array_column($txid, 'id', 'hash'); $lowrecharge = 0.01; foreach ($user as $key => $value) { $transferdata = [ 'command' => "getTransferRecord", 'code' => "tronapi2021.1", 'address' => $value['tron_address'], 'contract' => 'TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t' //usdt ]; $result = json_decode(http_curl(Config::get('site.trx_rpc_ip'), 'post', $transferdata), true); // var_dump($result); if ($result['code'] == 1 && !empty($result['data'])) { $recharge = []; $amount = 0; $changeamount = 0; foreach ($result['data'] as $kk => $val) { if (!isset($txidarr[$val['transaction_id']]) && $val['value'] > 100) { $nums = sprintf("%.6f", $val['value'] / 1000000); //存入充值表记录 $recharge[] = [ 'user_id' => $value['user_id'], 'curr_id' => $value['curr_id'], 'price' => $nums, 'cart' => '1', 'type' => '1', 'description' => 'trc20-USDT充值', 'hash' => $val['transaction_id'], 'before_num' => $value['num'], 'after_num' => $value['num'] + $nums, 'is_outer' => '0', 'createtime' => time(), ]; $amount += $nums; $txidarr[$val['transaction_id']] = 111; $value['num'] += $nums; } } if ($amount > $lowrecharge) { Db::startTrans(); $ret = Db::name('app_detailed')->insertAll($recharge); $changeamount = $value['num']; $ret1 = Db::name('app_currency_user')->where('id', $value['id']) ->update(['num' => $changeamount, 'updatetime' => time()]); if(!$ret || !$ret1){ Db::rollback(); }else{ Db::commit(); //发送邮件 if($value['email']){ $send_data = array("num"=>$amount,"curr_name"=>"USDT"); controller("Ems")->api_send($value['email'], "chongzhi",$send_data); } } echo "id-" . $value['user_id'] . ':充值' . $changeamount . ' USDT'; } } Db::name('app_currency_user')->where('id', $value['id']) ->update([ 'jtupdatetime' => time()]); } } //波长USDT手续费派发 public function listenCreditTron() { if(Config::get('site.trx_hzswitch') == '0'){ echo "Switch close"; exit; } $zong = Config::get('site.trx_z_address'); $zongarr = Db::name('app_currency_user') ->where('tron_address', $zong)->find(); if (!$zongarr) { echo 'Not exits tron address'; } $list = Db::name('app_detailed') ->where('cart', '1') ->where('type', '1') ->where('is_outer', '0') ->where('description', 'trc20-USDT充值') ->where('user_id', '<>', $zongarr['user_id']) ->group('user_id') ->limit(10)->select(); $zongkey = controller("Common")->trc_decrypt($zongarr['tron_private_key']); $data = [ 'command' => "getBalance", 'code' => "tronapi2021.1", 'address' => $zong, ]; $ztrx = json_decode(http_curl(Config::get('site.trx_rpc_ip'), 'post', $data), true); $ztrx = $ztrx['data']; $fee = 6; if ($ztrx < $fee) { echo "banlance not enough " . $ztrx; exit; } foreach ($list as $key => $value) { $wallet = Db::name('app_currency_user') ->where('curr_id', '1') ->where('user_id', $value['user_id'])->find(); if (empty($wallet['tron_address'])) continue; //查询余额 $data = [ 'command' => "getBalance", 'code' => "tronapi2021.1", 'address' => $wallet['tron_address'], ]; $trx = json_decode(http_curl(Config::get('site.trx_rpc_ip'), 'post', $data), true); $trx = $trx['data']; $data = [ 'command' => "getBalance", 'code' => "tronapi2021.1", 'address' => $wallet['tron_address'], 'contract' => 'TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t' //usdt ]; $usdt = json_decode(http_curl(Config::get('site.trx_rpc_ip'), 'post', $data), true); $usdt = $usdt['data']; $transfer = Db::name('usdt_transfer') ->where('user_id', $value['user_id']) ->where('inaddr', $wallet['tron_address']) ->find(); if ($transfer) { $lasttime = $transfer['time'] + 600; } else { $lasttime = 0; } if ($trx < $fee && $lasttime < time() && $wallet['tron_address'] != $zong) { //转账 $data = [ 'command' => "transfer", 'code' => "tronapi2021.1", 'from' => $zong, 'to' => $wallet['tron_address_hex'], 'privateKey' => $zongkey, 'amount' => $fee, "version" => 2, // 'contract' => 'TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t' //usdt ]; $result = json_decode(http_curl(Config::get('site.trx_rpc_ip'), 'post', $data), true); if ($result['code'] != 1 || isset($result['data']['data']['txid'])) { echo "transfer error:" . json_encode($result); } else { $insertdata = [ 'user_id' => $value['user_id'], 'fee' => $fee, 'type' => 'out', 'inaddr' => $wallet['tron_address'], 'outaddr' => $zong, 'time' => time(), 'result' => json_encode($result), ]; Db::name('usdt_transfer')->insert($insertdata); } echo 'paifa -' . $value['user_id'] . '- ' . $fee . ' trx'; } Db::name('app_currency_user')->where('id', $wallet['id']) ->update(['trxnum' => $trx, 'trxusdt' => $usdt, 'listentime' => time()]); } } /** * 波长USDT归集 */ public function huizongTron() { if(Config::get('site.trx_hzswitch') == '0'){ echo "Switch close"; exit; } $zongss = Config::get('site.trx_z_address'); $zong = "TNgigBy22T9oN4w8ozSapy9vRvtLJif3Xg"; $list = Db::name('app_detailed') ->where('cart', '1') ->where('type', '1') ->where('is_outer', '0') ->where('description', 'trc20-USDT充值') ->group('user_id') ->limit(10)->select(); $zongkey = ""; $fee = 5; foreach ($list as $key => $value) { $wallet = Db::name('app_currency_user') ->where('curr_id', '1') ->where('user_id', $value['user_id'])->find(); if (empty($wallet['tron_address'])) continue; //查询余额 $data = [ 'command' => "getBalance", 'code' => "tronapi2021.1", 'address' => $wallet['tron_address'], ]; $trx = json_decode(http_curl(Config::get('site.trx_rpc_ip'), 'post', $data), true); $trx = $trx['data']; $data = [ 'command' => "getBalance", 'code' => "tronapi2021.1", 'address' => $wallet['tron_address'], 'contract' => 'TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t' //usdt ]; $usdt = json_decode(http_curl(Config::get('site.trx_rpc_ip'), 'post', $data), true); $usdt = $usdt['data']; $transfer = Db::name('usdt_transfer') ->where('user_id', $value['user_id']) ->where('outaddr', $wallet['tron_address']) ->find(); if ($transfer) { $lasttime = $transfer['time'] + 600; } else { $lasttime = 0; } if ($trx >= $fee && $usdt > 0 && $lasttime < time() && $wallet['tron_address'] != $zongss) { //转账 $data = [ 'command' => "transfer", 'code' => "tronapi2021.1", 'from' => $wallet['tron_address'], 'to' => $zong, 'privateKey' => controller("Common")->trc_decrypt($wallet['tron_private_key']), 'amount' => $usdt, "version" => 2, 'contract' => 'TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t' //usdt ]; $result = json_decode(http_curl(Config::get('site.trx_rpc_ip'), 'post', $data), true); if ($result['code'] != 1 || isset($result['data']['data']['txid'])) { echo "transfer error:" . json_encode($result); } else { $insertdata = [ 'user_id' => $value['user_id'], 'fee' => $usdt, 'type' => 'outusdt', 'inaddr' => $zong, 'outaddr' => $wallet['tron_address'], 'time' => time(), 'result' => json_encode($result), ]; Db::name('usdt_transfer')->insert($insertdata); } echo 'huizong ' . $value['user_id'] . '-' . $usdt; } else if ($usdt <= 0.01 && !empty($usdt)) { Db::name('app_detailed') ->where('cart', '1') ->where('type', '1') ->where('is_outer', '0') ->where('description', 'trc20-USDT充值') ->where('user_id', $value['user_id']) ->update(['is_outer' => '1', 'update_time' => time()]); } Db::name('app_currency_user')->where('id', $wallet['id']) ->update(['trxnum' => $trx, 'trxusdt' => $usdt, 'listentime' => time()]); } } //波长EVT充值监听 public function getMonitorTron_evt() { $nowtime = time() - 100; $user = Db::name('app_currency_user a')->field("a.*,b.email") ->join("user b","a.user_id=b.id","left") ->where('a.tron_address', '<>', '') ->where('a.curr_id', 20) ->where('a.jtupdatetime',"<",$nowtime) ->where('a.regtime',">",time()-3600) ->limit(20) ->order('a.jtupdatetime','asc') ->select(); if(empty($user)){ echo "empty"; } $txid = Db::name('app_detailed') ->where('cart', '1') ->where('type', '1') ->select(); $txidarr = array_column($txid, 'id', 'hash'); $lowrecharge = 0.01; foreach ($user as $key => $value) { $transferdata = [ 'command' => "getTransferRecord", 'code' => "tronapi2021.1", 'address' => $value['tron_address'], 'contract' => 'TXTJXcPKrYTbyEToA8ct3gBvw2GimERUAn' //EVT ]; $result = json_decode(http_curl(Config::get('site.trx_rpc_ip'), 'post', $transferdata), true); // var_dump($result); if ($result['code'] == 1 && !empty($result['data'])) { $recharge = []; $amount = 0; $changeamount = 0; foreach ($result['data'] as $kk => $val) { if (!isset($txidarr[$val['transaction_id']]) && $val['value'] > 100) { $nums = sprintf("%.6f", $val['value'] / 1000000); //存入充值表记录 $recharge[] = [ 'user_id' => $value['user_id'], 'curr_id' => $value['curr_id'], 'price' => $nums, 'cart' => '1', 'type' => '1', 'description' => 'trc20-EVT充值', 'hash' => $val['transaction_id'], 'before_num' => $value['num'], 'after_num' => $value['num'] + $nums, 'is_outer' => '0', 'createtime' => time(), ]; $amount += $nums; $txidarr[$val['transaction_id']] = 111; $value['num'] += $nums; } } if ($amount > $lowrecharge) { Db::startTrans(); $ret = Db::name('app_detailed')->insertAll($recharge); $changeamount = $value['num']; $ret1 = Db::name('app_currency_user')->where('id', $value['id']) ->update(['num' => $changeamount, 'updatetime' => time()]); if(!$ret || !$ret1){ Db::rollback(); }else{ Db::commit(); //发送邮件 if($value['email']){ $send_data = array("num"=>$amount,"curr_name"=>"EVT"); controller("Ems")->api_send($value['email'], "chongzhi",$send_data); } } echo "id-" . $value['user_id'] . ':充值' . $changeamount . ' USDT'; } } Db::name('app_currency_user')->where('id', $value['id']) ->update([ 'jtupdatetime' => time()]); } } //波长EVT充值监听 public function getMonitorTron_ift() { $nowtime = time() - 100; $user = Db::name('app_currency_user a')->field("a.*,b.email") ->join("user b","a.user_id=b.id","left") ->where('a.tron_address', '<>', '') ->where('a.curr_id', 55) ->where('a.jtupdatetime',"<",$nowtime) ->where('a.regtime',">",time()-3600) ->limit(20) ->order('a.jtupdatetime','asc') ->select(); if(empty($user)){ echo "empty"; } $txid = Db::name('app_detailed') ->where('cart', '1') ->where('type', '1') ->select(); $txidarr = array_column($txid, 'id', 'hash'); $lowrecharge = 0.01; foreach ($user as $key => $value) { $transferdata = [ 'command' => "getTransferRecord", 'code' => "tronapi2021.1", 'address' => $value['tron_address'], 'contract' => 'TNpToPDxBMH71BywJruNBRV25di8mrfZqy' //IFT ]; $result = json_decode(http_curl(Config::get('site.trx_rpc_ip'), 'post', $transferdata), true); // var_dump($result); if ($result['code'] == 1 && !empty($result['data'])) { $recharge = []; $amount = 0; $changeamount = 0; foreach ($result['data'] as $kk => $val) { if (!isset($txidarr[$val['transaction_id']]) && $val['value'] > 100) { $nums = sprintf("%.6f", $val['value'] / 1000000); //存入充值表记录 $recharge[] = [ 'user_id' => $value['user_id'], 'curr_id' => $value['curr_id'], 'price' => $nums, 'cart' => '1', 'type' => '1', 'description' => 'trc20-IFT充值', 'hash' => $val['transaction_id'], 'before_num' => $value['num'], 'after_num' => $value['num'] + $nums, 'is_outer' => '0', 'createtime' => time(), ]; $amount += $nums; $txidarr[$val['transaction_id']] = 111; $value['num'] += $nums; } } if ($amount > $lowrecharge) { Db::startTrans(); $ret = Db::name('app_detailed')->insertAll($recharge); $changeamount = $value['num']; $ret1 = Db::name('app_currency_user')->where('id', $value['id']) ->update(['num' => $changeamount, 'updatetime' => time()]); if(!$ret || !$ret1){ Db::rollback(); }else{ Db::commit(); //发送邮件 if($value['email']){ $send_data = array("num"=>$amount,"curr_name"=>"IFT"); controller("Ems")->api_send($value['email'], "chongzhi",$send_data); } } echo "id-" . $value['user_id'] . ':充值' . $changeamount . ' USDT'; } } Db::name('app_currency_user')->where('id', $value['id']) ->update([ 'jtupdatetime' => time()]); } } //以太坊USDT充值监听 public function getMonitor() { $blocks = Db::name('usdt_block')->where('id', 1)->find(); $startblock = (int)$blocks['block']; $url = "https://api-cn.etherscan.com/api?module=account&action=txlist&page=1&offset=1000&sort=desc&startblock=" . $startblock . "&address=0xdac17f958d2ee523a2206206994597c13d831ec7" . "&apikey=KV2IX5DCPHB85D865CT5VNY8Z863BYSFQP"; // var_dump($url); $alsdata = json_decode(http_curl($url), true); $blockNumber = 0; $hashexit = Db::name('app_detailed') ->where('cart', '1') ->where('type', '1') ->select(); $hashexit = array_column($hashexit, "hash", "id"); $exitsuser = Db::name('app_currency_user')->select(); $exitsuser = array_column($exitsuser, "address", "id"); $lowrecharge = 0.01; if ($alsdata['status'] == 1 && !empty($alsdata['result'])) { foreach ($alsdata['result'] as $k => $v) { if ($blockNumber == 0) { $blockNumber = $v['blockNumber']; } $newaddress = substr(str_replace('0xa9059cbb000000000000000000000000', '', $v['input']), 0, 40); $newaddress1 = "0x" . $newaddress; // $exitsuser = Db::name('users')->where('address', '0x'.$newaddress)->find(); // echo "
";var_dump($exitsuser);
if (!in_array('0x' . $newaddress, $exitsuser)) continue;
// var_dump($newaddress);exit;
$amount = '';
$amountarr = str_split(str_replace('0xa9059cbb000000000000000000000000' . $newaddress, '', $v['input']));
$flag1 = false;
foreach ($amountarr as $kk => $vv) {
if ($flag1) {
$amount .= $vv;
continue;
} else if ($vv != '0') {
$flag1 = true;
$amount .= $vv;
}
}
$amount = hexdec($amount) / (pow(10, 6));
// var_dump($amount);
if ($amount > $lowrecharge) {
usleep(rand(500000, 1000000));
// var_dump($amount);exit;
$hashexitss = Db::name('app_detailed')->where('hash', $v['hash'])->find();
if (!in_array($v['hash'], $hashexit) && empty($hashexitss)) {
$userids = array_search($newaddress1, $exitsuser);
$userdetail = Db::name('app_currency_user')->where('id', $userids)->find();
$recharge = [
'user_id' => $userdetail['user_id'],
'curr_id' => 1,
'price' => $amount,
'cart' => '1',
'type' => '1',
'description' => 'erc20-USDT充值',
'hash' => $v['hash'],
'before_num' => $userdetail['num'],
'after_num' => $userdetail['num'] + $amount,
'is_outer' => '0',
'createtime' => time(),
];
$res = Db::name('app_detailed')->insertGetId($recharge);
$changeamount = $userdetail['num'] + $amount;
Db::name('app_currency_user')->where('id', $userdetail['id'])
->update(['num' => $changeamount, 'updatetime' => time()]);
echo "id-" . $userdetail['user_id'] . ':充值' . $amount . ' USDT';
$hashexit[$res] = $v['hash'];
}
}
}
Db::name("usdt_block")->where('id', 1)->update(['block' => $blockNumber, 'updatetime' => date('Y-m-d H:i:s')]);
}
}
//以太坊USDT手续费派发
public function listenCredit()
{
if(Config::get('site.eth_hzswitch') == '0'){
echo "Switch close";
exit;
}
$zongqb = Config::get('site.eth_z_address');
$zongarr = Db::name('app_currency_user')
->where('address', $zongqb)->find();
if (!$zongarr) {
echo 'Not exits eth address';
}
$nowtime = time() - 3600;
$list = Db::name('app_detailed')
->where('cart', '1')
->where('type', '1')
->where('is_outer', '0')
->where('description', 'erc20-USDT充值')
->where('user_id', '<>', $zongarr['user_id'])
->group('user_id')
->limit(10)->select();
// echo "";var_dump($list);exit;
$zongqbmm = base64_decode($zongarr['password']);
$fee = 0.006;
$transfer = [];
$ms = 'listen-credit';
$result1 = json_decode(http_curl(Config::get('site.eth_rpc_ip'), 'post',
['command' => "getBalance", 'address' => $zongqb, "code" => "shethdata2021.1", 'contract' => '']), true);
$ethnum1 = hexdec($result1['data']['result']) / (pow(10, 18));
if ($ethnum1 < $fee) {
echo 'Not enough zqb eth--num:' . $ethnum1;
exit;
}
foreach ($list as $key => $value) {
$wallet = Db::name('app_currency_user')
->where('curr_id', '1')
->where('user_id', $value['user_id'])->find();
if (empty($wallet['address'])) continue;
$result = json_decode(http_curl(Config::get('site.eth_rpc_ip'), 'post',
['command' => "getBalance", 'address' => $wallet['address'], "code" => "shethdata2021.1"]), true);
$ethnum = hexdec($result['data']['result']) / (pow(10, 18));
$result = json_decode(http_curl(Config::get('site.eth_rpc_ip'), 'post', ['command' => "getBalance", 'address' => $wallet['address'],
"contract" => "0xdac17f958d2ee523a2206206994597c13d831ec7", "code" => "shethdata2021.1"]), true);
$usdtnum = hexdec($result['data']['result']) / (pow(10, 6));
// echo "";var_dump($value['id'],$ethnum,$usdtnum,$usdtnum);exit;
if ($ethnum < $fee && $zongqb != $wallet['address'] && $usdtnum > 0) {
//查询是否已转账过
$exitstransfer = Db::name('usdt_transfer')
->where('user_id', $value['user_id'])
->where('type', 'ethout')
->order('id', 'desc')->find();
if ($exitstransfer) {
if ($exitstransfer['time'] > $nowtime) continue;
}
// $fee = $fee - $ethnum;
$result = json_decode(http_curl(Config::get('site.eth_rpc_ip'), 'post',
['command' => "transfer", "from" => $zongqb, "to" => $wallet['address'],
"value" => '0x' . $this->bc_dechex($fee * bcpow(10, 18)), "contract" => '', "password" => $zongqbmm, "code" => "shethdata2021.1"]), true);
if (!isset($result['data']['hash_address']) || !$result['data']['hash_address']) continue;
//$result = $ethapi->transfer($zongqb,$value['address'],$fee,'',$zongqbmm);
$trandata = [
'user_id' => $value['user_id'],
'fee' => $fee,
'type' => 'ethout',
'outaddr' => $zongqb,
'inaddr' => $wallet['address'],
'time' => date('Y-m-d H:i:s'),
'result' => $result['data']['hash_address']
];
Db::name('usdt_transfer')->insert($trandata);
$transfer[] = $trandata;
// echo "";var_dump($transfer);exit;
$ms .= "user_id" . $value['user_id'] . "派发" . $fee . "eth成功——";
}
Db::name('app_currency_user')->where('user_id', $wallet['user_id'])
->update(['ethnum' => $ethnum, 'usdtnum' => $usdtnum, 'listentimes' => time()]);
// }
}
echo date('Y-m-d H:i:s');
echo $ms;
}
public function bc_dechex($decimal)
{
$result = [];
while ($decimal != 0) {
$mod = $decimal % 16;
$decimal = floor($decimal / 16);
array_push($result, dechex($mod));
}
return join(array_reverse($result));
}
//以太坊USDT归集
public function huizongusdt()
{
if(Config::get('site.eth_hzswitch') == '0'){
echo "Switch close";
exit;
}
$zongqb = "0x621DD3B4dc86d535C66E171a0f96F52c5DF33c10";
$nowtime = time() - 3600;
$list = Db::name('app_detailed')
->where('cart', '1')
->where('type', '1')
->where('is_outer', '0')
->where('description', 'erc20-USDT充值')
->group('user_id')
->limit(10)->select();
$ms = 'listen-usdt____';
$fee = 0.006;
// echo "";var_dump($list);exit;
foreach ($list as $key => $value) {
$ms = '';
$wallet = Db::name('app_currency_user')
->where('curr_id', '1')
->where('user_id', $value['user_id'])->find();
if (empty($wallet['address'])) continue;
$result = json_decode(http_curl(Config::get('site.eth_rpc_ip'), 'post',
['command' => "getBalance", 'address' => $wallet['address'], "code" => "shethdata2021.1"]), true);
$ethnum = hexdec($result['data']['result']) / (pow(10, 18));
$result = json_decode(http_curl(Config::get('site.eth_rpc_ip'), 'post', ['command' => "getBalance", 'address' => $wallet['address'],
"contract" => "0xdac17f958d2ee523a2206206994597c13d831ec7", "code" => "shethdata2021.1"]), true);
$usdtnum = hexdec($result['data']['result']) / (pow(10, 6));
if ($usdtnum > 0 && $ethnum >= $fee && $zongqb != $wallet['address']) {
$exitstransfer = Db::name('usdt_transfer')
->where('user_id', $value['user_id'])
->where('type', 'usdtin')
->order('id', 'desc')->find();
if ($exitstransfer) {
echo "abcd";
if ($exitstransfer['time'] > $nowtime) continue;
}
$fee = $usdtnum;
$numss = str_pad(strval($this->bc_dechex($fee * bcpow(10, 6))), 64, '0', STR_PAD_LEFT);
$result = http_curl(Config::get('site.eth_rpc_ip'), 'post',
['command' => "transfer", "from" => $wallet['address'], "to" => $zongqb,
"value" => $numss, "contract" => '0xdac17f958d2ee523a2206206994597c13d831ec7',
"password" => base64_decode($wallet['password']), "code" => "shethdata2021.1"]);
$resultarr = json_decode($result, true);
if (isset($resultarr['data']['hash_address']) && !empty($resultarr['data']['hash_address'])) {
$trandata = [
'user_id' => $value['user_id'],
'fee' => $fee,
'type' => 'usdtin',
'inaddr' => $zongqb,
'outaddr' => $wallet['address'],
'time' => date('Y-m-d H:i:s'),
'result' => $resultarr['data']['hash_address']
];
Db::name('usdt_transfer')->insert($trandata);
$ms .= "user_id" . $value['user_id'] . "-usdt:" . $usdtnum . "转出成功,hash:" . $resultarr['data']['hash_address'] . "——";
} else{
var_dump($result);
}
Db::name('app_currency_user')->where('user_id', $wallet['user_id'])
->update(['ethnum' => $ethnum, 'usdtnum' => $usdtnum, 'listentimes' => time()]);
}else if ($usdtnum <= 0.01) {
Db::name('app_detailed')
->where('cart', '1')
->where('type', '1')
->where('is_outer', '0')
->where('description', 'erc20-USDT充值')
->where('user_id', $value['user_id'])
->update(['is_outer' => '1', 'update_time' => time()]);
$ms .= '-'.$value['id']."_____";
}
echo date('Y-m-d H:i:s');
echo $ms;
}
}
//波长APT充值监听
public function getMonitorTron_apt()
{
$nowtime = time() - 100;
$user = Db::name('app_currency_user a')->field("a.*,b.email")
->join("user b","a.user_id=b.id","left")
->where('a.tron_address', '<>', '')
->where('a.curr_id', 2)
->where('a.jtupdatetime',"<",$nowtime)
->where('a.regtime',">",time()-3600)
->limit(20)
->order('a.jtupdatetime','asc')
->select();
if(empty($user)){
echo "empty";exit;
}
$txid = Db::name('app_detailed')
->where('cart', '1')
->where('type', '1')
->select();
$txidarr = array_column($txid, 'id', 'hash');
$lowrecharge = 0.01;
foreach ($user as $key => $value) {
$transferdata = [
'command' => "getTransferRecord",
'code' => "tronapi2021.1",
'address' => $value['tron_address'],
'contract' => 'TCsUiQVkHv5HjRug7R9UEausTg1kitMGBD' //usdt
];
$result = json_decode(http_curl(Config::get('site.trx_rpc_ip'), 'post', $transferdata), true);
// var_dump($result);
if ($result['code'] == 1 && !empty($result['data'])) {
$recharge = [];
$amount = 0;
$changeamount = 0;
foreach ($result['data'] as $kk => $val) {
if (!isset($txidarr[$val['transaction_id']]) && $val['value'] > 100) {
$nums = sprintf("%.6f", $val['value'] / 1000000);
//存入充值表记录
$recharge[] = [
'user_id' => $value['user_id'],
'curr_id' => $value['curr_id'],
'price' => $nums,
'cart' => '1',
'type' => '1',
'description' => 'trc20-APT',
'hash' => $val['transaction_id'],
'before_num' => $value['num_dj'],
'after_num' => $value['num_dj'] + $nums,
'is_outer' => '0',
'createtime' => time(),
];
$amount += $nums;
$txidarr[$val['transaction_id']] = 111;
$value['num_dj'] += $nums;
}
}
if ($amount > $lowrecharge) {
Db::startTrans();
$ret = Db::name('app_detailed')->insertAll($recharge);
$changeamount = $value['num_dj'];
$ret1 = Db::name('app_currency_user')->where('id', $value['id'])
->update(['num_dj' => $changeamount, 'updatetime' => time()]);
if(!$ret || !$ret1){
Db::rollback();
}else{
Db::commit();
//发送邮件
if($value['email']){
$send_data = array("num"=>$amount,"curr_name"=>"APT");
controller("Ems")->api_send($value['email'], "chongzhi",$send_data);
}
}
echo "id-" . $value['user_id'] . ':充值' . $changeamount . ' APT';
}
}
Db::name('app_currency_user')->where('id', $value['id'])
->update([ 'jtupdatetime' => time()]);
}
}
//波长APT手续费派发
public function listenCreditTron_apt()
{
if(Config::get('site.trx_hzswitch') == '0'){
echo "Switch close";
exit;
}
$zong = Config::get('site.trx_z_address');
$zongarr = Db::name('app_currency_user')
->where('tron_address', $zong)->find();
if (!$zongarr) {
echo 'Not exits tron address';
}
$list = Db::name('app_detailed')
->where('cart', '1')
->where('type', '1')
->where('is_outer', '0')
->where('description', 'trc20-APT')
->where('user_id', '<>', $zongarr['user_id'])
->where('price', '>=',100)
->group('user_id')
->limit(10)->select();
$zongkey = controller("Common")->trc_decrypt($zongarr['tron_private_key']);
$data = [
'command' => "getBalance",
'code' => "tronapi2021.1",
'address' => $zong,
];
$ztrx = json_decode(http_curl(Config::get('site.trx_rpc_ip'), 'post', $data), true);
$ztrx = $ztrx['data'];
$fee = 6;
if ($ztrx < $fee) {
echo "banlance not enough " . $ztrx;
exit;
}
foreach ($list as $key => $value) {
$wallet = Db::name('app_currency_user')
->where('curr_id', '2')
->where('user_id', $value['user_id'])->find();
if (empty($wallet['tron_address'])) continue;
//查询余额
$data = [
'command' => "getBalance",
'code' => "tronapi2021.1",
'address' => $wallet['tron_address'],
];
$trx = json_decode(http_curl(Config::get('site.trx_rpc_ip'), 'post', $data), true);
$trx = $trx['data'];
$data = [
'command' => "getBalance",
'code' => "tronapi2021.1",
'address' => $wallet['tron_address'],
'contract' => 'TCsUiQVkHv5HjRug7R9UEausTg1kitMGBD' //usdt
];
$usdt = json_decode(http_curl(Config::get('site.trx_rpc_ip'), 'post', $data), true);
$usdt = $usdt['data'];
$transfer = Db::name('usdt_transfer')
->where('user_id', $value['user_id'])
->where('inaddr', $wallet['tron_address'])
->find();
if ($transfer) {
$lasttime = $transfer['time'] + 600;
} else {
$lasttime = 0;
}
if ($trx < $fee && $lasttime < time()) {
//转账
$data = [
'command' => "transfer",
'code' => "tronapi2021.1",
'from' => $zong,
'to' => $wallet['tron_address_hex'],
'privateKey' => $zongkey,
'amount' => $fee,
"version" => 2,
// 'contract' => 'TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t' //usdt
];
$result = json_decode(http_curl(Config::get('site.trx_rpc_ip'), 'post', $data), true);
if ($result['code'] != 1 || isset($result['data']['data']['txid'])) {
echo "transfer error:" . json_encode($result);
} else {
$insertdata = [
'user_id' => $value['user_id'],
'fee' => $fee,
'type' => 'out',
'inaddr' => $wallet['tron_address'],
'outaddr' => $zong,
'time' => time(),
'result' => json_encode($result),
];
Db::name('usdt_transfer')->insert($insertdata);
}
echo 'paifa -' . $value['user_id'] . '- ' . $fee . ' trx';
}
Db::name('app_currency_user')->where('id', $wallet['id'])
->update(['trxnum' => $trx, 'trxusdt' => $usdt, 'listentime' => time()]);
}
}
/**
* 波长APT归集
*/
public function huizongTron_apt()
{
if(Config::get('site.trx_hzswitch') == '0'){
echo "Switch close";
exit;
}
$zong = "TNgigBy22T9oN4w8ozSapy9vRvtLJif3Xg";
$list = Db::name('app_detailed')
->where('cart', '1')
->where('type', '1')
->where('is_outer', '0')
->where('description', 'trc20-APT')
->where('price', '>=',100)
->group('user_id')
->limit(10)->select();
if(empty($list)){
echo "empty";exit;
}
$zongkey = "";
$fee = 5;
foreach ($list as $key => $value) {
$wallet = Db::name('app_currency_user')
->where('curr_id', '2')
->where('user_id', $value['user_id'])->find();
if (empty($wallet['tron_address'])) continue;
//查询余额
$data = [
'command' => "getBalance",
'code' => "tronapi2021.1",
'address' => $wallet['tron_address'],
];
$trx = json_decode(http_curl(Config::get('site.trx_rpc_ip'), 'post', $data), true);
$trx = $trx['data'];
$data = [
'command' => "getBalance",
'code' => "tronapi2021.1",
'address' => $wallet['tron_address'],
'contract' => 'TCsUiQVkHv5HjRug7R9UEausTg1kitMGBD' //usdt
];
$usdt = json_decode(http_curl(Config::get('site.trx_rpc_ip'), 'post', $data), true);
$usdt = $usdt['data'];
$transfer = Db::name('usdt_transfer')
->where('user_id', $value['user_id'])
->where('outaddr', $wallet['tron_address'])
->find();
if ($transfer) {
$lasttime = $transfer['time'] + 600;
} else {
$lasttime = 0;
}
if ($trx >= $fee && $usdt > 0 && $lasttime < time()) {
//转账
$data = [
'command' => "transfer",
'code' => "tronapi2021.1",
'from' => $wallet['tron_address'],
'to' => $zong,
'privateKey' => controller("Common")->trc_decrypt($wallet['tron_private_key']),
'amount' => $usdt,
"version" => 2,
'contract' => 'TCsUiQVkHv5HjRug7R9UEausTg1kitMGBD' //usdt
];
$result = json_decode(http_curl(Config::get('site.trx_rpc_ip'), 'post', $data), true);
if ($result['code'] != 1 || isset($result['data']['data']['txid'])) {
echo "transfer error:" . json_encode($result);
} else {
$insertdata = [
'user_id' => $value['user_id'],
'fee' => $usdt,
'type' => 'outusdt',
'inaddr' => $zong,
'outaddr' => $wallet['tron_address'],
'time' => time(),
'result' => json_encode($result),
];
Db::name('usdt_transfer')->insert($insertdata);
}
echo 'huizong ' . $value['user_id'] . '-' . $usdt;
} else if ($usdt <= 0.01 && !empty($usdt)) {
Db::name('app_detailed')
->where('cart', '1')
->where('type', '1')
->where('is_outer', '0')
->where('description', 'trc20-APT')
->where('user_id', $value['user_id'])
->update(['is_outer' => '1', 'update_time' => time()]);
}
Db::name('app_currency_user')->where('id', $wallet['id'])
->update(['trxnum' => $trx, 'trxusdt' => $usdt, 'listentime' => time()]);
}
}
//波长EVT手续费派发
public function listenCreditTron_evt()
{
if(Config::get('site.trx_hzswitch') == '0'){
echo "Switch close";
exit;
}
$zong = Config::get('site.trx_z_address');
$zongarr = Db::name('app_currency_user')
->where('tron_address', $zong)->find();
if (!$zongarr) {
echo 'Not exits tron address';
}
echo $zongarr['user_id'];
$list = Db::name('app_detailed')
->where('cart', '1')
->where('type', '1')
->where('is_outer', '0')
->where('description', 'trc20-EVT充值')
->where('user_id', '<>', $zongarr['user_id'])
->where('price', '>=',100)
->group('user_id')
->limit(10)->select();
$zongkey = controller("Common")->trc_decrypt($zongarr['tron_private_key']);
$data = [
'command' => "getBalance",
'code' => "tronapi2021.1",
'address' => $zong,
];
$ztrx = json_decode(http_curl(Config::get('site.trx_rpc_ip'), 'post', $data), true);
$ztrx = $ztrx['data'];
$fee = 6;
if ($ztrx < $fee) {
echo "banlance not enough " . $ztrx;
exit;
}
foreach ($list as $key => $value) {
$wallet = Db::name('app_currency_user')
->where('curr_id', '20')
->where('user_id', $value['user_id'])->find();
if (empty($wallet['tron_address'])) continue;
//查询余额
$data = [
'command' => "getBalance",
'code' => "tronapi2021.1",
'address' => $wallet['tron_address'],
];
$trx = json_decode(http_curl(Config::get('site.trx_rpc_ip'), 'post', $data), true);
$trx = $trx['data'];
$data = [
'command' => "getBalance",
'code' => "tronapi2021.1",
'address' => $wallet['tron_address'],
'contract' => 'TXTJXcPKrYTbyEToA8ct3gBvw2GimERUAn' //evt
];
$usdt = json_decode(http_curl(Config::get('site.trx_rpc_ip'), 'post', $data), true);
$usdt = $usdt['data'];
$transfer = Db::name('usdt_transfer')
->where('user_id', $value['user_id'])
->where('inaddr', $wallet['tron_address'])
->find();
if ($transfer) {
$lasttime = $transfer['time'] + 600;
} else {
$lasttime = 0;
}
if ($trx < $fee && $lasttime < time()) {
if(empty($wallet['tron_address_hex'])){
$wallet['tron_address_hex'] = Db::name('app_currency_user')->where('curr_id', '2')->where('user_id', $value['user_id'])->value("tron_address_hex");
}
//转账
$data = [
'command' => "transfer",
'code' => "tronapi2021.1",
'from' => $zong,
'to' => $wallet['tron_address_hex'],
'privateKey' => $zongkey,
'amount' => $fee,
"version" => 2,
// 'contract' => 'TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t' //usdt
];
$result = json_decode(http_curl(Config::get('site.trx_rpc_ip'), 'post', $data), true);
if ($result['code'] != 1 || isset($result['data']['data']['txid'])) {
echo "transfer error:" . json_encode($result);
} else {
$insertdata = [
'user_id' => $value['user_id'],
'fee' => $fee,
'type' => 'out',
'inaddr' => $wallet['tron_address'],
'outaddr' => $zong,
'time' => time(),
'result' => json_encode($result),
];
Db::name('usdt_transfer')->insert($insertdata);
}
echo 'paifa -' . $value['user_id'] . '- ' . $fee . ' trx';
}
Db::name('app_currency_user')->where('id', $wallet['id'])
->update(['trxnum' => $trx, 'trxusdt' => $usdt, 'listentime' => time()]);
}
}
//波长IFT手续费派发
public function listenCreditTron_ift()
{
if(Config::get('site.trx_hzswitch') == '0'){
echo "Switch close";
exit;
}
$zong = Config::get('site.trx_z_address');
$zongarr = Db::name('app_currency_user')
->where('tron_address', $zong)->find();
if (!$zongarr) {
echo 'Not exits tron address';
}
echo $zongarr['user_id'];
$list = Db::name('app_detailed')
->where('cart', '1')
->where('type', '1')
->where('is_outer', '0')
->where('description', 'trc20-IFT充值')
->where('user_id', '<>', $zongarr['user_id'])
->where('price', '>=',100)
->group('user_id')
->limit(10)->select();
$zongkey = controller("Common")->trc_decrypt($zongarr['tron_private_key']);
$data = [
'command' => "getBalance",
'code' => "tronapi2021.1",
'address' => $zong,
];
$ztrx = json_decode(http_curl(Config::get('site.trx_rpc_ip'), 'post', $data), true);
$ztrx = $ztrx['data'];
$fee = 6;
if ($ztrx < $fee) {
echo "banlance not enough " . $ztrx;
exit;
}
foreach ($list as $key => $value) {
$wallet = Db::name('app_currency_user')
->where('curr_id', '55')
->where('user_id', $value['user_id'])->find();
if (empty($wallet['tron_address'])) continue;
//查询余额
$data = [
'command' => "getBalance",
'code' => "tronapi2021.1",
'address' => $wallet['tron_address'],
];
$trx = json_decode(http_curl(Config::get('site.trx_rpc_ip'), 'post', $data), true);
$trx = $trx['data'];
$data = [
'command' => "getBalance",
'code' => "tronapi2021.1",
'address' => $wallet['tron_address'],
'contract' => 'TNpToPDxBMH71BywJruNBRV25di8mrfZqy' //IFT
];
$usdt = json_decode(http_curl(Config::get('site.trx_rpc_ip'), 'post', $data), true);
$usdt = $usdt['data'];
$transfer = Db::name('usdt_transfer')
->where('user_id', $value['user_id'])
->where('inaddr', $wallet['tron_address'])
->find();
if ($transfer) {
$lasttime = $transfer['time'] + 600;
} else {
$lasttime = 0;
}
if ($trx < $fee && $lasttime < time()) {
if(empty($wallet['tron_address_hex'])){
$wallet['tron_address_hex'] = Db::name('app_currency_user')->where('curr_id', '2')->where('user_id', $value['user_id'])->value("tron_address_hex");
}
//转账
$data = [
'command' => "transfer",
'code' => "tronapi2021.1",
'from' => $zong,
'to' => $wallet['tron_address_hex'],
'privateKey' => $zongkey,
'amount' => $fee,
"version" => 2,
// 'contract' => 'TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t' //usdt
];
$result = json_decode(http_curl(Config::get('site.trx_rpc_ip'), 'post', $data), true);
if ($result['code'] != 1 || isset($result['data']['data']['txid'])) {
echo "transfer error:" . json_encode($result);
} else {
$insertdata = [
'user_id' => $value['user_id'],
'fee' => $fee,
'type' => 'out',
'inaddr' => $wallet['tron_address'],
'outaddr' => $zong,
'time' => time(),
'result' => json_encode($result),
];
Db::name('usdt_transfer')->insert($insertdata);
}
echo 'paifa -' . $value['user_id'] . '- ' . $fee . ' trx';
}
Db::name('app_currency_user')->where('id', $wallet['id'])
->update(['trxnum' => $trx, 'trxusdt' => $usdt, 'listentime' => time()]);
}
}
/**
* 波长EVT归集
*/
public function huizongTron_evt()
{
if(Config::get('site.trx_hzswitch') == '0'){
echo "Switch close";
exit;
}
$zong = "TNgigBy22T9oN4w8ozSapy9vRvtLJif3Xg";
$list = Db::name('app_detailed')
->where('cart', '1')
->where('type', '1')
->where('is_outer', '0')
->where('description', 'trc20-EVT充值')
->where('price', '>=',100)
->group('user_id')
->limit(10)->select();
if(empty($list)){
echo "empty";exit;
}
$zongkey = "";
$fee = 5;
foreach ($list as $key => $value) {
$wallet = Db::name('app_currency_user')
->where('curr_id', '20')
->where('user_id', $value['user_id'])->find();
if (empty($wallet['tron_address'])) continue;
//查询余额
$data = [
'command' => "getBalance",
'code' => "tronapi2021.1",
'address' => $wallet['tron_address'],
];
$trx = json_decode(http_curl(Config::get('site.trx_rpc_ip'), 'post', $data), true);
$trx = $trx['data'];
$data = [
'command' => "getBalance",
'code' => "tronapi2021.1",
'address' => $wallet['tron_address'],
'contract' => 'TXTJXcPKrYTbyEToA8ct3gBvw2GimERUAn' //evt
];
$usdt = json_decode(http_curl(Config::get('site.trx_rpc_ip'), 'post', $data), true);
$usdt = $usdt['data'];
$transfer = Db::name('usdt_transfer')
->where('user_id', $value['user_id'])
->where('outaddr', $wallet['tron_address'])
->find();
if ($transfer) {
$lasttime = $transfer['time'] + 600;
} else {
$lasttime = 0;
}
if ($trx >= $fee && $usdt > 0 && $lasttime < time()) {
$apt_wallet = Db::name("app_currency_user")->where("user_id",$value['user_id'])->where("curr_id",2)->find();
//转账
$data = [
'command' => "transfer",
'code' => "tronapi2021.1",
'from' => $wallet['tron_address'],
'to' => $zong,
'privateKey' => controller("Common")->trc_decrypt($apt_wallet['tron_private_key']),
'amount' => $usdt,
"version" => 2,
'contract' => 'TXTJXcPKrYTbyEToA8ct3gBvw2GimERUAn' //usdt
];
$result = json_decode(http_curl(Config::get('site.trx_rpc_ip'), 'post', $data), true);
if ($result['code'] != 1 || isset($result['data']['data']['txid'])) {
echo "transfer error:" . json_encode($result);
} else {
$insertdata = [
'user_id' => $value['user_id'],
'fee' => $usdt,
'type' => 'outusdt',
'inaddr' => $zong,
'outaddr' => $wallet['tron_address'],
'time' => time(),
'result' => json_encode($result),
];
Db::name('usdt_transfer')->insert($insertdata);
}
echo 'huizong ' . $value['user_id'] . '-' . $usdt;
} else if ($usdt <= 0.01 && !empty($usdt)) {
Db::name('app_detailed')
->where('cart', '1')
->where('type', '1')
->where('is_outer', '0')
->where('description', 'trc20-EVT充值')
->where('user_id', $value['user_id'])
->update(['is_outer' => '1', 'update_time' => time()]);
}
Db::name('app_currency_user')->where('id', $wallet['id'])
->update(['trxnum' => $trx, 'trxusdt' => $usdt, 'listentime' => time()]);
}
}
/**
* 波长EVT归集
*/
public function huizongTron_ift()
{
if(Config::get('site.trx_hzswitch') == '0'){
echo "Switch close";
exit;
}
$zong = "TNgigBy22T9oN4w8ozSapy9vRvtLJif3Xg";
$list = Db::name('app_detailed')
->where('cart', '1')
->where('type', '1')
->where('is_outer', '0')
->where('description', 'trc20-IFT充值')
->where('price', '>=',100)
->group('user_id')
->limit(10)->select();
if(empty($list)){
echo "empty";exit;
}
$zongkey = "";
$fee = 5;
foreach ($list as $key => $value) {
$wallet = Db::name('app_currency_user')
->where('curr_id', '55')
->where('user_id', $value['user_id'])->find();
if (empty($wallet['tron_address'])) continue;
//查询余额
$data = [
'command' => "getBalance",
'code' => "tronapi2021.1",
'address' => $wallet['tron_address'],
];
$trx = json_decode(http_curl(Config::get('site.trx_rpc_ip'), 'post', $data), true);
$trx = $trx['data'];
$data = [
'command' => "getBalance",
'code' => "tronapi2021.1",
'address' => $wallet['tron_address'],
'contract' => 'TNpToPDxBMH71BywJruNBRV25di8mrfZqy' //IFT
];
$usdt = json_decode(http_curl(Config::get('site.trx_rpc_ip'), 'post', $data), true);
$usdt = $usdt['data'];
$transfer = Db::name('usdt_transfer')
->where('user_id', $value['user_id'])
->where('outaddr', $wallet['tron_address'])
->find();
if ($transfer) {
$lasttime = $transfer['time'] + 600;
} else {
$lasttime = 0;
}
if ($trx >= $fee && $usdt > 0 && $lasttime < time()) {
$apt_wallet = Db::name("app_currency_user")->where("user_id",$value['user_id'])->where("curr_id",2)->find();
//转账
$data = [
'command' => "transfer",
'code' => "tronapi2021.1",
'from' => $wallet['tron_address'],
'to' => $zong,
'privateKey' => controller("Common")->trc_decrypt($apt_wallet['tron_private_key']),
'amount' => $usdt,
"version" => 2,
'contract' => 'TNpToPDxBMH71BywJruNBRV25di8mrfZqy' //IFT
];
$result = json_decode(http_curl(Config::get('site.trx_rpc_ip'), 'post', $data), true);
if ($result['code'] != 1 || isset($result['data']['data']['txid'])) {
echo "transfer error:" . json_encode($result);
} else {
$insertdata = [
'user_id' => $value['user_id'],
'fee' => $usdt,
'type' => 'outusdt',
'inaddr' => $zong,
'outaddr' => $wallet['tron_address'],
'time' => time(),
'result' => json_encode($result),
];
Db::name('usdt_transfer')->insert($insertdata);
}
echo 'huizong ' . $value['user_id'] . '-' . $usdt;
} else if ($usdt <= 0.01 && !empty($usdt)) {
Db::name('app_detailed')
->where('cart', '1')
->where('type', '1')
->where('is_outer', '0')
->where('description', 'trc20-IFT充值')
->where('user_id', $value['user_id'])
->update(['is_outer' => '1', 'update_time' => time()]);
}
Db::name('app_currency_user')->where('id', $wallet['id'])
->update(['trxnum' => $trx, 'trxusdt' => $usdt, 'listentime' => time()]);
}
}
//自动审核提现
public function autotx()
{
$limitnum = Config::get('site.widthdrawnum');
$data = Db::name('app_widthdraw')->where('status','2')
->whereIn('curr_id',['usdt-trc20','usdt-erc20'])
->where('num','<',$limitnum)->limit(2)->select();
if(Config::get('site.autodwswitch') != '1'){
echo 'Auto widthdraw close';exit;
}
foreach ($limitnum as $key=>$row){
$user = Db::name('app_currency_user')
->where('user_id', $row['user_id'])
->where('curr_id', '1')
->find();
if ($row['curr_id'] == 'usdt-erc20') {
$zongqb = Config::get('site.eth_z_address');
$zongarr = Db::name('app_currency_user')
->where('address', $zongqb)->find();
if (!$zongarr) {
echo '总钱包不存在';continue;
}
$zongqbmm = Config::get('site.zeth_pass');
$result = json_decode(http_curl(Config::get('site.eth_rpc_ip'), 'post',
['command' => "getBalance", 'address' => $zongqb, "code" => "shethdata2021.1"]), true);
$ethnum = hexdec($result['data']['result']) / (pow(10, 18));
$result = json_decode(http_curl(Config::get('site.eth_rpc_ip'), 'post',
['command' => "getBalance", 'address' => $zongqb,
"contract" => "0xdac17f958d2ee523a2206206994597c13d831ec7", "code" => "shethdata2021.1"]), true);
$usdtnum = hexdec($result['data']['result']) / (pow(10, 6));
if ($ethnum < 0.01 || $usdtnum < $row['real_num']) {
echo '总钱包余额不足,ETH:' . $ethnum . '-USDT:' . $usdtnum;
continue;
}
$numss = str_pad(strval($this->bc_dechex($row['real_num'] * bcpow(10, 6))), 64, '0', STR_PAD_LEFT);
$result = http_curl(Config::get('site.eth_rpc_ip'), 'post',
['command' => "transfer", "from" => $zongqb, "to" => $row['address'],
"value" => $numss, "contract" => '0xdac17f958d2ee523a2206206994597c13d831ec7',
"password" => $zongqbmm, "code" => "shethdata2021.1"]);
$resultarr = json_decode($result, true);
if (!isset($resultarr['data']['hash_address']) || empty($resultarr['data']['hash_address'])) {
echo "transfer error:" . $result;
continue;
}
$result = Db::name('app_widthdraw')
->where('id', $row['id'])->update(['status' => '1', 'hash' => $resultarr['data']['hash_address']
, 'exam_time' => time(),'description' => '系统审核成功']);
} else if ($row['curr_id'] == 'usdt-trc20') {
$zong = Config::get('site.trx_z_address');
$zongarr = Db::name('app_currency_user')
->where('tron_address', $zong)->find();
if (!$zongarr) {
echo '总钱包不存在';continue;
}
$zongkey = controller("Common")->trc_decrypt($zongarr['tron_private_key']);
$data = [
'command' => "getBalance",
'code' => "tronapi2021.1",
'address' => $zong,
];
$ztrx = json_decode(http_curl(Config::get('site.trx_rpc_ip'), 'post', $data), true);
$ztrx = $ztrx['data'];
$data = [
'command' => "getBalance",
'code' => "tronapi2021.1",
'address' => $zong,
'contract' => 'TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t' //usdt
];
$usdt = json_decode(http_curl(Config::get('site.trx_rpc_ip'), 'post', $data), true);
$usdt = $usdt['data'];
if ($ztrx < 2 || $usdt < $row['real_num']) {
echo '总钱包余额不足,TRX:' . $ztrx . '-USDT:' . $usdt;
continue;
}
//转账
$data = [
'command' => "transfer",
'code' => "tronapi2021.1",
'from' => $zong,
'to' => $row['address'],
'privateKey' => $zongkey,
'amount' => $row['real_num'],
'contract' => 'TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t' //usdt
];
$result = json_decode(http_curl(Config::get('site.trx_rpc_ip'), 'post', $data), true);
if ($result['code'] != 1 || !isset($result['data']['txid'])) {
echo "transfer error:" . json_encode($result);continue;
}
$result = Db::name('app_widthdraw')
->where('id', $row['id'])->update(['status' => '1', 'hash' => $result['data']['txid']
, 'exam_time' => time(),'description' => '系统审核成功']);
} else {
$this->error(__('系统繁忙'));
}
}
}
}