From 43f0578e80af82ecae6c61b51bd0539c6b960603 Mon Sep 17 00:00:00 2001
From: puhanshu <a9236326>
Date: 星期二, 16 八月 2022 19:08:32 +0800
Subject: [PATCH] 服务范围优化

---
 springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/McsGameServiceImpl.java |   61 ++++++++++++++++--------------
 1 files changed, 33 insertions(+), 28 deletions(-)

diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/McsGameServiceImpl.java b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/McsGameServiceImpl.java
index f3fc3c2..67f7d1c 100644
--- a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/McsGameServiceImpl.java
+++ b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/McsGameServiceImpl.java
@@ -2,7 +2,6 @@
 
 import static java.util.Objects.isNull;
 import static java.util.Objects.nonNull;
-import static org.apache.commons.lang3.StringUtils.isNotEmpty;
 
 import java.util.ArrayList;
 import java.util.Date;
@@ -11,15 +10,9 @@
 
 import javax.annotation.Resource;
 
-import com.panzhihua.common.model.vos.community.microCommercialStreet.McsCouponVO;
-import com.panzhihua.common.utlis.Snowflake;
-import com.panzhihua.service_community.dao.McsEvaluateDAO;
-import com.panzhihua.service_community.entity.McsCoupon;
-import com.panzhihua.service_community.util.NearbyUtil;
-import com.panzhihua.service_community.util.QRCodeUtil;
-import com.spatial4j.core.shape.Rectangle;
 import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -30,16 +23,20 @@
 import com.panzhihua.common.model.dtos.community.microCommercialStreet.SetPopularForGameDTO;
 import com.panzhihua.common.model.dtos.community.microCommercialStreet.SetShelfForGameDTO;
 import com.panzhihua.common.model.vos.R;
+import com.panzhihua.common.model.vos.community.microCommercialStreet.McsCouponVO;
 import com.panzhihua.common.model.vos.community.microCommercialStreet.McsGameVO;
 import com.panzhihua.common.model.vos.community.microCommercialStreet.TopStatisticsVO;
 import com.panzhihua.common.utlis.DateUtils;
+import com.panzhihua.common.utlis.Snowflake;
 import com.panzhihua.service_community.dao.McsCouponDAO;
+import com.panzhihua.service_community.dao.McsEvaluateDAO;
 import com.panzhihua.service_community.dao.McsGameDAO;
 import com.panzhihua.service_community.dao.McsMerchantDAO;
+import com.panzhihua.service_community.entity.McsCoupon;
 import com.panzhihua.service_community.entity.McsGame;
 import com.panzhihua.service_community.entity.McsMerchant;
 import com.panzhihua.service_community.service.McsGameService;
-import org.springframework.transaction.annotation.Transactional;
+import com.panzhihua.service_community.util.QRCodeUtil;
 
 /**
  * (McsGame)表服务实现类
@@ -319,10 +316,11 @@
     /**
      * 戳戳游戏顶部统计数据
      * @param userId
+     * @param type
      * @return
      */
     @Override
-    public R getTopStatistics(Long userId) {
+    public R getTopStatistics(Long userId, Integer type) {
         McsMerchant mcsMerchant = mcsMerchantDAO.selectOne(new QueryWrapper<McsMerchant>().lambda().eq(McsMerchant::getUserId, userId));
         if (isNull(mcsMerchant)) {
             return R.fail("未查询到商家信息");
@@ -333,9 +331,9 @@
             int surplusLitDays = DateUtils.retrieveRemainingDays(mcsMerchant.getExpireAt());
             topStatisticsVO.setSurplusLitDays(surplusLitDays > 0 ? surplusLitDays : 0);
         }
-        Integer appliedCount = this.baseMapper.selectAppliedCount(mcsMerchant.getId());
+        Integer appliedCount = this.baseMapper.selectAppliedCount(mcsMerchant.getId(), type);
         topStatisticsVO.setAppliedTotal(appliedCount);
-        Integer verifiedCount = this.baseMapper.selectVerifiedCount(mcsMerchant.getId());
+        Integer verifiedCount = this.baseMapper.selectVerifiedCount(mcsMerchant.getId(), type);
         topStatisticsVO.setVerifiedTotal(verifiedCount);
 
         Integer publishLimit = mcsMerchant.getPublishLimit();
@@ -392,9 +390,13 @@
             //体验游戏
             Integer awardType = mcsGame.getAwardType();
             if (awardType.equals(1)) {
-                mcsCoupon.setAward("免费产品");
+                mcsCoupon.setAward("免费领");
+            } else if (awardType.equals(2)) {
+                mcsCoupon.setAward("产品试用");
+            } else if (awardType.equals(3)) {
+                mcsCoupon.setAward("消费赠礼");
             } else {
-                mcsCoupon.setAward("免费服务");
+                mcsCoupon.setAward("优惠券");
             }
         }
         int num = mcsCouponDAO.insert(mcsCoupon);
@@ -421,19 +423,7 @@
         Page page = new Page<>();
         page.setSize(pageMcsGameDTO.getPageSize());
         page.setCurrent(pageMcsGameDTO.getPageNum());
-        String lat = pageMcsGameDTO.getLat();
-        String lon = pageMcsGameDTO.getLon();
-        Integer distance = pageMcsGameDTO.getDistance();
-        IPage<McsGameVO> mcsGames;
-        if (isNotEmpty(lat) && isNotEmpty(lon) && nonNull(distance)) {
-            Rectangle rectangle = new NearbyUtil().getRectangle(pageMcsGameDTO.getDistance(),
-                    Double.parseDouble(pageMcsGameDTO.getLon()), Double.parseDouble(pageMcsGameDTO.getLat()));
-            mcsGames = this.baseMapper.pageH5McsGame(page, rectangle.getMinX(), rectangle.getMaxX(),
-                    rectangle.getMinY(), rectangle.getMaxY(), pageMcsGameDTO);
-        } else {
-            mcsGames = this.baseMapper.pageH5McsGame(page, null, null, null, null, pageMcsGameDTO);
-        }
-
+        IPage<McsGameVO> mcsGames = this.baseMapper.pageH5McsGame(page, pageMcsGameDTO);
         return R.ok(mcsGames);
     }
 
@@ -446,11 +436,26 @@
     public R getMcsGame(Long gameId) {
         McsGameVO mcsGameVO = this.baseMapper.selectDetailById(gameId);
         Integer gameCount = this.baseMapper.selectCount(new QueryWrapper<McsGame>().lambda()
-                .eq(McsGame::getMerchantId, mcsGameVO.getMerchantId()).eq(McsGame::getStatus, McsGame.Status.jxz).eq(McsGame::getIsDel, false));
+                .eq(McsGame::getMerchantId, mcsGameVO.getMerchantId()).eq(McsGame::getStatus, McsGame.Status.jxz)
+                .eq(McsGame::getType, mcsGameVO.getType()).eq(McsGame::getIsDel, false));
         mcsGameVO.setGameCount(gameCount);
         return R.ok(mcsGameVO);
     }
 
+    /**
+     * 定时任务-每隔5分钟执行一次,将已到期的微商业街游戏结束
+     * @return
+     */
+    @Override
+    public R endStatusForMcsGame() {
+        List<McsGame> games = this.baseMapper.selectNeedDealExpire();
+        if (nonNull(games) && !games.isEmpty()) {
+            games.forEach(e -> e.setStatus(McsGame.Status.yjs));
+            this.updateBatchById(games);
+        }
+        return R.ok();
+    }
+
     public static void main(String[] args) {
         int total = 500;
         int people = 10;

--
Gitblit v1.7.1