131 lines
3.3 KiB
PHP
131 lines
3.3 KiB
PHP
![]() |
<?php
|
||
|
|
||
|
namespace app\channel\service\system;
|
||
|
|
||
|
/**
|
||
|
* 服务
|
||
|
* Class Bodingcheng
|
||
|
* @package app\channel\service
|
||
|
*/
|
||
|
class Wenye extends Core
|
||
|
{
|
||
|
# 这几个可以后台设置
|
||
|
protected $host = 'host';
|
||
|
protected $mid = 'mid';
|
||
|
protected $token = 'token';
|
||
|
protected $api = 'api';
|
||
|
|
||
|
public function dhcz($param)
|
||
|
{
|
||
|
$check = array
|
||
|
(
|
||
|
'mobile' => 'mob',
|
||
|
'cash' => 'amt',
|
||
|
);
|
||
|
$this->api = 'racc/index.php';
|
||
|
return $this->submit($param, $check);
|
||
|
}
|
||
|
|
||
|
# 通知处理 主要返回状态 2是成功 3是失败
|
||
|
public function notify($data)
|
||
|
{
|
||
|
$request = $data;
|
||
|
$sign = $this->_sign($request, array('ord','state'));
|
||
|
if ($sign != $data['sgn']) {
|
||
|
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['bz']) && $data['bz']) {
|
||
|
# 流水号
|
||
|
$data['s_nubmer'] = $result['s_nubmer'] = $data['bz'];
|
||
|
}
|
||
|
|
||
|
$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);
|
||
|
$array = explode('|', $data);
|
||
|
if (!$array) {
|
||
|
$msg = 'error';
|
||
|
} elseif (isset($array[0]) && $array[0] == '0') {
|
||
|
# 正确
|
||
|
$msg = 'ok';
|
||
|
} else {
|
||
|
# 错误
|
||
|
$msg = isset($array[1]) ? $array[1] : '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['usr'] = $this->mid;
|
||
|
$request['ord'] = $param['order'];
|
||
|
$request['act'] = 'lzrefill';
|
||
|
$request['op'] = 'add_mob';
|
||
|
$request['tim'] = date('YmdHis');
|
||
|
$request['notifyurl'] = $this->getNotify($param['order'], 1);
|
||
|
$request['sgn'] = $this->_sign($request, array('usr', 'ord', 'mob', 'amt', 'tim'));
|
||
|
$url = $this->host . $this->api;
|
||
|
|
||
|
$response = $this->curl('get', $url, $request);
|
||
|
$response = $this->response($response);
|
||
|
//$response['data'] = '';
|
||
|
//$response['msg'] = 'ok';
|
||
|
$channel_order_id = '';
|
||
|
|
||
|
$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, $param)
|
||
|
{
|
||
|
$signature_string = '';
|
||
|
foreach ($param as $k => $v) {
|
||
|
$signature_string .= $request[$v];
|
||
|
}
|
||
|
|
||
|
$signature_string .= $this->token;
|
||
|
|
||
|
return strtoupper(md5($signature_string));
|
||
|
}
|
||
|
}
|