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.
67 lines
1.8 KiB
67 lines
1.8 KiB
4 months ago
|
<?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;
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|