// +---------------------------------------------------------------------- namespace app\dao\order; use app\dao\BaseDao; use app\model\order\DeliveryService; /**配送dao * Class DeliveryServiceDao * @package app\dao\service */ class DeliveryServiceDao extends BaseDao { /** * 设置模型 * @return string */ protected function setModel(): string { return DeliveryService::class; } /** * 获取配送员列表 * @param array $where * @param int $page * @param int $limit * @return array * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ public function getServiceList(array $where, int $page, int $limit) { return $this->search($where, false)->when($page && $limit, function ($query) use ($page, $limit) { $query->page($page, $limit); })->when(isset($where['noId']), function ($query) use ($where) { $query->where('id', '<>', $where['noId']); })->order('id DESC')->select()->toArray(); } /**获取所有配送员列表 * @return array * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ public function getList(int $page, int $limit) { $list = $this->getModel()->where(['status' => 1])->order('id DESC')->limit($page, $limit)->select()->toArray(); foreach ($list as &$item) { $item['wx_name'] = $item['nickname']; } $count = $this->getModel()->where(['status' => 1])->count(); return [$list, $count]; } }