Selleraccountgroup.php 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. <?php
  2. namespace app\home\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 Selleraccountgroup extends BaseSeller {
  18. public function initialize() {
  19. parent::initialize();
  20. Lang::load(base_path() . 'home/lang/'.config('lang.default_lang').'/selleraccount.lang.php');
  21. }
  22. public function group_list() {
  23. $sellergroup_model = model('sellergroup');
  24. $seller_group_list = $sellergroup_model->getSellergroupList(array('store_id' => session('store_id')));
  25. View::assign('seller_group_list', $seller_group_list);
  26. /* 设置卖家当前菜单 */
  27. $this->setSellerCurMenu('selleraccountgroup');
  28. /* 设置卖家当前栏目 */
  29. $this->setSellerCurItem('group_list');
  30. return View::fetch($this->template_dir.'group_list');
  31. }
  32. public function group_add() {
  33. $seller_group_info = array(
  34. 'sellergroup_id' => 0,
  35. 'sellergroup_name' => '',
  36. 'sellergroup_limits' => '',
  37. 'smt_limits' => ''
  38. );
  39. View::assign('group_info', $seller_group_info);
  40. View::assign('group_limits', explode(',', $seller_group_info['sellergroup_limits']));
  41. View::assign('smt_limits', explode(',', $seller_group_info['smt_limits']));
  42. // 店铺消息模板列表
  43. $smt_list = model('storemsgtpl')->getStoremsgtplList(array(), 'storemt_code,storemt_name');
  44. View::assign('smt_list', $smt_list);
  45. /* 设置卖家当前菜单 */
  46. $this->setSellerCurMenu('selleraccountgroup');
  47. /* 设置卖家当前栏目 */
  48. $this->setSellerCurItem('group_add');
  49. return View::fetch($this->template_dir.'group_add');
  50. }
  51. public function group_edit() {
  52. $group_id = intval(input('param.group_id'));
  53. if ($group_id <= 0) {
  54. $this->error(lang('param_error'));
  55. }
  56. $sellergroup_model = model('sellergroup');
  57. $seller_group_info = $sellergroup_model->getSellergroupInfo(array('sellergroup_id' => $group_id, 'store_id' => session('store_id')));
  58. if (empty($seller_group_info)) {
  59. $this->error(lang('there_no_group'));
  60. }
  61. View::assign('group_info', $seller_group_info);
  62. View::assign('group_limits', explode('|', $seller_group_info['sellergroup_limits']));
  63. View::assign('smt_limits', explode(',', $seller_group_info['smt_limits']));
  64. // 店铺消息模板列表
  65. $smt_list = model('storemsgtpl')->getStoremsgtplList(array(), 'storemt_code,storemt_name');
  66. View::assign('smt_list', $smt_list);
  67. /* 设置卖家当前菜单 */
  68. $this->setSellerCurMenu('selleraccountgroup');
  69. /* 设置卖家当前栏目 */
  70. $this->setSellerCurItem('group_edit');
  71. return View::fetch($this->template_dir.'group_add');
  72. }
  73. public function group_save() {
  74. $seller_info = array();
  75. $group_id = intval(input('param.group_id'));
  76. $seller_info['sellergroup_name'] = input('post.seller_group_name');
  77. $seller_info['sellergroup_limits'] = implode('|', input('post.limits/a'));
  78. $seller_info['smt_limits'] = empty(input('post.smt_limits/a')) ? '' : implode(',', input('post.smt_limits/a'));
  79. $seller_info['store_id'] = session('store_id');
  80. $sellergroup_model = model('sellergroup');
  81. if (empty($group_id)) {
  82. $result = $sellergroup_model->addSellergroup($seller_info);
  83. $this->recordSellerlog(lang('add_group_successfully') . $result);
  84. if($result){
  85. ds_json_encode(10001,lang('add_success'));
  86. }else{
  87. ds_json_encode(10001,lang('add_failure'));
  88. }
  89. } else {
  90. $condition = array();
  91. $condition[] = array('sellergroup_id','=',$group_id);
  92. $condition[] = array('store_id','=',session('store_id'));
  93. $result = $sellergroup_model->editSellergroup($seller_info, $condition);
  94. $this->recordSellerlog(lang('editorial_team_succeeds') . $group_id);
  95. if($result){
  96. ds_json_encode(10000,lang('edit_success'));
  97. }else{
  98. ds_json_encode(10001,lang('edit_failure'));
  99. }
  100. }
  101. }
  102. public function group_del() {
  103. $group_id = intval(input('param.group_id'));
  104. if ($group_id > 0) {
  105. //判断当前用户组下是否有用户
  106. $condition = array();
  107. $condition[] = array('seller.store_id','=',session('store_id'));
  108. $condition[] = array('seller.sellergroup_id','=',$group_id);
  109. $seller_list = model('seller')->getSellerList($condition);
  110. if(!empty($seller_list)){
  111. ds_json_encode(10001,lang('please_change_account_group'));
  112. }
  113. $condition = array();
  114. $condition[] = array('sellergroup_id','=',$group_id);
  115. $condition[] = array('store_id','=',session('store_id'));
  116. $sellergroup_model = model('sellergroup');
  117. $result = $sellergroup_model->delSellergroup($condition);
  118. if ($result) {
  119. $this->recordSellerlog(lang('group_deleted_successfully') . $group_id);
  120. ds_json_encode(10000,lang('ds_common_op_succ'));
  121. } else {
  122. $this->recordSellerlog(lang('deletion_group_failed') . $group_id);
  123. ds_json_encode(10001,lang('ds_common_save_fail'));
  124. }
  125. } else {
  126. ds_json_encode(10001,lang('param_error'));
  127. }
  128. }
  129. /**
  130. * 栏目菜单
  131. */
  132. function getSellerItemList() {
  133. $menu_array[] = array(
  134. 'name' => 'group_list',
  135. 'text' => lang('group_list'),
  136. 'url' => (string)url('Selleraccountgroup/group_list'),
  137. );
  138. if (request()->action() === 'group_add') {
  139. $menu_array[] = array(
  140. 'name' => 'group_add',
  141. 'text' => lang('add_group'),
  142. 'url' => (string)url('Selleraccountgroup/group_add'),
  143. );
  144. }
  145. if (request()->action() === 'group_edit') {
  146. $menu_array[] = array(
  147. 'name' => 'group_edit',
  148. 'text' => lang('editorial_team'),
  149. 'url' => 'javascript:void(0)',
  150. );
  151. }
  152. return $menu_array;
  153. }
  154. }