PoTetherServiceImpl.java 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. package com.ruoyi.system.service.impl;
  2. import java.util.ArrayList;
  3. import java.util.Date;
  4. import java.util.List;
  5. import java.util.stream.Collectors;
  6. import com.ruoyi.common.constant.UserConstants;
  7. import com.ruoyi.common.utils.DateUtils;
  8. import com.ruoyi.common.utils.StringUtils;
  9. import com.ruoyi.common.utils.bean.BeanUtils;
  10. import com.ruoyi.system.domain.PoCollection;
  11. import com.ruoyi.system.domain.PoNews;
  12. import com.ruoyi.system.domain.PoTetherandcollection;
  13. import com.ruoyi.system.domain.vo.TetherVo;
  14. import org.springframework.beans.factory.annotation.Autowired;
  15. import org.springframework.stereotype.Service;
  16. import com.ruoyi.system.mapper.PoTetherMapper;
  17. import com.ruoyi.system.domain.PoTether;
  18. import com.ruoyi.system.service.IPoTetherService;
  19. /**
  20. * 套系Service业务层处理
  21. *
  22. * @author ruoyi
  23. * @date 2023-02-12
  24. */
  25. @Service
  26. public class PoTetherServiceImpl implements IPoTetherService
  27. {
  28. @Autowired
  29. private PoTetherMapper poTetherMapper;
  30. /**
  31. * 在售
  32. * @param poTether 套系 在售
  33. * @return
  34. */
  35. @Override
  36. public List<PoTether> selectPoTetherSellingList(PoTether poTether)
  37. {
  38. return poTetherMapper.selectPoTetherSellingList(poTether);
  39. }
  40. /**
  41. * 按照标题和时间搜索
  42. * @param tetherName
  43. * @param tetherTimeStart
  44. * @param tetherTimeEnd
  45. * @return
  46. */
  47. @Override
  48. public List<PoTether> selectListByTitleAndTime(String tetherName, Date tetherTimeStart, Date tetherTimeEnd) {
  49. if (tetherName != null) {
  50. //标题不为空且开始时间和结束时间都不为空
  51. if (tetherTimeStart != null && tetherTimeEnd != null) {
  52. if (DateUtils.getNowDate().before(tetherTimeEnd)){
  53. tetherTimeEnd = DateUtils.getNowDate();
  54. }
  55. if (tetherTimeStart.before(tetherTimeEnd)) {
  56. return poTetherMapper.selectPoTetherListByTitleAndTetherTimeStartAndTetherTimeEnd(tetherName, tetherTimeStart, tetherTimeEnd);
  57. } else{
  58. //有一个时间不为空返回提示信息
  59. List list = new ArrayList();
  60. list.add("请选择正确的时间段");
  61. return list;
  62. }
  63. } else {//时间都为空
  64. return poTetherMapper.selectPoTetherListByTitleAndTetherTimeStartAndTetherTimeEnd(tetherName,tetherTimeStart,tetherTimeEnd);
  65. }
  66. }
  67. //标题为空
  68. else {
  69. //时间不为空
  70. if (tetherTimeStart != null && tetherTimeEnd != null) {
  71. if (tetherTimeStart.before(tetherTimeEnd)){
  72. return poTetherMapper.selectPoTetherListByTitleAndTetherTimeStartAndTetherTimeEnd(tetherName,tetherTimeStart,tetherTimeEnd);
  73. }else{
  74. //有一个时间不为空返回提示信息
  75. List list = new ArrayList();
  76. list.add("请选择正确的时间段");
  77. return list;
  78. }
  79. }
  80. }
  81. //都为空执行分页查询
  82. PoTether poTether = new PoTether();
  83. return poTetherMapper.selectPoTetherList(poTether);
  84. }
  85. /**
  86. * 预售
  87. * @param poTether
  88. * @return
  89. */
  90. @Override
  91. public List<PoTether> selectPoTetherAdvanceList(PoTether poTether) {
  92. return poTetherMapper.selectPoTetherAdvanceList(poTether);
  93. }
  94. /**
  95. * 已过期
  96. * @param poTether
  97. * @return
  98. */
  99. @Override
  100. public List<PoTether> selectPoTetherSelledList(PoTether poTether) {
  101. return poTetherMapper.selectPoTetherSelledList(poTether);
  102. }
  103. /**
  104. * 查询套系列表
  105. * @param poTether
  106. * @return
  107. */
  108. @Override
  109. public List<PoTether> selectPoTetherList(PoTether poTether) {
  110. return poTetherMapper.selectPoTetherList(poTether);
  111. }
  112. /**
  113. * 藏品按钮
  114. * @param
  115. * @return
  116. */
  117. @Override
  118. public List<PoTetherandcollection> selectPoCollectionListById(Long tetherId) {
  119. return poTetherMapper.selectPoCollectionListById(tetherId);
  120. }
  121. /**
  122. * 新增套系 同时保存对应的藏品数据
  123. *
  124. * @param tetherVo
  125. * @return
  126. */
  127. @Override
  128. public boolean insertPoTetherWithCollection(TetherVo tetherVo) {
  129. //保存套系的基本数据到套系表tether
  130. this.poTetherMapper.insertPoTether(tetherVo);
  131. Long tetherId = tetherVo.getTetherId();
  132. //套系包含藏品
  133. List<PoTetherandcollection> poCollections = tetherVo.getPoTetherandcollections();
  134. poCollections.stream().map((item)->{
  135. item.setTetherId(tetherId);
  136. return item;
  137. }).collect(Collectors.toList());
  138. //保存藏品数据到藏品表 po_collection
  139. //后续添加代码
  140. return true;
  141. }
  142. /**
  143. * 通过id查询套系信息和对应的藏品信息
  144. * @param tetherId
  145. * @return
  146. */
  147. @Override
  148. public TetherVo selectPoTetherByTetherIdWithCollection(Long tetherId) {
  149. //查询套系基本信息 po_tether
  150. PoTether poTether = this.poTetherMapper.selectPoTetherByTetherId(tetherId);
  151. TetherVo tetherVo = new TetherVo();
  152. if (poTether != null) {
  153. BeanUtils.copyProperties(poTether, tetherVo);
  154. }
  155. //查询当前套系对应的藏品信息
  156. //后续添加代码
  157. return tetherVo;
  158. }
  159. /**
  160. * 修改套系信息
  161. * @param tetherVo
  162. * @return
  163. */
  164. @Override
  165. public boolean updatePoTetherWithCollection(TetherVo tetherVo) {
  166. //更新po_tether表基本信息
  167. this.poTetherMapper.updatePoTether(tetherVo);
  168. //清理po_collection表数据
  169. //添加当前提交过来的藏品数据--po_tether表的insert操作
  170. return true;
  171. }
  172. /**
  173. * 同时删除套系和藏品的关联关系
  174. * @param tetherIds
  175. * @return
  176. */
  177. @Override
  178. public boolean deletePoTetherByTetherIdsWithCollection(Long[] tetherIds) {
  179. //查询藏品状态确认是否可以删除
  180. //如果可以删除 先删除套系po_tether表中的数据
  181. this.poTetherMapper.deletePoTetherByTetherIds(tetherIds);
  182. //删除po_collection表中的数据
  183. return true;
  184. }
  185. /**
  186. * 校验套系名称是否存在
  187. * @param tetherVo
  188. * @return
  189. */
  190. @Override
  191. public String checkPostTetherNameUnique(TetherVo tetherVo) {
  192. Long tetherId = StringUtils.isNull(tetherVo.getTetherId()) ? -1L : tetherVo.getTetherId();
  193. PoTether info = poTetherMapper.checkPostTetherTitleUnique(tetherVo.getTetherName());
  194. if (StringUtils.isNotNull(info) && info.getTetherId() != tetherId) {
  195. return UserConstants.NOT_UNIQUE;
  196. }
  197. return UserConstants.UNIQUE;
  198. }
  199. /**
  200. * 检验图片是否重复
  201. * @param tetherVo
  202. * @return
  203. */
  204. @Override
  205. public String checkPostTetherImageUnique(TetherVo tetherVo) {
  206. Long tetherId = StringUtils.isNull(tetherVo.getTetherId()) ? -1L : tetherVo.getTetherId();
  207. PoTether info = poTetherMapper.checkPostTetherImageUnique(tetherVo.getImage());
  208. if (StringUtils.isNotNull(info) && info.getTetherId() != tetherId) {
  209. return UserConstants.NOT_UNIQUE;
  210. }
  211. return UserConstants.UNIQUE;
  212. }
  213. /**
  214. * 批量查询套系信息
  215. * @param tetherIds
  216. * @return
  217. */
  218. @Override
  219. public TetherVo selectPoTetherByTetherIdsWithCollection(Long[] tetherIds) {
  220. //查询套系基本信息 po_tether
  221. PoTether poTether = this.poTetherMapper.selectPoTetherByTetherIds(tetherIds);
  222. TetherVo tetherVo = new TetherVo();
  223. if (poTether != null) {
  224. BeanUtils.copyProperties(poTether, tetherVo);
  225. }
  226. //查询当前套系对应的藏品信息
  227. //后续添加代码
  228. return tetherVo;
  229. }
  230. /**
  231. * 修改状态 是否上链
  232. * @param cochain
  233. * @param tetherId
  234. * @return
  235. */
  236. @Override
  237. public boolean updatePoTetherIsCochain(Integer cochain, Long tetherId) {
  238. return poTetherMapper.updatePoTetherIsCochain(cochain,tetherId);
  239. }
  240. /**
  241. * 修改状态 是否上架
  242. * @param grounding
  243. * @param tetherId
  244. * @return
  245. */
  246. @Override
  247. public boolean updatePoTetherIsGrounding(Integer grounding, Long tetherId) {
  248. return poTetherMapper.updatePoTetherIsGrounding(grounding, tetherId);
  249. }
  250. /**
  251. * 藏品种类个数
  252. * @param poTether
  253. * @return
  254. */
  255. @Override
  256. public List<PoTether> selectPoTetherCollectionList(PoTether poTether) {
  257. poTetherMapper.updatePostTetherCollection(poTether);
  258. return poTetherMapper.selectPoTetherCollectionList(poTether);
  259. }
  260. }