<?php namespace App\Models; use Dcat\Admin\Traits\HasDateTimeFormatter; use Illuminate\Database\Eloquent\Model; /** * @property $id 主键id * @property $department_id 部门id * @property $department_name 部门名 * @property $assign_sale_name 分配业务员名 * @property $assign_sale_id 分配业务员id * @property $sort 排序 * @property $now_num 当前数量 * @property $max_num 分配总数 * @property $is_now 是否为当前分配部门 */ class AutoAssignCustomer extends Model { use HasDateTimeFormatter; public $timestamps = false; protected $table = 'auto_assign_customer'; const IS_NOW_YES = 1; const IS_NOW_NO = 0; public static function insertData($data) { return self::insertGetId($data); } //获取列表 public static function getList() { $res = self::orderBy('sort', 'asc')->get(); return ($res) ? $res->toArray() : []; } public static function getNowAssignInfo() { $res = self::where('is_now', self::IS_NOW_YES)->first(); return ($res) ? $res->toArray() : []; } public static function getInfoByOrderSort($sort = 0) { $res = self::where('sort', ">", $sort)->orderBy("sort", "ASC")->first(); return ($res) ? $res->toArray() : []; } public static function deleteById($addressId) { return self::where('id', $addressId)->delete(); } public static function updateById($id, $update) { return self::where("id", $id)->update($update); } public static function updateAll($update) { return self::where([])->update($update); } public static function updateByUserId($userId, $update) { return self::where("user_id", $userId)->update($update); } public static function getInfoById($id) { $res = self::where('id', $id)->first(); return ($res) ? $res->toArray() : []; } public static function getInfoByDepartmentId($id) { $res = self::where('department_id', $id)->first(); return ($res) ? $res->toArray() : []; } }