Membergrade.php 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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 Membergrade extends AdminControl
  17. {
  18. public function initialize()
  19. {
  20. parent::initialize();
  21. Lang::load(base_path() . 'admin/lang/'.config('lang.default_lang').'/membergrade.lang.php');
  22. }
  23. public function index() {
  24. if (request()->isPost()) {
  25. $update_arr = array();
  26. if (!empty(input('post.mg/a'))) {
  27. $mg_arr = array();
  28. $i = 1;
  29. $max_exppoints = '-1';#用户判断 下级会员等级积分应大于上级等级积分
  30. foreach (input('post.mg/a') as $k => $v) {
  31. $mg_arr[$i]['level'] = $i;
  32. $level_name = $v['level_name'];
  33. $exppoints = intval($v['exppoints']);
  34. if(empty($level_name)){
  35. $this->error(lang('param_error'));
  36. }
  37. $mg_arr[$i]['level_name'] = $level_name;
  38. //所需经验值
  39. if($max_exppoints>=$exppoints){
  40. $this->error($level_name.lang('exppoints_greater_than').$max_exppoints);
  41. }else{
  42. $mg_arr[$i]['exppoints'] = $exppoints;
  43. }
  44. $max_exppoints = $exppoints;
  45. $i++;
  46. }
  47. $update_arr['member_grade'] = serialize($mg_arr);
  48. } else {
  49. $this->error(lang('ds_common_op_fail'));
  50. }
  51. $result = true;
  52. if ($update_arr) {
  53. $config_model = model('config');
  54. $result = $config_model->editConfig($update_arr);
  55. }
  56. if ($result) {
  57. $this->log(lang('ds_edit') . lang('ds_member_grade'), 1);
  58. $this->success(lang('ds_common_save_succ'));
  59. } else {
  60. $this->log(lang('ds_edit') . lang('ds_member_grade'), 0);
  61. $this->error(lang('ds_common_save_fail'));
  62. }
  63. } else {
  64. $list_config = rkcache('config', true);
  65. $membergrade_list = $list_config['member_grade'] ? unserialize($list_config['member_grade']) : array();
  66. foreach ($membergrade_list as $key => $value) {
  67. $maxlevel[]=$value['level'];
  68. }
  69. View::assign('maxlevel', max($maxlevel)+1);
  70. View::assign('membergrade_list', $membergrade_list);
  71. $this->setAdminCurItem('index');
  72. return View::fetch();
  73. }
  74. }
  75. /**
  76. * 获取卖家栏目列表,针对控制器下的栏目
  77. */
  78. protected function getAdminItemList() {
  79. $menu_array = array(
  80. array(
  81. 'name' => 'index',
  82. 'text' => lang('ds_manage'),
  83. 'url' => (string)url('Membergrade/index')
  84. )
  85. );
  86. return $menu_array;
  87. }
  88. }