<?php
/*
 * @Descripttion:
 * @version:
 * @Author: kangkang
 * @Date: 2020-10-16 14:44:02
 * @LastEditors: Please set LastEditors
 * @LastEditTime: 2020-11-20 16:51:47
 */

namespace app\manager\model;

use fastphp\base\Model;

class User extends Model
{
    protected $table = 'user';

    /**
     * @description: 获取所有客户经理客户数量
     * @param {*}
     * @return {*}
     */
    public function getAllManagerUserCount()
    {
        return $this->field('ManagerId,ManagerName,count(1) as count_num')->group(['ManagerId'])->fetchAll();
    }

    /**
     * @description: 获取所有客户经理客户
     * @param {*}
     * @return {*}
     */
    public function getAllManagerUser($where = [])
    {
        return $this->field('Id,CreateTime')->where($where)->fetchAll();
    }

    /**
     * @description: 查询符合筛选条件的所有用户数量
     * @param {*}
     * @return {*}
     */
    public function getScreenUserCount($where)
    {
        return $this->field('ManagerId,ManagerName,count(1) as count_num')->where($where)->group(['ManagerId'])->fetchAll();
    }

    /**
     * @description: 为客户经理分配用户
     * @param {*}
     * @return {*}
     */
    public function setManager($where, $data, $limit)
    {
        return $this->where($where)->limit($limit)->update($data);
    }

}
