www_fpvone_cn/application/index/service/PlayerService.php

131 lines
5.3 KiB
PHP

<?php
namespace app\index\service;
/**
* @Created by PhpStorm.
* @Author:Soar
* @Time:2023/11/14 13:31
*/
class PlayerService {
public static function checkPlayer(array $add_data)
{
$validate = [
["real_name", "require", '姓名不可为空!'],
["gender", "require", '请选择性别!'],
["birthday", "require", '出生日期不可为空!'],
["country", "require", '国籍不可为空!'],
["address", "require", '详细地址不可为空!'],
["player_pic", "require", '请上传证件照!'],
];
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', "请上传监护人{$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', "请上传监护人{$add_data['guarder_card_type']}签名页照片"]
);
}
array_push(
$validate,
['guarder_card_back_view', 'require', "请上传监护人{$add_data['guarder_card_type']}反面证件照片"]
);
}
//比较麻烦的判断
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', '请选择证件类型!'],
['card_number', 'require', "请输入{$add_data['card_type']}证件号码"],
['card_front_view', 'require', "请上传{$add_data['card_type']}证件照片"]
);
//护照特殊判断
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', "请上传{$add_data['guarder_card_type']}反面证件照片"]
);
}
//比较麻烦的判断
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)){
print_r("aaa");exit;
}
}
}