SupplierGoods.php 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. <?php
  2. namespace app\operate\controller;
  3. use app\common\model\DatumIntro;
  4. use library\Controller;
  5. use think\Db;
  6. /**
  7. * 供货商商品
  8. * Class SupplierGoods
  9. * @package app\mall\controller
  10. */
  11. class SupplierGoods extends Controller
  12. {
  13. /**
  14. * 绑定数据表
  15. * @var string
  16. */
  17. protected $table = 'SupplierGoods';
  18. /**
  19. * 供货商商品列表
  20. * @auth true
  21. * @menu true
  22. * @throws \think\Exception
  23. * @throws \think\db\exception\DataNotFoundException
  24. * @throws \think\db\exception\ModelNotFoundException
  25. * @throws \think\exception\DbException
  26. * @throws \think\exception\PDOException
  27. */
  28. public function index()
  29. {
  30. $this->title = '供货商商品列表';
  31. $supplier_id = input('get.supplier_id');
  32. $company_id = input('get.company_id');
  33. $third_classify = input('get.third_classify');
  34. $this->supplier_id = $supplier_id;
  35. $this->supplier_list = \app\common\model\Supplier::getSupplierName(0);
  36. //$this->company_list = \app\common\model\Company::getCompanyName();
  37. $where = [];
  38. $where[] = ['a.is_deleted','=',0];
  39. if($supplier_id)$where[] = ['a.supplier_id','=',$supplier_id];
  40. if($company_id)$where[] = ['a.company_id','=',$company_id];
  41. if($third_classify)$where[] = ['a.third_classify','=',$third_classify];
  42. $query = $this->_query($this->table)->where($where)->like('a.name')->alias('a')->field('a.*,b.title supplier_name ,c.title company_name');
  43. $query->leftJoin('Supplier b','b.id = a.supplier_id')->leftJoin('Company c','c.id = a.company_id');
  44. $query->order(' a.sort desc , a.id desc')->page();
  45. }
  46. /**
  47. * 数据列表处理
  48. * @auth true
  49. * @menu true
  50. * @param array $data
  51. * @throws \think\db\exception\DataNotFoundException
  52. * @throws \think\db\exception\ModelNotFoundException
  53. * @throws \think\exception\DbException
  54. */
  55. protected function _index_page_filter(&$data)
  56. {
  57. }
  58. /**
  59. * 添加供货商商品
  60. * @auth true
  61. * @menu true
  62. * @throws \think\Exception
  63. * @throws \think\db\exception\DataNotFoundException
  64. * @throws \think\db\exception\ModelNotFoundException
  65. * @throws \think\exception\DbException
  66. * @throws \think\exception\PDOException
  67. */
  68. public function add()
  69. {
  70. $this->title = '添加供货商商品';
  71. $this->supplier_id = input('supplier_id');
  72. $this->_form($this->table, 'form');
  73. }
  74. /**
  75. * 编辑供货商商品
  76. * @auth true
  77. * @menu true
  78. * @throws \think\Exception
  79. * @throws \think\db\exception\DataNotFoundException
  80. * @throws \think\db\exception\ModelNotFoundException
  81. * @throws \think\exception\DbException
  82. * @throws \think\exception\PDOException
  83. */
  84. public function edit()
  85. {
  86. $this->title = '编辑供货商商品';
  87. $this->supplier_id = input('supplier_id');
  88. $this->_form($this->table, 'form');
  89. }
  90. /**
  91. * 启用
  92. * @auth true
  93. * @menu true
  94. * @throws \think\Exception
  95. * @throws \think\exception\PDOException
  96. */
  97. public function enable()
  98. {
  99. $this->_save($this->table, ['status' => 1]);
  100. $this->success('已上架!');
  101. }
  102. /**
  103. * 禁用
  104. * @auth true
  105. * @menu true
  106. * @throws \think\Exception
  107. * @throws \think\db\exception\DataNotFoundException
  108. * @throws \think\db\exception\ModelNotFoundException
  109. * @throws \think\exception\DbException
  110. * @throws \think\exception\PDOException
  111. */
  112. public function forbidden()
  113. {
  114. $this->_save($this->table, ['status' => 0]);
  115. $this->success('已下架!');
  116. }
  117. /**
  118. * 删除
  119. * @auth true
  120. * @menu true
  121. * @throws \think\Exception
  122. * @throws \think\exception\PDOException
  123. */
  124. public function del()
  125. {
  126. $this->_save($this->table, ['is_deleted' => 1]);
  127. }
  128. /**
  129. * 表单数据处理
  130. * @auth true
  131. * @menu true
  132. * @param array $data
  133. */
  134. protected function _form_filter(&$data)
  135. {
  136. // 视频
  137. $this->video_list = \app\common\model\VideoIntro::with('videoArr')
  138. ->where(['is_deleted'=>0])->order('id desc')
  139. ->select()->toArray();
  140. // 文章列表
  141. $this->article_list = \app\common\model\ArticleIntro::with('itemChildren')
  142. ->field('id,title')
  143. ->where(['is_deleted'=>0])->order('id desc')
  144. ->select()->toArray();
  145. // 资料
  146. $this->datum_list = DatumIntro::with('urlArr')
  147. ->where(['is_deleted'=>0])->order('id desc')
  148. ->select()->toArray();
  149. $data['create_at'] = date('Y-m-d H:i:s');
  150. $this->supplier_list = \app\common\model\Supplier::getSupplierName(0);
  151. // $this->company_list = \app\common\model\Company::getCompanyName();
  152. $all_cate = \app\common\model\SupplierCate::where(['is_deleted'=>0])->order('sort desc ,id desc')->select();
  153. $this->cate_tree = make_tree($all_cate);
  154. $this->assign('waitSecond','1');
  155. $this->assign("jumpUrl",$_SERVER["HTTP_REFERER"]);
  156. }
  157. protected function _form_result($id)
  158. {
  159. $this->success('操作成功', 'javascript:history.back()');
  160. }
  161. }