135 lines
3.9 KiB
PHP
135 lines
3.9 KiB
PHP
![]() |
<?php
|
||
|
|
||
|
namespace app\channel\service\system;
|
||
|
|
||
|
/**
|
||
|
* 速汇充服务
|
||
|
* Class Tiancheng
|
||
|
* @package app\channel\service
|
||
|
*/
|
||
|
class Suhuichong extends Core
|
||
|
{
|
||
|
# 这几个可以后台设置
|
||
|
protected $host = 'http://jiayouka.5800cc.com/';
|
||
|
protected $mid = '1412984700';
|
||
|
protected $token = '1qgMhZRYhzUibWr3JqL2sV';
|
||
|
|
||
|
# 中石油油卡充值 拼音来吧
|
||
|
public function zsycz($param)
|
||
|
{
|
||
|
$check = array
|
||
|
(
|
||
|
'card' => 'cardno',
|
||
|
'cash' => 'amt',
|
||
|
'idCard' => 'idcard',
|
||
|
'realName' => 'cardusername',
|
||
|
'cardtype' => 'cardtype',
|
||
|
//'storeid' => 'storeid',
|
||
|
);
|
||
|
$param['cardtype'] = 'PetroChina';
|
||
|
//$param['storeid'] = $this->shop();
|
||
|
return $this->submit($param, $check);
|
||
|
}
|
||
|
|
||
|
# 中石化油卡充值
|
||
|
public function zshcz($param)
|
||
|
{
|
||
|
$check = array
|
||
|
(
|
||
|
'card' => 'cardno',
|
||
|
'cash' => 'amt',
|
||
|
'cardtype' => 'cardtype',
|
||
|
//'storeid' => 'storeid',
|
||
|
);
|
||
|
$param['cardtype'] = 'Sinoepc';
|
||
|
//$param['storeid'] = $this->shop();
|
||
|
return $this->submit($param, $check);
|
||
|
}
|
||
|
|
||
|
# 通知处理 主要返回状态 2是成功 3是失败
|
||
|
public function notify($data)
|
||
|
{
|
||
|
$request = $data;
|
||
|
unset($request['sign']);
|
||
|
unset($request['s_order']);
|
||
|
$sign = $this->sign($request, 'md5', '&key=' . $this->token);
|
||
|
if ($sign != $data['sign']) {
|
||
|
return false;
|
||
|
}
|
||
|
$result = array();
|
||
|
$result['cash'] = floatval($data['amt']);
|
||
|
if ($data['status'] == 2) {
|
||
|
$result['status'] = 2;
|
||
|
} else {
|
||
|
$result['status'] = 3;
|
||
|
}
|
||
|
$result['yes'] = 'SUCCESS';
|
||
|
|
||
|
if (isset($data['jdno']) && $data['jdno']) {
|
||
|
# 流水号
|
||
|
$data['s_nubmer'] = $result['s_nubmer'] = $data['jdno'];
|
||
|
} elseif (isset($data['pddno']) && $data['pddno']) {
|
||
|
# 流水号
|
||
|
$data['s_nubmer'] = $result['s_nubmer'] = $data['pddno'];
|
||
|
} elseif (isset($data['tbno']) && $data['tbno']) {
|
||
|
# 流水号
|
||
|
$data['s_nubmer'] = $result['s_nubmer'] = $data['tbno'];
|
||
|
}
|
||
|
|
||
|
$result['data'] = $data;
|
||
|
|
||
|
return $result;
|
||
|
}
|
||
|
|
||
|
# 数据响应格式处理
|
||
|
public function response($data)
|
||
|
{
|
||
|
$log['type'] = 'response';
|
||
|
$log['data'] = $data;
|
||
|
$log['config'] = $this->data;
|
||
|
$this->log($log);
|
||
|
|
||
|
$array = $this->json_decode($data);
|
||
|
if (!$array) {
|
||
|
$msg = 'error';
|
||
|
} elseif (isset($array['state']) && $array['state'] == 0 && isset($array['data']) && $array['data']) {
|
||
|
# 正确
|
||
|
$msg = 'ok';
|
||
|
} else {
|
||
|
# 错误
|
||
|
$msg = $array['msg'];
|
||
|
}
|
||
|
|
||
|
return array
|
||
|
(
|
||
|
'msg' => $msg,
|
||
|
'data' => $data,
|
||
|
'array' => $array,
|
||
|
);
|
||
|
}
|
||
|
|
||
|
# 提交数据
|
||
|
private function submit($param, $check)
|
||
|
{
|
||
|
$param = $this->param($param, $check);
|
||
|
if (is_string($param) || (is_array($param) && $param['status'] == 1)) {
|
||
|
return $param;
|
||
|
}
|
||
|
$request = $param['detail'];
|
||
|
$request['orgid'] = $this->mid;
|
||
|
$request['notifyurl'] = $this->getNotify($param['order'], 1);
|
||
|
$request['sign'] = $this->sign($request, 'md5', '&key=' . $this->token);
|
||
|
$url = $this->host . '/createKaOrder.html';
|
||
|
|
||
|
$response = $this->curl('post', $url, $request);
|
||
|
$response = $this->response($response);
|
||
|
//$response['data'] = '';
|
||
|
//$response['msg'] = 'ok';
|
||
|
$channel_order_id = '';
|
||
|
if (isset($response['array']['data'])) {
|
||
|
$channel_order_id = $response['array']['data'];
|
||
|
}
|
||
|
$this->create($param['order'], $channel_order_id, $param['merchant_order'], $param['cash'], $url, $request, $response, 1, $param['account']);
|
||
|
return $response['msg'];
|
||
|
}
|
||
|
}
|