1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- <?php
- namespace refill\wantong;
- require_once(BASE_HELPER_RAPI_PATH . '/wantong/config.php');
- use refill;
- use Log;
- class RefillPhone extends refill\IRefillPhone
- {
- public function __construct($cfgs)
- {
- parent::__construct($cfgs);
- }
- private function req_params(int $phone, int $amount, int $card_type, string $order_sn)
- {
- $params['uid'] = config::UID;
- $params['order_no'] = $order_sn;
- $params['order_type'] = 1;
- $params['mobile_type'] = config::operator[$card_type];
- $params['phone_number'] = $phone;
- $params['face_value'] = intval($amount * 100);
- $params['notify_url'] = config::NOTIFY_URL;
- return $params;
- }
- public function add($card_no, $card_type, $amount, $params,&$net_errno = 0)
- {
- refill\util::send_normal($params['order_sn']);
- return [true , '',false];
- }
- public function query($refill_info)
- {
- $params['uid'] = config::UID;
- $params['order_no'] = $refill_info['order_sn'];
- $content = $params['uid'] . $params['order_no'] . config::KEY;
- $params['sign'] = md5($content);
- $resp = http_request(config::QUERY_URL, $params, 'POST', false);
- if (empty($resp)) {
- return [false, '系统错误'];
- }
- else
- {
- Log::record($resp, Log::DEBUG);
- $resp = json_decode($resp, true);
- if (empty($resp)) {
- return [false, '系统错误'];
- }
- elseif ($resp['code'] == 200)
- {
- $status = $resp['data']['statusId'];
- if ($status == 4) {
- $updata['ch_trade_no'] = $resp['data']['serialNumber'];
- $updata['official_sn'] = $resp['data']['mobileOrderNo'];
- Model('refill_order')->edit($refill_info['order_id'], $updata);
- $order_state = ORDER_STATE_SUCCESS;
- } elseif (in_array($status, [0, 1, 9])) {
- $order_state = ORDER_STATE_CANCEL;
- } elseif (in_array($status, [2, 5, 6])) {
- $order_state = ORDER_STATE_SEND;
- } else {
- return [false, $resp['msg']];
- }
- return [true, $order_state];
- }
- else {
- return [false, $resp['msg']];
- }
- }
- }
- public function balance()
- {
- return [false, '暂无余额接口'];
- }
- private function sign($params)
- {
- $key = config::KEY;
- $content = $params['uid'] . $params['order_no'] . $params['phone_number'] . $params['face_value'] . $key;
- return md5($content);
- }
- }
|