|
@@ -295,8 +295,12 @@ class UserController extends MatchmakerBaseController
|
|
*/
|
|
*/
|
|
public function match()
|
|
public function match()
|
|
{
|
|
{
|
|
- $id = $this->request->param('id');
|
|
|
|
- $type = $this->request->param('type', 0);
|
|
|
|
|
|
+ $id = $this->request->param('id');
|
|
|
|
+ $type = $this->request->param('type', 0);
|
|
|
|
+ $match_field = $this->request->param('match_field', '');
|
|
|
|
+
|
|
|
|
+ $mating = MatchmakerUserMatingModel::where('user_id', $id)->find();
|
|
|
|
+ $where = $this->_matchWhere($match_field, $mating);
|
|
if (empty($id)) {
|
|
if (empty($id)) {
|
|
$this->error('该用户不存在');
|
|
$this->error('该用户不存在');
|
|
}
|
|
}
|
|
@@ -308,21 +312,27 @@ class UserController extends MatchmakerBaseController
|
|
if ($type == 0) {
|
|
if ($type == 0) {
|
|
//自有库
|
|
//自有库
|
|
$list = MatchmakerUserModel::where('matchmaker_id', $this->matchmaker->id)
|
|
$list = MatchmakerUserModel::where('matchmaker_id', $this->matchmaker->id)
|
|
|
|
+ ->where($where)
|
|
->where('id', '<>', $id)
|
|
->where('id', '<>', $id)
|
|
->where('sex', '<>', $user['sex'] == 1 ? 1 : 2)
|
|
->where('sex', '<>', $user['sex'] == 1 ? 1 : 2)
|
|
|
|
+ ->where('status',2)
|
|
->append(['sex_text'])
|
|
->append(['sex_text'])
|
|
->select();
|
|
->select();
|
|
} elseif ($type == 1) {
|
|
} elseif ($type == 1) {
|
|
//其他红娘库
|
|
//其他红娘库
|
|
$list = MatchmakerUserModel::with('matchmaker')
|
|
$list = MatchmakerUserModel::with('matchmaker')
|
|
|
|
+ ->where($where)
|
|
->where('matchmaker_id', '<>', $this->matchmaker->id)
|
|
->where('matchmaker_id', '<>', $this->matchmaker->id)
|
|
->where('sex', '<>', $user['sex'] == 1 ? 1 : 2)
|
|
->where('sex', '<>', $user['sex'] == 1 ? 1 : 2)
|
|
|
|
+ ->where('status',2)
|
|
->append(['sex_text'])
|
|
->append(['sex_text'])
|
|
->select();
|
|
->select();
|
|
} else {
|
|
} else {
|
|
//系统库
|
|
//系统库
|
|
$list = UserModel::where('user_type', 2)
|
|
$list = UserModel::where('user_type', 2)
|
|
|
|
+ ->where($where)
|
|
->where('user_status', 1)
|
|
->where('user_status', 1)
|
|
|
|
+ ->where('want_status',2)
|
|
->where('is_complete', 1)
|
|
->where('is_complete', 1)
|
|
->where('sex', '<>', $user['sex'] == 1 ? 1 : 2)
|
|
->where('sex', '<>', $user['sex'] == 1 ? 1 : 2)
|
|
->append(['sex_text'])
|
|
->append(['sex_text'])
|
|
@@ -330,8 +340,7 @@ class UserController extends MatchmakerBaseController
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
- $mating = MatchmakerUserMatingModel::where('user_id', $id)->find();
|
|
|
|
- $res = $this->_orderMatchUser($list->toArray(), $mating);
|
|
|
|
|
|
+ $res = $this->_orderMatchUser($list->toArray(), $mating);
|
|
|
|
|
|
return $this->fetch('', [
|
|
return $this->fetch('', [
|
|
'list' => json_encode($res),
|
|
'list' => json_encode($res),
|
|
@@ -339,6 +348,7 @@ class UserController extends MatchmakerBaseController
|
|
'user' => $user,
|
|
'user' => $user,
|
|
'id' => $id,
|
|
'id' => $id,
|
|
'mating' => $mating,
|
|
'mating' => $mating,
|
|
|
|
+ 'match_field' => $match_field,
|
|
'tinyint' => json_encode(Constant::TINYINT),
|
|
'tinyint' => json_encode(Constant::TINYINT),
|
|
'cond_tinyint' => json_encode(Constant::COND_TINYINT),
|
|
'cond_tinyint' => json_encode(Constant::COND_TINYINT),
|
|
]);
|
|
]);
|
|
@@ -378,6 +388,154 @@ class UserController extends MatchmakerBaseController
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private function _matchWhere($field, $mating)
|
|
|
|
+ {
|
|
|
|
+ $where = [];
|
|
|
|
+ $match_field = [];
|
|
|
|
+ if (!empty($field)) {
|
|
|
|
+ $match_field = explode(',', $field);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //年龄
|
|
|
|
+ if (in_array('age', $match_field)) {
|
|
|
|
+ $year = date('Y');
|
|
|
|
+ if (!empty($mating['min_age'])) {
|
|
|
|
+ $min_year = $year - $mating['min_age'];
|
|
|
|
+ $min_year_time = strtotime(date($min_year . '-m-d H:i:s'));
|
|
|
|
+ $where[] = ['birthday', '<', $min_year_time];
|
|
|
|
+ }
|
|
|
|
+ if (!empty($mating['max_age'])) {
|
|
|
|
+ $max_year = $year - $mating['max_age'];
|
|
|
|
+ $max_year_time = strtotime(date($max_year . '-m-d H:i:s'));
|
|
|
|
+ $where[] = ['birthday', '>', $max_year_time];
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //身高
|
|
|
|
+ if (in_array('high', $match_field)) {
|
|
|
|
+ if (!empty($mating['min_high'])) {
|
|
|
|
+ $where[] = ['high', '>', $mating['min_high']];
|
|
|
|
+ }
|
|
|
|
+ if (!empty($mating['max_high'])) {
|
|
|
|
+ $where[] = ['high', '<', $mating['max_high']];
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //体重
|
|
|
|
+ if (in_array('weight', $match_field)) {
|
|
|
|
+ if (!empty($mating['min_weight'])) {
|
|
|
|
+ $where[] = ['weight', '>', $mating['min_weight']];
|
|
|
|
+ }
|
|
|
|
+ if (!empty($mating['max_weight'])) {
|
|
|
|
+ $where[] = ['weight', '<', $mating['max_weight']];
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //生肖
|
|
|
|
+ if (in_array('animal', $match_field)) {
|
|
|
|
+ if (!empty($mating['animal'])) {
|
|
|
|
+ foreach ($mating['animal'] as $animal) {
|
|
|
|
+ $where[] = ['animal', '<>', $animal];
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //籍贯
|
|
|
|
+ if (in_array('native', $match_field)) {
|
|
|
|
+ if ($mating['native'] == '晋江籍') {
|
|
|
|
+ $where[] = ['native', 'like', "%晋江%"];
|
|
|
|
+ }
|
|
|
|
+ if ($mating['native'] == '非晋江籍') {
|
|
|
|
+ $where[] = ['native', 'not like', "%晋江%"];
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //学历
|
|
|
|
+ if (in_array('education', $match_field)) {
|
|
|
|
+ if ($mating['education'] == '本科') {
|
|
|
|
+ $where[] = ['education', 'in', ['本科', '硕士', '博士']];
|
|
|
|
+ }
|
|
|
|
+ if ($mating['education'] == '硕士') {
|
|
|
|
+ $where[] = ['education', 'in', ['硕士', '博士']];
|
|
|
|
+ }
|
|
|
|
+ if ($mating['education'] == '博士') {
|
|
|
|
+ $where[] = ['education', '=', '博士'];
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //年收入
|
|
|
|
+ if (in_array('income', $match_field)) {
|
|
|
|
+ if ($mating['income'] == '5-10万') {
|
|
|
|
+ $where[] = ['income', 'in', ['5-10万', '10-20万', '20-30万', '30-50万', '50-100万', '100万以上']];
|
|
|
|
+ }
|
|
|
|
+ if ($mating['income'] == '10-20万') {
|
|
|
|
+ $where[] = ['income', 'in', ['10-20万', '20-30万', '30-50万', '50-100万', '100万以上']];
|
|
|
|
+ }
|
|
|
|
+ if ($mating['income'] == '20-30万') {
|
|
|
|
+ $where[] = ['income', 'in', ['20-30万', '30-50万', '50-100万', '100万以上']];
|
|
|
|
+ }
|
|
|
|
+ if ($mating['income'] == '30-50万') {
|
|
|
|
+ $where[] = ['income', 'in', ['30-50万', '50-100万', '100万以上']];
|
|
|
|
+ }
|
|
|
|
+ if ($mating['income'] == '50-100万') {
|
|
|
|
+ $where[] = ['income', 'in', ['50-100万', '100万以上']];
|
|
|
|
+ }
|
|
|
|
+ if ($mating['income'] == '100万以上') {
|
|
|
|
+ $where[] = ['income', '=', '100万以上'];
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //是否有房
|
|
|
|
+ if (in_array('have_house', $match_field)) {
|
|
|
|
+ if ($mating['have_house'] == 1) {
|
|
|
|
+ $where[] = ['have_house', '=', 1];
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //是否有车
|
|
|
|
+ if (in_array('have_car', $match_field)) {
|
|
|
|
+ if ($mating['have_car'] == 1) {
|
|
|
|
+ $where[] = ['have_car', '=', 1];
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //婚后是否愿意与父母同住
|
|
|
|
+ if (in_array('with_parent_live', $match_field)) {
|
|
|
|
+ if ($mating['with_parent_live'] == 1) {
|
|
|
|
+ $where[] = ['with_parent_live', '=', 1];
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //是否吸烟
|
|
|
|
+ if (in_array('smoke', $match_field)) {
|
|
|
|
+ if ($mating['smoke'] == '接受偶尔') {
|
|
|
|
+ $where[] = ['smoke', 'in', ['社交时偶尔吸烟', '不吸烟,但不反感', '不吸,很反感']];
|
|
|
|
+ }
|
|
|
|
+ if ($mating['smoke'] == '反感') {
|
|
|
|
+ $where[] = ['smoke', 'in', ['不吸,很反感', '不吸烟,但不反感']];
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //是否喝酒
|
|
|
|
+ if (in_array('drink', $match_field)) {
|
|
|
|
+ if ($mating['drink'] == '接受偶尔') {
|
|
|
|
+ $where[] = ['drink', 'in', ['不喝酒', '社交需要喝', '兴致时小酌']];
|
|
|
|
+ }
|
|
|
|
+ if ($mating['drink'] == '反感') {
|
|
|
|
+ $where[] = ['drink', 'in', ['不喝酒']];
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //婚后是否愿意与父母同住
|
|
|
|
+ if (in_array('want_birth', $match_field)) {
|
|
|
|
+ if ($mating['want_birth'] == 1) {
|
|
|
|
+ $where[] = ['want_birth', '=', 1];
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return $where;
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 排序
|
|
* 排序
|
|
*/
|
|
*/
|
|
@@ -446,6 +604,17 @@ class UserController extends MatchmakerBaseController
|
|
$match_count++;
|
|
$match_count++;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ //生肖
|
|
|
|
+ if (empty($mating['animal'])) {
|
|
|
|
+ $match_arr[] = 'animal';
|
|
|
|
+ $match_count++;
|
|
|
|
+ } else {
|
|
|
|
+ if (!in_array($v['animal'], $mating['animal'])) {
|
|
|
|
+ $match_arr[] = 'animal';
|
|
|
|
+ $match_count++;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
//籍贯 ['晋江籍','非晋江籍','无要求']
|
|
//籍贯 ['晋江籍','非晋江籍','无要求']
|
|
if ($mating['native'] == '无要求') {
|
|
if ($mating['native'] == '无要求') {
|
|
$match_arr[] = 'native';
|
|
$match_arr[] = 'native';
|
|
@@ -552,7 +721,7 @@ class UserController extends MatchmakerBaseController
|
|
$match_count++;
|
|
$match_count++;
|
|
}
|
|
}
|
|
|
|
|
|
- //是否吸烟 ['不吸,很反感', '不吸烟,但不反感', '社交时偶尔吸烟','烟不离手']
|
|
|
|
|
|
+ //是否吸烟 ['不反感', '接受偶尔', '反感']
|
|
if ($mating['smoke'] == '不反感' || $mating['smoke'] == '') {
|
|
if ($mating['smoke'] == '不反感' || $mating['smoke'] == '') {
|
|
$match_arr[] = 'smoke';
|
|
$match_arr[] = 'smoke';
|
|
$match_count++;
|
|
$match_count++;
|
|
@@ -568,7 +737,7 @@ class UserController extends MatchmakerBaseController
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- //是否喝酒 ['不喝酒', '社交需要喝', '兴致时小酌', '酒不离口']
|
|
|
|
|
|
+ //是否喝酒 ['不反感', '接受偶尔', '反感']
|
|
if ($mating['drink'] == '不反感' || $mating['drink'] == '') {
|
|
if ($mating['drink'] == '不反感' || $mating['drink'] == '') {
|
|
$match_arr[] = 'drink';
|
|
$match_arr[] = 'drink';
|
|
$match_count++;
|
|
$match_count++;
|
|
@@ -584,6 +753,17 @@ class UserController extends MatchmakerBaseController
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ //是否生育
|
|
|
|
+ if ($mating['want_birth'] != 1) {
|
|
|
|
+ $match_arr[] = 'want_birth';
|
|
|
|
+ $match_count++;
|
|
|
|
+ } else {
|
|
|
|
+ if ($v['want_birth'] == 1) {
|
|
|
|
+ $match_arr[] = 'want_birth';
|
|
|
|
+ $match_count++;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
$list[$k]['age'] = $age;
|
|
$list[$k]['age'] = $age;
|
|
$list[$k]['match_arr'] = $match_arr;
|
|
$list[$k]['match_arr'] = $match_arr;
|
|
$list[$k]['match_count'] = $match_count;
|
|
$list[$k]['match_count'] = $match_count;
|