$uid, 'mer_id' => $mer_id])) { if ($is_follow == 1) { $data['follow_time'] = time(); } else { $data['unfollow_time'] = time(); } return self::where(['uid' => $uid, 'mer_id' => $mer_id])->update($data); } else { $data['uid'] = $uid; $data['mer_id'] = $mer_id; $data['follow_time'] = time(); return self::set($data); } } /**讲师关注列表 * @param $uid * @param int $page * @param int $limit * @return array */ public static function get_user_merchant_follow_list($uid, $page = 1, $limit = 20) { $data = self::alias('f')->where(['f.uid' => $uid, 'f.is_follow' => 1,'l.is_show' => 1, 'l.is_del' => 0]) ->join('Lecturer l', 'f.mer_id=l.mer_id') ->where('l.mer_id','>',0)->page((int)$page, (int)$limit) ->order('f.follow_time desc')->field('f.uid,f.mer_id,f.is_follow,l.id,l.mer_id,l.is_show,l.is_del,l.lecturer_name,l.lecturer_head,l.label,l.introduction,l.study,l.curriculum') ->select(); $data = count($data) > 0 ? $data->toArray() : []; return $data; } /**是否关注 * @param $uid * @param $mer_id */ public static function isFollow($uid, $mer_id) { $follow=self::where(['uid'=>$uid,'mer_id'=>$mer_id,'is_follow'=>1])->find(); if($follow) return true; else return false; } }