109 lines
2.7 KiB
PHP
109 lines
2.7 KiB
PHP
![]() |
<?php
|
||
|
|
||
|
namespace app\channel\service\system;
|
||
|
|
||
|
/**
|
||
|
* 卡密代充服务 待开发
|
||
|
* Class Card
|
||
|
* @package app\channel\service
|
||
|
*/
|
||
|
class Card extends Core
|
||
|
{
|
||
|
# 这几个可以后台设置
|
||
|
protected $host = 'http://api.91shouka.com/';
|
||
|
protected $mid = '800262';
|
||
|
protected $token = '90B87B208ADC086D';
|
||
|
protected $method = '';
|
||
|
|
||
|
# 中石油油卡充值 拼音来吧
|
||
|
public function zsycz($param)
|
||
|
{
|
||
|
$check = array
|
||
|
(
|
||
|
'card' => 'card',
|
||
|
'cash' => 'cash',
|
||
|
);
|
||
|
$this->method = 'zsycz';
|
||
|
return $this->submit($param, $check);
|
||
|
}
|
||
|
|
||
|
# 中石化油卡充值
|
||
|
public function zshcz($param)
|
||
|
{
|
||
|
$check = array
|
||
|
(
|
||
|
'card' => 'card',
|
||
|
'cash' => 'cash',
|
||
|
);
|
||
|
$this->method = 'zshcz';
|
||
|
return $this->submit($param, $check);
|
||
|
}
|
||
|
|
||
|
# 通知处理 主要返回状态 2是成功 3是失败
|
||
|
public function notify($data)
|
||
|
{
|
||
|
$request = $data;
|
||
|
$sign = $this->_sign($request['OrderID'] . $request['MerchantOrderID'] . $request['State']);
|
||
|
if ($sign != $data['Sign']) {
|
||
|
return false;
|
||
|
}
|
||
|
$result = array();
|
||
|
$result['cash'] = 1;
|
||
|
if ($data['State'] == 1) {
|
||
|
$result['status'] = 2;
|
||
|
} elseif ($data['State'] == 2) {
|
||
|
$result['status'] = 3;
|
||
|
} else {
|
||
|
$result['status'] = 4;
|
||
|
}
|
||
|
if (isset($data['Number']) && $data['Number']) {
|
||
|
# 流水号
|
||
|
$data['s_nubmer'] = $result['s_nubmer'] = $data['Number'];
|
||
|
}
|
||
|
|
||
|
$result['data'] = $data;
|
||
|
|
||
|
$result['yes'] = 'OK';
|
||
|
|
||
|
return $result;
|
||
|
}
|
||
|
|
||
|
# 数据响应格式处理
|
||
|
public function response($data)
|
||
|
{
|
||
|
$log['type'] = 'response';
|
||
|
$log['data'] = $data;
|
||
|
$log['config'] = $this->data;
|
||
|
$this->log($log);
|
||
|
|
||
|
$array = (array) simplexml_load_string($data);
|
||
|
|
||
|
if (!$array) {
|
||
|
$msg = 'error';
|
||
|
} elseif (isset($array['resultno']) && $array['resultno'] == '000') {
|
||
|
$array['order'] = (array) $array['order'];
|
||
|
if (isset($array['order']['orderid']) && $array['order']['orderid']) {
|
||
|
# 正确
|
||
|
$msg = 'ok';
|
||
|
} else {
|
||
|
$msg = isset($array['retmsg']) ? $array['retmsg'] : 'error';
|
||
|
}
|
||
|
} else {
|
||
|
# 错误
|
||
|
$msg = isset($array['retmsg']) ? $array['retmsg'] : 'error';
|
||
|
}
|
||
|
|
||
|
return array
|
||
|
(
|
||
|
'msg' => $msg,
|
||
|
'data' => $data,
|
||
|
'array' => $array,
|
||
|
);
|
||
|
}
|
||
|
|
||
|
# 提交数据
|
||
|
private function submit($param, $check)
|
||
|
{
|
||
|
# 直接提交过去就行了
|
||
|
}
|
||
|
}
|