Goods.php 1.6 KB

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