683 lines
29 KiB
PHP
683 lines
29 KiB
PHP
<?php
|
|
/**
|
|
* @Created by PhpStorm.
|
|
* @Author:Soar
|
|
* @Time:2023/7/17 9:14
|
|
*/
|
|
|
|
namespace app\index\controller;
|
|
|
|
use app\common\controller\Frontend;
|
|
use think\Exception;
|
|
use think\Request;
|
|
use think\response\Json;
|
|
use app\index\controller\Wxmb;
|
|
use app\admin\model\Renzheng;
|
|
use app\admin\model\Club;
|
|
use app\admin\model\ClubPlayercheck;
|
|
use app\admin\model\ClubInvate;
|
|
use think\Db;
|
|
use app\admin\model\shopro\ClubThirdOauth;
|
|
|
|
class Players extends Frontend
|
|
{
|
|
protected $noNeedLogin = '*';
|
|
protected $noNeedRight = '*';
|
|
protected $layout = 'defaults';
|
|
|
|
public function _initialize()
|
|
{
|
|
parent::_initialize();
|
|
}
|
|
|
|
public function __construct(Request $request = null)
|
|
{
|
|
parent::__construct($request);
|
|
$this->model = new \app\common\model\Players();
|
|
}
|
|
|
|
public function sociaty(){
|
|
$clubinvate = new ClubInvate();
|
|
$player_info = $this->model->where("member_id", $this->auth->id)->find();
|
|
|
|
if (empty($player_info)){
|
|
$this->error(__("请先申请成为飞手!"), url('players/registeredflyers')) ;
|
|
}
|
|
|
|
if ($player_info['player_status'] != 9){
|
|
$this->error(__("您还不是正式飞手!"), url('user/index'));
|
|
}
|
|
$is_joinclub = 0;
|
|
$club_invateres = $clubinvate->where('player_id',$player_info['id'])->where('status',5)->where('deletetime',null)->find();
|
|
$club_invateres1 = $clubinvate->where('player_id',$player_info['id'])->where('status',9)->where('deletetime',null)->find();
|
|
$club_invateres2 = $clubinvate->where('player_id',$player_info['id'])->where('status',6)->where('deletetime',null)->find();
|
|
if(!empty($club_invateres) || !empty($club_invateres1) || !empty($club_invateres2)) $is_joinclub = 1;
|
|
|
|
$this->view->assign('is_joinclub', $is_joinclub);
|
|
$this->view->assign('title', "飞手公会");
|
|
$this->view->assign('is_sociaty', $player_info['is_sociaty']);
|
|
$this->view->assign('playerinfo', $player_info);
|
|
return $this->view->fetch();
|
|
}
|
|
|
|
public function index()
|
|
{
|
|
//获取用户id
|
|
$user_id = $this->auth->id;
|
|
$club_playercheck = new ClubPlayercheck();
|
|
|
|
if (empty($user_id)){
|
|
$this->error("请先登录!",url('user/login'));
|
|
}
|
|
// var_dump($this->auth->member_type);exit;
|
|
$players_info = $this->model
|
|
->where('member_id', $user_id)
|
|
->find();
|
|
|
|
if (empty($players_info) ){
|
|
$this->view->assign('playerinfo', $players_info);
|
|
return $this->redirect('players/registeredflyers');
|
|
}
|
|
|
|
// $club_playercheckres = $club_playercheck->where('player_id',$players_info['id'])->where('status in (2,4,5)')->find();
|
|
// $club_playercheckres1 = $club_playercheck->where('player_id',$players_info['id'])->where('status',1)->find();
|
|
// if(!empty($club_playercheckres)) $this->view->assign('user_player_status', 2);
|
|
// if(!empty($club_playercheckres1)) $this->view->assign('user_player_status', 1);
|
|
|
|
|
|
if ($players_info->player_status == \app\common\model\Players::PLAYERS_MODIFY) {
|
|
$players_info->pass_centent =
|
|
db("player_check")->where(['after_status' => 1, 'player_id' => $players_info->id])->
|
|
order('id', 'DESC')->find();
|
|
}
|
|
if ($players_info->player_status == \app\common\model\Players::PLAYERS_NO_PASS) {
|
|
// 如果拒绝获取拒绝理由
|
|
$players_info->pass_centent =
|
|
db("player_check")->where(['after_status' => 2, 'player_id' => $players_info->id])->
|
|
order('id', 'DESC')->find();
|
|
|
|
|
|
}
|
|
|
|
$this->view->assign('title', "身份认证");
|
|
$this->view->assign('players', $players_info);
|
|
return $this->view->fetch();
|
|
}
|
|
|
|
public function authenticationflayers()
|
|
{
|
|
//获取用户id
|
|
$user_id = $this->auth->id;
|
|
|
|
if (empty($user_id)){
|
|
$this->error("请先登录!",url('user/login'));
|
|
}
|
|
|
|
$players_info = $this->model
|
|
->where('member_id', $user_id)
|
|
->find();
|
|
|
|
if (empty($players_info)){
|
|
$this->view->assign('playerinfo', $players_info);
|
|
return $this->redirect('players/registeredflyers');
|
|
}
|
|
|
|
$this->view->assign('title', "身份认证");
|
|
$this->view->assign('players', $players_info);
|
|
return $this->view->fetch();
|
|
}
|
|
|
|
/**
|
|
* 重新申请
|
|
* @Author:Soar
|
|
* @Time:2023/10/8 15:17
|
|
* @param $ids
|
|
* @return void
|
|
*/
|
|
public function reapply($ids = null)
|
|
{
|
|
$this->view->assign('title', "重新申请");
|
|
|
|
if ($this->request->isPost()) {
|
|
$id = $this->request->post("id");
|
|
$add_data['real_name'] = $this->request->post("real_name");
|
|
$add_data['gender'] = $this->request->post("gender");
|
|
$add_data['birthday'] = $this->request->post("birthday");
|
|
$add_data['age'] = $this->request->post("age");
|
|
$add_data['country'] = $this->request->post("country");
|
|
$add_data['province'] = $this->request->post("province");
|
|
$add_data['city'] = $this->request->post("city");
|
|
$add_data['district'] = $this->request->post("district");
|
|
$add_data['address'] = $this->request->post("address");
|
|
$add_data['player_pic'] = $this->request->post("player_pic");
|
|
$add_data['experience'] = $this->request->post("experience");
|
|
$add_data['guarder_name'] = $this->request->post("guarder_name");
|
|
$add_data['guarder_phone'] = $this->request->post("guarder_phone");
|
|
$add_data['guarder_card_number'] = $this->request->post("guarder_card_number");
|
|
$add_data['guarder_card_type'] = $this->request->post("guarder_card_type");
|
|
$add_data['guarder_card_front_view'] = $this->request->post("guarder_card_front_view");
|
|
$add_data['guarder_card_back_view'] = $this->request->post("guarder_card_back_view");
|
|
$add_data['card_type'] = $this->request->post("card_type");
|
|
$add_data['card_number'] = $this->request->post("card_number");
|
|
$add_data['card_front_view'] = $this->request->post("card_front_view");
|
|
$add_data['card_back_view'] = $this->request->post("card_back_view");
|
|
$add_data['card_view_same'] = $this->request->post("card_view_same");
|
|
$add_data['guarder_card_view_same'] = $this->request->post("guarder_card_view_same");
|
|
$add_data['asfc_user'] = $this->request->post("asfc_user");
|
|
$add_data['membership_id'] = $this->request->post("membership_id");
|
|
$add_data['flight_number'] = $this->request->post("flight_number");
|
|
$add_data['club_members'] = $this->request->post("club_members");
|
|
$add_data['club_name'] = $this->request->post("club_name");
|
|
$add_data['duties'] = $this->request->post("duties");
|
|
$add_data['counselor_name'] = $this->request->post("counselor_name");
|
|
$add_data['post_type'] = $this->request->post("post_type");
|
|
|
|
$this->registeredFlyer($id, $add_data);
|
|
}
|
|
//获取用户id
|
|
$user_id = $this->auth->id;
|
|
|
|
if (empty($user_id)){
|
|
$this->error("请先登录!",url('user/login'));
|
|
}
|
|
|
|
$player_info = $this->model
|
|
->where('member_id', $user_id)
|
|
->find();
|
|
|
|
$this->view->assign('playerinfo', $player_info);
|
|
|
|
return $this->view->fetch();
|
|
}
|
|
|
|
public function edit($ids = null)
|
|
{
|
|
$this->view->engine->layout('layout/defaultsRegister');
|
|
$this->view->assign('title', "修改信息");
|
|
|
|
if ($this->request->isPost()) {
|
|
$id = $this->request->post("id");
|
|
$add_data['real_name'] = $this->request->post("real_name");
|
|
$add_data['gender'] = $this->request->post("gender");
|
|
$add_data['birthday'] = $this->request->post("birthday");
|
|
$add_data['age'] = $this->request->post("age");
|
|
$add_data['country'] = $this->request->post("country");
|
|
$add_data['province'] = $this->request->post("province");
|
|
$add_data['city'] = $this->request->post("city");
|
|
$add_data['district'] = $this->request->post("district");
|
|
$add_data['address'] = $this->request->post("address");
|
|
$add_data['player_pic'] = $this->request->post("player_pic");
|
|
$add_data['experience'] = $this->request->post("experience");
|
|
$add_data['guarder_name'] = $this->request->post("guarder_name");
|
|
$add_data['guarder_phone'] = $this->request->post("guarder_phone");
|
|
$add_data['guarder_card_number'] = $this->request->post("guarder_card_number");
|
|
$add_data['guarder_card_type'] = $this->request->post("guarder_card_type");
|
|
$add_data['guarder_card_front_view'] = $this->request->post("guarder_card_front_view");
|
|
$add_data['guarder_card_back_view'] = $this->request->post("guarder_card_back_view");
|
|
$add_data['card_type'] = $this->request->post("card_type");
|
|
$add_data['card_number'] = $this->request->post("card_number");
|
|
$add_data['card_front_view'] = $this->request->post("card_front_view");
|
|
$add_data['card_back_view'] = $this->request->post("card_back_view");
|
|
$add_data['card_view_same'] = $this->request->post("card_view_same");
|
|
$add_data['guarder_card_view_same'] = $this->request->post("guarder_card_view_same");
|
|
$add_data['asfc_user'] = $this->request->post("asfc_user");
|
|
$add_data['membership_id'] = $this->request->post("membership_id");
|
|
$add_data['flight_number'] = $this->request->post("flight_number");
|
|
$add_data['club_members'] = $this->request->post("club_members");
|
|
$add_data['club_name'] = $this->request->post("club_name");
|
|
$add_data['duties'] = $this->request->post("duties");
|
|
$add_data['counselor_name'] = $this->request->post("counselor_name");
|
|
$add_data['post_type'] = $this->request->post("post_type");
|
|
$add_data['eng_name'] = $this->request->post("eng_name");
|
|
$add_data['fai_number'] = $this->request->post("fai_number");
|
|
|
|
$this->registeredFlyer($id, $add_data);
|
|
}
|
|
//获取用户id
|
|
$user_id = $this->auth->id;
|
|
|
|
if (empty($user_id)){
|
|
$this->error("请先登录!",url('user/login'));
|
|
}
|
|
|
|
$player_info = $this->model
|
|
->where('member_id', $user_id)
|
|
->find();
|
|
|
|
$this->view->assign('playerinfo', $player_info);
|
|
|
|
return $this->view->fetch();
|
|
}
|
|
|
|
public function registeredflyers($ids = null)
|
|
{
|
|
$this->view->engine->layout('layout/defaultsRegister');
|
|
$this->view->assign('title', "注册飞手");
|
|
|
|
//获取用户id
|
|
$user_id = $this->auth->id;
|
|
|
|
if (empty($user_id)){
|
|
$this->error("请先登录!",url('user/login'));
|
|
}
|
|
|
|
$player_info = $this->model
|
|
->where('member_id', $user_id)
|
|
->find();
|
|
|
|
if($player_info && $player_info->player_status == 9){
|
|
return $this->redirect('players/index');
|
|
}
|
|
|
|
$this->view->assign('playerinfo', $player_info);
|
|
|
|
return $this->view->fetch();
|
|
}
|
|
|
|
/**
|
|
* @Author Soar
|
|
* @DESC 注册飞手
|
|
* @return json
|
|
*/
|
|
public function registeredFlyer($id, $add_data)
|
|
{
|
|
// var_dump(123);exit;
|
|
$post_type = $add_data['post_type'];
|
|
unset($add_data['post_type']);
|
|
|
|
$validate = [
|
|
["real_name", "require", '姓名不可为空!'],
|
|
["gender", "require", '请选择性别!'],
|
|
["birthday", "require", '出生日期不可为空!'],
|
|
["country", "require", '国籍不可为空!'],
|
|
["address", "require", '详细地址不可为空!'],
|
|
["player_pic", "require", '请上传证件照!'],
|
|
['card_front_view', 'require', "请上传正面证件照片"],
|
|
// ['card_back_view', 'require', "请上传{$add_data['card_type']}证件照片"],
|
|
['card_number', 'require', "请输入{$add_data['card_type']}证件号码"]
|
|
];
|
|
|
|
if ($add_data['country'] == "中国 China"){
|
|
array_push(
|
|
$validate,
|
|
['province', 'require', "请选择省份"],
|
|
['city', 'require', "请选择市"],
|
|
['district', 'require', "请选择区/县"]
|
|
);
|
|
}
|
|
// 如果是 ASFC 获取会员编号
|
|
if ($add_data['asfc_user'] == \app\common\model\Players::ASFC_VIP) {
|
|
array_push(
|
|
$validate,
|
|
['membership_id', 'require', '请填写 ASFC会员 证号!']
|
|
);
|
|
}
|
|
|
|
|
|
if ($add_data['club_members'] == \app\common\model\Players::CLUP_USER) {
|
|
array_push(
|
|
$validate,
|
|
['club_name', 'require', '请填写俱乐部名称!'],
|
|
['duties', 'require', '请填写所在俱乐部职务!'],
|
|
);
|
|
}
|
|
|
|
if ($add_data["country"] == "中国 China" && $add_data['age'] < \app\common\model\Players::ADULT) {
|
|
//监护人
|
|
array_push(
|
|
$validate,
|
|
['guarder_name', 'require', '请输入监护人姓名!'],
|
|
['guarder_phone', 'require', '请输入监护人手机号'],
|
|
['guarder_card_type', 'require', '请选择监护人证件类型'],
|
|
['guarder_card_number', 'require', "请输入监护人{$add_data['guarder_card_type']}证件号码"],
|
|
['guarder_card_front_view', 'require', "请上传监护人正面证件照片"],
|
|
// ['guarder_card_back_view', 'require', "请上传监护人{$add_data['guarder_card_type']}证件照片"]
|
|
);
|
|
|
|
//护照特殊判断
|
|
if ($add_data['guarder_card_type'] == \app\common\model\Players::CARD_TYPE[0]){
|
|
array_push(
|
|
$validate,
|
|
['guarder_card_view_same', 'require', "请选择人像页类型"]
|
|
);
|
|
}
|
|
//排除护照单页的情况,背面必传
|
|
if (!($add_data['guarder_card_type'] == \app\common\model\Players::CARD_TYPE[1] && isset($add_data["guarder_card_view_same"]) && $add_data["guarder_card_view_same"] == 2)) {
|
|
|
|
if ($add_data['guarder_card_type'] == \app\common\model\Players::CARD_TYPE[1]){
|
|
array_push(
|
|
$validate,
|
|
['guarder_card_back_view', 'require', "请上传监护人签名页照片"]
|
|
);
|
|
}
|
|
|
|
array_push(
|
|
$validate,
|
|
['card_back_view', 'require', "请上传反面证件照片"],
|
|
['guarder_card_back_view', 'require', "请上传监护人反面证件照片"]
|
|
);
|
|
|
|
}
|
|
|
|
//比较麻烦的判断
|
|
if ($add_data["guarder_card_type"] == \app\common\model\Players::CARD_TYPE[1] && $add_data["guarder_card_view_same"] == 2) {
|
|
$add_data["guarder_card_back_view"] = null;
|
|
} elseif ($add_data["guarder_card_type"] != "护照") {
|
|
$add_data["guarder_card_view_same"] = 1;
|
|
}
|
|
}else{
|
|
array_push(
|
|
$validate,
|
|
['card_type', 'require', '请选择证件类型!']
|
|
);
|
|
|
|
//护照特殊判断
|
|
if ($add_data['card_type'] == \app\common\model\Players::CARD_TYPE[0]){
|
|
array_push(
|
|
$validate,
|
|
['card_view_same', 'require', "请选择人像页类型"]
|
|
);
|
|
}
|
|
|
|
//排除护照单页的情况,背面必传
|
|
if (!($add_data['card_type'] == \app\common\model\Players::CARD_TYPE[1] && isset($add_data["card_view_same"]) && $add_data["card_view_same"] == 2)) {
|
|
|
|
if ($add_data['card_type'] == \app\common\model\Players::CARD_TYPE[1]){
|
|
array_push(
|
|
$validate,
|
|
['card_back_view', 'require', "请上传{$add_data['guarder_card_type']}签名页照片"]
|
|
);
|
|
}
|
|
array_push(
|
|
$validate,
|
|
['card_back_view', 'require', "请上传反面证件照片"]
|
|
);
|
|
}
|
|
|
|
//比较麻烦的判断
|
|
if ($add_data["card_type"] == "护照" && $add_data["card_view_same"] == 2) {
|
|
$add_data["card_back_view"] = null;
|
|
} elseif ($add_data["card_type"] != "护照") {
|
|
$add_data["card_view_same"] = 1;
|
|
}
|
|
}
|
|
$validate = new \think\Validate($validate);
|
|
|
|
if (!$validate->check($add_data)){
|
|
$this->error($validate->getError());
|
|
}
|
|
|
|
$playersModel = new \app\common\model\Players();
|
|
$playersinfo = $playersModel->getPlayers($this->auth->id);
|
|
|
|
try {
|
|
$add_data['member_id'] = $this->auth->id;
|
|
$add_data['club_id'] = 0;
|
|
$add_data['phone'] = $this->auth->mobile;
|
|
$add_data['id'] = $id;
|
|
$add_data['player_status'] = \app\common\model\Players::PLAYERS_REAPPLY;
|
|
$add_data['updated_at'] = date("Y-m-d H:i:s", time());
|
|
$playersinfo->save($add_data);
|
|
|
|
}catch (Exception $exception){
|
|
$this->error($exception->getMessage());
|
|
}
|
|
|
|
if (!empty($post_type) && $post_type == "json") {
|
|
return json(['code' => 1, 'data' => [], 'msg' => "提交成功"]);
|
|
}
|
|
//模板消息通知
|
|
$renzheng = new Renzheng();
|
|
$res = $renzheng->where('id',1)->find();
|
|
if(!empty($res)) $res = $res->toArray();
|
|
if($res['status'] == 1){
|
|
$wxmb = new Wxmb();
|
|
$wxmb->renzhengpush($add_data,$res['openid']);
|
|
}
|
|
$this->success("提交成功!", url('players/index'));
|
|
|
|
}
|
|
|
|
|
|
//飞手加入俱乐部
|
|
public function joinclub(){
|
|
$user_id = $this->auth->id;
|
|
// $club_model = new Club();
|
|
// $club_playercheck = new ClubPlayercheck();
|
|
$player_info = $this->model
|
|
->where('member_id', $user_id)
|
|
->find();
|
|
if(empty($player_info)){
|
|
$this->error('请先成为飞手');
|
|
}
|
|
$this->view->assign('title', "查找队伍");
|
|
return $this->view->fetch();
|
|
}
|
|
|
|
public function confirmed_player(){
|
|
$user_id = $this->auth->id;
|
|
$player_info = $this->model->where("member_id", $user_id)->find();
|
|
|
|
if (empty($player_info)){
|
|
$this->error(__("请先申请成为飞手!"), url('players/registeredflyers')) ;
|
|
}
|
|
|
|
if ($player_info['player_status'] != 9){
|
|
$this->error(__("您还不是正式飞手!"), url('user/index'));
|
|
}
|
|
}
|
|
//我的俱乐部
|
|
public function myclub(){
|
|
$this->view->assign('title', "我的队伍");
|
|
$this->confirmed_player();
|
|
$user_id = $this->auth->id;
|
|
$club_model = new Club();
|
|
$club_playercheck = new ClubPlayercheck();
|
|
$clubinvate = new ClubInvate();
|
|
$player_info = $this->model
|
|
->where('member_id', $user_id)
|
|
->find();
|
|
$clubinvate_res = $clubinvate->where('player_id',$player_info['id'])->where('status',6)->where('deletetime',null)->find();
|
|
if(!empty($clubinvate_res)) {
|
|
$club_info = $club_model->where('id',$clubinvate_res['club_id'])->find();
|
|
$this->view->assign('club_info', $club_info);
|
|
$this->view->assign('player_status', 2); //未加入公会已参加俱乐部
|
|
|
|
}else{
|
|
$invate_res1 = $clubinvate->where('player_id',$player_info['id'])->where('status',9)->where('deletetime',null)->find();
|
|
$invate_res2 = $clubinvate->where('player_id',$player_info['id'])->where('status',8)->where('deletetime',null)->find();
|
|
if(!empty($invate_res1) || !empty($invate_res2)){
|
|
if(!empty($invate_res1)){
|
|
$invate_res1 = $invate_res1->toArray();
|
|
$club_info1 = $club_model->where('id',$invate_res1['club_id'])->find();
|
|
$this->view->assign('club_name', $club_info1['name']);
|
|
$this->view->assign('player_status', 4); //待俱乐部上传协议
|
|
}
|
|
if(!empty($invate_res2)){
|
|
$invate_res2 = $invate_res2->toArray();
|
|
$club_info2 = $club_model->where('id',$invate_res2['club_id'])->find();
|
|
$this->view->assign('club_name', $club_info2['name']);
|
|
$this->view->assign('player_status', 5); //俱乐部重新上传协议
|
|
}
|
|
|
|
}else{
|
|
$invate_res = $clubinvate->where('player_id',$player_info['id'])->where('status',5)->where('deletetime',null)->find();
|
|
if(!empty($invate_res)){
|
|
$this->view->assign('player_status', 3); //待平台审核
|
|
}else{
|
|
if($player_info['is_sociaty'] == 1){
|
|
// var_dump(123);exit;
|
|
|
|
$this->view->assign('player_status', 1); //加入公会未参加俱乐部
|
|
//
|
|
}elseif($player_info['is_sociaty'] == ''){
|
|
$this->view->assign('player_status', 0); //未加入公会未参加俱乐部
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
// $res = $club_playercheck->where('player_id',$player_info['id'])->where('status',2)->find();
|
|
// if(empty($res)) $this->error('请先加入俱乐部');
|
|
return $this->view->fetch();
|
|
|
|
}
|
|
|
|
public function myinvate(){
|
|
$this->confirmed_player();
|
|
$user_id = $this->auth->id;
|
|
$club_model = new Club();
|
|
$club_playercheck = new ClubPlayercheck();
|
|
$clubinvate = new ClubInvate();
|
|
$page = $this->request->param('page');
|
|
$player_info = $this->model
|
|
->where('member_id', $user_id)
|
|
->find();
|
|
$invate_res = $clubinvate->where('player_id',$player_info['id'])->where('deletetime',null)->where('grass',null)->select();
|
|
$invate_res1 = $clubinvate->where('player_id',$player_info['id'])->where('deletetime',null)->where('grass',null)->page($page,10)->select();
|
|
foreach ($invate_res1 as &$val){
|
|
$club_res = $club_model->where('id',$val['club_id'])->find();
|
|
$val['club_name'] = $club_res['name'];
|
|
$val['updatetime'] = date('Y-m-d H:i:s',$val['updatetime']);
|
|
}
|
|
$data['total'] = count($invate_res);
|
|
$data['data'] = $invate_res1;
|
|
return json($data);
|
|
}
|
|
|
|
public function agree_invate(){
|
|
$this->confirmed_player();
|
|
$user_id = $this->auth->id;
|
|
$club_model = new Club();
|
|
$club_playercheck = new ClubPlayercheck();
|
|
$clubinvate = new ClubInvate();
|
|
$ClubThirdOauth = new ClubThirdOauth();
|
|
$Wxmb = new Wxmb();
|
|
$invate_id = $this->request->param('invate_id');
|
|
// var_dump($invate_id);exit;
|
|
$player_info = $this->model
|
|
->where('member_id', $user_id)
|
|
->find();
|
|
// var_dump($invate_id);exit;
|
|
$exist_invate = $clubinvate->where('id',$invate_id)->where('player_id',$player_info['id'])->find();
|
|
if(empty($exist_invate)) $this->error('异常请求',url('players/index'));
|
|
$jiaru_res = $clubinvate->where('player_id',$player_info['id'])->where('status',6)->where('deletetime',null)->select();
|
|
if(!empty($jiaru_res)) $this->error('您已加入俱乐部',url('players/index'));
|
|
$invate_res = $clubinvate->where('player_id',$player_info['id'])->where('deletetime',null)->select();
|
|
// 启动事务
|
|
// Db::startTrans();
|
|
// try{
|
|
// var_dump($invate_id);exit;
|
|
foreach ($invate_res as $val){
|
|
|
|
if($val['id'] != $invate_id){
|
|
// var_dump($val['id']);exit;
|
|
$clubinvate->save([
|
|
'deletetime' => time(),
|
|
// 'updatetime' => time(),
|
|
],['id' => $val['id']]);
|
|
}
|
|
}
|
|
// var_dump($invate_res);exit;
|
|
$res = $clubinvate->save([
|
|
'status' => 5,
|
|
// 'status' => 9,
|
|
// 'createtime' => time(),
|
|
'updatetime' => time(),
|
|
],['id' => $invate_id]);
|
|
// var_dump($res);exit;
|
|
|
|
$res1 = $this->model->save([
|
|
'is_sociaty' => null,
|
|
'updated_at' => date('Y-m-d H:i:s',time()),
|
|
],['id'=>$player_info['id']]);
|
|
// var_dump($res1);exit;
|
|
|
|
// } catch (\Exception $e) {
|
|
// // 回滚事务
|
|
// // var_dump($e);exit;
|
|
// Db::rollback();
|
|
// }
|
|
$club_info = $club_model->where('id',$exist_invate['club_id'])->find();
|
|
if(!empty($club_info)){
|
|
$oauth_res = $ClubThirdOauth->where('user_id',$club_info['user_id'])->find();
|
|
if(!empty($oauth_res)){
|
|
$oauth_res = $oauth_res->toArray();
|
|
$push_arr = array('title'=>'飞手已同意邀请','username'=> $player_info['real_name'],'type'=>'飞手确认');
|
|
$Wxmb->leaguepush($push_arr,$oauth_res['openid']);
|
|
}
|
|
}
|
|
|
|
$this->success('同意成功',url('players/index'));
|
|
}
|
|
|
|
public function reject_invate(){
|
|
$this->confirmed_player();
|
|
$user_id = $this->auth->id;
|
|
$club_model = new Club();
|
|
$club_playercheck = new ClubPlayercheck();
|
|
$clubinvate = new ClubInvate();
|
|
$ClubThirdOauth = new ClubThirdOauth();
|
|
$Wxmb = new Wxmb();
|
|
$invate_id = $this->request->param('invate_id');
|
|
$player_info = $this->model
|
|
->where('member_id', $user_id)
|
|
->find();
|
|
$exist_invate = $clubinvate->where('id',$invate_id)->where('player_id',$player_info['id'])->find();
|
|
if(empty($exist_invate)) $this->error('异常请求',url('players/index'));
|
|
$jiaru_res = $clubinvate->where('player_id',$player_info['id'])->where('status',6)->where('deletetime',null)->select();
|
|
if(!empty($jiaru_res)) $this->error('您已加入俱乐部');
|
|
$clubinvate->save([
|
|
'status' => 3,
|
|
// 'createtime' => time(),
|
|
'grass' => 1,
|
|
],['id' => $invate_id]);
|
|
|
|
//模板消息通知
|
|
$club_info = $club_model->where('id',$exist_invate['club_id'])->find();
|
|
if(!empty($club_info)){
|
|
$oauth_res = $ClubThirdOauth->where('user_id',$club_info['user_id'])->find();
|
|
if(!empty($oauth_res)){
|
|
$oauth_res = $oauth_res->toArray();
|
|
$push_arr = array('title'=>'飞手已拒绝邀请','username'=> $player_info['real_name'],'type'=>'飞手确认');
|
|
$Wxmb->leaguepush($push_arr,$oauth_res['openid']);
|
|
}
|
|
}
|
|
$this->success('拒绝成功');
|
|
}
|
|
|
|
public function all_club(){
|
|
header('Access-Control-Allow-Origin: *');
|
|
header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept");
|
|
header('Access-Control-Allow-Methods: GET,POST');
|
|
$this->confirmed_player();
|
|
$club_model = new Club();
|
|
$user_id = $this->auth->id;
|
|
$page = $this->request->param('page');
|
|
$res = $club_model->field('id,user_id,name,province,city,district')->where('status',9)->page($page,10)->orderRaw('rand()')->select();
|
|
$res1 = $club_model->field('id,user_id,name,province,city,district')->where('status',9)->select();
|
|
$data = array('code' => 1, 'total'=>count($res1),'data'=>$res,'user_data'=>$user_id);
|
|
return json($data);
|
|
// var_dump($res);exit;
|
|
}
|
|
|
|
public function search_club(){
|
|
$this->confirmed_player();
|
|
$club_model = new Club();
|
|
$user_id = $this->auth->id;
|
|
$keyword = $this->request->param('keyword');
|
|
$page = $this->request->param('page');
|
|
$res = $club_model->field('id,user_id,name,province,city,district')->where('status',9)->where('name','like','%'.$keyword.'%')->select();
|
|
$res1 = $club_model->field('id,user_id,name,province,city,district')->where('status',9)->where('name','like','%'.$keyword.'%')->page($page,10)->select();
|
|
$data = array('code' => 1, 'total'=>count($res),'data'=>$res ,'user_data'=>$user_id);
|
|
return json($data);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|