From 719fa0e7de817843021ed0f3f58bb448979ef1c1 Mon Sep 17 00:00:00 2001
From: Administrator <15274802129@163.com>
Date: Wed, 07 May 2025 17:44:44 +0800
Subject: [PATCH] feat(mall): 新增会员等级管理功能

---
 src/main/java/cc/mrbird/febs/mall/service/AdminMemberLevelService.java                        |   21 +
 src/main/java/cc/mrbird/febs/mall/mapper/HappyMemberLevelMapper.java                          |    7 
 src/main/java/cc/mrbird/febs/mall/controller/memberLevel/AdminHappyMemberLevelController.java |   90 +++++
 src/main/resources/templates/febs/views/modules/levelView/levelAdd.html                       |  192 ++++++++++++
 src/main/java/cc/mrbird/febs/mall/dto/memberLevel/AdminMemberLevelAddDto.java                 |   23 +
 src/main/java/cc/mrbird/febs/mall/dto/memberLevel/AdminMemberLevelUpdateDto.java              |   22 +
 src/main/resources/templates/febs/views/modules/levelView/levelList.html                      |  199 ++++++++++++
 src/main/java/cc/mrbird/febs/mall/entity/HappyMemberLevel.java                                |   30 +
 src/main/java/cc/mrbird/febs/mall/service/impl/AdminMemberLevelServiceImpl.java               |   71 ++++
 src/main/java/cc/mrbird/febs/mall/controller/memberLevel/ViewHappyMemberLevelController.java  |   64 ++++
 src/main/java/cc/mrbird/febs/mall/dto/memberLevel/AdminMemberLevelDto.java                    |    7 
 src/main/resources/templates/febs/views/modules/levelView/levelInfo.html                      |  215 +++++++++++++
 12 files changed, 941 insertions(+), 0 deletions(-)

diff --git a/src/main/java/cc/mrbird/febs/mall/controller/memberLevel/AdminHappyMemberLevelController.java b/src/main/java/cc/mrbird/febs/mall/controller/memberLevel/AdminHappyMemberLevelController.java
new file mode 100644
index 0000000..baab533
--- /dev/null
+++ b/src/main/java/cc/mrbird/febs/mall/controller/memberLevel/AdminHappyMemberLevelController.java
@@ -0,0 +1,90 @@
+package cc.mrbird.febs.mall.controller.memberLevel;
+
+import cc.mrbird.febs.common.annotation.ControllerEndpoint;
+import cc.mrbird.febs.common.controller.BaseController;
+import cc.mrbird.febs.common.entity.FebsResponse;
+import cc.mrbird.febs.common.entity.QueryRequest;
+import cc.mrbird.febs.common.utils.RedisUtils;
+import cc.mrbird.febs.common.utils.excl.ExcelSheetPO;
+import cc.mrbird.febs.common.utils.excl.ExcelUtil;
+import cc.mrbird.febs.common.utils.excl.ExcelVersion;
+import cc.mrbird.febs.common.utils.excl.ResponseHeadUtil;
+import cc.mrbird.febs.mall.dto.AdminHappyActivityCategoryDto;
+import cc.mrbird.febs.mall.dto.activity.*;
+import cc.mrbird.febs.mall.dto.memberLevel.AdminMemberLevelAddDto;
+import cc.mrbird.febs.mall.dto.memberLevel.AdminMemberLevelDto;
+import cc.mrbird.febs.mall.dto.memberLevel.AdminMemberLevelUpdateDto;
+import cc.mrbird.febs.mall.entity.HappyActivity;
+import cc.mrbird.febs.mall.entity.HappyActivityOption;
+import cc.mrbird.febs.mall.service.AdminMemberLevelService;
+import cc.mrbird.febs.mall.service.IAdminHappyActivityService;
+import cn.hutool.core.date.DateUtil;
+import cn.hutool.core.util.StrUtil;
+import lombok.RequiredArgsConstructor;
+import lombok.SneakyThrows;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletResponse;
+import javax.validation.Valid;
+import javax.validation.constraints.NotNull;
+import java.io.OutputStream;
+import java.net.URLEncoder;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+@Slf4j
+@Validated
+@RestController
+@RequiredArgsConstructor
+@RequestMapping(value = "/admin/level")
+public class AdminHappyMemberLevelController extends BaseController {
+
+    private final AdminMemberLevelService adminMemberLevelService;
+    private final RedisUtils redisUtils;
+
+    /**
+     * 会员等级-列表
+     * @return
+     */
+    @GetMapping("levelList")
+    public FebsResponse levelList(AdminMemberLevelDto dto, QueryRequest request) {
+
+        Map<String, Object> data = getDataTable(adminMemberLevelService.getLevelListInPage(dto, request));
+        return new FebsResponse().success().data(data);
+    }
+    /**
+     * 会员等级-新增
+     */
+    @PostMapping("levelAdd")
+    @ControllerEndpoint(operation = " 会员等级-新增", exceptionMessage = "操作失败")
+    public FebsResponse levelAdd(@RequestBody @Valid AdminMemberLevelAddDto dto) {
+
+        return adminMemberLevelService.levelAdd(dto);
+    }
+
+
+    /**
+     * 会员等级-更新
+     */
+    @PostMapping("levelUpdate")
+    @ControllerEndpoint(operation = "会员等级-更新", exceptionMessage = "操作失败")
+    public FebsResponse levelUpdate(@RequestBody @Valid AdminMemberLevelUpdateDto dto) {
+
+        return adminMemberLevelService.levelUpdate(dto);
+    }
+
+    /**
+     * 会员等级-获取全部
+     * @return
+     */
+    @GetMapping(value = "/levelAll")
+    public FebsResponse levelAll() {
+
+        return adminMemberLevelService.levelAll();
+    }
+
+}
diff --git a/src/main/java/cc/mrbird/febs/mall/controller/memberLevel/ViewHappyMemberLevelController.java b/src/main/java/cc/mrbird/febs/mall/controller/memberLevel/ViewHappyMemberLevelController.java
new file mode 100644
index 0000000..37f6e3e
--- /dev/null
+++ b/src/main/java/cc/mrbird/febs/mall/controller/memberLevel/ViewHappyMemberLevelController.java
@@ -0,0 +1,64 @@
+package cc.mrbird.febs.mall.controller.memberLevel;
+
+import cc.mrbird.febs.common.controller.BaseController;
+import cc.mrbird.febs.common.entity.FebsConstant;
+import cc.mrbird.febs.common.utils.FebsUtil;
+import cc.mrbird.febs.common.utils.RedisUtils;
+import cc.mrbird.febs.mall.entity.HappyActivity;
+import cc.mrbird.febs.mall.entity.HappyActivityCategory;
+import cc.mrbird.febs.mall.entity.HappyActivityOption;
+import cc.mrbird.febs.mall.entity.HappyMemberLevel;
+import cc.mrbird.febs.mall.mapper.HappyActivityCategoryMapper;
+import cc.mrbird.febs.mall.mapper.HappyActivityOptionMapper;
+import cc.mrbird.febs.mall.service.AdminMemberLevelService;
+import cc.mrbird.febs.mall.service.IAdminHappyActivityService;
+import cn.hutool.core.util.StrUtil;
+import lombok.RequiredArgsConstructor;
+import org.apache.shiro.authz.annotation.RequiresPermissions;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+@Controller("levelView")
+@RequestMapping(FebsConstant.VIEW_PREFIX + "modules/levelView")
+@RequiredArgsConstructor
+public class ViewHappyMemberLevelController extends BaseController {
+
+    private final AdminMemberLevelService adminMemberLevelService;
+
+    /**
+     * 会员等级列表
+     */
+    @GetMapping("levelList")
+    @RequiresPermissions("levelList:view")
+    public String levelList() {
+        return FebsUtil.view("modules/levelView/levelList");
+    }
+
+    /**
+     * 会员等级新增
+     * @return
+     */
+    @GetMapping(value = "/levelAdd")
+    @RequiresPermissions("levelAdd:add")
+    public String levelAdd() {
+        return FebsUtil.view("modules/levelView/levelAdd");
+    }
+
+    /**
+     * 会员等级编辑
+     * @param id
+     * @param model
+     * @return
+     */
+    @GetMapping("levelInfo/{id}")
+    @RequiresPermissions("levelInfo:view")
+    public String levelInfo(@PathVariable long id, Model model) {
+        HappyMemberLevel happyMemberLevel = adminMemberLevelService.getBaseMapper().selectById(id);
+        model.addAttribute("happyMemberLevel", happyMemberLevel);
+        return FebsUtil.view("modules/levelView/levelInfo");
+    }
+
+}
diff --git a/src/main/java/cc/mrbird/febs/mall/dto/memberLevel/AdminMemberLevelAddDto.java b/src/main/java/cc/mrbird/febs/mall/dto/memberLevel/AdminMemberLevelAddDto.java
new file mode 100644
index 0000000..079813d
--- /dev/null
+++ b/src/main/java/cc/mrbird/febs/mall/dto/memberLevel/AdminMemberLevelAddDto.java
@@ -0,0 +1,23 @@
+package cc.mrbird.febs.mall.dto.memberLevel;
+
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+@Data
+public class AdminMemberLevelAddDto {
+
+    private String name;
+
+    private Integer code;
+
+    private Integer upgradeScore;
+
+    private BigDecimal minePercent;
+
+    private BigDecimal otherPercent;
+
+    private String content;
+
+    private String iconPng;
+}
diff --git a/src/main/java/cc/mrbird/febs/mall/dto/memberLevel/AdminMemberLevelDto.java b/src/main/java/cc/mrbird/febs/mall/dto/memberLevel/AdminMemberLevelDto.java
new file mode 100644
index 0000000..9865b2f
--- /dev/null
+++ b/src/main/java/cc/mrbird/febs/mall/dto/memberLevel/AdminMemberLevelDto.java
@@ -0,0 +1,7 @@
+package cc.mrbird.febs.mall.dto.memberLevel;
+
+import lombok.Data;
+
+@Data
+public class AdminMemberLevelDto {
+}
diff --git a/src/main/java/cc/mrbird/febs/mall/dto/memberLevel/AdminMemberLevelUpdateDto.java b/src/main/java/cc/mrbird/febs/mall/dto/memberLevel/AdminMemberLevelUpdateDto.java
new file mode 100644
index 0000000..156fd00
--- /dev/null
+++ b/src/main/java/cc/mrbird/febs/mall/dto/memberLevel/AdminMemberLevelUpdateDto.java
@@ -0,0 +1,22 @@
+package cc.mrbird.febs.mall.dto.memberLevel;
+
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+@Data
+public class AdminMemberLevelUpdateDto {
+    private Long id;
+
+    private String name;
+
+    private Integer upgradeScore;
+
+    private BigDecimal minePercent;
+
+    private BigDecimal otherPercent;
+
+    private String content;
+
+    private String iconPng;
+}
diff --git a/src/main/java/cc/mrbird/febs/mall/entity/HappyMemberLevel.java b/src/main/java/cc/mrbird/febs/mall/entity/HappyMemberLevel.java
new file mode 100644
index 0000000..c690652
--- /dev/null
+++ b/src/main/java/cc/mrbird/febs/mall/entity/HappyMemberLevel.java
@@ -0,0 +1,30 @@
+package cc.mrbird.febs.mall.entity;
+
+import cc.mrbird.febs.common.entity.BaseEntity;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+@Data
+@TableName("happy_member_level")
+public class HappyMemberLevel extends BaseEntity {
+    /**
+     *
+     `name` varchar(100) DEFAULT NULL COMMENT '会员等级名称',
+     `code` int(11) DEFAULT NULL COMMENT '等级编码',
+     `upgrade_score` int(11) DEFAULT NULL COMMENT '升级所需积分',
+     `mine_percent` decimal(20,2) DEFAULT NULL COMMENT '自己下单返积分的比例10%为0.1',
+     `other_percent` decimal(20,2) DEFAULT NULL COMMENT '邀请好友下单后返积分比例',
+     `content` text COMMENT '规则说明',
+     `icon_png` varchar(200) DEFAULT NULL COMMENT '会员图标',
+     */
+
+    private String name;
+    private Integer code;
+    private Integer upgradeScore;
+    private BigDecimal minePercent;
+    private BigDecimal otherPercent;
+    private String content;
+    private String iconPng;
+}
diff --git a/src/main/java/cc/mrbird/febs/mall/mapper/HappyMemberLevelMapper.java b/src/main/java/cc/mrbird/febs/mall/mapper/HappyMemberLevelMapper.java
new file mode 100644
index 0000000..a38231c
--- /dev/null
+++ b/src/main/java/cc/mrbird/febs/mall/mapper/HappyMemberLevelMapper.java
@@ -0,0 +1,7 @@
+package cc.mrbird.febs.mall.mapper;
+
+import cc.mrbird.febs.mall.entity.HappyMemberLevel;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+public interface HappyMemberLevelMapper extends BaseMapper<HappyMemberLevel> {
+}
diff --git a/src/main/java/cc/mrbird/febs/mall/service/AdminMemberLevelService.java b/src/main/java/cc/mrbird/febs/mall/service/AdminMemberLevelService.java
new file mode 100644
index 0000000..7b7c83c
--- /dev/null
+++ b/src/main/java/cc/mrbird/febs/mall/service/AdminMemberLevelService.java
@@ -0,0 +1,21 @@
+package cc.mrbird.febs.mall.service;
+
+import cc.mrbird.febs.common.entity.FebsResponse;
+import cc.mrbird.febs.common.entity.QueryRequest;
+import cc.mrbird.febs.mall.dto.memberLevel.AdminMemberLevelAddDto;
+import cc.mrbird.febs.mall.dto.memberLevel.AdminMemberLevelDto;
+import cc.mrbird.febs.mall.dto.memberLevel.AdminMemberLevelUpdateDto;
+import cc.mrbird.febs.mall.entity.HappyMemberLevel;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+public interface AdminMemberLevelService extends IService<HappyMemberLevel> {
+
+    IPage<HappyMemberLevel> getLevelListInPage(AdminMemberLevelDto dto, QueryRequest request);
+
+    FebsResponse levelAdd(AdminMemberLevelAddDto dto);
+
+    FebsResponse levelUpdate(AdminMemberLevelUpdateDto dto);
+
+    FebsResponse levelAll();
+}
diff --git a/src/main/java/cc/mrbird/febs/mall/service/impl/AdminMemberLevelServiceImpl.java b/src/main/java/cc/mrbird/febs/mall/service/impl/AdminMemberLevelServiceImpl.java
new file mode 100644
index 0000000..92be6af
--- /dev/null
+++ b/src/main/java/cc/mrbird/febs/mall/service/impl/AdminMemberLevelServiceImpl.java
@@ -0,0 +1,71 @@
+package cc.mrbird.febs.mall.service.impl;
+
+import cc.mrbird.febs.common.entity.FebsResponse;
+import cc.mrbird.febs.common.entity.QueryRequest;
+import cc.mrbird.febs.common.enumerates.StateUpDownEnum;
+import cc.mrbird.febs.mall.dto.memberLevel.AdminMemberLevelAddDto;
+import cc.mrbird.febs.mall.dto.memberLevel.AdminMemberLevelDto;
+import cc.mrbird.febs.mall.dto.memberLevel.AdminMemberLevelUpdateDto;
+import cc.mrbird.febs.mall.entity.HappyActivityCategory;
+import cc.mrbird.febs.mall.entity.HappyMemberLevel;
+import cc.mrbird.febs.mall.mapper.HappyMemberLevelMapper;
+import cc.mrbird.febs.mall.service.AdminMemberLevelService;
+import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.util.ObjectUtil;
+import cn.hutool.core.util.StrUtil;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.List;
+
+@Slf4j
+@Service
+@RequiredArgsConstructor
+@Transactional
+public class AdminMemberLevelServiceImpl extends ServiceImpl<HappyMemberLevelMapper, HappyMemberLevel> implements AdminMemberLevelService {
+
+    private final HappyMemberLevelMapper happyMemberLevelMapper;
+    @Override
+    public IPage<HappyMemberLevel> getLevelListInPage(AdminMemberLevelDto dto, QueryRequest request) {
+
+        Page<HappyMemberLevel> page = new Page<>(request.getPageNum(), request.getPageSize());
+        LambdaQueryWrapper<HappyMemberLevel> lambdaQueryWrapper = new LambdaQueryWrapper<>();
+        lambdaQueryWrapper.orderByAsc(HappyMemberLevel::getId);
+        Page<HappyMemberLevel>  happyMemberLevelPage = happyMemberLevelMapper.selectPage(page, lambdaQueryWrapper);
+        return happyMemberLevelPage;
+    }
+
+    @Override
+    public FebsResponse levelAdd(AdminMemberLevelAddDto dto) {
+        HappyMemberLevel happyMemberLevel = new HappyMemberLevel();
+        BeanUtil.copyProperties(dto, happyMemberLevel);
+        happyMemberLevelMapper.insert(happyMemberLevel);
+        return new FebsResponse().success().message("操作成功");
+    }
+
+    @Override
+    public FebsResponse levelUpdate(AdminMemberLevelUpdateDto dto) {
+        HappyMemberLevel happyMemberLevel = happyMemberLevelMapper.selectById(dto.getId());
+        if (ObjectUtil.isNotNull(happyMemberLevel)) {
+            BeanUtil.copyProperties(dto, happyMemberLevel);
+            happyMemberLevelMapper.updateById(happyMemberLevel);
+        }
+        return new FebsResponse().success().message("操作成功");
+    }
+
+    @Override
+    public FebsResponse levelAll() {
+        List<HappyMemberLevel> happyMemberLevels = happyMemberLevelMapper.selectList(
+                new LambdaQueryWrapper<HappyMemberLevel>()
+                        .select(HappyMemberLevel::getId, HappyMemberLevel::getName)
+                        .orderByAsc(HappyMemberLevel::getId)
+        );
+        return new FebsResponse().success().data(happyMemberLevels);
+    }
+}
diff --git a/src/main/resources/templates/febs/views/modules/levelView/levelAdd.html b/src/main/resources/templates/febs/views/modules/levelView/levelAdd.html
new file mode 100644
index 0000000..a1b14a6
--- /dev/null
+++ b/src/main/resources/templates/febs/views/modules/levelView/levelAdd.html
@@ -0,0 +1,192 @@
+<div class="layui-fluid layui-anim febs-anim" id="febs-level-add" lay-title="新增">
+    <div class="layui-row febs-container">
+        <div class="layui-col-md12">
+            <div class="layui-fluid" id="member-level-add">
+                <form class="layui-form" action="" lay-filter="member-level-add-form">
+                    <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
+                        <ul class="layui-tab-title">
+                            <li class="layui-this">基础信息</li>
+                        </ul>
+                        <div class="layui-tab-content">
+                            <div class="layui-tab-item layui-show">
+                                <div class="layui-row layui-col-space10 layui-form-item">
+                                    <div class="layui-col-lg6">
+                                        <label class="layui-form-label febs-form-item-require">名称:</label>
+                                        <div class="layui-input-block">
+                                            <input type="text" name="name" lay-verify="required"
+                                                   placeholder="" autocomplete="off" class="layui-input">
+                                        </div>
+                                    </div>
+                                </div>
+                                <div class="layui-row layui-col-space10 layui-form-item">
+                                    <div class="layui-col-lg6">
+                                        <label class="layui-form-label febs-form-item-require">会员图标:</label>
+                                        <div class="layui-input-block">
+                                            <div class="layui-upload">
+                                                <button type="button" class="layui-btn layui-btn-normal layui-btn" id="iconPngUploadButton">上传</button>
+                                                <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;">
+                                                    <div class="layui-upload-list" id="iconPngUpload"></div>
+                                                </blockquote>
+                                            </div>
+                                        </div>
+                                    </div>
+                                </div>
+
+                                <div class="layui-row layui-col-space10 layui-form-item febs-hide">
+                                    <div class="layui-col-lg6">
+                                        <label class="layui-form-label">会员图标链接:</label>
+                                        <div class="layui-input-block">
+                                            <input type="text" id="iconPng" lay-verify="required" name="iconPng" autocomplete="off" class="layui-input" readonly>
+                                        </div>
+                                    </div>
+                                </div>
+                                <div class="layui-form-item">
+                                    <label class="layui-form-label febs-form-item-require">升级:</label>
+                                    <div class="layui-form-mid">积分达到</div>
+                                    <div class="layui-input-inline" style="width: 80px">
+                                        <input type="text" name="upgradeScore" lay-verify="required" autocomplete="off" class="layui-input" >
+                                    </div>
+                                    <div class="layui-form-mid">之后,升级。</div>
+                                </div>
+
+                                <blockquote class="layui-elem-quote blue-border">奖励规则</blockquote>
+                                <div class="layui-form-item">
+                                    <label class="layui-form-label febs-form-item-require">规则一:</label>
+                                    <div class="layui-form-mid">用户下单,点击确认收货后,返还支付金额乘以</div>
+                                    <div class="layui-input-inline" style="width: 80px">
+                                        <input type="text" name="minePercent" lay-verify="required" autocomplete="off" class="layui-input" >
+                                    </div>
+                                    <div class="layui-form-mid">的积分数量。</div>
+                                </div>
+                                <div class="layui-form-item">
+                                    <label class="layui-form-label febs-form-item-require">规则二:</label>
+                                    <div class="layui-form-mid">好友下单,点击确认收货后,返还用户支付金额乘以</div>
+                                    <div class="layui-input-inline" style="width: 80px">
+                                        <input type="text" name="otherPercent" lay-verify="required" autocomplete="off" class="layui-input" >
+                                    </div>
+                                    <div class="layui-form-mid">的积分数量。</div>
+                                </div>
+
+                                <div class="layui-form-item">
+                                    <label class="layui-form-label febs-form-item-require">规则说明:</label>
+                                    <div class="layui-input-block">
+                                        <div style="border: 1px solid #ccc;">
+                                            <div id="memberLevel-toolbar-container" class="toolbar"></div>
+                                            <div id="memberLevel-text-container" class="text" style="height: 450px;"></div>
+                                        </div>
+                                    </div>
+                                </div>
+
+                            </div>
+                        </div>
+                    </div>
+
+                    <div class="layui-form-item febs-hide">
+                        <button class="layui-btn" lay-submit="" lay-filter="member-level-form-submit" id="submit">保存</button>
+                    </div>
+                </form>
+            </div>
+        </div>
+    </div>
+</div>
+<style>
+    .blue-border {
+        border-left-color: #2db7f5;
+        font-size: 18px;
+    }
+    .layui-table-cell {
+        height:auto;
+    }
+</style>
+
+<!-- 表格操作栏 end -->
+<script data-th-inline="javascript">
+    layui.use(['febs', 'form', 'formSelects', 'validate', 'treeSelect', 'eleTree','dropdown', 'laydate', 'layedit', 'upload', 'element', 'table', 'xmSelect','jquery'], function () {
+        var $ = layui.jquery,
+            febs = layui.febs,
+            layer = layui.layer,
+            table = layui.table,
+            formSelects = layui.formSelects,
+            treeSelect = layui.treeSelect,
+            form = layui.form,
+            laydate = layui.laydate,
+            eleTree = layui.eleTree,
+            $view = $('#member-level-add'),
+            layedit = layui.layedit,
+            upload = layui.upload,
+            validate = layui.validate,
+            element = layui.element;
+
+        form.render();
+
+        const E = window.wangEditor;
+        const editor = new E('#memberLevel-toolbar-container', '#memberLevel-text-container'); // 传入两个元素
+        editor.config.showLinkImg = false;
+        editor.config.uploadFileName = 'file';
+        editor.config.customUploadImg = function (files, insertImgFn) {
+            // files 是 input 中选中的文件列表
+            // insertImgFn 是获取图片 url 后,插入到编辑器的方法
+            // 上传图片,返回结果,将图片插入到编辑器中
+            for (let i = 0; i < files.length; i++){
+                var form = new FormData();
+                form.append("file", files[0]);
+                $.ajax({
+                    url:'/admin/goods/uploadFileBase64',
+                    type: "post",
+                    processData: false,
+                    contentType: false,
+                    data: form,
+                    dataType: 'json',
+                    success(res) {
+                        // 上传代码返回结果之后,将图片插入到编辑器中
+                        insertImgFn(res.data.src, res.data.title, '')
+                    }
+                })
+            }
+        };
+        editor.create();
+
+        //图片上传
+        upload.render({
+            elem: '#iconPngUploadButton'
+            ,url: ctx + 'admin/goods/uploadFileBase64' //改成您自己的上传接口
+            ,accept: 'file' //普通文件
+            ,size: 10240 //限制文件大小,单位 KB
+            ,before: function(obj){
+                //预读本地文件示例,不支持ie8
+                obj.preview(function(index, file, result){
+                    $('#iconPngUpload').html('<img src="'+ result +'" alt="'+ file.name +'" class="layui-upload-img single-image" style="width: 130px">')
+                });
+            }
+            ,done: function(res){
+                $("#iconPng").val(res.data.src);
+            }
+        });
+        formSelects.render();
+        form.on('submit(member-level-form-submit)', function (data) {
+            data.field.content = editor.txt.html();
+            $.ajax({
+                'url':ctx + 'admin/level/levelAdd',
+                'type':'post',
+                'dataType':'json',
+                'headers' : {'Content-Type' : 'application/json;charset=utf-8'}, //接口json格式
+                'traditional': true,//ajax传递数组必须添加属性
+                'data':JSON.stringify(data.field),
+                'success':function (data) {
+                    if(data.code==200){
+                        layer.closeAll();
+                        febs.alert.success(data.message);
+                        $('#febs-level').find('#query').click();
+                    }else{
+                        febs.alert.warn(data.message);
+                    }
+                },
+                'error':function () {
+                    febs.alert.warn('服务器繁忙');
+                }
+            })
+            return false;
+        });
+
+    });
+</script>
diff --git a/src/main/resources/templates/febs/views/modules/levelView/levelInfo.html b/src/main/resources/templates/febs/views/modules/levelView/levelInfo.html
new file mode 100644
index 0000000..430cdca
--- /dev/null
+++ b/src/main/resources/templates/febs/views/modules/levelView/levelInfo.html
@@ -0,0 +1,215 @@
+<div class="layui-fluid layui-anim febs-anim" id="febs-level-Info" lay-title="编辑">
+    <div class="layui-row febs-container">
+        <div class="layui-col-md12">
+            <div class="layui-fluid" id="memberLevel-info">
+                <form class="layui-form" action="" lay-filter="memberLevel-info-form">
+                    <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
+                        <ul class="layui-tab-title">
+                            <li class="layui-this">基础信息</li>
+                        </ul>
+                        <div class="layui-tab-content">
+                            <input type="text" name="id"
+                                   placeholder="" autoComplete="off" class="layui-input febs-hide">
+                            <div class="layui-tab-item layui-show">
+                                <div class="layui-row layui-col-space10 layui-form-item">
+                                    <div class="layui-col-lg6">
+                                        <label class="layui-form-label febs-form-item-require">名称:</label>
+                                        <div class="layui-input-block">
+                                            <input type="text" name="name" lay-verify="required"
+                                                   placeholder="" autocomplete="off" class="layui-input">
+                                        </div>
+                                    </div>
+                                </div>
+                                <div class="layui-row layui-col-space10 layui-form-item">
+                                    <div class="layui-col-lg6">
+                                        <label class="layui-form-label febs-form-item-require">会员图标:</label>
+                                        <div class="layui-input-block">
+                                            <div class="layui-upload">
+                                                <button type="button" class="layui-btn layui-btn-normal layui-btn" id="iconPngUploadButton">上传</button>
+                                                <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;">
+                                                    <div class="layui-upload-list" id="iconPngUpload"></div>
+                                                </blockquote>
+                                            </div>
+                                        </div>
+                                    </div>
+                                </div>
+
+                                <div class="layui-row layui-col-space10 layui-form-item febs-hide">
+                                    <div class="layui-col-lg6">
+                                        <label class="layui-form-label">会员图标链接:</label>
+                                        <div class="layui-input-block">
+                                            <input type="text" id="iconPng" lay-verify="required" name="iconPng" autocomplete="off" class="layui-input" readonly>
+                                        </div>
+                                    </div>
+                                </div>
+                                <div class="layui-form-item">
+                                    <label class="layui-form-label febs-form-item-require">升级:</label>
+                                    <div class="layui-form-mid">积分达到</div>
+                                    <div class="layui-input-inline" style="width: 80px">
+                                        <input type="text" name="upgradeScore" lay-verify="required" autocomplete="off" class="layui-input" >
+                                    </div>
+                                    <div class="layui-form-mid">之后,升级。</div>
+                                </div>
+
+                                <blockquote class="layui-elem-quote blue-border">奖励规则</blockquote>
+                                <div class="layui-form-item">
+                                    <label class="layui-form-label febs-form-item-require">规则一:</label>
+                                    <div class="layui-form-mid">用户下单,点击确认收货后,返还支付金额乘以</div>
+                                    <div class="layui-input-inline" style="width: 80px">
+                                        <input type="text" name="minePercent" lay-verify="required" autocomplete="off" class="layui-input" >
+                                    </div>
+                                    <div class="layui-form-mid">的积分数量。</div>
+                                </div>
+                                <div class="layui-form-item">
+                                    <label class="layui-form-label febs-form-item-require">规则二:</label>
+                                    <div class="layui-form-mid">好友下单,点击确认收货后,返还用户支付金额乘以</div>
+                                    <div class="layui-input-inline" style="width: 80px">
+                                        <input type="text" name="otherPercent" lay-verify="required" autocomplete="off" class="layui-input" >
+                                    </div>
+                                    <div class="layui-form-mid">的积分数量。</div>
+                                </div>
+
+                                <div class="layui-form-item">
+                                    <label class="layui-form-label febs-form-item-require">规则说明:</label>
+                                    <div class="layui-input-block">
+                                        <div style="border: 1px solid #ccc;">
+                                            <div id="memberLevel-toolbar-container" class="toolbar"></div>
+                                            <div id="memberLevel-text-container" class="text" style="height: 450px;"></div>
+                                        </div>
+                                    </div>
+                                </div>
+                            </div>
+                        </div>
+                    </div>
+                    <div class="layui-form-item febs-hide">
+                        <button class="layui-btn" lay-submit="" lay-filter="memberLevel-info-form-submit" id="submit">保存</button>
+                    </div>
+                </form>
+            </div>
+        </div>
+    </div>
+</div>
+<style>
+    .blue-border {
+        border-left-color: #2db7f5;
+        font-size: 18px;
+    }
+    .layui-table-cell {
+        height:auto;
+    }
+    .layui-upload-list {
+        margin: 0 !important;
+    }
+    .multi-images {
+        margin: 0 5px !important;
+    }
+</style>
+<!-- 表格操作栏 end -->
+<script data-th-inline="javascript">
+    layui.use(['febs', 'form', 'validate','formSelects', 'table', 'upload'], function () {
+        var $ = layui.jquery,
+            febs = layui.febs,
+            layer = layui.layer,
+            table = layui.table,
+            form = layui.form,
+            formSelects = layui.formSelects,
+            $view = $('#memberLevel-info'),
+            happyMemberLevel = [[${happyMemberLevel}]],
+            upload = layui.upload,
+            validate = layui.validate;
+
+        const E = window.wangEditor;
+        const editor = new E('#memberLevel-toolbar-container', '#memberLevel-text-container'); // 传入两个元素
+        editor.config.showLinkImg = false;
+        editor.config.uploadFileName = 'file';
+        editor.config.customUploadImg = function (files, insertImgFn) {
+            // files 是 input 中选中的文件列表
+            // insertImgFn 是获取图片 url 后,插入到编辑器的方法
+            // 上传图片,返回结果,将图片插入到编辑器中
+            for (let i = 0; i < files.length; i++){
+                var form = new FormData();
+                form.append("file", files[0]);
+                $.ajax({
+                    url:'/admin/goods/uploadFileBase64',
+                    type: "post",
+                    processData: false,
+                    contentType: false,
+                    data: form,
+                    dataType: 'json',
+                    success(res) {
+                        // 上传代码返回结果之后,将图片插入到编辑器中
+                        insertImgFn(res.data.src, res.data.title, '')
+                    }
+                })
+            }
+        };
+        editor.create();
+        //图片上传
+        upload.render({
+            elem: '#iconPngUploadButton'
+            ,url: ctx + 'admin/goods/uploadFileBase64' //改成您自己的上传接口
+            ,accept: 'file' //普通文件
+            ,size: 10240 //限制文件大小,单位 KB
+            ,before: function(obj){
+                //预读本地文件示例,不支持ie8
+                obj.preview(function(index, file, result){
+                    $('#iconPngUpload').html('<img src="'+ result +'" alt="'+ file.name +'" class="layui-upload-img single-image" style="width: 130px">')
+                });
+            }
+            ,done: function(res){
+                $("#iconPng").val(res.data.src);
+            }
+        });
+
+        form.render();
+        inithappyMemberLevel();
+
+        formSelects.render();
+
+        function inithappyMemberLevel() {
+            console.log("happyMemberLevel:", happyMemberLevel); // 调试信息
+            form.val("memberLevel-info-form", {
+                "id": happyMemberLevel.id,
+                "name": happyMemberLevel.name,
+                "upgradeScore": happyMemberLevel.upgradeScore,
+                "minePercent": happyMemberLevel.minePercent,
+                "otherPercent": happyMemberLevel.otherPercent,
+                "otherPercent": happyMemberLevel.otherPercent,
+
+
+            });
+
+
+            $('#iconPngUpload').append('<img src="' + happyMemberLevel.iconPng + '" alt="" class="layui-upload-img single-image" style="width: 130px">');
+            $("#iconPng").val(happyMemberLevel.iconPng);
+            editor.txt.html(happyMemberLevel.content);
+
+        }
+
+        form.on('submit(memberLevel-info-form-submit)', function (data) {
+            data.field.content = editor.txt.html();
+            $.ajax({
+                'url':ctx + 'admin/level/levelUpdate',
+                'type':'post',
+                'dataType':'json',
+                'headers' : {'Content-Type' : 'application/json;charset=utf-8'}, //接口json格式
+                'traditional': true,//ajax传递数组必须添加属性
+                'data':JSON.stringify(data.field),
+                'success':function (data) {
+                    if(data.code==200){
+                        layer.closeAll();
+                        febs.alert.success(data.message);
+                        $('#febs-level').find('#query').click();
+                    }else{
+                        febs.alert.warn(data.message);
+                    }
+                },
+                'error':function () {
+                    febs.alert.warn('服务器繁忙');
+                }
+            })
+            return false;
+        });
+
+    });
+</script>
\ No newline at end of file
diff --git a/src/main/resources/templates/febs/views/modules/levelView/levelList.html b/src/main/resources/templates/febs/views/modules/levelView/levelList.html
new file mode 100644
index 0000000..f5c1f61
--- /dev/null
+++ b/src/main/resources/templates/febs/views/modules/levelView/levelList.html
@@ -0,0 +1,199 @@
+<div class="layui-fluid layui-anim febs-anim" id="febs-level" lay-title="会员级别列表">
+    <div class="layui-row febs-container">
+        <div class="layui-col-md12">
+            <div class="layui-card">
+                <div class="layui-card-body febs-table-full">
+                    <form class="layui-form layui-table-form" lay-filter="memberLevel-table-form">
+                        <div class="layui-row">
+                            <div class="layui-col-md10">
+                                <div class="layui-form-item">
+<!--                                    <div class="layui-inline">-->
+<!--                                        <label class="layui-form-label layui-form-label-sm">标题</label>-->
+<!--                                        <div class="layui-input-inline">-->
+<!--                                            <input type="text" placeholder="标题" name="name" autocomplete="off" class="layui-input">-->
+<!--                                        </div>-->
+<!--                                    </div>-->
+<!--                                    <div class="layui-inline">-->
+<!--                                        <label class="layui-form-label layui-form-label-sm">分类</label>-->
+<!--                                        <div class="layui-input-inline">-->
+<!--                                            <select name="categoryId" class="sc-type">-->
+<!--                                                <option value="">请选择</option>-->
+<!--                                            </select>-->
+<!--                                        </div>-->
+<!--                                    </div>-->
+<!--                                    <div class="layui-inline">-->
+<!--                                        <label class="layui-form-label layui-form-label-sm">状态</label>-->
+<!--                                        <div class="layui-input-inline">-->
+<!--                                            <select name="state">-->
+<!--                                                <option value="">请选择</option>-->
+<!--                                                <option value="0">隐藏</option>-->
+<!--                                                <option value="1">展示</option>-->
+<!--                                            </select>-->
+<!--                                        </div>-->
+<!--                                    </div>-->
+                                </div>
+                            </div>
+                            <div class="layui-col-md2 layui-col-sm12 layui-col-xs12 table-action-area">
+                                <div class="layui-btn layui-btn-sm layui-btn-primary febs-button-blue-plain table-action" id="query">
+                                    <i class="layui-icon">&#xe848;</i>
+                                </div>
+                                <div class="layui-btn layui-btn-sm layui-btn-primary febs-button-green-plain table-action" id="reset">
+                                    <i class="layui-icon">&#xe79b;</i>
+                                </div>
+                            </div>
+                        </div>
+                    </form>
+                    <table lay-filter="memberLevelTable" lay-data="{id: 'memberLevelTable'}"></table>
+                </div>
+            </div>
+        </div>
+    </div>
+</div>
+<!-- 表格操作栏 start -->
+<script type="text/html" id="user-option">
+    <span shiro:lacksPermission="list:view,add:add,votesActivityUpdate:update">
+        <span class="layui-badge-dot febs-bg-orange"></span> 无权限
+    </span>
+    <a lay-event="edit" shiro:hasPermission="votesActivityUpdate:update"><i
+            class="layui-icon febs-edit-area febs-blue">&#xe7a5;</i></a>
+</script>
+
+<script type="text/html" id="memberLevelToolbar">
+    <div class="layui-btn-container">
+        <button class="layui-btn layui-btn-normal layui-btn-sm" type="button" shiro:hasPermission="levelAdd:add" lay-event="levelAdd">新增</button>
+    </div>
+</script>
+
+<script type="text/html" id="memberLevelOption">
+    <button class="layui-btn layui-btn-normal layui-btn-sm" type="button" shiro:hasPermission="levelInfo:view" lay-event="levelInfoEvent">编辑</button>
+</script>
+
+<style>
+    .layui-form-onswitch {
+        background-color: #5FB878 !important;
+    }
+</style>
+<!-- 表格操作栏 end -->
+<script data-th-inline="none" type="text/javascript">
+    // 引入组件并初始化
+    layui.use([ 'jquery', 'form', 'table', 'febs'], function () {
+        var $ = layui.jquery,
+            febs = layui.febs,
+            form = layui.form,
+            table = layui.table,
+            $view = $('#febs-level'),
+            $query = $view.find('#query'),
+            $reset = $view.find('#reset'),
+            $searchForm = $view.find('form'),
+            sortObject = {field: 'phone', type: null},
+            tableIns;
+
+        form.render();
+
+        // 表格初始化
+        initmemberLevelTable();
+
+        // 初始化表格操作栏各个按钮功能
+        table.on('tool(memberLevelTable)', function (obj) {
+            console.log("触发事件:", obj.event); // 调试信息
+            var data = obj.data,
+                layEvent = obj.event;
+
+            if (layEvent === 'seeIconPng') {
+                var t = $view.find('#seeIconPng'+data.id+'');
+                //页面层
+                layer.open({
+                    type: 1,
+                    title: "会员图标",
+                    skin: 'layui-layer-rim', //加上边框
+                    area: ['100%', '100%'], //宽高
+                    shadeClose: true, //开启遮罩关闭
+                    end: function (index, layero) {
+                        return false;
+                    },
+                    content: '<div style="text-align:center"><img src="' + $(t).attr('src') + '" /></div>'
+                });
+            }
+            if (layEvent === 'levelInfoEvent') {
+                febs.modal.open('编辑','modules/levelView/levelInfo/' + data.id, {
+                    btn: ['提交', '取消'],
+                    area: ['100%', '100%'],
+                    yes: function (index, layero) {
+                        $('#febs-level-Info').find('#submit').trigger('click');
+                    },
+                    btn2: function () {
+                        layer.closeAll();
+                    }
+                });
+            }
+        });
+
+        // 初始化表格操作栏各个按钮功能
+        table.on('toolbar(memberLevelTable)', function (obj) {
+            let data = obj.data,
+                layEvent = obj.event;
+            console.log("触发事件:", obj.event); // 调试信息
+            if(layEvent === 'levelAdd'){
+                febs.modal.open('新增', 'modules/levelView/levelAdd/', {
+                    btn: ['提交', '取消'],
+                    area:['100%','100%'],
+                    yes: function (index, layero) {
+                        $('#febs-level-add').find('#submit').trigger('click');
+                    },
+                    btn2: function () {
+                        layer.closeAll();
+                    }
+                });
+            }
+        });
+
+        function initmemberLevelTable() {
+            tableIns = febs.table.init({
+                elem: $view.find('table'),
+                id: 'memberLevelTable',
+                url: ctx + 'admin/level/levelList',
+                toolbar:"#memberLevelToolbar",
+                defaultToolbar:[],
+                cols: [[
+                    {type: 'numbers', title: '', width: 80},
+                    {title: '操作', toolbar: '#memberLevelOption', minWidth: 200, align: 'center'},
+                    {field: 'name', title: '名称', minWidth: 150,align:'center'},
+                    {field: 'indexImg',title: '会员图标',
+                        templet: function (d) {
+                            return '<a lay-event="seeIconPng">' +
+                                '<img id="seeIconPng' + d.id + '" src="' + d.iconPng +
+                                '" alt="图片" style="width: 50px; height: 50px; object-fit: cover; border-radius: 5px; cursor: pointer;">' +
+                                '</a>';
+                        },
+                    minWidth: 150,align: 'center'},
+                    {field: 'upgradeScore', title: '升级需要积分', minWidth: 150,align:'center'},
+                    {field: 'minePercent', title: '自己返还比例', minWidth: 150,align:'center'},
+                    {field: 'otherPercent', title: '好友返还比例', minWidth: 150,align:'center'},
+                ]]
+            });
+        }
+
+
+        // 查询按钮
+        $query.on('click', function () {
+            var params = $.extend(getQueryParams(), {field: sortObject.field, order: sortObject.type});
+            tableIns.reload({where: params, page: {curr: 1}});
+        });
+
+        // 刷新按钮
+        $reset.on('click', function () {
+            $searchForm[0].reset();
+            sortObject.type = 'null';
+            tableIns.reload({where: getQueryParams(), page: {curr: 1}, initSort: sortObject});
+        });
+        // 获取查询参数
+        function getQueryParams() {
+            return {
+                // name: $searchForm.find('input[name="name"]').val().trim(),
+                // state: $searchForm.find("select[name='state']").val(),
+                // categoryId: $searchForm.find("select[name='categoryId']").val(),
+            };
+        }
+
+    })
+</script>

--
Gitblit v1.9.1