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