|
@@ -0,0 +1,78 @@
|
|
|
+<?php
|
|
|
+namespace refill\jc;
|
|
|
+
|
|
|
+require_once(BASE_HELPER_PATH . '/refill/jc/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['phone'] = $phone;
|
|
|
+ $params['order_no'] = $order_sn;
|
|
|
+ $params['s_id'] = config::APP_ID;
|
|
|
+ $params['amount'] = $amount;
|
|
|
+ $params['notify_url'] = config::NOTIFY_URL;
|
|
|
+ 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::ORDER_URL,$params,'GET');
|
|
|
+ if($resp === false) {
|
|
|
+ return [false,'系统错误'];
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Log::record($resp,Log::DEBUG);
|
|
|
+ $resp = json_decode($resp,true);
|
|
|
+ if($resp['result'] == 'SUCCESS') {
|
|
|
+ return [true,$resp['data']];
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ return [false,$resp['msg']];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public function query($refill_info)
|
|
|
+ {
|
|
|
+ $params['orderId'] = $refill_info['order_sn'];
|
|
|
+ $params['sid'] = config::APP_ID;
|
|
|
+ $content = $params['orderId'] . $params['sid'] . config::APP_SECRET;
|
|
|
+ $params['sign'] = strtoupper(md5($content));
|
|
|
+ $resp = http_request(config::QUERY_URL,$params);
|
|
|
+ if($resp === false) {
|
|
|
+ return [false,'系统错误'];
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Log::record($resp,Log::DEBUG);
|
|
|
+ $resp = json_decode($resp , true);
|
|
|
+ if($resp['result'] == 'SUCCESS') {
|
|
|
+
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ return [false,$resp['msg']];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private function sign($params)
|
|
|
+ {
|
|
|
+ $key = config::APP_SECRET;
|
|
|
+ $content = $params['amount'] . $params['notify_url'] . $params['order_no'] . $params['phone'] . $params['s_id'] . $key;
|
|
|
+ return strtoupper(md5($content));
|
|
|
+ }
|
|
|
+}
|