150 lines
3.9 KiB
PHP
150 lines
3.9 KiB
PHP
<?php
|
|
|
|
namespace app\channel\service\system;
|
|
|
|
/**
|
|
* 天诚亿发服务新版本-天际通
|
|
* Class Tianjitong
|
|
* @package app\channel\service
|
|
*/
|
|
class Liangmei extends Core
|
|
{
|
|
# 这几个可以后台设置
|
|
protected $host = 'http://api.70kc.com/';
|
|
protected $mid = '7514657800';
|
|
protected $token = '4n4zIGxBSpPYNLNaklC8NQ';
|
|
|
|
# 中石油油卡充值 拼音来吧
|
|
public function zsycz($param)
|
|
{
|
|
$check = array
|
|
(
|
|
'card' => 'attach',
|
|
'cash' => 'cash',
|
|
);
|
|
return $this->submit($param, $check);
|
|
}
|
|
|
|
# 中石化油卡充值
|
|
public function zshcz($param)
|
|
{
|
|
$check = array
|
|
(
|
|
'card' => 'attach',
|
|
'cash' => 'cash',
|
|
);
|
|
return $this->submit($param, $check);
|
|
}
|
|
|
|
# 通知处理 主要返回状态 2是成功 3是失败
|
|
public function notify($data)
|
|
{
|
|
$request = $data;
|
|
unset($request['sign']);
|
|
unset($request['s_order']);
|
|
unset($request['voucher']);
|
|
$sign = $this->sign($request, 'md5', '&key=' . $this->token);
|
|
if ($sign != $data['sign']) {
|
|
return false;
|
|
}
|
|
$result = array();
|
|
$result['cash'] = 1;
|
|
if ($data['status'] == 3) {
|
|
$result['status'] = 2;
|
|
} elseif ($data['status'] == 4) {
|
|
$result['status'] = 3;
|
|
} else {
|
|
$result['status'] = 4;
|
|
}
|
|
if (isset($data['voucher']) && $data['voucher']) {
|
|
# 流水号
|
|
$data['s_number'] = $result['s_number'] = $data['voucher'];
|
|
}
|
|
$result['yes'] = 'ok';
|
|
|
|
$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'] == '8888') {
|
|
# 正确
|
|
$msg = 'ok';
|
|
} else {
|
|
# 错误
|
|
$msg = $array['msg'];
|
|
}
|
|
|
|
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;
|
|
}
|
|
$request['user'] = $this->mid;
|
|
$request['code'] = '102';
|
|
$request['order'] = $param['order'];
|
|
$request['spid'] = $this->getCode($param['cash']);
|
|
if (!$request['spid']) {
|
|
return 'order';
|
|
}
|
|
$request['attach'] = $param['detail']['attach'];
|
|
$request['notifyUrl'] = $this->getNotify($param['order'], 1);
|
|
$url = $this->host . 'api/index';
|
|
|
|
$request['sign'] = $this->sign($request, 'md5', '&key=' . $this->token);
|
|
|
|
$response = $this->curl('post', $url, $request);
|
|
$response = $this->response($response);
|
|
//$response['data'] = '';
|
|
//$response['msg'] = 'ok';
|
|
$channel_order_id = '';
|
|
if (isset($response['array']['order'])) {
|
|
$channel_order_id = $response['array']['order'];
|
|
}
|
|
|
|
$this->create($param['order'], $channel_order_id, $param['merchant_order'], $param['cash'], $url, $request, $response, 1, $param['account']);
|
|
return $response['msg'];
|
|
}
|
|
|
|
private function getCode($cash)
|
|
{
|
|
if ($cash == 100) {
|
|
return '000104';
|
|
} elseif ($cash == 200) {
|
|
return '000105';
|
|
} elseif ($cash == 500) {
|
|
return '000106';
|
|
} elseif ($cash == 1000) {
|
|
return '000107';
|
|
}
|
|
|
|
return false;
|
|
}
|
|
} |