You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

124 lines
4.1 KiB
PHTML

2 years ago
<?php
namespace Sdk\Controller;
use Think\Controller;
use Think\Log;
class UserHController extends Controller
{
public $userId;
public $userToken;
public function _initialize()
{
$user = BaseController::webH5Verify();
$this->userId = $user['userId'];
$this->userToken = $user['userToken'];
}
/**
* 获取用户平台币充值记录绑币余额
* @return [type] [description]
*/
public function get_user_money()
{
$data['user_token'] = I('user_token');
$user_info = M('user','tab_')->where(['id' => $this->userId])->field('id,account,balance')->find();
$user_play = M('user_play','tab_')->alias('user')
->join('tab_game as game on user.game_id = game.id')
->where(['user_id' => $user_info['id']])
->field('user.game_name,user.bind_balance,game.icon')->select();
foreach($user_play as $k => $v)
{
$icon = get_cover($v['icon'],"path");
$cover = (substr($icon, 0, 7) == "http://" || substr($icon, 0, 8) == "https://" ) ? $icon : C('ADMIN_DOMAIN') . $icon;
$user_play[$k]['cover'] = $cover;
}
$deposit = M('deposit','tab_')->where(['user_id' => $user_info['id'],'pay_status' => 1])
->field('user_account,create_time,pay_amount')->order('id DESC')->select();
foreach($deposit as $k => $v)
{
$deposit[$k]['create_time'] = date('Y-m-d',$v['create_time']);
}
// 玩家特殊处理 隐藏平台币充值记录
if ($user_info['id'] == 353996) {
$deposit = [];
}
$this->assign('game_id', I('game_id', 0));
$this->assign('account', $user_info['account']);
$this->assign('balance', $user_info['balance']?:0);
$this->assign('deposit', $deposit);
$this->assign('user_play', $user_play);
$this->assign('user_token', $data['user_token']);
$this->display();
}
/**
* 平台币充值
*/
public function platform_pay_show()
{
$u = M('user', 'tab_')->where(['id' => $this->userId])->find();
$this->assign("account", $u['account']);
$this->assign("user_token", $this->userToken);
$this->assign('game_id', I('game_id', 0));
$this->display();
}
/**
* 平台币充值展示
*/
public function platform_pay()
{
C(BaseController::get_tool());
$u = M('user', 'tab_')->where(['id' => $this->userId])->find();
$money = I('money', 0);
$api_ver = I('api_ver', 0);
if(!$money) {
$this->error('金额不能为空');
}
$user_info = M('user', 'tab_')->field('account,promote_id,promote_account')->where(['id' => $this->userId])->find();
$game_name = M('game', 'tab_')->where(['id' => I('game_id')])->getField('game_name');
$prefix = "PF_"; // SP
$out_trade_no = $prefix.date('Ymd').date('His').sp_random_string(4);
$data = [
'user_id' => $this->userId,
'game_id' => I('game_id'),
'order_id' => $out_trade_no,
'price' => $money,
'type' => 'platform_pay',
'status' => 'normal',
'create_time' => time(),
'user_account' => $user_info['account'],
'game_name' => $game_name,
'promote_id' => $user_info['promote_id'],
'promote_account' => $user_info['promote_account'],
'sdk_version' => $api_ver,
'ip' => get_client_ip(),
'extend' => '',
'game_player_name' => '',
'server_id' => 0, // 旧包平台充值 没传
'server_name' => '',
'game_player_id' => '',
];
M('pay_info', 'tab_')->add($data);
$this->assign('api_ver', $api_ver);
$this->assign("account", $u['account']);
$this->assign("user_id", $u['id']);
$this->assign('money', $money);
$this->assign('game_id', I('game_id', 0));
$this->display();
}
}