From 03a83c5702db94c495b9c9228436f028a7b7409a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BD=90=E5=A4=A9=E5=A4=A7=E5=9C=A3?= <17615834396@163.com> Date: Tue, 5 Dec 2023 09:43:37 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B2=B9=E7=AB=99=E6=B4=BB=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mapper/xml/ActiveConsumptionMapper.xml | 47 +++++ .../impl/ActiveConsumptionServiceImpl.java | 6 +- .../controller/ActiveExchangeController.java | 2 - .../impl/ActiveExchangeServiceImpl.java | 1 - .../controller/CardFuelDieselController.java | 46 +---- .../service/CardFuelDieselService.java | 9 + .../impl/CardFuelDieselServiceImpl.java | 52 ++++++ .../controller/CardGiftController.java | 26 +-- .../cardGift/service/CardGiftService.java | 10 ++ .../service/impl/CardGiftServiceImpl.java | 29 ++++ .../controller/CardValueController.java | 144 +-------------- .../cardValue/service/CardValueService.java | 34 ++++ .../service/impl/CardValueServiceImpl.java | 164 ++++++++++++++++++ .../pagesHome/oilRecharge/oilRecharge.vue | 51 ++++-- gasStation-uni/pagesHome/order/order.vue | 2 +- 15 files changed, 397 insertions(+), 226 deletions(-) create mode 100644 fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/activeConsumption/mapper/xml/ActiveConsumptionMapper.xml diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/activeConsumption/mapper/xml/ActiveConsumptionMapper.xml b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/activeConsumption/mapper/xml/ActiveConsumptionMapper.xml new file mode 100644 index 000000000..31b5b7c30 --- /dev/null +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/activeConsumption/mapper/xml/ActiveConsumptionMapper.xml @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/activeConsumption/service/impl/ActiveConsumptionServiceImpl.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/activeConsumption/service/impl/ActiveConsumptionServiceImpl.java index 5abf97dfc..b50ca521e 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/activeConsumption/service/impl/ActiveConsumptionServiceImpl.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/activeConsumption/service/impl/ActiveConsumptionServiceImpl.java @@ -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 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 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"); diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFule/service/CardFuelDieselService.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFule/service/CardFuelDieselService.java index 12a510a6e..ed3c331e5 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFule/service/CardFuelDieselService.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFule/service/CardFuelDieselService.java @@ -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 { List countOilType(); + /** + * 分页查询所有数据 + * @param page + * @param cardFuelDiesel + * @return + */ + IPage select(Page page, CardFuelDiesel cardFuelDiesel); } diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFule/service/impl/CardFuelDieselServiceImpl.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFule/service/impl/CardFuelDieselServiceImpl.java index 9f9c88253..c1dc35254 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFule/service/impl/CardFuelDieselServiceImpl.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFule/service/impl/CardFuelDieselServiceImpl.java @@ -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 countOilType() { AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo(); return cardFuelDieselMapper.countOilType(nowAccountInfo.getStoreId()); } + + /** + * 分页查询所有数据 + * @param page + * @param cardFuelDiesel + * @return + */ + @Override + public IPage select(Page page, CardFuelDiesel cardFuelDiesel) { + //构建查询条件 + LambdaQueryWrapper 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 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; + } } diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardGift/controller/CardGiftController.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardGift/controller/CardGiftController.java index e46a0516d..ea332b3ac 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardGift/controller/CardGiftController.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardGift/controller/CardGiftController.java @@ -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 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)); } /** diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardGift/service/CardGiftService.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardGift/service/CardGiftService.java index cee040110..195eb986c 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardGift/service/CardGiftService.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardGift/service/CardGiftService.java @@ -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 { * @return */ Map selectStatistics(Integer storeId); + + /** + * 分页查询所有数据 + * @param page + * @param cardGift + * @return + */ + IPage select(Page page, CardGift cardGift); } diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardGift/service/impl/CardGiftServiceImpl.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardGift/service/impl/CardGiftServiceImpl.java index 902c47302..6132a9ba8 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardGift/service/impl/CardGiftServiceImpl.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardGift/service/impl/CardGiftServiceImpl.java @@ -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 i } return map; } + + /** + * 分页查询所有数据 + * @param page + * @param cardGift + * @return + */ + @Override + public IPage select(Page page, CardGift cardGift) { + LambdaQueryWrapper 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); + } } diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardValue/controller/CardValueController.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardValue/controller/CardValueController.java index ea921704e..2a1462899 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardValue/controller/CardValueController.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardValue/controller/CardValueController.java @@ -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 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 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 queryWrapper = new LambdaQueryWrapper<>(); - queryWrapper.eq(CardValueChild::getCardValueId,id); - queryWrapper.orderByDesc(CardValueChild::getCreateTime); - List 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 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 queryWrapper = new LambdaQueryWrapper<>(); - queryWrapper.eq(CardValueChild::getCardValueId,cardValueDTO.getId()); - cardValueChildService.remove(queryWrapper); - //新增兑换物品 - List 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 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; - } } diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardValue/service/CardValueService.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardValue/service/CardValueService.java index b65c76ae8..0a72d882d 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardValue/service/CardValueService.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardValue/service/CardValueService.java @@ -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 { + /** + * 分页查询所有数据 + * @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); } diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardValue/service/impl/CardValueServiceImpl.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardValue/service/impl/CardValueServiceImpl.java index 96f84bb10..974d9202f 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardValue/service/impl/CardValueServiceImpl.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardValue/service/impl/CardValueServiceImpl.java @@ -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 implements CardValueService { + @Resource + private CardValueChildService cardValueChildService; + @Resource + private StoreService storeService; + /** + * 分页查询所有数据 + * @param page + * @param cardValue + * @return + */ + @Override + public IPage select(Page page, CardValue cardValue) { + LambdaQueryWrapper 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 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 queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(CardValueChild::getCardValueId,id); + queryWrapper.orderByDesc(CardValueChild::getCreateTime); + List 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 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 queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(CardValueChild::getCardValueId,cardValueDTO.getId()); + cardValueChildService.remove(queryWrapper); + //新增兑换物品 + List 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; + } } diff --git a/gasStation-uni/pagesHome/oilRecharge/oilRecharge.vue b/gasStation-uni/pagesHome/oilRecharge/oilRecharge.vue index 14f4c3e9e..34d1e9b7f 100644 --- a/gasStation-uni/pagesHome/oilRecharge/oilRecharge.vue +++ b/gasStation-uni/pagesHome/oilRecharge/oilRecharge.vue @@ -28,10 +28,12 @@ 充值{{text}}元权益 - {{1}}.{{fringeBenefit}} - {{2}}.赠送金额{{giftBalance}} - {{3}}.赠送积分{{points}} - {{4}}.赠送成长值{{growthValue}} + + {{index+1}}.{{item || "" }} + + @@ -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.shuomingList = [] + console.log(this.shuomingList); + if (text) { + this.text = text + } + 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 + // 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 = res.data.records + 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) + + } + }) } } diff --git a/gasStation-uni/pagesHome/order/order.vue b/gasStation-uni/pagesHome/order/order.vue index e8b9b2ba2..336f0b108 100644 --- a/gasStation-uni/pagesHome/order/order.vue +++ b/gasStation-uni/pagesHome/order/order.vue @@ -109,7 +109,7 @@