From b67cb476a3de3eb720bc4c295e8fcd9c29825df7 Mon Sep 17 00:00:00 2001
From: Hentua <wangdoubleone@gmail.com>
Date: Tue, 23 Jan 2024 02:07:21 +0800
Subject: [PATCH] fix
---
src/main/resources/mapper/modules/MallVipBenefitsMapper.xml | 6
src/main/resources/templates/febs/views/modules/vip/vipBenefits-edit.html | 57 ++--
src/main/resources/templates/febs/views/modules/vip/vipConfig-list.html | 151 +++++++++++++
src/main/java/cc/mrbird/febs/vip/service/IMallVipBenefitsService.java | 2
src/main/resources/templates/febs/views/modules/vip/vipBenefits-list.html | 18
src/main/resources/templates/febs/views/modules/vip/vipBenefits-add.html | 11
src/main/java/cc/mrbird/febs/vip/controller/AdminMallVipConfigController.java | 15 +
src/main/java/cc/mrbird/febs/vip/entity/MallVipBenefitsDetails.java | 4
src/main/java/cc/mrbird/febs/vip/service/impl/MallVipConfigServiceImpl.java | 9
src/main/java/cc/mrbird/febs/vip/service/IMallVipConfigService.java | 4
src/main/resources/templates/febs/views/modules/vip/vipConfig-add.html | 207 ++++++++++++++++++
src/main/java/cc/mrbird/febs/vip/controller/AdminMallVipBenefitsController.java | 17 +
src/main/java/cc/mrbird/febs/vip/service/impl/MallVipBenefitsServiceImpl.java | 23 ++
src/main/resources/mapper/modules/MallVipConfigMapper.xml | 42 +++
src/main/java/cc/mrbird/febs/vip/mapper/MallVipConfigMapper.java | 3
src/main/java/cc/mrbird/febs/vip/controller/ViewVipConfigController.java | 86 +++++++
16 files changed, 612 insertions(+), 43 deletions(-)
diff --git a/src/main/java/cc/mrbird/febs/vip/controller/AdminMallVipBenefitsController.java b/src/main/java/cc/mrbird/febs/vip/controller/AdminMallVipBenefitsController.java
index 066f916..42e8107 100644
--- a/src/main/java/cc/mrbird/febs/vip/controller/AdminMallVipBenefitsController.java
+++ b/src/main/java/cc/mrbird/febs/vip/controller/AdminMallVipBenefitsController.java
@@ -36,15 +36,24 @@
return new FebsResponse().success().data(mallVipBenefitsService.findVipBenefitsById(id));
}
- @PostMapping("/addBenefits")
- public FebsResponse addBenefits(@RequestBody MallVipBenefits mallVipBenefits) {
- this.mallVipBenefitsService.addVipBenefits(mallVipBenefits);
+ @PostMapping("/addOrEditBenefits")
+ public FebsResponse addOrEditBenefits(@RequestBody MallVipBenefits mallVipBenefits) {
+ if (mallVipBenefits.getId() == null) {
+ this.mallVipBenefitsService.addVipBenefits(mallVipBenefits);
+ } else {
+ this.mallVipBenefitsService.editVipBenefits(mallVipBenefits);
+ }
return new FebsResponse().success();
}
- @GetMapping("/delBenefites/{id}")
+ @GetMapping("/delBenefits/{id}")
public FebsResponse delBenefits(@PathVariable("id") Long id) {
this.mallVipBenefitsService.delVipBenefits(id);
return new FebsResponse().success();
}
+
+ @GetMapping("/findAllBenefits")
+ public FebsResponse findAllBenefits() {
+ return new FebsResponse().success().data(mallVipBenefitsService.list());
+ }
}
diff --git a/src/main/java/cc/mrbird/febs/vip/controller/AdminMallVipConfigController.java b/src/main/java/cc/mrbird/febs/vip/controller/AdminMallVipConfigController.java
index 88a0e99..b2e6bbe 100644
--- a/src/main/java/cc/mrbird/febs/vip/controller/AdminMallVipConfigController.java
+++ b/src/main/java/cc/mrbird/febs/vip/controller/AdminMallVipConfigController.java
@@ -1,8 +1,14 @@
package cc.mrbird.febs.vip.controller;
+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.vip.entity.MallVipConfig;
+import cc.mrbird.febs.vip.service.IMallVipConfigService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@@ -14,5 +20,12 @@
@RestController
@RequiredArgsConstructor
@RequestMapping(value = "/admin/vip/config")
-public class AdminMallVipConfigController {
+public class AdminMallVipConfigController extends BaseController {
+
+ private final IMallVipConfigService mallVipConfigService;
+
+ @GetMapping(value = "/list")
+ public FebsResponse list(QueryRequest request) {
+ return new FebsResponse().success().data(getDataTable(mallVipConfigService.vipConfigList(request)));
+ }
}
diff --git a/src/main/java/cc/mrbird/febs/vip/controller/ViewVipConfigController.java b/src/main/java/cc/mrbird/febs/vip/controller/ViewVipConfigController.java
index a4b0048f..51a0f72 100644
--- a/src/main/java/cc/mrbird/febs/vip/controller/ViewVipConfigController.java
+++ b/src/main/java/cc/mrbird/febs/vip/controller/ViewVipConfigController.java
@@ -2,6 +2,13 @@
import cc.mrbird.febs.common.entity.FebsConstant;
import cc.mrbird.febs.common.utils.FebsUtil;
+import cc.mrbird.febs.mall.entity.MallGoods;
+import cc.mrbird.febs.mall.entity.MallGoodsCoupon;
+import cc.mrbird.febs.mall.mapper.MallGoodsCouponMapper;
+import cc.mrbird.febs.mall.service.IApiMallGoodsService;
+import cc.mrbird.febs.vip.entity.MallVipBenefits;
+import cc.mrbird.febs.vip.service.IMallVipBenefitsService;
+import cn.hutool.core.collection.CollUtil;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
@@ -9,11 +16,19 @@
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
@Controller("mallVipConfig")
@RequestMapping(FebsConstant.VIEW_PREFIX + "modules/vip/config")
@RequiredArgsConstructor
public class ViewVipConfigController {
+ private final IMallVipBenefitsService mallVipBenefitsService;
+ private final IApiMallGoodsService apiMallGoodsService;
+ private final MallGoodsCouponMapper mallGoodsCouponMapper;
@GetMapping(value = "/benefitsList")
public String benefitsList() {
@@ -38,4 +53,75 @@
model.addAttribute("tableIndex", index);
return FebsUtil.view("modules/vip/coupon-select");
}
+
+ @GetMapping("/editBenefits/{id}")
+ public String editBenefits(@PathVariable("id") Long id, Model model) {
+ MallVipBenefits vipBenefits = mallVipBenefitsService.findVipBenefitsById(id);
+
+ List<Long> goodsIds = new ArrayList<>();
+ List<Long> couponIds = new ArrayList<>();
+ vipBenefits.getDetails().forEach(item -> {
+ if (item.getIsClick() == 2) {
+ return;
+ }
+
+ if (item.getLinkType() == 2) {
+ goodsIds.add(Long.parseLong(item.getContent()));
+ }
+
+ if (item.getLinkType() == 3) {
+ couponIds.add(Long.parseLong(item.getContent()));
+ }
+ });
+
+ List<MallGoods> goodsList = new ArrayList<>();
+ if (CollUtil.isNotEmpty(goodsIds)) {
+ goodsList = apiMallGoodsService.listByIds(goodsIds);
+ }
+
+ List<MallGoodsCoupon> coupons = new ArrayList<>();
+ if (CollUtil.isNotEmpty(couponIds)) {
+ coupons = mallGoodsCouponMapper.selectBatchIds(couponIds);
+ }
+
+ Map<Long, MallGoods> goodsMap = goodsList.stream().collect(Collectors.toMap(MallGoods::getId, MallGoods -> MallGoods));
+ Map<Long, MallGoodsCoupon> couponMap = coupons.stream().collect(Collectors.toMap(MallGoodsCoupon::getId, MallGoodsCoupon -> MallGoodsCoupon));
+
+ vipBenefits.getDetails().forEach(item -> {
+ if (item.getIsClick() == 2) {
+ return;
+ }
+
+ if (item.getLinkType() == 2) {
+ MallGoods mallGoods = goodsMap.get(Long.parseLong(item.getContent()));
+ if (mallGoods != null) {
+ item.setContentName(mallGoods.getGoodsName());
+ }
+ }
+
+ if (item.getLinkType() == 3) {
+ MallGoodsCoupon coupon = couponMap.get(Long.parseLong(item.getContent()));
+ if (coupon != null) {
+ item.setContentName(coupon.getName());
+ }
+ }
+ });
+ model.addAttribute("benefitsData", vipBenefits);
+ return FebsUtil.view("modules/vip/vipBenefits-edit");
+ }
+
+ @GetMapping(value = "/levelList")
+ public String levelList() {
+ return FebsUtil.view("modules/vip/vipConfig-list");
+ }
+
+ @GetMapping(value = "/levelAdd")
+ public String levelAdd() {
+ return FebsUtil.view("modules/vip/vipConfig-add");
+ }
+
+ @GetMapping(value = "/levelEdit")
+ public String levelEdit() {
+ return FebsUtil.view("modules/vip/vipLevel-list");
+ }
}
diff --git a/src/main/java/cc/mrbird/febs/vip/entity/MallVipBenefitsDetails.java b/src/main/java/cc/mrbird/febs/vip/entity/MallVipBenefitsDetails.java
index ee933ee..a7832de 100644
--- a/src/main/java/cc/mrbird/febs/vip/entity/MallVipBenefitsDetails.java
+++ b/src/main/java/cc/mrbird/febs/vip/entity/MallVipBenefitsDetails.java
@@ -1,6 +1,7 @@
package cc.mrbird.febs.vip.entity;
import cc.mrbird.febs.common.entity.BaseEntity;
+import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
@@ -37,4 +38,7 @@
* 权益ID
*/
private Long benefitsId;
+
+ @TableField(exist = false)
+ private String contentName;
}
diff --git a/src/main/java/cc/mrbird/febs/vip/mapper/MallVipConfigMapper.java b/src/main/java/cc/mrbird/febs/vip/mapper/MallVipConfigMapper.java
index 4d7d9d6..22865f8 100644
--- a/src/main/java/cc/mrbird/febs/vip/mapper/MallVipConfigMapper.java
+++ b/src/main/java/cc/mrbird/febs/vip/mapper/MallVipConfigMapper.java
@@ -2,6 +2,9 @@
import cc.mrbird.febs.vip.entity.MallVipConfig;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
public interface MallVipConfigMapper extends BaseMapper<MallVipConfig> {
+
+ IPage<MallVipConfig> findVipConfigListInPage(IPage<MallVipConfig> page);
}
diff --git a/src/main/java/cc/mrbird/febs/vip/service/IMallVipBenefitsService.java b/src/main/java/cc/mrbird/febs/vip/service/IMallVipBenefitsService.java
index 7b978b7..5187343 100644
--- a/src/main/java/cc/mrbird/febs/vip/service/IMallVipBenefitsService.java
+++ b/src/main/java/cc/mrbird/febs/vip/service/IMallVipBenefitsService.java
@@ -14,4 +14,6 @@
void addVipBenefits(MallVipBenefits mallVipBenefits);
void delVipBenefits(Long id);
+
+ void editVipBenefits(MallVipBenefits mallVipBenefits);
}
diff --git a/src/main/java/cc/mrbird/febs/vip/service/IMallVipConfigService.java b/src/main/java/cc/mrbird/febs/vip/service/IMallVipConfigService.java
index 5b795c1..6827271 100644
--- a/src/main/java/cc/mrbird/febs/vip/service/IMallVipConfigService.java
+++ b/src/main/java/cc/mrbird/febs/vip/service/IMallVipConfigService.java
@@ -1,7 +1,11 @@
package cc.mrbird.febs.vip.service;
+import cc.mrbird.febs.common.entity.QueryRequest;
import cc.mrbird.febs.vip.entity.MallVipConfig;
+import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
public interface IMallVipConfigService extends IService<MallVipConfig> {
+
+ IPage<MallVipConfig> vipConfigList(QueryRequest request);
}
diff --git a/src/main/java/cc/mrbird/febs/vip/service/impl/MallVipBenefitsServiceImpl.java b/src/main/java/cc/mrbird/febs/vip/service/impl/MallVipBenefitsServiceImpl.java
index b6562dc..07d20cb 100644
--- a/src/main/java/cc/mrbird/febs/vip/service/impl/MallVipBenefitsServiceImpl.java
+++ b/src/main/java/cc/mrbird/febs/vip/service/impl/MallVipBenefitsServiceImpl.java
@@ -18,6 +18,7 @@
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
@Slf4j
@Service
@@ -38,6 +39,7 @@
}
@Override
+ @Transactional
public void addVipBenefits(MallVipBenefits mallVipBenefits) {
if (mallVipBenefits == null) {
return;
@@ -56,6 +58,7 @@
}
@Override
+ @Transactional
public void delVipBenefits(Long id) {
this.baseMapper.deleteById(id);
@@ -64,5 +67,25 @@
this.mallVipBenefitsDetailsService.remove(delQuery);
}
+ @Override
+ @Transactional
+ public void editVipBenefits(MallVipBenefits mallVipBenefits) {
+ if (mallVipBenefits.getId() == null) {
+ throw new FebsException("缺少重要参数");
+ }
+
+ this.baseMapper.updateById(mallVipBenefits);
+
+ LambdaQueryWrapper<MallVipBenefitsDetails> delQuery = new LambdaQueryWrapper<>();
+ delQuery.eq(MallVipBenefitsDetails::getBenefitsId, mallVipBenefits.getId());
+ this.mallVipBenefitsDetailsService.remove(delQuery);
+
+ mallVipBenefits.getDetails().forEach(item -> {
+ item.setBenefitsId(mallVipBenefits.getId());
+ });
+ this.mallVipBenefitsDetailsService.saveBatch(mallVipBenefits.getDetails());
+
+ }
+
}
diff --git a/src/main/java/cc/mrbird/febs/vip/service/impl/MallVipConfigServiceImpl.java b/src/main/java/cc/mrbird/febs/vip/service/impl/MallVipConfigServiceImpl.java
index 93374fc..c694413 100644
--- a/src/main/java/cc/mrbird/febs/vip/service/impl/MallVipConfigServiceImpl.java
+++ b/src/main/java/cc/mrbird/febs/vip/service/impl/MallVipConfigServiceImpl.java
@@ -1,8 +1,11 @@
package cc.mrbird.febs.vip.service.impl;
+import cc.mrbird.febs.common.entity.QueryRequest;
import cc.mrbird.febs.vip.entity.MallVipConfig;
import cc.mrbird.febs.vip.mapper.MallVipConfigMapper;
import cc.mrbird.febs.vip.service.IMallVipConfigService;
+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;
@@ -12,4 +15,10 @@
@Service
@RequiredArgsConstructor
public class MallVipConfigServiceImpl extends ServiceImpl<MallVipConfigMapper, MallVipConfig> implements IMallVipConfigService {
+
+ @Override
+ public IPage<MallVipConfig> vipConfigList(QueryRequest request) {
+ Page<MallVipConfig> page = new Page<>(request.getPageNum(), request.getPageNum());
+ return this.baseMapper.findVipConfigListInPage(page);
+ }
}
diff --git a/src/main/resources/mapper/modules/MallVipBenefitsMapper.xml b/src/main/resources/mapper/modules/MallVipBenefitsMapper.xml
index a2e5d7d..a77bc14 100644
--- a/src/main/resources/mapper/modules/MallVipBenefitsMapper.xml
+++ b/src/main/resources/mapper/modules/MallVipBenefitsMapper.xml
@@ -6,8 +6,9 @@
<id property="id" column="id" />
<result property="name" column="name" />
<result property="type" column="type" />
+ <result property="gainType" column="gain_type" />
<result property="icon" column="icon" />
- <result property="multiple" column="multiple" />
+ <result property="scoreMultiple" column="score_multiple" />
<result property="remark" column="remark" />
<collection property="details" ofType="cc.mrbird.febs.vip.entity.MallVipBenefitsDetails">
@@ -16,6 +17,7 @@
<result property="isClick" column="is_click" />
<result property="linkType" column="link_type" />
<result property="content" column="content" />
+ <result property="benefitsId" column="benefits_id" />
<result property="seq" column="seq" />
</collection>
</resultMap>
@@ -34,7 +36,7 @@
,benefitsDetail.content
,benefitsDetail.seq
from mall_vip_benefits benefits
- inner join mall_vip_benefits_details benefitsDetail on benefits.id=benefitsDetail.benefitsId
+ inner join mall_vip_benefits_details benefitsDetail on benefits.id=benefitsDetail.benefits_id
where benefits.id=#{id}
</select>
</mapper>
\ No newline at end of file
diff --git a/src/main/resources/mapper/modules/MallVipConfigMapper.xml b/src/main/resources/mapper/modules/MallVipConfigMapper.xml
new file mode 100644
index 0000000..9a059ba
--- /dev/null
+++ b/src/main/resources/mapper/modules/MallVipConfigMapper.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="cc.mrbird.febs.vip.mapper.MallVipConfigMapper">
+
+ <resultMap id="VipBenefitsMap" type="cc.mrbird.febs.vip.entity.MallVipConfig">
+<!-- <id property="id" column="id" />-->
+<!-- <result property="name" column="name" />-->
+<!-- <result property="type" column="type" />-->
+<!-- <result property="gainType" column="gain_type" />-->
+<!-- <result property="icon" column="icon" />-->
+<!-- <result property="scoreMultiple" column="score_multiple" />-->
+<!-- <result property="remark" column="remark" />-->
+
+<!-- <collection property="details" ofType="cc.mrbird.febs.vip.entity.MallVipBenefitsDetails">-->
+<!-- <id property="id" column="c_id" />-->
+<!-- <result property="image" column="image" />-->
+<!-- <result property="isClick" column="is_click" />-->
+<!-- <result property="linkType" column="link_type" />-->
+<!-- <result property="content" column="content" />-->
+<!-- <result property="benefitsId" column="benefits_id" />-->
+<!-- <result property="seq" column="seq" />-->
+<!-- </collection>-->
+ </resultMap>
+
+ <select id="findVipConfigListInPage" resultType="cc.mrbird.febs.vip.entity.MallVipBenefits">
+ select * from mall_vip_config
+ </select>
+
+ <select id="selectVipBenefitsById" resultMap="VipBenefitsMap">
+ select
+ benefits.*,
+ benefitsDetail.id c_id
+ ,benefitsDetail.image
+ ,benefitsDetail.is_click
+ ,benefitsDetail.link_type
+ ,benefitsDetail.content
+ ,benefitsDetail.seq
+ from mall_vip_benefits benefits
+ inner join mall_vip_benefits_details benefitsDetail on benefits.id=benefitsDetail.benefits_id
+ where benefits.id=#{id}
+ </select>
+</mapper>
\ No newline at end of file
diff --git a/src/main/resources/templates/febs/views/modules/vip/vipBenefits-add.html b/src/main/resources/templates/febs/views/modules/vip/vipBenefits-add.html
index acbf76e..b1cb41b 100644
--- a/src/main/resources/templates/febs/views/modules/vip/vipBenefits-add.html
+++ b/src/main/resources/templates/febs/views/modules/vip/vipBenefits-add.html
@@ -286,6 +286,7 @@
$(".linkContent").each(function(index, elem) {
var dataIndex = $(this).attr('data-index');
var $this = $(this);
+ $(this).off('blur')
$(this).on('blur', function() {
var data = $this.val();
hasData[dataIndex - 1].content = data;
@@ -300,6 +301,7 @@
$(".goodsSelect").each(function(index, elem) {
var dataIndex = $(this).attr('data-index');
+ $(this).off('click')
$(this).on('click', function() {
febs.modal.open('选择商品', 'modules/vip/config/goodsSelect/' + dataIndex, {
btn: ['提交', '取消'],
@@ -317,6 +319,8 @@
function listenerCouponSelect() {
$(".couponSelect").each(function(index, elem) {
var dataIndex = $(this).attr('data-index');
+
+ $(this).off('click')
$(this).on('click', function() {
febs.modal.open('选择优惠券', 'modules/vip/config/couponSelect/' + dataIndex, {
btn: ['提交', '取消'],
@@ -341,7 +345,10 @@
var data = {};
- data.linkType = linkTypeVal;
+
+ if (isClickVal == 1) {
+ data.linkType = linkTypeVal;
+ }
data.isClick = isClickVal;
addTableDate(data);
@@ -400,7 +407,7 @@
form.on('submit(vipBenefits-add-form-submit)', function (data) {
data.field.details = tableBenefitsItemsData;
$.ajax({
- 'url':ctx + 'admin/vip/benefits/addBenefits',
+ 'url':ctx + 'admin/vip/benefits/addOrEditBenefits',
'type':'post',
'dataType':'json',
'headers' : {'Content-Type' : 'application/json;charset=utf-8'}, //接口json格式
diff --git a/src/main/resources/templates/febs/views/modules/vip/vipBenefits-edit.html b/src/main/resources/templates/febs/views/modules/vip/vipBenefits-edit.html
index 2ed2b2e..2330e99 100644
--- a/src/main/resources/templates/febs/views/modules/vip/vipBenefits-edit.html
+++ b/src/main/resources/templates/febs/views/modules/vip/vipBenefits-edit.html
@@ -141,10 +141,6 @@
<input type="text" id="awardImage{{d.index}}" name="awardImage{{d.index}}" autocomplete="off" value="{{d.image}}" class="layui-input febs-hide">
</div>
</script>
-
-<!--<script type="text/html" id="seqInput">-->
-<!-- <input type="text" name="seq" autocomplete="off" class="layui-input">-->
-<!--</script>-->
<!-- 表格操作栏 end -->
<script data-th-inline="javascript">
layui.use(['febs', 'form', 'formSelects', 'validate', 'treeSelect', 'eleTree','dropdown', 'laydate', 'layedit', 'upload', 'element', 'table', 'xmSelect'], function () {
@@ -164,25 +160,9 @@
benefitsData = [[${benefitsData}]],
element = layui.element;
+ var tableBenefitsItemsData=[];
form.render();
formSelects.render();
-
- function initValue() {
- form.val("goods-detail-form", {
- "id": benefitsData.id,
- "goodsNo": mailGoodsDetail.name,
- "categoryId": mailGoodsDetail.categoryId,
- "mailGoodsSkuDetailVo": mailGoodsDetail.mailGoodsSkuDetailVo,
- "unit": mailGoodsDetail.unit,
- "originalPrice": mailGoodsDetail.originalPrice,
- "presentPrice": mailGoodsDetail.presentPrice,
- "goodsIntrodution": mailGoodsDetail.goodsIntrodution,
- "thumb": mailGoodsDetail.thumb,
- "goodsDetails": mailGoodsDetail.goodsDetails,
- "isHot": mailGoodsDetail.isHot,
- "goodsName": mailGoodsDetail.goodsName
- });
- }
//图片上传
upload.render({
@@ -194,7 +174,6 @@
}
});
- var tableBenefitsItemsData=[];
var tableIns = table.render({
elem: '#benefitsDetailsItem'
,limit:999
@@ -310,6 +289,7 @@
$(".linkContent").each(function(index, elem) {
var dataIndex = $(this).attr('data-index');
var $this = $(this);
+ $(this).off('blur')
$(this).on('blur', function() {
var data = $this.val();
hasData[dataIndex - 1].content = data;
@@ -324,6 +304,7 @@
$(".goodsSelect").each(function(index, elem) {
var dataIndex = $(this).attr('data-index');
+ $(this).off('click')
$(this).on('click', function() {
febs.modal.open('选择商品', 'modules/vip/config/goodsSelect/' + dataIndex, {
btn: ['提交', '取消'],
@@ -341,6 +322,7 @@
function listenerCouponSelect() {
$(".couponSelect").each(function(index, elem) {
var dataIndex = $(this).attr('data-index');
+ $(this).off('click')
$(this).on('click', function() {
febs.modal.open('选择优惠券', 'modules/vip/config/couponSelect/' + dataIndex, {
btn: ['提交', '取消'],
@@ -365,7 +347,9 @@
var data = {};
- data.linkType = linkTypeVal;
+ if (isClickVal == 1) {
+ data.linkType = linkTypeVal;
+ }
data.isClick = isClickVal;
addTableDate(data);
@@ -424,7 +408,7 @@
form.on('submit(vipBenefits-edit-form-submit)', function (data) {
data.field.details = tableBenefitsItemsData;
$.ajax({
- 'url':ctx + 'admin/vip/benefits/addBenefits',
+ 'url':ctx + 'admin/vip/benefits/addOrEditBenefits',
'type':'post',
'dataType':'json',
'headers' : {'Content-Type' : 'application/json;charset=utf-8'}, //接口json格式
@@ -477,7 +461,6 @@
}
tableBenefitsItemsData = hasData;
- console.log(tableBenefitsItemsData)
$(".couponSelect").each(function(index, elem) {
var dataIndex = $(this).attr('data-index');
if (dataIndex == tableIndex) {
@@ -487,6 +470,30 @@
});
}
+ initValue();
+ function initValue() {
+ form.val("vipBenefits-edit-form", {
+ "id": benefitsData.id,
+ "name": benefitsData.name,
+ "gainType": benefitsData.gainType,
+ "type": benefitsData.type,
+ "scoreMultiple": benefitsData.scoreMultiple,
+ "remark": benefitsData.remark,
+ "icon":benefitsData.icon,
+ });
+
+ $('#demo2').attr('src', benefitsData.icon);
+
+ var details = benefitsData.details;
+ for(var i = 0; i < details.length; i++) {
+ details[i].index = i + 1;
+ }
+ reloadTable(details);
+
+
+ tableBenefitsItemsData = details;
+ }
+
});
</script>
diff --git a/src/main/resources/templates/febs/views/modules/vip/vipBenefits-list.html b/src/main/resources/templates/febs/views/modules/vip/vipBenefits-list.html
index a4b3f90..1265c40 100644
--- a/src/main/resources/templates/febs/views/modules/vip/vipBenefits-list.html
+++ b/src/main/resources/templates/febs/views/modules/vip/vipBenefits-list.html
@@ -65,26 +65,26 @@
table.on('tool(vipBenefitsTable)', function (obj) {
var data = obj.data,
layEvent = obj.event;
- if (layEvent === 'newsInfoUpdate') {
- febs.modal.open('编辑', 'modules/news/newsInfoUpdate/' + data.id, {
+ if (layEvent === 'benefitsUpdate') {
+ febs.modal.open('编辑', 'modules/vip/config/editBenefits/' + data.id, {
btn: ['提交', '取消'],
yes: function (index, layero) {
- $('#newsInfo-update').find('#submit').trigger('click');
+ $('#febs-vipBenefits-edit').find('#submit').trigger('click');
},
btn2: function () {
layer.closeAll();
}
});
}
- if (layEvent === 'delNewsInfo') {
+ if (layEvent === 'delBenefits') {
febs.modal.confirm('删除', '确认删除?', function () {
- delNewsInfo(data.id);
+ delBenefits(data.id);
});
}
});
- function delNewsInfo(id) {
- febs.get(ctx + 'admin/news/delNewsInfo/' + id, null, function () {
+ function delBenefits(id) {
+ febs.get(ctx + 'admin/vip/benefits/delBenefits/' + id, null, function () {
febs.alert.success('操作成功');
$query.click();
});
@@ -133,8 +133,8 @@
{
title: '操作',
templet: function (d) {
- return '<button class="layui-btn layui-btn-normal layui-btn-xs" lay-event="newsInfoUpdate" shiro:hasPermission="user:update">编辑</button>'
- + '<button class="layui-btn layui-btn-danger layui-btn-xs" lay-event="delNewsInfo" shiro:hasPermission="user:update">删除</button>'
+ return '<button class="layui-btn layui-btn-normal layui-btn-xs" lay-event="benefitsUpdate" shiro:hasPermission="user:update">编辑</button>'
+ + '<button class="layui-btn layui-btn-danger layui-btn-xs" lay-event="delBenefits" shiro:hasPermission="user:update">删除</button>'
}, minWidth: 300, align: 'center'
}
]]
diff --git a/src/main/resources/templates/febs/views/modules/vip/vipConfig-add.html b/src/main/resources/templates/febs/views/modules/vip/vipConfig-add.html
new file mode 100644
index 0000000..9b04a5c
--- /dev/null
+++ b/src/main/resources/templates/febs/views/modules/vip/vipConfig-add.html
@@ -0,0 +1,207 @@
+<style>
+ #vipConfig-add {
+ padding: 20px 25px 25px 0;
+ }
+
+ #vipConfig-add .layui-treeSelect .ztree li a, .ztree li span {
+ margin: 0 0 2px 3px !important;
+ }
+ #vipConfig-add #data-permission-tree-block {
+ border: 1px solid #eee;
+ border-radius: 2px;
+ padding: 3px 0;
+ }
+ #vipConfig-add .layui-treeSelect .ztree li span.button.switch {
+ top: 1px;
+ left: 3px;
+ }
+ #vipConfig-add img{
+ max-width:100px
+ }
+
+</style>
+<div class="layui-fluid" id="febs-vipConfig-add">
+ <form class="layui-form" action="" lay-filter="vipConfig-add-form">
+ <div class="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" autocomplete="off" class="layui-input" >
+ </div>
+ </div>
+
+ <div class="layui-col-lg6">
+ <label class="layui-form-label febs-form-item-require">会员等级:</label>
+ <div class="layui-input-block">
+ <input type="number" name="level" lay-verify="required" autocomplete="off" class="layui-input" >
+ </div>
+ </div>
+ </div>
+
+ <div class="layui-form-item">
+ <label class="layui-form-label">主图:</label>
+ <div class="layui-input-block">
+ <button type="button" class="layui-btn" id="imageUpload" style="background-color: #009688; margin-bottom: 2px">图片上传</button>
+ <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;">
+ <div class=" layui-upload-list view-images" id="thumbImage">
+ </div>
+ </blockquote>
+ <div class="febs-hide">
+ <input type="text" id="thumb" name="thumb" autocomplete="off" class="layui-input" readonly>
+ </div>
+ </div>
+ </div>
+
+ <div class="layui-form-item">
+ <div class="layui-col-lg4">
+ <label class="layui-form-label febs-form-item-require">有效期:</label>
+ <div class="layui-input-block">
+ <input type="number" name="validTime" lay-verify="required" autocomplete="off" class="layui-input" >
+ </div>
+ </div>
+ <div class="layui-col-lg2">
+ <select name="validType" class="valid-type" lay-filter="valid-type-select">
+ <option value="day">日</option>
+ <option value="month">月</option>
+ <option value="year">年</option>
+ </select>
+ </div>
+ </div>
+
+ <div id="layui-form-item">
+ <div class="layui-col-lg6">
+ <label class="layui-form-label febs-form-item-require">成为会员条件:</label>
+ <div class="layui-input-block">
+ <select name="type" class="valid-type" lay-filter="type-select">
+ <option value="1">指定商品</option>
+ <option value="2">时间区间内消费金额</option>
+ </select>
+ </div>
+ </div>
+
+ <div class="layui-col-lg6" id="targetGoods">
+ <label class="layui-form-label febs-form-item-require">指定商品:</label>
+ <div class="layui-input-block">
+ <input type="text" name="targetName" placeholder="点击选择商品" autocomplete="off" class="layui-input" >
+ <input type="text" name="targetId" placeholder="点击选择商品" autocomplete="off" class="layui-input febs-hide" >
+ </div>
+ </div>
+
+ <div class="layui-col-lg6 febs-hide" id="targetShopping">
+ <div class="layui-input-inline">
+ <input type="text" name="times" autocomplete="off" class="layui-input" >
+ </div>
+ <div class="layui-form-mid">月内,消费</div>
+ <div class="layui-input-inline">
+ <input type="text" name="times" autocomplete="off" class="layui-input" >
+ </div>
+ <div class="layui-form-mid">金额</div>
+ </div>
+ </div>
+
+ <div class="layui-form-item">
+ <label class="layui-form-label febs-form-item-require">选择会员权益:</label>
+ <div class="layui-input-block">
+ <select name="benefitsIds" class="vip-benefits-list" id="vip-benefits-list">
+ <option value="">请选择</option>
+ </select>
+ </div>
+ </div>
+
+ <div class="layui-form-item febs-hide">
+ <button class="layui-btn" lay-submit="" lay-filter="vipConfig-add-form-submit" id="submit"></button>
+ </div>
+ </form>
+</div>
+
+<script data-th-inline="javascript">
+ layui.use(['febs', 'form', 'formSelects', 'validate', 'treeSelect', 'eleTree','layedit', 'laydate', 'upload'], function () {
+ var $ = layui.$,
+ febs = layui.febs,
+ layer = layui.layer,
+ upload = layui.upload,
+ formSelects = layui.formSelects,
+ form = layui.form,
+ laydate = layui.laydate,
+ layedit = layui.layedit,
+ $view = $('#vipConfig-add'),
+ validate = layui.validate;
+
+ //(下拉框)
+ $.get(ctx + 'admin/vip/benefits/findAllBenefits', function (data) {
+ var arr = data.data;
+ for (let i = 0; i < arr.length; i++) {
+ $(".vip-benefits-list").append("<option value='" + arr[i].id + "'>" + arr[i].name + "</option>");
+ }
+ layui.use('form', function () {
+ var form = layui.form;
+ form.render();
+ });
+ });
+
+ form.render();
+
+ formSelects.render();
+ form.on('submit(vipConfig-add-form-submit)', function (data) {
+ febs.post(ctx + 'admin/news/addNewsInfo', data.field, function () {
+ layer.closeAll();
+ febs.alert.success('操作成功');
+ $('#febs-newInfo').find('#reset').click();
+ });
+ return false;
+ });
+
+ form.on('select(type-select)', function(data) {
+ if (data.value == 1) {
+ $("#targetGoods").show();
+ $("#targetShopping").hide();
+ } else {
+ $("#targetGoods").hide();
+ $("#targetShopping").show();
+ }
+ })
+
+ upload.render({
+ elem: '#imageUpload'
+ ,url: ctx + 'admin/goods/uploadFileBase64' //改成您自己的上传接口
+ ,multiple: false
+ ,before: function(obj){
+ //预读本地文件示例,不支持ie8
+ obj.preview(function(index, file, result){
+ $('#thumbImage').html('<img src="'+ result +'" alt="'+ file.name +'" class="layui-upload-img" style="width: 100px">')
+ });
+ }
+ ,done: function(res){
+ $("#thumb").val(res.data.src);
+ }
+ });
+
+
+ bindUpload();
+ function bindUpload() {
+ upload.render({
+ elem: '.upload'
+ ,url: ctx + 'admin/goods/uploadFileBase64' //改成您自己的上传接口
+ ,accept: 'file'
+ ,before: function(obj){
+ layer.msg('上传中', {icon: 16, time: 0});
+ }
+ ,done: function(res){
+ var item = this.item;
+ //如果上传失败
+ if(res.code !== 0){
+ return layer.msg('上传失败');
+ }
+
+ // $(item).parent().prev().find('input').val(res.data[0]);
+ $("#videoUrl").val(res.data.src);
+ layer.msg('上传完毕', {icon: 1});
+ }
+ ,error: function(err){
+ return layer.msg('上传失败');
+ }
+ });
+ }
+ });
+</script>
\ No newline at end of file
diff --git a/src/main/resources/templates/febs/views/modules/vip/vipConfig-list.html b/src/main/resources/templates/febs/views/modules/vip/vipConfig-list.html
new file mode 100644
index 0000000..9c73002
--- /dev/null
+++ b/src/main/resources/templates/febs/views/modules/vip/vipConfig-list.html
@@ -0,0 +1,151 @@
+<div class="layui-fluid layui-anim febs-anim" id="febs-vip-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="vip-benefits-level-table-form">
+ <div class="layui-row">
+ <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-green-plain table-action" id="add">
+ 新增
+ </div>
+ <div class="layui-btn layui-btn-sm layui-btn-primary febs-button-blue-plain table-action" id="query">
+ <i class="layui-icon"></i>
+ </div>
+ <div class="layui-btn layui-btn-sm layui-btn-primary febs-button-green-plain table-action" id="reset">
+ <i class="layui-icon"></i>
+ </div>
+ </div>
+ </div>
+ </form>
+ <table lay-filter="vipBenefitsLevelTable" lay-data="{id: 'vipBenefitsLevelTable'}"></table>
+ </div>
+ </div>
+ </div>
+ </div>
+</div>
+<style>
+ .layui-table-cell {
+ height: auto;
+ }
+ .layui-form-onswitch {
+ background-color: #5FB878 !important;
+ }
+</style>
+<!-- 表格操作栏 start -->
+<script type="text/html" id="user-option">
+ <span shiro:lacksPermission="vipConfig:view,vipConfig:update,vipConfig:delete">
+ <span class="layui-badge-dot febs-bg-orange"></span> 无权限
+ </span>
+ <a lay-event="edit" shiro:hasPermission="vipConfig:update"><i
+ class="layui-icon febs-edit-area febs-blue"></i></a>
+</script>
+<!-- 表格操作栏 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-vip-level'),
+ $query = $view.find('#query'),
+ $add = $view.find('#add'),
+ $reset = $view.find('#reset'),
+ $searchForm = $view.find('form'),
+ sortObject = {field: 'phone', type: null},
+ tableIns;
+
+ form.render();
+
+ // 表格初始化
+ initTable();
+
+ // 初始化表格操作栏各个按钮功能
+ table.on('tool(vipBenefitsLevelTable)', function (obj) {
+ var data = obj.data,
+ layEvent = obj.event;
+ if (layEvent === 'benefitsUpdate') {
+ febs.modal.open('编辑', 'modules/vip/config/editBenefits/' + data.id, {
+ btn: ['提交', '取消'],
+ yes: function (index, layero) {
+ $('#febs-vipConfig-edit').find('#submit').trigger('click');
+ },
+ btn2: function () {
+ layer.closeAll();
+ }
+ });
+ }
+ if (layEvent === 'delBenefits') {
+ febs.modal.confirm('删除', '确认删除?', function () {
+ delBenefits(data.id);
+ });
+ }
+ });
+
+ function delBenefits(id) {
+ febs.get(ctx + 'admin/vip/benefits/delBenefits/' + id, null, function () {
+ febs.alert.success('操作成功');
+ $query.click();
+ });
+ }
+
+ // 查询按钮
+ $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});
+ });
+
+ $add.on('click', function () {
+ febs.modal.open('新增', 'modules/vip/config/levelAdd/', {
+ btn: ['提交', '取消'],
+ yes: function (index, layero) {
+ $('#febs-vipConfig-add').find('#submit').trigger('click');
+ },
+ btn2: function () {
+ layer.closeAll();
+ }
+ });
+ });
+
+ function initTable() {
+ tableIns = febs.table.init({
+ elem: $view.find('table'),
+ id: 'vipBenefitsLevelTable',
+ url: ctx + 'admin/vip/config/list',
+ cols: [[
+ {field: 'name', title: '会员名称', minWidth: 120, align: 'center'},
+ {
+ field: 'icon', title: '主图',
+ templet: function (d) {
+ return '';
+ }, minWidth: 150, align: 'center'
+ },
+ {field: 'level', title: '等级', minWidth: 120, align: 'center'},
+ {field: 'validType', title: '有效类型', minWidth: 120, align: 'center'},
+ {field: 'type', title: '成为会员条件', minWidth: 120, align: 'center'},
+ {
+ title: '操作',
+ templet: function (d) {
+ return '<button class="layui-btn layui-btn-normal layui-btn-xs" lay-event="benefitsUpdate" shiro:hasPermission="user:update">编辑</button>'
+ + '<button class="layui-btn layui-btn-danger layui-btn-xs" lay-event="delBenefits" shiro:hasPermission="user:update">删除</button>'
+ }, minWidth: 300, align: 'center'
+ }
+ ]]
+ });
+ }
+
+ // 获取查询参数
+ function getQueryParams() {
+ return {
+ };
+ }
+ })
+</script>
\ No newline at end of file
--
Gitblit v1.9.1