getLoginPromote(); $map = ['op_type' => 1, '_string' => '1=1']; if(isset($params['account'])) { $map['user_account']= ['like', '%' . $params['account'] . '%']; } if(!empty($params['promote_id'])) { $map['promote_id']= $params['promote_id']; } if(!empty($params['promote_id_to'])) { $map['promote_id_to'] = $params['promote_id_to']; } if(!empty($params['op_id'])) { $map['op_id'] = $params['op_id']; } if (!empty($params['time_start'])) { $map['order_time'] = ['egt', strtotime($params['time_start'])]; } if (!empty($params['time_end'])) { $map['order_time'] = ['elt', strtotime($params['time_end']) + 86399]; } $promoteService = new PromoteService(); $subInSql = $promoteService->subInSql($loginer); $map['_string'] .= ' and (promote_id in (' . $subInSql . ') or promote_id_to in (' . $subInSql . '))'; $records = M('mend', 'tab_')->where($map)->order('create_time desc')->page($page, $row)->select(); $count = M('mend', 'tab_')->where($map)->count(); $mendService = new MendService(); foreach ($records as $key => $record) { $record['status_text'] = $mendService->getStatusText($record['status']); $records[$key] = $record; } $page = set_pagination($count, $row, $params); if ($page) { $this->assign('_page', $page); } $levelColumn = 'level'. $loginer['level'] . '_id'; $promotes = M('promote', 'tab_')->field(['id', 'account'])->where([$levelColumn => $loginer['id']])->select(); $this->assign('promotes', $promotes); $this->assign('count', $count); $this->assign('records', $records); $this->meta_title = '补链记录'; $this->display(); } public function add() { $userId = I('user_id', 0); $user = M('user', 'tab_')->where(['id' => $userId])->find(); if (!$user) { return $this->error('用户不存在'); } $loginer = $this->getLoginPromote(); $levelColumn = 'level'. $loginer['level'] . '_id'; $promote = M('promote', 'tab_')->where(['id' => $user['promote_id']])->where([$levelColumn => $loginer['id']])->find(); if (!$promote) { return $this->error('所属推广员异常'); } $promotes = M('promote', 'tab_')->field(['id', 'account'])->where([$levelColumn => $loginer['id']])->select(); $this->meta_title = '玩家补链'; $this->assign('user', $user); $this->assign('promotes', $promotes); $this->display(); } public function save() { $params = I('post.'); $loginer = $this->getLoginPromote(); $service = new MendService(); try { $service->addMendTask($params, $loginer); $this->ajaxReturn(['status' => 1, 'msg' => '补链申请成功']); } catch (\Exception $e) { $this->ajaxReturn(['status' => 0, 'msg' => $e->getMessage()]); } } }