Promotionbooth.php 6.1 KB

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