Selleraccountgroup.php 6.9 KB

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