一键发券

This commit is contained in:
齐天大圣 2024-03-04 13:37:29 +08:00
parent ec24649985
commit d96d1f1e53
21 changed files with 957 additions and 55 deletions

View File

@ -40,7 +40,7 @@ public interface ActiveNewlywedsService extends IService<ActiveNewlyweds> {
* @param id
* @return
*/
List<ActiveNewlywedsVO> getOneById(Serializable id);
ActiveNewlywedsVO getOneById(Serializable id);
ActiveNewlywedsVO getOneByStoreId(Serializable id);
ActiveNewlywedsVO getOneByIdApplet(ActiveConsumption activeConsumption);

View File

@ -115,13 +115,13 @@ public class ActiveNewlywedsServiceImpl extends ServiceImpl<ActiveNewlywedsMappe
/**
* 分页查询所有数据
* @param page
* @param activeNewlyweds
* @param activeNewlywedss
* @return
*/
@Override
public IPage select(Page page, ActiveNewlyweds activeNewlyweds) {
public IPage select(Page page, ActiveNewlyweds activeNewlywedss) {
//构建查询条件
LambdaQueryWrapper<ActiveNewlyweds> queryWrapper = new LambdaQueryWrapper<>();
/*LambdaQueryWrapper<ActiveNewlyweds> queryWrapper = new LambdaQueryWrapper<>();
if(ObjectUtils.isNotEmpty(activeNewlyweds.getName())){
queryWrapper.like(ActiveNewlyweds::getName,activeNewlyweds.getName());
}
@ -150,24 +150,16 @@ public class ActiveNewlywedsServiceImpl extends ServiceImpl<ActiveNewlywedsMappe
return activeNewlywedsVO;
}).collect(Collectors.toList());
page1.setRecords(activeNewlywedsVOList);
return page1;
}
/**
* 通过店铺查询单条数据
* @param id
* @return
*/
@Override
public List<ActiveNewlywedsVO> getOneById(Serializable id) {
return page1;*/
Integer storeId = TokenUtil.getNowAccountInfo().getStoreId();
ArrayList<ActiveNewlywedsVO> activeNewlywedsVOS = new ArrayList<>();
if (ObjectUtils.isNotEmpty(storeId)){
//获取新人有礼活动信息
LambdaQueryWrapper<ActiveNewlyweds> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(ActiveNewlyweds::getStoreId,TokenUtil.getNowAccountInfo().getStoreId());
//ActiveNewlyweds activeNewlyweds = getOne(lambdaQueryWrapper);
List<ActiveNewlyweds> list = list(lambdaQueryWrapper);
IPage page1 = page(page, lambdaQueryWrapper);
List<ActiveNewlyweds> list = page1.getRecords();
//List<ActiveNewlyweds> list = list(lambdaQueryWrapper);
//获取兑换物品信息
if (CollectionUtils.isNotEmpty(list)){
for (ActiveNewlyweds activeNewlyweds : list) {
@ -232,8 +224,86 @@ public class ActiveNewlywedsServiceImpl extends ServiceImpl<ActiveNewlywedsMappe
}
}
}
}
return activeNewlywedsVOS;
page1.setRecords(list);
return page1;
//return activeNewlywedsVOS;
}
/**
* 通过店铺查询单条数据
* @param id
* @return
*/
@Override
public ActiveNewlywedsVO getOneById(Serializable id) {
Integer storeId = TokenUtil.getNowAccountInfo().getStoreId();
//获取新人有礼活动信息
LambdaQueryWrapper<ActiveNewlyweds> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(ActiveNewlyweds::getStoreId,TokenUtil.getNowAccountInfo().getStoreId());
lambdaQueryWrapper.eq(ActiveNewlyweds::getId,id);
ActiveNewlyweds activeNewlyweds = getOne(lambdaQueryWrapper);
//List<ActiveNewlyweds> list = list(lambdaQueryWrapper);
//获取兑换物品信息
int youhuiTed = 0;
int duihuanTed = 0;
ActiveNewlywedsVO activeNewlywedsVO = new ActiveNewlywedsVO();
activeNewlywedsVO.setCourtesyReward(new String[0]);
if (ObjectUtils.isNotEmpty(activeNewlyweds)){
LambdaQueryWrapper<ActiveNewlywedsChild> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(ActiveNewlywedsChild::getActiveNewlywedsId,activeNewlyweds.getId());
queryWrapper.orderByDesc(ActiveNewlywedsChild::getCreateTime);
List<ActiveNewlywedsChild> activeNewlywedsChildList = activeNewlywedsChildService.list(queryWrapper);
for (ActiveNewlywedsChild activeNewlywedsChild : activeNewlywedsChildList) {
//优惠券
if (activeNewlywedsChild.getActiveGift().equals("1")){
LambdaQueryWrapper<CardFavorableRecord> queryWrappers = new LambdaQueryWrapper<>();
queryWrappers.eq(CardFavorableRecord::getActiveId,activeNewlywedsChild.getActiveNewlywedsId());
queryWrappers.eq(CardFavorableRecord::getCardFavorableId,activeNewlywedsChild.getVouchersId());
List<CardFavorableRecord> lists = cardFavorableRecordService.list(queryWrappers);
activeNewlywedsVO.setYouhuiTotal(lists.size());
for (CardFavorableRecord cardFavorableRecord : lists) {
if (cardFavorableRecord.getStatus().equals("1")){
youhuiTed+=1;
}
}
}
//兑换券
if (activeNewlywedsChild.getActiveGift().equals("2")){
LambdaQueryWrapper<CardExchangeRecord> queryWrapperss = new LambdaQueryWrapper<>();
queryWrapperss.eq(CardExchangeRecord::getActiveId,activeNewlywedsChild.getActiveNewlywedsId());
queryWrapperss.eq(CardExchangeRecord::getCardExchangeId,activeNewlywedsChild.getVouchersId());
List<CardExchangeRecord> lisst = cardExchangeRecordService.list(queryWrapperss);
activeNewlywedsVO.setDuihuanTotal(lisst.size());
for (CardExchangeRecord cardExchangeRecord : lisst) {
if (cardExchangeRecord.getStatus().equals("1")){
duihuanTed+=1;
}
}
}
}
BeanUtils.copyProperties(activeNewlyweds,activeNewlywedsVO);
//封装VO返回
activeNewlywedsVO.setCourtesyReward(activeNewlyweds.getCourtesyReward().split(","));
activeNewlywedsVO.setYouhuiTotaled(youhuiTed);
activeNewlywedsVO.setDuihuanTotaled(duihuanTed);
if (CollectionUtils.isNotEmpty(activeNewlywedsChildList)){
activeNewlywedsVO.setActiveNewlywedsChildList(activeNewlywedsChildList);
//activeNewlywedsVOS.add(activeNewlywedsVO);
}else {
ArrayList<ActiveNewlywedsChild> activeNewlywedsChildLists = new ArrayList<>();
activeNewlywedsVO.setActiveNewlywedsChildList(activeNewlywedsChildLists);
//activeNewlywedsVOS.add(activeNewlywedsVO);
}
}else {
ArrayList<ActiveNewlywedsChild> activeNewlywedsChildList = new ArrayList<>();
activeNewlywedsVO.setActiveNewlywedsChildList(activeNewlywedsChildList);
activeNewlywedsVO.setDuihuanTotaled(youhuiTed);
activeNewlywedsVO.setDuihuanTotaled(duihuanTed);
activeNewlywedsVO.setDuihuanTotal(0);
activeNewlywedsVO.setDuihuanTotal(0);
//activeNewlywedsVOS.add(activeNewlywedsVO);
}
return activeNewlywedsVO;
}
/**

View File

@ -0,0 +1,92 @@
package com.fuint.business.marketingActivity.activeOneCoupon.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fuint.business.marketingActivity.activeOneCoupon.dtos.ActiveOneCouponDTO;
import com.fuint.business.marketingActivity.activeOneCoupon.entity.ActiveOneCoupon;
import com.fuint.business.marketingActivity.activeOneCoupon.service.ActiveOneCouponService;
import com.fuint.framework.web.BaseController;
import com.fuint.framework.web.ResponseObject;
import org.apache.ibatis.annotations.Param;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.io.Serializable;
import java.util.List;
/**
* 一键发券活动(ActiveOneCoupon)表控制层
*
* @author makejava
* @since 2024-03-02 13:22:50
*/
@RestController
@RequestMapping("business/marketingActivity/oneActiveOneCoupon")
public class ActiveOneCouponController extends BaseController {
/**
* 服务对象
*/
@Resource
private ActiveOneCouponService activeOneCouponService;
/**
* 分页查询所有数据
*
* @param activeOneCoupon 查询实体
* @return 所有数据
*/
@GetMapping
public ResponseObject selectAll(@RequestParam(value = "pageNo",defaultValue = "1") Integer pageNo,
@RequestParam(value = "pageSize",defaultValue = "10") Integer pageSize,
@Param("activeOneCoupon") ActiveOneCoupon activeOneCoupon) {
Page page = new Page(pageNo, pageSize);
return getSuccessResult(this.activeOneCouponService.select(page, new QueryWrapper<>(activeOneCoupon)));
}
/**
* 通过主键查询单条数据
*
* @param id 主键
* @return 单条数据
*/
@GetMapping("{id}")
public ResponseObject selectOne(@PathVariable Serializable id) {
return getSuccessResult(this.activeOneCouponService.getOneById(id));
}
/**
* 新增数据
*
* @param activeOneCouponDTO 实体对象
* @return 新增结果
*/
@PostMapping
public ResponseObject insert(@RequestBody ActiveOneCouponDTO activeOneCouponDTO) {
return getSuccessResult(this.activeOneCouponService.add(activeOneCouponDTO));
}
/**
* 修改数据
*
* @param activeOneCouponDTO 实体对象
* @return 修改结果
*/
@PutMapping
public ResponseObject update(@RequestBody ActiveOneCouponDTO activeOneCouponDTO) {
return getSuccessResult(this.activeOneCouponService.updateOneById(activeOneCouponDTO));
}
/**
* 删除数据
*
* @param idList 主键结合
* @return 删除结果
*/
@DeleteMapping
public ResponseObject delete(@RequestParam("idList") List<Long> idList) {
return getSuccessResult(this.activeOneCouponService.removeByIds(idList));
}
}

View File

@ -0,0 +1,17 @@
package com.fuint.business.marketingActivity.activeOneCoupon.dtos;
import com.fuint.business.marketingActivity.activeOneCoupon.entity.ActiveOneCoupon;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
@Data
public class ActiveOneCouponDTO extends ActiveOneCoupon implements Serializable {
//优惠券ids
private List<Integer> cardFavorableIds;
//兑换券ids
private List<Integer> cardExchangeIds;
//会员等级ids
private Integer[] gradeIds;
}

View File

@ -0,0 +1,46 @@
package com.fuint.business.marketingActivity.activeOneCoupon.entity;
import java.util.Date;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import lombok.Data;
import java.io.Serializable;
/**
* 一键发券活动(ActiveOneCoupon)表实体类
*
* @author makejava
* @since 2024-03-02 13:22:50
*/
@SuppressWarnings("serial")
@Data
public class ActiveOneCoupon extends Model<ActiveOneCoupon> {
//主键id
private Integer id;
private Integer storeId;
private String activeName;
//会员等级id
private String gradeId;
private Integer condition;
//会员等级名字
private String gradeName;
//创建者
private String createBy;
//创建时间
private Date createTime;
//更新者
private String updateBy;
//更新时间
private Date updateTime;
/**
* 获取主键值
*
* @return 主键值
*/
@Override
protected Serializable pkVal() {
return this.id;
}
}

View File

@ -0,0 +1,131 @@
package com.fuint.business.marketingActivity.activeOneCoupon.entity;
import java.util.Date;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import lombok.Data;
import java.io.Serializable;
/**
* 一键发券子表(ActiveOneCouponChild)表实体类
*
* @author makejava
* @since 2024-03-02 13:23:50
*/
@SuppressWarnings("serial")
@Data
public class ActiveOneCouponChild extends Model<ActiveOneCouponChild> {
//主键id
private Integer id;
private Integer storeId;
//消费有礼活动id
private Integer activeConsumptionId;
//活动奖品 0赠送积分1赠送优惠券 2. 赠送兑换券 3赠送成长值 4. 赠送实物
private String activeGift;
//券id
private Integer vouchersId;
//赠送卡券名称
private String giftCardName;
//券详情
private String giftCardDetail;
//创建者
private String createBy;
//创建时间
private Date createTime;
//更新者
private String updateBy;
//更新时间
private Date updateTime;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Integer getActiveConsumptionId() {
return activeConsumptionId;
}
public void setActiveConsumptionId(Integer activeConsumptionId) {
this.activeConsumptionId = activeConsumptionId;
}
public String getActiveGift() {
return activeGift;
}
public void setActiveGift(String activeGift) {
this.activeGift = activeGift;
}
public Integer getVouchersId() {
return vouchersId;
}
public void setVouchersId(Integer vouchersId) {
this.vouchersId = vouchersId;
}
public String getGiftCardName() {
return giftCardName;
}
public void setGiftCardName(String giftCardName) {
this.giftCardName = giftCardName;
}
public String getGiftCardDetail() {
return giftCardDetail;
}
public void setGiftCardDetail(String giftCardDetail) {
this.giftCardDetail = giftCardDetail;
}
public String getCreateBy() {
return createBy;
}
public void setCreateBy(String createBy) {
this.createBy = createBy;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public String getUpdateBy() {
return updateBy;
}
public void setUpdateBy(String updateBy) {
this.updateBy = updateBy;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
/**
* 获取主键值
*
* @return 主键值
*/
@Override
protected Serializable pkVal() {
return this.id;
}
}

View File

@ -0,0 +1,15 @@
package com.fuint.business.marketingActivity.activeOneCoupon.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.fuint.business.marketingActivity.activeOneCoupon.entity.ActiveOneCouponChild;
/**
* 一键发券子表(ActiveOneCouponChild)表数据库访问层
*
* @author makejava
* @since 2024-03-02 13:23:50
*/
public interface ActiveOneCouponChildMapper extends BaseMapper<ActiveOneCouponChild> {
}

View File

@ -0,0 +1,15 @@
package com.fuint.business.marketingActivity.activeOneCoupon.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.fuint.business.marketingActivity.activeOneCoupon.entity.ActiveOneCoupon;
/**
* 一键发券活动(ActiveOneCoupon)表数据库访问层
*
* @author makejava
* @since 2024-03-02 13:22:50
*/
public interface ActiveOneCouponMapper extends BaseMapper<ActiveOneCoupon> {
}

View File

@ -0,0 +1,15 @@
package com.fuint.business.marketingActivity.activeOneCoupon.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.fuint.business.marketingActivity.activeOneCoupon.entity.ActiveOneCouponChild;
/**
* 一键发券子表(ActiveOneCouponChild)表服务接口
*
* @author makejava
* @since 2024-03-02 13:23:50
*/
public interface ActiveOneCouponChildService extends IService<ActiveOneCouponChild> {
}

View File

@ -0,0 +1,29 @@
package com.fuint.business.marketingActivity.activeOneCoupon.service;
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.baomidou.mybatisplus.extension.service.IService;
import com.fuint.business.marketingActivity.activeOneCoupon.dtos.ActiveOneCouponDTO;
import com.fuint.business.marketingActivity.activeOneCoupon.entity.ActiveOneCoupon;
import com.fuint.business.marketingActivity.activeOneCoupon.vo.ActiveOneCouponVO;
import java.io.Serializable;
/**
* 一键发券活动(ActiveOneCoupon)表服务接口
*
* @author makejava
* @since 2024-03-02 13:22:50
*/
public interface ActiveOneCouponService extends IService<ActiveOneCoupon> {
boolean add(ActiveOneCouponDTO activeOneCouponDTO);
IPage select(Page page, QueryWrapper<ActiveOneCoupon> activeOneCouponQueryWrapper);
ActiveOneCouponVO getOneById(Serializable id);
boolean updateOneById(ActiveOneCouponDTO activeOneCouponDTO);
}

View File

@ -0,0 +1,19 @@
package com.fuint.business.marketingActivity.activeOneCoupon.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fuint.business.marketingActivity.activeOneCoupon.mapper.ActiveOneCouponChildMapper;
import com.fuint.business.marketingActivity.activeOneCoupon.entity.ActiveOneCouponChild;
import com.fuint.business.marketingActivity.activeOneCoupon.service.ActiveOneCouponChildService;
import org.springframework.stereotype.Service;
/**
* 一键发券子表(ActiveOneCouponChild)表服务实现类
*
* @author makejava
* @since 2024-03-02 13:23:51
*/
@Service("activeOneCouponChildService")
public class ActiveOneCouponChildServiceImpl extends ServiceImpl<ActiveOneCouponChildMapper, ActiveOneCouponChild> implements ActiveOneCouponChildService {
}

View File

@ -0,0 +1,257 @@
package com.fuint.business.marketingActivity.activeOneCoupon.service.impl;
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.CollectionUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fuint.business.marketingActivity.activeOneCoupon.dtos.ActiveOneCouponDTO;
import com.fuint.business.marketingActivity.activeOneCoupon.entity.ActiveOneCouponChild;
import com.fuint.business.marketingActivity.activeOneCoupon.mapper.ActiveOneCouponMapper;
import com.fuint.business.marketingActivity.activeOneCoupon.entity.ActiveOneCoupon;
import com.fuint.business.marketingActivity.activeOneCoupon.service.ActiveOneCouponChildService;
import com.fuint.business.marketingActivity.activeOneCoupon.service.ActiveOneCouponService;
import com.fuint.business.marketingActivity.activeOneCoupon.vo.ActiveOneCouponVO;
import com.fuint.business.marketingActivity.cardExchange.entity.CardExchange;
import com.fuint.business.marketingActivity.cardExchange.entity.CardExchangeRecord;
import com.fuint.business.marketingActivity.cardExchange.service.CardExchangeRecordService;
import com.fuint.business.marketingActivity.cardExchange.service.CardExchangeService;
import com.fuint.business.marketingActivity.cardFavorable.entity.CardFavorable;
import com.fuint.business.marketingActivity.cardFavorable.entity.CardFavorableRecord;
import com.fuint.business.marketingActivity.cardFavorable.service.CardFavorableRecordService;
import com.fuint.business.marketingActivity.cardFavorable.service.CardFavorableService;
import com.fuint.business.marketingActivity.cardFavorable.vo.LJUserVos;
import com.fuint.business.userManager.service.LJUserService;
import com.fuint.business.userManager.vo.LJUserVo;
import com.fuint.common.dto.AccountInfo;
import com.fuint.common.util.TokenUtil;
import com.fuint.repository.mapper.MtUserGradeMapper;
import com.fuint.repository.model.MtUserGrade;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
/**
* 一键发券活动(ActiveOneCoupon)表服务实现类
*
* @author makejava
* @since 2024-03-02 13:22:50
*/
@Service("activeOneCouponService")
public class ActiveOneCouponServiceImpl extends ServiceImpl<ActiveOneCouponMapper, ActiveOneCoupon> implements ActiveOneCouponService {
@Resource
private MtUserGradeMapper mtUserGradeMapper;
@Resource
private CardFavorableService cardFavorableService;
@Resource
private ActiveOneCouponChildService activeOneCouponChildService;
@Resource
private CardExchangeService exchangeService;
@Resource
private LJUserService userService;
@Resource
private CardFavorableRecordService cardFavorableRecordService;
@Resource
private CardExchangeRecordService cardExchangeRecordService;
@Override
@Transactional
public boolean add(ActiveOneCouponDTO activeOneCouponDTO) {
ActiveOneCouponChild activeOneCouponChild = new ActiveOneCouponChild();
AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo();
boolean flag = false;
ActiveOneCoupon activeOneCoupon = new ActiveOneCoupon();
//会员等级
String gradeIdStr = "";
String gradeIdName = "";
Integer[] gradeIds = activeOneCouponDTO.getGradeIds();
for (Integer gradeId : gradeIds) {
gradeIdStr+=gradeId + ",";
MtUserGrade mtUserGrade = mtUserGradeMapper.selectById(gradeId);
gradeIdName += mtUserGrade.getName() + ",";
}
activeOneCoupon.setGradeId(gradeIdStr);
activeOneCoupon.setGradeName(gradeIdName);
activeOneCoupon.setStoreId(nowAccountInfo.getStoreId());
activeOneCoupon.setCondition(activeOneCouponDTO.getCondition());
flag = save(activeOneCoupon);
//优惠券
List<Integer> cardFavorableIds = activeOneCouponDTO.getCardFavorableIds();
if (ObjectUtils.isNotEmpty(cardFavorableIds)){
for (Integer cardFavorableId : cardFavorableIds) {
activeOneCouponChild.setActiveGift("1");
activeOneCouponChild.setActiveConsumptionId(activeOneCoupon.getId());
activeOneCouponChild.setVouchersId(cardFavorableId);
CardFavorable byId = cardFavorableService.getById(cardFavorableId);
activeOneCouponChild.setGiftCardName(byId.getName());
activeOneCouponChild.setStoreId(nowAccountInfo.getStoreId());
flag = activeOneCouponChildService.save(activeOneCouponChild);
}
}
//兑换券
List<Integer> cardExchangeIds = activeOneCouponDTO.getCardExchangeIds();
if (ObjectUtils.isNotEmpty(cardExchangeIds)){
for (Integer cardExahangeId : cardExchangeIds) {
activeOneCouponChild.setActiveGift("2");
activeOneCouponChild.setActiveConsumptionId(activeOneCoupon.getId());
activeOneCouponChild.setVouchersId(cardExahangeId);
CardExchange byId = exchangeService.getById(cardExahangeId);
activeOneCouponChild.setGiftCardName(byId.getName());
activeOneCouponChild.setStoreId(nowAccountInfo.getStoreId());
flag = activeOneCouponChildService.save(activeOneCouponChild);
}
}
return flag;
}
@Override
public IPage select(Page page, QueryWrapper<ActiveOneCoupon> activeOneCouponQueryWrapper) {
AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo();
LambdaQueryWrapper<ActiveOneCoupon> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(nowAccountInfo.getStoreId() != null, ActiveOneCoupon::getStoreId, nowAccountInfo.getStoreId());
IPage page1 = page(page, queryWrapper);
List<ActiveOneCoupon> records = page1.getRecords();
ArrayList<ActiveOneCouponVO> activeOneCouponVOArrayList = new ArrayList<>();
ArrayList<LJUserVos> userList = new ArrayList<>();
for (ActiveOneCoupon record : records) {
ActiveOneCouponVO activeOneCouponVO = new ActiveOneCouponVO();
BeanUtils.copyProperties(record, activeOneCouponVO);
String gradeIds = record.getGradeId();
//会员存量
String[] gradeId = gradeIds.split(",");
for (String s : gradeId) {
LJUserVos ljUserVos = new LJUserVos();
MtUserGrade mtUserGrade = mtUserGradeMapper.selectById(s);
ljUserVos.setGradeName(mtUserGrade.getName());
LJUserVo ljUserVo = new LJUserVo();
ljUserVo.setGradeId(Integer.parseInt(s));
List<LJUserVo> userLists = userService.getUserCountList(ljUserVo);
ljUserVos.setCountAll(userLists.size());
ljUserVo.setDays(record.getCondition());
List<LJUserVo> userListss = userService.getUserLists(ljUserVo);
ljUserVos.setCount(userListss.size());
if (ObjectUtils.isNotEmpty(ljUserVos.getCountAll()) && ObjectUtils.isNotEmpty(ljUserVos.getCount()) && ljUserVos.getCountAll()!=0){
ljUserVos.setRate(ljUserVos.getCount()/ljUserVos.getCountAll() + "%");
}
userList.add(ljUserVos);
}
//优惠券
LambdaQueryWrapper<CardFavorableRecord> queryWrapper1 = new LambdaQueryWrapper<>();
queryWrapper1.eq(CardFavorableRecord::getExchangeFrom, "店铺一键送券!");
queryWrapper1.eq(CardFavorableRecord::getActiveId, record.getId());
queryWrapper1.eq(CardFavorableRecord::getStoreId, record.getStoreId());
List<CardFavorableRecord> list = cardFavorableRecordService.list(queryWrapper1);
activeOneCouponVO.setCouponReceiveCount(list.size());
queryWrapper1.eq(CardFavorableRecord::getStatus, "1");
List<CardFavorableRecord> list1 = cardFavorableRecordService.list(queryWrapper1);
activeOneCouponVO.setCouponUseCount(list1.size());
//兑换券
LambdaQueryWrapper<CardExchangeRecord> queryWrapper2 = new LambdaQueryWrapper<>();
queryWrapper2.eq(CardExchangeRecord::getExchangeFrom, "店铺一键送券!");
queryWrapper2.eq(CardExchangeRecord::getActiveId, record.getId());
queryWrapper2.eq(CardExchangeRecord::getStoreId, record.getStoreId());
List<CardExchangeRecord> list2 = cardExchangeRecordService.list(queryWrapper2);
activeOneCouponVO.setExchangeReceiveCount(list2.size());
queryWrapper2.eq(CardExchangeRecord::getStatus, "1");
List<CardExchangeRecord> list3 = cardExchangeRecordService.list(queryWrapper2);
activeOneCouponVO.setExchangeUseCount(list3.size());
//活动效果
activeOneCouponVOArrayList.add(activeOneCouponVO);
}
page1.setRecords(activeOneCouponVOArrayList);
return page1;
}
@Override
public ActiveOneCouponVO getOneById(Serializable id) {
AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo();
ActiveOneCouponVO activeOneCouponVO = new ActiveOneCouponVO();
ActiveOneCoupon oneCoupon = getById(id);
BeanUtils.copyProperties(oneCoupon, activeOneCouponVO);
LambdaQueryWrapper<ActiveOneCouponChild> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(ActiveOneCouponChild::getActiveConsumptionId, id);
queryWrapper.eq(ActiveOneCouponChild::getStoreId, nowAccountInfo.getStoreId());
List<ActiveOneCouponChild> activeOneCouponChildren = activeOneCouponChildService.list(queryWrapper);
ArrayList<CardFavorable> cardFavorableArrayList = new ArrayList<>();
ArrayList<CardExchange> cardExchangeArrayList = new ArrayList<>();
for (ActiveOneCouponChild activeOneCouponChild : activeOneCouponChildren) {
//优惠券
if (activeOneCouponChild.getActiveGift().equals("1")){
CardFavorable byId = cardFavorableService.getById(activeOneCouponChild.getVouchersId());
cardFavorableArrayList.add(byId);
}
//兑换券
if (activeOneCouponChild.getActiveGift().equals("2")){
CardExchange byId = exchangeService.getById(activeOneCouponChild.getVouchersId());
cardExchangeArrayList.add(byId);
}
}
activeOneCouponVO.setCardFavorableList(cardFavorableArrayList);
activeOneCouponVO.setCardExchangeList(cardExchangeArrayList);
return activeOneCouponVO;
}
@Override
public boolean updateOneById(ActiveOneCouponDTO activeOneCouponDTO) {
AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo();
boolean flag = false;
ActiveOneCoupon activeOneCoupon = new ActiveOneCoupon();
BeanUtils.copyProperties(activeOneCouponDTO,activeOneCoupon);
flag= updateById(activeOneCoupon);
//更新子表数据
LambdaQueryWrapper<ActiveOneCouponChild> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(ActiveOneCouponChild::getStoreId,nowAccountInfo.getStoreId());
queryWrapper.eq(ActiveOneCouponChild::getActiveConsumptionId,activeOneCoupon.getId());
List<ActiveOneCouponChild> list = activeOneCouponChildService.list(queryWrapper);
if (CollectionUtils.isNotEmpty(list)){
for (ActiveOneCouponChild activeOneCouponChild : list) {
activeOneCouponChildService.removeById(activeOneCouponChild.getId());
}
}
//优惠券
ActiveOneCouponChild activeOneCouponChild = new ActiveOneCouponChild();
List<Integer> cardFavorableIds = activeOneCouponDTO.getCardFavorableIds();
if (ObjectUtils.isNotEmpty(cardFavorableIds)){
for (Integer cardFavorableId : cardFavorableIds) {
activeOneCouponChild.setActiveGift("1");
activeOneCouponChild.setActiveConsumptionId(activeOneCoupon.getId());
activeOneCouponChild.setVouchersId(cardFavorableId);
CardFavorable byId = cardFavorableService.getById(cardFavorableId);
activeOneCouponChild.setGiftCardName(byId.getName());
activeOneCouponChild.setStoreId(nowAccountInfo.getStoreId());
flag = activeOneCouponChildService.save(activeOneCouponChild);
}
}
//兑换券
List<Integer> cardExchangeIds = activeOneCouponDTO.getCardExchangeIds();
if (ObjectUtils.isNotEmpty(cardExchangeIds)){
for (Integer cardExahangeId : cardExchangeIds) {
activeOneCouponChild.setActiveGift("2");
activeOneCouponChild.setActiveConsumptionId(activeOneCoupon.getId());
activeOneCouponChild.setVouchersId(cardExahangeId);
CardExchange byId = exchangeService.getById(cardExahangeId);
activeOneCouponChild.setGiftCardName(byId.getName());
activeOneCouponChild.setStoreId(nowAccountInfo.getStoreId());
flag = activeOneCouponChildService.save(activeOneCouponChild);
}
}
return flag;
}
}

View File

@ -0,0 +1,37 @@
package com.fuint.business.marketingActivity.activeOneCoupon.vo;
import com.fuint.business.marketingActivity.activeOneCoupon.entity.ActiveOneCoupon;
import com.fuint.business.marketingActivity.activeOneCoupon.entity.ActiveOneCouponChild;
import com.fuint.business.marketingActivity.cardExchange.entity.CardExchange;
import com.fuint.business.marketingActivity.cardFavorable.entity.CardFavorable;
import com.fuint.business.marketingActivity.cardFavorable.vo.LJUserVos;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
@Data
public class ActiveOneCouponVO extends ActiveOneCoupon implements Serializable {
private List<LJUserVos> vosList;
//优惠券领取数量
private Integer couponReceiveCount;
//优惠券使用数量
private Integer couponUseCount;
//兑换券领取数量
private Integer exchangeReceiveCount;
//兑换券使用数量
private Integer exchangeUseCount;
//活动效果
//充值
private Double rechargeCount;
//加油
private Double oilCount;
//洗车
private Integer carWashCount;
//商品
private Integer productCount;
private List<ActiveOneCouponChild> activeOneCouponChildren;
private List<CardFavorable> cardFavorableList;
private List<CardExchange> cardExchangeList;
}

View File

@ -50,7 +50,7 @@ public class ActiveRecommendController extends BaseController {
@Param("cardFuelDiesel") ActiveRecommend activeRecommend) {
Page page = new Page(pageNo, pageSize);
activeRecommend.setStoreId(TokenUtil.getNowAccountInfo().getStoreId());
return getSuccessResult(this.activeRecommendService.page(page, new QueryWrapper<>(activeRecommend)));
return getSuccessResult(this.activeRecommendService.select(page, activeRecommend));
}
/**

View File

@ -3,6 +3,7 @@ package com.fuint.business.marketingActivity.activeRecommend.dto;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fuint.business.marketingActivity.activeRecommend.entity.ActiveRecommendChild;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
@ -15,13 +16,20 @@ import java.util.List;
* @since 2023-11-13 15:09:50
*/
@SuppressWarnings("serial")
@Data
public class ActiveRecommendDTO extends Model<ActiveRecommendDTO> {
//主键id
private Integer id;
//所属连锁店id
private Integer chainStoreId;
//新人有礼活动id
private Integer activeNewId;
private String activeNewName;
//所属店铺id
private Integer storeId;
//活动名称
private String activeName;
//活动图片
private String activePictureUrl;
//邀请人获得 0优惠券 1兑换券 2成长值 3积分

View File

@ -32,6 +32,8 @@ public class ActiveRecommend extends Model<ActiveRecommend> {
private String inviterGiftType;
private String activeNewName;
private Integer activeNewId;
//活动名称
private String activeName;
//赠送积分
private Integer points;
//赠送成长值

View File

@ -1,5 +1,7 @@
package com.fuint.business.marketingActivity.activeRecommend.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.activeConsumption.entity.ActiveConsumption;
import com.fuint.business.marketingActivity.activeRecommend.dto.ActiveRecommendDTO;
@ -30,7 +32,7 @@ public interface ActiveRecommendService extends IService<ActiveRecommend> {
* @param id
* @return
*/
List<ActiveRecommendVO> getOneById(Serializable id);
ActiveRecommendVO getOneById(Serializable id);
ActiveRecommendVO getOneByIdApplet(ActiveConsumption activeConsumption);
/**
@ -45,5 +47,7 @@ public interface ActiveRecommendService extends IService<ActiveRecommend> {
* @return
*/
ActiveRecommendAppletVO selectApplet(ActiveConsumption activeConsumption);
IPage select(Page page, ActiveRecommend activeRecommend);
}

View File

@ -1,7 +1,9 @@
package com.fuint.business.marketingActivity.activeRecommend.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.activeConsumption.entity.ActiveConsumption;
import com.fuint.business.marketingActivity.activeRecommend.dto.ActiveRecommendDTO;
@ -102,18 +104,16 @@ public class ActiveRecommendServiceImpl extends ServiceImpl<ActiveRecommendMappe
* @return
*/
@Override
public List<ActiveRecommendVO> getOneById(Serializable id) {
public ActiveRecommendVO getOneById(Serializable id) {
Integer storeId = TokenUtil.getNowAccountInfo().getStoreId();
ArrayList<ActiveRecommendVO> activeRecommendVOS = new ArrayList<>();
if (ObjectUtils.isNotEmpty(storeId)){
//获取新人有礼活动信息
LambdaQueryWrapper<ActiveRecommend> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(ActiveRecommend::getStoreId,TokenUtil.getNowAccountInfo().getStoreId());
//ActiveRecommend activeRecommend = getOne(lambdaQueryWrapper);
List<ActiveRecommend> list = list(lambdaQueryWrapper);
for (ActiveRecommend activeRecommend : list) {
lambdaQueryWrapper.eq(ActiveRecommend::getId,id);
ActiveRecommend activeRecommend = getOne(lambdaQueryWrapper);
//List<ActiveRecommend> list = list(lambdaQueryWrapper);
int youhuiTed = 0;
int duihuanTed = 0;
ActiveRecommendVO activeRecommendVO = new ActiveRecommendVO();
@ -131,7 +131,7 @@ public class ActiveRecommendServiceImpl extends ServiceImpl<ActiveRecommendMappe
queryWrappers.eq(CardFavorableRecord::getActiveId,activeRecommendChild.getActiveRecommendId());
queryWrappers.eq(CardFavorableRecord::getCardFavorableId,activeRecommendChild.getVouchersId());
List<CardFavorableRecord> lists = cardFavorableRecordService.list(queryWrappers);
activeRecommendVO.setYouhuiTotal(list.size());
activeRecommendVO.setYouhuiTotal(lists.size());
for (CardFavorableRecord cardFavorableRecord : lists) {
if (cardFavorableRecord.getStatus().equals("1")){
youhuiTed+=1;
@ -144,7 +144,7 @@ public class ActiveRecommendServiceImpl extends ServiceImpl<ActiveRecommendMappe
queryWrapperss.eq(CardExchangeRecord::getActiveId,activeRecommendChild.getActiveRecommendId());
queryWrapperss.eq(CardExchangeRecord::getCardExchangeId,activeRecommendChild.getVouchersId());
List<CardExchangeRecord> lisst = cardExchangeRecordService.list(queryWrapperss);
activeRecommendVO.setDuihuanTotal(list.size());
activeRecommendVO.setDuihuanTotal(lisst.size());
for (CardExchangeRecord cardExchangeRecord : lisst) {
if (cardExchangeRecord.getStatus().equals("1")){
duihuanTed+=1;
@ -158,11 +158,9 @@ public class ActiveRecommendServiceImpl extends ServiceImpl<ActiveRecommendMappe
activeRecommendVO.setDuihuanTotaled(duihuanTed);
if (CollectionUtils.isNotEmpty(activeRecommendChildList)){
activeRecommendVO.setActiveRecommendChildList(activeRecommendChildList);
activeRecommendVOS.add(activeRecommendVO);
}else {
ArrayList<ActiveRecommendChild> activeRecommendChildren = new ArrayList<>();
activeRecommendVO.setActiveRecommendChildList(activeRecommendChildren);
activeRecommendVOS.add(activeRecommendVO);
}
}else {
ArrayList<ActiveRecommendChild> activeRecommendChildren = new ArrayList<>();
@ -171,11 +169,8 @@ public class ActiveRecommendServiceImpl extends ServiceImpl<ActiveRecommendMappe
activeRecommendVO.setDuihuanTotaled(duihuanTed);
activeRecommendVO.setDuihuanTotal(0);
activeRecommendVO.setDuihuanTotal(0);
activeRecommendVOS.add(activeRecommendVO);
}
}
}
return activeRecommendVOS;
return activeRecommendVO;
}
@ -308,6 +303,83 @@ public class ActiveRecommendServiceImpl extends ServiceImpl<ActiveRecommendMappe
return activeRecommendAppletVO;
}
@Override
public IPage select(Page page, ActiveRecommend activeRecommends) {
Integer storeId = TokenUtil.getNowAccountInfo().getStoreId();
ArrayList<ActiveRecommendVO> activeRecommendVOS = new ArrayList<>();
//获取新人有礼活动信息
LambdaQueryWrapper<ActiveRecommend> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(ActiveRecommend::getStoreId,TokenUtil.getNowAccountInfo().getStoreId());
//ActiveRecommend activeRecommend = getOne(lambdaQueryWrapper);
//List<ActiveRecommend> list = list(lambdaQueryWrapper);
IPage page1 = page(page, lambdaQueryWrapper);
List<ActiveRecommend> list = page1.getRecords();
for (ActiveRecommend activeRecommend : list) {
int youhuiTed = 0;
int duihuanTed = 0;
ActiveRecommendVO activeRecommendVO = new ActiveRecommendVO();
activeRecommendVO.setInviterGiftType(new String[0]);
//获取兑换物品信息
if (ObjectUtils.isNotEmpty(activeRecommend)){
LambdaQueryWrapper<ActiveRecommendChild> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(ActiveRecommendChild::getActiveRecommendId,activeRecommend.getId());
queryWrapper.orderByDesc(ActiveRecommendChild::getCreateTime);
List<ActiveRecommendChild> activeRecommendChildList = activeRecommendChildService.list(queryWrapper);
for (ActiveRecommendChild activeRecommendChild : activeRecommendChildList) {
//优惠券
if (activeRecommendChild.getActiveGift().equals("1")){
LambdaQueryWrapper<CardFavorableRecord> queryWrappers = new LambdaQueryWrapper<>();
queryWrappers.eq(CardFavorableRecord::getActiveId,activeRecommendChild.getActiveRecommendId());
queryWrappers.eq(CardFavorableRecord::getCardFavorableId,activeRecommendChild.getVouchersId());
List<CardFavorableRecord> lists = cardFavorableRecordService.list(queryWrappers);
activeRecommendVO.setYouhuiTotal(list.size());
for (CardFavorableRecord cardFavorableRecord : lists) {
if (cardFavorableRecord.getStatus().equals("1")){
youhuiTed+=1;
}
}
}
//兑换券
if (activeRecommendChild.getActiveGift().equals("2")){
LambdaQueryWrapper<CardExchangeRecord> queryWrapperss = new LambdaQueryWrapper<>();
queryWrapperss.eq(CardExchangeRecord::getActiveId,activeRecommendChild.getActiveRecommendId());
queryWrapperss.eq(CardExchangeRecord::getCardExchangeId,activeRecommendChild.getVouchersId());
List<CardExchangeRecord> lisst = cardExchangeRecordService.list(queryWrapperss);
activeRecommendVO.setDuihuanTotal(list.size());
for (CardExchangeRecord cardExchangeRecord : lisst) {
if (cardExchangeRecord.getStatus().equals("1")){
duihuanTed+=1;
}
}
}
}
BeanUtils.copyProperties(activeRecommend,activeRecommendVO);
activeRecommendVO.setInviterGiftType(activeRecommend.getInviterGiftType().split(","));
activeRecommendVO.setYouhuiTotaled(youhuiTed);
activeRecommendVO.setDuihuanTotaled(duihuanTed);
if (CollectionUtils.isNotEmpty(activeRecommendChildList)){
activeRecommendVO.setActiveRecommendChildList(activeRecommendChildList);
activeRecommendVOS.add(activeRecommendVO);
}else {
ArrayList<ActiveRecommendChild> activeRecommendChildren = new ArrayList<>();
activeRecommendVO.setActiveRecommendChildList(activeRecommendChildren);
activeRecommendVOS.add(activeRecommendVO);
}
}else {
ArrayList<ActiveRecommendChild> activeRecommendChildren = new ArrayList<>();
activeRecommendVO.setActiveRecommendChildList(activeRecommendChildren);
activeRecommendVO.setDuihuanTotaled(youhuiTed);
activeRecommendVO.setDuihuanTotaled(duihuanTed);
activeRecommendVO.setDuihuanTotal(0);
activeRecommendVO.setDuihuanTotal(0);
activeRecommendVOS.add(activeRecommendVO);
}
}
page1.setRecords(list);
return page1;
}
/**
* 数组转字符串
* @param array

View File

@ -22,6 +22,8 @@ public class ActiveRecommendVO extends Model<ActiveRecommendVO> {
private Integer id;
//所属连锁店id
private Integer chainStoreId;
private String activeNewName;
private String activeName;
//所属店铺id
private Integer storeId;
//活动图片

View File

@ -11,10 +11,14 @@ public class CardFavorableAdnUserDTO extends CardFavorable {
private List<Integer> userIds;
//优惠券ids
private List<Integer> cardFavorableIds;
//兑换券ids
private List<Integer> cardExchangeIds;
//等级ID
private List<Integer> gradeIds;
//天数
private Integer days;
//活动id
private Integer activeId;
//优惠卷名称
private String favorableName;

View File

@ -6,14 +6,18 @@ 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.activeDiscountRecords.entity.ActiveDiscountRecords;
import com.fuint.business.marketingActivity.activeDiscountRecords.mapper.ActiveDiscountRecordsMapper;
import com.fuint.business.marketingActivity.activeDiscountRecords.service.ActiveDiscountRecordsService;
import com.fuint.business.marketingActivity.activeExchange.dto.PaymentActiveDTO;
import com.fuint.business.marketingActivity.activeExchange.service.ActiveExchangeService;
import com.fuint.business.marketingActivity.activeExchange.vo.PaymentActiveVO;
import com.fuint.business.marketingActivity.activeFullminusRecords.entity.ActiveFullminusRecords;
import com.fuint.business.marketingActivity.activeFullminusRecords.mapper.ActiveFullminusRecordsMapper;
import com.fuint.business.marketingActivity.activeFullminusRecords.service.ActiveFullminusRecordsService;
import com.fuint.business.marketingActivity.activeOneCoupon.entity.ActiveOneCoupon;
import com.fuint.business.marketingActivity.activeOneCoupon.entity.ActiveOneCouponChild;
import com.fuint.business.marketingActivity.activeOneCoupon.service.ActiveOneCouponChildService;
import com.fuint.business.marketingActivity.activeOneCoupon.service.ActiveOneCouponService;
import com.fuint.business.marketingActivity.cardExchange.entity.CardExchangeRecord;
import com.fuint.business.marketingActivity.cardExchange.service.CardExchangeRecordService;
import com.fuint.business.marketingActivity.cardFavorable.dto.CardFavorableAdnUserDTO;
import com.fuint.business.marketingActivity.cardFavorable.dto.IdListDTO;
import com.fuint.business.marketingActivity.cardFavorable.entity.CardFavorable;
@ -55,20 +59,33 @@ import java.util.Map;
public class CardFavorableRecordServiceImpl extends ServiceImpl<CardFavorableRecordMapper, CardFavorableRecord> implements CardFavorableRecordService {
@Resource
@Lazy
private CardFavorableRecordMapper cardFavorableRecordMapper;
@Resource
private LJUserService userService;
@Resource
@Lazy
private CardFavorableService cardFavorableService;
@Resource
private OilNameService oilNameService;
@Resource
@Lazy
private ActiveFullminusRecordsService activeFullminusRecordsService;
@Resource
@Lazy
private ActiveDiscountRecordsService activeDiscountRecordsService;
@Resource
@Lazy
private ActiveExchangeService activeExchangeService;
@Resource
@Lazy
private CardExchangeRecordService cardExchangeRecordService;
@Resource
@Lazy
private ActiveOneCouponService activeOneCouponService;
@Resource
@Lazy
private ActiveOneCouponChildService activeOneCouponChildService;
/**
* 分页查询所有数据
* @param page
@ -320,37 +337,87 @@ public class CardFavorableRecordServiceImpl extends ServiceImpl<CardFavorableRec
*/
@Override
public boolean issueCardFavorable(CardFavorableAdnUserDTO cardFavorableAdnUserDTO) {
AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo();
Integer activeId = cardFavorableAdnUserDTO.getActiveId();
LambdaQueryWrapper<ActiveOneCoupon> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(ActiveOneCoupon::getId,activeId);
queryWrapper.eq(ActiveOneCoupon::getStoreId,nowAccountInfo.getStoreId());
ActiveOneCoupon activeOneCoupon = activeOneCouponService.getOne(queryWrapper);
String[] split = activeOneCoupon.getGradeId().split(",");
//查询用户列表
ArrayList<LJUserVo> ljUserVosList = new ArrayList<>();
List<Integer> gradeIds = cardFavorableAdnUserDTO.getGradeIds();
for (Integer gradeId : gradeIds) {
// List<Integer> gradeIds = cardFavorableAdnUserDTO.getGradeIds();
for (String gradeId : split) {
LJUserVo ljUserVo = new LJUserVo();
ljUserVo.setGradeId(gradeId);
ljUserVo.setDays(cardFavorableAdnUserDTO.getDays());
ljUserVo.setGradeId(Integer.parseInt(gradeId));
ljUserVo.setDays(activeOneCoupon.getCondition());
List<LJUserVo> userLists = userService.getUserLists(ljUserVo);
ljUserVosList.addAll(userLists);
}
boolean flag = false;
//油站信息
AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo();
//会员ids
//List<Integer> userIds = cardFavorableAdnUserDTO.getUserIds();
//优惠券ids
List<Integer> cardIds = cardFavorableAdnUserDTO.getCardFavorableIds();
for (Integer cardId : cardIds) {
CardFavorableRecord cardFavorableRecord = new CardFavorableRecord();
if (CollectionUtils.isNotEmpty(ljUserVosList)){
for (LJUserVo ljUserVo : ljUserVosList) {
LJUser userInfo = userService.queryUserByUserId(ljUserVo.getId());
cardFavorableRecord.setCardFavorableId(cardId);
cardFavorableRecord.setStoreId(nowAccountInfo.getStoreId());
cardFavorableRecord.setChainStorId(nowAccountInfo.getChainStoreId());
cardFavorableRecord.setName(userInfo.getName());
cardFavorableRecord.setMobile(userInfo.getMobile());
cardFavorableRecord.setStatus("0");
cardFavorableRecord.setExchangeFrom("店铺一键送券!");
flag = addCardFavorableRecord(cardFavorableRecord);
LambdaQueryWrapper<ActiveOneCouponChild> queryWrapper1 = new LambdaQueryWrapper<>();
queryWrapper1.eq(ActiveOneCouponChild::getActiveConsumptionId,activeId);
queryWrapper1.eq(ActiveOneCouponChild::getStoreId,nowAccountInfo.getStoreId());
List<ActiveOneCouponChild> list = activeOneCouponChildService.list(queryWrapper1);
ArrayList<Integer> integers = new ArrayList<>();
for (ActiveOneCouponChild activeOneCouponChild : list) {
if(activeOneCouponChild.getActiveGift().equals("1")){
integers.add(activeOneCouponChild.getVouchersId());
}
}
//List<Integer> cardIds = cardFavorableAdnUserDTO.getCardFavorableIds();
if (ObjectUtils.isNotEmpty(integers)){
for (Integer cardId : integers) {
CardFavorableRecord cardFavorableRecord = new CardFavorableRecord();
if (CollectionUtils.isNotEmpty(ljUserVosList)){
for (LJUserVo ljUserVo : ljUserVosList) {
LJUser userInfo = userService.queryUserByUserId(ljUserVo.getId());
cardFavorableRecord.setCardFavorableId(cardId);
cardFavorableRecord.setStoreId(nowAccountInfo.getStoreId());
cardFavorableRecord.setChainStorId(nowAccountInfo.getChainStoreId());
cardFavorableRecord.setName(userInfo.getName());
cardFavorableRecord.setMobile(userInfo.getMobile());
cardFavorableRecord.setStatus("0");
cardFavorableRecord.setExchangeFrom("店铺一键送券!");
flag = addCardFavorableRecord(cardFavorableRecord);
}
}
}
}
//兑换券ids
LambdaQueryWrapper<ActiveOneCouponChild> queryWrapper2 = new LambdaQueryWrapper<>();
queryWrapper2.eq(ActiveOneCouponChild::getActiveConsumptionId,activeId);
queryWrapper2.eq(ActiveOneCouponChild::getStoreId,nowAccountInfo.getStoreId());
List<ActiveOneCouponChild> lists = activeOneCouponChildService.list(queryWrapper1);
ArrayList<Integer> integerss = new ArrayList<>();
for (ActiveOneCouponChild activeOneCouponChild : lists) {
if(activeOneCouponChild.getActiveGift().equals("2")){
integerss.add(activeOneCouponChild.getVouchersId());
}
}
//List<Integer> exchangeCardIds = cardFavorableAdnUserDTO.getCardExchangeIds();
if (ObjectUtils.isNotEmpty(integerss)){
for (Integer exchangeCardId : integerss) {
if (CollectionUtils.isNotEmpty(ljUserVosList)) {
for (LJUserVo ljUserVo : ljUserVosList) {
CardExchangeRecord cardExchangeRecord = new CardExchangeRecord();
cardExchangeRecord.setCardExchangeId(exchangeCardId);
cardExchangeRecord.setStoreId(nowAccountInfo.getStoreId());
cardExchangeRecord.setMtUserId(ljUserVo.getId());
cardExchangeRecord.setName(ljUserVo.getName());
cardExchangeRecord.setMobile(ljUserVo.getMobile());
cardExchangeRecord.setPhoto(ljUserVo.getAvatar());
cardExchangeRecord.setStatus("0");
cardExchangeRecord.setExchangeFrom("店铺一键送券!");
flag = cardExchangeRecordService.addCardExchangeRecord(cardExchangeRecord);
}
}
}
}