123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- <?php
- namespace refill\bjb;
- require_once(BASE_HELPER_RAPI_PATH . '/bjb/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 ,string $order_sn)
- {
- $params['usr'] = config::USR;
- $params['mob'] = $phone;
- $params['amt'] = $amount;
- $params['ord'] = $order_sn;
- $params['tim'] = date("YmdHis");
- $params['yysid'] = 0;
- $params['hmlx'] = 0;
- return $params;
- }
- public function add($card_no, $card_type,$amount,$params)
- {
- $order_sn = $params['order_sn'];
- $params = $this->req_params($card_no,$amount,$order_sn);
- $sign = $this->sign($params);
- $params['sgn'] = $sign;
- $resp = http_request(config::PAY_PHONE_URL,$params,'GET');
- if (empty($resp)) {
- return [false,'系统错误',true];
- }
- else
- {
- Log::record($resp,Log::DEBUG);
- $resp = ltrim($resp , '|');
- $resp = explode('|' , $resp);
- if (count($resp) != 3) {
- return [false, '返回值错误', false];
- } elseif ($resp[0] == 0) {
- return [true, '', false];
- } else {
- return [false, $resp[1], false];
- }
- }
- }
- public function query($refill_info)
- {
- $params['ord'] = $refill_info['order_sn'];
- $params['usr'] = config::USR;
- $content = $params['usr'] . $params['ord'] . config::KEY;
- $params['sgn'] = strtoupper(md5($content));
- $resp = http_request(config::QUERY_URL,$params);
- if (empty($resp)) {
- return [false,'系统错误'];
- }
- else
- {
- Log::record($resp,Log::DEBUG);
- $resp = ltrim($resp , '|');
- $resp = explode('|' , $resp);
- if (count($resp) != 3) {
- return [false, '返回值错误'];
- } elseif ($resp[0] == 1) {
- $order_state = ORDER_STATE_SUCCESS;
- } elseif ($resp[0] == 2) {
- $order_state = ORDER_STATE_CANCEL;
- } elseif ($resp[0] == 0) {
- $order_state = ORDER_STATE_SEND;
- } else {
- return [false, $resp[0]];
- }
- return [true, $order_state];
- }
- }
- private function sign($params)
- {
- $key = config::KEY;
- $content = $params['usr'] . $params['ord'] . $params['mob'] . $params['amt'] . $params['tim'] . $key;
- return strtoupper(md5($content));
- }
- }
|