Promotionbooth.php 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. <?php
  2. namespace app\admin\controller;
  3. use think\facade\View;
  4. use think\facade\Lang;
  5. /**
  6. * ============================================================================
  7. *
  8. * ============================================================================
  9. * 版权所有 2014-2028 浙江惠利玛产业互联网有限公司,并保留所有权利。
  10. * 网站地址: https://www.valimart.net/
  11. * ----------------------------------------------------------------------------
  12. *
  13. * ============================================================================
  14. * 控制器
  15. */
  16. class Promotionbooth extends AdminControl {
  17. public function initialize() {
  18. parent::initialize(); // TODO: Change the autogenerated stub
  19. Lang::load(base_path() . 'admin/lang/'.config('lang.default_lang').'/promotionbooth.lang.php');
  20. }
  21. public function index() {
  22. //自动开启优惠套装
  23. if (intval(input('param.promotion_allow')) === 1) {
  24. $config_model = model('config');
  25. $update_array = array();
  26. $update_array['promotion_allow'] = 1;
  27. $config_model->editConfig($update_array);
  28. }
  29. /**
  30. * 处理商品分类
  31. */
  32. $gcid = intval(input('param.choose_gcid'));
  33. $choose_gcid = $gcid > 0 ? $gcid : 0;
  34. $gccache_arr = model('goodsclass')->getGoodsclassCache($choose_gcid, 3);
  35. View::assign('gc_json', json_encode($gccache_arr['showclass']));
  36. View::assign('gc_choose_json', json_encode($gccache_arr['choose_gcid']));
  37. $pbooth_model = model('pbooth');
  38. $where = array();
  39. if (intval(input('param.choose_gcid')) > 0) {
  40. $where=$pbooth_model->_getRecursiveClass($where,intval(input('param.choose_gcid')));
  41. }
  42. $goods_list = $pbooth_model->getBoothgoodsList($where, 'goods_id', 10);
  43. if (!empty($goods_list)) {
  44. $goodsid_array = array();
  45. foreach ($goods_list as $val) {
  46. $goodsid_array[] = $val['goods_id'];
  47. }
  48. $goods_list = model('goods')->getGoodsList(array(array('goods_id','in', $goodsid_array)));
  49. }
  50. View::assign('gc_list', model('goodsclass')->getGoodsclassForCacheModel());
  51. View::assign('goods_list', $goods_list);
  52. View::assign('show_page', $pbooth_model->page_info->render());
  53. $this->setAdminCurItem('index');
  54. // 输出自营店铺IDS
  55. View::assign('flippedOwnShopIds', array_flip(model('store')->getOwnShopIds()));
  56. return View::fetch();
  57. }
  58. /**
  59. * 套餐列表
  60. */
  61. public function booth_quota() {
  62. $pbooth_model = model('pbooth');
  63. $where = array();
  64. if (input('param.store_name') != '') {
  65. $where[]=array('store_name','like', '%' . trim(input('param.store_name')) . '%');
  66. }
  67. $booth_list = $pbooth_model->getBoothquotaList($where, '*', 10);
  68. // 状态数组
  69. $state_array = array(0 => lang('ds_close'), 1 => lang('ds_open'));
  70. View::assign('state_array', $state_array);
  71. $this->setAdminCurItem('booth_quota');
  72. View::assign('booth_list', $booth_list);
  73. View::assign('show_page', $pbooth_model->page_info->render());
  74. return View::fetch();
  75. }
  76. /**
  77. * 删除推荐商品
  78. */
  79. public function del_goods() {
  80. $where = array();
  81. $goods_id = input('param.goods_id');
  82. $goods_id_array = ds_delete_param($goods_id);
  83. if ($goods_id_array == FALSE) {
  84. ds_json_encode('10001', lang('param_error'));
  85. }
  86. $where[]=array('goods_id','in', $goods_id_array);
  87. $rs = model('pbooth')->delBoothgoods($where);
  88. if ($rs) {
  89. ds_json_encode(10000, lang('ds_common_del_succ'));
  90. } else {
  91. ds_json_encode(10001, lang('ds_common_del_fail'));
  92. }
  93. }
  94. /**
  95. * 设置
  96. */
  97. public function booth_setting() {
  98. // 实例化模型
  99. $config_model = model('config');
  100. if (request()->isPost()) {
  101. // 验证
  102. $data = [
  103. 'promotion_booth_price' => input('post.promotion_booth_price'),
  104. 'promotion_booth_goods_sum' => input('post.promotion_booth_goods_sum'),
  105. ];
  106. $promotionbooth_validate = ds_validate('promotionbooth');
  107. if (!$promotionbooth_validate->scene('booth_setting')->check($data)){
  108. $this->error($promotionbooth_validate->getError());
  109. }
  110. $data['promotion_booth_price'] = intval(input('post.promotion_booth_price'));
  111. $data['promotion_booth_goods_sum'] = intval(input('post.promotion_booth_goods_sum'));
  112. $return = $config_model->editConfig($data);
  113. if ($return) {
  114. $this->log(lang('ds_set') . ' 推荐展位');
  115. dsLayerOpenSuccess(lang('ds_common_op_succ'));
  116. } else {
  117. $this->error(lang('ds_common_op_fail'));
  118. }
  119. } else {
  120. // 查询setting列表
  121. $setting = rkcache('config', true);
  122. View::assign('setting', $setting);
  123. return View::fetch();
  124. }
  125. }
  126. protected function getAdminItemList() {
  127. $menu_array = array(
  128. array(
  129. 'name' => 'index',
  130. 'text' => lang('goods_list'),
  131. 'url' => (string)url('Promotionbooth/index')
  132. ), array(
  133. 'name' => 'booth_quota',
  134. 'text' => lang('booth_list'),
  135. 'url' => (string)url('Promotionbooth/booth_quota')
  136. ), array(
  137. 'name' => 'booth_setting',
  138. 'text' => lang('ds_setting'),
  139. 'url' => "javascript:dsLayerOpen('" . (string)url('Promotionbooth/booth_setting') . "','".lang('ds_setting')."')"
  140. ),
  141. );
  142. return $menu_array;
  143. }
  144. }