|
|
|
@ -32,68 +32,74 @@ class ExchangeController extends BaseController{
|
|
|
|
|
$request = SafeFilter($request);
|
|
|
|
|
// $request['server_id'] = 0;
|
|
|
|
|
// $request['game_player_id'] = 0;
|
|
|
|
|
if (empty($request['server_id']) && empty($request['serve_name'])
|
|
|
|
|
&& empty($request['game_player_id']) && empty($request['game_player_name'])) {
|
|
|
|
|
$this->set_message(0,"fail","未上传角色,不允许充值.");
|
|
|
|
|
}
|
|
|
|
|
if ($request['code'] == 1) {
|
|
|
|
|
if (empty($request['server_id']) && empty($request['serve_name'])
|
|
|
|
|
&& empty($request['game_player_id']) && empty($request['game_player_name'])) {
|
|
|
|
|
$this->set_message(0,"fail","未上传角色,不允许充值.");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!isset($request['server_id']) || !$request['server_id']
|
|
|
|
|
|| !isset($request['game_player_id']) || !$request['game_player_id']
|
|
|
|
|
) {
|
|
|
|
|
// 加入日志表
|
|
|
|
|
M('serverid_null_log', 'tab_')->add([
|
|
|
|
|
'user_id' => $request['user_id'],
|
|
|
|
|
'game_id' => $request['game_id'],
|
|
|
|
|
'sdk_version' => $request['sdk_version'],
|
|
|
|
|
'request' => json_encode($request),
|
|
|
|
|
'create_time' => time()
|
|
|
|
|
]);
|
|
|
|
|
if (!$request['server_name']) {
|
|
|
|
|
$this->set_message(0,"fail","区服名不能为空");
|
|
|
|
|
}
|
|
|
|
|
if (!$request['game_id']) {
|
|
|
|
|
$this->set_message(0,"fail","game_id不存在");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$server = M('server', 'tab_')->where([
|
|
|
|
|
'game_id' => $request['game_id'],
|
|
|
|
|
'server_name' => $request['server_name']
|
|
|
|
|
])->find();
|
|
|
|
|
$request['server_id'] = $server['server_id'];
|
|
|
|
|
if (!isset($request['server_id']) || !$request['server_id']) {
|
|
|
|
|
$unionServer = M('server_union', 'tab_')->where([
|
|
|
|
|
'game_id' => $request['game_id'],
|
|
|
|
|
'server_name' => $request['server_name']
|
|
|
|
|
])->find();
|
|
|
|
|
$request['server_id'] = $unionServer['server_id'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$userPlayInfo = M('user_play_info', 'tab_')->where([
|
|
|
|
|
'user_id' => $request['user_id'],
|
|
|
|
|
'game_id' => $request['game_id'],
|
|
|
|
|
'server_name' => $request['server_name']
|
|
|
|
|
])->find();
|
|
|
|
|
|
|
|
|
|
if ($userPlayInfo) {
|
|
|
|
|
$request['game_player_id'] = $userPlayInfo['role_id'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!isset($request['server_id']) || !$request['server_id']
|
|
|
|
|
|| !isset($request['game_player_id']) || !$request['game_player_id']
|
|
|
|
|
) {
|
|
|
|
|
// 加入日志表
|
|
|
|
|
M('serverid_null_log', 'tab_')->add([
|
|
|
|
|
$role = M("user_play_info", "tab_")->where([
|
|
|
|
|
'user_id' => $request['user_id'],
|
|
|
|
|
'game_id' => $request['game_id'],
|
|
|
|
|
'sdk_version' => $request['sdk_version'],
|
|
|
|
|
'request' => json_encode($request),
|
|
|
|
|
'create_time' => time()
|
|
|
|
|
]);
|
|
|
|
|
if (!$request['server_name']) {
|
|
|
|
|
$this->set_message(0,"fail","区服名不能为空");
|
|
|
|
|
}
|
|
|
|
|
if (!$request['game_id']) {
|
|
|
|
|
$this->set_message(0,"fail","game_id不存在");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$server = M('server', 'tab_')->where([
|
|
|
|
|
'game_id' => $request['game_id'],
|
|
|
|
|
'server_name' => $request['server_name']
|
|
|
|
|
])->find();
|
|
|
|
|
$request['server_id'] = $server['server_id'];
|
|
|
|
|
if (!isset($request['server_id']) || !$request['server_id']) {
|
|
|
|
|
$unionServer = M('server_union', 'tab_')->where([
|
|
|
|
|
'game_id' => $request['game_id'],
|
|
|
|
|
'server_name' => $request['server_name']
|
|
|
|
|
])->find();
|
|
|
|
|
$request['server_id'] = $unionServer['server_id'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$userPlayInfo = M('user_play_info', 'tab_')->where([
|
|
|
|
|
'user_id' => $request['user_id'],
|
|
|
|
|
'game_id' => $request['game_id'],
|
|
|
|
|
'server_name' => $request['server_name']
|
|
|
|
|
])->find();
|
|
|
|
|
|
|
|
|
|
if ($userPlayInfo) {
|
|
|
|
|
$request['game_player_id'] = $userPlayInfo['role_id'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
'server_id' => $request['server_id']
|
|
|
|
|
])->find();
|
|
|
|
|
if (!$role || !$role['role_id']) {
|
|
|
|
|
$this->set_message(0,"fail","未上传角色,不允许充值"/* .M("user_play_info", "tab_")->_sql() */);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$role = M("user_play_info", "tab_")->where([
|
|
|
|
|
'user_id' => $request['user_id'],
|
|
|
|
|
'game_id' => $request['game_id'],
|
|
|
|
|
'server_id' => $request['server_id']
|
|
|
|
|
])->find();
|
|
|
|
|
if (!$role || !$role['role_id']) {
|
|
|
|
|
$this->set_message(0,"fail","未上传角色,不允许充值"/* .M("user_play_info", "tab_")->_sql() */);
|
|
|
|
|
}
|
|
|
|
|
$prefix = $request['code'] == 1 ? "SP_" : "PF_";
|
|
|
|
|
$out_trade_no = $prefix.date('Ymd').date('His').sp_random_string(4);
|
|
|
|
|
$request['pay_order_number'] = $out_trade_no;
|
|
|
|
|
|
|
|
|
|
$user_entity = get_user_entity($request['user_id']);
|
|
|
|
|
M("pay_info", "tab_")->add([
|
|
|
|
|
'user_id' => $request['user_id'],
|
|
|
|
|
'game_id' => $request['game_id'],
|
|
|
|
|
'order_id' => '',
|
|
|
|
|
'order_id' => $request['pay_order_number'],
|
|
|
|
|
'extend' => $request['extend'],
|
|
|
|
|
'price' => $request['price'],
|
|
|
|
|
'type' => '', //
|
|
|
|
@ -109,18 +115,15 @@ class ExchangeController extends BaseController{
|
|
|
|
|
'game_player_id' => $request['game_player_id'],
|
|
|
|
|
'sdk_version' => $request['sdk_version'],
|
|
|
|
|
'promote_account' => $user_entity['promote_account'],
|
|
|
|
|
'ip' => get_client_ip(),
|
|
|
|
|
]);
|
|
|
|
|
/* if (!isset($request['api_ver'])) {
|
|
|
|
|
$payPage = "pay_way_v1";
|
|
|
|
|
} else {
|
|
|
|
|
$payPage = "pay_way_v".$request['api_ver'];
|
|
|
|
|
} */
|
|
|
|
|
|
|
|
|
|
$payPage = "pay_way_v1";
|
|
|
|
|
if (isset($request['api_ver']) && $request['api_ver'] == 2) {
|
|
|
|
|
$payPage = "pay_way";
|
|
|
|
|
// 用户
|
|
|
|
|
$userToken = $request['user_token'];
|
|
|
|
|
// M('user', 'tab_')->where(['id' => $request['user_id']])->getField('user_token');
|
|
|
|
|
// M('user', 'tab_')->where(['id' => $request['user_id']])->getField('user_token');
|
|
|
|
|
if (!$userToken) {
|
|
|
|
|
$this->set_message(0,"fail","请重新登入");
|
|
|
|
|
}
|
|
|
|
@ -155,7 +158,7 @@ class ExchangeController extends BaseController{
|
|
|
|
|
|
|
|
|
|
if($request['code'] == 0) { /* 平台币充值 */
|
|
|
|
|
|
|
|
|
|
file_put_contents("./Application/Sdk/Scheme/".$request['game_id'].".txt",$request['scheme']);
|
|
|
|
|
// file_put_contents("./Application/Sdk/Scheme/".$request['game_id'].".txt",$request['scheme']);
|
|
|
|
|
|
|
|
|
|
$prefix = "PF_";
|
|
|
|
|
|
|
|
|
@ -168,7 +171,7 @@ class ExchangeController extends BaseController{
|
|
|
|
|
$request['spend_ip'] = get_client_ip();
|
|
|
|
|
|
|
|
|
|
// $url = C('PAY_DOMAIN') . '/sdk.php?s=/Spend/'.$payPage.'&user_id='.$request['user_id'].'&game_id='.$request['game_id'].'&type=1'.'&user_token='.$userToken.'&action=pay';
|
|
|
|
|
file_put_contents("./Application/Sdk/OrderNo/".$request['user_id']."-".$request['game_id'].".txt",think_encrypt(json_encode($request)));
|
|
|
|
|
// file_put_contents("./Application/Sdk/OrderNo/".$request['user_id']."-".$request['game_id'].".txt",think_encrypt(json_encode($request)));
|
|
|
|
|
// $url = C('PAY_DOMAIN') . '/sdk.php?s=/userH/platform_pay/account/'.$request['account'].'&user_token='.$userToken.'&game_id='.$request['game_id'].'&money='.$request['price'].'&action=pay1&api_ver=1';
|
|
|
|
|
// echo base64_encode(json_encode(array('status'=>200,'out_trade_no'=>$out_trade_no,'img'=>$url)));
|
|
|
|
|
echo base64_encode(json_encode(array('status'=>200,'out_trade_no'=>$out_trade_no,'img'=>C('PAY_DOMAIN').'/sdk.php?s=/Spend/pay_way_v1&user_id='.$request['user_id'].'&game_id='.$request['game_id'].'&type=1'.'&user_token='.$userToken)));exit;
|
|
|
|
|