123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 |
- <?php
- /**
- * HunterRankLogic.php UTF-8
- * 猎人平台逻辑
- *
- * @date : 2018/9/20 19:42
- *
- * @license 这不是一个自由软件,未经授权不许任何使用和传播。
- * @author : chenbingling <cbl@huosdk.com>
- * @version : HuoMP 1.0
- */
- namespace huomp\logic\hunter;
- use huo\model\user\AgentExtModel;
- use huolib\constant\DataConst;
- use huolib\tool\StrUtils;
- use huomp\logic\finance\IncomeListLogic;
- use huomp\model\common\CommonModel;
- use huomp\model\hunter\HunterRankModel;
- class HunterRankLogic extends CommonModel {
- protected function getWhere($param = []) {
- $_map = [];
- return $_map;
- }
- /**
- * 获取虚拟排行列表
- *
- * @param array $param
- * @param string $page
- * @param string $order
- *
- * @return array
- */
- public function getList($param = [], $page = '1,10', $order = '-update_time') {
- $_rdata = ['count' => 0, 'list' => []];
- $_model = new HunterRankModel();
- $_map = $this->getWhere($param);
- $_count = $_model->where($_map)->count();
- if (empty($_count)) {
- return $_rdata;
- }
- $_order = $_model->orderFilter($order);
- $_data = $_model->with('mem')
- ->where($_map)
- ->order($_order)
- ->page($page)
- ->select();
- if (is_object($_data)) {
- $_data = $_data->toArray();
- }
- if (empty($_data)) {
- return $_rdata;
- }
- $_rdata['count'] = $_count;
- $_rdata['list'] = $_data;
- return $_rdata;
- }
- /**
- * 获取后台玩家数据,排除已在虚拟列表的玩家
- *
- * @param $where
- * @param string $page
- *
- * @return array
- */
- public function getAgentExt($where, $page = '1,10') {
- $_map = [];
- if (!empty($where['role_id'])) {
- $_map['mpagent.role_id'] = $where['role_id'];
- }
- if (!empty($where['nickname'])) {
- $_map['mpagent.user_nicename'] = $where['nickname'];
- }
- /* 排除已在虚拟列表玩家 */
- $_mem_id = (new HunterRankModel())->getMemIds();
- if (!empty($_mem_id)) {
- $_map['mpagent.mem_id'] = ['not in', $_mem_id];
- }
- $_model = new AgentExtModel();
- $_count = $_model->with('mpagent')->where($_map)->count();
- if (empty($_count)) {
- return [
- 'count' => 0,
- 'list' => []
- ];
- }
- $_order = 'share_total desc';
- $_data_list = $_model
- ->with('mpagent')
- ->where($_map)
- ->order($_order)
- ->page($page)
- ->select();
- if (is_object($_data_list)) {
- $_data_list = $_data_list->toArray();
- }
- if (empty($_data_list)) {
- return [
- 'count' => $_count,
- 'list' => []
- ];
- }
- $_data = [];
- foreach ($_data_list as $_item) {
- $_data[] = [
- 'avatar' => !empty($_item['mpagent']) ? $_item['mpagent']['avatar'] : '',
- 'nickname' => !empty($_item['mpagent']) ? $_item['mpagent']['user_nicename'] : '',
- 'mem_id' => !empty($_item['mpagent']) ? $_item['mpagent']['mem_id'] : 0,
- 'share_total' => StrUtils::formatNumber($_item['share_total']),
- ];
- }
- $_rdata = [
- 'count' => $_count,
- 'list' => $_data
- ];
- return $_rdata;
- }
- /**
- * 获取 静态html 展示数据
- *
- * @return mixed
- */
- public function getHtmlList() {
- $_param = ['range' => DataConst::RANK_RANGE_WEEK];
- $_data = $this->getList([], '1,10', '-day_money');
- return $_data['list'];
- }
- /* 获取虚拟排行榜最新更新的时间用于cdn 防止刷新*/
- public function lastUpdateTime() {
- return (new HunterRankModel())->order('update_time DESC')->limit(1)->value('update_time');
- }
- }
|