Bundling.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <?php
  2. /**
  3. * Niushop商城系统 - 团队十年电商经验汇集巨献!
  4. * =========================================================
  5. * Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
  6. * ----------------------------------------------
  7. * 官方网址: https://www.niushop.com
  8. * =========================================================
  9. */
  10. namespace addon\bundling\shop\controller;
  11. use app\shop\controller\BaseShop;
  12. use addon\bundling\model\Bundling as BundlingModel;
  13. /**
  14. * 优惠套餐
  15. * @author Administrator
  16. *
  17. */
  18. class Bundling extends BaseShop
  19. {
  20. /**
  21. * 添加优惠套餐
  22. */
  23. public function add()
  24. {
  25. if (request()->isAjax()) {
  26. $data = [
  27. 'site_id' => $this->site_id,
  28. 'bl_name' => input('bl_name', ''),//组合名称
  29. 'bl_price' => input('bl_price', ''),//商品组合价格
  30. 'shipping_fee_type' => input('shipping_fee_type', ''),//运费承担方式 1卖家承担运费 2买家承担运费
  31. 'status' => input('status', ''),//是否上下架
  32. ];
  33. $sku_ids = input("sku_ids", "");
  34. $bundling_model = new BundlingModel();
  35. $res = $bundling_model->addBundling($data, $sku_ids);
  36. return $res;
  37. } else {
  38. return $this->fetch("bundling/add");
  39. }
  40. }
  41. /**
  42. * 编辑优惠套餐
  43. */
  44. public function edit()
  45. {
  46. $bl_id = input('bl_id', 0);
  47. $bundling_model = new BundlingModel();
  48. if (request()->isAjax()) {
  49. $data = [
  50. 'bl_name' => input('bl_name', ''),//组合名称
  51. 'bl_price' => input('bl_price', ''),//商品组合价格
  52. 'shipping_fee_type' => input('shipping_fee_type', ''),//运费承担方式 1卖家承担运费 2买家承担运费
  53. 'status' => input('status', ''),//最大领取数量
  54. ];
  55. $sku_ids = input("sku_ids", "");
  56. $condition = array (
  57. [ "bl_id", "=", $bl_id ],
  58. [ "site_id", "=", $this->site_id ]
  59. );
  60. $res = $bundling_model->editBundling($data, $sku_ids, $condition);
  61. return $res;
  62. } else {
  63. $condition = [ [ 'bl_id', '=', $bl_id ], [ 'site_id', '=', $this->site_id ] ];
  64. $info_result = $bundling_model->getBundlingDetail($condition);
  65. $info = $info_result[ "data" ];
  66. if (empty($info)) $this->error('未获取到活动数据', addon_url('bundling://shop/bundling/lists'));
  67. $this->assign("info", $info);
  68. $this->assign("bl_id", $bl_id);
  69. return $this->fetch("bundling/edit");
  70. }
  71. }
  72. /**
  73. * 优惠套餐详情
  74. */
  75. public function detail()
  76. {
  77. $bundling_id = input('bl_id', '');
  78. $bundling_model = new BundlingModel();
  79. $condition = [ [ 'bl_id', '=', $bundling_id ], [ 'site_id', '=', $this->site_id ] ];
  80. $info = $bundling_model->getBundlingDetail($condition)[ 'data' ] ?? [];
  81. if (empty($info)) $this->error('未获取到活动数据', addon_url('bundling://shop/bundling/lists'));
  82. $this->assign('info', $info);
  83. return $this->fetch("bundling/detail");
  84. }
  85. /**
  86. * 优惠套餐列表
  87. */
  88. public function lists()
  89. {
  90. if (request()->isAjax()) {
  91. $page = input('page', 1);
  92. $page_size = input('page_size', PAGE_LIST_ROWS);
  93. $bl_name = input('bl_name', '');
  94. $status = input('status', '');
  95. $condition = [];
  96. if ($status !== '') {
  97. $condition[] = [ 'status', '=', $status ];
  98. }
  99. $condition[] = [ 'site_id', '=', $this->site_id ];
  100. $condition[] = [ 'bl_name', 'like', '%' . $bl_name . '%' ];
  101. $order = 'update_time desc';
  102. $field = '*';
  103. $bundling_model = new BundlingModel();
  104. $res = $bundling_model->getBundlingPageList($condition, $page, $page_size, $order, $field);
  105. return $res;
  106. } else {
  107. return $this->fetch("bundling/lists");
  108. }
  109. }
  110. /**
  111. * 删除优惠套餐
  112. */
  113. public function delete()
  114. {
  115. if (request()->isAjax()) {
  116. $bl_id = input('bl_id', 0);
  117. $bundling_model = new BundlingModel();
  118. $res = $bundling_model->deleteBundling($bl_id, $this->site_id);
  119. return $res;
  120. }
  121. }
  122. }