diff --git a/app/common/model/Tipoff.php b/app/common/model/Tipoff.php new file mode 100644 index 00000000..6967509a --- /dev/null +++ b/app/common/model/Tipoff.php @@ -0,0 +1,66 @@ +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; + } + + +} diff --git a/app/store/controller/Goods.php b/app/store/controller/Goods.php index 6158c0ff..f4b6c0e8 100644 --- a/app/store/controller/Goods.php +++ b/app/store/controller/Goods.php @@ -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')); + + } }