From ac9a9743d185d46ec7dca7577402dfef6a553eed Mon Sep 17 00:00:00 2001
From: 101captain <237651143@qq.com>
Date: 星期三, 27 四月 2022 11:09:00 +0800
Subject: [PATCH] Merge branch 'huacheng' of http://gitlab.nhys.cdnhxx.com/root/zhihuishequ into huacheng
---
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/McsInformationServiceImpl.java | 205 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 202 insertions(+), 3 deletions(-)
diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/McsInformationServiceImpl.java b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/McsInformationServiceImpl.java
index c45fb66..0139e47 100644
--- a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/McsInformationServiceImpl.java
+++ b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/McsInformationServiceImpl.java
@@ -1,13 +1,32 @@
package com.panzhihua.service_community.service.impl;
+import static java.util.Objects.isNull;
+import static java.util.Objects.nonNull;
+
+import java.util.Date;
+
+import javax.annotation.Resource;
+
+import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.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.impl.ServiceImpl;
+import com.panzhihua.common.model.dtos.community.microCommercialStreet.McsInfoDTO;
import com.panzhihua.common.model.dtos.community.microCommercialStreet.PageMcsInformationDTO;
import com.panzhihua.common.model.dtos.community.microCommercialStreet.SetShelfForInfoDTO;
import com.panzhihua.common.model.vos.R;
+import com.panzhihua.common.model.vos.community.microCommercialStreet.McsInformationVO;
+import com.panzhihua.common.model.vos.community.microCommercialStreet.McsMerchantVO;
+import com.panzhihua.common.model.vos.community.microCommercialStreet.TopStatisticsVO;
+import com.panzhihua.common.utlis.DateUtils;
+import com.panzhihua.service_community.dao.McsGameDAO;
import com.panzhihua.service_community.dao.McsInformationDAO;
+import com.panzhihua.service_community.dao.McsMerchantDAO;
import com.panzhihua.service_community.entity.McsInformation;
+import com.panzhihua.service_community.entity.McsMerchant;
import com.panzhihua.service_community.service.McsInformationService;
/**
@@ -20,6 +39,11 @@
public class McsInformationServiceImpl extends ServiceImpl<McsInformationDAO, McsInformation>
implements McsInformationService {
+ @Resource
+ private McsGameDAO mcsGameDAO;
+ @Resource
+ private McsMerchantDAO mcsMerchantDAO;
+
/**
* 分页查询戳戳资讯
* @param pageMcsInformationDTO
@@ -27,7 +51,11 @@
*/
@Override
public R pageMcsInfo(PageMcsInformationDTO pageMcsInformationDTO) {
- return null;
+ Page page = new Page<>();
+ page.setSize(pageMcsInformationDTO.getPageSize());
+ page.setCurrent(pageMcsInformationDTO.getPageNum());
+ IPage<McsInformationVO> mcsInfos = this.baseMapper.pageMcsInfo(page, pageMcsInformationDTO);
+ return R.ok(mcsInfos);
}
/**
@@ -37,7 +65,31 @@
*/
@Override
public R setShelfForMcsInfo(SetShelfForInfoDTO setShelfForInfoDTO) {
- return null;
+ McsInformation mcsInformation = this.baseMapper.selectById(setShelfForInfoDTO.getInfoId());
+ if (isNull(mcsInformation)) {
+ return R.fail("修改数据不存在");
+ }
+ Integer type = setShelfForInfoDTO.getType();
+ if (type.equals(1)) {
+ //上架
+ McsMerchant mcsMerchant = mcsMerchantDAO.selectById(mcsInformation.getMerchantId());
+ Integer publishLimit = mcsMerchant.getPublishLimit();
+ Integer publishCount = mcsGameDAO.selectPublishCount(mcsInformation.getMerchantId());
+ if (publishCount >= publishLimit) {
+ return R.fail("空闲戳戳点不足");
+ }
+ mcsInformation.setStatus(2);
+ } else if (type.equals(2)) {
+ //下架
+ mcsInformation.setStatus(3);
+ } else {
+ return R.fail("未知错误");
+ }
+ int num = this.baseMapper.updateById(mcsInformation);
+ if (num > 0) {
+ return R.ok();
+ }
+ return R.fail("修改失败,请重新尝试");
}
/**
@@ -48,6 +100,153 @@
*/
@Override
public R deleteMcsInfo(Long infoId, Long userId) {
- return null;
+ McsInformation mcsInformation = this.baseMapper.selectById(infoId);
+ if (isNull(mcsInformation)) {
+ return R.fail("修改数据不存在");
+ }
+ mcsInformation.setIsDel(true);
+ mcsInformation.setStatus(McsInformation.Status.yxj);
+ mcsInformation.setUpdatedBy(userId);
+ int num = this.baseMapper.updateById(mcsInformation);
+ if (num > 0) {
+ return R.ok();
+ }
+ return R.fail("删除失败,请重新尝试");
+ }
+
+ /**
+ * 戳戳资讯顶部统计数据
+ * @param userId
+ * @return
+ */
+ @Override
+ public R getTopStatistics(Long userId) {
+ McsMerchant mcsMerchant = mcsMerchantDAO.selectOne(new QueryWrapper<McsMerchant>().lambda().eq(McsMerchant::getUserId, userId));
+ if (isNull(mcsMerchant)) {
+ return R.fail("未查询到商家信息");
+ }
+ TopStatisticsVO topStatisticsVO = new TopStatisticsVO();
+ topStatisticsVO.setExpireAt(mcsMerchant.getExpireAt());
+ if (nonNull(mcsMerchant.getExpireAt())) {
+ int surplusLitDays = DateUtils.retrieveRemainingDays(mcsMerchant.getExpireAt());
+ topStatisticsVO.setSurplusLitDays(surplusLitDays > 0 ? surplusLitDays : 0);
+ }
+
+ Integer publishLimit = mcsMerchant.getPublishLimit();
+ Integer publishCount = mcsGameDAO.selectPublishCount(mcsMerchant.getId());
+ Integer idleTotal = publishLimit - publishCount;
+ topStatisticsVO.setIdleTotal(idleTotal > 0 ? idleTotal : 0);
+ return R.ok(topStatisticsVO);
+ }
+
+ /**
+ * 新增戳戳资讯
+ * @param mcsInfoDTO
+ * @return
+ */
+ @Override
+ public R addMcsInfo(McsInfoDTO mcsInfoDTO) {
+ Long userId = mcsInfoDTO.getCreatedBy();
+ McsMerchant mcsMerchant = mcsMerchantDAO.selectOne(new QueryWrapper<McsMerchant>().lambda().eq(McsMerchant::getUserId, userId));
+ if (isNull(mcsMerchant)) {
+ return R.fail("未查询到商家信息");
+ }
+ McsInformation mcsInformation = new McsInformation();
+ BeanUtils.copyProperties(mcsInfoDTO, mcsInformation);
+ mcsInformation.setMerchantId(mcsMerchant.getId());
+ mcsInformation.setStatus(McsInformation.Status.wfb);
+ int num = this.baseMapper.insert(mcsInformation);
+ if (num > 0) {
+ return R.ok();
+ }
+ return R.fail("新增失败,请重新尝试");
+ }
+
+ /**
+ * 编辑戳戳资讯
+ * @param mcsInfoDTO
+ * @return
+ */
+ @Override
+ public R putMcsInfo(McsInfoDTO mcsInfoDTO) {
+ McsInformation mcsInformation = this.baseMapper.selectById(mcsInfoDTO.getId());
+ if (isNull(mcsInformation)) {
+ return R.fail("资源不存在");
+ }
+ BeanUtils.copyProperties(mcsInfoDTO, mcsInformation);
+ int num = this.baseMapper.updateById(mcsInformation);
+ if (num > 0) {
+ return R.ok();
+ }
+ return R.fail("编辑失败,请重新尝试");
+ }
+
+ /**
+ * 发布戳戳资讯
+ * @param infoId
+ * @param userId
+ * @return
+ */
+ @Override
+ public R publishMcsInfo(Long infoId, Long userId) {
+ McsInformation mcsInformation = this.baseMapper.selectById(infoId);
+ if (isNull(mcsInformation)) {
+ return R.fail("资源不存在");
+ }
+ McsMerchant mcsMerchant = mcsMerchantDAO.selectById(mcsInformation.getMerchantId());
+ Integer publishLimit = mcsMerchant.getPublishLimit();
+ Integer publishCount = mcsGameDAO.selectPublishCount(mcsInformation.getMerchantId());
+ if (publishCount >= publishLimit) {
+ return R.fail("空闲戳戳点不足");
+ }
+ mcsInformation.setStatus(McsInformation.Status.yfb);
+ mcsInformation.setPublishAt(new Date());
+ int num = this.baseMapper.updateById(mcsInformation);
+ if (num > 0) {
+ return R.ok();
+ }
+ return R.fail("发布失败,请重新尝试");
+ }
+
+ /**
+ * h5分页查询戳戳资讯
+ * @param pageMcsInformationDTO
+ * @return
+ */
+ @Override
+ public R pageH5McsInfo(PageMcsInformationDTO pageMcsInformationDTO) {
+ Page page = new Page<>();
+ page.setSize(pageMcsInformationDTO.getPageSize());
+ page.setCurrent(pageMcsInformationDTO.getPageNum());
+ IPage<McsInformationVO> mcsInfos = this.baseMapper.pageH5McsInfo(page, pageMcsInformationDTO);
+ return R.ok(mcsInfos);
+ }
+
+ /**
+ * 资讯详情
+ * @param infoId
+ * @return
+ */
+ @Override
+ public R getMcsInfo(Long infoId) {
+ McsInformation mcsInformation = this.baseMapper.selectById(infoId);
+ if (isNull(mcsInformation)) {
+ return R.fail("资源不存在");
+ }
+ McsInformationVO mcsInformationVO = new McsInformationVO();
+ BeanUtils.copyProperties(mcsInformation, mcsInformationVO);
+ McsMerchant mcsMerchant = mcsMerchantDAO.selectById(mcsInformation.getMerchantId());
+ McsMerchantVO mcsMerchantVO = new McsMerchantVO();
+ if (nonNull(mcsMerchant)) {
+ mcsMerchantVO.setId(mcsMerchant.getId());
+ mcsMerchantVO.setName(mcsMerchant.getName());
+ mcsMerchantVO.setLogo(mcsMerchant.getLogo());
+ mcsMerchantVO.setIntroduction(mcsMerchant.getIntroduction());
+ mcsMerchantVO.setLat(mcsMerchant.getLat());
+ mcsMerchantVO.setLon(mcsMerchant.getLon());
+ mcsMerchantVO.setAddress(mcsMerchant.getAddress());
+ }
+ mcsInformationVO.setMerchantInfo(mcsMerchantVO);
+ return R.ok(mcsInformationVO);
}
}
--
Gitblit v1.7.1