Goods.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <?php
  2. /**
  3. * Niushop商城系统 - 团队十年电商经验汇集巨献!
  4. * =========================================================
  5. * Copy right 2019-2029 山西牛酷信息科技有限公司, 保留所有权利。
  6. * ----------------------------------------------
  7. * 官方网址: https://www.niushop.com.cn
  8. * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
  9. * 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
  10. * =========================================================
  11. */
  12. namespace addon\pintuan\api\controller;
  13. use addon\pintuan\model\Pintuan as PintuanModel;
  14. use app\api\controller\BaseApi;
  15. use app\model\shop\Shop as ShopModel;
  16. use addon\pintuan\model\Poster;
  17. /**
  18. * 拼团商品
  19. */
  20. class Goods extends BaseApi
  21. {
  22. /**
  23. * 基础信息
  24. */
  25. public function info()
  26. {
  27. $sku_id = isset($this->params['sku_id']) ? $this->params['sku_id'] : 0;
  28. $pintuan_id = isset($this->params['pintuan_id']) ? $this->params['pintuan_id'] : 0;
  29. if (empty($sku_id)) {
  30. return $this->response($this->error('', 'REQUEST_SKU_ID'));
  31. }
  32. if (empty($pintuan_id)) {
  33. return $this->response($this->error('', 'REQUEST_PINTUAN_ID'));
  34. }
  35. $goods = new PintuanModel();
  36. $condition = [
  37. [ 'sku.sku_id', '=', $sku_id ],
  38. [ 'ppg.pintuan_id', '=', $pintuan_id ],
  39. ];
  40. $info = $goods->getPintuanGoodsDetail($condition);
  41. return $this->response($info);
  42. }
  43. /**
  44. * 拼团商品详情信息
  45. */
  46. public function detail()
  47. {
  48. $id = isset($this->params['id']) ? $this->params['id'] : 0;
  49. if (empty($id)) {
  50. return $this->response($this->error('', 'REQUEST_ID'));
  51. }
  52. $pintuan_model = new PintuanModel();
  53. $condition = [
  54. [ 'ppg.id', '=', $id ],
  55. ];
  56. $goods_sku_detail = $pintuan_model->getPintuanGoodsDetail($condition);
  57. $goods_sku_detail = $goods_sku_detail['data'];
  58. $res['goods_sku_detail'] = $goods_sku_detail;
  59. // 店铺信息
  60. $shop_model = new ShopModel();
  61. $shop_info = $shop_model->getShopInfo([ [ 'site_id', '=', $goods_sku_detail['site_id'] ] ], 'site_id,site_name,is_own,logo,avatar,banner,seo_description,qq,ww,telephone,shop_desccredit,shop_servicecredit,shop_deliverycredit,shop_baozh,shop_baozhopen,shop_baozhrmb,shop_qtian,shop_zhping,shop_erxiaoshi,shop_tuihuo,shop_shiyong,shop_shiti,shop_xiaoxie,shop_sales,sub_num');
  62. $shop_info = $shop_info['data'];
  63. $res['shop_info'] = $shop_info;
  64. return $this->response($this->success($res));
  65. }
  66. public function page()
  67. {
  68. $site_id = isset($this->params['site_id']) ? $this->params['site_id'] : 0;
  69. $page = isset($this->params['page']) ? $this->params['page'] : 1;
  70. $page_size = isset($this->params['page_size']) ? $this->params['page_size'] : PAGE_LIST_ROWS;
  71. $condition = [
  72. [ 'pp.status', '=', 1 ],// 状态(0正常 1活动进行中 2活动已结束 3失效 4删除)
  73. [ 'sku.stock', '>', 0 ],
  74. [ 'sku.goods_state', '=', 1 ],
  75. [ 'sku.verify_state', '=', 1 ],
  76. [ 'sku.is_delete', '=', 0 ],
  77. ];
  78. if (!empty($site_id)) {
  79. $condition[] = [ 'sku.site_id', '=', $site_id ];
  80. }
  81. $pintuan_model = new PintuanModel();
  82. $list = $pintuan_model->getPintuanGoodsPageList($condition, $page, $page_size);
  83. return $this->response($list);
  84. }
  85. /**
  86. * 获取商品海报
  87. */
  88. public function poster(){
  89. if (!empty($qrcode_param)) return $this->response($this->error('', '缺少必须参数qrcode_param'));
  90. $promotion_type = 'pintuan';
  91. $qrcode_param = json_decode($this->params['qrcode_param'], true);
  92. $qrcode_param['source_member'] = $qrcode_param['source_member'] ?? 0;
  93. $poster = new Poster();
  94. $res = $poster->goods($this->params['app_type'], $this->params['page'], $qrcode_param, $promotion_type);
  95. return $this->response($res);
  96. }
  97. }