canViewMend) { return $this->error('没有权限'); } $page = intval(I('p', 1)); $row = intval(I('row', 10)); $params = I('get.'); $loginer = $this->getLoginPromote(); $promoteService = new PromoteService(); $permPromote = $loginer; if ($loginer['shift_over_apply'] == 1) { $permPromote = $promoteService->getTopPromote($loginer); } $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]; } $subInSql = $promoteService->subInSql($permPromote); $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'. $permPromote['level'] . '_id'; $promotes = M('promote', 'tab_')->field(['id', 'account'])->where([$levelColumn => $permPromote['id']])->select(); $this->assign('promotes', $promotes); $this->assign('count', $count); $this->assign('records', $records); $this->meta_title = '补链记录'; $this->display(); } public function add() { if (!$this->canViewMend) { return $this->error('没有权限'); } $userId = I('user_id', 0); $user = M('user', 'tab_')->where(['id' => $userId])->find(); if (!$user) { return $this->error('用户不存在'); } $loginer = $this->getLoginPromote(); $permPromote = $loginer; $promoteService = new PromoteService(); if ($loginer['shift_over_apply'] == 1) { $permPromote = $promoteService->getTopPromote($loginer); } $levelColumn = 'level'. $permPromote['level'] . '_id'; $promote = M('promote', 'tab_')->where(['id' => $user['promote_id']])->where([$levelColumn => $permPromote['id']])->find(); if (!$promote) { return $this->error('所属推广员异常'); } $promotes = M('promote', 'tab_')->field(['id', 'account'])->where([$levelColumn => $permPromote['id']])->select(); $this->meta_title = '玩家补链'; $this->assign('user', $user); $this->assign('promotes', $promotes); $this->display(); } public function save() { $params = I('post.'); $loginer = $this->getLoginPromote(); $permPromote = $loginer; $promoteService = new PromoteService(); if ($loginer['shift_over_apply'] == 1) { $permPromote = $promoteService->getTopPromote($loginer); } $service = new MendService(); try { $service->addMendTask($params, $permPromote, $loginer); $this->ajaxReturn(['status' => 1, 'msg' => '补链申请成功']); } catch (\Exception $e) { $this->ajaxReturn(['status' => 0, 'msg' => $e->getMessage()]); } } }