123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- <?php
- namespace app\models\vote;
- use app\models\user\User;
- use crmeb\basic\BaseModel;
- use crmeb\traits\ModelTrait;
- class UserVote extends BaseModel
- {
- /**
- * 数据表主键
- * @var string
- */
- protected $pk = 'id';
- /**
- * 模型名称
- * @var string
- */
- protected $name = 'user_vote';
- use ModelTrait;
- /**
- * @param $where
- * @return array
- */
- public static function getUserList($where)
- {
- $model = self::group('uid')->field('uid,sum(vote_num) as money');
- if (isset($where['id']) && $where['id']) $model = $model->where('sub_vote_id', $where['id']);
- $count = $model->count();
- $data = $model->page((int)$where['page'], (int)$where['limit'])->select()->each(function ($item) {
- $item['user'] = User::getUserInfo($item['uid']);
- });
- return compact('count', 'data');
- }
- /**
- * @param $where
- * @return array
- */
- public static function getOneUserList($where)
- {
- $model = self::where('uid', $where['uid'])->order('add_time', 'desc')->page((int)$where['page'], (int)$where['limit'])->select()->each(function ($item) {
- $item['vote'] = VoteSub::get($item['sub_vote_id']);
- $item['_add_time'] = date('Y-m-d H:i:s', $item['add_time']);
- });
- return $model;
- }
- }
|