123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- <?php
- namespace app\admin\controller;
- use app\model\web\Recommend as RecommendModel;
- use app\model\goods\Goods;
- class Recommend extends BaseAdmin
- {
-
- public function index(){
- if (request()->isAjax()) {
- $page = input('page', 1);
- $limit = input('page_size', PAGE_LIST_ROWS);
- $condition = [];
- $goods_name = input('goods_name','');
- if($goods_name){
- $condition[] = ['goods_name','like','%'.$goods_name.'%'];
- }
- $notice = new RecommendModel();
- $list = $notice->getRecommendPageList($condition, $page, $limit);
- return $list;
- }
- return $this->fetch('recommend/index');
- }
- public function add(){
- $goods_model = new Goods();
- if (request()->isAjax()) {
- $data = [
- 'goods_id' => input('goods_id', ''),
- 'create_time' => time(),
- ];
- if(!empty($data['goods_id'])){
- $goods = $goods_model->getGoodsInfo([['goods_id','=',$data['goods_id']]],'goods_name,goods_image');
- $goods_image = explode(',',$goods['data']['goods_image']);
- $data['goods_name']=$goods['data']['goods_name'];
- $data['goods_image']=$goods_image[0];
- }
- $notice = new RecommendModel();
- $res = $notice->add_recommend($data);
- return $res;
- } else {
- $goods_arr = $goods_model->getGoodsList(['goods_state'=>1,'verify_state'=>1,'is_delete'=>0],'goods_id,goods_name');
- $this->assign('goods_arr',$goods_arr['data']);
- return $this->fetch('recommend/add');
- }
- }
-
- public function deleteRecommend()
- {
- if (request()->isAjax()) {
- $id = input('id', '');
- $notice = new RecommendModel();
- $res = $notice->delete_recommend([ [ 'id', 'in', $id ] ]);
- return $res;
- }
- }
- }
|