147 lines
4.2 KiB
PHP
147 lines
4.2 KiB
PHP
<?php
|
|
|
|
namespace app\channel\service\system;
|
|
|
|
/**
|
|
* 博鼎城服务
|
|
* Class Bodingcheng
|
|
* @package app\channel\service
|
|
*/
|
|
class Bodingcheng extends Core
|
|
{
|
|
# 这几个可以后台设置
|
|
protected $host = 'http://47.93.43.30:8360/';
|
|
protected $mid = '633';
|
|
protected $token = 'd62a6e2dd28b5cc7cf9a4d0758bb9846d193f46b018ea56d5b93502a76794fa1';
|
|
|
|
# 中石化油卡充值
|
|
public function zshcz($param)
|
|
{
|
|
$check = array
|
|
(
|
|
'card' => 'uid',
|
|
'cash' => 'checkItemFacePrice',
|
|
'itemId' => 'itemId',
|
|
);
|
|
if ($param['cash'] == 100) {
|
|
$param['itemId'] = 20188;
|
|
} elseif ($param['cash'] == 200) {
|
|
$param['itemId'] = 20189;
|
|
} elseif ($param['cash'] == 500) {
|
|
$param['itemId'] = 20190;
|
|
} elseif ($param['cash'] == 1000) {
|
|
$param['itemId'] = 20191;
|
|
} else {
|
|
return 'order';
|
|
}
|
|
|
|
return $this->submit($param, $check);
|
|
}
|
|
|
|
# 通知处理 主要返回状态 2是成功 3是失败
|
|
public function notify($data)
|
|
{
|
|
$request = $data;
|
|
$send = array();
|
|
$send['userId'] = $request['userId'];
|
|
$send['bizId'] = $request['bizId'];
|
|
$send['ejId'] = $request['ejId'];
|
|
$send['downstreamSerialno'] = $request['downstreamSerialno'];
|
|
$send['status'] = $request['status'];
|
|
$sign = $this->_sign($send);
|
|
if ($sign != $data['sign']) {
|
|
return false;
|
|
}
|
|
$result = array();
|
|
$result['cash'] = 1;
|
|
if ($data['status'] == 2) {
|
|
$result['status'] = 2;
|
|
} elseif ($data['status'] == 3) {
|
|
$result['status'] = 3;
|
|
} else {
|
|
$result['status'] = 4;
|
|
}
|
|
if (isset($data['ext']) && $data['ext']) {
|
|
# 流水号
|
|
$data['s_nubmer'] = $result['s_nubmer'] = $data['ext'];
|
|
}
|
|
|
|
$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'] == '00' && isset($array['status']) && $array['status'] == 'success') {
|
|
# 正确
|
|
$msg = 'ok';
|
|
} else {
|
|
# 错误
|
|
$msg = isset($array['desc']) ? $array['desc'] : '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;
|
|
}
|
|
$request = $param['detail'];
|
|
$request['checkItemFacePrice'] = $request['checkItemFacePrice'] * 1000;
|
|
$request['userId'] = $this->mid;
|
|
$request['serialno'] = $param['order'];
|
|
$request['dtCreate'] = date('YmdHis');
|
|
$request['sign'] = $this->_sign($request);
|
|
$url = $this->host . 'unicomAync/buy.do';
|
|
|
|
$response = $this->curl('get', $url, $request, false, array('Accept' => 'application/json;charset=UTF-8'));
|
|
$response = $this->response($response);
|
|
//$response['data'] = '';
|
|
//$response['msg'] = 'ok';
|
|
$channel_order_id = '';
|
|
if (isset($response['array']['bizOrderId'])) {
|
|
$channel_order_id = $response['array']['bizOrderId'];
|
|
}
|
|
|
|
$this->create($param['order'], $channel_order_id, $param['merchant_order'], $param['cash'], $url, $request, $response, 1, $param['account']);
|
|
return $response['msg'];
|
|
}
|
|
|
|
private function _sign($request)
|
|
{
|
|
ksort($request);
|
|
$signature_string = '';
|
|
foreach ($request as $k => $v) {
|
|
$signature_string .= $v;
|
|
}
|
|
|
|
$signature_string .= $this->token;
|
|
|
|
return md5($signature_string);
|
|
}
|
|
} |