log; _logger_(__file__, __line__, $log); return $this->success(); } /** * 获取用户信息接口 */ public function getUserWhiteList(Request $request) { $id = $request->user_id; $uid = $request->uid; // print_r($uid);exit; $info = WxUser::where('id', $id)->first(['id','is_official']); // print_r($info->is_member);exit; if (empty($info)) { return $this->fail(200000, [], '用户不存在'); } if ($info->is_official == 0) { $user_info = WxUser::where('id',$uid)->first(['id','is_official']); // print_r($user_info);exit; if ($user_info->is_official == 1) { $info->is_official = 1; } } return $this->success($info); } /** * 获取首页列表 */ public function getIndexList(Request $request) { $list[0]['id'] = 1; $list[0]['name'] = '全部'; $list[0]['is_vip'] = 0; $list[1]['id'] = 2; $list[1]['name'] = '推荐'; $list[1]['is_vip'] = 0; $wheresa = ['is_city_wide','is_new_list']; $info = WxSetting::whereIn('key',$wheresa)->get(); // print_r($info[0]);exit; if ($info[0]['value'] == 1) { $list[2]['id'] = 3; $list[2]['name'] = '同城'; $list[2]['is_vip'] = 1; } if ($info[1]['value'] == 1) { $list[3]['id'] = 4; $list[3]['name'] = '最新'; $list[3]['is_vip'] = 1; } // 重新排序 $list = array_values($list); return $this->success($list); } /** * 推荐自己回调 */ public function recommendSelfCallback($data) { $order_sn = $data['order_sn']; $order = UserRecommended::where('order_sn', $order_sn)->first(); if (empty($order)) { return $this->fail(200000, [], '订单不存在'); } // 获取是否是续费订单 $pid = $order->pid; $time = time(); if ($pid > 0) { // 如果是续费订单 $pid_order = UserRecommended::where('id', $pid)->first(); if (empty($pid_order)) { // return $this->fail(200000, [], '续费订单不存在'); // 续费订单不存在,直接更新当前订单 $order->start_time = $time; $order->end_time = $time + ($order->day_num * 86400); $order->status = 2; $order->pid = 0; $order->pay_time = $time; $order->save(); } else { $order->start_time = $time; $order->end_time = $time + ($order->day_num * 86400); $order->status = 4; $order->pay_time = $time; $order->save(); // 更新续费订单 $pid_order->end_time = $pid_order->end_time + ($order->day_num * 86400); $pid_order->save(); } } else { $order->start_time = $time; $order->end_time = $time + ($order->day_num * 86400); $order->status = 2; $order->pay_time = $time; $order->save(); } // 更新推荐状态 和推荐结束时间(结束时间+推荐天数*86400) 如果推荐结束时间为空或者小于当前时间 则更新为当前时间 $conditions = Conditions::where('user_id', $order->user_id)->first(); if (empty($conditions->recommend_end_time) || $conditions->recommend_end_time < time()) { $conditions->recommend_end_time = $time + ($order->day_num * 86400); $conditions->save(); } else { $conditions->recommend_end_time = $conditions->recommend_end_time + ($order->day_num * 86400); $conditions->save(); } } /** * 详情 */ public function getConditionsDetailAdmin($id) { // $id = $request->uid; $id = $id; $info = Conditions::where('user_id', $id)->first(); if (empty($info)) { return []; } $info['video_url'] = $info['video_url'] ?? ''; $info['addresss'] = $info['addresss'] ?? ''; $info['registration'] = $info['registration'] ?? ''; $info['content'] = $info['content'] ?? ''; if (!empty($info['addresss'])) { $address_name = explode(',',$info['addresss']); $info['addresss'] = $address_name[0].$address_name[1]; } if (!empty($info['registration'])) { $registration_name = explode(',',$info['registration']); $info['registration'] = $registration_name[0].$registration_name[1]; } $settings = $this->getSettings(2); // 获取用户的名称 $user = WxUser::where('id', $info['user_id'])->first(['user_name','is_yy','is_real']); $info['user_name'] = $user->user_name ?? ''; $info['is_yy'] = $user->is_yy ?? 0; $info['is_real'] = $user->is_real ?? 0; $info['house_name'] = $this->getNameInfo($settings['house'], $info['house']); // 买房情况 $info['occupation_name'] = $this->getNameInfo($settings['occupation'], $info['occupation']); // 职业 $info['income_name'] = $this->getNameInfo($settings['income'], $info['income']); // 收入 $info['age'] = $info['age'] . '岁'; // 年龄 $info['height'] = $info['height'] . 'cm'; // 身高 $info['educational_name'] = $this->getNameInfo($settings['educational'], $info['educational']);// 学历 $info['img_urls'] = explode(',', $info['img_urls']); $info['sex_name'] = $info['sex'] == 1 ? '男' : '女'; $info['matrimony_name'] = $this->getNameInfo($settings['matrimony'], $info['matrimony']); // 婚姻状况 $info['only_name'] = $info['is_only'] == 1 ? '是' : '否'; // 独生子女 $info['married_name'] = $this->getNameInfo($settings['married'], $info['married']); // 何时结婚 $info['car_name'] = $this->getNameInfo($settings['car'], $info['car']);// 买车情况 $info['choose_small_educational_name'] = $this->getNameInfo($settings['educational'], $info['choose_small_educational']); // 择偶-最低学历 $info['choose_matrimony_name'] = $this->getNameInfo($settings['matrimony'], $info['choose_matrimony']); // 择偶-婚姻状况要求 $info['choose_house_name'] = $this->getNameInfo($settings['house'], $info['choose_house']); // 择偶-住房要求 $info['choose_age'] = $this->getNameInfo($settings['choose_age'], $info['choose_age']); // 择偶-住房要求 $info['choose_child_name'] = $info['choose_child'] == 1 ? '接受' : '不接受'; // 择偶-接受对方小孩 $info['choose_income_name'] = $this->getNameInfo($settings['choose_income'], $info['choose_income']); // 择偶-最低月薪 $info['choose_content'] = explode(',', $info['choose_content']); unset($info['choose_child_name']); if (!empty($info['choose_matrimony_name'])) { $info['choose_matrimony_name'] = '婚姻状况:'.$info['choose_matrimony_name']; } if (!empty($info['choose_income_name'])) { if ($info['choose_income_name'] == '不限') { $info['choose_income_name'] = '不限'; } else { $info['choose_income_name'] = '月收入'.$info['choose_income_name'] . '以上'; // 择偶-最低身高 } } if ($info['choose_small_educational_name'] == '初中以下') { $info['choose_small_educational_name'] = '初中以上'; } else if ($info['choose_small_educational_name'] == '') { $info['choose_small_educational_name'] = '不限'; } else { $info['choose_small_educational_name'] = $info['choose_small_educational_name'].'及以上'; } if (!empty($info['choose_small_height'])) { if ($info['choose_small_height'] == '不限') { $info['choose_small_height'] = '不限'; } else { $info['choose_small_height'] = $info['choose_small_height'] . '以上'; // 择偶-最低身高 } } // if ($info['choose_small_height'] == '不限') { // $info['choose_small_height'] = '不限'; // } else { // $info['choose_small_height'] = $info['choose_small_height'] . 'cm以上'; // 择偶-最低身高 // } // print_r('
'); // print_r($info); // exit; // 获取礼物列表 $gifts = WxGift::get(['id','name','photo_url'])->toArray(); $gift_num = 0; // 获取礼物数量 foreach ($gifts as $key => $val) { $num = WxUserGift::where('accept_user_id', $info['user_id'])->where('gift_id', $val['id'])->count(); if ($num == 0) { unset($gifts[$key]); } else { $gifts[$key]['num'] = $num; $gift_num += $num; } } if (empty($gifts)) { $gifts = []; } else { // 重新排序 $gifts = array_values($gifts); } $is_follow = (new WxUserFollow())->isFollowUser($info['id'], $info['user_id']); $info['is_follow'] = $is_follow ? 1 : 0; $info['gift_num'] = $gift_num; $info['gifts'] = $gifts; // print_r($id);exit; if ($info['step']) { $info['step'] = $info['step']+1; } else { $info['step'] = 0+1; } //$info['user_choose_content'] = $this->getConditionsById($info['choose_content'],'choose_content',4); return $info; return $this->success($info); } /** * 获取标签 */ public function getTagList($type=1) { $educational = [ ['id' => 1, 'name' => '毛遂自荐'], ['id' => 2, 'name' => '温柔善良'], ['id' => 3, 'name' => '勤俭持家'], ]; if ($type == 1) { return $this->success($educational); } else { return $educational; } } /** * 获取红娘信息 */ public function getMatchmakerInfo(Request $request) { $type = $request->type; // print_r($type);exit; if ($type == 1) { $wheresa = ['xiangqin_name','xiangqin_wx_code','xiangqin_wx_img']; $info = WxSetting::whereIn('key',$wheresa)->get(); $data = [ 'id' => 1, 'name' => $info[0]['value'], 'wx_code' => $info[1]['value'], 'wx_img' => $info[2]['value'], ]; } else { $wheresa = ['xiangqin_one_name','xiangqin_one_wx_code','xiangqin_one_wx_img']; $info = WxSetting::whereIn('key',$wheresa)->get(); $data = [ 'id' => 2, 'name' => $info[0]['value'], 'wx_code' => $info[1]['value'], 'wx_img' => $info[2]['value'], ]; } return $this->success($data); } /** * 获取用户信息接口 */ public function getUserInfo(Request $request) { $id = $request->uid; $info = WxUser::where('id', $id)->first(['id','is_yy','is_real','is_member','gender','age','requirement','is_online_status']); // print_r($info->is_member);exit; if (empty($info)) { return $this->fail(200000, [], '用户不存在'); } // if (empty($info->is_member)) { // $info->is_member = 0; // } else if ($info->is_member <= time()) { // $info->is_member = 0; // } else { // $info->is_member = 1; // } if (empty($info->gender) || empty($info->age) || empty($info->requirement)) { $info->is_user_info = 0; } else { $info->is_user_info = 1; } return $this->success($info); } /** * 获取地区 */ public function getAreaList(Request $request) { $pid = $request->code; // print_r($pid);exit; if (empty($pid)) { $area = ChinaArea::where('pcode', 0)->get(['code','name']); return $this->success($area); } $area = ChinaArea::where('pcode', $pid)->get(['code','name']); return $this->success($area); } /** * 获取选择内容 */ public function getChooseContent(Request $request) { $wheresa = ['xiangqin_question']; $info = WxSetting::whereIn('key',$wheresa)->get(); $list = $info[0]['value']; $list = json_decode($list, true); foreach ($list as $key => $val) { $list[$key]['id'] = $key+1; } // print_r($list);exit; // $list[0] = [ // 'id' => 1, // 'name' => 'NO.1 亿友圈内找对象', // ]; // $list[1] = [ // 'id' => 2, // 'name' => 'NO.2 了解乙肝治疗知识', // ]; // $list[2] = [ // 'id' => 3, // 'name' => 'NO.3 随便逛逛', // ]; return $this->success(['list' => $list]); } /** * 个人信息 */ public function updateUserInfo(Request $request) { global $__MINI_GLOBAL_IP__; $uid = $request->uid; $age = $request->age; // print_r($uid);exit; // 身高范围 $requirement = $request->requirement; $user_avatar = $request->user_avatar; $user_name = $request->user_name; $is_online_status = $request->is_online_status; $data = []; //print_r($requirement);exit; // 性别 $sex = $request->sex; //$data['age'] = $age; //$data['requirement'] = $requirement; //$data['gender'] = $sex; //$data['user_name'] = $user_name; // 判断头像是否为空 为空不上传 if (!empty($user_avatar)) { $data['user_avatar'] = $user_avatar; } if (isset($user_name)) { $data['user_name'] = $user_name; } if (isset($is_online_status)) { $data['is_online_status'] = $is_online_status; } if (isset($age)) { $data['age'] = $age; } if (isset($requirement)) { $data['requirement'] = $requirement; } if (isset($sex)) { $data['gender'] = $sex; } if ($data != []) { $info = WxUser::where('id', $uid)->update($data); } $requirement_list = explode(',', $requirement); // 检测里面是否包含 亿友圈内找对象 文字(要模糊查询 里面可能还有别的文字) $is_find = 0; foreach ($requirement_list as $key => $val) { if (strpos($val, '亿友圈内找对象') !== false) { $is_find = 1; } } // print_r($is_find);exit; if ($is_find == 1) { // 亿友圈内找对象 Conditions $info = Conditions::where('user_id', $uid)->first(['id']); //print_r($info);exit; if (!empty($info)) { $info->status = 1; $info->save(); } else { $res = _ip_address($__MINI_GLOBAL_IP__); // print_r($res);exit; if(_empty_($res)){ // 获取wxuser 表的地区 $user_info = WxUser::where('id', $uid)->first(['province','city','district']); $ip_address = $user_info->province .','. $user_info->city .','. $user_info->district; $add_conditions['ip_address'] = $ip_address; } else { // 更新用户相亲表 ip 地址地区 // 判断是否存在不存在就不更新 ,如果 ip_address 相同 也不更新 $ip_address = $res['province'] .','. $res['city'] .','. $res['district']; $add_conditions['ip_address'] = $ip_address; } // 如果不存在添加 Conditions $add_conditions['img_urls'] = $request->user_avatar; $add_conditions['age'] = $request->age; $add_conditions['sex'] = $sex; $add_conditions['create_time'] = time(); $add_conditions['user_id'] = $uid; $add_conditions['status'] = 1; //print_r($add_conditions);exit; Conditions::create($add_conditions); } } return $this->success(); } /** * 获取轮播图 */ public function getSlideshow(Request $request) { $slideshow = WxSlideshow::wherein('id', explode(',', Settings::get('app_xiangqin_index_banner', '', true)))->orderBy(DB::raw('FIND_IN_SET(id, "' . Settings::get('app_xiangqin_index_banner', '', true) . '"' . ")"))->get(['id', 'poster', 'target_id', 'slideshow_type']); // sort 排序 // $where[] = ['slideshow_state', 1]; // $where[] = ['is_xiangqin', 1]; // $slideshow = WxSlideshow::where($where)->get(['poster','target_id','slideshow_type']); foreach ($slideshow as $key => $val) { unset($slideshow[$key]['id']); } return $this->success(['data' => $slideshow]); } /** * 查看公告 */ public function getNoticeInfo(Request $request) { $id = $request->id; $notice = Settings::get('app_xiangqin_index_notice', [], true); $info = $notice[$id - 1] ?? []; // 查询wx_user_notice 表 $wx_swhere = []; $wx_swhere[] = ['notice_info', $info['text']]; $wx_swhere[] = ['user_id', $request->uid]; $notice_info = WxUserNotice::where($wx_swhere)->first(); if (empty($notice_info)) { $data = [ 'user_id' => $request->uid, 'notice_info' => $info['text'], ]; WxUserNotice::create($data); } return $this->success(); } /** * 获取相亲tab * */ public function getXiangQinTab() { $notice = Settings::get('app_xiangqin_index_nav', [], true); return $this->success(['data' => $notice]); } /** * 获取 会员消息提示 * app_index_nav */ public function getVipMessage() { $wheresa = ['message_vip_name','huji_vip_name','jvzhu_vip_name','yincang_vip_name']; $info = WxSetting::whereIn('key',$wheresa)->get(); $message_vip_name = Settings::get('message_vip_name', [], true); $huji_vip_name = Settings::get('huji_vip_name', [], true); $jvzhu_vip_name = Settings::get('jvzhu_vip_name', [], true); $data['message_vip_name'] = $info[2]['value']; $data['huji_vip_name'] = $info[0]['value']; $data['jvzhu_vip_name'] = $info[1]['value']; $data['yincang_vip_name'] = $info[3]['value']; return $this->success(['data' => $data]); // return $this->success(['data' => $info]); } /** * 获取公告列表 * app_index_nav */ public function getNoticeList(Request $request) { $notice = Settings::get('app_xiangqin_index_notice', [], true); foreach ($notice as $key => $val) { $notice[$key]['id'] = $key+1; // 查询wx_user_notice 表 $wx_swhere = []; $wx_swhere[] = ['notice_info', $val['text']]; $wx_swhere[] = ['user_id', $request->uid]; $info = WxUserNotice::where($wx_swhere)->count(); if ($info > 0) { $notice[$key]['is_read'] = 1; } else { $notice[$key]['is_read'] = 0; } } // print_r($notice);exit; return $this->success(['data' => $notice]); } /** * 获取跳转ID */ public function getTargetId(Request $request) { $where[] = ['id', '<>', 0]; $info = WxXiangqin::where($where)->get(['id','type','target_id']); if (empty($info)) { return $this->fail(200000, [], '数据不存在'); } return $this->success(['data' => $info]); } /** * 获取推荐自己每天的价格 */ public function getRecommendSelfPrice(Request $request) { $wheresa = ['tuijian_price']; $info = WxSetting::whereIn('key',$wheresa)->get(); $day_price = $info[0]['value']; // 转换为数字 $day_price = intval($day_price); return $this->success(['day_price' => $day_price]); } /** * 推荐自己 */ public function recommendSelf(Request $request) { $uid = $request->uid; $day_num = $request->day_num;// 推荐天数 $tag = $request->tag;// 标签 $type = $request->type;// 1:余额支付 2:微信支付 $user = WxUser::where('id', $uid)->first(['is_yy','is_real']); if (empty($user)) { return $this->fail(200000, [], '用户不存在'); } // if ($user->is_yy == 0 || $user->is_real == 0) { // return $this->fail(200000, [], '用户未实名认证或者未亿友认证'); // } // 获取每天推荐需要多少钱 $day_price = 1; $total_price = $day_num * $day_price; // 获取当前用户相亲表ID $info = Conditions::where('user_id', $uid)->first(['id']); if (empty($info)) { return $this->fail(200000, [], '请先发布相亲信息'); } // 检测当前用户是否在推荐中 $pid = 0; $ur_info = UserRecommended::where('user_id', $uid)->where('status', 2)->first(); if (!empty($ur_info)) { // 如果已经在推荐中 续费时间 $pid = $ur_info->id; } if ($pid == 0) { // 检测现在已发布的数量 $count = UserRecommended::where('status', 2)->count(); // 获取配置的最大推荐数量 $max_num = Settings::get('app_max_recommend_num', 10); if ($count >= $max_num) { return $this->fail(200000, [], '推荐数量已经达到上限'); } } $user_financial = WxUserFinancial::where('user_id', $request->uid)->first(); if (empty($user_financial)) { return $this->fail(200001, [], '余额不足'); } if ($user_financial->balance < $total_price) { return $this->fail(200001, [], '余额不足'); } // 生成随机数字订单编号 纯数字 $order_sn = Utils::getSn(1); $data = [ 'user_id' => $uid, 'uc_id' => $info->id, 'order_sn' => $order_sn, 'tag' => $tag, 'day_num' => $day_num, 'start_time' => time(), 'end_time' => time() + ($day_num * 86400), 'status' => 1, 'price' => $total_price, 'pid' => $pid, 'create_time' => time(), ]; UserRecommended::create($data); // 扣除用户的余额 $user_financial->balance = $user_financial->balance - $total_price; $user_financial->save(); if ($type == 1) { $this->recommendSelfCallback($data); return $this->success(); } else { $pay_info['body'] = '推荐自己'; $pay_info['price'] = $total_price; $pay_info['order_sn'] = $order_sn; return (new OrderController)->orderfun($uid,$data); } } /** * 赠送礼物 */ public function sendGift(Request $request) { // 获取赠送礼物的ID $gift_id = $request->gift_id; $gift_num = $request->gift_num; // 获取接收礼物的用户ID $accept_user_id = $request->accept_user_id; // 获取分成 $wheresa = ['share_proportion']; $info = WxSetting::whereIn('key',$wheresa)->get(); $app_reward_platform_percent = $info[0]['value']; $gift = WxGift::where('id', $gift_id)->first(); if (empty($gift)) { return $this->fail(200000, [], '礼物不存在'); } $price = $gift->price * $gift_num; // 获取用户的余额 $user_financial = WxUserFinancial::where('user_id', $request->uid)->first(); if (empty($user_financial)) { return $this->fail(200000, [], '余额不足1'); } if ($user_financial->balance < $price) { return $this->fail(200001, [], '余额不足'); } // 开始赠送礼物 $data = [ 'user_id' => $request->uid, 'accept_user_id' => $accept_user_id, 'gift_id' => $gift_id, 'num' => $gift_num, 'price' => $price, 'create_time' => time(), ]; WxUserGift::create($data); // 扣除用户的余额 $user_financial->balance = $user_financial->balance - $price; $user_financial->save(); // 平台分成 $platform_price = $price * $app_reward_platform_percent / 100; // 接受礼物的收入 = 价格 - 平台分成 // 接受礼物的人收入 $accept_user_financial = WxUserFinancial::where('user_id', $accept_user_id)->first(); if (empty($accept_user_financial)) { // 创建 // $accept_user_financial = [ // 'user_id' => $accept_user_id, // 'balance' => $price - $platform_price, // ]; $accept_user_financial['user_id'] = $accept_user_id; $accept_user_financial['balance'] = $price - $platform_price; $user_financial_record = $price - $platform_price; WxUserFinancial::create($accept_user_financial); } else { $user_financial_record = $accept_user_financial->balance + $price - $platform_price; $accept_user_financial->balance = $user_financial_record; $accept_user_financial->save(); } // WxUserFinancialRecord 记录 $record = [ 'user_id' => $request->uid, 'num' => $user_financial_record, 'type' => 6, 'balance' => $user_financial->balance, 'tip'=>'礼物收益增加'.$user_financial_record.',平台收入'.$platform_price, 'created_at' => date('Y-m-d H:i:s'), ]; WxUserFinancialRecord::create($record); // 赠送成功 return $this->success(); } /** * 获取礼物列表 */ public function getGiftList(Request $request) { $list = WxGift::get(['id','name','photo_url','price']); return $this->success($list); } /** * 详情 */ public function getConditionsDetail(Request $request) { // $id = $request->uid; $id = $request->id; $info = Conditions::where('id', $id)->first(); $info['addresss'] = $info['addresss'] ?? ''; $info['registration'] = $info['registration'] ?? ''; // print_r($info['registration']);exit; if (!empty($info['addresss'])) { $address_name = explode(',',$info['addresss']); $info['addresss'] = $address_name[0].$address_name[1]; } if (!empty($info['registration'])) { $registration_name = explode(',',$info['registration']); $info['registration'] = $registration_name[0].$registration_name[1]; } $settings = $this->getSettings(2); // 获取用户的名称 $user = WxUser::where('id', $info['user_id'])->first(['user_name','is_yy','is_real']); $info['user_name'] = $user->user_name ?? ''; //$info['is_yy'] = $user->is_yy ?? 0; //$info['is_real'] = $user->is_real ?? 0; $info['house_name'] = $this->getNameInfo($settings['house'], $info['house']); // 买房情况 $info['occupation_name'] = $this->getNameInfo($settings['occupation'], $info['occupation']); // 职业 $info['income_name'] = $this->getNameInfo($settings['income'], $info['income']); // 收入 if (empty($info['age'])) { $info['age'] = '暂无'; } else { $info['age'] = $info['age'] . '岁'; // 年龄 } if (empty($info['height'])) { $info['height'] = '暂无'; } else { $info['height'] = $info['height'] . 'cm'; // 身高 } $info['educational_name'] = $this->getNameInfo($settings['educational'], $info['educational']);// 学历 $info['img_urls'] = explode(',', $info['img_urls']); $info['sex_name'] = $info['sex'] == 1 ? '男' : '女'; $info['matrimony_name'] = $this->getNameInfo($settings['matrimony'], $info['matrimony']); // 婚姻状况 $info['only_name'] = $info['is_only'] == 1 ? '是' : '否'; // 独生子女 $info['married_name'] = $this->getNameInfo($settings['married'], $info['married']); // 何时结婚 $info['car_name'] = $this->getNameInfo($settings['car'], $info['car']);// 买车情况 $info['choose_small_educational_name'] = $this->getNameInfo($settings['educational'], $info['choose_small_educational']); // 择偶-最低学历 $info['choose_matrimony_name'] = $this->getNameInfo($settings['matrimony'], $info['choose_matrimony']); // 择偶-婚姻状况要求 $info['choose_house_name'] = $this->getNameInfo($settings['house'], $info['choose_house']); // 择偶-住房要求 $info['choose_age'] = $this->getNameInfo($settings['choose_age'], $info['choose_age']); // 择偶-住房要求 $info['choose_small_height'] = $this->getNameInfo($settings['choose_small_height'], $info['choose_small_height']); // 择偶-住房要求 $info['choose_child_name'] = $info['choose_child'] == 1 ? '接受' : '不接受'; // 择偶-接受对方小孩 unset($info['choose_child_name']); $info['choose_income_name'] = $this->getNameInfo($settings['choose_income'], $info['choose_income']); // 择偶-最低月薪 // $info['choose_content'] = explode(',', $info['choose_content']); $info['choose_content'] = $this->getConditionsById($info['choose_content'],'choose_content',4); $info['peculiarity_names'] = $this->getConditionsById($info['peculiarity'],'peculiarity',4); $info['family_name'] = $this->getConditionsById($info['family'],'family',1); if (!empty($info['choose_matrimony_name'])) { $info['choose_matrimony_name'] = '婚姻状况:'.$info['choose_matrimony_name']; } if (!empty($info['choose_income_name'])) { if ($info['choose_income_name'] == '不限') { $info['choose_income_name'] = '不限'; } else { $info['choose_income_name'] = '月收入'.$info['choose_income_name'] . '以上'; // 择偶-最低身高 } } if ($info['choose_small_educational_name'] == '初中以下') { $info['choose_small_educational_name'] = '初中以上'; } else if ($info['choose_small_educational_name'] == '') { $info['choose_small_educational_name'] = '不限'; } else { $info['choose_small_educational_name'] = $info['choose_small_educational_name'].'及以上'; } if (!empty($info['choose_small_height'])) { if ($info['choose_small_height'] == '不限') { $info['choose_small_height'] = '不限'; } else { $info['choose_small_height'] = $info['choose_small_height'] . '以上'; // 择偶-最低身高 } } // 获取礼物列表 $gifts = WxGift::get(['id','name','photo_url'])->toArray(); $gift_num = 0; // 获取礼物数量 foreach ($gifts as $key => $val) { $num = WxUserGift::where('accept_user_id', $info['user_id'])->where('gift_id', $val['id'])->count(); if ($num == 0) { unset($gifts[$key]); } else { $gifts[$key]['num'] = $num; $gift_num += $num; } } if (empty($gifts)) { $gifts = []; } else { // 重新排序 $gifts = array_values($gifts); } $is_follow = (new WxUserFollow())->isFollowUser($request->uid, $info['user_id']); $info['is_follow'] = $is_follow ? 1 : 0; $info['gift_num'] = $gift_num; $info['gifts'] = $gifts; // print_r($id);exit; if ($info['step']) { $info['step'] = $info['step']+1; } else { $info['step'] = 0+1; } return $this->success($info); } /** * 首页列表 */ public function getConditionsList(Request $request) { $uid = $request->uid; $page = $request->page ?? 1; $limit = $request->limit ?? 10; $type = $request->type ?? 1; // 年龄范围 $age = $request->age; // 身高范围 $height = $request->height; // 性别 $sex = $request->sex; // 学历 $educational = $request->educational; // 职业 $occupation = $request->occupation; // 收入 $income = $request->income; // 婚姻状况 $matrimony = $request->matrimony; // 实名认证 $is_real = $request->is_real; // 现居地 $addresss = $request->addresss; // 户籍地 $registration = $request->registration; $offset = ($page - 1) * $limit; if ($age && $age != 0) { $age = explode('-', $age); $age = [$age[0], $age[1]]; $where[] = ['age', '>=', $age[0]]; $where[] = ['age', '<=', $age[1]]; } if ($height && $height != 0) { $height = explode('-', $height); $height = [$height[0], $height[1]]; $where[] = ['height', '>=', $height[0]]; $where[] = ['height', '<=', $height[1]]; } if ($sex && $sex != 0) { $where[] = ['sex', $sex]; } if ($educational && $educational != 0) { $where[] = ['educational','>=', $educational]; } if ($occupation && $occupation != 0) { $where[] = ['occupation', $occupation]; } if ($income && $income != 0) { $where[] = ['income', $income]; } if ($matrimony && $matrimony != 0) { $where[] = ['matrimony', $matrimony]; } // 获取当前用户信息 $user = WxUser::where('id', $uid)->first(['is_member']); $address_status = 0; // Log::info('addresss', ['addresss' => $addresss]) if ($user->is_member > 0) { if ($addresss && $addresss != 0) { $where[] = ['addresss', 'like', '%' . $addresss . '%']; $address_status = 1; } if ($registration && $registration != 0) { // $where[] = ['registration', $registration]; $where[] = ['registration', 'like', '%' . $registration . '%']; } } if ($is_real && $is_real != 0) { if ($is_real == 1) { $where[] = ['is_real', 1]; } else { $where[] = ['is_yy', 1]; } } $order_by = [ ['id', 'desc'], ]; if ($type == 1) { // 全部 } else if ($type == 2) { // 推荐 $where[] = ['recommend_end_time', '>', time()]; $order_by = [ ['r_time', 'asc'], ]; } else if ($type == 3) { // 同城 // 获取当前用户的省市区 if ($address_status == 0) { $user_info = Conditions::where('user_id', $uid)->first(['ip_address']); // $where[] = ['addresss', $user_info->addresss]; $where[] = ['ip_address', 'like', '%' . $user_info->ip_address . '%']; } } else { // 最新 create_time $order_by = [ ['create_time', 'desc'], ]; } $where[] = ['user_id', '>', 0]; $where[] = ['is_xiangqin_status', '=', 1]; // $where[] = ['status', '>', 0]; // print_r($where);exit; $field = ['id', 'user_id', 'age', 'height', 'img_urls','house','occupation','income','educational','sex']; // $list = Conditions::where($where)->offset($offset)->limit($limit)->get($field); // $total = Conditions::where($where)->count(); $query = Conditions::where($where)->offset($offset)->limit($limit); foreach ($order_by as $order) { $query->orderBy($order[0], $order[1]); } $list = $query->get($field); $total = Conditions::where($where)->count(); $settings = $this->getSettings(2); $tag_list = $this->getTagList(2); // print_r($this->getNameInfo($settings['house'], 2));exit; foreach ($list as $key => $val) { if ($type == 2) { // 获取推荐标签 UserRecommended 表 user_id , 倒序排序,status = 2 $recommend_tags = UserRecommended::where('user_id', $val['user_id'])->orderBy('id', 'desc')->whereIn('status', [2, 4])->first(['id','tag']); if (empty($recommend_tags)) { $list[$key]['recommend_tag_name'] = $tag_list[0]['name'] ?? ''; } else { $recommend_tag_name = $tag_list[0]['name'] ?? ''; foreach ($tag_list as $ks => $vs) { if ($vs['id'] == $recommend_tags->tag) { $recommend_tag_name = $vs['name']; } } $list[$key]['recommend_tag_name'] = $recommend_tag_name; } } else { $list[$key]['recommend_tag_name'] = ''; } // print_r($val['house']);exit; $list[$key]['sex_name'] = $val['sex'] == 1 ? '男' : '女'; $list[$key]['photo_img'] = explode(',', $val['img_urls'])[0];// 取第一张图片, 作为封面 $list[$key]['img_urls'] = explode(',', $val['img_urls']); // 获取用户的名称 $user = WxUser::where('id', $val['user_id'])->first(['user_name','is_yy','is_real']); $list[$key]['user_name'] = $user->user_name ?? ''; $list[$key]['is_yy'] = $user->is_yy ?? 0; $list[$key]['is_real'] = $user->is_real ?? 0; // $list[$key]['house_name'] = $settings['house'][$val['house']]['name'] ?? '暂无'; $list[$key]['house_name'] = $this->getNameInfo($settings['house'], $val['house']); $list[$key]['occupation_name'] = $this->getNameInfo($settings['occupation'], $val['occupation']); $list[$key]['income_name'] = $this->getNameInfo($settings['income'], $val['income']); if (empty($val['age'])) { $list[$key]['age'] = '暂无'; } else { $list[$key]['age'] = $val['age'] . '岁'; } if (empty($val['height'])) { $list[$key]['height'] = '暂无'; } else { $list[$key]['height'] = $val['height'] . 'cm'; } $list[$key]['educational_name'] = $this->getNameInfo($settings['educational'], $val['educational']); } return $this->success(['list' => $list, 'total' => $total]); } public function editConditions(Request $request) { $uid = $request->uid; $step = 1; if (empty($request->img_urls)) { return $this->fail(200000, [], '图片地址不能为空'); } if (empty($request->age)) { return $this->fail(200000, [], '年龄不能为空'); } if (empty($request->height)) { return $this->fail(200000, [], '身高不能为空'); } // if (empty($request->sex)) { // return $this->fail(200000, [], '性别不能为空'); // } if (empty($request->educational)) { return $this->fail(200000, [], '学历不能为空'); } if (empty($request->occupation)) { return $this->fail(200000, [], '职业不能为空'); } if (empty($request->income)) { return $this->fail(200000, [], '收入不能为空'); } if (empty($request->matrimony)) { return $this->fail(200000, [], '婚姻状况不能为空'); } if (empty($request->addresss)) { return $this->fail(200000, [], '省市区不能为空'); } if (empty($request->registration)) { return $this->fail(200000, [], '户籍地不能为空'); } if (empty($request->content)) { return $this->fail(200000, [], '补充内容不能为空'); } // 百度审核 $wheresa = ['is_xiangqin_audit_posts']; $info = WxSetting::whereIn('key',$wheresa)->get(); $is_xiangqin_audit_posts = $info[0]['value']; if(UserUtils::user_permissions_check_by_config($uid, 'xiangqin_audit_posts_white_list')){ $need_manual_review = false; }else{ $need_manual_review = true; } if($is_xiangqin_audit_posts == 2 && $need_manual_review){ $filter_result = BaiduUtils::text_filter($request->content); if($filter_result){ if($filter_result['hit_level'] == 2){ return $this->fail(200016, ['tip'=>$filter_result['tip_list'], 'hit_word'=>$filter_result['hit_word']]); } } } $data['img_urls'] = $request->img_urls ?? ''; $data['video_url'] = $request->video_url ?? ''; $data['age'] = $request->age ?? ''; $data['height'] = $request->height ?? ''; // $data['sex'] = $request->sex ?? ''; $data['educational'] = $request->educational ?? ''; $data['occupation'] = $request->occupation ?? ''; $data['income'] = $request->income ?? ''; $data['matrimony'] = $request->matrimony ?? ''; $data['addresss'] = $request->addresss ?? ''; $data['registration'] = $request->registration ?? ''; $data['content'] = $request->content ?? ''; $data['family'] = $request->family ?? ''; $data['is_only'] = $request->is_only ?? 0; $data['married'] = $request->married ?? 0; $data['car'] = $request->car ?? 0; $data['house'] = $request->house ?? 0; $data['peculiarity'] = $request->peculiarity ?? ''; // 检测 上面这个几个是否有提交的数据 family、is_only、married、car、house、peculiarity 里面其中一个不为空 修改步骤为2 if (!empty($request->family) || !empty($request->is_only) || !empty($request->married) || !empty($request->car) || !empty($request->house) || !empty($request->peculiarity)) { $step = 2; } $data['choose_age'] = $request->choose_age ?? ''; $data['choose_small_height'] = $request->choose_small_height ?? ''; $data['choose_small_educational'] = $request->choose_small_educational ?? ''; $data['choose_income'] = $request->choose_income ?? ''; $data['choose_matrimony'] = $request->choose_matrimony ?? ''; $data['choose_house'] = $request->choose_house ?? ''; $data['choose_child'] = $request->choose_child ?? 0; $data['choose_content'] = $request->choose_content ?? ''; if (!empty($request->choose_age) || !empty($request->choose_small_height) || !empty($request->choose_small_educational) || !empty($request->choose_income) || !empty($request->choose_matrimony) || !empty($request->choose_house) || !empty($request->choose_child) || !empty($request->choose_content)) { $step = 3; } $user = WxUser::where('id', $uid)->first(); // 判断是否创建了数据 $info = Conditions::where('user_id', $uid)->first(); if ($info) { // 判断步骤是否大于 当前步骤 如果大于当前步骤 则不更新步骤 if ($info->step < $step) { $data['step'] = $step; } Conditions::where('user_id', $uid)->update($data); } else { // 获取 requirement 并逗号分隔 获取是否有 亿友圈内找对象 文字 $requirement = $user->requirement; $requirementArray = explode(',', $requirement); $is_find = 0; $data['status'] = 0; foreach ($requirementArray as $key => $val) { if (strpos($val, '亿友圈内找对象') !== false) { $is_find = 1; $data['status'] = 1; } } $data['create_time'] = date('Y-m-d H:i:s'); $data['step'] = $step; Conditions::create($data); } //Conditions::where('user_id', $uid)->update($data); // $user = WxUser::where('id', $uid)->first(); // address 分为province、city、area $address = $request->addresss; if ($address) { $addressArray = explode(',', $address); // $user->province = $addressArray[0]; // $user->city = $addressArray[1]; // $user->district = $addressArray[2]; // $user->country = '中国'; } if ($request->sex) { $user->gender = $request->sex; } if ($request->sex || $address) { $user->save(); } return $this->success(); } /** * 实名认证 */ public function realNameAuth(Request $request) { $uid = $request->uid; $info = (new UserController())->real_name_api($uid, $request->real_name, $request->card_num); return $info; return $this->success(); } /** * 添加用户条件 * video_url 视频地址 * img_urls 图片地址 - 强制验证 * age 年龄 - 强制验证 * height 身高 - 强制验证 * sex 性别 1:男 2:女 - 强制验证 * educational 学历 - 强制验证 * occupation 职业ID - 强制验证 * income 收入ID - 强制验证 * matrimony 婚姻状况 - 强制验证 * addresss 省市区ID 用逗号分隔 - 强制验证 * registration 户籍地(省市区)用逗号分隔 - 强制验证 * content 补充内容 - 强制验证 * family 家庭背景 * is_only 独生子女1:是 2:否 * married 何时结婚ID * car 买车情况ID * house 买房情况 * peculiarity 特点 * choose_age 择偶-年龄范围 * choose_small_height 择偶-最低身高 * choose_small_educational 择偶-最低学历 * choose_income 择偶-最低月薪 * choose_matrimony 择偶-婚姻状况要求 * choose_house 择偶-住房要求 * choose_child 择偶-接受对方小孩 1:接受 2:不接受 * choose_content 择偶-希望ta 内容 * @param Request $request */ public function addConditions(Request $request) { $uid = $request->uid; $step = $request->step; if (!isset($step) || empty($step)) { return $this->fail(200000, [], '参数错误'); } // $info = Conditions::where('user_id', $uid)->first(); // if ($info) { // return $this->fail(200000, [], '已经存在条件'); // } if ($step == 1) { // 手动验证数据 - 有些数据需要强制验证 if (empty($request->img_urls)) { return $this->fail(200000, [], '图片地址不能为空'); } if (empty($request->age)) { return $this->fail(200000, [], '年龄不能为空'); } if (empty($request->height)) { return $this->fail(200000, [], '身高不能为空'); } // if (empty($request->sex)) { // return $this->fail(200000, [], '性别不能为空'); // } if (empty($request->educational)) { return $this->fail(200000, [], '学历不能为空'); } if (empty($request->occupation)) { return $this->fail(200000, [], '职业不能为空'); } if (empty($request->income)) { return $this->fail(200000, [], '收入不能为空'); } if (empty($request->matrimony)) { return $this->fail(200000, [], '婚姻状况不能为空'); } if (empty($request->addresss)) { return $this->fail(200000, [], '省市区不能为空'); } if (empty($request->registration)) { return $this->fail(200000, [], '户籍地不能为空'); } if (empty($request->content)) { return $this->fail(200000, [], '补充内容不能为空'); } // 百度审核 $wheresa = ['is_xiangqin_audit_posts']; $info = WxSetting::whereIn('key',$wheresa)->get(); $is_xiangqin_audit_posts = $info[0]['value']; if(UserUtils::user_permissions_check_by_config($uid, 'xiangqin_audit_posts_white_list')){ $need_manual_review = false; }else{ $need_manual_review = true; } if($is_xiangqin_audit_posts == 2 && $need_manual_review){ $filter_result = BaiduUtils::text_filter($request->content); if($filter_result){ if($filter_result['hit_level'] == 2){ return $this->fail(200016, ['tip'=>$filter_result['tip_list'], 'hit_word'=>$filter_result['hit_word']]); } } } } if ($step == 2) { // 验证 家庭背景、独生子女、何时结婚、买车情况、买房情况、我的特点 // if (empty($request->family)) { // return $this->fail(200000, [], '家庭背景不能为空'); // } // if (empty($request->is_only)) { // return $this->fail(200000, [], '独生子女不能为空'); // } // if (empty($request->married)) { // return $this->fail(200000, [], '何时结婚不能为空'); // } // if (empty($request->car)) { // return $this->fail(200000, [], '买车情况不能为空'); // } // if (empty($request->house)) { // return $this->fail(200000, [], '买房情况不能为空'); // } // if (empty($request->peculiarity)) { // return $this->fail(200000, [], '我的特点不能为空'); // } } if ($step == 3) { // 年龄范围、最低身高、最低学历、最低月薪、婚姻状况要求、住房要求、接受对方小孩、希望ta 内容 // if (empty($request->choose_age)) { // return $this->fail(200000, [], '年龄范围不能为空'); // } // if (empty($request->choose_small_height)) { // return $this->fail(200000, [], '最低身高不能为空'); // } // if (empty($request->choose_small_educational)) { // return $this->fail(200000, [], '最低学历不能为空'); // } // if (empty($request->choose_income)) { // return $this->fail(200000, [], '最低月薪不能为空'); // } // if (empty($request->choose_matrimony)) { // return $this->fail(200000, [], '婚姻状况要求不能为空'); // } // if (empty($request->choose_house)) { // return $this->fail(200000, [], '住房要求不能为空'); // } // if (empty($request->choose_child)) { // return $this->fail(200000, [], '接受对方小孩不能为空'); // } // if (empty($request->choose_content)) { // return $this->fail(200000, [], '希望ta 内容不能为空'); // } } if ($step == 4) { // if (!empty($request->real_name) || !empty($request->card_num) || !empty($request->identity_picture) || !empty($request->identity_picture_the)) { // if (empty($request->real_name)) { // return $this->fail(200000, [], '真实姓名不能为空'); // } // if (empty($request->card_num)) { // return $this->fail(200000, [], '身份证号不能为空'); // } // if (empty($request->identity_picture)) { // return $this->fail(200000, [], '身份证正面不能为空'); // } // if (empty($request->identity_picture_the)) { // return $this->fail(200000, [], '身份证反面不能为空'); // } // // 添加到实名认证表 // $standing = [ // 'user_id' => $uid, // 'real_name' => $request->real_name, // 'card_num' => $request->card_num, // 'identity_picture' => $request->identity_picture, // 'identity_picture_the' => $request->identity_picture_the, // 'created_at' => date('Y-m-d H:i:s') // ]; // UserStanding::create($standing); $data['step'] = $step; // return $this->success($data); // 检测是否实名认证 $user_infos = WxUser::where('id', $uid)->first(); // 检测是否实名认证 real_name、real_id_card 不为空 if (empty($user_infos->real_name) || empty($user_infos->real_id_card)) { // 如果存在更新里面的数据 Conditions::where('user_id', $uid)->update($data); $info = (new UserController())->real_name_api($uid, $request->real_name, $request->card_num); return $info; } } else { $step = 4; } } // 获取用户是否在否在实名认证 // 查询排序 // $user = UserStanding::where('user_id', $uid)->orderBy('id','desc')->first(); // if (empty($user) || $user->is_examine == 2) { // // 如果没有实名认证或者实名认证失败 // // 检测是否上传了实名认证 // if (!empty($request->real_name) || !empty($request->card_num)|| !empty($request->identity_picture) || !empty($request->identity_picture_the)) { // // 如果其中有一个上传了,那么就要验证其他的 // if (empty($request->real_name)) { // return $this->fail(200000, [], '真实姓名不能为空'); // } // if (empty($request->card_num)) { // return $this->fail(200000, [], '身份证号不能为空'); // } // if (empty($request->identity_picture)) { // return $this->fail(200000, [], '身份证正面不能为空'); // } // if (empty($request->identity_picture_the)) { // return $this->fail(200000, [], '身份证反面不能为空'); // } // // 添加到实名认证表 // $standing = [ // 'user_id' => $uid, // 'real_name' => $request->real_name, // 'card_num' => $request->card_num, // 'identity_picture' => $request->identity_picture, // 'identity_picture_the' => $request->identity_picture_the, // 'created_at' => date('Y-m-d H:i:s') // ]; // UserStanding::create($standing); // } // } // 检测user_id是否存在 $count = Conditions::where('user_id', $uid)->count(); // $data = $request->all(); // unset($data['real_name']); // unset($data['card_num']); // unset($data['identity_picture']); // unset($data['identity_picture_the']); // unset($data['uid']); if ($step == 1) { $data['img_urls'] = $request->img_urls; $data['video_url'] = $request->video_url; $data['age'] = $request->age; $data['height'] = $request->height; // $data['sex'] = $request->sex; $data['educational'] = $request->educational; $data['occupation'] = $request->occupation; $data['income'] = $request->income; $data['matrimony'] = $request->matrimony; $data['addresss'] = $request->addresss; $data['registration'] = $request->registration; $data['content'] = $request->content; $data['create_time'] = time(); } if ($step == 2) { $data['family'] = $request->family; $data['is_only'] = $request->is_only; $data['married'] = $request->married; $data['car'] = $request->car; $data['house'] = $request->house; $data['peculiarity'] = $request->peculiarity; } if ($step == 3) { $data['choose_age'] = $request->choose_age; $data['choose_small_height'] = $request->choose_small_height; $data['choose_small_educational'] = $request->choose_small_educational; $data['choose_income'] = $request->choose_income; $data['choose_matrimony'] = $request->choose_matrimony; $data['choose_house'] = $request->choose_house; $data['choose_child'] = $request->choose_child; $data['choose_content'] = $request->choose_content; } // 更新会员的性别 if ($step == 1) { // 更新会员 country $user = WxUser::where('id', $uid)->first(); //print_r($user->area);exit; // address 分为province、city、area $address = $request->addresss; //print_r($address);exit; $addressArray = explode(',', $address); // $user->province = $addressArray[0]; // $user->city = $addressArray[1]; // $user->district = $addressArray[2]; // $user->country = '中国'; // $user->gender = $request->age; //$user->save(); // 获取 requirement 并逗号分隔 获取是否有 亿友圈内找对象 文字 $requirement = $user->requirement; $requirementArray = explode(',', $requirement); $is_find = 0; foreach ($requirementArray as $key => $val) { if (strpos($val, '亿友圈内找对象') !== false) { $is_find = 1; $data['status'] = 1; } } } if ($count > 0) { $data['step'] = $step; // return $this->success($data); // 如果存在更新里面的数据 Conditions::where('user_id', $uid)->update($data); } else { $data['step'] = 1; $data['user_id'] = $uid; $data['create_time'] = time(); Conditions::create($data); } return $this->success(); } public function getNameInfo($data, $id) { $name = ''; foreach ($data as $item) { if ($item['id'] == $id) { $name = $item['name']; break; } } return $name; } /** 获取用户的条件 * @param Request $request * @return \Illuminate\Http\JsonResponse */ public function getConditions(Request $request) { // 获取当前用户表里的年龄 $user = WxUser::where('id', $request->uid)->first(); // 获取当前用户的条件 Conditions $info = Conditions::where('user_id', $request->uid)->first(); if (empty($info)) { // return $this->fail(200000, [], '暂无数据'); $info['step'] = 1; // 获取用户信息 $user = WxUser::where('id', $request->uid)->first(); $info['sex'] = $user->gender; $info['sex_name'] = $info['sex'] == 1 ? '男' : '女'; $info['age'] = $user->age; return $this->success($info); } $info['sex_name'] = $info['sex'] == 1 ? '男' : '女'; $info['only_name'] = $info['is_only'] == 1 ? '是' : '否'; $info['age'] = $user->age; $settings = $this->getSettings(2); $info['educational_name'] = $this->getNameInfo($settings['educational'], $info['educational']); $info['occupation_name'] = $this->getNameInfo($settings['occupation'], $info['occupation']); $info['income_name'] = $this->getNameInfo($settings['income'], $info['income']); $info['matrimony_name'] = $this->getNameInfo($settings['matrimony'], $info['matrimony']); $info['married_name'] = $this->getNameInfo($settings['married'], $info['married']); $info['car_name'] = $this->getNameInfo($settings['car'], $info['car']); $info['house_name'] = $this->getNameInfo($settings['house'], $info['house']); $info['choose_small_educational_name'] = $this->getNameInfo($settings['educational'], $info['choose_small_educational']); $info['choose_matrimony_name'] = $this->getNameInfo($settings['matrimony'], $info['choose_matrimony']); $info['choose_child_name'] = $info['choose_child'] == 1 ? '接受' : '不接受'; // 获取实名认证状态 $user = UserStanding::where('user_id', $request->uid)->orderBy('id','desc')->first(); if (empty($user)) { $info['real_name'] = ''; $info['card_num'] = ''; $info['identity_picture'] = ''; $info['identity_picture_the'] = ''; $info['is_examine'] = 3; } else { $info['real_name'] = $user->real_name ?? ''; $info['card_num'] = $user->card_num ?? ''; $info['identity_picture'] = $user->identity_picture ?? ''; $info['identity_picture_the'] = $user->identity_picture_the ?? ''; $info['is_examine'] = $user->is_examine ?? 3; } $info['user_educational'] = $this->getConditionsById($info['educational'],'educational'); $info['user_occupation'] = $this->getConditionsById($info['occupation'],'occupation'); $info['user_income'] = $this->getConditionsById($info['income'],'income'); $info['user_matrimony'] = $this->getConditionsById($info['matrimony'],'matrimony'); $info['user_family'] = $this->getConditionsById($info['family'],'family'); $info['user_married'] = $this->getConditionsById($info['married'],'married'); $info['user_car'] = $this->getConditionsById($info['car'],'car'); $info['user_house'] = $this->getConditionsById($info['house'],'house'); $info['user_peculiarity'] = $this->getConditionsById($info['peculiarity'],'peculiarity',4); $info['user_choose_age'] = $this->getConditionsById($info['choose_age'],'choose_age',1); $info['user_choose_small_height'] = $this->getConditionsById($info['choose_small_height'],'choose_small_height',1); $info['user_choose_small_educational'] = $this->getConditionsById($info['choose_small_educational'],'choose_small_educational',1); $info['user_choose_income'] = $this->getConditionsById($info['choose_income'],'choose_income',1); $info['user_choose_matrimony'] = $this->getConditionsById($info['choose_matrimony'],'choose_matrimony',1); $info['user_choose_house'] = $this->getConditionsById($info['choose_house'],'choose_house',1); $info['user_choose_child'] = $this->getConditionsById($info['choose_child'],'choose_child',1); $info['user_choose_content'] = $this->getConditionsById($info['choose_content'],'choose_content',4); $info['user_is_only'] = $this->getConditionsById($info['is_only'],'is_only',1); if (empty($info)) { $info['step'] = 1; } else { if ($info['step'] == 0) { $info['step'] = 1; } else { $info['step'] = $info['step'] + 1; } } return $this->success($info); } /** * 根据id获取用户所选的条件 */ public function getConditionsById($id,$name,$type = 1) { $settings = $this->getSettings(2); $list = $settings[$name]; if ($type == 1) { foreach ($list as $key => $val) { if ($val['id'] == $id) { return $val; } } } if ($type == 2) { foreach ($list as $key => $val) { if ($val['name'] == $id) { return $val; } } } if ($type == 3) { $arr = []; // $id = '品味出众,重视家庭'; $idArray = array_map('trim', explode(',', $id)); $arr = array_filter($list, function($val) use ($idArray) { return in_array(trim($val['name']), $idArray); }); $arr = array_values($arr); return $arr; } if ($type == 4) { $arr = []; $idArray = array_map('trim', explode(',', $id)); $arr = array_filter($list, function($val) use ($idArray) { return in_array(trim($val['id']), $idArray); }); // 重拍数组 $arr = array_values($arr); return $arr; } return ''; } /** * 获取配置信息 */ public function getSettings($type = 1) { // 学历配置, 初中以下,高中,大专,本科,硕士,博士 $educational = [ ['id' => 1, 'name' => '初中以下','search_name' => '初中以下'], ['id' => 2, 'name' => '高中','search_name' =>'高中及以上'], ['id' => 3, 'name' => '大专','search_name' => '大专及以上'], ['id' => 4, 'name' => '本科','search_name' => '本科及以上'], ['id' => 5, 'name' => '硕士','search_name' => '硕士及以上'], ['id' => 6, 'name' => '博士','search_name' => '博士及以上'], ]; // 职业配置 occupation $occupation = [ ['id' => 1, 'name' => '学生'], ['id' => 2, 'name' => '教师'], ['id' => 3, 'name' => '医生'], ['id' => 4, 'name' => '程序员'], ['id' => 5, 'name' => '公务员'], ['id' => 6, 'name' => '警察'], ['id' => 7, 'name' => '军人'], ['id' => 8, 'name' => '司机'], ['id' => 9, 'name' => '厨师'], ['id' => 10, 'name' => '服务员'], ['id' => 11, 'name' => '销售'], ['id' => 12, 'name' => '保安'], ['id' => 13, 'name' => '保姆'], ['id' => 14, 'name' => '其他'], ]; // income 收入配置 $income = [ ['id' => 1, 'name' => '2000以下'], ['id' => 2, 'name' => '2000-5000'], ['id' => 3, 'name' => '5000-8000'], ['id' => 4, 'name' => '8000-12000'], ['id' => 5, 'name' => '12000-20000'], ['id' => 6, 'name' => '20000以上'], ]; // 婚姻状况配置 matrimony $matrimony = [ ['id' => 1, 'name' => '未婚'], ['id' => 2, 'name' => '离异'], ['id' => 3, 'name' => '丧偶'], ]; // married 何时结婚配置 $married = [ ['id' => 1, 'name' => '一年内'], ['id' => 2, 'name' => '两年内'], ['id' => 3, 'name' => '三年内'], ['id' => 4, 'name' => '四年内'], ['id' => 5, 'name' => '五年内'], ['id' => 6, 'name' => '五年以上'], ]; // car 买车情况配置 $car = [ ['id' => 1, 'name' => '已买车'], ['id' => 2, 'name' => '未买车'], ]; // house 买房情况配置 $house = [ ['id' => 1, 'name' => '已买房'], ['id' => 2, 'name' => '未买房'], ]; // choose_age 择偶-年龄范围 $choose_age = [ ['id' => 1, 'name' => '18-25'], ['id' => 2, 'name' => '26-30'], ['id' => 3, 'name' => '31-35'], ['id' => 4, 'name' => '36-40'], ['id' => 5, 'name' => '41-45'], ['id' => 6, 'name' => '46-50'], ['id' => 7, 'name' => '51-55'], ['id' => 8, 'name' => '56-60'], ['id' => 9, 'name' => '60以上'], ]; // 家庭背景 $family = [ ['id' => 1, 'name' => '一般'], ['id' => 2, 'name' => '良好'], ['id' => 3, 'name' => '优秀'], ]; // peculiarity 特点 $peculiarity = [ ['id' => 1, 'name' => '温柔'], ['id' => 2, 'name' => '善良'], ['id' => 3, 'name' => '孝顺'], ['id' => 4, 'name' => '幽默'], ['id' => 5, 'name' => '开朗'], ['id' => 6, 'name' => '大方'], ['id' => 7, 'name' => '细心'], ['id' => 8, 'name' => '有责任心'], ['id' => 9, 'name' => '有上进心'], ['id' => 10, 'name' => '有爱心'], ]; // 我的补充(补充个人信息的内容) $user_content = [ ['id' => 1, 'name' => '我是一个有责任心的人'], ['id' => 2, 'name' => '我是一个有爱心的人'], ['id' => 3, 'name' => '我是一个有上进心的人'], ]; // 独生子女 $is_only = [ ['id' => 1, 'name' => '是'], ['id' => 2, 'name' => '否'], ]; // 希望Ta有的特点 $choose_content = [ ['id' => 1, 'name' => '品味出众'], ['id' => 2, 'name' => '喜欢厨艺'], ['id' => 3, 'name' => '不冷暴力'], ['id' => 4, 'name' => '重视家庭'], ['id' => 5, 'name' => '整洁干净'], ['id' => 6, 'name' => '阳光运动'], ['id' => 7, 'name' => '文艺范'], ['id' => 8, 'name' => '懂得尊重'], ['id' => 9, 'name' => '低调沉稳'], ['id' => 10, 'name' => '心地善良'], ]; // 最低身高 $choose_small_height = [ ['id' => 1, 'name' => '150cm'], ['id' => 2, 'name' => '155cm'], ['id' => 3, 'name' => '160cm'], ['id' => 4, 'name' => '165cm'], ['id' => 5, 'name' => '170cm'], ['id' => 6, 'name' => '175cm'], ['id' => 7, 'name' => '180cm'], ['id' => 8, 'name' => '185cm'], ['id' => 9, 'name' => '不限'], ]; // 最低月薪 $choose_income = [ ['id' => 1, 'name' => '2000'], ['id' => 2, 'name' => '3000'], ['id' => 3, 'name' => '4000'], ['id' => 4, 'name' => '5000'], ['id' => 5, 'name' => '6000'], ['id' => 6, 'name' => '7000'], ['id' => 7, 'name' => '8000'], ['id' => 8, 'name' => '9000'], ['id' => 9, 'name' => '10000'], ['id' => 10, 'name' => '15000'], ['id' => 11, 'name' => '20000'], ['id' => 12, 'name' => '30000'], ['id' => 13, 'name' => '不限'], ]; // 择偶-最低学历 $choose_small_educational = [ ['id' => 1, 'name' => '初中'], ['id' => 2, 'name' => '高中'], ['id' => 3, 'name' => '大专'], ['id' => 4, 'name' => '本科'], ['id' => 5, 'name' => '硕士'], ['id' => 6, 'name' => '博士'], ['id' => 7, 'name' => '不限'], ]; // 择偶-婚姻状况要求 $choose_matrimony = [ ['id' => 1, 'name' => '未婚'], ['id' => 2, 'name' => '离异'], ['id' => 3, 'name' => '丧偶'], ['id' => 4, 'name' => '不限'], ]; // 择偶-住房要求 $choose_house = [ ['id' => 1, 'name' => '已买房'], ['id' => 2, 'name' => '未买房'], ['id' => 3, 'name' => '不限'], ]; // 择偶-接受对方小孩 $choose_child = [ ['id' => 1, 'name' => '接受'], ['id' => 2, 'name' => '不接受'], ]; $data['educational'] = $educational; $data['occupation'] = $occupation; $data['income'] = $income; $data['matrimony'] = $matrimony; $data['married'] = $married; $data['car'] = $car; $data['house'] = $house; $data['choose_age'] = $choose_age; $data['choose_content'] = $choose_content; $data['is_only'] = $is_only; $data['user_content'] = $user_content; $data['peculiarity'] = $peculiarity; $data['family'] = $family; $data['choose_income'] = $choose_income; $data['choose_small_height'] = $choose_small_height; $data['choose_small_educational'] = $choose_small_educational; $data['choose_house'] = $choose_house; $data['choose_child'] = $choose_child; $data['choose_matrimony'] = $choose_matrimony; if ($type == 2) { return $data; } return $this->success($data); } }