191 lines
4.6 KiB
PHP
191 lines
4.6 KiB
PHP
<?php
|
|
|
|
namespace app\channel\service\system;
|
|
use app\channel\service\CardService;
|
|
use app\merchant\service\MerchantService;
|
|
/**
|
|
* 测试渠道
|
|
* Class Tiancheng
|
|
* @package app\channel\service
|
|
*/
|
|
class Test extends Core
|
|
{
|
|
private $t = 1;
|
|
# 购买卡密
|
|
public function cardbuy($param)
|
|
{
|
|
$check = array
|
|
(
|
|
'proid' => 'proid',
|
|
'num' => 'num',
|
|
);
|
|
|
|
$this->t = 2;
|
|
return $this->submit($param, $check);
|
|
}
|
|
|
|
# 通用的充值
|
|
public function common($param)
|
|
{
|
|
$check = array
|
|
(
|
|
'mobile' => 'mobile',
|
|
'cash' => 'cash',
|
|
);
|
|
return $this->submit($param, $check);
|
|
}
|
|
# 系统代充
|
|
public function xtdc($param)
|
|
{
|
|
$check = array
|
|
(
|
|
'card' => 'card',
|
|
'cash' => 'cash',
|
|
);
|
|
if (!isset($param['cnum'])) {
|
|
$data = CardService::instance()->getData($param['cash'], $this->data['merchant']);
|
|
if ($data) {
|
|
$this->data['param']['cnum'] = $param['cnum'] = $data['cnum'];
|
|
$this->data['param']['cpwd'] = $param['cpwd'] = $data['cpwd'];
|
|
|
|
$this->card = $data;
|
|
$this->card_id = $this->card['id'];
|
|
} else {
|
|
return 'card error';
|
|
}
|
|
}
|
|
|
|
return $this->submit($param, $check);
|
|
}
|
|
|
|
# 中石油油卡充值 拼音来吧
|
|
public function zsycz($param)
|
|
{
|
|
$check = array
|
|
(
|
|
'card' => 'card',
|
|
'cash' => 'cash',
|
|
);
|
|
return $this->submit($param, $check);
|
|
}
|
|
|
|
# 中石化油卡充值
|
|
public function zshcz($param)
|
|
{
|
|
$check = array
|
|
(
|
|
'card' => 'card',
|
|
'cash' => 'cash',
|
|
);
|
|
return $this->submit($param, $check);
|
|
}
|
|
|
|
# 话费充值 拼音来吧
|
|
public function dhcz($param)
|
|
{
|
|
$check = array
|
|
(
|
|
'mobile' => 'mobile',
|
|
'cash' => 'cash',
|
|
);
|
|
return $this->submit($param, $check);
|
|
}
|
|
|
|
public function ydcz($param)
|
|
{
|
|
$check = array
|
|
(
|
|
'mobile' => 'mobile',
|
|
'cash' => 'cash',
|
|
);
|
|
return $this->submit($param, $check);
|
|
}
|
|
|
|
public function ltcz($param)
|
|
{
|
|
$check = array
|
|
(
|
|
'mobile' => 'mobile',
|
|
'cash' => 'cash',
|
|
);
|
|
return $this->submit($param, $check);
|
|
}
|
|
|
|
public function dxcz($param)
|
|
{
|
|
$check = array
|
|
(
|
|
'mobile' => 'mobile',
|
|
'cash' => 'cash',
|
|
);
|
|
return $this->submit($param, $check);
|
|
}
|
|
|
|
public function test($param)
|
|
{
|
|
$check = array
|
|
(
|
|
'mobile' => 'mobile',
|
|
'cash' => 'cash',
|
|
);
|
|
return $this->submit($param, $check);
|
|
}
|
|
public function dy($param)
|
|
{
|
|
$check = array
|
|
(
|
|
'account' => 'account',
|
|
'cash' => 'cash',
|
|
);
|
|
return $this->submit($param, $check);
|
|
}
|
|
|
|
# 通知处理 主要返回状态 2是成功 3是失败
|
|
public function notify($data)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
# 提交数据
|
|
private function submit($param, $check)
|
|
{
|
|
$param = $this->param($param, $check);
|
|
if (is_string($param) || (is_array($param) && $param['status'] == 1)) {
|
|
return $param;
|
|
}
|
|
|
|
$url = 'test';
|
|
$request = $param['detail'];
|
|
$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']);
|
|
|
|
if ($this->t == 2) {
|
|
$merchant = MerchantService::instance()->get($this->data['merchant']);
|
|
$response['card'][] = array
|
|
(
|
|
'cardno' => $this->encrypt('testno', $merchant['appsecret']),
|
|
'cardpwd' => $this->encrypt('testpwd', $merchant['appsecret']),
|
|
'expired' => '2024-04-30 00:00:00',
|
|
'value' => '10.0000',
|
|
);
|
|
$result = array();
|
|
$result['order'] = $param['order'];
|
|
$result['card'] = $response['card'];
|
|
return $result;
|
|
}
|
|
return $response['msg'];
|
|
}
|
|
|
|
public function encrypt($value, $token = false)
|
|
{
|
|
$key = $token ? $token : $this->token;
|
|
$iv = substr($key, -8, 8);
|
|
$key = substr($key, 0, 8);
|
|
$data = openssl_encrypt($value, 'DES-CBC', $key, false, $iv);
|
|
//$data = base64_encode($data);
|
|
return $data;
|
|
}
|
|
}
|