|
@@ -0,0 +1,568 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+namespace app\matchmaker\controller;
|
|
|
+
|
|
|
+use app\common\Constant;
|
|
|
+use app\common\Fun;
|
|
|
+use app\love\model\UserModel;
|
|
|
+use app\matchmaker\model\MatchmakerUserFollowModel;
|
|
|
+use app\matchmaker\model\MatchmakerUserMatingModel;
|
|
|
+use app\matchmaker\model\MatchmakerUserModel;
|
|
|
+
|
|
|
+class UserController extends MatchmakerBaseController
|
|
|
+{
|
|
|
+ public function infoAdd()
|
|
|
+ {
|
|
|
+ $data = [
|
|
|
+ 'sex' => Constant::SEX_MATCHMAKER,
|
|
|
+ 'marry' => Constant::MARRY,
|
|
|
+ 'high' => Constant::HIGH,
|
|
|
+ 'weight' => Constant::WEIGHT,
|
|
|
+ 'education' => Constant::EDUCATION,
|
|
|
+ 'income' => Constant::INCOME,
|
|
|
+ 'nation' => Constant::NATION,
|
|
|
+ 'smoke' => Constant::SMOKE,
|
|
|
+ 'drink' => Constant::DRINK,
|
|
|
+ 'family' => Constant::FAMILY,
|
|
|
+ 'tinyint' => Constant::TINYINT,
|
|
|
+ ];
|
|
|
+ foreach ($data as &$v) {
|
|
|
+ $v = json_encode($v);
|
|
|
+ unset($v);
|
|
|
+ }
|
|
|
+
|
|
|
+ return $this->fetch('', $data);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function infoAddPost()
|
|
|
+ {
|
|
|
+ $value = $this->request->post();
|
|
|
+ $value['birthday'] = strtotime($value['birthday']);
|
|
|
+ $value['matchmaker_id'] = $this->matchmaker['id'];
|
|
|
+ $user = MatchmakerUserModel::create($value);
|
|
|
+ MatchmakerUserMatingModel::create(['user_id' => $user['id']]);
|
|
|
+ $this->success('', '', ['id' => $user['id']]);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function matingAdd()
|
|
|
+ {
|
|
|
+ $id = $this->request->param('id');
|
|
|
+ if (empty($id)) {
|
|
|
+ $this->error('参数错误');
|
|
|
+ }
|
|
|
+ $mating = MatchmakerUserMatingModel::get(['user_id' => $id]);
|
|
|
+ $this->assign('mating', $mating);
|
|
|
+
|
|
|
+ $education = Constant::EDUCATION;
|
|
|
+ $education[] = '无要求';
|
|
|
+ $data = [
|
|
|
+ 'min_age' => Constant::MIN_AGE,
|
|
|
+ 'max_age' => Constant::MAX_AGE,
|
|
|
+ 'min_high' => Constant::MIN_HIGH,
|
|
|
+ 'max_high' => Constant::MAX_HIGH,
|
|
|
+ 'min_weight' => Constant::MIN_WEIGHT,
|
|
|
+ 'max_weight' => Constant::MAX_WEIGHT,
|
|
|
+ 'native' => Constant::NATIVE,
|
|
|
+ 'education' => $education,
|
|
|
+ 'income' => Constant::COND_INCOME,
|
|
|
+ 'smoke' => Constant::SMOKE,
|
|
|
+ 'drink' => Constant::DRINK,
|
|
|
+ 'tinyint' => Constant::COND_TINYINT,
|
|
|
+ ];
|
|
|
+ foreach ($data as &$v) {
|
|
|
+ $v = json_encode($v);
|
|
|
+ unset($v);
|
|
|
+ }
|
|
|
+
|
|
|
+ return $this->fetch('', $data);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function matingAddPost()
|
|
|
+ {
|
|
|
+ $param = $this->request->post();
|
|
|
+ MatchmakerUserMatingModel::update($param);
|
|
|
+ $this->success('操作成功');
|
|
|
+ }
|
|
|
+
|
|
|
+ public function infoEdit()
|
|
|
+ {
|
|
|
+ $id = $this->request->param('id');
|
|
|
+ if (empty($id)) {
|
|
|
+ $this->error('参数错误');
|
|
|
+ }
|
|
|
+
|
|
|
+ $user = MatchmakerUserModel::get($id);
|
|
|
+ if (empty($user)) {
|
|
|
+ $this->error('该用户不存在或已删除');
|
|
|
+ }
|
|
|
+ $user['birthday'] = date('Y-m-d', $user['birthday']);
|
|
|
+ $this->assign('user', json_encode($user));
|
|
|
+
|
|
|
+ $data = [
|
|
|
+ 'sex' => Constant::SEX_MATCHMAKER,
|
|
|
+ 'marry' => Constant::MARRY,
|
|
|
+ 'high' => Constant::HIGH,
|
|
|
+ 'weight' => Constant::WEIGHT,
|
|
|
+ 'education' => Constant::EDUCATION,
|
|
|
+ 'income' => Constant::INCOME,
|
|
|
+ 'nation' => Constant::NATION,
|
|
|
+ 'smoke' => Constant::SMOKE,
|
|
|
+ 'drink' => Constant::DRINK,
|
|
|
+ 'family' => Constant::FAMILY,
|
|
|
+ 'tinyint' => Constant::TINYINT,
|
|
|
+ ];
|
|
|
+ foreach ($data as &$v) {
|
|
|
+ $v = json_encode($v);
|
|
|
+ unset($v);
|
|
|
+ }
|
|
|
+
|
|
|
+ return $this->fetch('', $data);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function infoEditPost()
|
|
|
+ {
|
|
|
+ $value = $this->request->post();
|
|
|
+ $value['birthday'] = strtotime($value['birthday']);
|
|
|
+ MatchmakerUserModel::update($value);
|
|
|
+
|
|
|
+ $this->success();
|
|
|
+ }
|
|
|
+
|
|
|
+ public function matingEdit()
|
|
|
+ {
|
|
|
+ $id = $this->request->param('id');
|
|
|
+ if (empty($id)) {
|
|
|
+ $this->error('参数错误');
|
|
|
+ }
|
|
|
+ $mating = MatchmakerUserMatingModel::get(['user_id' => $id]);
|
|
|
+ $this->assign('mating', $mating);
|
|
|
+
|
|
|
+ $education = Constant::EDUCATION;
|
|
|
+ $education[] = '无要求';
|
|
|
+ $data = [
|
|
|
+ 'min_age' => Constant::MIN_AGE,
|
|
|
+ 'max_age' => Constant::MAX_AGE,
|
|
|
+ 'min_high' => Constant::MIN_HIGH,
|
|
|
+ 'max_high' => Constant::MAX_HIGH,
|
|
|
+ 'min_weight' => Constant::MIN_WEIGHT,
|
|
|
+ 'max_weight' => Constant::MAX_WEIGHT,
|
|
|
+ 'native' => Constant::NATIVE,
|
|
|
+ 'education' => $education,
|
|
|
+ 'income' => Constant::COND_INCOME,
|
|
|
+ 'smoke' => Constant::SMOKE,
|
|
|
+ 'drink' => Constant::DRINK,
|
|
|
+ 'tinyint' => Constant::COND_TINYINT,
|
|
|
+ ];
|
|
|
+ foreach ($data as &$v) {
|
|
|
+ $v = json_encode($v);
|
|
|
+ unset($v);
|
|
|
+ }
|
|
|
+
|
|
|
+ return $this->fetch('', $data);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function matingEditPost()
|
|
|
+ {
|
|
|
+ $param = $this->request->post();
|
|
|
+ MatchmakerUserMatingModel::update($param);
|
|
|
+ $this->success('操作成功');
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 图片上传
|
|
|
+ */
|
|
|
+ public function imageUpload()
|
|
|
+ {
|
|
|
+ $file = $this->request->post('file');
|
|
|
+ $ext = pathinfo($this->request->post('name'))['extension'];
|
|
|
+ if (!in_array($ext, ['jpg', 'jpeg', 'png'])) {
|
|
|
+ $this->error('文件后缀必须为jpg,jpeg,png');
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($file) {
|
|
|
+
|
|
|
+ $upload_dir = WEB_ROOT . 'upload/image';
|
|
|
+ if (!is_dir($upload_dir)) {
|
|
|
+ @mkdir($upload_dir);
|
|
|
+ }
|
|
|
+ $upload_dir = $upload_dir . '/' . date('Ymd');
|
|
|
+ if (!is_dir($upload_dir)) {
|
|
|
+ @mkdir($upload_dir);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ $file_name = $this->_file_name($ext);
|
|
|
+ $file_path = $upload_dir . '/' . $file_name;
|
|
|
+ $is_upload = $this->_base64_image_content($file, $file_path);
|
|
|
+ if (!$is_upload) {
|
|
|
+ $this->error('上传失败,请重新上传');
|
|
|
+ }
|
|
|
+
|
|
|
+ $avatar = cmf_get_user_avatar_url('image' . '/' . date('Ymd') . '/' . $file_name);
|
|
|
+
|
|
|
+ $this->result([
|
|
|
+ 'avatar' => $avatar,
|
|
|
+ ], 1);
|
|
|
+ } else {
|
|
|
+ $this->error('请上传文件');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 跟进
|
|
|
+ */
|
|
|
+ public function follow()
|
|
|
+ {
|
|
|
+ $id = $this->request->get('id');
|
|
|
+ $list = MatchmakerUserFollowModel::where('user_id', $id)->append(['create_time_text'])->order('create_time desc')->select();
|
|
|
+ $info = MatchmakerUserModel::get($id);
|
|
|
+ $info['age'] = Fun::getAgeByBirth($info['birthday']);
|
|
|
+ $info['sex_text'] = Constant::SEX[$info['sex']];
|
|
|
+
|
|
|
+ return $this->fetch('', ['list' => $list, 'id' => $id, 'info' => $info]);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 跟进提交
|
|
|
+ */
|
|
|
+ public function followPost()
|
|
|
+ {
|
|
|
+ $data = $this->request->param();
|
|
|
+ if (empty($data['user_id'])) {
|
|
|
+ $this->error('数据异常,请刷新重试');
|
|
|
+ }
|
|
|
+ if (empty($data['content'])) {
|
|
|
+ $this->error('请输入内容');
|
|
|
+ }
|
|
|
+
|
|
|
+ $data['create_time'] = time();
|
|
|
+ MatchmakerUserFollowModel::create($data);
|
|
|
+
|
|
|
+ $this->success('操作成功');
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 匹配
|
|
|
+ */
|
|
|
+ public function match()
|
|
|
+ {
|
|
|
+ $id = $this->request->param('id');
|
|
|
+ $type = $this->request->param('type', 0);
|
|
|
+ if (empty($id)) {
|
|
|
+ $this->error('该用户不存在');
|
|
|
+ }
|
|
|
+ $user = MatchmakerUserModel::get($id);
|
|
|
+ if (empty($user)) {
|
|
|
+ $this->error('该用户不存在');
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($type == 0) {
|
|
|
+
|
|
|
+ $list = MatchmakerUserModel::where('matchmaker_id', $this->matchmaker->id)
|
|
|
+ ->where('id', '<>', $id)
|
|
|
+ ->where('sex', '<>', $user['sex'] == 1 ? 2 : 1)
|
|
|
+ ->append(['sex_text'])
|
|
|
+ ->select();
|
|
|
+ } elseif ($type == 1) {
|
|
|
+
|
|
|
+ $list = MatchmakerUserModel::with('matchmaker')
|
|
|
+ ->where('matchmaker_id', '<>', $this->matchmaker->id)
|
|
|
+ ->where('sex', '<>', $user['sex'] == 1 ? 2 : 1)
|
|
|
+ ->append(['sex_text'])
|
|
|
+ ->select();
|
|
|
+ } else {
|
|
|
+
|
|
|
+ $list = UserModel::where('user_type', 2)
|
|
|
+ ->where('user_status', 1)
|
|
|
+ ->where('sex', '=', $user['sex'] == 1 ? 2 : 1)
|
|
|
+ ->append(['sex_text'])
|
|
|
+ ->select();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ $mating = MatchmakerUserMatingModel::where('user_id', $id)->find();
|
|
|
+ $res = $this->_orderMatchUser($list->toArray(), $mating);
|
|
|
+
|
|
|
+ return $this->fetch('', [
|
|
|
+ 'list' => json_encode($res),
|
|
|
+ 'type' => $type,
|
|
|
+ 'user' => $user,
|
|
|
+ 'id' => $id,
|
|
|
+ 'mating' => $mating,
|
|
|
+ 'tinyint' => json_encode(Constant::TINYINT),
|
|
|
+ 'cond_tinyint' => json_encode(Constant::COND_TINYINT),
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+
|
|
|
+ private function _file_name($ext)
|
|
|
+ {
|
|
|
+
|
|
|
+
|
|
|
+ $chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
|
|
+
|
|
|
+ $newchars = str_split($chars);
|
|
|
+
|
|
|
+ shuffle($newchars);
|
|
|
+
|
|
|
+ $chars_key = array_rand($newchars, 15);
|
|
|
+
|
|
|
+ $fnstr = '';
|
|
|
+ for ($i = 0; $i < 15; $i++) {
|
|
|
+ $fnstr .= $newchars[$chars_key[$i]];
|
|
|
+ }
|
|
|
+
|
|
|
+ return md5($fnstr . microtime(true) * 1000) . '.' . $ext;
|
|
|
+ }
|
|
|
+
|
|
|
+ private function _base64_image_content($base64_image_content, $file_path)
|
|
|
+ {
|
|
|
+
|
|
|
+ if (preg_match('/^(data:\s*image\/(\w+);base64,)/', $base64_image_content, $result)) {
|
|
|
+ if (file_put_contents($file_path, base64_decode(str_replace($result[1], '', $base64_image_content)))) {
|
|
|
+ return true;
|
|
|
+ } else {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 排序
|
|
|
+ */
|
|
|
+ private function _orderMatchUser($list, $mating)
|
|
|
+ {
|
|
|
+
|
|
|
+ foreach ($list as $k => $v) {
|
|
|
+ $match_arr = [];
|
|
|
+ $match_count = 0;
|
|
|
+
|
|
|
+
|
|
|
+ $age = Fun::getAgeByBirth($v['birthday']);
|
|
|
+ if (empty($mating['min_age']) && empty($mating['max_age'])) {
|
|
|
+ $match_arr[] = 'age';
|
|
|
+ $match_count++;
|
|
|
+ } elseif (empty($mating['min_age'])) {
|
|
|
+ if ($age <= $mating['max_age']) {
|
|
|
+ $match_arr[] = 'age';
|
|
|
+ $match_count++;
|
|
|
+ }
|
|
|
+ } elseif (empty($mating['max_age'])) {
|
|
|
+ if ($age >= $mating['min_age']) {
|
|
|
+ $match_arr[] = 'age';
|
|
|
+ $match_count++;
|
|
|
+ }
|
|
|
+ } elseif ($age >= $mating['min_age'] && $age <= $mating['max_age']) {
|
|
|
+ $match_arr[] = 'age';
|
|
|
+ $match_count++;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if (empty($mating['min_high']) && empty($mating['max_high'])) {
|
|
|
+ $match_arr[] = 'high';
|
|
|
+ $match_count++;
|
|
|
+ } elseif (empty($mating['min_high'])) {
|
|
|
+ if ($v['high'] <= $mating['max_high']) {
|
|
|
+ $match_arr[] = 'high';
|
|
|
+ $match_count++;
|
|
|
+ }
|
|
|
+ } elseif (empty($mating['max_high'])) {
|
|
|
+ if ($v['high'] >= $mating['min_high']) {
|
|
|
+ $match_arr[] = 'high';
|
|
|
+ $match_count++;
|
|
|
+ }
|
|
|
+ } elseif ($v['high'] >= $mating['min_high'] && $v['high'] <= $mating['max_high']) {
|
|
|
+ $match_arr[] = 'high';
|
|
|
+ $match_count++;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if (empty($mating['min_weight']) && empty($mating['max_weight'])) {
|
|
|
+ $match_arr[] = 'weight';
|
|
|
+ $match_count++;
|
|
|
+ } elseif (empty($mating['min_weight'])) {
|
|
|
+ if ($v['weight'] <= $mating['max_weight']) {
|
|
|
+ $match_arr[] = 'weight';
|
|
|
+ $match_count++;
|
|
|
+ }
|
|
|
+ } elseif (empty($mating['max_weight'])) {
|
|
|
+ if ($v['weight'] >= $mating['min_weight']) {
|
|
|
+ $match_arr[] = 'weight';
|
|
|
+ $match_count++;
|
|
|
+ }
|
|
|
+ } elseif ($v['weight'] >= $mating['min_weight'] && $v['weight'] <= $mating['max_weight']) {
|
|
|
+ $match_arr[] = 'weight';
|
|
|
+ $match_count++;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if ($mating['native'] == '无要求') {
|
|
|
+ $match_arr[] = 'native';
|
|
|
+ $match_count++;
|
|
|
+ } elseif ($mating['native'] == '晋江籍') {
|
|
|
+ if (strpos($v['native'], '晋江') !== false) {
|
|
|
+ $match_arr[] = 'native';
|
|
|
+ $match_count++;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (strpos($v['native'], '晋江') === false) {
|
|
|
+ $match_arr[] = 'native';
|
|
|
+ $match_count++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if ($mating['education'] == '无要求' || $mating['education'] == '本科以下') {
|
|
|
+ $match_arr[] = 'education';
|
|
|
+ $match_count++;
|
|
|
+ } elseif ($mating['education'] == '本科') {
|
|
|
+ if (in_array($v['education'], ['本科', '硕士', '博士'])) {
|
|
|
+ $match_arr[] = 'education';
|
|
|
+ $match_count++;
|
|
|
+ }
|
|
|
+ } elseif ($mating['education'] == '硕士') {
|
|
|
+ if (in_array($v['education'], ['硕士', '博士'])) {
|
|
|
+ $match_arr[] = 'education';
|
|
|
+ $match_count++;
|
|
|
+ }
|
|
|
+ } elseif ($mating['education'] == '博士') {
|
|
|
+ if ($v['education'] == '博士') {
|
|
|
+ $match_arr[] = 'education';
|
|
|
+ $match_count++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if ($mating['income'] == '不限' || $mating['income'] == '5万以下') {
|
|
|
+ $match_arr[] = 'income';
|
|
|
+ $match_count++;
|
|
|
+ } elseif ($mating['income'] == '5-10万') {
|
|
|
+ if (in_array($v['income'], ['5-10万', '10-20万', '20-30万', '30-50万', '50-100万', '100万以上'])) {
|
|
|
+ $match_arr[] = 'income';
|
|
|
+ $match_count++;
|
|
|
+ }
|
|
|
+ } elseif ($mating['income'] == '10-20万') {
|
|
|
+ if (in_array($v['income'], ['10-20万', '20-30万', '30-50万', '50-100万', '100万以上'])) {
|
|
|
+ $match_arr[] = 'income';
|
|
|
+ $match_count++;
|
|
|
+ }
|
|
|
+ } elseif ($mating['income'] == '20-30万') {
|
|
|
+ if (in_array($v['income'], ['20-30万', '30-50万', '50-100万', '100万以上'])) {
|
|
|
+ $match_arr[] = 'income';
|
|
|
+ $match_count++;
|
|
|
+ }
|
|
|
+ } elseif ($mating['income'] == '30-50万') {
|
|
|
+ if (in_array($v['income'], ['30-50万', '50-100万', '100万以上'])) {
|
|
|
+ $match_arr[] = 'income';
|
|
|
+ $match_count++;
|
|
|
+ }
|
|
|
+ } elseif ($mating['income'] == '50-100万') {
|
|
|
+ if (in_array($v['income'], ['50-100万', '100万以上'])) {
|
|
|
+ $match_arr[] = 'income';
|
|
|
+ $match_count++;
|
|
|
+ }
|
|
|
+ } elseif ($mating['income'] == '100万以上') {
|
|
|
+ if (in_array($v['income'], ['100万以上'])) {
|
|
|
+ $match_arr[] = 'income';
|
|
|
+ $match_count++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if ($mating['have_house'] == 1) {
|
|
|
+ if ($v['have_house'] == 1) {
|
|
|
+ $match_arr[] = 'have_house';
|
|
|
+ $match_count++;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ $match_arr[] = 'have_house';
|
|
|
+ $match_count++;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if ($mating['have_car'] == 1) {
|
|
|
+ if ($v['have_car'] == 1) {
|
|
|
+ $match_arr[] = 'have_car';
|
|
|
+ $match_count++;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ $match_arr[] = 'have_car';
|
|
|
+ $match_count++;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if ($mating['with_parent_live'] == 2) {
|
|
|
+ if ($v['with_parent_live'] == 2) {
|
|
|
+ $match_arr[] = 'with_parent_live';
|
|
|
+ $match_count++;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ $match_arr[] = 'with_parent_live';
|
|
|
+ $match_count++;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if ($mating['smoke'] == '烟不离手' || $mating['smoke'] == '' || $mating['smoke'] == '不吸烟,但不反感') {
|
|
|
+ $match_arr[] = 'smoke';
|
|
|
+ $match_count++;
|
|
|
+ } elseif ($mating['smoke'] == '社交时偶尔吸烟') {
|
|
|
+ if (in_array($v['smoke'], ['社交时偶尔吸烟', '不吸烟,但不反感', '不吸,很反感'])) {
|
|
|
+ $match_arr[] = 'smoke';
|
|
|
+ $match_count++;
|
|
|
+ }
|
|
|
+ } elseif ($mating['smoke'] == '不吸,很反感') {
|
|
|
+ if (in_array($v['smoke'], ['不吸,很反感', '不吸烟,但不反感'])) {
|
|
|
+ $match_arr[] = 'smoke';
|
|
|
+ $match_count++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if ($mating['drink'] == '酒不离口' || $mating['drink'] == '') {
|
|
|
+ $match_arr[] = 'drink';
|
|
|
+ $match_count++;
|
|
|
+ } elseif ($mating['drink'] == '兴致时小酌' || $mating['drink'] == '社交需要喝') {
|
|
|
+ if ($v['drink'] == '兴致时小酌' || $v['drink'] == '社交需要喝') {
|
|
|
+ $match_arr[] = 'drink';
|
|
|
+ $match_count++;
|
|
|
+ }
|
|
|
+ } elseif ($mating['drink'] == '不喝酒') {
|
|
|
+ if ($v['drink'] == '不喝酒') {
|
|
|
+ $match_arr[] = 'drink';
|
|
|
+ $match_count++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $list[$k]['age'] = $age;
|
|
|
+ $list[$k]['match_arr'] = $match_arr;
|
|
|
+ $list[$k]['match_count'] = $match_count;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ usort($list, function ($a, $b) {
|
|
|
+ if ($a['match_count'] < $b['match_count']) {
|
|
|
+ return 1;
|
|
|
+ } elseif ($a['match_count'] > $b['match_count']) {
|
|
|
+ return -1;
|
|
|
+ } else {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+ if (count($list) > 10) {
|
|
|
+ return array_slice($list, 0, 10);
|
|
|
+ } else {
|
|
|
+ return $list;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|