Freeshipping.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <?php
  2. /**
  3. * Niushop商城系统 - 团队十年电商经验汇集巨献!
  4. * =========================================================
  5. * Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
  6. * ----------------------------------------------
  7. * 官方网址: https://www.niushop.com
  8. * =========================================================
  9. */
  10. namespace addon\freeshipping\shop\controller;
  11. use app\shop\controller\BaseShop;
  12. use addon\freeshipping\model\Freeshipping as FreeshippingModel;
  13. class Freeshipping extends BaseShop
  14. {
  15. public function lists()
  16. {
  17. $model = new FreeshippingModel();
  18. $condition[] = [ 'site_id', '=', $this->site_id ];
  19. if (request()->isAjax()) {
  20. $page = input('page', 1);
  21. $page_size = input('page_size', PAGE_LIST_ROWS);
  22. $list = $model->getFreeshippingPageList($condition, $page, $page_size, 'price asc');
  23. return $list;
  24. } else {
  25. return $this->fetch("freeshipping/lists");
  26. }
  27. }
  28. /**
  29. * 添加活动
  30. */
  31. public function add()
  32. {
  33. if (request()->isAjax()) {
  34. $price = input("price", '');
  35. $json = input("json", "");
  36. $surplus_area_ids = input('surplus_area_ids', '');
  37. $json_data = json_decode($json, true);
  38. $data = $json_data[ '1' ];
  39. $data[ 'price' ] = $price;
  40. $data[ 'site_id' ] = $this->site_id;
  41. $data[ 'surplus_area_ids' ] = $surplus_area_ids;
  42. $model = new FreeshippingModel();
  43. $result = $model->addFreeshipping($data);
  44. return $result;
  45. } else {
  46. // 地区等级设置 将来从配置中查询数据
  47. $area_level = 3;
  48. $this->assign('area_level', $area_level);//地址级别
  49. return $this->fetch("freeshipping/add");
  50. }
  51. }
  52. /**
  53. * 编辑活动
  54. */
  55. public function edit()
  56. {
  57. $model = new FreeshippingModel();
  58. $freeshipping_id = input('freeshipping_id', 0);
  59. if (request()->isAjax()) {
  60. $price = input("price", '');
  61. $json = input("json", "");
  62. $surplus_area_ids = input('surplus_area_ids', '');
  63. $json_data = json_decode($json, true);
  64. $data = $json_data[ '1' ];
  65. $data[ 'price' ] = $price;
  66. $data[ 'site_id' ] = $this->site_id;
  67. $data[ 'surplus_area_ids' ] = $surplus_area_ids;
  68. $data[ 'freeshipping_id' ] = $freeshipping_id;
  69. $result = $model->editFreeshipping($data);
  70. return $result;
  71. } else {
  72. $this->assign('freeshipping_id', $freeshipping_id);
  73. // 地区等级设置 将来从配置中查询数据
  74. $area_level = 3;
  75. $this->assign('area_level', $area_level);//地址级别
  76. $info = $model->getFreeshippingInfo([ [ 'freeshipping_id', '=', $freeshipping_id ], [ 'site_id', '=', $this->site_id ] ])[ 'data' ];
  77. $this->assign('info', $info);
  78. return $this->fetch("freeshipping/edit");
  79. }
  80. }
  81. /*
  82. * 删除
  83. */
  84. public function delete()
  85. {
  86. $freeshipping_id = input('freeshipping_id', '');
  87. $site_id = $this->site_id;
  88. $model = new FreeshippingModel();
  89. return $model->deleteFreeshipping($freeshipping_id, $site_id);
  90. }
  91. }