This commit is contained in:
cun-nan 2024-09-05 14:37:36 +08:00
parent e5e0fa1fbd
commit c9ab6b7f3f
7 changed files with 259 additions and 93 deletions

View File

@ -79,7 +79,7 @@ export function editPriceRule(data) {
// 删除活动规则 // 删除活动规则
export function deletePriceRule(id) { export function deletePriceRule(id) {
return request({ return request({
url: '/business/activePriceRule/del'+id, url: '/business/activePriceRule/del/'+id,
method: 'delete', method: 'delete',
}) })
} }

View File

@ -101,7 +101,7 @@
<div class="gang"></div> <div class="gang"></div>
<div class="g-title">活动规则</div> <div class="g-title">活动规则</div>
</div> </div>
<el-button type="primary" @click="showDialogVisible =! showDialogVisible">新增活动规则</el-button> <el-button type="primary" @click="addActiveRule">新增活动规则</el-button>
</div> </div>
<el-table <el-table
:data="ruleList" :data="ruleList"
@ -115,7 +115,7 @@
</el-table-column> </el-table-column>
<el-table-column <el-table-column
align="center" align="center"
prop="activeId" prop="activeTitle"
label="分时优惠名称" label="分时优惠名称"
> >
</el-table-column> </el-table-column>
@ -127,7 +127,7 @@
</el-table-column> </el-table-column>
<el-table-column <el-table-column
align="center" align="center"
prop="levelId" prop="levelText"
label="会员等级" label="会员等级"
> >
</el-table-column> </el-table-column>
@ -139,7 +139,7 @@
</el-table-column> </el-table-column>
<el-table-column <el-table-column
align="center" align="center"
prop="babelIds" prop="labelText"
label="会员标签" label="会员标签"
> >
</el-table-column> </el-table-column>
@ -173,12 +173,12 @@
<template slot-scope="scope"> <template slot-scope="scope">
<span v-if="scope.row.status==0" style="color:#FF9655;">未生效</span> <span v-if="scope.row.status==0" style="color:#FF9655;">未生效</span>
<span v-if="scope.row.status==1" style="color:#409EFF;">使用中</span> <span v-if="scope.row.status==1" style="color:#409EFF;">使用中</span>
<span v-if="scope.row.status==2" style="color:#F44522;"></span> <span v-if="scope.row.status==2" style="color:#F44522;"></span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column
align="center" align="center"
prop="createBy" prop="createName"
label="创建人" label="创建人"
> >
</el-table-column> </el-table-column>
@ -194,13 +194,14 @@
<el-button <el-button
size="mini" size="mini"
type="text" type="text"
@click="showDialogVisible =! showDialogVisible" @click="editRule(scope.row)"
>修改 >修改
</el-button> </el-button>
<el-button <el-button
size="mini" size="mini"
type="text" type="text"
@click="deleteRule(scope.row)"
>删除 >删除
</el-button> </el-button>
</template> </template>
@ -210,8 +211,7 @@
<el-dialog <el-dialog
title="新增/修改分时优惠" title="新增/修改分时优惠"
:visible.sync="centerDialogVisible" :visible.sync="centerDialogVisible"
width="48%" width="48%">
center>
<el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="120px" class="demo-ruleForm"> <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="120px" class="demo-ruleForm">
<el-form-item label="分时优惠名称" prop="title"> <el-form-item label="分时优惠名称" prop="title">
<el-input v-model="ruleForm.title" style="width: 217px"></el-input> <el-input v-model="ruleForm.title" style="width: 217px"></el-input>
@ -295,19 +295,21 @@
<el-dialog <el-dialog
title="新增/修改活动规则" title="新增/修改活动规则"
:visible.sync="showDialogVisible" :visible.sync="showDialogVisible"
width="60%" width="60%">
center> <el-form :model="ruleForm1" :rules="rules" ref="ruleForm1" label-width="120px" class="demo-ruleForm">
<el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="120px" class="demo-ruleForm"> <div style="display: flex;width: 100%;margin: 20px 0;">
<div style="display: flex;width: 100%"> <div style="width: 50%">
<div style="width: 40%"> <el-form-item label="分时优惠名称" prop="activeId">
<el-form-item label="分时优惠名称" prop="region"> <el-select v-model="ruleForm1.activeId" placeholder="请选择优惠名称">
<el-select v-model="ruleForm.region" placeholder="请选择优惠名称"> <el-option
<el-option label="区域一" value="shanghai"></el-option> v-for="(item,index) in timeShareList"
<el-option label="区域二" value="beijing"></el-option> :key="index"
:label="item.title"
:value="item.id"></el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="可使用支付方式" prop="type"> <el-form-item label="可使用支付方式" prop="paymentType">
<el-checkbox-group v-model="ruleForm.paymentType"> <el-checkbox-group v-model="ruleForm1.paymentType">
<el-checkbox <el-checkbox
v-for="dict in dict.type.payment_type" v-for="dict in dict.type.payment_type"
v-if="dict.value!='APPLET_CODE'" v-if="dict.value!='APPLET_CODE'"
@ -316,8 +318,8 @@
:value="dict.value"></el-checkbox> :value="dict.value"></el-checkbox>
</el-checkbox-group> </el-checkbox-group>
</el-form-item> </el-form-item>
<el-form-item label=" 会员标签" prop="region"> <el-form-item label=" 会员标签" prop="babelIds">
<el-select v-model="ruleForm.region" placeholder="请选择会员标签"> <el-select v-model="ruleForm1.babelIds" multiple placeholder="请选择会员标签">
<el-option <el-option
v-for="item in userLabelList" v-for="item in userLabelList"
:key="item.id+''" :key="item.id+''"
@ -327,47 +329,47 @@
</el-form-item> </el-form-item>
<el-form-item label="适用实收金额" required> <el-form-item label="适用实收金额" required>
<el-col :span="11"> <el-col :span="11">
<el-form-item prop="name"> <el-form-item prop="moneyMin">
<el-input v-model="ruleForm.name"></el-input> <el-input v-model="ruleForm1.moneyMin"></el-input>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="2"> <el-col :span="2">
<div style="margin-left: 5px"></div> <div style="margin-left: 5px"></div>
</el-col> </el-col>
<el-col :span="11"> <el-col :span="11">
<el-form-item prop="name"> <el-form-item prop="moneyMax">
<el-input v-model="ruleForm.name"></el-input> <el-input v-model="ruleForm1.moneyMax"></el-input>
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-form-item> </el-form-item>
<el-form-item label="适用加油升数" required> <el-form-item label="适用加油升数" required>
<el-col :span="11"> <el-col :span="11">
<el-form-item prop="name"> <el-form-item prop="literMin">
<el-input v-model="ruleForm.name"></el-input> <el-input v-model="ruleForm1.literMin"></el-input>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="2"> <el-col :span="2">
<div style="margin-left: 5px"></div> <div style="margin-left: 5px"></div>
</el-col> </el-col>
<el-col :span="11"> <el-col :span="11">
<el-form-item prop="name"> <el-form-item prop="literMax">
<el-input v-model="ruleForm.name"></el-input> <el-input v-model="ruleForm1.literMax"></el-input>
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-form-item> </el-form-item>
<el-form-item label="最大优惠金额" prop="name"> <el-form-item label="最大优惠金额" prop="disMax">
<el-input v-model="ruleForm.name"></el-input> <el-input v-model="ruleForm1.disMax"></el-input>
</el-form-item> </el-form-item>
<el-form-item label="每人每日参与限制" label-width="140px" prop="name"> <el-form-item label="每人每日参与限制" label-width="140px" prop="dayLimitNum">
<el-input v-model="ruleForm.name"></el-input> <el-input v-model="ruleForm1.dayLimitNum"></el-input>
</el-form-item> </el-form-item>
</div> </div>
<div style="width: 60%"> <div style="width:50%">
<el-form-item label="活动规则名称" prop="name"> <el-form-item label="活动规则名称" prop="ruleName">
<el-input v-model="ruleForm.name"></el-input> <el-input v-model="ruleForm1.ruleName"></el-input>
</el-form-item> </el-form-item>
<el-form-item label="适用会员等级" prop="region"> <el-form-item label="适用会员等级" prop="levelId">
<el-select v-model="ruleForm.levelId" clearable placeholder="请选择会员等级"> <el-select v-model="ruleForm1.levelId" clearable placeholder="请选择会员等级">
<el-option <el-option
v-for="(item,index) in userGradeList" v-for="(item,index) in userGradeList"
:label="item.name" :label="item.name"
@ -376,12 +378,23 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="生效时间" required> <el-form-item label="生效时间" required>
<el-col :span="11">
<el-form-item prop="date1"> <el-form-item prop="activeStartTime">
<el-date-picker type="date" placeholder="选择日期" v-model="ruleForm.date1" <el-date-picker type="date" placeholder="选择日期" v-model="ruleForm1.activeStartTime"
style="width: 100%;"></el-date-picker> style="width: 100%"
></el-date-picker>
</el-form-item> </el-form-item>
</el-col>
<el-col :span="1">
<div style="margin-left: 5px"></div>
</el-col>
<el-col :span="11">
<el-form-item prop="activeEndTime">
<el-date-picker type="date" placeholder="选择日期" v-model="ruleForm1.activeEndTime"
style="width: 100%"
></el-date-picker>
</el-form-item>
</el-col>
</el-form-item> </el-form-item>
@ -418,31 +431,33 @@
<div style="margin-top: 20px"> <div style="margin-top: 20px">
<el-form-item label="时间段" prop="timeApplyStart"> <el-form-item label="时间段" prop="timeApplyStart">
<el-time-picker <el-time-picker
v-model="ruleForm.timeApplyStart" v-model="ruleForm1.dayStartTime"
format="HH:mm" format="HH:mm"
value-format="HH:mm" value-format="HH:mm"
style="width: 45%"
placeholder="请选择开始时间点"> placeholder="请选择开始时间点">
</el-time-picker> </el-time-picker>
<el-time-picker <el-time-picker
v-model="ruleForm.timeApplyEnd" v-model="ruleForm1.dayEndTime"
format="HH:mm" format="HH:mm"
value-format="HH:mm" value-format="HH:mm"
style="width: 45%"
placeholder="请选择结束时间点"> placeholder="请选择结束时间点">
</el-time-picker> </el-time-picker>
</el-form-item> </el-form-item>
</div> </div>
</el-form-item> </el-form-item>
<el-form-item label="每人累计参与限制" label-width="140px" prop="name"> <el-form-item label="每人累计参与限制" label-width="140px" prop="limitNum">
<el-input v-model="ruleForm.name"></el-input> <el-input v-model="ruleForm1.limitNum"></el-input>
</el-form-item> </el-form-item>
</div> </div>
</div> </div>
<!-- --> <!-- -->
<el-form-item> <el-form-item style="text-align: center">
<el-button>取消</el-button> <el-button @click="showDialogVisible = !showDialogVisible">取消</el-button>
<el-button type="primary">保存</el-button> <el-button type="primary" @click="submitRuleForm()">保存</el-button>
</el-form-item> </el-form-item>
</el-form> </el-form>
@ -457,7 +472,7 @@ import {
getID, getID,
updateActivePrice, updateActivePrice,
deleteList, deleteList,
getPriceRuleList getPriceRuleList, addPriceRule, editPriceRule, getPriceRule, deletePriceRule
} from "./api/separate"; } from "./api/separate";
import {oilNumberList1} from "@/api/order/oilnumgun"; import {oilNumberList1} from "@/api/order/oilnumgun";
import {listUserGrade} from "@/api/staff/user/usergrade"; import {listUserGrade} from "@/api/staff/user/usergrade";
@ -510,22 +525,110 @@ export default {
weekDay: [], weekDay: [],
monthDay: [], monthDay: [],
userLabelList: [], userLabelList: [],
userGradeList:[] userGradeList: [],
timeShareList: [],
ruleForm1: {
activeType: 1,
timeType: 0,
paymentType: []
}
} }
}, },
created() { created() {
this.getList() this.getList()
this.getRuleList() this.getRuleList()
this.listUserGrade()
this.getUserLabelList()
}, },
methods: { methods: {
//
resetRule(){
this.ruleForm1 = {
activeType: 1,
timeType: 0,
paymentType: []
}
this.tindex3 = 0
this.weekDay = []
this.monthDay = []
},
//
deleteRule(data){
deletePriceRule(data.id).then(res => {
this.$message.success("删除成功")
this.getRuleList()
})
},
//
editRule(data) {
this.resetRule()
getPriceRule(data.id).then(res => {
this.getTimeShareList()
this.listUserGrade()
this.getUserLabelList()
this.showDialogVisible = true
if (res.data){
this.ruleForm1 = res.data
if (res.data.paymentType) this.ruleForm1.paymentType = res.data.paymentType.split(",")
if (res.data.babelIds) this.ruleForm1.babelIds = res.data.babelIds.split(",")
if (res.data.timeSlots){
if (res.data.timeType == "0") {
this.weekDay = this.ruleForm1.timeSlots.split(",")
} else if (this.ruleForm1.timeType == "1") {
this.monthDay = this.ruleForm1.timeSlots.split(",")
}
}
}
})
},
//
submitRuleForm() {
this.$refs["ruleForm1"].validate((valid) => {
if (valid) {
if (this.ruleForm1.paymentType) this.ruleForm1.paymentType = this.ruleForm1.paymentType.toString()
if (this.ruleForm1.babelIds) this.ruleForm1.babelIds = this.ruleForm1.babelIds.toString()
if (this.ruleForm1.timeType == "0") {
this.ruleForm1.timeSlots = this.weekDay.toString()
} else if (this.ruleForm1.timeType == "1") {
this.ruleForm1.timeSlots = this.monthDay.toString()
}
if (this.ruleForm1.id) {
editPriceRule(this.ruleForm1).then(res => {
this.$message.success("修改成功")
this.getRuleList()
this.showDialogVisible = false
})
} else {
addPriceRule(this.ruleForm1).then(res => {
this.$message.success("添加成功")
this.getRuleList()
this.showDialogVisible = false
})
}
}
})
},
//
addActiveRule() {
this.resetRule()
this.getTimeShareList()
this.listUserGrade()
this.getUserLabelList()
this.showDialogVisible = true
},
//
getTimeShareList() {
getRequestList({pageNo: 1, pageSize: 10000}).then(res => {
this.timeShareList = res.data.records
})
},
// //
listUserGrade() { listUserGrade() {
listUserGrade({page: 1, pageSize: 1000}).then(res => { listUserGrade({page: 1, pageSize: 1000}).then(res => {
if (res.code == 200) { if (res.code == 200) {
this.userGradeList = res.data.records this.userGradeList = res.data.records
console.log(this.userGradeList)
} }
}) })
}, },
@ -537,7 +640,7 @@ export default {
}, },
Typeindex3(index) { Typeindex3(index) {
this.tindex3 = index this.tindex3 = index
this.ruleForm.timeType = index this.ruleForm1.timeType = index
this.weekDay = [] this.weekDay = []
this.monthDay = [] this.monthDay = []
}, },
@ -730,6 +833,7 @@ export default {
font-size: 14px; font-size: 14px;
color: #333333; color: #333333;
} }
.d-s { .d-s {
display: flex; display: flex;
align-items: center; align-items: center;

View File

@ -80,10 +80,10 @@ public class ActivePriceRuleController extends BaseController {
* @param saveVO ActivePriceRuleSaveVO实体 * @param saveVO ActivePriceRuleSaveVO实体
* @return com.fuint.framework.web.ResponseObject * @return com.fuint.framework.web.ResponseObject
**/ **/
@PostMapping("/update") @PutMapping("/update")
public ResponseObject update(@RequestBody ActivePriceRuleSaveVO saveVO) { public ResponseObject update(@RequestBody ActivePriceRuleSaveVO saveVO) {
try { try {
activePriceRuleService.saveActivePriceRule(true, saveVO); activePriceRuleService.saveActivePriceRule(false, saveVO);
} catch (BusinessCheckException businessCheckException) { } catch (BusinessCheckException businessCheckException) {
return getFailureResult(businessCheckException.getMessage()); return getFailureResult(businessCheckException.getMessage());
} }

View File

@ -37,8 +37,10 @@ public class ActivePriceRule extends Model<ActivePriceRule> {
/** 会员标签ids多个以英文逗号隔开 */ /** 会员标签ids多个以英文逗号隔开 */
private String babelIds ; private String babelIds ;
/** 生效起始时间 */ /** 生效起始时间 */
@JsonFormat(pattern = "yyyy-MM-dd" , timezone = "GMT+8")
private Date activeStartTime ; private Date activeStartTime ;
/** 生效截止时间 */ /** 生效截止时间 */
@JsonFormat(pattern = "yyyy-MM-dd" , timezone = "GMT+8")
private Date activeEndTime ; private Date activeEndTime ;
/** 适用实收金额下限 */ /** 适用实收金额下限 */
private Double moneyMin ; private Double moneyMin ;
@ -62,7 +64,7 @@ public class ActivePriceRule extends Model<ActivePriceRule> {
private Integer dayLimitNum ; private Integer dayLimitNum ;
/** 每人累计参与限制次数 */ /** 每人累计参与限制次数 */
private Integer limitNum ; private Integer limitNum ;
/** 状态0未生效1使用中2已效 */ /** 状态0未生效1使用中2已效 */
private String status ; private String status ;
/** 创建人 */ /** 创建人 */
private String createBy ; private String createBy ;

View File

@ -14,13 +14,15 @@
ofType="com.fuint.business.userManager.entity.UserLabel"/> ofType="com.fuint.business.userManager.entity.UserLabel"/>
</resultMap> </resultMap>
<select id="pageActivePriceRule" resultMap="ActivePriceRuleMap"> <select id="pageActivePriceRule" resultType="com.fuint.business.marketingActivity.activePrice.vo.ActivePriceRuleRespVO">
SELECT SELECT
main.*, main.*,
ap.title AS activeTitle ap.title AS activeTitle,
ta.real_name createName
FROM FROM
active_price_rule main active_price_rule main
LEFT JOIN active_price ap ON main.active_id = ap.id LEFT JOIN active_price ap ON main.active_id = ap.id
LEFT JOIN t_account ta on main.create_by = ta.acct_id
<where> <where>
<if test="entity.chainStorId != null and entity.chainStorId != ''"> <if test="entity.chainStorId != null and entity.chainStorId != ''">
AND main.chain_stor_id = #{entity.chainStorId} AND main.chain_stor_id = #{entity.chainStorId}
@ -48,13 +50,13 @@
</foreach> </foreach>
</select> </select>
<select id="getRuleById" <select id="getRuleById"
resultMap="ActivePriceRuleMap"> resultType="com.fuint.business.marketingActivity.activePrice.vo.ActivePriceRuleRespVO">
SELECT SELECT
main.*, main.*,ap.active_type,
ap.title AS activeTitle ap.title AS activeTitle
FROM FROM
active_price_rule main active_price_rule main
LEFT JOIN active_price ap ON main.active_id = ap.id LEFT JOIN active_price ap ON main.active_id = ap.id
where id = #{id} where main.id = #{id}
</select> </select>
</mapper> </mapper>

View File

@ -1,5 +1,6 @@
package com.fuint.business.marketingActivity.activePrice.service.impl; package com.fuint.business.marketingActivity.activePrice.service.impl;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@ -11,7 +12,10 @@ import com.fuint.business.marketingActivity.activePrice.util.ActPriceUtil;
import com.fuint.business.marketingActivity.activePrice.vo.ActivePriceRuleReqVO; import com.fuint.business.marketingActivity.activePrice.vo.ActivePriceRuleReqVO;
import com.fuint.business.marketingActivity.activePrice.vo.ActivePriceRuleRespVO; import com.fuint.business.marketingActivity.activePrice.vo.ActivePriceRuleRespVO;
import com.fuint.business.marketingActivity.activePrice.vo.ActivePriceRuleSaveVO; import com.fuint.business.marketingActivity.activePrice.vo.ActivePriceRuleSaveVO;
import com.fuint.business.userManager.entity.LJUserGrade;
import com.fuint.business.userManager.entity.UserLabel; import com.fuint.business.userManager.entity.UserLabel;
import com.fuint.business.userManager.service.LJUserGradeService;
import com.fuint.business.userManager.service.UserLabelService;
import com.fuint.common.dto.AccountInfo; import com.fuint.common.dto.AccountInfo;
import com.fuint.common.util.StringUtils; import com.fuint.common.util.StringUtils;
import com.fuint.common.util.TokenUtil; import com.fuint.common.util.TokenUtil;
@ -19,10 +23,13 @@ import com.fuint.framework.exception.BusinessCheckException;
import com.fuint.quartz.util.BeanUtils; import com.fuint.quartz.util.BeanUtils;
import com.fuint.repository.model.MtUserGrade; import com.fuint.repository.model.MtUserGrade;
import com.fuint.utils.StringUtil; import com.fuint.utils.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static com.fuint.business.marketingActivity.activePrice.entity.ActivePrice.*; import static com.fuint.business.marketingActivity.activePrice.entity.ActivePrice.*;
@ -43,6 +50,10 @@ public class ActivePriceRuleServiceImpl extends ServiceImpl<ActivePriceRuleMappe
private ActivePriceRuleMapper activePriceRuleMapper; private ActivePriceRuleMapper activePriceRuleMapper;
@Resource @Resource
private ActPriceUtil actPriceUtil; private ActPriceUtil actPriceUtil;
@Autowired
private LJUserGradeService userGradeService;
@Autowired
private UserLabelService userLabelService;
/** /**
* 分页查询活动规则分时优惠/限时特价通用接口 * 分页查询活动规则分时优惠/限时特价通用接口
@ -59,13 +70,38 @@ public class ActivePriceRuleServiceImpl extends ServiceImpl<ActivePriceRuleMappe
actPriceRuleReq.setStoreId(nowAccountInfo.getStoreId()); actPriceRuleReq.setStoreId(nowAccountInfo.getStoreId());
/*1、列表数据查询返回结构中带有会员等级集合和会员标签集合*/ /*1、列表数据查询返回结构中带有会员等级集合和会员标签集合*/
IPage<ActivePriceRuleRespVO> result = activePriceRuleMapper.pageActivePriceRule(page, actPriceRuleReq); IPage<ActivePriceRuleRespVO> result = activePriceRuleMapper.pageActivePriceRule(page, actPriceRuleReq);
// 会员等级列表
List<LJUserGrade> ljUserGrades = userGradeService.selectUserGradeAll(nowAccountInfo.getStoreId());
// 会员标签列表
List<UserLabel> userLabels = userLabelService.queryList();
/*2、数据处理*/ /*2、数据处理*/
result.getRecords().forEach(item -> { result.getRecords().forEach(item -> {
item.setPaymentTypeText(replacePayment(item.getPaymentType())); // item.setPaymentTypeText(replacePayment(item.getPaymentType()));
//会员等级集合转文字列表展示 //会员等级集合转文字列表展示
item.setLevelText(item.getLevelList().stream().map(MtUserGrade::getName).collect(Collectors.joining(","))); // item.setLevelText(ljUserGrades.stream().map(LJUserGrade::getName).collect(Collectors.joining(",")));
//会员标签集合转文字列表展示 //会员标签集合转文字列表展示
item.setLabelText(item.getLabelList().stream().map(UserLabel::getLabelName).collect(Collectors.joining(","))); // item.setLabelText(userLabels.stream().map(UserLabel::getLabelName).collect(Collectors.joining(",")));
String levelText = "";
for (LJUserGrade ljUserGrade : ljUserGrades) {
if (ObjectUtil.isNotEmpty(item.getLevelId()) && item.getLevelId().equals(ljUserGrade.getId().toString())){
levelText = ljUserGrade.getName() + ",";
}
}
item.setLevelText(levelText);
String labelText = "";
if (ObjectUtil.isNotEmpty(item.getBabelIds())) {
String[] babelIds = item.getBabelIds().split(",");
for (UserLabel userLabel : userLabels) {
for (String babelId : babelIds) {
if (babelId.equals(userLabel.getId().toString())){
labelText += userLabel.getLabelName() + ",";
}
}
}
}
item.setLabelText(labelText);
}); });
return result; return result;
} }
@ -84,15 +120,15 @@ public class ActivePriceRuleServiceImpl extends ServiceImpl<ActivePriceRuleMappe
ActivePriceRuleRespVO result = activePriceRuleMapper.getRuleById(id); ActivePriceRuleRespVO result = activePriceRuleMapper.getRuleById(id);
/*2、数据处理将会员等级和会员标签抽出id组成新的集合方便前端展示*/ /*2、数据处理将会员等级和会员标签抽出id组成新的集合方便前端展示*/
//会员标签id集合抽取id方便前端展示 //会员标签id集合抽取id方便前端展示
if (!result.getLabelList().isEmpty()) { // if (!result.getLabelList().isEmpty()) {
//会员标签id集合 // //会员标签id集合
result.setLabelIdList(result.getLabelList().stream().map(item -> String.valueOf(item.getId())).collect(Collectors.toList())); // result.setLabelIdList(result.getLabelList().stream().map(item -> String.valueOf(item.getId())).collect(Collectors.toList()));
} // }
//会员等级集合抽取id方便前端展示 // //会员等级集合抽取id方便前端展示
if (!result.getLevelList().isEmpty()){ // if (!result.getLevelList().isEmpty()){
//会员等级id集合 // //会员等级id集合
result.setLevelIdList(result.getLevelList().stream().map(item -> String.valueOf(item.getId())).collect(Collectors.toList())); // result.setLevelIdList(result.getLevelList().stream().map(item -> String.valueOf(item.getId())).collect(Collectors.toList()));
} // }
return result; return result;
} }
@ -116,16 +152,32 @@ public class ActivePriceRuleServiceImpl extends ServiceImpl<ActivePriceRuleMappe
//实体类转换 //实体类转换
ActivePriceRule activePriceRule = new ActivePriceRule(); ActivePriceRule activePriceRule = new ActivePriceRule();
BeanUtils.copyProperties(saveVO,activePriceRule); BeanUtils.copyProperties(saveVO,activePriceRule);
//会员等级id转换 // //会员等级id转换
String levelId = String.join(",", saveVO.getLevelIdList()); // String levelId = String.join(",", saveVO.getLevelIdList());
//会员标签id转换 // //会员标签id转换
String babelIds = String.join(",",saveVO.getLabelIdList()); // String babelIds = String.join(",",saveVO.getLabelIdList());
activePriceRule.setLevelId(levelId); // activePriceRule.setLevelId(levelId);
activePriceRule.setBabelIds(babelIds); // activePriceRule.setBabelIds(babelIds);
// 插入店铺信息id // 插入店铺信息id
AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo(); AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo();
activePriceRule.setChainStorId(nowAccountInfo.getChainStoreId()); activePriceRule.setChainStorId(nowAccountInfo.getChainStoreId());
activePriceRule.setStoreId(nowAccountInfo.getStoreId()); activePriceRule.setStoreId(nowAccountInfo.getStoreId());
// 判断规则状态信息
Date date = new Date();
if (ObjectUtil.isNotEmpty(activePriceRule.getActiveStartTime()) && ObjectUtil.isNotEmpty(activePriceRule.getActiveEndTime())){
if (activePriceRule.getActiveStartTime().after(date)){
activePriceRule.setStatus("0");
}
if (activePriceRule.getActiveStartTime().before(date) && activePriceRule.getActiveEndTime().after(date)){
activePriceRule.setStatus("1");
}
if (activePriceRule.getActiveEndTime().before(date)){
activePriceRule.setStatus("2");
}
}
/*3、保存数据库*/ /*3、保存数据库*/
//保存活动规则 //保存活动规则
saveOrUpdate(activePriceRule); saveOrUpdate(activePriceRule);

View File

@ -16,7 +16,7 @@ import java.util.List;
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@Data @Data
public class ActivePriceRuleRespVO extends ActivePriceRule { public class ActivePriceRuleRespVO extends ActivePriceRule {
/** 活动名称 */ /** 活动名称 分时优惠名称 */
private String activeTitle ; private String activeTitle ;
/** 支付方式字符串 */ /** 支付方式字符串 */
private String paymentTypeText; private String paymentTypeText;
@ -33,4 +33,10 @@ public class ActivePriceRuleRespVO extends ActivePriceRule {
/**标签集合*/ /**标签集合*/
private List<String> labelIdList; private List<String> labelIdList;
/** 活动名称 分时优惠 类型 */
private String activeType ;
/**
* 创建人
*/
private String createName;
} }