173 lines
4.8 KiB
PHP
173 lines
4.8 KiB
PHP
<?php
|
|
|
|
namespace app\channel\service\system;
|
|
use app\channel\service\CardService;
|
|
use app\merchant\service\OrderService;
|
|
/**
|
|
* 七只熊服务
|
|
* Class Qizhixiong
|
|
* @package app\channel\service
|
|
*/
|
|
class Qzx extends Core
|
|
{
|
|
# 这几个可以后台设置
|
|
protected $host = 'http://youka.5dev.cn/';
|
|
protected $mid = 'app318205390881';
|
|
protected $token = 'BY0NXHGS103VPCORAX8V8MJBTTTSNLVC';
|
|
protected $card = array();
|
|
protected $order_id = '';
|
|
|
|
# 通用的充值
|
|
public function common($param)
|
|
{
|
|
$check = array
|
|
(
|
|
'account' => 'account',
|
|
'cash' => 'cash',
|
|
'api_product' => 'api_product',
|
|
);
|
|
$param['api_product'] = 'dycz';
|
|
return $this->submit($param, $check);
|
|
}
|
|
|
|
# 电话充值 拼音来吧
|
|
public function dhcz($param)
|
|
{
|
|
$check = array
|
|
(
|
|
'mobile' => 'mobile',
|
|
'cash' => 'cash',
|
|
'api_product' => 'api_product',
|
|
);
|
|
$param['api_product'] = 'dhcz';
|
|
return $this->submit($param, $check);
|
|
}
|
|
|
|
# 中石油油卡充值 拼音来吧
|
|
public function zsycz($param)
|
|
{
|
|
$check = array
|
|
(
|
|
'card' => 'card',
|
|
'cash' => 'cash',
|
|
//'idCard' => 'idCard',
|
|
//'realName' => 'realName',
|
|
'api_product' => 'api_product',
|
|
);
|
|
$param['api_product'] = 'zsycz';
|
|
return $this->submit($param, $check);
|
|
}
|
|
|
|
# 中石化油卡充值
|
|
public function zshcz($param)
|
|
{
|
|
$check = array
|
|
(
|
|
'card' => 'card',
|
|
'cash' => 'cash',
|
|
'api_product' => 'api_product',
|
|
);
|
|
$param['api_product'] = 'zshcz';
|
|
return $this->submit($param, $check);
|
|
}
|
|
|
|
# 通知处理 主要返回状态 2是成功 3是失败
|
|
public function notify($data)
|
|
{
|
|
$request = $data;
|
|
unset($request['signature']);
|
|
$this->token = $this->mid . '|' . $this->token;
|
|
$request = $this->getParam($request, $this->token);
|
|
if ($request['signature'] != $data['signature']) {
|
|
return false;
|
|
}
|
|
$result = array();
|
|
$result['cash'] = 1;
|
|
if ($data['status'] == 2) {
|
|
$result['status'] = 2;
|
|
} elseif ($data['status'] == 3) {
|
|
$result['status'] = 3;
|
|
} else {
|
|
return false;
|
|
$result['status'] = 4;
|
|
}
|
|
if (isset($data['number']) && $data['number'] && $data['number'] != 'empty') {
|
|
# 流水号
|
|
$data['s_nubmer'] = $result['s_nubmer'] = $data['number'];
|
|
} elseif (isset($data['s_nubmer']) && $data['s_nubmer'] && $data['s_nubmer'] != 'empty') {
|
|
# 流水号
|
|
$data['s_nubmer'] = $result['s_nubmer'] = $data['s_nubmer'];
|
|
}
|
|
if (isset($data['msg']) && $data['msg']) {
|
|
# 错误信息
|
|
$data['msg'] = $result['msg'] = $data['msg'];
|
|
}
|
|
|
|
$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'] == 1) {
|
|
# 正确
|
|
$msg = 'ok';
|
|
} else {
|
|
# 错误
|
|
$msg = isset($array['info']) ? $array['info'] : '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['appid'] = $this->mid;
|
|
$request['order'] = $param['order'];
|
|
$this->token = $this->mid . '|' . $this->token;
|
|
$request = $this->getParam($request, $this->token);
|
|
$url = $this->host . 'gateway/api.handle/submit';
|
|
$response = $this->curl('post', $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'], $parent_order);
|
|
|
|
return $response['msg'];
|
|
}
|
|
} |