- 按 docs/renew-code-comment.md 将 PHP 文件头改为带边框的 Author 注释\n- 注释中的 crmeb.com 替换为 uj345.cn(代码字符串中的外链未改)\n- 新增 docs/renew-code-comment.md 说明 Made-with: Cursor
64 lines
2.0 KiB
PHP
64 lines
2.0 KiB
PHP
<?php
|
|
// +----------------------------------------------------------------------
|
|
// | Author: ScottPan Team
|
|
// +----------------------------------------------------------------------
|
|
|
|
namespace app\dao\store;
|
|
|
|
use app\dao\BaseDao;
|
|
use app\model\store\DeliveryService;
|
|
|
|
/**
|
|
* 配送dao
|
|
* Class DeliveryServiceDao
|
|
* @package app\dao\store
|
|
*/
|
|
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 = 0, int $limit = 0)
|
|
{
|
|
$realName = $where['keyword'] ?? '';
|
|
$fieldKey = $where['field_key'] ?? '';
|
|
$fieldKey = $fieldKey == 'all' ? '' : $fieldKey;
|
|
return $this->search($where)->with('user')->when($page && $limit, function ($query) use ($page, $limit) {
|
|
$query->page($page, $limit);
|
|
})->when($realName && $fieldKey && in_array($fieldKey, ['id', 'phone']), function ($query) use ($where, $realName, $fieldKey) {
|
|
$query->whereLike($fieldKey, '%' . $where['keyword'] . '%');
|
|
})->when($realName && !$fieldKey, function ($query) use ($where) {
|
|
$query->whereLike('uid|id|nickname|phone', '%' . $where['keyword'] . '%');
|
|
})->when(isset($where['noId']), function ($query) use ($where) {
|
|
$query->where('id', '<>', $where['noId']);
|
|
})->order('id DESC')->field('id,uid,avatar,nickname as wx_name,status,add_time,phone')->select()->toArray();
|
|
}
|
|
|
|
/**
|
|
* 获取配送员select
|
|
* @param array $where
|
|
* @return array
|
|
*/
|
|
public function getSelectList(array $where)
|
|
{
|
|
return $this->search($where)->field('uid,nickname')->select()->toArray();
|
|
}
|
|
|
|
}
|