|
|
@@ -89,7 +89,7 @@ class Member extends Model
|
|
|
{
|
|
|
$userName = isset($params['mobile']) ? trim($params['mobile']) : '';
|
|
|
$password = isset($params['password']) ? trim($params['password']) : '';
|
|
|
- $field = 'id,user_login,sex,agent_type,agent_status,user_nickname,avatar,openid,is_reg_profile,user_pass,user_type,score,balance,user_status';
|
|
|
+ $field = 'id,user_login,sex,user_nickname,avatar,openid,user_pass,user_type,score,balance,user_status';
|
|
|
$userInfo = Member::where(['user_login' => $userName])->field($field)->find();
|
|
|
$userPass = isset($userInfo['user_pass']) ? $userInfo['user_pass'] : '';
|
|
|
$userStatus = isset($userInfo['user_status']) ? intval($userInfo['user_status']) : 0;
|
|
|
@@ -155,7 +155,7 @@ class Member extends Model
|
|
|
*/
|
|
|
public static function getInfo($where, $field = "")
|
|
|
{
|
|
|
- $field = $field ? $field : 'id,openid,user_nickname,user_type,agent_status,agent_type,avatar,user_login,collect_expire,user_status,real_name,redheart,is_reg_profile,mobile,balance,user_status,is_heart,vip_auth,vip_expire,is_follow,freezing_choose';
|
|
|
+ $field = $field ? $field : 'id,openid,user_nickname,user_type,avatar,user_login,collect_expire,user_status,real_name,redheart,is_reg_profile,mobile,balance,user_status,is_heart,vip_auth,vip_expire,is_follow,freezing_choose';
|
|
|
$info = self::where($where)->field($field)->order('user_status desc,id desc')->find();
|
|
|
return $info ? $info->toArray() : [];
|
|
|
}
|
|
|
@@ -409,62 +409,6 @@ class Member extends Model
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 余额明细
|
|
|
- * @param $params
|
|
|
- * @param int $pageSize
|
|
|
- * @return mixed
|
|
|
- */
|
|
|
- public static function getBalanceLog($params, $pageSize = 15)
|
|
|
- {
|
|
|
- $where = [];
|
|
|
- $userId = isset($params['user_id']) ? $params['user_id'] : 0;
|
|
|
- if ($userId) {
|
|
|
- $where['b.user_id'] = $userId;
|
|
|
- }
|
|
|
- $changeType = isset($params['change_type']) ? $params['change_type'] : 0;
|
|
|
- if ($changeType) {
|
|
|
- $where['b.change_type'] = $changeType;
|
|
|
- }
|
|
|
- $type = isset($params['type']) ? $params['type'] : 0;
|
|
|
- $model = db('user_balance_log')->alias('b')
|
|
|
- ->leftJoin('user u','u.id=b.source_uid')
|
|
|
- ->where($where)
|
|
|
- ->where(function($query) use ($type){
|
|
|
- if($type == 'income'){
|
|
|
- $query->where('b.type', '>', 1);
|
|
|
- } else if ($type){
|
|
|
- $type = is_array($type)? $type : [$type];
|
|
|
- $query->whereIn('b.type', $type);
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- $types = config('weixin.incomeTypes');
|
|
|
- $dataList = $model->field('b.id,b.type,b.order_sn,b.change as money,b.change_type,b.balance,b.remark,b.description,b.create_time,status,u.user_nickname')
|
|
|
- ->where('b.status', 'lt', 4)
|
|
|
- ->order("b.create_time desc")
|
|
|
- ->paginate($pageSize)
|
|
|
- ->each(function ($item, $k) use($types){
|
|
|
- $item['format_time'] = $item['create_time']? date('Y年m月d日 H点i分', $item['create_time']) : '';
|
|
|
- $item['money'] = floatval($item['money']);
|
|
|
-
|
|
|
- $type = isset($item['type'])? $item['type'] : 0;
|
|
|
- $item['typeName'] = isset($types[$type])? $types[$type] : '';
|
|
|
- return $item;
|
|
|
- });
|
|
|
-
|
|
|
- $dataList = $dataList ? $dataList->toArray() : [];
|
|
|
- if($dataList){
|
|
|
- $total = $model->where('b.status',2)->sum('b.change');
|
|
|
- $dataList['total_money'] = moneyFormat($total);
|
|
|
- $total = $model->where('b.status',1)->sum('b.change');
|
|
|
- $dataList['nopay_money'] = moneyFormat($total);
|
|
|
- }
|
|
|
-
|
|
|
- return $dataList;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
* 推荐用户
|
|
|
* @param $params 参数
|
|
|
* @param $page 分页
|
|
|
@@ -481,7 +425,7 @@ class Member extends Model
|
|
|
return $dataList;
|
|
|
}
|
|
|
|
|
|
- $where = ['m.is_tuijian' => 1,'m.is_heart'=> 1, 'm.is_reg_profile' => 1, 'm.user_status' => 1, 'm.user_type' => 2];
|
|
|
+ $where = ['m.is_tuijian' => 1,'is_heart'=> 1, 'm.is_reg_profile' => 1, 'm.user_status' => 1, 'm.user_type' => 2];
|
|
|
|
|
|
// 匹配当前用户信息:性别
|
|
|
$sex = 0;
|
|
|
@@ -662,8 +606,8 @@ class Member extends Model
|
|
|
$hasMatchData = Predis::get("hearts:hasMeatch:{$userId}");
|
|
|
$ids = isset($hasMatchData['ids'])? $hasMatchData['ids'] : '';
|
|
|
$ids = $ids? explode(',', $ids) : [];
|
|
|
- $expire = isset($hasMatchData['expire'])? $hasMatchData['expire'] : 0;
|
|
|
- if(time() > $expire || !$isVip){
|
|
|
+ $hasExpire = isset($hasMatchData['expire'])? $hasMatchData['expire'] : 0;
|
|
|
+ if(time() > $hasExpire || !$isVip){
|
|
|
$ids = [];
|
|
|
}
|
|
|
|
|
|
@@ -798,6 +742,118 @@ class Member extends Model
|
|
|
->column('m.id');
|
|
|
|
|
|
PRedis::set('hearts:query:' . $userId, Member::getLastSql(), 6 * 3600);
|
|
|
+ if(empty($recommendIds)){
|
|
|
+ $recommendIds = Member::alias('m')
|
|
|
+ ->join('user_profile up', 'up.userid=m.id', 'left')
|
|
|
+ ->where($where)
|
|
|
+ ->where(function ($query) use ($sex) {
|
|
|
+ return $query->where('m.sex', 'in', [0, $sex]);
|
|
|
+ })
|
|
|
+ ->where(function ($query) use ($ids) {
|
|
|
+ // 过滤一星期内已经推荐过的
|
|
|
+ if($ids){
|
|
|
+ return $query->where('m.id', 'not in', $ids);
|
|
|
+ }else{
|
|
|
+ return $query->where('m.id', '>', 0);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ ->where(function ($query) use ($conditions, $memberInfo, $ageGap) {
|
|
|
+ $querys = $query;
|
|
|
+ // 年龄
|
|
|
+ /*$age = isset($memberInfo['age']) ? intval($memberInfo['age']) : 0;
|
|
|
+ $cage = isset($conditions['age']) ? intval($conditions['age']) : 0;
|
|
|
+ if ($cage) {
|
|
|
+ $dataArr = config('weixin.ages');
|
|
|
+ $datas = isset($dataArr[$cage]) ? $dataArr[$cage] : [];
|
|
|
+ $data1 = isset($datas['value1']) ? $datas['value1'] : 0;
|
|
|
+ $data2 = isset($datas['value2']) ? $datas['value2'] : 0;
|
|
|
+ if ($data2) {
|
|
|
+ $querys = $querys->where('up.age', '>=', $data1)->where('up.age', '<=', $data2);
|
|
|
+ } else if ($data1) {
|
|
|
+ $querys = $querys->where('up.age', '>=', $data1);
|
|
|
+ }
|
|
|
+ } else if ($age && $ageGap) {
|
|
|
+ $querys = $querys->where('up.age', '>=', ($age - $ageGap))->where('up.age', '<=', ($age + $ageGap));
|
|
|
+ }*/
|
|
|
+
|
|
|
+ // 年龄
|
|
|
+ $year = isset($conditions['year']) ? trim($conditions['year']) : '';
|
|
|
+ if ($year) {
|
|
|
+ $year = explode('~', $year);
|
|
|
+ $data1 = isset($year[0]) ? intval($year[0]) : 0;
|
|
|
+ $data2 = isset($year[1]) ? intval($year[1]) : 0;
|
|
|
+ if ($data2) {
|
|
|
+ $data1 = $data1 ? strtotime($data1 . '-01-01') : 0;
|
|
|
+ $data2 = $data2 ? strtotime(($data2 + 1) . '-01-01') : 0;
|
|
|
+ $querys = $querys->where('m.birthday', '>=', $data1 . '')->where('m.birthday', '<=', $data2);
|
|
|
+ } else if ($data1) {
|
|
|
+ $data1 = $data1 ? strtotime($data1 . '-01-01') : 0;
|
|
|
+ $querys = $querys->where('m.birthday', '>=', $data1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 身高
|
|
|
+ $height = isset($conditions['height']) ? trim($conditions['height']) : '';
|
|
|
+ if ($height) {
|
|
|
+ $height = explode('~', $height);
|
|
|
+ $data1 = isset($height[0]) ? intval($height[0]) : 0;
|
|
|
+ $data2 = isset($height[1]) ? intval($height[1]) : 0;
|
|
|
+ if ($data2) {
|
|
|
+ $querys = $querys->where('up.height', '>=', $data1)->where('up.height', '<=', $data2);
|
|
|
+ } else if ($data1) {
|
|
|
+ $querys = $querys->where('up.height', '>=', $data1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 收入
|
|
|
+ $salary = isset($conditions['salary']) ? intval($conditions['salary']) : 0;
|
|
|
+ if ($height<=0 && $salary) {
|
|
|
+ $dataArr = config('weixin.salarys');
|
|
|
+ $datas = isset($dataArr[$salary]) ? $dataArr[$salary] : [];
|
|
|
+ $data1 = isset($datas['value']) ? $datas['value'] : 0;
|
|
|
+ $data2 = isset($datas['value2']) ? $datas['value2'] : 0;
|
|
|
+ if ($data2) {
|
|
|
+ $querys = $querys->where('up.salary', '>=', $data1)->where('up.salary', '<=', $data2);
|
|
|
+ } else if ($data1) {
|
|
|
+ $querys = $querys->where('up.salary', '=', $data1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 所在城市
|
|
|
+ $city = isset($memberInfo['city']) ? trim($memberInfo['city']) : '';
|
|
|
+ $cityValue = isset($conditions['city']) ? trim($conditions['city']) : '';
|
|
|
+ if ($cityValue > 0 && $city) {
|
|
|
+ $querys = $querys->where('up.city', '=', $city);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ // 婚姻状态
|
|
|
+ $married = isset($conditions['married']) ? intval($conditions['married']) : 0;
|
|
|
+ if ($married > 0) {
|
|
|
+ $querys = $querys->where('up.married', '>=', $married);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 学历
|
|
|
+ $education = isset($conditions['education']) ? intval($conditions['education']) : 0;
|
|
|
+ if ($education > 0) {
|
|
|
+ if($married >0 && $education==3){
|
|
|
+ $querys = $querys->where('up.education', '>=', 1);
|
|
|
+ }else if($married <=0){
|
|
|
+ // 硕士及以上或按学历匹配
|
|
|
+ $op = $education == 3 ? '>=' : '=';
|
|
|
+ $querys = $querys->where('up.education', $op, $education);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ return $querys;
|
|
|
+ })
|
|
|
+ ->orderRaw('rand()')
|
|
|
+ ->limit($recommendNum)
|
|
|
+ ->column('m.id');
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
if ($recommendIds) {
|
|
|
// 更新推荐日期
|
|
|
Member::where(['id' => $userId])->update(['heart_recommend_at' => date('Y-m-d H:i:s')]);
|
|
|
@@ -871,9 +927,9 @@ class Member extends Model
|
|
|
if($updated && $recommendIds){
|
|
|
if($ids){
|
|
|
$newIds = array_merge($ids, $recommendIds);
|
|
|
- Predis::set("hearts:hasMeatch:{$userId}", ['ids'=>implode(',', $newIds), 'expire'=> $expire], 7*24*3600);
|
|
|
+ Predis::set("hearts:hasMeatch:{$userId}", ['ids'=>implode(',', $newIds), 'expire'=> $hasExpire], 3*24*3600);
|
|
|
}else{
|
|
|
- Predis::set("hearts:hasMeatch:{$userId}", ['ids'=>implode(',', $recommendIds), 'expire'=> time()+7*24*3600], 7*24*3600);
|
|
|
+ Predis::set("hearts:hasMeatch:{$userId}", ['ids'=>implode(',', $recommendIds), 'expire'=> time()+3*24*3600], 3*24*3600);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -979,13 +1035,13 @@ class Member extends Model
|
|
|
$collectTime = isset($siteInfo['collect_time']) ? intval($siteInfo['collect_time']) : 0;
|
|
|
$collectTime = $collectTime ? $collectTime : 6;
|
|
|
Member::saveData(['id' => $userId], ['collect_expire' => time() + $collectTime * 3600]);
|
|
|
-
|
|
|
+
|
|
|
$memberInfo = Member::where(['id'=> $userId])->field('collect_expire,vip_auth,vip_expire')->find();
|
|
|
- $vipAuth = isset($memberInfo['vip_auth']) ? intval($memberInfo['vip_auth']) : 0;
|
|
|
- $vipExpire = isset($memberInfo['vip_expire']) ? $memberInfo['vip_expire'] : 0;
|
|
|
+ $vipAuth = isset($memberInfo['vip_auth']) ? intval($memberInfo['vip_auth']) : 0;
|
|
|
+ $vipExpire = isset($memberInfo['vip_expire']) ? $memberInfo['vip_expire'] : 0;
|
|
|
if(!$vipAuth || $vipExpire < time()){
|
|
|
UserCollect::where(['user_id' => $userId])
|
|
|
- ->update(['status' => 2, 'updated_at' => date('Y-m-d H:i:s')]);
|
|
|
+ ->update(['status' => 2, 'updated_at' => date('Y-m-d H:i:s')]);
|
|
|
}
|
|
|
}
|
|
|
|