12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- <?php
- namespace refill\bdt;
- require_once(BASE_HELPER_RAPI_PATH . '/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,&$net_errno = 0)
- {
- $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, $net_errno);
- if (empty($resp)) {
- return [false,'系统错误',true];
- }
- else
- {
- Log::record($resp,Log::DEBUG);
- $resp = json_decode($resp,true);
- if (empty($resp)) {
- return [false, '系统错误', true];
- } elseif ($resp['code'] == 200) {
- return [true, $resp['msg'], false];
- } else {
- return [false, $resp['msg'], false];
- }
- }
- }
- public function query($refill_info)
- {
- }
- }
|