Goods.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. namespace app\data\controller\api\business;
  3. use app\data\model\ShopGoods;
  4. use think\admin\Controller;
  5. /**
  6. * 商家商品数据接口
  7. */
  8. class Goods extends Controller
  9. {
  10. /**
  11. * @Title ("我的商品数据")
  12. * @Param ("name",desc="商品名称")
  13. * @Param ("status",desc="1售卖中 0已下架 2已售罄 传空全部")
  14. * @return void
  15. * @throws \think\db\exception\DataNotFoundException
  16. * @throws \think\db\exception\DbException
  17. * @throws \think\db\exception\ModelNotFoundException
  18. */
  19. public function goods_list(){
  20. $count = ['全部','售卖中','已下架','已售罄'];
  21. foreach ($count as &$v){
  22. switch ($v){
  23. case '全部':
  24. $where =[];
  25. break;
  26. case '售卖中':
  27. $where['status']=1;
  28. break;
  29. case '已下架':
  30. $where['status']=0;
  31. break;
  32. case '已售罄':
  33. $where['status']=2;
  34. }
  35. $v=ShopGoods::mk()->where('admin_id',10000)->where($where)->count();
  36. }
  37. $query = ShopGoods::mQuery()->like('name,cateids')->equal('code,status');
  38. $result = $query->where('admin_id',10000)->order('id desc')->page(true, false, false, 10);
  39. $data['count'] =$count;
  40. $data['list']=$result;
  41. $this->success('我的商品列表',$data);
  42. }
  43. /**
  44. * @Title ("添加商品")
  45. */
  46. public function goods_add(){
  47. }
  48. }