Membergrade.php 3.7 KB

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