|
@@ -0,0 +1,78 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+
|
|
|
+namespace refill\bdt;
|
|
|
+
|
|
|
+require_once(BASE_HELPER_PATH . '/refill/bdt/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['cardNo'] = $card_no;
|
|
|
+
|
|
|
+ if($card_type == mtopcard\PetroChinaCard) {
|
|
|
+ $params['payType'] = 1001;
|
|
|
+ }
|
|
|
+ elseif($card_type == mtopcard\SinopecCard) {
|
|
|
+ $params['payType'] = 1002;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ Log::record("RefillOil req_params err params",Log::DEBUG);
|
|
|
+ }
|
|
|
+
|
|
|
+ $params['amount'] = $amount;
|
|
|
+ $params['cardOwnerOrderNo'] = $other['order_sn'];
|
|
|
+ $params['notifyUrl'] = config::NOTIFY_URL;
|
|
|
+ $params['cardOwnerAccount'] = config::CardOwnerAccount;
|
|
|
+ $params['date'] = date("Y-m-d H:i:s");
|
|
|
+ $params['ip'] = config::API_IP;
|
|
|
+
|
|
|
+ return $params;
|
|
|
+ }
|
|
|
+
|
|
|
+ private function sign($params)
|
|
|
+ {
|
|
|
+ $content = '';
|
|
|
+ ksort($params);
|
|
|
+ foreach ($params as $key => $val){
|
|
|
+ $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'] == 200) {
|
|
|
+ return [true,$resp['msg']];
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ return [false,$resp['msg']];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|