parent
631db392b5
commit
ee5942fcb5
@ -0,0 +1,66 @@ |
||||
<?php |
||||
|
||||
declare (strict_types=1); |
||||
|
||||
namespace app\common\model; |
||||
|
||||
use cores\BaseModel; |
||||
use app\common\service\Jd; |
||||
|
||||
class Tipoff extends BaseModel |
||||
{ |
||||
|
||||
protected $name = 'tipoff'; |
||||
|
||||
protected $pk = 'id'; |
||||
|
||||
public function add(array $data) |
||||
{ |
||||
return $this->save($data); |
||||
} |
||||
|
||||
public function getList(array $param = []) |
||||
{ |
||||
$filter = $this->getQueryFilter($param); |
||||
$list = $this->alias('tipoff') |
||||
->where($filter) |
||||
->join('goods', 'goods.goods_id = tipoff.goods_id') |
||||
->field('tipoff.*,goods.*') |
||||
->order(['tipoff.create_time' => 'desc']) |
||||
->paginate($param['pageSize'] ?? 15); |
||||
$jd = new Jd(); |
||||
foreach ($list as $key => $value) { |
||||
//京东短链 |
||||
$jd_short_url = $jd->getJdShortLink($value->goods_no); |
||||
$value['jd_short_url'] = $jd_short_url; |
||||
} |
||||
|
||||
return $list; |
||||
} |
||||
|
||||
public function getQueryFilter(array $param) |
||||
{ |
||||
// 设置默认的检索数据 |
||||
$params = $this->setQueryDefaultValue($param, [ |
||||
'header_content' =>"", // 查询内容 |
||||
'channel' => "", // 渠道 |
||||
'betweenTime' => [] // 起止时间 |
||||
]); |
||||
// 检索查询条件 |
||||
$filter = []; |
||||
|
||||
// 起止时间 |
||||
if (!empty($params['create_time'])) { |
||||
$times = between_time($params['create_time']); |
||||
$filter[] = ['tipoff.create_time', '>=', $times['create_time']]; |
||||
$filter[] = ['tipoff.create_time', '<', $times['create_time'] + 86400]; |
||||
} |
||||
|
||||
!empty($params['channel_name']) && $filter[] = ['tipoff.channel_name', 'like', "%{$params['channel_name']}%"]; |
||||
!empty($params['header_content']) && $filter[] = ['tipoff.header_content', 'like', "%{$params['header_content']}%"]; |
||||
|
||||
return $filter; |
||||
} |
||||
|
||||
|
||||
} |
Loading…
Reference in new issue