|
@@ -33,6 +33,7 @@ class UserController extends MatchmakerBaseController
|
|
|
'drink' => Constant::DRINK,
|
|
|
'family' => Constant::FAMILY,
|
|
|
'tinyint' => Constant::TINYINT,
|
|
|
+ 'animal' => Constant::ANIMAL,
|
|
|
];
|
|
|
foreach ($data as &$v) {
|
|
|
$v = json_encode($v);
|
|
@@ -48,7 +49,7 @@ class UserController extends MatchmakerBaseController
|
|
|
$value['birthday'] = strtotime($value['birthday']);
|
|
|
$value['matchmaker_id'] = $this->matchmaker['id'];
|
|
|
$user = MatchmakerUserModel::create($value);
|
|
|
- MatchmakerUserMatingModel::create(['user_id' => $user['id']]);
|
|
|
+ MatchmakerUserMatingModel::create(['user_id' => $user['id'], 'animal' => []]);
|
|
|
$this->success('', '', ['id' => $user['id']]);
|
|
|
}
|
|
|
|
|
@@ -59,6 +60,9 @@ class UserController extends MatchmakerBaseController
|
|
|
$this->error('参数错误');
|
|
|
}
|
|
|
$mating = MatchmakerUserMatingModel::get(['user_id' => $id]);
|
|
|
+ if (empty($mating['animal'])) {
|
|
|
+ $mating['animal'] = [];
|
|
|
+ }
|
|
|
$this->assign('mating', $mating);
|
|
|
|
|
|
$education = Constant::EDUCATION;
|
|
@@ -73,9 +77,10 @@ class UserController extends MatchmakerBaseController
|
|
|
'native' => Constant::NATIVE,
|
|
|
'education' => $education,
|
|
|
'income' => Constant::COND_INCOME,
|
|
|
- 'smoke' => Constant::SMOKE,
|
|
|
- 'drink' => Constant::DRINK,
|
|
|
+ 'smoke' => Constant::MATTING_SMOKING,
|
|
|
+ 'drink' => Constant::MATTING_DRINK,
|
|
|
'tinyint' => Constant::COND_TINYINT,
|
|
|
+ 'animal' => Constant::ANIMAL,
|
|
|
];
|
|
|
foreach ($data as &$v) {
|
|
|
$v = json_encode($v);
|
|
@@ -88,6 +93,9 @@ class UserController extends MatchmakerBaseController
|
|
|
public function matingAddPost()
|
|
|
{
|
|
|
$param = $this->request->post();
|
|
|
+ if (empty($param['animal'])) {
|
|
|
+ $param['animal'] = [];
|
|
|
+ }
|
|
|
MatchmakerUserMatingModel::update($param);
|
|
|
$this->success('操作成功');
|
|
|
}
|
|
@@ -118,6 +126,7 @@ class UserController extends MatchmakerBaseController
|
|
|
'drink' => Constant::DRINK,
|
|
|
'family' => Constant::FAMILY,
|
|
|
'tinyint' => Constant::TINYINT,
|
|
|
+ 'animal' => Constant::ANIMAL,
|
|
|
];
|
|
|
foreach ($data as &$v) {
|
|
|
$v = json_encode($v);
|
|
@@ -143,6 +152,9 @@ class UserController extends MatchmakerBaseController
|
|
|
$this->error('参数错误');
|
|
|
}
|
|
|
$mating = MatchmakerUserMatingModel::get(['user_id' => $id]);
|
|
|
+ if (empty($mating['animal'])) {
|
|
|
+ $mating['animal'] = [];
|
|
|
+ }
|
|
|
$this->assign('mating', $mating);
|
|
|
|
|
|
$education = Constant::EDUCATION;
|
|
@@ -157,9 +169,10 @@ class UserController extends MatchmakerBaseController
|
|
|
'native' => Constant::NATIVE,
|
|
|
'education' => $education,
|
|
|
'income' => Constant::COND_INCOME,
|
|
|
- 'smoke' => Constant::SMOKE,
|
|
|
- 'drink' => Constant::DRINK,
|
|
|
+ 'smoke' => Constant::MATTING_SMOKING,
|
|
|
+ 'drink' => Constant::MATTING_DRINK,
|
|
|
'tinyint' => Constant::COND_TINYINT,
|
|
|
+ 'animal' => Constant::ANIMAL,
|
|
|
];
|
|
|
foreach ($data as &$v) {
|
|
|
$v = json_encode($v);
|
|
@@ -172,6 +185,9 @@ class UserController extends MatchmakerBaseController
|
|
|
public function matingEditPost()
|
|
|
{
|
|
|
$param = $this->request->post();
|
|
|
+ if (empty($param['animal'])) {
|
|
|
+ $param['animal'] = [];
|
|
|
+ }
|
|
|
MatchmakerUserMatingModel::update($param);
|
|
|
$this->success('操作成功');
|
|
|
}
|
|
@@ -249,6 +265,31 @@ class UserController extends MatchmakerBaseController
|
|
|
$this->success('操作成功');
|
|
|
}
|
|
|
|
|
|
+ public function deleteUser()
|
|
|
+ {
|
|
|
+ $id = $this->request->post('id', 0);
|
|
|
+ if (empty($id)) {
|
|
|
+ $this->error('数据异常,请刷新重试');
|
|
|
+ }
|
|
|
+ MatchmakerUserModel::destroy($id);
|
|
|
+ MatchmakerUserMatingModel::destroy(['user_id' => $id]);
|
|
|
+ MatchmakerUserFollowModel::destroy(['user_id' => $id]);
|
|
|
+
|
|
|
+ $this->success('操作成功');
|
|
|
+ }
|
|
|
+
|
|
|
+ public function statusUser()
|
|
|
+ {
|
|
|
+ $id = $this->request->post('id', 0);
|
|
|
+ $status = $this->request->post('status', 0);
|
|
|
+ if (empty($id) || empty($status)) {
|
|
|
+ $this->error('数据异常,请刷新重试');
|
|
|
+ }
|
|
|
+ MatchmakerUserModel::update(['status' => $status], ['id' => $id]);
|
|
|
+
|
|
|
+ $this->success('操作成功');
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 匹配
|
|
|
*/
|
|
@@ -512,15 +553,15 @@ class UserController extends MatchmakerBaseController
|
|
|
}
|
|
|
|
|
|
//是否吸烟 ['不吸,很反感', '不吸烟,但不反感', '社交时偶尔吸烟','烟不离手']
|
|
|
- if ($mating['smoke'] == '烟不离手' || $mating['smoke'] == '' || $mating['smoke'] == '不吸烟,但不反感') {
|
|
|
+ if ($mating['smoke'] == '不反感' || $mating['smoke'] == '') {
|
|
|
$match_arr[] = 'smoke';
|
|
|
$match_count++;
|
|
|
- } elseif ($mating['smoke'] == '社交时偶尔吸烟') {
|
|
|
+ } elseif ($mating['smoke'] == '接受偶尔') {
|
|
|
if (in_array($v['smoke'], ['社交时偶尔吸烟', '不吸烟,但不反感', '不吸,很反感'])) {
|
|
|
$match_arr[] = 'smoke';
|
|
|
$match_count++;
|
|
|
}
|
|
|
- } elseif ($mating['smoke'] == '不吸,很反感') {
|
|
|
+ } elseif ($mating['smoke'] == '反感') {
|
|
|
if (in_array($v['smoke'], ['不吸,很反感', '不吸烟,但不反感'])) {
|
|
|
$match_arr[] = 'smoke';
|
|
|
$match_count++;
|
|
@@ -528,15 +569,15 @@ class UserController extends MatchmakerBaseController
|
|
|
}
|
|
|
|
|
|
//是否喝酒 ['不喝酒', '社交需要喝', '兴致时小酌', '酒不离口']
|
|
|
- if ($mating['drink'] == '酒不离口' || $mating['drink'] == '') {
|
|
|
+ if ($mating['drink'] == '不反感' || $mating['drink'] == '') {
|
|
|
$match_arr[] = 'drink';
|
|
|
$match_count++;
|
|
|
- } elseif ($mating['drink'] == '兴致时小酌' || $mating['drink'] == '社交需要喝') {
|
|
|
- if ($v['drink'] == '兴致时小酌' || $v['drink'] == '社交需要喝') {
|
|
|
+ } elseif ($mating['drink'] == '接受偶尔') {
|
|
|
+ if (in_array($v['drink'], ['不喝酒', '社交需要喝', '兴致时小酌'])) {
|
|
|
$match_arr[] = 'drink';
|
|
|
$match_count++;
|
|
|
}
|
|
|
- } elseif ($mating['drink'] == '不喝酒') {
|
|
|
+ } elseif ($mating['drink'] == '反感') {
|
|
|
if ($v['drink'] == '不喝酒') {
|
|
|
$match_arr[] = 'drink';
|
|
|
$match_count++;
|
|
@@ -546,6 +587,11 @@ class UserController extends MatchmakerBaseController
|
|
|
$list[$k]['age'] = $age;
|
|
|
$list[$k]['match_arr'] = $match_arr;
|
|
|
$list[$k]['match_count'] = $match_count;
|
|
|
+
|
|
|
+ //姓名
|
|
|
+ if (mb_strlen($list[$k]['realname'], 'utf-8') > 1) {
|
|
|
+ $list[$k]['realname'] = $this->_replaceSecondChineseCharWithAsterisk($list[$k]['realname']); // 将第二个字符替换为星号
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
//排序
|
|
@@ -566,4 +612,17 @@ class UserController extends MatchmakerBaseController
|
|
|
return $list;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ private function _replaceSecondChineseCharWithAsterisk($string)
|
|
|
+ {
|
|
|
+ $length = mb_strlen($string, 'utf-8');
|
|
|
+ $arr = [];
|
|
|
+ for ($i = 0; $i < $length; $i++) {
|
|
|
+ $arr[] = mb_substr($string, $i, 1, 'utf-8');
|
|
|
+ }
|
|
|
+ $arr[1] = '*';
|
|
|
+
|
|
|
+ return implode('', $arr);
|
|
|
+ }
|
|
|
+
|
|
|
}
|