phone_type($phone); $params['timeout'] = 50; $params['time'] = time(); $params['rand'] = rand(100000,999999); return $params; } public function add($card_no, $card_type, $amount, $params) { $params = $this->req_params($card_no, $amount, $params['order_sn']); $sign = $this->sign($params); $params['sign'] = $sign; Log::record("start request",Log::DEBUG); $resp = http_request(config::ORDER_URL, $params , 'POST' , false); Log::record("recv length = " . strlen($resp),Log::DEBUG); if ($resp === false) { return [false, '系统错误',true]; } else { $rand = mt_rand(0,1); return [$rand , '',false]; } } public function query($refill_info) { $params['mch_order_id'] = $refill_info['order_sn']; $params['mchid'] = config::MCHID; $content = $params['mchid'] . $params['mch_order_id'] . config::KEY; $params['sign'] = md5($content); $resp = http_request(config::QUERY_URL, $params , 'POST' , false); if ($resp === false) { return [false, '系统错误']; } else { $rand = mt_rand(0,1); // Log::record("query return rand : $resp", Log::DEBUG); return [$rand , '']; } } private function sign($params) { $key = config::KEY; $content = $params['mchid'] . $params['tel'] . $params['mch_order_id'] . $params['price'] . $params['teltype'] . $params['timeout'] . $params['notify']; $content .= $params['time'] . $params['rand'] . $key; return md5($content); } private function phone_type($phone) { $card_type = mtopcard\card_type($phone,$regin_no); if ($card_type == mtopcard\ChinaMobileCard) { return 2; } elseif ($card_type == mtopcard\ChinaUnicomCard) { return 1; } elseif ($card_type == mtopcard\ChinaTelecomCard) { return 3; } } }