This commit is contained in:
齐天大圣 2024-03-12 15:51:04 +08:00
parent 918efbd372
commit c0a282e71c
7 changed files with 190 additions and 37 deletions

View File

@ -31,11 +31,24 @@ public class ActiveAppletController extends BaseController {
* @param activeApplet 查询实体
* @return 所有数据
*/
@GetMapping("/applet")
@GetMapping("/appletActive")
public ResponseObject selectAll(ActiveApplet activeApplet) {
return getSuccessResult(this.activeAppletService.applet(activeApplet));
}
/**
* 查询所有数据
*
* @param activeApplet 查询实体
* @return 所有数据
*/
@GetMapping("/appletActiveByType")
public ResponseObject appletActiveByType(ActiveApplet activeApplet) {
return getSuccessResult(this.activeAppletService.appletActiveByType(activeApplet));
}
/**
* 通过主键查询单条数据
*

View File

@ -2,6 +2,9 @@ package com.fuint.business.marketingActivity.activeApplet.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.fuint.business.marketingActivity.activeApplet.entity.ActiveApplet;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 小程序端活动表(ActiveApplet)表数据库访问层
@ -11,5 +14,8 @@ import com.fuint.business.marketingActivity.activeApplet.entity.ActiveApplet;
*/
public interface ActiveAppletMapper extends BaseMapper<ActiveApplet> {
List<ActiveApplet> selectApplet(@Param("cardValueRecord") ActiveApplet activeApplet);
List<ActiveApplet> appletActiveByType(@Param("cardValueRecord")ActiveApplet activeApplet);
}

View File

@ -14,5 +14,6 @@ import java.util.List;
public interface ActiveAppletService extends IService<ActiveApplet> {
List<ActiveApplet> applet(ActiveApplet activeApplet);
List<ActiveApplet> appletActiveByType(ActiveApplet activeApplet);
}

View File

@ -6,6 +6,7 @@ import com.fuint.business.marketingActivity.activeApplet.entity.ActiveApplet;
import com.fuint.business.marketingActivity.activeApplet.service.ActiveAppletService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
/**
@ -17,9 +18,17 @@ import java.util.List;
@Service("activeAppletService")
public class ActiveAppletServiceImpl extends ServiceImpl<ActiveAppletMapper, ActiveApplet> implements ActiveAppletService {
@Resource
private ActiveAppletMapper activeAppletMapper;
@Override
public List<ActiveApplet> applet(ActiveApplet activeApplet) {
return null;
return activeAppletMapper.selectApplet();
}
@Override
public List<ActiveApplet> appletActiveByType(ActiveApplet activeApplet) {
return activeAppletMapper.appletActiveByType(activeApplet);
}
}

View File

@ -2,8 +2,11 @@ package com.fuint.business.marketingActivity.activeRecommend.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fuint.business.marketingActivity.activeApplet.entity.ActiveApplet;
import com.fuint.business.marketingActivity.activeApplet.service.ActiveAppletService;
import com.fuint.business.marketingActivity.activeConsumption.entity.ActiveConsumption;
import com.fuint.business.marketingActivity.activeNewlyweds.entity.ActiveNewlyweds;
import com.fuint.business.marketingActivity.activeRecommend.dto.ActiveRecommendDTO;
@ -19,6 +22,7 @@ import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
/**
* 推荐有礼表(ActiveRecommend)表控制层
@ -36,6 +40,8 @@ public class ActiveRecommendController extends BaseController {
private ActiveRecommendService activeRecommendService;
@Resource
private ActiveRecommendChildService activeRecommendChildService;
@Resource
private ActiveAppletService activeAppletService;
/**
* 分页查询所有数据
@ -84,6 +90,19 @@ public class ActiveRecommendController extends BaseController {
return getSuccessResult(this.activeRecommendService.add(activeRecommendDTO));
}
/**
* 修改数据
*
* @param map 实体对象
* @return 修改结果
*/
@PostMapping("/edit")
public ResponseObject updateIsOnline(@RequestBody Map<String,String> map) {
Integer id = Integer.valueOf(map.get("id"));
String isonline = map.get("isonline");
return getSuccessResult(this.activeRecommendService.updateIsonline(id,isonline));
}
/**
* 修改数据
*
@ -112,6 +131,11 @@ public class ActiveRecommendController extends BaseController {
*/
@DeleteMapping("delById/{ids}")
public ResponseObject delete(@PathVariable Long ids) {
LambdaQueryWrapper<ActiveApplet> queryWrapper1 = new LambdaQueryWrapper<>();
queryWrapper1.eq(ActiveApplet::getStoreId, TokenUtil.getNowAccountInfo().getStoreId());
queryWrapper1.eq(ActiveApplet::getActiveId,ids);
queryWrapper1.eq(ActiveApplet::getType,"7");
activeAppletService.remove(queryWrapper1);
return getSuccessResult(this.activeRecommendService.removeById(ids));
}

View File

@ -34,6 +34,13 @@ public interface ActiveRecommendService extends IService<ActiveRecommend> {
*/
ActiveRecommendVO getOneById(Serializable id);
List<ActiveRecommendVO> getOneByIdApplet(ActiveConsumption activeConsumption);
/**
* 修改下线
* @param id
* @param isonline
* @return
*/
Boolean updateIsonline(Integer id,String isonline);
/**
* 修改数据

View File

@ -6,7 +6,11 @@ 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.activeApplet.entity.ActiveApplet;
import com.fuint.business.marketingActivity.activeApplet.service.ActiveAppletService;
import com.fuint.business.marketingActivity.activeConsumption.entity.ActiveConsumption;
import com.fuint.business.marketingActivity.activeNewlyweds.entity.ActiveNewlyweds;
import com.fuint.business.marketingActivity.activeNewlyweds.entity.ActiveNewlywedsChild;
import com.fuint.business.marketingActivity.activeRecommend.dto.ActiveRecommendDTO;
import com.fuint.business.marketingActivity.activeRecommend.entity.ActiveRecommendChild;
import com.fuint.business.marketingActivity.activeRecommend.mapper.ActiveRecommendMapper;
@ -66,6 +70,8 @@ public class ActiveRecommendServiceImpl extends ServiceImpl<ActiveRecommendMappe
@Resource
private CardExchangeMapper cardExchangeMapper;
@Resource
private ActiveAppletService activeAppletService;
/**
* 新增数据
* @param activeRecommendDTO
@ -75,7 +81,8 @@ public class ActiveRecommendServiceImpl extends ServiceImpl<ActiveRecommendMappe
@Transactional
public Boolean add(ActiveRecommendDTO activeRecommendDTO) {
boolean save = false;
Integer storeId = TokenUtil.getNowAccountInfo().getStoreId();
ActiveApplet activeApplet = new ActiveApplet();
activeApplet.setStoreId(TokenUtil.getNowAccountInfo().getStoreId());
//根据店铺id查询
/* LambdaQueryWrapper<ActiveRecommend> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(ActiveRecommend::getStoreId,storeId);
@ -100,6 +107,33 @@ public class ActiveRecommendServiceImpl extends ServiceImpl<ActiveRecommendMappe
activeRecommend.setId(null);
save = save(activeRecommend);
}
activeApplet.setActiveId(activeRecommend.getId());
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy.MM.dd");
String formatSt = dateFormat.format(activeRecommend.getActiveStartTime());
String formatEd = dateFormat.format(activeRecommend.getActiveEndTime());
activeApplet.setTime(formatSt+"-" + formatEd+"");
if (ObjectUtils.isNotEmpty(activeRecommend.getPoints())){
activeApplet.setPoints(activeRecommend.getPoints());
}
if (ObjectUtils.isNotEmpty(activeRecommend.getGrowthValue())){
activeApplet.setGrowaValue(activeRecommend.getGrowthValue());
}
activeApplet.setType("7");
activeApplet.setName("推荐有礼活动");
//赠送优惠券兑换券实物
String card = "";
if (CollectionUtils.isNotEmpty(activeRecommendDTO.getActiveRecommendChildList())) {
for (ActiveRecommendChild activeRecommendChild : activeRecommendDTO.getActiveRecommendChildList()) {
card += activeRecommendChild.getGiftCardDetail() + "的券,";
}
}
activeApplet.setDiscountActiveDescribe("此项推荐有礼活动,推荐即可获得积分:"+activeApplet.getPoints()+"积分,成长值:"+activeApplet.getGrowaValue()+"成长值,赠送券为:"+card+"");
activeAppletService.save(activeApplet);
//礼品
List<ActiveRecommendChild> list = activeRecommendDTO.getActiveRecommendChildList();
if (CollectionUtils.isNotEmpty(list)) {
@ -114,6 +148,77 @@ public class ActiveRecommendServiceImpl extends ServiceImpl<ActiveRecommendMappe
return save;
}
/**
* 修改数据
* @param activeRecommendDTO
* @return
*/
@Override
@Transactional
public Boolean updateOneById(ActiveRecommendDTO activeRecommendDTO) {
boolean update = false;
LambdaQueryWrapper<ActiveApplet> queryWrapper1 = new LambdaQueryWrapper<>();
queryWrapper1.eq(ActiveApplet::getStoreId,TokenUtil.getNowAccountInfo().getStoreId());
queryWrapper1.eq(ActiveApplet::getType,"7");
queryWrapper1.eq(ActiveApplet::getActiveId,activeRecommendDTO.getId());
ActiveApplet activeApplet = activeAppletService.getOne(queryWrapper1);
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy.MM.dd");
String formatSt = dateFormat.format(activeRecommendDTO.getActiveStartTime());
String formatEd = dateFormat.format(activeRecommendDTO.getActiveEndTime());
activeApplet.setTime(formatSt+"-" + formatEd+"");
if (ObjectUtils.isNotEmpty(activeRecommendDTO.getPoints())){
activeApplet.setPoints(activeRecommendDTO.getPoints());
}
if (ObjectUtils.isNotEmpty(activeRecommendDTO.getGrowthValue())){
activeApplet.setGrowaValue(activeRecommendDTO.getGrowthValue());
}
activeApplet.setType("7");
activeApplet.setName("推荐有礼活动");
//赠送优惠券兑换券实物
String card = "";
if (CollectionUtils.isNotEmpty(activeRecommendDTO.getActiveRecommendChildList())) {
for (ActiveRecommendChild activeRecommendChild : activeRecommendDTO.getActiveRecommendChildList()) {
card += activeRecommendChild.getGiftCardDetail() + "的券,";
}
}
activeApplet.setDiscountActiveDescribe("此项推荐有礼活动,推荐即可获得积分:"+activeApplet.getPoints()+"积分,成长值:"+activeApplet.getGrowaValue()+"成长值,赠送券为:"+card+"");
activeAppletService.updateById(activeApplet);
//更新推荐有礼活动
ActiveRecommend activeRecommend = new ActiveRecommend();
BeanUtils.copyProperties(activeRecommendDTO,activeRecommend);
TAccount accountInfoById = accountService.getAccountInfoById(TokenUtil.getNowAccountInfo().getId());
if (ObjectUtil.isNotEmpty(accountInfoById)) activeRecommend.setCreateBy(accountInfoById.getRealName());
//柴油会员等级
if (ObjectUtil.isNotEmpty(activeRecommendDTO.getInviterGiftType()))
activeRecommend.setInviterGiftType(arrayToString(activeRecommendDTO.getInviterGiftType()));
if (activeRecommendDTO.getStatus().equals("0")) activeRecommend.setIsonline("0");
if (activeRecommendDTO.getStatus().equals("2")) activeRecommend.setIsonline("1");
update = updateById(activeRecommend);
//更新子表数据
LambdaQueryWrapper<ActiveRecommendChild> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(ActiveRecommendChild::getActiveRecommendId,activeRecommendDTO.getId());
activeRecommendChildService.remove(queryWrapper);
//新增兑换物品
List<ActiveRecommendChild> activeRecommendChildList = activeRecommendDTO.getActiveRecommendChildList();
if (CollectionUtils.isNotEmpty(activeRecommendChildList)){
activeRecommendChildList.stream().map(s ->{
s.setActiveRecommendId(activeRecommend.getId());
return s;
}).collect(Collectors.toList());
update = activeRecommendChildService.saveBatch(activeRecommendChildList);
}
return update;
}
/**
* 通过店铺id查询单条数据
* @param id
@ -214,6 +319,28 @@ public class ActiveRecommendServiceImpl extends ServiceImpl<ActiveRecommendMappe
return activeRecommendVO;
}
@Override
@Transactional
public Boolean updateIsonline(Integer id, String isonline) {
int row = 0;
ActiveRecommend activeRecommend = baseMapper.selectById(id);
if (ObjectUtil.isNotEmpty(activeRecommend)){
activeRecommend.setStatus("2");
activeRecommend.setIsonline(isonline);
row = baseMapper.updateById(activeRecommend);
}
LambdaQueryWrapper<ActiveApplet> queryWrapper1 = new LambdaQueryWrapper<>();
queryWrapper1.eq(ActiveApplet::getStoreId, TokenUtil.getNowAccountInfo().getStoreId());
queryWrapper1.eq(ActiveApplet::getActiveId,id);
queryWrapper1.eq(ActiveApplet::getType,"7");
ActiveApplet activeApplet = activeAppletService.getOne(queryWrapper1);
activeApplet.setIsonline(isonline);
activeAppletService.updateById(activeApplet);
return row == 1;
}
/**
* 通过店铺id查询单条数据(小程序端)
@ -259,41 +386,7 @@ public class ActiveRecommendServiceImpl extends ServiceImpl<ActiveRecommendMappe
return arrayList;
}
/**
* 修改数据
* @param activeRecommendDTO
* @return
*/
@Override
public Boolean updateOneById(ActiveRecommendDTO activeRecommendDTO) {
boolean update = false;
//更新推荐有礼活动
ActiveRecommend activeRecommend = new ActiveRecommend();
BeanUtils.copyProperties(activeRecommendDTO,activeRecommend);
TAccount accountInfoById = accountService.getAccountInfoById(TokenUtil.getNowAccountInfo().getId());
if (ObjectUtil.isNotEmpty(accountInfoById)) activeRecommend.setCreateBy(accountInfoById.getRealName());
//柴油会员等级
if (ObjectUtil.isNotEmpty(activeRecommendDTO.getInviterGiftType()))
activeRecommend.setInviterGiftType(arrayToString(activeRecommendDTO.getInviterGiftType()));
if (activeRecommendDTO.getStatus().equals("0")) activeRecommend.setIsonline("0");
if (activeRecommendDTO.getStatus().equals("2")) activeRecommend.setIsonline("1");
update = updateById(activeRecommend);
//更新子表数据
LambdaQueryWrapper<ActiveRecommendChild> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(ActiveRecommendChild::getActiveRecommendId,activeRecommendDTO.getId());
activeRecommendChildService.remove(queryWrapper);
//新增兑换物品
List<ActiveRecommendChild> activeRecommendChildList = activeRecommendDTO.getActiveRecommendChildList();
if (CollectionUtils.isNotEmpty(activeRecommendChildList)){
activeRecommendChildList.stream().map(s ->{
s.setActiveRecommendId(activeRecommend.getId());
return s;
}).collect(Collectors.toList());
update = activeRecommendChildService.saveBatch(activeRecommendChildList);
}
return update;
}
/**
* 查询单条数据(小程序端)