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.
yanzong/app/common/model/successful.php

87 lines
2.0 KiB

<?php
declare (strict_types=1);
namespace app\common\model;
use cores\BaseModel;
/**
* 模型类:调货记录表
* Class Cart
* @package app\common\model
*/
class successful extends BaseModel
{
// 定义表名
protected $name = 'successful';
// 定义主键
protected $pk = 'id';
// 开启自动写入时间戳
protected $autoWriteTimestamp = true;
// 创建时间字段
protected $createTime = 'create_time';
// 更新时间字段
protected $updateTime = 'update_time';
/**
* 获取列表数据并分页
*
* @param array $param 查询参数
* @return \think\Paginator
*/
public function list(array $param): \think\Paginator
{
// 假设从数据库查询数据
$filter = $this->getFilter($param);
// 使用分页方法
$list = $this->where($filter)->order('sort', 'asc')->paginate($param['pageSize'] ?? 15);;
return $list;
}
/**
* @notes:新增
* @param $data
* @return bool
*/
public function add($data): bool
{
$data['store_id'] = self::$storeId;
return $this->save($data);
}
/**
* @notes:删除
* @param array $IdentityId
* @return bool
* @author: wanghousheng
*/
public function remove(array $ids): bool
{
if (static::whereIn('id', $ids)->delete()) {
return true;
}
return false;
}
/**
* 设置查询条件
* @param array $param
* @return array
*/
private function getFilter(array $param): array
{
// 设置默认的检索数据
$params = $this->setQueryDefaultValue($param, [
'successful' => '', // 查询内容
]);
// 检索查询条件
$filter = [];
// 用户昵称/订单号
!empty($params['successful']) && $filter[] = ['successful', 'like', "%{$params['successful']}%"];
return $filter;
}
}