123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292 |
- package com.ruoyi.system.service.impl;
- import java.util.ArrayList;
- import java.util.Date;
- import java.util.List;
- import java.util.stream.Collectors;
- import com.ruoyi.common.constant.UserConstants;
- import com.ruoyi.common.utils.DateUtils;
- import com.ruoyi.common.utils.StringUtils;
- import com.ruoyi.common.utils.bean.BeanUtils;
- import com.ruoyi.system.domain.PoCollection;
- import com.ruoyi.system.domain.PoNews;
- import com.ruoyi.system.domain.PoTetherandcollection;
- import com.ruoyi.system.domain.vo.TetherVo;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import com.ruoyi.system.mapper.PoTetherMapper;
- import com.ruoyi.system.domain.PoTether;
- import com.ruoyi.system.service.IPoTetherService;
- /**
- * 套系Service业务层处理
- *
- * @author ruoyi
- * @date 2023-02-12
- */
- @Service
- public class PoTetherServiceImpl implements IPoTetherService
- {
- @Autowired
- private PoTetherMapper poTetherMapper;
- /**
- * 在售
- * @param poTether 套系 在售
- * @return
- */
- @Override
- public List<PoTether> selectPoTetherSellingList(PoTether poTether)
- {
- return poTetherMapper.selectPoTetherSellingList(poTether);
- }
- /**
- * 按照标题和时间搜索
- * @param tetherName
- * @param tetherTimeStart
- * @param tetherTimeEnd
- * @return
- */
- @Override
- public List<PoTether> selectListByTitleAndTime(String tetherName, Date tetherTimeStart, Date tetherTimeEnd) {
- if (tetherName != null) {
- //标题不为空且开始时间和结束时间都不为空
- if (tetherTimeStart != null && tetherTimeEnd != null) {
- if (DateUtils.getNowDate().before(tetherTimeEnd)){
- tetherTimeEnd = DateUtils.getNowDate();
- }
- if (tetherTimeStart.before(tetherTimeEnd)) {
- return poTetherMapper.selectPoTetherListByTitleAndTetherTimeStartAndTetherTimeEnd(tetherName, tetherTimeStart, tetherTimeEnd);
- } else{
- //有一个时间不为空返回提示信息
- List list = new ArrayList();
- list.add("请选择正确的时间段");
- return list;
- }
- } else {//时间都为空
- return poTetherMapper.selectPoTetherListByTitleAndTetherTimeStartAndTetherTimeEnd(tetherName,tetherTimeStart,tetherTimeEnd);
- }
- }
- //标题为空
- else {
- //时间不为空
- if (tetherTimeStart != null && tetherTimeEnd != null) {
- if (tetherTimeStart.before(tetherTimeEnd)){
- return poTetherMapper.selectPoTetherListByTitleAndTetherTimeStartAndTetherTimeEnd(tetherName,tetherTimeStart,tetherTimeEnd);
- }else{
- //有一个时间不为空返回提示信息
- List list = new ArrayList();
- list.add("请选择正确的时间段");
- return list;
- }
- }
- }
- //都为空执行分页查询
- PoTether poTether = new PoTether();
- return poTetherMapper.selectPoTetherList(poTether);
- }
- /**
- * 预售
- * @param poTether
- * @return
- */
- @Override
- public List<PoTether> selectPoTetherAdvanceList(PoTether poTether) {
- return poTetherMapper.selectPoTetherAdvanceList(poTether);
- }
- /**
- * 已过期
- * @param poTether
- * @return
- */
- @Override
- public List<PoTether> selectPoTetherSelledList(PoTether poTether) {
- return poTetherMapper.selectPoTetherSelledList(poTether);
- }
- /**
- * 查询套系列表
- * @param poTether
- * @return
- */
- @Override
- public List<PoTether> selectPoTetherList(PoTether poTether) {
- return poTetherMapper.selectPoTetherList(poTether);
- }
- /**
- * 藏品按钮
- * @param
- * @return
- */
- @Override
- public List<PoTetherandcollection> selectPoCollectionListById(Long tetherId) {
- return poTetherMapper.selectPoCollectionListById(tetherId);
- }
- /**
- * 新增套系 同时保存对应的藏品数据
- *
- * @param tetherVo
- * @return
- */
- @Override
- public boolean insertPoTetherWithCollection(TetherVo tetherVo) {
- //保存套系的基本数据到套系表tether
- this.poTetherMapper.insertPoTether(tetherVo);
- Long tetherId = tetherVo.getTetherId();
- //套系包含藏品
- List<PoTetherandcollection> poCollections = tetherVo.getPoTetherandcollections();
- poCollections.stream().map((item)->{
- item.setTetherId(tetherId);
- return item;
- }).collect(Collectors.toList());
- //保存藏品数据到藏品表 po_collection
- //后续添加代码
- return true;
- }
- /**
- * 通过id查询套系信息和对应的藏品信息
- * @param tetherId
- * @return
- */
- @Override
- public TetherVo selectPoTetherByTetherIdWithCollection(Long tetherId) {
- //查询套系基本信息 po_tether
- PoTether poTether = this.poTetherMapper.selectPoTetherByTetherId(tetherId);
- TetherVo tetherVo = new TetherVo();
- if (poTether != null) {
- BeanUtils.copyProperties(poTether, tetherVo);
- }
- //查询当前套系对应的藏品信息
- //后续添加代码
- return tetherVo;
- }
- /**
- * 修改套系信息
- * @param tetherVo
- * @return
- */
- @Override
- public boolean updatePoTetherWithCollection(TetherVo tetherVo) {
- //更新po_tether表基本信息
- this.poTetherMapper.updatePoTether(tetherVo);
- //清理po_collection表数据
- //添加当前提交过来的藏品数据--po_tether表的insert操作
- return true;
- }
- /**
- * 同时删除套系和藏品的关联关系
- * @param tetherIds
- * @return
- */
- @Override
- public boolean deletePoTetherByTetherIdsWithCollection(Long[] tetherIds) {
- //查询藏品状态确认是否可以删除
- //如果可以删除 先删除套系po_tether表中的数据
- this.poTetherMapper.deletePoTetherByTetherIds(tetherIds);
- //删除po_collection表中的数据
- return true;
- }
- /**
- * 校验套系名称是否存在
- * @param tetherVo
- * @return
- */
- @Override
- public String checkPostTetherNameUnique(TetherVo tetherVo) {
- Long tetherId = StringUtils.isNull(tetherVo.getTetherId()) ? -1L : tetherVo.getTetherId();
- PoTether info = poTetherMapper.checkPostTetherTitleUnique(tetherVo.getTetherName());
- if (StringUtils.isNotNull(info) && info.getTetherId() != tetherId) {
- return UserConstants.NOT_UNIQUE;
- }
- return UserConstants.UNIQUE;
- }
- /**
- * 检验图片是否重复
- * @param tetherVo
- * @return
- */
- @Override
- public String checkPostTetherImageUnique(TetherVo tetherVo) {
- Long tetherId = StringUtils.isNull(tetherVo.getTetherId()) ? -1L : tetherVo.getTetherId();
- PoTether info = poTetherMapper.checkPostTetherImageUnique(tetherVo.getImage());
- if (StringUtils.isNotNull(info) && info.getTetherId() != tetherId) {
- return UserConstants.NOT_UNIQUE;
- }
- return UserConstants.UNIQUE;
- }
- /**
- * 批量查询套系信息
- * @param tetherIds
- * @return
- */
- @Override
- public TetherVo selectPoTetherByTetherIdsWithCollection(Long[] tetherIds) {
- //查询套系基本信息 po_tether
- PoTether poTether = this.poTetherMapper.selectPoTetherByTetherIds(tetherIds);
- TetherVo tetherVo = new TetherVo();
- if (poTether != null) {
- BeanUtils.copyProperties(poTether, tetherVo);
- }
- //查询当前套系对应的藏品信息
- //后续添加代码
- return tetherVo;
- }
- /**
- * 修改状态 是否上链
- * @param cochain
- * @param tetherId
- * @return
- */
- @Override
- public boolean updatePoTetherIsCochain(Integer cochain, Long tetherId) {
- return poTetherMapper.updatePoTetherIsCochain(cochain,tetherId);
- }
- /**
- * 修改状态 是否上架
- * @param grounding
- * @param tetherId
- * @return
- */
- @Override
- public boolean updatePoTetherIsGrounding(Integer grounding, Long tetherId) {
- return poTetherMapper.updatePoTetherIsGrounding(grounding, tetherId);
- }
- /**
- * 藏品种类个数
- * @param poTether
- * @return
- */
- @Override
- public List<PoTether> selectPoTetherCollectionList(PoTether poTether) {
- poTetherMapper.updatePostTetherCollection(poTether);
- return poTetherMapper.selectPoTetherCollectionList(poTether);
- }
- }
|