|
@@ -6,6 +6,7 @@ require_once(BASE_HELPER_RAPI_PATH . '/zanzan/config.php');
|
|
|
|
|
|
use refill;
|
|
|
use Log;
|
|
|
+use mtopcard;
|
|
|
|
|
|
class RefillPhone extends refill\IRefillPhone
|
|
|
{
|
|
@@ -14,7 +15,7 @@ class RefillPhone extends refill\IRefillPhone
|
|
|
parent::__construct($cfgs);
|
|
|
}
|
|
|
|
|
|
- private function req_params(int $phone, int $amount, string $order_sn)
|
|
|
+ private function req_params(int $phone,int $card_type,int $amount, string $order_sn)
|
|
|
{
|
|
|
$params['userid'] = config::USER_ID;
|
|
|
$params['orderid'] = $order_sn;
|
|
@@ -24,18 +25,34 @@ class RefillPhone extends refill\IRefillPhone
|
|
|
$params['packcode'] = $amount;
|
|
|
$params['mobile'] = $phone;
|
|
|
$params['flowtype'] = '1001';
|
|
|
+ $params['channelcode'] = $this->getCode($card_type);
|
|
|
$params['callback_url'] = config::NOTIFY_URL;
|
|
|
return $params;
|
|
|
}
|
|
|
|
|
|
+ private function getCode($card_type)
|
|
|
+ {
|
|
|
+ if($card_type == mtopcard\ChinaMobileCard) {
|
|
|
+ return 'cmcc';
|
|
|
+ }
|
|
|
+ elseif($card_type == mtopcard\ChinaUnicomCard) {
|
|
|
+ return 'cucc';
|
|
|
+ }
|
|
|
+ elseif($card_type == mtopcard\ChinaTelecomCard) {
|
|
|
+ return 'ctcc';
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ return '';
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public function add($card_no, $card_type, $amount, $params)
|
|
|
{
|
|
|
- $params = $this->req_params($card_no, $amount, $params['order_sn']);
|
|
|
+ $params = $this->req_params($card_no, $card_type, $amount, $params['order_sn']);
|
|
|
$sign = $this->sign($params);
|
|
|
$params['chargeSign'] = $sign;
|
|
|
|
|
|
$params = json_encode($params);
|
|
|
-
|
|
|
$resp = http_post_data(config::ORDER_URL, $params , config::ExtHeaders);
|
|
|
|
|
|
if (empty($resp)) {
|
|
@@ -73,6 +90,8 @@ class RefillPhone extends refill\IRefillPhone
|
|
|
{
|
|
|
Log::record($resp, Log::DEBUG);
|
|
|
$resp = json_decode($resp, true);
|
|
|
+ $desc = urldecode($resp['desc']);
|
|
|
+
|
|
|
if (empty($resp)) {
|
|
|
return [false, '系统错误'];
|
|
|
} elseif ($resp['code'] === '0000') {
|
|
@@ -82,8 +101,9 @@ class RefillPhone extends refill\IRefillPhone
|
|
|
} elseif ($resp['code'] === '0002' || $resp['code'] === '0003') {
|
|
|
$order_state = ORDER_STATE_SEND;
|
|
|
} else {
|
|
|
- return [false, $resp['desc']];
|
|
|
+ return [false, $desc];
|
|
|
}
|
|
|
+
|
|
|
return [true, $order_state];
|
|
|
}
|
|
|
}
|