Goods.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <?php
  2. namespace app\api\controller;
  3. use app\model\goods\Goods as GoodsModel;
  4. use app\model\goods\GoodsService;
  5. use app\model\order\OrderCommon;
  6. use app\model\system\Poster;
  7. use app\model\goods\Config as GoodsConfigModel;
  8. use app\model\web\Config as ConfigModel;
  9. class Goods extends BaseApi
  10. {
  11. /**
  12. * 修改商品点击量
  13. * @return string
  14. */
  15. public function modifyclicks()
  16. {
  17. $sku_id = isset($this->params[ 'sku_id' ]) ? $this->params[ 'sku_id' ] : 0;
  18. if (empty($sku_id)) {
  19. return $this->response($this->error('', 'REQUEST_SKU_ID'));
  20. }
  21. $token = $this->checkToken();
  22. if ($token[ 'code' ] < 0) return $this->response($token);
  23. $goods_model = new GoodsModel();
  24. $res = $goods_model->modifyClick($sku_id, $this->site_id);
  25. return $this->response($res);
  26. }
  27. /**
  28. * 获取商品海报
  29. */
  30. public function poster()
  31. {
  32. $this->checkToken();
  33. $promotion_type = 'null';
  34. $qrcode_param = json_decode($this->params[ 'qrcode_param' ], true);
  35. $qrcode_param[ 'source_member' ] = $this->member_id;
  36. $poster = new Poster();
  37. $res = $poster->goods($this->params[ 'app_type' ], $this->params[ 'page' ], $qrcode_param, $promotion_type, $this->site_id, $this->store_id);
  38. return $this->response($res);
  39. }
  40. /**
  41. * 售后保障
  42. * @return false|string
  43. */
  44. public function aftersale()
  45. {
  46. $goods_config_model = new GoodsConfigModel();
  47. $res = $goods_config_model->getAfterSaleConfig($this->site_id);
  48. return $this->response($res);
  49. }
  50. /**
  51. * 获取热门搜索关键词
  52. */
  53. public function hotSearchWords()
  54. {
  55. $config_model = new ConfigModel();
  56. $info = $config_model->getHotSearchWords($this->site_id, $this->app_module);
  57. return $this->response($this->success($info[ 'data' ][ 'value' ]));
  58. }
  59. /**
  60. * 获取默认搜索关键词
  61. */
  62. public function defaultSearchWords()
  63. {
  64. $config_model = new ConfigModel();
  65. $info = $config_model->getDefaultSearchWords($this->site_id, $this->app_module);
  66. return $this->response($this->success($info[ 'data' ][ 'value' ]));
  67. }
  68. /**
  69. * 商品服务
  70. * @return false|string
  71. */
  72. public function service()
  73. {
  74. $goods_service = new GoodsService();
  75. $data = $goods_service->getServiceList([ [ 'site_id', '=', $this->site_id ] ], 'service_name,desc,icon');
  76. foreach ($data[ 'data' ] as $key => $val) {
  77. $data[ 'data' ][ $key ][ 'icon' ] = json_decode($val[ 'icon' ], true);
  78. }
  79. return $this->response($data);
  80. }
  81. /**
  82. * 商品弹幕
  83. * @return false|string
  84. */
  85. public function goodsBarrage()
  86. {
  87. $goods_id = isset($this->params[ 'goods_id' ]) ? $this->params[ 'goods_id' ] : 0;
  88. $order = new OrderCommon();
  89. $field = 'm.headimg as img, m.nickname as title';
  90. $join = [
  91. [
  92. 'member m',
  93. 'm.member_id=og.member_id',
  94. 'left'
  95. ],
  96. [
  97. 'order o',
  98. 'o.order_id=og.order_id',
  99. 'left'
  100. ]
  101. ];
  102. $data = $order->getOrderGoodsPageList([ [ 'og.site_id', '=', $this->site_id ], [ 'og.goods_id', '=', $goods_id ], [ 'o.pay_status', '=', 1 ] ], 1, 20, 'og.order_goods_id desc', $field, 'og', $join, 'o.member_id');
  103. return $this->response($data);
  104. }
  105. /**
  106. * 小程序分享图
  107. * @return false|string
  108. */
  109. public function shareImg()
  110. {
  111. $qrcode_param = json_decode($this->params[ 'qrcode_param' ] ?? '{}', true);
  112. $poster = new Poster();
  113. $res = $poster->shareImg($this->params[ 'page' ] ?? '', $qrcode_param, $this->site_id, $this->store_id);
  114. return $this->response($res);
  115. }
  116. }