1, 'CallBackUrl' => config::NOTIFY_URL, 'ChargeAccount' => $phone, 'CustomerIP' => '127.0.0.1', 'MOrderID' => $order_sn, 'ProductCode' => $sku_code, 'TimesTamp' => config::time_stamp() ]; return config::gen_params($input,config::add_keys); } //[$state, $errmsg, $neterr] public function add($card_no, $card_type, $amount, $params, &$net_errno = 0): array { $params = $this->add_params($card_no, $amount, $params['order_sn'],$card_type); if(empty($params)) { return [false, '提单参数不符合', false]; } $resp = http_request(config::ORDER_URL, $params, 'POST', false, [], $net_errno); if (empty($resp)) { return [false, '系统错误', true]; } else { Log::record($resp, Log::DEBUG); $resp = json_decode($resp, true); if (empty($resp)) { return [false, '系统错误', true]; } elseif ($resp['Code'] === 999) { /// 999 收单成功 return [true, $resp['OrderID'], false]; } else { return [false, $resp['Msg'], false]; } } } public function query($refill_info): array { $input = [ 'TimesTamp' => config::time_stamp(), 'MOrderID' =>$refill_info['order_sn'] ]; $params = config::gen_params($input,config::query_keys); $resp = http_request(config::QUERY_URL, $params , 'POST'); if (empty($resp)) { return [false, '系统错误', '']; } else { Log::record($resp, Log::DEBUG); $resp = json_decode($resp, true); if (empty($resp)) { return [false, '系统错误', '']; } $code = intval($resp['Code']); if ($code === 999) { $val = $resp['Data']; $status = intval($val['OrderState']); $official_sn = $val['ExtendParam']['OfficialOrderID'] ?? ''; //充值状态:1=订单正在处理中,2=订单成功,3=订单失败,4=订单状态异常或位置 if ($status == 2) { Model('refill_order')->edit($refill_info['order_id'], ['ch_trade_no' => $val['OrderID'],'official_sn' => $official_sn]); $order_state = ORDER_STATE_SUCCESS; } elseif ($status == 3) { Model('refill_order')->edit($refill_info['order_id'], ['ch_trade_no' => $val['OrderID']]); $order_state = ORDER_STATE_CANCEL; } else { $order_state = ORDER_STATE_SEND; } return [true, $order_state, $official_sn]; } elseif($code === 10 and (time() - $refill_info['commit_time']) >= 300) { return [true, ORDER_STATE_NOEXIST, '']; } else { return [false, $resp['Msg']]; } } } public function balance(): array { $input = [ 'TimesTamp' => config::time_stamp() ]; $params = config::gen_params($input,config::balance_keys); $resp = http_request(config::BALANCE_URL, $params , 'POST'); if (empty($resp)) { return [false, '系统错误']; } else { Log::record($resp, Log::DEBUG); $resp = json_decode($resp, true); if (empty($resp)) { return [false, '系统错误']; } elseif ($resp['Code'] === 999) { return [true, ncPriceFormat($resp['Data'][0]['Balance'])]; } else { return [false, $resp['Msg']]; } } } }