This commit is contained in:
wangh 2023-12-05 10:39:00 +08:00
commit f2aa5c9533
15 changed files with 397 additions and 226 deletions

View File

@ -0,0 +1,47 @@
<?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="com.fuint.business.marketingActivity.activeConsumption.mapper.ActiveConsumptionMapper">
<resultMap type="com.fuint.business.petrolStationManagement.entity.OilGun" id="OilGunMap">
<result property="id" column="id" jdbcType="INTEGER"/>
<result property="gunName" column="gun_name" jdbcType="VARCHAR"/>
<result property="tankId" column="tank_id" jdbcType="INTEGER"/>
<result property="status" column="status" jdbcType="VARCHAR"/>
<result property="storeId" column="store_id" jdbcType="INTEGER"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
<result property="createBy" column="create_by" jdbcType="INTEGER"/>
<result property="updateBy" column="update_by" jdbcType="INTEGER"/>
<result property="numberId" column="number_id" jdbcType="INTEGER"/>
<result property="tankName" column="tank_name" jdbcType="VARCHAR"/>
<result property="oilNumber" column="oil_number" jdbcType="VARCHAR"/>
<result property="oilMachineGunNumber" column="oil_machine_gun_number" jdbcType="VARCHAR"/>
</resultMap>
<select id="getAllList" resultMap="OilGunMap">
select
og.id, og.gun_name, og.tank_id, og.status, og.store_id, og.create_time, og.update_time, og.create_by, og.update_by, og.number_id, ot.tank_name,
og.oil_machine_gun_number
from oil_gun og left join oil_tank ot on og.tank_id = ot.id
<where>
<if test="oilGun.id != null">
and og.id = #{oilGun.id}
</if>
<if test="oilGun.gunName != null and oilGun.gunName != ''">
and og.gun_name = #{oilGun.gunName}
</if>
<if test="oilGun.tankId != null">
and og.tank_id = #{oilGun.tankId}
</if>
<if test="oilGun.status != null and oilGun.status != ''">
and og.status = #{oilGun.status}
</if>
<if test="oilGun.storeId != null">
and og.store_id = #{oilGun.storeId}
</if>
<if test="oilGun.updateBy != null">
and og.update_by = #{oilGun.updateBy}
</if>
</where>
</select>
</mapper>

View File

@ -15,6 +15,7 @@ import com.fuint.business.marketingActivity.activeConsumption.vo.ActiveConsumpti
import com.fuint.business.marketingActivity.activeConsumption.vo.ActiveConsumptionVO;
import com.fuint.business.petrolStationManagement.service.OilNameService;
import com.fuint.business.store.service.StoreService;
import com.fuint.business.userManager.entity.LJUserGrade;
import com.fuint.business.userManager.service.LJUserGradeService;
import com.fuint.common.util.TokenUtil;
import org.apache.commons.lang3.ObjectUtils;
@ -131,8 +132,9 @@ public class ActiveConsumptionServiceImpl extends ServiceImpl<ActiveConsumptionM
String str = "";
if (ObjectUtils.isNotEmpty(s.getDieselUserLevel())){
for (String gradeId : s.getDieselUserLevel().split(",")) {
if (ObjectUtils.isNotEmpty(userGradeService.selectUserGradeById(Integer.parseInt(gradeId)))){
str += userGradeService.selectUserGradeById(Integer.parseInt(gradeId)).getName() + ",";
LJUserGrade ljUserGrade = userGradeService.selectUserGradeById(Integer.parseInt(gradeId));
if (ObjectUtils.isNotEmpty(ljUserGrade)){
str += ljUserGrade.getName() + ",";
}
}
activeConsumptionVO.setDieselUserLevel(str.split(","));

View File

@ -83,8 +83,6 @@ public class ActiveExchangeController extends BaseController {
/**
* 分页查询所有数据
* @param pageNo
* @param pageSize
* @return
*/
@GetMapping("applet")

View File

@ -264,7 +264,6 @@ public class ActiveExchangeServiceImpl implements ActiveExchangeService {
}
/**
* 分页查询所有数据
* @param page
* @return
*/
@Override

View File

@ -2,24 +2,15 @@ package com.fuint.business.marketingActivity.cardFule.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fuint.business.marketingActivity.cardFule.entity.CardFuelDiesel;
import com.fuint.business.marketingActivity.cardFule.service.CardFuelDieselService;
import com.fuint.business.marketingActivity.cardGift.entity.CardGift;
import com.fuint.business.petrolStationManagement.entity.OilName;
import com.fuint.business.petrolStationManagement.service.OilNameService;
import com.fuint.business.store.service.StoreService;
import com.fuint.common.dto.AccountInfo;
import com.fuint.common.util.TokenUtil;
import com.fuint.framework.web.BaseController;
import com.fuint.framework.web.ResponseObject;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
@ -43,8 +34,6 @@ public class CardFuelDieselController extends BaseController {
private CardFuelDieselService cardFuelDieselService;
@Resource
private StoreService storeService;
@Autowired
private OilNameService oilNameService;
/**
* 分页查询所有数据
@ -58,39 +47,7 @@ public class CardFuelDieselController extends BaseController {
@RequestParam(value = "pageSize",defaultValue = "10") Integer pageSize,
@Param("cardFuelDiesel") CardFuelDiesel cardFuelDiesel) {
Page page = new Page(pageNo, pageSize);
//构建查询条件
LambdaQueryWrapper<CardFuelDiesel> queryWrapper = new LambdaQueryWrapper<>();
if(ObjectUtils.isNotEmpty(cardFuelDiesel.getOilType())){
queryWrapper.eq(CardFuelDiesel::getOilType,cardFuelDiesel.getOilType());
}
if (ObjectUtils.isNotEmpty(cardFuelDiesel.getActiveStatus())){
queryWrapper.eq(CardFuelDiesel::getActiveStatus,cardFuelDiesel.getActiveStatus());
}
if(ObjectUtils.isNotEmpty(cardFuelDiesel.getType())) {
queryWrapper.eq(CardFuelDiesel::getType,cardFuelDiesel.getType());
}
queryWrapper.eq(CardFuelDiesel::getStoreId, TokenUtil.getNowAccountInfo().getStoreId());
queryWrapper.orderByDesc(CardFuelDiesel::getCreateTime);
IPage page1 = this.cardFuelDieselService.page(page, queryWrapper);
List<CardFuelDiesel> records = page1.getRecords();
//返回囤油卡状态
for (CardFuelDiesel record : records) {
record.setOilType(oilNameService.selectOilNameById(Integer.parseInt(record.getOilType())).getOilName());
record.setStatus(record.getStatus().equals("1") ? "true" : "false");
if(ObjectUtils.isNotEmpty(record.getActiveTime()) && "1".equals(record.getActiveTime())){
record.setActivityProgress("1");
}
//活动进度状态
if (ObjectUtils.isNotEmpty(record.getStartTime()) &&
ObjectUtils.isNotEmpty(record.getEndTime()) &&
record.getActiveTime().equals("2")){
record.setActivityProgress(record.getStartTime().getTime() > new Date().getTime() ? "0" : "");
if(ObjectUtils.isEmpty(record.getActivityProgress())){
record.setActivityProgress(record.getEndTime().getTime() > new Date().getTime() ? "1" : "2");
}
}
}
return getSuccessResult(page1);
return getSuccessResult(this.cardFuelDieselService.select(page, cardFuelDiesel));
}
/**
@ -117,7 +74,6 @@ public class CardFuelDieselController extends BaseController {
cardFuelDiesel.setStoreId(TokenUtil.getNowAccountInfo().getStoreId());
cardFuelDiesel.setChainStorId(storeService.getById(TokenUtil.getNowAccountInfo().getStoreId()).getChainStoreId());
}
cardFuelDiesel.setStartTime(new Date());
cardFuelDiesel.setEndTime(new Date());
cardFuelDiesel.setStatus(cardFuelDiesel.getStatus().equals("true") ? "1" : "2");

View File

@ -1,5 +1,7 @@
package com.fuint.business.marketingActivity.cardFule.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.fuint.business.marketingActivity.cardFule.entity.CardFuelDiesel;
@ -15,5 +17,12 @@ public interface CardFuelDieselService extends IService<CardFuelDiesel> {
List<CardFuelDiesel> countOilType();
/**
* 分页查询所有数据
* @param page
* @param cardFuelDiesel
* @return
*/
IPage select(Page page, CardFuelDiesel cardFuelDiesel);
}

View File

@ -1,14 +1,21 @@
package com.fuint.business.marketingActivity.cardFule.service.impl;
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 com.fuint.business.marketingActivity.cardFule.mapper.CardFuelDieselMapper;
import com.fuint.business.marketingActivity.cardFule.entity.CardFuelDiesel;
import com.fuint.business.marketingActivity.cardFule.service.CardFuelDieselService;
import com.fuint.business.petrolStationManagement.service.OilNameService;
import com.fuint.common.dto.AccountInfo;
import com.fuint.common.util.TokenUtil;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
/**
@ -22,11 +29,56 @@ public class CardFuelDieselServiceImpl extends ServiceImpl<CardFuelDieselMapper,
@Resource
CardFuelDieselMapper cardFuelDieselMapper;
@Autowired
private OilNameService oilNameService;
@Override
public List<CardFuelDiesel> countOilType() {
AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo();
return cardFuelDieselMapper.countOilType(nowAccountInfo.getStoreId());
}
/**
* 分页查询所有数据
* @param page
* @param cardFuelDiesel
* @return
*/
@Override
public IPage select(Page page, CardFuelDiesel cardFuelDiesel) {
//构建查询条件
LambdaQueryWrapper<CardFuelDiesel> queryWrapper = new LambdaQueryWrapper<>();
if(ObjectUtils.isNotEmpty(cardFuelDiesel.getOilType())){
queryWrapper.eq(CardFuelDiesel::getOilType,cardFuelDiesel.getOilType());
}
if (ObjectUtils.isNotEmpty(cardFuelDiesel.getActiveStatus())){
queryWrapper.eq(CardFuelDiesel::getActiveStatus,cardFuelDiesel.getActiveStatus());
}
if(ObjectUtils.isNotEmpty(cardFuelDiesel.getType())) {
queryWrapper.eq(CardFuelDiesel::getType,cardFuelDiesel.getType());
}
queryWrapper.eq(CardFuelDiesel::getStoreId, TokenUtil.getNowAccountInfo().getStoreId());
queryWrapper.orderByDesc(CardFuelDiesel::getCreateTime);
IPage page1 = page(page, queryWrapper);
List<CardFuelDiesel> records = page1.getRecords();
//返回囤油卡状态
for (CardFuelDiesel record : records) {
record.setOilType(oilNameService.selectOilNameById(Integer.parseInt(record.getOilType())).getOilName());
record.setStatus(record.getStatus().equals("1") ? "true" : "false");
if(ObjectUtils.isNotEmpty(record.getActiveTime()) && "1".equals(record.getActiveTime())){
record.setActivityProgress("1");
}
//活动进度状态
if (ObjectUtils.isNotEmpty(record.getStartTime()) &&
ObjectUtils.isNotEmpty(record.getEndTime()) &&
record.getActiveTime().equals("2")){
record.setActivityProgress(record.getStartTime().getTime() > new Date().getTime() ? "0" : "");
if(ObjectUtils.isEmpty(record.getActivityProgress())){
record.setActivityProgress(record.getEndTime().getTime() > new Date().getTime() ? "1" : "2");
}
}
}
return page1;
}
}

View File

@ -1,19 +1,11 @@
package com.fuint.business.marketingActivity.cardGift.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fuint.business.marketingActivity.cardGift.entity.CardGift;
import com.fuint.business.marketingActivity.cardGift.service.CardGiftService;
import com.fuint.business.marketingActivity.cardValue.entity.CardValue;
import com.fuint.common.util.TokenUtil;
import com.fuint.framework.web.BaseController;
import com.fuint.framework.web.ResponseObject;
import com.fuint.utils.ObjectUtil;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.ibatis.annotations.Param;
import org.springframework.web.bind.annotation.*;
@ -48,23 +40,7 @@ public class CardGiftController extends BaseController {
@RequestParam(value = "pageSize",defaultValue = "10") Integer pageSize,
@Param("cardGift") CardGift cardGift) {
Page page = new Page(pageNo, pageSize);
LambdaQueryWrapper<CardGift> queryWrapper = new LambdaQueryWrapper<>();
//构建查询条件
if(ObjectUtils.isNotEmpty(cardGift.getNumber())){
queryWrapper.like(CardGift::getNumber,cardGift.getNumber());
}
if(ObjectUtils.isNotEmpty(cardGift.getRemark())){
queryWrapper.like(CardGift::getRemark,cardGift.getRemark());
}
if(ObjectUtils.isNotEmpty(cardGift.getActivateStatus())) {
queryWrapper.eq(CardGift::getActivateStatus,cardGift.getActivateStatus());
}
if(ObjectUtils.isNotEmpty(cardGift.getStatus())) {
queryWrapper.eq(CardGift::getStatus,cardGift.getStatus());
}
queryWrapper.eq(CardGift::getStoreId, TokenUtil.getNowAccountInfo().getStoreId());
queryWrapper.orderByDesc(CardGift::getCreateTime);
return getSuccessResult(this.cardGiftService.page(page, queryWrapper));
return getSuccessResult(this.cardGiftService.select(page, cardGift));
}
/**

View File

@ -1,5 +1,7 @@
package com.fuint.business.marketingActivity.cardGift.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.fuint.business.marketingActivity.cardGift.entity.CardGift;
import com.fuint.business.petrolStationManagement.entity.OilGun;
@ -27,5 +29,13 @@ public interface CardGiftService extends IService<CardGift> {
* @return
*/
Map<String, Long> selectStatistics(Integer storeId);
/**
* 分页查询所有数据
* @param page
* @param cardGift
* @return
*/
IPage select(Page page, CardGift cardGift);
}

View File

@ -1,6 +1,8 @@
package com.fuint.business.marketingActivity.cardGift.service.impl;
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 com.fuint.business.marketingActivity.cardGift.mapper.CardGiftMapper;
import com.fuint.business.marketingActivity.cardGift.entity.CardGift;
@ -102,5 +104,32 @@ public class CardGiftServiceImpl extends ServiceImpl<CardGiftMapper, CardGift> i
}
return map;
}
/**
* 分页查询所有数据
* @param page
* @param cardGift
* @return
*/
@Override
public IPage select(Page page, CardGift cardGift) {
LambdaQueryWrapper<CardGift> queryWrapper = new LambdaQueryWrapper<>();
//构建查询条件
if(ObjectUtils.isNotEmpty(cardGift.getNumber())){
queryWrapper.like(CardGift::getNumber,cardGift.getNumber());
}
if(ObjectUtils.isNotEmpty(cardGift.getRemark())){
queryWrapper.like(CardGift::getRemark,cardGift.getRemark());
}
if(ObjectUtils.isNotEmpty(cardGift.getActivateStatus())) {
queryWrapper.eq(CardGift::getActivateStatus,cardGift.getActivateStatus());
}
if(ObjectUtils.isNotEmpty(cardGift.getStatus())) {
queryWrapper.eq(CardGift::getStatus,cardGift.getStatus());
}
queryWrapper.eq(CardGift::getStoreId, TokenUtil.getNowAccountInfo().getStoreId());
queryWrapper.orderByDesc(CardGift::getCreateTime);
return page(page, queryWrapper);
}
}

View File

@ -1,33 +1,18 @@
package com.fuint.business.marketingActivity.cardValue.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fuint.business.marketingActivity.cardFavorable.entity.CardFavorable;
import com.fuint.business.marketingActivity.cardValue.dto.CardValueDTO;
import com.fuint.business.marketingActivity.cardValue.entity.CardValue;
import com.fuint.business.marketingActivity.cardValue.entity.CardValueChild;
import com.fuint.business.marketingActivity.cardValue.service.CardValueChildService;
import com.fuint.business.marketingActivity.cardValue.service.CardValueService;
import com.fuint.business.marketingActivity.cardValue.vo.CardValueVO;
import com.fuint.business.store.service.StoreService;
import com.fuint.common.util.TokenUtil;
import com.fuint.framework.web.BaseController;
import com.fuint.framework.web.ResponseObject;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.BeanUtils;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
/**
* 储值卡表(CardValue)表控制层
@ -44,12 +29,6 @@ public class CardValueController extends BaseController {
@Resource
private CardValueService cardValueService;
@Resource
private StoreService storeService;
@Resource
private CardValueChildService cardValueChildService;
/**
* 分页查询所有数据
* @param pageNo
@ -62,33 +41,7 @@ public class CardValueController extends BaseController {
@RequestParam(value = "pageSize",defaultValue = "10") Integer pageSize,
@Param("cardValue") CardValue cardValue) {
Page page = new Page(pageNo, pageSize);
LambdaQueryWrapper<CardValue> queryWrapper = new LambdaQueryWrapper<>();
//构建查询条件
if (ObjectUtils.isNotEmpty(cardValue.getIsonline())){
queryWrapper.eq(CardValue::getIsonline,cardValue.getIsonline());
}
if (ObjectUtils.isNotEmpty(cardValue.getActiveStatus())){
queryWrapper.eq(CardValue::getActiveStatus,cardValue.getActiveStatus());
}
queryWrapper.eq(CardValue::getStoreId,TokenUtil.getNowAccountInfo().getStoreId());
queryWrapper.orderByDesc(CardValue::getCreateTime);
IPage page1 = this.cardValueService.page(page, queryWrapper);
List<CardValue> records = page1.getRecords();
//返回储值卡活动进度状态
for (CardValue record : records) {
if(ObjectUtils.isNotEmpty(record.getActiveTime()) && record.getActiveTime().equals("1")){
record.setActivityProgress("1");
}
if (ObjectUtils.isNotEmpty(record.getStartTime()) &&
ObjectUtils.isNotEmpty(record.getEndTime()) &&
record.getActiveTime().equals("2")){
record.setActivityProgress(record.getStartTime().getTime() > new Date().getTime() ? "0" : "");
if(ObjectUtils.isEmpty(record.getActivityProgress())){
record.setActivityProgress(record.getEndTime().getTime() > new Date().getTime() ? "1" : "2");
}
}
}
return getSuccessResult(page1);
return getSuccessResult(this.cardValueService.select(page, cardValue));
}
/**
@ -110,27 +63,7 @@ public class CardValueController extends BaseController {
*/
@GetMapping("/selectById/{id}")
public ResponseObject selectById(@PathVariable Serializable id) {
CardValueVO cardValueVO = new CardValueVO();
if (ObjectUtils.isNotEmpty(id)){
//获取新人有礼活动信息
CardValue cardValue = this.cardValueService.getById(id);
//获取兑换物品信息
LambdaQueryWrapper<CardValueChild> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(CardValueChild::getCardValueId,id);
queryWrapper.orderByDesc(CardValueChild::getCreateTime);
List<CardValueChild> activeNewlywedsChildList = cardValueChildService.list(queryWrapper);
BeanUtils.copyProperties(cardValue,cardValueVO);
cardValueVO.setMembershipLevel(cardValue.getMembershipLevel().split(","));
if (CollectionUtils.isNotEmpty(activeNewlywedsChildList)){
//封装VO返回
cardValueVO.setCardValueChildList(activeNewlywedsChildList);
}else {
cardValueVO.setCardValueChildList(new ArrayList<>());
}
}
return getSuccessResult(cardValueVO);
//return getSuccessResult(this.cardValueService.getById(id));
return getSuccessResult(this.cardValueService.getOneById(id));
}
/**
@ -141,39 +74,7 @@ public class CardValueController extends BaseController {
*/
@PostMapping
public ResponseObject insert(@RequestBody CardValueDTO cardValueDTO) {
boolean save = false;
//获取当前店铺的id和连锁店id
if (ObjectUtils.isNotEmpty(TokenUtil.getNowAccountInfo().getStoreId())) {
cardValueDTO.setStoreId(TokenUtil.getNowAccountInfo().getStoreId());
cardValueDTO.setChainStoreId(storeService.getById(TokenUtil.getNowAccountInfo().getStoreId()).getChainStoreId());
}
//新增折扣营销活动模板
CardValue cardValue = new CardValue();
cardValue.setStartTime(new Date());
cardValue.setEndTime(new Date());
//柴油会员等级
cardValue.setMembershipLevel(arrayToString(cardValueDTO.getMembershipLevel()));
if (ObjectUtils.isNotEmpty(cardValueDTO)){
BeanUtils.copyProperties(cardValueDTO,cardValue);
save = this.cardValueService.save(cardValue);
}
//新增兑换物品
List<CardValueChild> cardValueChildList = cardValueDTO.getCardValueChildList();
cardValueChildList.stream().map(s ->{
s.setCardValueId(cardValue.getId());
return s;
}).collect(Collectors.toList());
save = cardValueChildService.saveBatch(cardValueChildList);
return getSuccessResult(save);
/*//获取当前店铺的id和连锁店id
if (ObjectUtils.isNotEmpty(TokenUtil.getNowAccountInfo().getStoreId())) {
cardValue.setStartTime(new Date());
cardValue.setEndTime(new Date());
cardValue.setStoreId(TokenUtil.getNowAccountInfo().getStoreId());
cardValue.setChainStoreId(storeService.getById(TokenUtil.getNowAccountInfo().getStoreId()).getChainStoreId());
}
return getSuccessResult(this.cardValueService.save(cardValue));*/
return getSuccessResult(this.cardValueService.add(cardValueDTO));
}
/**
@ -184,31 +85,7 @@ public class CardValueController extends BaseController {
*/
@PutMapping
public ResponseObject update(@RequestBody CardValueDTO cardValueDTO) {
boolean update = false;
//更新新人有礼活动
CardValue cardValue = new CardValue();
BeanUtils.copyProperties(cardValueDTO,cardValue);
if (cardValueDTO.getIsonline().equals("1")){
cardValue.setActiveStatus("2");
}
update =this.cardValueService.updateById(cardValue);
//更新子表数据
LambdaQueryWrapper<CardValueChild> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(CardValueChild::getCardValueId,cardValueDTO.getId());
cardValueChildService.remove(queryWrapper);
//新增兑换物品
List<CardValueChild> cardValueChildList = cardValueDTO.getCardValueChildList();
if (CollectionUtils.isNotEmpty(cardValueChildList)){
cardValueChildList.stream().map(s ->{
s.setCardValueId(cardValue.getId());
return s;
}).collect(Collectors.toList());
update = cardValueChildService.saveBatch(cardValueChildList);
}
return getSuccessResult(update);
//return getSuccessResult(this.cardValueService.updateById(cardValue));
return getSuccessResult(this.cardValueService.updateOneById(cardValueDTO));
}
/**
@ -221,18 +98,5 @@ public class CardValueController extends BaseController {
public ResponseObject delete(@RequestParam("idList") List<Long> idList) {
return getSuccessResult(this.cardValueService.removeByIds(idList));
}
/**
* 数组转字符串
* @param array
* @return
*/
public static String arrayToString(String[] array){
String result = "";
for (String s : array) {
result += s + ",";
}
return result;
}
}

View File

@ -1,7 +1,13 @@
package com.fuint.business.marketingActivity.cardValue.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.fuint.business.marketingActivity.cardValue.dto.CardValueDTO;
import com.fuint.business.marketingActivity.cardValue.entity.CardValue;
import com.fuint.business.marketingActivity.cardValue.vo.CardValueVO;
import java.io.Serializable;
/**
* 储值卡表(CardValue)表服务接口
@ -11,5 +17,33 @@ import com.fuint.business.marketingActivity.cardValue.entity.CardValue;
*/
public interface CardValueService extends IService<CardValue> {
/**
* 分页查询所有数据
* @param page
* @param cardValue
* @return
*/
IPage select(Page page, CardValue cardValue);
/**
* 通过主键查询单条数据(充值)
* @param id
* @return
*/
CardValueVO getOneById(Serializable id);
/**
* 新增数据
* @param cardValueDTO
* @return
*/
boolean add(CardValueDTO cardValueDTO);
/**
* 修改数据
* @param cardValueDTO
* @return
*/
boolean updateOneById(CardValueDTO cardValueDTO);
}

View File

@ -1,11 +1,30 @@
package com.fuint.business.marketingActivity.cardValue.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fuint.business.marketingActivity.cardValue.dto.CardValueDTO;
import com.fuint.business.marketingActivity.cardValue.entity.CardValueChild;
import com.fuint.business.marketingActivity.cardValue.mapper.CardValueMapper;
import com.fuint.business.marketingActivity.cardValue.entity.CardValue;
import com.fuint.business.marketingActivity.cardValue.service.CardValueChildService;
import com.fuint.business.marketingActivity.cardValue.service.CardValueService;
import com.fuint.business.marketingActivity.cardValue.vo.CardValueVO;
import com.fuint.business.store.service.StoreService;
import com.fuint.common.util.TokenUtil;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
/**
* 储值卡表(CardValue)表服务实现类
*
@ -15,5 +34,150 @@ import org.springframework.stereotype.Service;
@Service("cardValueService")
public class CardValueServiceImpl extends ServiceImpl<CardValueMapper, CardValue> implements CardValueService {
@Resource
private CardValueChildService cardValueChildService;
@Resource
private StoreService storeService;
/**
* 分页查询所有数据
* @param page
* @param cardValue
* @return
*/
@Override
public IPage select(Page page, CardValue cardValue) {
LambdaQueryWrapper<CardValue> queryWrapper = new LambdaQueryWrapper<>();
//构建查询条件
if (ObjectUtils.isNotEmpty(cardValue.getIsonline())){
queryWrapper.eq(CardValue::getIsonline,cardValue.getIsonline());
}
if (ObjectUtils.isNotEmpty(cardValue.getActiveStatus())){
queryWrapper.eq(CardValue::getActiveStatus,cardValue.getActiveStatus());
}
queryWrapper.eq(CardValue::getStoreId, TokenUtil.getNowAccountInfo().getStoreId());
queryWrapper.orderByDesc(CardValue::getCreateTime);
IPage page1 = page(page, queryWrapper);
List<CardValue> records = page1.getRecords();
//返回储值卡活动进度状态
for (CardValue record : records) {
if(ObjectUtils.isNotEmpty(record.getActiveTime()) && record.getActiveTime().equals("1")){
record.setActivityProgress("1");
}
if (ObjectUtils.isNotEmpty(record.getStartTime()) &&
ObjectUtils.isNotEmpty(record.getEndTime()) &&
record.getActiveTime().equals("2")){
record.setActivityProgress(record.getStartTime().getTime() > new Date().getTime() ? "0" : "");
if(ObjectUtils.isEmpty(record.getActivityProgress())){
record.setActivityProgress(record.getEndTime().getTime() > new Date().getTime() ? "1" : "2");
}
}
}
return page1;
}
/**
* 通过主键查询单条数据(充值)
* @param id
* @return
*/
@Override
public CardValueVO getOneById(Serializable id) {
CardValueVO cardValueVO = new CardValueVO();
if (ObjectUtils.isNotEmpty(id)){
//获取新人有礼活动信息
CardValue cardValue = getById(id);
//获取兑换物品信息
LambdaQueryWrapper<CardValueChild> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(CardValueChild::getCardValueId,id);
queryWrapper.orderByDesc(CardValueChild::getCreateTime);
List<CardValueChild> activeNewlywedsChildList = cardValueChildService.list(queryWrapper);
BeanUtils.copyProperties(cardValue,cardValueVO);
cardValueVO.setMembershipLevel(cardValue.getMembershipLevel().split(","));
if (CollectionUtils.isNotEmpty(activeNewlywedsChildList)){
//封装VO返回
cardValueVO.setCardValueChildList(activeNewlywedsChildList);
}else {
cardValueVO.setCardValueChildList(new ArrayList<>());
}
}
return cardValueVO;
}
/**
* 新增数据
* @param cardValueDTO
* @return
*/
@Override
public boolean add(CardValueDTO cardValueDTO) {
boolean save = false;
//获取当前店铺的id和连锁店id
if (ObjectUtils.isNotEmpty(TokenUtil.getNowAccountInfo().getStoreId())) {
cardValueDTO.setStoreId(TokenUtil.getNowAccountInfo().getStoreId());
cardValueDTO.setChainStoreId(storeService.getById(TokenUtil.getNowAccountInfo().getStoreId()).getChainStoreId());
}
//新增折扣营销活动模板
CardValue cardValue = new CardValue();
cardValue.setStartTime(new Date());
cardValue.setEndTime(new Date());
//柴油会员等级
cardValue.setMembershipLevel(arrayToString(cardValueDTO.getMembershipLevel()));
if (ObjectUtils.isNotEmpty(cardValueDTO)){
BeanUtils.copyProperties(cardValueDTO,cardValue);
save = save(cardValue);
}
//新增兑换物品
List<CardValueChild> cardValueChildList = cardValueDTO.getCardValueChildList();
cardValueChildList.stream().map(s ->{
s.setCardValueId(cardValue.getId());
return s;
}).collect(Collectors.toList());
save = cardValueChildService.saveBatch(cardValueChildList);
return save;
}
/**
* 修改数据
* @param cardValueDTO
* @return
*/
@Override
public boolean updateOneById(CardValueDTO cardValueDTO) {
boolean update = false;
//更新新人有礼活动
CardValue cardValue = new CardValue();
BeanUtils.copyProperties(cardValueDTO,cardValue);
if (cardValueDTO.getIsonline().equals("1")){
cardValue.setActiveStatus("2");
}
update =updateById(cardValue);
//更新子表数据
LambdaQueryWrapper<CardValueChild> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(CardValueChild::getCardValueId,cardValueDTO.getId());
cardValueChildService.remove(queryWrapper);
//新增兑换物品
List<CardValueChild> cardValueChildList = cardValueDTO.getCardValueChildList();
if (CollectionUtils.isNotEmpty(cardValueChildList)){
cardValueChildList.stream().map(s ->{
s.setCardValueId(cardValue.getId());
return s;
}).collect(Collectors.toList());
update = cardValueChildService.saveBatch(cardValueChildList);
}
return update;
}
/**
* 数组转字符串
* @param array
* @return
*/
public static String arrayToString(String[] array){
String result = "";
for (String s : array) {
result += s + ",";
}
return result;
}
}

View File

@ -28,10 +28,12 @@
</view>
<view class="box-hui">
<view style="margin-bottom: 15px;">充值{{text}}元权益</view>
<view class="huisize" v-if="fringeBenefit">{{1}}.{{fringeBenefit}}</view>
<view class="huisize" v-if="giftBalance">{{2}}.赠送金额{{giftBalance}}</view>
<view class="huisize" v-if="points">{{3}}.赠送积分{{points}}</view>
<view class="huisize" v-if="growthValue">{{4}}.赠送成长值{{growthValue}}</view>
<view class="huisize" v-for="(item,index) in shuomingList" :key="index">
{{index+1}}.{{item || "" }}
</view>
<!-- <view class="huisize" v-if="giftBalance">2.赠送金额{{giftBalance}}</view>
<view class="huisize" v-if="points">3.赠送积分{{points}}</view>
<view class="huisize" v-if="growthValue">4.赠送成长值{{growthValue}}</view> -->
<!-- <view class="huisize" v-if="fringeBenefit">{{index + 1}}.{{fringeBenefit}}</view> -->
</view>
<view class="box-gang">
@ -94,6 +96,7 @@
points: "",
growthValue: "",
show: false,
shuomingList: [],
columns: [
['员工一', '员工二', '员工三']
],
@ -118,6 +121,7 @@
},
onShow() {
this.getValueCars();
// this.xzindex(index, text, fringeBenefit, giftBalance, points, growthValue)
},
methods: {
confirm(e) {
@ -127,12 +131,31 @@
this.show = false
},
xzindex(index, text, fringeBenefit, giftBalance, points, growthValue) {
this.actindex = index
this.shuomingList = []
console.log(this.shuomingList);
if (text) {
this.text = text
this.fringeBenefit = fringeBenefit
this.giftBalance = giftBalance
this.points = points
this.growthValue = growthValue
}
if (fringeBenefit) {
this.shuomingList.push(fringeBenefit)
}
if (giftBalance) {
this.shuomingList.push('赠送' + giftBalance + '金额')
}
if (points) {
this.shuomingList.push('赠送' + points + '积分')
}
if (growthValue) {
this.shuomingList.push('赠送' + growthValue + '成长值')
}
this.actindex = index
// this.text = text
// this.fringeBenefit = fringeBenefit
// this.giftBalance = giftBalance
// this.points = points
// this.growthValue = growthValue
},
getindex(index) {
this.actinput = index
@ -148,7 +171,15 @@
activeStatus: '1'
},
}).then(res => {
this.cardValueList = []
if (res.code == 200) {
this.cardValueList = res.data.records
this.xzindex(0, this.cardValueList[0].rechargeBalance, this.cardValueList[0].fringeBenefit,
this.cardValueList[0].giftBalance, this.cardValueList[0].points, this
.cardValueList[0].growthValue)
}
})
}
}

View File

@ -111,7 +111,7 @@
<script>
import config from '@/config'
import request from '../../utils/request'
import BigNumber from 'bignumber.js';
/* import BigNumber from 'bignumber.js'; */
export default {