This repository has been archived on 2024-07-11. You can view files and clone it, but cannot push or open issues or pull requests.
yoshop/source/application/store/model/bargain/Task.php
2020-04-25 22:20:29 +08:00

59 lines
1.6 KiB
PHP

<?php
namespace app\store\model\bargain;
use app\common\model\bargain\Task as TaskModel;
use app\store\service\Goods as GoodsService;
/**
* 砍价任务模型
* Class Task
* @package app\store\model\bargain
*/
class Task extends TaskModel
{
/**
* 获取列表数据
* @param string $search
* @return mixed|\think\Paginator
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getList($search = '')
{
$this->setBaseQuery($this->alias, [
['goods', 'goods_id'],
['user', 'user_id'],
]);
// 检索查询条件
if (!empty($search)) {
$this->where(function ($query) use ($search) {
$query->whereOr('goods.goods_name', 'like', "%{$search}%");
$query->whereOr('user.nickName', 'like', "%{$search}%");
});
}
// 获取活动列表
$list = $this->with(['user'])
->where("{$this->alias}.is_delete", '=', 0)
->order(["{$this->alias}.create_time" => 'desc'])
->paginate(15, false, [
'query' => \request()->request()
]);
if (!$list->isEmpty()) {
// 设置商品数据
$list = GoodsService::setGoodsData($list);
}
return $list;
}
/**
* 软删除
* @return false|int
*/
public function setDelete()
{
return $this->allowField(true)->save(['is_delete' => 1]);
}
}