Selleraccountgroup.php 6.6 KB

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