|
@@ -0,0 +1,72 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+
|
|
|
+namespace refill\zzx;
|
|
|
+
|
|
|
+require_once(BASE_HELPER_PATH . '/refill/zzx/config.php');
|
|
|
+
|
|
|
+
|
|
|
+use refill;
|
|
|
+use mtopcard;
|
|
|
+use Log;
|
|
|
+
|
|
|
+class RefillOil extends refill\IRefillOil
|
|
|
+{
|
|
|
+ public function __construct($cfgs)
|
|
|
+ {
|
|
|
+ parent::__construct($cfgs);
|
|
|
+ }
|
|
|
+
|
|
|
+ private function req_params(string $card_no,int $card_type,int $amount,array $other)
|
|
|
+ {
|
|
|
+ $params['mid'] = config::MID;
|
|
|
+ $params['cardNo'] = $card_no;
|
|
|
+ $params['amount'] = $amount;
|
|
|
+ $params['orderNum'] = $other['order_sn'];
|
|
|
+ $params['backUrl'] = config::NOTIFY_URL;
|
|
|
+ return json_encode($params);
|
|
|
+ }
|
|
|
+
|
|
|
+ private function sign($params)
|
|
|
+ {
|
|
|
+ $content = '';
|
|
|
+ ksort($params);
|
|
|
+ foreach ($params as $key => $val){
|
|
|
+ if($val == '' || empty($val)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ $content .= "{$key}={$val}&";
|
|
|
+ }
|
|
|
+ $content .= "key=".config::KEY;
|
|
|
+
|
|
|
+ return strtoupper(md5($content));
|
|
|
+ }
|
|
|
+
|
|
|
+ public function add($card_no,$card_type,$amount,$input)
|
|
|
+ {
|
|
|
+ $params = $this->req_params($card_no,$card_type,$amount,$input);
|
|
|
+ $sign = $this->sign($params);
|
|
|
+ $params['sign'] = $sign;
|
|
|
+
|
|
|
+ $resp = http_request(config::ORDER_URL,$params,'POST',false, config::ExtHeaders);
|
|
|
+ if($resp === false) {
|
|
|
+ return [false,'系统错误'];
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Log::record($resp,Log::DEBUG);
|
|
|
+ $resp = json_decode($resp,true);
|
|
|
+ if($resp['code'] == 0000 && $resp['respCode'] == 1111) {
|
|
|
+ return [true,$resp['msg']];
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ return [false,$resp['msg']];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public function query($refill_info)
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+}
|