Goods.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. /**
  3. * Niushop商城系统 - 团队十年电商经验汇集巨献!
  4. * =========================================================
  5. * Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
  6. * ----------------------------------------------
  7. * 官方网址: https://www.niushop.com
  8. * =========================================================
  9. */
  10. namespace addon\live\shop\controller;
  11. use app\shop\controller\BaseShop;
  12. use addon\live\model\Goods as GoodsModel;
  13. /**
  14. * 直播间
  15. */
  16. class Goods extends BaseShop
  17. {
  18. public function index()
  19. {
  20. if (request()->isAjax()) {
  21. $goods = new GoodsModel();
  22. $page = input('page', 1);
  23. $page_size = input('page_size', PAGE_LIST_ROWS);
  24. $condition = [
  25. 'site_id' => $this->site_id
  26. ];
  27. $data = $goods->getGoodsPageList($condition, '*', 'id desc', $page, $page_size);
  28. return $data;
  29. } else {
  30. $this->forthMenu();
  31. return $this->fetch("goods/index");
  32. }
  33. }
  34. /**
  35. * 同步直播商品库
  36. */
  37. public function sync()
  38. {
  39. if (request()->isAjax()) {
  40. $goods = new GoodsModel();
  41. $start = input('start', 0);
  42. $res = $goods->syncGoods($start, 20, $this->site_id);
  43. return $res;
  44. }
  45. }
  46. /**
  47. * 添加商品
  48. * @return mixed
  49. */
  50. public function add()
  51. {
  52. if (request()->isAjax()) {
  53. $goods = new GoodsModel();
  54. $data = [
  55. 'site_id' => $this->site_id,
  56. 'name' => input('name', ''),
  57. 'goods_pic' => input('goods_pic', ''),
  58. 'price_type' => input('price_type', ''),
  59. 'price' => input('price', ''),
  60. 'price2' => input('price2', ''),
  61. 'url' => input('url', ''),
  62. ];
  63. $res = $goods->addGoods($data);
  64. return $res;
  65. }
  66. return $this->fetch("goods/add");
  67. }
  68. /**
  69. * 删除商品
  70. */
  71. public function delete()
  72. {
  73. if (request()->isAjax()) {
  74. $id = input('id', '');
  75. $goods = new GoodsModel();
  76. $res = $goods->deleteGoods($id, $this->site_id);
  77. return $res;
  78. }
  79. }
  80. }