You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
91 lines
2.6 KiB
91 lines
2.6 KiB
11 months ago
|
<?php
|
||
|
// +----------------------------------------------------------------------
|
||
|
// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
|
||
|
// +----------------------------------------------------------------------
|
||
|
// | Copyright (c) 2017~2023 https://www.yiovo.com All rights reserved.
|
||
|
// +----------------------------------------------------------------------
|
||
|
// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
|
||
|
// +----------------------------------------------------------------------
|
||
|
// | Author: 萤火科技 <admin@yiovo.com>
|
||
|
// +----------------------------------------------------------------------
|
||
|
declare (strict_types=1);
|
||
|
|
||
|
namespace app\store\model\eorder;
|
||
|
|
||
|
use app\common\model\eorder\Template as TemplateModel;
|
||
|
|
||
|
/**
|
||
|
* 模型类:电子面单模板
|
||
|
* Class Template
|
||
|
* @package app\store\model
|
||
|
*/
|
||
|
class Template extends TemplateModel
|
||
|
{
|
||
|
/**
|
||
|
* 获取全部电子面单模板
|
||
|
* @return array|static[]|\think\Collection
|
||
|
* @throws \think\db\exception\DataNotFoundException
|
||
|
* @throws \think\db\exception\DbException
|
||
|
* @throws \think\db\exception\ModelNotFoundException
|
||
|
*/
|
||
|
public function getAll()
|
||
|
{
|
||
|
return $this->where('is_delete', '=', 0)
|
||
|
->order(['sort' => 'asc', $this->getPk()])
|
||
|
->select();
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 获取列表记录
|
||
|
* @param array $param
|
||
|
* @return \think\Paginator
|
||
|
* @throws \think\db\exception\DbException
|
||
|
*/
|
||
|
public function getList(array $param = []): \think\Paginator
|
||
|
{
|
||
|
// 查询模型
|
||
|
$query = $this->getNewQuery();
|
||
|
// 查询参数
|
||
|
$params = $this->setQueryDefaultValue($param, [
|
||
|
'search' => '', // 关键词
|
||
|
]);
|
||
|
// 检索关键词
|
||
|
!empty($params['search']) && $query->where('name', 'like', "%{$params['search']}%");
|
||
|
// 查询数据
|
||
|
return $query->with(['express'])
|
||
|
->where('is_delete', '=', 0)
|
||
|
->order(['sort', 'create_time'])
|
||
|
->paginate(15);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 添加新记录
|
||
|
* @param array $data
|
||
|
* @return bool|false
|
||
|
*/
|
||
|
public function add(array $data): bool
|
||
|
{
|
||
|
$data['store_id'] = self::$storeId;
|
||
|
return $this->save($data);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 编辑记录
|
||
|
* @param array $data
|
||
|
* @return bool
|
||
|
*/
|
||
|
public function edit(array $data): bool
|
||
|
{
|
||
|
return $this->save($data);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 删除记录
|
||
|
* @return bool
|
||
|
*/
|
||
|
public function setDelete(): bool
|
||
|
{
|
||
|
return $this->save(['is_delete' => 1]);
|
||
|
}
|
||
|
}
|