zyh 3 months ago
parent 631db392b5
commit ee5942fcb5
  1. 66
      app/common/model/Tipoff.php
  2. 30
      app/store/controller/Goods.php

@ -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;
}
}

@ -19,6 +19,7 @@ use app\store\model\Goods as GoodsModel;
use app\store\model\goods\Import as ImportModel;
use app\common\model\GoodsCategoryRel;
use app\common\model\Category;
use app\common\model\Tipoff as ModelTipoff;
use app\job\controller\goods\StoreGoodsOffline as StoreGoodsOfflineJob;
use app\job\controller\goods\StoreGoodsOnline as StoreGoodsOnlineJob;
use app\job\controller\goods\StoreGoodsDelete as StoreGoodsDeleteJob;
@ -597,4 +598,33 @@ class Goods extends Controller
}
public function addTipff()
{
$params = $this->postForm();
$model = new GoodsModel;
$goods = $model->where("goods_id", "in", $params['goods_id'])->select();
// $jd = new Jd();
// foreach ($goods as $key => $value) {
// //京东短链
// $jd_short_url = $jd->getJdShortLink($value->goods_no);
// $value['jd_short_url'] = $jd_short_url;
// }
// $params['goods'] = $goods;
$params['store_id'] = $this->storeId;
$Tipoff = new ModelTipoff();
if (!$Tipoff->add($params)) {
return $this->renderError($Tipoff->getError() ?: '操作失败');
}
return $this->renderSuccess('操作成功');
}
public function tipOffList()
{
$params = $this->request->param();
$model = new ModelTipoff;
$result = $model->getList($params);
return $this->renderSuccess(compact('result'));
}
}

Loading…
Cancel
Save