
- 新增 IP白名单设置页面和相关逻辑- 实现 IP 白名单的添加和修改功能 - 与宝塔防火墙进行集成,自动同步 IP 白名单 - 卡卡云渠道支持 - 自动选择最优价格 - 修改完成订单迁移bug - 提单错误异常捕捉提醒 - 飞之度推单支持
217 lines
5.7 KiB
PHP
217 lines
5.7 KiB
PHP
<?php
|
|
|
|
namespace app\channel\service\system;
|
|
|
|
/**
|
|
* 话费服务
|
|
* Class Common
|
|
* @package app\channel\service
|
|
*/
|
|
class Meicheng extends Core
|
|
{
|
|
# 这几个可以后台设置
|
|
protected $host = 'host';
|
|
protected $mid = 'mid';
|
|
protected $token = 'token';
|
|
protected $api = 'api';
|
|
|
|
# 电话充值
|
|
public function dhcz($param)
|
|
{
|
|
$check = array
|
|
(
|
|
'mobile' => 'mobile',
|
|
'cash' => 'price',
|
|
'paytype' => 'paytype',
|
|
);
|
|
$this->api = 'onlinepay.do';
|
|
|
|
if (isset($param['isp']) && $param['isp']) {
|
|
$isp = $param['isp'];
|
|
} else {
|
|
$isp = $this->isp($param['mobile']);
|
|
}
|
|
$paytype = '';
|
|
if ($isp == 1) {
|
|
$paytype = 'yd';
|
|
}
|
|
if ($isp == 2) {
|
|
$paytype = 'lt';
|
|
}
|
|
if ($isp == 3) {
|
|
$paytype = 'dx';
|
|
}
|
|
$param['paytype'] = $paytype;
|
|
|
|
return $this->submit($param, $check);
|
|
}
|
|
|
|
public function ydcz($param)
|
|
{
|
|
$param['paytype'] = 'yd';
|
|
return $this->hf_submit($param);
|
|
}
|
|
public function ltcz($param)
|
|
{
|
|
$param['paytype'] = 'lt';
|
|
return $this->hf_submit($param);
|
|
}
|
|
public function dxcz($param)
|
|
{
|
|
$param['paytype'] = 'dx';
|
|
return $this->hf_submit($param);
|
|
}
|
|
|
|
public function hf_submit($param)
|
|
{
|
|
$check = array
|
|
(
|
|
'mobile' => 'mobile',
|
|
'cash' => 'price',
|
|
'paytype' => 'paytype',
|
|
's_num'=>'num'
|
|
);
|
|
$param['s_num'] = 1;
|
|
$this->api = 'onlinepay.do';
|
|
|
|
return $this->submit($param, $check);
|
|
|
|
}
|
|
|
|
# 通知处理 主要返回状态 2是成功 3是失败
|
|
public function notify($data)
|
|
{
|
|
$request = $data;
|
|
unset($request['sign']);
|
|
unset($request['s_order']);
|
|
$sign = strtoupper($this->_sign($request, array('userid', 'orderid', 'sporderid', 'merchantsubmittime', 'resultno')));
|
|
if ($sign != $data['sign']) {
|
|
return false;
|
|
}
|
|
$result = array();
|
|
$result['cash'] = 1;
|
|
if ($data['resultno'] == 1) {
|
|
$result['status'] = 2;
|
|
} elseif ($data['resultno'] == 9) {
|
|
$result['status'] = 3;
|
|
} else {
|
|
$result['status'] = 4;
|
|
}
|
|
if (isset($data['remark1']) && $data['remark1']) {
|
|
# 流水号
|
|
$data['s_number'] = $result['s_number'] = $data['remark1'];
|
|
}
|
|
|
|
$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 = (array) simplexml_load_string($data);
|
|
|
|
if (!$array) {
|
|
$msg = 'error';
|
|
} elseif (isset($array['resultno']) && $array['resultno'] == '0') {
|
|
# 正确
|
|
$msg = 'ok';
|
|
} else {
|
|
# 错误
|
|
$msg = 'error';
|
|
}
|
|
|
|
return array
|
|
(
|
|
'msg' => $msg,
|
|
'data' => $array,
|
|
'array' => $array,
|
|
);
|
|
}
|
|
|
|
# 查询接口
|
|
public function query($param)
|
|
{
|
|
$request['userid'] = $this->mid;
|
|
$request['sporderid'] = $param['order_id'];
|
|
|
|
$request['sign'] = $this->_sign($request, array('userid', 'sporderid'));
|
|
$url = $this->host . 'searchpay.do';
|
|
$response = $this->curl('post', $url, $request);
|
|
|
|
$log['type'] = 'query_response';
|
|
$log['data'] = $response;
|
|
$log['config'] = $this->data;
|
|
$this->log($log);
|
|
|
|
$array = $this->json_decode($response);
|
|
|
|
$result = array();
|
|
$result['status'] = 4;
|
|
if (isset($array['resultno']) ) {
|
|
if($array['resultno'] == '1'){
|
|
$result['status'] = 2;
|
|
}elseif ($array['resultno'] == '9'){
|
|
$result['status'] = 3;
|
|
}
|
|
|
|
}
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
# 提交数据
|
|
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['num'] = $request['num']??1;
|
|
$request['productid'] = '';
|
|
|
|
$request['userid'] = $this->mid;
|
|
$request['sporderid'] = $param['order'];
|
|
$request['spordertime'] = date('YmdHis');
|
|
$request['back_url'] = $this->getNotify($param['order'], 1);
|
|
|
|
$request['productid'] = $this->getGid($param['cash']);
|
|
|
|
$request['sign'] = $this->_sign($request, array('userid', 'productid', 'price', 'num', 'mobile', 'spordertime', 'sporderid'));
|
|
$url = $this->host . $this->api;
|
|
$response = $this->curl('get', $url, $request);
|
|
$response = $this->response($response);
|
|
$channel_order_id = '';
|
|
if (isset($response['array']['orderid'])) {
|
|
$channel_order_id = $response['array']['orderid'];
|
|
}
|
|
|
|
$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)
|
|
{
|
|
//ksort($request);
|
|
$signature_string = '';
|
|
foreach ($param as $k => $v) {
|
|
if (isset($request[$v])) {
|
|
$signature_string .= $v . '=' . $request[$v] . '&';
|
|
}
|
|
}
|
|
|
|
$signature_string .= 'key=' . $this->token;
|
|
|
|
return md5($signature_string);
|
|
}
|
|
} |