123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- <?php
- namespace huomp\logic\log;
- use huo\controller\member\MemCache;
- use huo\model\common\CommonModel;
- use huomp\model\homepage\HpVisitorModel;
- use huomp\model\log\HomepageLogModel;
- class HomepageLogLogic extends CommonModel {
-
- protected function getWhere($param = []) {
- $_map = [];
- if (!empty($param['parent_mem_id'])) {
- $_map['hp_visitor_model.parent_mem_id'] = $param['parent_mem_id'];
- }
- return $_map;
- }
-
- public function getVisitorList($where = [], $page = '1,10', $order = '-update_time') {
- $_map = $this->getWhere($where);
- $_field = [];
- $_map['status'] = 2;
- return $this->getList($_field, $_map, $page, $order);
- }
- public function getList($_field, $where, $page = '1,10', $order = '-update_time') {
- $_model = new HpVisitorModel();
- $_count = $_model->with('visitor')->where($where)->count();
- if (empty($_count)) {
- return [
- 'count' => 0,
- 'list' => []
- ];
- }
- $_order = $_model->orderFilter($order);
- $_log_datas = $_model->with('visitor')
- ->where($where)
- ->order($_order)
- ->page($page)
- ->select();
- if (is_object($_log_datas)) {
- $_log_datas = $_log_datas->toArray();
- }
- if (empty($_log_datas)) {
- return [
- 'count' => $_count,
- 'list' => []
- ];
- }
- $_rdata = [];
- foreach ($_log_datas as $key => $_log_data) {
- $_rdata[] = [
- 'mem_id' => $_log_data['mem_id'],
- 'nickname' => !empty($_log_data['visitor']) ? $_log_data['visitor']['nickname'] : '',
- 'avatar' => !empty($_log_data['visitor']) ? $_log_data['visitor']['avatar'] : '',
- ];
- }
- return [
- 'count' => $_count,
- 'list' => $_rdata
- ];
- }
-
- public function addVisitLog($mem_id, $_to_mem_id) {
- $_mem_info = (new MemCache())->getInfoById($mem_id);
- $_insert_data = [
- "mem_id" => $mem_id,
- "homepage_id" => $_to_mem_id,
- "agent_id" => $_mem_info['agent_id'],
- "agent_game" => $_mem_info['agent_game'],
- "ip" => request()->ip(),
- ];
- return (new HomepageLogModel())->insertLog($_insert_data);
- }
- }
|