修改,优化地址拉取
This commit is contained in:
parent
09972c7fdd
commit
9e2a2466de
|
@ -74,15 +74,16 @@ class UsdtAddrGetList extends Command
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->pay_service->payConfig('1007');
|
$this->pay_service->payConfig('1017');
|
||||||
|
|
||||||
|
|
||||||
//查找地址数据库
|
//查找地址数据库
|
||||||
$addr_list = UsdtAddr::all();
|
$addr_list = UsdtAddr::where(['is_checked'=>'1'])->get()->toArray();
|
||||||
if(count($addr_list) > 0){
|
if(count($addr_list) > 100){
|
||||||
Log::info(count($addr_list));
|
Log::info(count($addr_list));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//没有地址数据,请求接口更新数据
|
//没有地址数据,请求接口更新数据
|
||||||
$addr = $this->reqAddrList();
|
$addr = $this->reqAddrList();
|
||||||
if(empty($addr)){
|
if(empty($addr)){
|
||||||
|
@ -104,12 +105,12 @@ class UsdtAddrGetList extends Command
|
||||||
$createUrl='http://api.etwallet.net/wallet'.'/v1/api/address/batch';
|
$createUrl='http://api.etwallet.net/wallet'.'/v1/api/address/batch';
|
||||||
|
|
||||||
//商户号
|
//商户号
|
||||||
$accountId = $this->pay_service->pay_config['app_id'];
|
$accountId = $this->pay_service->pay_config['mch_id'];
|
||||||
//商户秘钥
|
//商户秘钥
|
||||||
$key = $this->pay_service->pay_config['token'];
|
$key = $this->pay_service->pay_config['token'];
|
||||||
|
|
||||||
$payData = [
|
$payData = [
|
||||||
'num' => 10000,//请求钱包地址数量
|
'num' => 100,//请求钱包地址数量
|
||||||
'nonce' => strval(mt_rand(10000,99999)),//随机数
|
'nonce' => strval(mt_rand(10000,99999)),//随机数
|
||||||
'merchantId' => $accountId, //商户id
|
'merchantId' => $accountId, //商户id
|
||||||
'timestamp' => get_total_millisecond(),// //异步回调地址
|
'timestamp' => get_total_millisecond(),// //异步回调地址
|
||||||
|
@ -119,8 +120,8 @@ class UsdtAddrGetList extends Command
|
||||||
$payData['sign'] = $sign;
|
$payData['sign'] = $sign;
|
||||||
|
|
||||||
$res = Curl::to($createUrl)->withData($payData)->post();
|
$res = Curl::to($createUrl)->withData($payData)->post();
|
||||||
// Log::info('下单接口请求内容' . json_encode($payData, 256), []);
|
//Log::info('下单接口请求内容' . json_encode($payData, 256), []);
|
||||||
// Log::info('返回内容' . json_encode($res, 256), []);
|
//Log::info('返回内容' . json_encode($res, 256), []);
|
||||||
|
|
||||||
$res = is_array($res) ? $res : json_decode($res, true);
|
$res = is_array($res) ? $res : json_decode($res, true);
|
||||||
if (is_array($res) && isset($res['code']) && $res['code'] == 0) {
|
if (is_array($res) && isset($res['code']) && $res['code'] == 0) {
|
||||||
|
@ -141,6 +142,11 @@ class UsdtAddrGetList extends Command
|
||||||
foreach ($addr as $k => $v) {
|
foreach ($addr as $k => $v) {
|
||||||
$addrModel->$k = $v;
|
$addrModel->$k = $v;
|
||||||
}
|
}
|
||||||
|
if (UsdtAddr::where('addr',$addr['addr'])->first()){
|
||||||
|
DB::rollBack();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
$r = $addrModel->save();
|
$r = $addrModel->save();
|
||||||
|
|
||||||
if ($r) {
|
if ($r) {
|
||||||
|
@ -171,8 +177,8 @@ class UsdtAddrGetList extends Command
|
||||||
$addr = $value["usdt_addr"];
|
$addr = $value["usdt_addr"];
|
||||||
if (!empty($addr)){
|
if (!empty($addr)){
|
||||||
try {
|
try {
|
||||||
Order::where("id",$value['id'])->firstOrFail()->update(['usdt_addr_status' => 1]);
|
Order::where("id",$value['id'])->update(['usdt_addr_status' => 1]);
|
||||||
UsdtAddr::where("addr",$addr)->firstOrFail()->update(['is_checked' => 1]);
|
UsdtAddr::where("addr",$addr)->update(['is_checked' => 1]);
|
||||||
}catch(Exception $exception){
|
}catch(Exception $exception){
|
||||||
Log::error('失败异常内容:' . $exception->getMessage());
|
Log::error('失败异常内容:' . $exception->getMessage());
|
||||||
}
|
}
|
||||||
|
|
|
@ -857,7 +857,7 @@ function convert_under_line($str, $ucfirst = true)
|
||||||
function get_total_millisecond()
|
function get_total_millisecond()
|
||||||
{
|
{
|
||||||
$time = explode (" ", microtime () );
|
$time = explode (" ", microtime () );
|
||||||
$time = $time [1] . ($time [0] * 1000);
|
$time = $time [1] . str_pad(($time [0] * 1000),3,"0",STR_PAD_LEFT);
|
||||||
$time2 = explode ( ".", $time );
|
$time2 = explode ( ".", $time );
|
||||||
$time = $time2 [0];
|
$time = $time2 [0];
|
||||||
return $time;
|
return $time;
|
||||||
|
|
|
@ -762,6 +762,9 @@ trait PayTrait
|
||||||
|
|
||||||
public function msg($data)
|
public function msg($data)
|
||||||
{
|
{
|
||||||
|
if(!isset($data['code'])){
|
||||||
|
$data['code'] = 0;
|
||||||
|
}
|
||||||
//临时测试一下看看是否可行
|
//临时测试一下看看是否可行
|
||||||
return response()->json($data);
|
return response()->json($data);
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ class UsdtWalletServices extends BasePay implements PayApiInterface
|
||||||
'address' => $this->order['usdt_addr'], //支付收款地址
|
'address' => $this->order['usdt_addr'], //支付收款地址
|
||||||
'nonce' => strval(mt_rand(10000,99999)),//随机数
|
'nonce' => strval(mt_rand(10000,99999)),//随机数
|
||||||
'notifyUrl' => strval($this->pay_config['notify_url']),//异步回调地址
|
'notifyUrl' => strval($this->pay_config['notify_url']),//异步回调地址
|
||||||
'timestamp' => get_total_millisecond(),// //异步回调地址
|
'timestamp' => time()*1000,//
|
||||||
];
|
];
|
||||||
|
|
||||||
$this->debugLog('请求的数据接口配置信息' . strval(json_encode($this->pay_config)), []);
|
$this->debugLog('请求的数据接口配置信息' . strval(json_encode($this->pay_config)), []);
|
||||||
|
@ -221,6 +221,10 @@ class UsdtWalletServices extends BasePay implements PayApiInterface
|
||||||
$this->debugLog('金额不正确');
|
$this->debugLog('金额不正确');
|
||||||
return '金额不正确';
|
return '金额不正确';
|
||||||
}
|
}
|
||||||
|
if($allData['toAddress'] != $this->order['usdt_addr']){
|
||||||
|
$this->debugLog('数字货币地址不正确');
|
||||||
|
return '数字货币地址不正确';
|
||||||
|
}
|
||||||
|
|
||||||
// $out_trade_no=strval($allData['id']);
|
// $out_trade_no=strval($allData['id']);
|
||||||
// $checkorder = $this->checkOrder($out_trade_no);
|
// $checkorder = $this->checkOrder($out_trade_no);
|
||||||
|
@ -391,8 +395,8 @@ class UsdtWalletServices extends BasePay implements PayApiInterface
|
||||||
|
|
||||||
private function getUstdAddr(){
|
private function getUstdAddr(){
|
||||||
DB::beginTransaction();
|
DB::beginTransaction();
|
||||||
$addr = UsdtAddr::where('is_checked',1)->orderby('updated_at','asc')->firstOrFail();
|
$addr = UsdtAddr::where('is_checked',1)->orderby('updated_at','asc')->first();
|
||||||
if (!empty($addr)){
|
if (!$addr){
|
||||||
$addr['is_checked'] = 0;
|
$addr['is_checked'] = 0;
|
||||||
$ret = $addr['addr'];
|
$ret = $addr['addr'];
|
||||||
$r = $addr->save();
|
$r = $addr->save();
|
||||||
|
|
Loading…
Reference in New Issue