Browse Source

Merge branch 'seo-target' of wangfan/adweb3-server into master

wangfan 1 month ago
parent
commit
76bcf594c2

+ 3 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/seo/mapper/SeoKeywordsSerpMapper.java

@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.jeecg.modules.adweb.seo.entity.SeoKeywordsSerp;
 import org.jeecg.modules.adweb.seo.vo.KeywordsInfoVO;
 
+import java.util.Date;
 import java.util.List;
 
 /**
@@ -22,4 +23,6 @@ public interface SeoKeywordsSerpMapper extends BaseMapper<SeoKeywordsSerp> {
     SeoKeywordsSerp getLatestSeoKeywordSerp(int keywordId);
 
     List<KeywordsInfoVO> getSeoKeywordsRank(String siteCode, String date, Integer keywordsType, Integer limit);
+
+    Date getAchieveDate(String siteCode, int target, int appointKeywordNum, int longTailKeywordNum);
 }

+ 34 - 8
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/seo/mapper/xml/SeoKeywordsSerpMapper.xml

@@ -13,24 +13,50 @@
         se_date DESC
         LIMIT 1
     </select>
+
     <select id="getSeoKeywordsRank" resultType="org.jeecg.modules.adweb.seo.vo.KeywordsInfoVO">
         SELECT
-            t2.keywords,t1.keywords_id,t2.domain as position_url,t1.rank_absolute as lastRank,t1.se_datetime,t2.keyword_type
+        t2.keywords,t1.keywords_id,t2.domain as position_url,t1.rank_absolute as lastRank,t1.se_datetime,t2.keyword_type
         FROM adweb_seo_keywords_serp t1,
-             adweb_seo_keywords t2
+        adweb_seo_keywords t2
         WHERE
-            t1.keywords_id = t2.id
+        t1.keywords_id = t2.id
         AND
-            t2.site_code = #{siteCode}
+        t2.site_code = #{siteCode}
         AND
-            t2.keyword_type = #{keywordsType}
+        t2.keyword_type = #{keywordsType}
         AND
-            t1.rank_absolute > 0
+        t1.rank_absolute > 0
         AND
-            date(t1.se_datetime) = #{date}
+        date(t1.se_datetime) = #{date}
         ORDER BY
-            t1.rank_absolute
+        t1.rank_absolute
         LIMIT #{limit}
     </select>
 
+    <select id="getAchieveDate" resultType="java.util.Date">
+        SELECT
+        MIN(t3.se_date)
+        FROM
+        (
+        SELECT
+        SUM(t1.keyword_type = 1) appointKeywordNum,
+        SUM(t1.keyword_type = 2) longTailKeywordNum,
+        t2.se_date
+        FROM
+        adweb_seo_keywords t1,
+        adweb_seo_keywords_serp t2
+        WHERE
+        t1.id = t2.keywords_id
+        AND t2.rank_absolute >= 1
+        AND IF(t1.keyword_type = 1, #{target}, #{target}) >= t2.rank_absolute
+        AND t1.site_code = #{siteCode}
+        GROUP BY
+        t2.se_date
+        ) t3
+        WHERE
+        t3.appointKeywordNum >= #{appointKeywordNum}
+        AND t3.longTailKeywordNum >= #{longTailKeywordNum}
+    </select>
+
 </mapper>

+ 14 - 9
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/seo/service/impl/SeoKeywordsRankServiceImpl.java

@@ -5,8 +5,6 @@ import static org.jeecg.modules.adweb.seo.dto.ComprehensiveStatistics.KeywordRan
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.xkcoding.http.util.StringUtil;
 
-import jakarta.annotation.Resource;
-
 import lombok.extern.slf4j.Slf4j;
 
 import org.apache.commons.collections4.CollectionUtils;
@@ -21,11 +19,13 @@ import org.jeecg.modules.adweb.seo.dto.ComprehensiveStatistics;
 import org.jeecg.modules.adweb.seo.entity.SeoKeywords;
 import org.jeecg.modules.adweb.seo.entity.SeoKeywordsSerp;
 import org.jeecg.modules.adweb.seo.mapper.SeoKeywordsMapper;
+import org.jeecg.modules.adweb.seo.mapper.SeoKeywordsSerpMapper;
 import org.jeecg.modules.adweb.seo.service.ISeoKeywordsRankService;
 import org.jeecg.modules.adweb.seo.service.ISeoKeywordsSerpService;
 import org.jeecg.modules.adweb.seo.service.ISeoKeywordsService;
 import org.jeecg.modules.adweb.seo.vo.RankInfoVO;
 import org.jeecg.modules.adweb.seo.vo.SeoRankInfoVO;
+import org.jeecg.modules.adweb.seo.vo.ServiceTimeVO;
 import org.jeecg.modules.adweb.site.entity.AdwebSite;
 import org.jeecg.modules.adweb.site.service.IAdwebSiteService;
 import org.jeecg.modules.adweb.site.service.ISiteUserPermissionService;
@@ -42,10 +42,7 @@ import java.util.*;
 import java.util.stream.Collectors;
 
 /**
- * @Description: seo_kpi_statistics
- * @Author: jeecg-boot
- * @Date: 2024-10-09
- * @Version: V1.0
+ * @Description: seo_kpi_statistics @Author: jeecg-boot @Date: 2024-10-09 @Version: V1.0
  */
 @Service
 @Slf4j
@@ -53,7 +50,7 @@ public class SeoKeywordsRankServiceImpl implements ISeoKeywordsRankService {
 
     @Autowired private IAdwebSiteService adwebSiteService;
 
-    @Resource private SysAdwebApi sysAdwebApi;
+    @Autowired private SysAdwebApi sysAdwebApi;
 
     @Autowired private ISiteUserPermissionService siteUserPermissionService;
 
@@ -61,11 +58,13 @@ public class SeoKeywordsRankServiceImpl implements ISeoKeywordsRankService {
 
     @Autowired private ISeoKeywordsService seoKeywordsService;
 
-    @Resource private SeoKeywordsMapper seoKeywordsMapper;
+    @Autowired private SeoKeywordsMapper seoKeywordsMapper;
+
+    @Autowired private SeoKeywordsSerpMapper seoKeywordsSerpMapper;
 
     @Autowired private ISeoKeywordsSerpService seoKeywordsSerpService;
 
-    @Resource private SubscribePlanMapper subscribePlanMapper;
+    @Autowired private SubscribePlanMapper subscribePlanMapper;
 
     @Override
     public List<AdwebSite> getAllSites() {
@@ -191,6 +190,12 @@ public class SeoKeywordsRankServiceImpl implements ISeoKeywordsRankService {
         Map map = new HashMap<>();
         map.put("appointKeyword", seoRankInfos.get(0));
         map.put("longTailKeyword", seoRankInfos.get(1));
+
+        // TODO - 获取达标时间和剩余服务时间
+        if (userPlanSubscription.getKeywordsAchieveTime() == null) {
+            seoKeywordsSerpMapper.getAchieveDate(siteCode, 10, 10, 10);
+        }
+        map.put("serviceTime", new ServiceTimeVO());
         return map;
     }
 

+ 4 - 4
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/seo/vo/ServerTimeVO.java → jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/seo/vo/ServiceTimeVO.java

@@ -5,10 +5,10 @@ import lombok.Data;
 import java.util.Date;
 
 @Data
-public class ServerTimeVO {
-    private String reachStandardTime;
-    private int reachStandardDays;
-    private int remainServerDays;
+public class ServiceTimeVO {
+    private String reachTargetTime;
+    private int reachTargetDays;
+    private int remainServiceDays;
 
     // 是否自定义结束日期 0:否 1:是
     private int planServiceEndStatus;

+ 1 - 1
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/subscription/mapper/UserPlanSubscriptionMapper.java

@@ -20,7 +20,7 @@ public interface UserPlanSubscriptionMapper extends BaseMapper<UserPlanSubscript
      * @param siteCode 站点code
      * @return 达标标准
      */
-    int getKeywordStandard(String siteCode);
+    int getKeywordTarget(String siteCode);
 
     /**
      * 根据站点id,查询站点的营销方案

+ 1 - 1
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/subscription/mapper/xml/UserPlanSubscriptionMapper.xml

@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="org.jeecg.modules.adweb.subscription.mapper.UserPlanSubscriptionMapper">
-    <select id="getKeywordStandard" resultType="java.lang.Integer">
+    <select id="getKeywordTarget" resultType="java.lang.Integer">
         SELECT
         IF(COUNT(*) = 0 OR t1.target IS NULL, 10, t1.target)
         FROM