214 lines
6.5 KiB
PHP
214 lines
6.5 KiB
PHP
<?php
|
||
|
||
namespace app\channel\service\system;
|
||
|
||
class Feihan extends Core
|
||
{
|
||
# 这几个可以后台设置
|
||
protected $host = '';
|
||
protected $mid = '';
|
||
protected $token = '';
|
||
// protected $keystr='9972A391085219C2';
|
||
protected $keystr='OFCARD';
|
||
protected $api="";
|
||
# 电话充值
|
||
public function dhcz($param)
|
||
{
|
||
$check = array
|
||
(
|
||
# key值是传入的数据,value是传出的数据
|
||
|
||
'cash' => 'cardnum',
|
||
'mobile'=>'game_userid'
|
||
);
|
||
$this->api='onlineorder.do';
|
||
return $this->submit( $param, $check);
|
||
}
|
||
public function ydcz($param)
|
||
{
|
||
$check = array
|
||
(
|
||
# key值是传入的数据,value是传出的数据
|
||
|
||
'cash' => 'cardnum',
|
||
'mobile'=>'game_userid'
|
||
);
|
||
$this->api='onlineorder.do';
|
||
return $this->submit( $param, $check);
|
||
}
|
||
public function dxcz($param)
|
||
{
|
||
$check = array
|
||
(
|
||
# key值是传入的数据,value是传出的数据
|
||
|
||
'cash' => 'cardnum',
|
||
'mobile'=>'game_userid'
|
||
);
|
||
$this->api='onlineorder.do';
|
||
return $this->submit( $param, $check);
|
||
}
|
||
public function ltcz($param)
|
||
{
|
||
$check = array
|
||
(
|
||
# key值是传入的数据,value是传出的数据
|
||
|
||
'cash' => 'cardnum',
|
||
'mobile'=>'game_userid'
|
||
);
|
||
$this->api='onlineorder.do';
|
||
return $this->submit( $param, $check);
|
||
}
|
||
|
||
# 通知处理 主要返回状态 2是成功 3是失败
|
||
public function notify($data)
|
||
{
|
||
$request = $data;
|
||
$result = array();
|
||
$result['cash'] = 1;
|
||
$result['status'] = 4;
|
||
|
||
if(isset($data['query_status'])){
|
||
$data['status'] =$data['query_status'];
|
||
}
|
||
if(isset($data['ret_code'])){
|
||
$data['status'] =$data['ret_code'];
|
||
}
|
||
if ($data['status'] == 1) {
|
||
$result['status'] = 2;
|
||
} else if($data['status'] == 9) {
|
||
$result['status'] = 3;
|
||
}else {
|
||
$result['status'] = 4;
|
||
}
|
||
if (isset($data['card_no']) && $data['card_no']) {
|
||
# 流水号
|
||
$data['s_nubmer'] = $result['s_nubmer'] = $data['card_no'];
|
||
}
|
||
|
||
$result['yes'] = 'success';//根据接口要求响应对应数据
|
||
|
||
$result['data'] = $data;
|
||
|
||
return $result;
|
||
}
|
||
|
||
# 数据响应格式处理
|
||
public function response($data,$isxml=false)
|
||
{
|
||
$log['type'] = 'response';
|
||
$log['data'] = $data;
|
||
$log['config'] = $this->data;
|
||
$this->log($log);
|
||
if($isxml){
|
||
// $data=str_replace('GB2312','UTF-8',$data);
|
||
// $xmlObject = simplexml_load_string($data);
|
||
$content = str_replace('GB2312', 'UTF-8', $data);
|
||
$content = iconv('GBK', 'UTF-8', $content);
|
||
// $content = mb_convert_encoding($content, 'UTF-8', 'GB2312, GBK');
|
||
$xmlObject = simplexml_load_string($content);
|
||
$data = json_encode($xmlObject);
|
||
}
|
||
$array = $this->json_decode($data,true);
|
||
if (!$array) {
|
||
$msg = 'error';
|
||
} elseif (isset($array['retcode']) && $array['retcode']==1 ) {
|
||
$msg = 'ok';
|
||
} else {
|
||
$msg = $array['err_msg'];
|
||
}
|
||
|
||
return array
|
||
(
|
||
'msg' => $msg,
|
||
'data' => $data,
|
||
'array' => $array,
|
||
);
|
||
}
|
||
|
||
# 查询接口 (未调试)
|
||
public function query($param)
|
||
{
|
||
if (empty($param['order'])) {
|
||
return 'order';
|
||
}
|
||
$request['sporder_id'] = $param['order_id'];
|
||
|
||
$request['md5_str'] =strtoupper(md5($this->mid.$this->token.$request['sporder_id'].$this->keystr));
|
||
|
||
$headers['version'] = '6.0';
|
||
$url = $this->host . 'queryOrderInfo.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,true);
|
||
$result = array();
|
||
$result['status'] = 4;
|
||
if (isset($array['game_state']) ) {
|
||
if($array['game_state'] == 1){
|
||
$result['query_status'] = 1;
|
||
|
||
$result['status'] = 2;
|
||
}elseif ($array['game_state'] == 9){
|
||
$result['query_status'] = 9;
|
||
$result['status'] = 3;
|
||
}
|
||
if (isset($array['cardid']) && $array['cardid']) {
|
||
# 流水号
|
||
// $data['szRtnMsg']
|
||
$result['s_number'] = $array['cardid'];
|
||
}
|
||
|
||
}
|
||
|
||
return $result;
|
||
}
|
||
private function _sign($data){
|
||
$str=$this->mid.$this->token.$data['cardid'].$data['cardnum'].$data['sporder_id'].$data['sporder_time'].$data['game_userid'];
|
||
// $data['mid']=$this->mid;
|
||
// $data['ped']=$this->token;
|
||
// $data['keystr']=$this->keystr;
|
||
// var_dump($data);exit;
|
||
return strtoupper(md5($str.$this->keystr));
|
||
}
|
||
# 提交数据
|
||
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['sporder_id'] = $param['order'];
|
||
$request['userid'] = $this->mid;
|
||
$request['userpws'] =$this->token;
|
||
$request['cardid'] = '140101';
|
||
// $request['cardid'] = $this->getGid($param['cash']);
|
||
$request['sporder_time'] = date("YmdHis",time());
|
||
$request['md5_str'] = $this->_sign($request);
|
||
$request['ret_url'] = $this->getNotify($param['order'], 1);
|
||
$request['version'] = '6.0';
|
||
$url = $this->host . $this->api;
|
||
$response = $this->curl('post', $url, $request);
|
||
|
||
// $response = $this->send_post($url,$request,'POST');
|
||
$response = $this->response($response,true);
|
||
//$response['data'] = '';
|
||
//$response['msg'] = 'ok';
|
||
$channel_order_id = '';
|
||
if (isset($response['array']['code']) && $response['array']['code'] == 1&&isset($response['array']['orderid'])) {
|
||
#如果有订单则进来
|
||
$channel_order_id = $response['array']['orderid'];
|
||
}
|
||
// $channel_order_id = '';
|
||
|
||
$this->create($param['order'], $channel_order_id, $param['merchant_order'], $param['cash'], $url, $request, $response, 1, $param['account']);
|
||
return $response['msg'];
|
||
}
|
||
|
||
} |