151 lines
4.0 KiB
PHP
151 lines
4.0 KiB
PHP
<?php
|
|
|
|
namespace app\channel\service\system;
|
|
|
|
/**
|
|
* 乐响服务
|
|
* Class Tiancheng
|
|
* @package app\channel\service
|
|
*/
|
|
class Lexiang extends Core
|
|
{
|
|
# 这几个可以后台设置
|
|
protected $host = 'http://119.84.53.72:7100/';
|
|
protected $mid = '1519';
|
|
protected $token = '5b8795ef5abb60b3f335e74658e7ef1e';
|
|
protected $method = '';
|
|
|
|
# 中石油油卡充值 拼音来吧
|
|
public function zsycz($param)
|
|
{
|
|
$check = array
|
|
(
|
|
'card' => 'rechargeno',
|
|
'cash' => 'amount',
|
|
//'idCard' => 'idCard',
|
|
//'realName' => 'realName',
|
|
'type' => 'type',
|
|
);
|
|
$param['type'] = 'zsy';
|
|
return $this->submit($param, $check);
|
|
}
|
|
|
|
# 中石化油卡充值
|
|
public function zshcz($param)
|
|
{
|
|
$check = array
|
|
(
|
|
'card' => 'rechargeno',
|
|
'cash' => 'amount',
|
|
'type' => 'type',
|
|
);
|
|
$param['type'] = 'zsh';
|
|
return $this->submit($param, $check);
|
|
}
|
|
|
|
# 通知处理 主要返回状态 2是成功 3是失败
|
|
public function notify($data)
|
|
{
|
|
$request = $data;
|
|
unset($request['signature']);
|
|
$request = $this->_sign($request);
|
|
if ($request['signature'] != $data['signature']) {
|
|
//return false;
|
|
}
|
|
$result = array();
|
|
$result['cash'] = 1;
|
|
if ($data['rechargestate'] == 99) {
|
|
$result['status'] = 2;
|
|
} elseif ($data['status'] == 3) {
|
|
$result['status'] = 3;
|
|
} else {
|
|
$result['status'] = 4;
|
|
}
|
|
if (isset($data['orderid']) && $data['orderid']) {
|
|
# 流水号
|
|
$data['s_nubmer'] = $result['s_nubmer'] = $data['orderid'];
|
|
}
|
|
|
|
$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['code']) && $array['code'] == '000') {
|
|
# 正确
|
|
$msg = 'ok';
|
|
} else {
|
|
# 错误
|
|
$msg = isset($array['msg']) ? $array['msg'] : 'error';
|
|
}
|
|
|
|
return array
|
|
(
|
|
'msg' => $msg,
|
|
'data' => $data,
|
|
'array' => $array,
|
|
);
|
|
}
|
|
|
|
# 查询接口
|
|
public function query($param)
|
|
{
|
|
|
|
}
|
|
|
|
# 提交数据
|
|
private function submit($param, $check)
|
|
{
|
|
$param = $this->param($param, $check);
|
|
if (is_string($param) || (is_array($param) && $param['status'] == 1)) {
|
|
return $param;
|
|
}
|
|
|
|
return $this->send($param);
|
|
}
|
|
|
|
private function send($param, $parent_order = '')
|
|
{
|
|
$request = $param['detail'];
|
|
$request['merid'] = $this->mid;
|
|
$request['orderid'] = $param['order'];
|
|
$request['ts'] = $this->timestamp();
|
|
$request['callbackurl'] = $this->getNotify($param['order'], 1);
|
|
$request['sign'] = $this->_sign($request);
|
|
$url = $this->host . 'home/recharge';
|
|
$response = $this->curl('post', $url, $request);
|
|
//print_r($response);die;
|
|
$response = $this->response($response);
|
|
//$response['data'] = '{}';
|
|
//$response['msg'] = 'ok';
|
|
$channel_order_id = '';
|
|
if (isset($response['array']['orderno'])) {
|
|
$channel_order_id = $response['array']['orderno'];
|
|
}
|
|
|
|
$this->create($param['order'], $channel_order_id, $param['merchant_order'], $param['cash'], $url, $request, $response, 1, $param['account'], $parent_order);
|
|
|
|
return $response['msg'];
|
|
}
|
|
|
|
private function _sign($request)
|
|
{
|
|
ksort($request);
|
|
$string = '';
|
|
foreach ($request as $k => $v) {
|
|
$string .= $v;
|
|
}
|
|
return md5($string . $this->token);
|
|
}
|
|
} |