683 lines
30 KiB
PHP
683 lines
30 KiB
PHP
<?php
|
|
|
|
namespace app\api\model;
|
|
|
|
use think\Db;
|
|
use think\Model;
|
|
|
|
class Player extends Model
|
|
{
|
|
protected $name = 'user_player';
|
|
//获取陪玩列表
|
|
public function get_player_list($uid, $gid, $keywords, $is_top, $is_recommend, $sex, $lid, $sort, $sort_type, $page, $page_limit)
|
|
{
|
|
$page = intval($page);
|
|
$page_limit = $page_limit < 10 ? $page_limit : 10;
|
|
$map = [];
|
|
$map['a.status'] = 2; //已审核通过
|
|
// $map['a.status'] = 2; //已审核通过
|
|
if (!empty($is_top)) {
|
|
$map['a.is_top'] = $is_top;
|
|
}
|
|
if (!empty($is_recommend)) {
|
|
$map['a.is_recommend'] = $is_recommend;
|
|
}
|
|
if (!empty($uid)) {
|
|
$map['a.uid'] = $uid;
|
|
}
|
|
if (!empty($gid)) {
|
|
$map['a.gid'] = $gid;
|
|
}
|
|
if (!empty($lid)) {
|
|
$map['a.lid'] = $lid;
|
|
}
|
|
if (!empty($sex)) {
|
|
$map['b.sex'] = $sex;
|
|
}
|
|
|
|
$order_string = 'a.is_top desc,a.is_recommend desc,a.pid desc'; //排序规则
|
|
$sort_string = $sort_type == 1 ? ' desc' : ' asc';
|
|
if ($sort == 1) {
|
|
$order_string = 'a.price' . $sort_string;
|
|
} elseif ($sort == 2) {
|
|
$order_string = 'a.order_count' . $sort_string;
|
|
} elseif ($sort == 3) {
|
|
$order_string = 'a.service_rate' . $sort_string;
|
|
}
|
|
|
|
$game_data = db::name('game')->cache(60)->column('game_name', 'gid');
|
|
$model = Db::name('user_player')->alias('a')->join('yy_user b', 'a.uid = b.uid');
|
|
$model = $model->where($map);
|
|
if (!empty($keywords)) {
|
|
$model = $model->where("a.uid = :keywords or b.nick_name like '%:keywords%' or b.special_uid = ':keywords'", ['keywords' => $keywords]);
|
|
}
|
|
$list = $model->field('a.pid,a.gid,a.lid,a.price,a.cover_image,a.sound,a.sound_duration,a.order_duration,a.order_count,a.order_total_amount,a.service_rate,a.flag,a.is_top,a.is_recommend,a.is_business,b.base64_nick_name,b.sex')->order($order_string)->page($page, $page_limit)->group('a.uid')->select();
|
|
foreach ($list as $k => &$v) {
|
|
$v['cover_image'] = localpath_to_netpath($v['cover_image']);
|
|
$v['nick_name'] = mb_convert_encoding(base64_decode($v['base64_nick_name']), 'UTF-8', 'UTF-8');
|
|
$v['sound'] = localpath_to_netpath($v['sound']);
|
|
$v['game_name'] = $game_data[$v['gid']];
|
|
}
|
|
return ['code' => 200, 'msg' => '获取成功', 'data' => $list];
|
|
}
|
|
public function get_player_user_list($page, $page_limit)
|
|
{
|
|
$map = [];
|
|
$map[] = ['is_player', '=', 2];
|
|
$map[] = ['player_game_list', '<>', ""];
|
|
$user_list = Db::name('user')->field('uid,head_pic,sex,base64_nick_name,player_game_list,palyer_order_count')->where($map)->page($page, $page_limit)->order('palyer_order_count desc')->select();
|
|
$game_list_data = db::name('game')->field('gid,game_name,game_ico,sort')->column('game_ico', 'gid');
|
|
foreach ($user_list as $k => &$v) {
|
|
$v['nick_name'] = mb_convert_encoding(base64_decode($v['base64_nick_name']), 'UTF-8', 'UTF-8');
|
|
$v['head_pic'] = localpath_to_netpath($v['head_pic']);
|
|
$game_data = explode(',', $v['player_game_list']);
|
|
$v['game_list'] = [];
|
|
foreach ($game_data as $m => $n) {
|
|
$v['game_list'][] = localpath_to_netpath($game_list_data[$n]);
|
|
}
|
|
unset($v['player_game_list']);
|
|
unset($v['base64_nick_name']);
|
|
}
|
|
return ['code' => 200, 'msg' => '获取成功', 'data' => $user_list];
|
|
}
|
|
|
|
//获取陪玩详情
|
|
public function get_player_info($pid)
|
|
{
|
|
if (empty($pid)) {
|
|
return ['code' => 200, 'msg' => '非法参数', 'data' => null];
|
|
}
|
|
$map = [];
|
|
$map[] = ['a.pid', '=', $pid];
|
|
$model = Db::name('user_player')->alias('a')->join('yy_user b', 'a.uid = b.uid');
|
|
$model = $model->where($map);
|
|
$info = $model->field('a.pid,a.uid,a.gid,a.lid,a.price,a.cover_image,a.skill_image,a.sound,a.sound_duration,a.order_duration,a.order_count,a.order_total_amount,a.service_rate,a.flag,a.is_top,a.is_recommend,a.is_business,a.introduction,b.base64_nick_name,b.sex,b.head_pic')->find();
|
|
$info['cover_image'] = localpath_to_netpath($info['cover_image']);
|
|
$info['skill_image'] = localpath_to_netpath($info['skill_image']);
|
|
$info['head_pic'] = localpath_to_netpath($info['head_pic']);
|
|
$info['sound'] = localpath_to_netpath($info['sound']);
|
|
$info['nick_name'] = mb_convert_encoding(base64_decode($info['base64_nick_name']), 'UTF-8', 'UTF-8');
|
|
$game_info = model('game')->get_game_info($info['gid']);
|
|
$info['game_info'] = $game_info['data'];
|
|
$game_level_info = model('game')->get_game_skill_level_info($info['gid']);
|
|
// $info['game_level_info'] = $game_level_info['data'];
|
|
return ['code' => 200, 'msg' => '获取成功', 'data' => $info];
|
|
}
|
|
|
|
//获取陪玩个人主页
|
|
//from_id 个人主页用户uid
|
|
public function player_home_page($uid, $from_id)
|
|
{
|
|
$user_info = db::name('user')->find($from_id);
|
|
if (empty($user_info)) {
|
|
return ['code' => 201, 'msg' => '用户信息不存在', 'data' => null];
|
|
}
|
|
$data['is_online'] = $user_info['is_online'];
|
|
$data['uid'] = $user_info['uid']; //用户ID
|
|
$data['head_pic'] = localpath_to_netpath($user_info['head_pic']);
|
|
$data['nick_name'] = mb_convert_encoding(base64_decode($user_info['base64_nick_name']), 'UTF-8', 'UTF-8');
|
|
$data['sex'] = $user_info['sex']; //性别
|
|
$data['country'] = $user_info['country']; //国家
|
|
$data['constellation'] = $user_info['constellation']; //星座
|
|
$data['special_uid'] = $user_info['special_uid']; //靓号
|
|
$data['follow_num'] = $user_info['follow_num'];
|
|
$data['fans_num'] = $user_info['fans_num'];
|
|
$data['birthday'] = $user_info['birthday'];
|
|
$data['is_player'] = $user_info['is_player'];
|
|
$data['is_anchor'] = $user_info['is_anchor'];
|
|
$data['hobby'] = $user_info['hobby'];
|
|
$data['autograph'] = $user_info['autograph'];
|
|
if(empty($user_info['province'])){
|
|
$data['ip_address'] = '中国';
|
|
}else{
|
|
$data['ip_address'] = $user_info['province'];
|
|
}
|
|
|
|
if($user_info['is_open_address'] == 2){
|
|
$data['ip_address'] = '中国';
|
|
}
|
|
|
|
//获取用户魅力 财富等级
|
|
|
|
$reslut = model('api/User')->get_user_charm_contribution_info($user_info);
|
|
|
|
$data['user_charm_contribution_info'] = $reslut['data'];
|
|
$user_nobility_info = model('user')->get_user_nobility_info($from_id);
|
|
$data['nobility_image'] = $user_nobility_info['data']['nobility_image'];
|
|
//收藏数量
|
|
$data['room_collect_num'] = 0;
|
|
$data['user_room_rid'] = 0; //用户房间
|
|
//获取用户所属房间
|
|
$map = [];
|
|
$map[] = ['room_owner_uid', '=', $from_id];
|
|
$rid_data = db::name('room')->where($map)->column('rid');
|
|
if (!empty($rid_data)) {
|
|
$map = [];
|
|
$map[] = ['rid', 'in', $rid_data];
|
|
$data['room_collect_num'] = db::name('user_collect_room')->where($map)->count();
|
|
$data['user_room_rid'] = current($rid_data);
|
|
}
|
|
//获取用户当前所在房间
|
|
|
|
$room_visitor=[];
|
|
$room_visitor['rid'] = 0;
|
|
$room_visitor['room_name'] = '';
|
|
$room_visitor['room_cover'] = '';
|
|
$data['user_room_visitor'] = $room_visitor;
|
|
|
|
$map = [];
|
|
$map[] = ['uid', '=', $from_id];
|
|
$room_visitor_rid = db::name('room_visitor')->where($map)->order('update_time desc')->value('rid');
|
|
if(!empty($room_visitor_rid)){
|
|
$map = [];
|
|
$map[] = ['rid', '=', $room_visitor_rid];
|
|
$room_info = db::name('room')->where($map)->field('rid,room_name,base64_room_name,room_cover')->find();
|
|
if(!empty($room_info)){
|
|
$data['user_room_visitor']['rid'] = $room_info['rid'];
|
|
$data['user_room_visitor']['room_name'] = mb_convert_encoding(base64_decode($room_info['base64_room_name']), 'UTF-8', 'UTF-8');
|
|
$data['user_room_visitor']['room_cover'] = localpath_to_netpath($room_info['room_cover']);
|
|
}
|
|
}
|
|
|
|
//获取用户陪玩游戏里列表
|
|
$player_list = [];
|
|
$map = [];
|
|
$map[] = ['a.uid', '=', $from_id];
|
|
$map[] = ['b.is_show', '=', 1];
|
|
$map[] = ['b.is_delete', '=', 1];
|
|
$model = Db::name('user_player')->alias('a')->join('yy_game b', 'a.gid = b.gid');
|
|
$player_list = $model->field('a.pid,a.gid,a.cover_image,a.order_duration,a.order_count,a.service_rate,a.price')->where($map)->order('order_count desc')->select();
|
|
$game_data = db::name('game')->column('game_name', 'gid');
|
|
foreach ($player_list as $k => &$v) {
|
|
$v['cover_image'] = localpath_to_netpath($v['cover_image']);
|
|
if (!empty($game_data[$v['gid']])) {
|
|
$v['game_name'] = $game_data[$v['gid']];
|
|
} else {
|
|
$v['game_name'] = "";
|
|
}
|
|
}
|
|
$data['user_player_list'] = $player_list;
|
|
//获取用户所有收到的礼物总数量
|
|
$receive_gift_list = [];
|
|
|
|
$map = [];
|
|
$map[] = ['receive_uid', '=', $from_id];
|
|
$receive_gift_list = db::name('user_send_gift')->field('gid,gift_name,gift_price,sum(gift_num) as gift_total_sum,gift_total_price')->where($map)->group('gid')->order('gift_num desc')->select();
|
|
if (!empty($receive_gift_list)) {
|
|
$gift_data = db::name('gift')->cache(10)->column('base_image', 'gid');
|
|
foreach ($receive_gift_list as $k => &$v) {
|
|
$v['base_image'] = localpath_to_netpath($gift_data[$v['gid']]);
|
|
}
|
|
}
|
|
$data['receive_gift_list'] = $receive_gift_list;
|
|
//获取用户相册
|
|
$user_albums_list = [];
|
|
$map = [];
|
|
$map[] = ['uid', '=', $from_id];
|
|
$map[] = ['is_delete', '=', 1];
|
|
$user_albums_list = db::name('user_albums')->field('aid,image')->where($map)->order('aid desc')->limit(30)->select();
|
|
foreach ($user_albums_list as $k => &$v) {
|
|
$v['image'] = localpath_to_netpath($v['image']);
|
|
}
|
|
$data['user_albums_list'] = $user_albums_list;
|
|
|
|
//判断是否关注
|
|
$uid_follow = db::name('user_follow')->where(['uid' => $uid, 'follow_uid' => $from_id])->find();
|
|
$from_follow = db::name('user_follow')->where(['uid' => $from_id, 'follow_uid' => $uid])->find();
|
|
$data['is_follow'] = 1; //是否已关注关注
|
|
$data['is_befollow'] = 1; //是否被关注
|
|
if (!empty($uid_follow)) {
|
|
$data['is_follow'] = 2;
|
|
}
|
|
if (!empty($from_follow)) {
|
|
$data['is_befollow'] = 2;
|
|
}
|
|
|
|
//cp数量
|
|
$data['cp_num'] = 0;
|
|
//CP信息
|
|
$user_cp_info = model('Coupling')->user_coupling_info($from_id);
|
|
if($user_cp_info['data']['is_have_cp'] == 1){
|
|
$data['cp_num'] = 1;
|
|
}
|
|
//是否已被我拉黑
|
|
$is_black = Db::name('user_black')->where(['uid'=>$uid,'receive_uid'=>$from_id])->find();
|
|
$data['is_black'] = $is_black?1:0;
|
|
|
|
//加入的公会
|
|
$is_join_guild = 2;
|
|
$data['is_join_guild'] = 2;
|
|
$data['guild_info'] = (object)[];
|
|
$join_guild = db::name('user_guild')->where(['uid'=>$from_id,'status'=>1,'is_delete'=>1])->find();
|
|
if(!empty($join_guild)){
|
|
$guild_info = db::name('guild')
|
|
->alias('g')
|
|
->join('yy_user u','u.uid = g.uid')
|
|
->where(['g.id'=>$join_guild['guild_id'],'g.is_delete'=>1,'g.is_show'=>1])
|
|
->field('g.*,u.head_pic as ghz_head_pic,u.base64_nick_name as ghz_nick_name')
|
|
->find();
|
|
if(!empty($guild_info)){
|
|
$guild_info['guild_name'] = mb_convert_encoding(base64_decode($guild_info['base64_guild_name']), 'UTF-8', 'UTF-8');
|
|
$guild_info['cover'] = localpath_to_netpath($guild_info['cover']);
|
|
|
|
$guild_info['ghz_nick_name'] = mb_convert_encoding(base64_decode($guild_info['ghz_nick_name']), 'UTF-8', 'UTF-8');
|
|
$guild_info['ghz_head_pic'] = localpath_to_netpath($guild_info['ghz_head_pic']);
|
|
$data['guild_info'] = $guild_info;
|
|
$data['is_join_guild'] = 1;
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ['code' => 200, 'msg' => '获取成功', 'data' => $data];
|
|
}
|
|
|
|
//获取实名认证状态
|
|
public function get_player_real_status($uid)
|
|
{
|
|
$user_info = db::name('user')->find($uid);
|
|
if ($user_info['is_real'] == 1) {
|
|
return ['code' => 200, 'msg' => '已实名', 'data' => null];
|
|
} else {
|
|
return ['code' => 201, 'msg' => '未实名', 'data' => null];
|
|
}
|
|
}
|
|
|
|
//实名信息提交
|
|
public function real_name_authentication($uid, $real_name, $card_id, $identity1, $identity2)
|
|
{
|
|
|
|
if (empty($real_name)) {
|
|
return ['code' => 201, 'msg' => '真实姓名必须', 'data' => null];
|
|
}
|
|
if (empty($card_id)) {
|
|
return ['code' => 201, 'msg' => '身份证号必须', 'data' => null];
|
|
}
|
|
|
|
// if (empty($identity1)) {
|
|
// return ['code' => 201, 'msg' => '身份证正面必须', 'data' => null];
|
|
// }
|
|
|
|
// if (empty($identity2)) {
|
|
// return ['code' => 201, 'msg' => '身份证反面必须', 'data' => null];
|
|
// }
|
|
$map = [];
|
|
$map[] = ['card_id', '=', $card_id];
|
|
|
|
$user_count = db::name('user')->where($map)->count();
|
|
if($user_count > 2) {
|
|
return ['code' => 201, 'msg' => '该身份证已认证两个账号,不能再认证', 'data' => null];
|
|
}
|
|
// if (!empty($user_info) && $user_info['uid'] != $uid) {
|
|
// // return ['code' => 201, 'msg' => '该身份证号已被使用', 'data' => null];
|
|
// }
|
|
$month_time = strtotime(date("Y-m-01"));
|
|
$real_month_time = 0;
|
|
$user_info = db::name('user')->find($uid);
|
|
if ($user_info['is_real'] == 1) {
|
|
if($month_time == $user_info['real_month_time']){
|
|
return ['code' => 201, 'msg' => '本月无法再次换绑身份证号', 'data' => null];
|
|
}
|
|
$real_month_time = $month_time;
|
|
}
|
|
|
|
if ($user_info['is_real'] == 3) {
|
|
return ['code' => 201, 'msg' => '实名审核中,请勿重复提交', 'data' => null];
|
|
}
|
|
|
|
$age = getAgeId($card_id);
|
|
if(!$age){
|
|
return ['code' => 201, 'msg' => '该身份证号未满18岁', 'data' => null];
|
|
}
|
|
|
|
//调用第三方实名认证接口
|
|
$reslut = model('api/AliRealNameVerify')->real_name_verify($real_name, $card_id);
|
|
if($reslut['code'] == 201){
|
|
return ['code' => 201, 'msg' => $reslut['msg'], 'data' => null];
|
|
}
|
|
|
|
$map = [];
|
|
$map[] = ['uid', '=', $uid];
|
|
$map[] = ['is_real', '=', 2];
|
|
$data = [];
|
|
$data['is_real'] = 1;
|
|
$data['real_name'] = $real_name;
|
|
$data['card_id'] = $card_id;
|
|
$data['identity1'] = $identity1;
|
|
$data['identity2'] = $identity2;
|
|
$data['real_month_time'] = $real_month_time;
|
|
$data['update_time'] = time();
|
|
|
|
// 启动事务
|
|
Db::startTrans();
|
|
try {
|
|
//提交认证
|
|
$reslut = db::name('user')->where($map)->update($data);
|
|
if (!$reslut) {
|
|
Db::rollback();
|
|
return ['code' => 201, 'msg' => '提交失败', 'data' => null];
|
|
}
|
|
|
|
//是否已创建过房间
|
|
$room_info = db::name('room')->where('room_owner_uid', $uid)->find();
|
|
if(empty($room_info)){
|
|
//创建房间
|
|
$cate_id = 18;
|
|
$room_password = '';
|
|
$room_cover = '/uploads/head_pic/head_pic.png';
|
|
$room_intro = '本房间严禁刷屏,禁止非法广告及宣传,禁止引战、地域黑、言语攻击等。';
|
|
$room_background_id = db::name('room_background')->where(['is_delete' => 1,'status' => 1])->order('bid asc')->value('bid');
|
|
$room_create = model('room')->user_create_room($uid, $user_info['nick_name'], $cate_id, $user_info['head_pic'], $room_password, $room_intro, $room_background_id);
|
|
if($room_create['code'] != 200){
|
|
Db::rollback();
|
|
return ['code' => 201, 'msg' => $room_create['msg'], 'data' => null];
|
|
}
|
|
}
|
|
|
|
//如果已申请、加入工会 更新工会信息
|
|
$guild_list = Db::name('user_guild')->where(['status' => [1,2], 'is_delete' => 1, 'rid' => 0, 'uid' => $uid])->select();
|
|
if($guild_list) {
|
|
$rid = Db::name('room')->where(['room_owner_uid' => $uid])->value('rid');
|
|
$result = Db::name('user_guild')->where(['status' => [1,2], 'is_delete' => 1, 'rid' => 0, 'uid' => $uid])->update(['rid' => $rid, 'card_id' => $card_id]);
|
|
if(!$result) {
|
|
return ['code' => 201, 'msg' => '创建失败', 'data' => null];
|
|
}
|
|
}
|
|
// 提交事务
|
|
Db::commit();
|
|
return ['code' => 200, 'msg' => '开启成功', 'data' => null];
|
|
} catch (\Exception $e) {
|
|
// 回滚事务
|
|
dump($e);
|
|
Db::rollback();
|
|
return ['code' => 201, 'msg' => '提交失败', 'data' => null];
|
|
}
|
|
|
|
// $reslut = db::name('user')->where($map)->update($data);
|
|
// if ($reslut) {
|
|
// return ['code' => 200, 'msg' => '提交成功', 'data' => null];
|
|
// } else {
|
|
// return ['code' => 201, 'msg' => '提交失败', 'data' => null];
|
|
// }
|
|
}
|
|
|
|
|
|
//申请陪玩
|
|
public function apply_play_game($uid, $gid, $lid, $price, $skill_image, $cover_image, $sound, $sound_duration, $introduction)
|
|
{
|
|
$map = [];
|
|
$map[] = ['uid', '=', $uid];
|
|
$map[] = ['gid', '=', $gid];
|
|
$palyer_info = db::name('user_player')->where($map)->find();
|
|
if (!empty($palyer_info)) {
|
|
return ['code' => 201, 'msg' => '该游戏陪玩您已申请', 'data' => null];
|
|
}
|
|
$game_info = db::name('game')->find($gid);
|
|
if (empty($game_info)) {
|
|
return ['code' => 201, 'msg' => '陪玩游戏不存在', 'data' => null];
|
|
}
|
|
$map = [];
|
|
$map[] = ['lid', '=', $lid];
|
|
$map[] = ['gid', '=', $gid];
|
|
$game_skill_level_info = db::name('game_skill_level')->where($map)->find();
|
|
if (empty($game_skill_level_info)) {
|
|
return ['code' => 201, 'msg' => '陪玩游戏等级不存在', 'data' => null];
|
|
}
|
|
if (empty($skill_image)) {
|
|
return ['code' => 201, 'msg' => '陪玩技能图不能为空', 'data' => null];
|
|
}
|
|
if (empty($cover_image)) {
|
|
return ['code' => 201, 'msg' => '封面图不能为空', 'data' => null];
|
|
}
|
|
$data = [];
|
|
$data['uid'] = $uid;
|
|
$data['gid'] = $gid;
|
|
$data['lid'] = $lid;
|
|
$data['price'] = $price;
|
|
$data['skill_image'] = $skill_image;
|
|
$data['cover_image'] = $cover_image;
|
|
$data['sound'] = $sound;
|
|
$data['sound_duration'] = $sound_duration;
|
|
$data['introduction'] = $introduction;
|
|
$data['is_business'] = 1; //默认接单中
|
|
$data['status'] = 1; //默认审核中
|
|
$data['add_time'] = time();
|
|
$data['update_time'] = time();
|
|
$validate = validate('admin/UserPlayer');
|
|
$reslut = $validate->scene('apiAdd')->check($data);
|
|
if ($reslut !== true) {
|
|
return ['code' => 201, 'msg' => $validate->getError(), 'data' => null];
|
|
}
|
|
$reslut = model('admin/UserPlayer')->save($data);
|
|
if ($reslut) {
|
|
return ['code' => 200, 'msg' => '提交成功,请等待审核', 'data' => null];
|
|
} else {
|
|
return ['code' => 201, 'msg' => '提交失败', 'data' => null];
|
|
}
|
|
}
|
|
|
|
|
|
//修改 陪玩信息
|
|
public function edit_play_game($uid, $gid, $lid, $price, $skill_image, $cover_image, $sound, $sound_duration, $introduction)
|
|
{
|
|
|
|
$game_info = db::name('game')->find($gid);
|
|
if (empty($game_info)) {
|
|
return ['code' => 201, 'msg' => '陪玩游戏不存在', 'data' => null];
|
|
}
|
|
$map = [];
|
|
$map[] = ['lid', '=', $lid];
|
|
$map[] = ['gid', '=', $gid];
|
|
$game_skill_level_info = db::name('game_skill_level')->where($map)->find();
|
|
if (empty($game_skill_level_info)) {
|
|
return ['code' => 201, 'msg' => '陪玩游戏等级不存在', 'data' => null];
|
|
}
|
|
if (empty($skill_image)) {
|
|
return ['code' => 201, 'msg' => '陪玩技能图不能为空', 'data' => null];
|
|
}
|
|
if (empty($cover_image)) {
|
|
return ['code' => 201, 'msg' => '封面图不能为空', 'data' => null];
|
|
}
|
|
|
|
$map = [];
|
|
$map[] = ['uid', '=', $uid];
|
|
$map[] = ['gid', '=', $gid];
|
|
$pid = db::name('user_player')->where($map)->value('pid');
|
|
if (empty($pid)) {
|
|
return ['code' => 201, 'msg' => '陪玩信息不存在', 'data' => null];
|
|
}
|
|
|
|
$data = [];
|
|
$data['uid'] = $uid;
|
|
$data['lid'] = $lid;
|
|
$data['price'] = $price;
|
|
$data['skill_image'] = $skill_image;
|
|
$data['cover_image'] = $cover_image;
|
|
$data['sound'] = $sound;
|
|
$data['sound_duration'] = $sound_duration;
|
|
$data['introduction'] = $introduction;
|
|
$data['is_business'] = 1; //默认接单中
|
|
$data['status'] = 1; //默认审核中
|
|
$data['update_time'] = time();
|
|
$validate = validate('admin/UserPlayer');
|
|
$reslut = $validate->scene('apiEdit')->check($data);
|
|
if ($reslut !== true) {
|
|
return ['code' => 201, 'msg' => $validate->getError(), 'data' => null];
|
|
}
|
|
$reslut = db::name('user_player')->where(['pid' => $pid])->update($data);
|
|
if ($reslut) {
|
|
return ['code' => 200, 'msg' => '提交成功,请等待审核', 'data' => null];
|
|
} else {
|
|
return ['code' => 201, 'msg' => '提交失败', 'data' => null];
|
|
}
|
|
}
|
|
|
|
|
|
public function get_player_game_list($uid)
|
|
{
|
|
$map = [];
|
|
$map[] = ['is_show', '=', 1];
|
|
$map[] = ['is_delete', '=', 1];
|
|
$list = db::name('game')->field('gid,game_name,game_ico,game_ico1,game_ico2,sort')->where($map)->order('sort desc')->select();
|
|
|
|
foreach ($list as $k => &$v) {
|
|
$v['status'] = 0;
|
|
$v['game_ico'] = localpath_to_netpath($v['game_ico']);
|
|
$v['game_ico1'] = localpath_to_netpath($v['game_ico1']);
|
|
$v['game_ico2'] = localpath_to_netpath($v['game_ico2']);
|
|
$map = [];
|
|
$map[] = ['uid', '=', $uid];
|
|
$map[] = ['gid', '=', $v['gid']];
|
|
$status = db::name('user_player')->where($map)->value('status');
|
|
|
|
if (!empty($status)) {
|
|
$v['status'] = $status;
|
|
}
|
|
}
|
|
|
|
return ['code' => 200, 'msg' => '获取成功', 'data' => $list];
|
|
}
|
|
//获取提交审核状态详情
|
|
public function get_apply_status($uid, $gid)
|
|
{
|
|
$map = [];
|
|
$map[] = ['uid', '=', $uid];
|
|
$map[] = ['gid', '=', $gid];
|
|
$palyer_info = db::name('user_player')->field('gid,status,remarks')->where($map)->find();
|
|
if (empty($palyer_info)) {
|
|
return ['code' => 201, 'msg' => '信息不存在', 'data' => null];
|
|
}
|
|
return ['code' => 200, 'msg' => '获取成功', 'data' => $palyer_info];
|
|
}
|
|
//获取提交详情
|
|
public function get_apply_info($uid, $gid)
|
|
{
|
|
|
|
$map = [];
|
|
$map[] = ['uid', '=', $uid];
|
|
$map[] = ['gid', '=', $gid];
|
|
$player_info = db::name('user_player')->field('gid,lid,price,skill_image,cover_image,sound,sound_duration,introduction,status,remarks')->where($map)->find();
|
|
if (empty($player_info)) {
|
|
return ['code' => 201, 'msg' => '信息不存在', 'data' => null];
|
|
}
|
|
$game = db::name('game')->field('game_name,cover_image,skill_image')->where(['gid' => $gid])->find();
|
|
$player_info['sound'] = localpath_to_netpath($player_info['sound']);
|
|
$player_info['skill_image'] = localpath_to_netpath($player_info['skill_image']);
|
|
$player_info['cover_image'] = localpath_to_netpath($player_info['cover_image']);
|
|
$player_info['game_level_name'] = db::name('game_skill_level')->where(['lid' => $player_info['lid']])->value('game_level_name');
|
|
$player_info['game_name'] = $game['game_name'];
|
|
$player_info['game_cover_image'] = localpath_to_netpath($game['cover_image']);
|
|
$player_info['game_skill_image'] = localpath_to_netpath($game['skill_image']);
|
|
|
|
return ['code' => 200, 'msg' => '获取成功', 'data' => $player_info];
|
|
}
|
|
|
|
//获取陪玩游戏 信息 及列表
|
|
public function get_player_game_lists($pid)
|
|
{
|
|
|
|
$map = [];
|
|
$map[] = ['pid', '=', $pid];
|
|
$palyer_info = db::name('user_player')->field('pid,uid,gid,price,status')->where($map)->find();
|
|
$game_name = db::name('game')->where(['gid' => $palyer_info['gid']])->value('game_name');
|
|
$user_info = db::name('user')->where(['uid' => $palyer_info['uid']])->find();
|
|
|
|
$arr1 = [];
|
|
$arr1['pid'] = $palyer_info['pid'];
|
|
$arr1['price'] = $palyer_info['price'];
|
|
$arr1['game_name'] = $game_name;
|
|
$arr1['nick_name'] = mb_convert_encoding(base64_decode($user_info['base64_nick_name']), 'UTF-8', 'UTF-8');
|
|
$arr1['head_pic'] = localpath_to_netpath($user_info['head_pic']);
|
|
|
|
$map = [];
|
|
$map[] = ['uid', '=', $palyer_info['uid']];
|
|
$arr2 = db::name('user_player')->alias('a')->join('yy_game b', 'a.gid = b.gid')->field('a.pid,a.price,b.game_name')->where($map)->select();
|
|
|
|
if ($user_info['is_real'] != 1 || $palyer_info['status'] != 2) {
|
|
$data['palyer_game_list'] = [];
|
|
} else {
|
|
$data['palyer_game_list'] = $arr2;
|
|
}
|
|
$data['palyer_info'] = $arr1;
|
|
return ['code' => 200, 'msg' => '获取成功', 'data' => $data];
|
|
}
|
|
|
|
//首页搜索
|
|
public function search($uid, $keywords)
|
|
{
|
|
if (empty($keywords)) {
|
|
$data = [];
|
|
$data['user'] = [];
|
|
$data['play'] = [];
|
|
$data['room'] = [];
|
|
return ['code' => 200, 'msg' => '获取成功', 'data' => $data];
|
|
}
|
|
//记录所有关键词
|
|
$data = [];
|
|
$data['uid'] = $uid;
|
|
$data['search_content'] = $keywords;
|
|
$data['add_time'] = time();
|
|
$data['update_time'] = time();
|
|
db::name('user_search')->insert($data);
|
|
|
|
$map = [];
|
|
$map[] = ['uid|nick_name|special_uid', 'like', '%' . $keywords . '%'];
|
|
$map[] = ['login_status', '<>', 3];
|
|
$arr1 = db::name('user')->where($map)->field('uid,base64_nick_name,head_pic,special_uid')->limit(0, 30)->select();
|
|
if (!empty($arr1)) {
|
|
foreach ($arr1 as $k => &$v) {
|
|
$v['nick_name'] = mb_convert_encoding(base64_decode($v['base64_nick_name']), 'UTF-8', 'UTF-8');
|
|
$v['head_pic'] = localpath_to_netpath($v['head_pic']);
|
|
unset($v['base64_nick_name']);
|
|
}
|
|
}
|
|
|
|
// $map = [];
|
|
// $map[] = ['b.uid|b.nick_name|b.special_uid', 'like', '%' . $keywords . '%'];
|
|
// $map[] = ['a.status', '=', 2];
|
|
// $model = Db::name('user_player')->alias('a')->join('yy_user b', 'a.uid = b.uid');
|
|
// $arr2 = $model->where($map)->field('a.pid,a.skill_image,a.cover_image,a.order_count,a.price,b.uid,b.base64_nick_name,b.head_pic,b.special_uid')->limit(0, 30)->select();
|
|
// if (!empty($arr2)) {
|
|
// foreach ($arr2 as $k => &$v) {
|
|
// $v['nick_name'] = mb_convert_encoding(base64_decode($v['base64_nick_name']), 'UTF-8', 'UTF-8');
|
|
// $v['head_pic'] = localpath_to_netpath($v['head_pic']);
|
|
// $v['skill_image'] = localpath_to_netpath($v['skill_image']);
|
|
// $v['cover_image'] = localpath_to_netpath($v['cover_image']);
|
|
// unset($v['base64_nick_name']);
|
|
// }
|
|
// }
|
|
|
|
$map = [];
|
|
$map[] = ['b.uid|b.nick_name|b.special_uid|a.room_name|a.room_number', 'like', '%' . $keywords . '%'];
|
|
$map[] = ['a.room_status', '=', 1];
|
|
$map[] = ['b.login_status', '<>', 3];
|
|
$model = Db::name('room')->alias('a')->join('yy_user b', 'a.room_owner_uid = b.uid');
|
|
$arr3 = $model->where($map)->field('a.rid,a.room_number,a.room_name,a.room_cover,b.uid,b.base64_nick_name,b.head_pic,b.special_uid')->limit(0, 30)->select();
|
|
if (!empty($arr3)) {
|
|
foreach ($arr3 as $k => &$v) {
|
|
$v['nick_name'] = mb_convert_encoding(base64_decode($v['base64_nick_name']), 'UTF-8', 'UTF-8');
|
|
$v['head_pic'] = localpath_to_netpath($v['head_pic']);
|
|
$v['room_cover'] = localpath_to_netpath($v['room_cover']);
|
|
unset($v['base64_nick_name']);
|
|
}
|
|
}
|
|
|
|
$data = [];
|
|
$data['user'] = $arr1;
|
|
$data['play'] = [];
|
|
$data['room'] = $arr3;
|
|
return ['code' => 200, 'msg' => '获取成功', 'data' => $data];
|
|
}
|
|
|
|
//申请陪玩可选金额
|
|
public function get_player_price_list()
|
|
{
|
|
$player_unit_price_list = get_system_config('player_unit_price_list');
|
|
$data = explode(',', $player_unit_price_list);
|
|
return ajaxReturn(200, '获取成功', $data);
|
|
}
|
|
}
|