1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- <?php
- namespace app\admin\model\user;
- use app\admin\model\order\StoreOrder;
- use app\models\store\StoreProduct;
- use crmeb\services\SystemConfigService;
- use think\facade\Db;
- use crmeb\traits\ModelTrait;
- use crmeb\basic\BaseModel;
- /**
- * TODO 场馆model
- * Class Article
- * @package app\models\article
- */
- class UserPartake extends BaseModel
- {
- /**
- * 数据表主键
- * @var string
- */
- protected $pk = 'id';
- /**
- * 模型名称
- * @var string
- */
- protected $name = 'user_partake';
- protected $autoWriteTimestamp = true;
- use ModelTrait;
- public static function list($where)
- {
- $model = self::alias('a')
- ->field('a.*,b.nickname,c.name,c.number')
- ->order('a.id DESC')
- ->leftJoin('user b', 'b.uid = a.uid')
- ->leftJoin('out c', 'c.id = a.out_id');
- if ($where['name']) $model->where('b.nickname|a.uid', 'like', '%'.$where['name'].'%');
- if ($where['status'] == 1){
- $model->where('a.status', 0);
- }
- if ($where['status'] == 2){
- $model->where('a.status', 1);
- }
- if ($where['status'] == 3){
- $model->where('a.status', 2);
- }
- if ($where['status'] == 4){
- $model->where('a.status', -1);
- }
- $data['count'] = $model->count();
- if ($where['page'] && $where['limit']){
- $model->page($where['page'], $where['limit']);
- }else{
- $model->page(20, 1);
- }
- $list = $model->select();
- $list = count($list) ? $list->toArray() : [];
- foreach ($list as &$item)
- {
- $uids = User::where('spread_uid', $item['uid'])->column('uid');
- if ($item['money'] == 0){
- $item['money'] = StoreOrder::where('uid', 'in', $uids)
- ->where('paid', 1)
- ->where('is_participate', 0)
- ->sum('pay_price');
- }
- }
- $data['data'] = $list;
- return $data;
- }
- }
|