Selaa lähdekoodia

Merge branch 'master' into cpq-dev

chenlei1231 1 kuukausi sitten
vanhempi
commit
31e186404d
37 muutettua tiedostoa jossa 977 lisäystä ja 875 poistoa
  1. BIN
      conf/adweb_v3.sql.zip
  2. 11 11
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/seo/controller/SeoKeywordsController.java
  3. 3 3
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/seo/controller/SeoKeywordsRankController.java
  4. 0 171
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/seo/controller/SeoPlanSubscriptionController.java
  5. 25 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/seo/dto/ComprehensiveStatistics.java
  6. 55 20
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/seo/mapper/SeoKeywordsMapper.java
  7. 3 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/seo/mapper/SeoKeywordsSerpMapper.java
  8. 0 36
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/seo/mapper/SeoPlanSubscriptionMapper.java
  9. 34 24
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/seo/mapper/xml/SeoKeywordsMapper.xml
  10. 34 8
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/seo/mapper/xml/SeoKeywordsSerpMapper.xml
  11. 0 18
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/seo/mapper/xml/SeoPlanSubscriptionMapper.xml
  12. 5 4
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/seo/service/ISeoKeywordsRankService.java
  13. 4 3
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/seo/service/ISeoKeywordsService.java
  14. 0 38
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/seo/service/ISeoPlanSubscriptionService.java
  15. 105 74
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/seo/service/impl/SeoKeywordsRankServiceImpl.java
  16. 12 12
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/seo/service/impl/SeoKeywordsServiceImpl.java
  17. 0 191
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/seo/service/impl/SeoPlanSubscriptionServiceImpl.java
  18. 4 4
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/seo/vo/ServiceTimeVO.java
  19. 5 5
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/site/controller/AdwebSiteController.java
  20. 3 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/site/dto/result/SiteBasicInfo.java
  21. 21 17
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/site/service/SelfWebSiteServiceCommon.java
  22. 30 28
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/site/service/SiteManageService.java
  23. 0 18
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/subscribePlan/mapper/xml/SubscribePlanMapper.xml
  24. 26 21
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/subscription/controller/SubscribePlanController.java
  25. 172 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/subscription/controller/UserPlanSubscriptionController.java
  26. 56 79
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/subscription/entity/SubscribePlan.java
  27. 56 79
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/subscription/entity/UserPlanSubscription.java
  28. 2 2
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/subscription/mapper/SubscribePlanMapper.java
  29. 35 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/subscription/mapper/UserPlanSubscriptionMapper.java
  30. 18 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/subscription/mapper/xml/SubscribePlanMapper.xml
  31. 18 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/subscription/mapper/xml/UserPlanSubscriptionMapper.xml
  32. 2 2
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/subscription/service/ISubscribePlanService.java
  33. 39 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/subscription/service/IUserPlanSubscriptionService.java
  34. 4 4
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/subscription/service/impl/SubscribePlanServiceImpl.java
  35. 192 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/subscription/service/impl/UserPlanSubscriptionServiceImpl.java
  36. 2 2
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/mapper/xml/SysDictMapper.xml
  37. 1 1
      jeecg-module-system/jeecg-system-start/src/main/resources/application-prod.yml

BIN
conf/adweb_v3.sql.zip


+ 11 - 11
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/seo/controller/SeoKeywordsController.java

@@ -35,12 +35,12 @@ import org.jeecg.modules.adweb.common.constant.AdwebConstant;
 import org.jeecg.modules.adweb.seo.dto.AvesApiSearchKeywordsDTO;
 import org.jeecg.modules.adweb.seo.dto.ChangeTypeDTO;
 import org.jeecg.modules.adweb.seo.entity.SeoKeywords;
-import org.jeecg.modules.adweb.seo.entity.SeoPlanSubscription;
 import org.jeecg.modules.adweb.seo.service.ISeoKeywordsRankService;
 import org.jeecg.modules.adweb.seo.service.ISeoKeywordsService;
-import org.jeecg.modules.adweb.seo.service.ISeoPlanSubscriptionService;
 import org.jeecg.modules.adweb.site.entity.AdwebSite;
 import org.jeecg.modules.adweb.site.service.IAdwebSiteService;
+import org.jeecg.modules.adweb.subscription.entity.UserPlanSubscription;
+import org.jeecg.modules.adweb.subscription.service.IUserPlanSubscriptionService;
 import org.jeecg.modules.adweb.system.service.SysAdwebApi;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
@@ -78,7 +78,7 @@ public class SeoKeywordsController extends JeecgController<SeoKeywords, ISeoKeyw
 
     @Autowired private IAdwebSiteService adwebSiteService;
 
-    @Autowired private ISeoPlanSubscriptionService seoPlanSubscriptionService;
+    @Autowired private IUserPlanSubscriptionService userPlanSubscriptionService;
 
     @Value("${jeecg.path.upload}")
     private String uploadUrl;
@@ -131,7 +131,7 @@ public class SeoKeywordsController extends JeecgController<SeoKeywords, ISeoKeyw
      */
     @AutoLog(value = "关键词-添加")
     @Operation(summary = "关键词-添加")
-    @PreAuthorize("@jps.requiresPermissions('keywords:seo_keywords:add')")
+    @PreAuthorize("@jps.requiresPermissions('seo:seo_keywords:add')")
     @PostMapping(value = "/add")
     public Result<String> add(@RequestBody SeoKeywords seoKeywords) {
         //        AdwebSite siteByCode = adwebSiteService.getSiteByCode(seoKeywords.getSiteCode());
@@ -156,7 +156,7 @@ public class SeoKeywordsController extends JeecgController<SeoKeywords, ISeoKeyw
      */
     @AutoLog(value = "关键词-编辑")
     @Operation(summary = "关键词-编辑")
-    @PreAuthorize("@jps.requiresPermissions('keywords:seo_keywords:edit')")
+    @PreAuthorize("@jps.requiresPermissions('seo:seo_keywords:edit')")
     @RequestMapping(
             value = "/edit",
             method = {RequestMethod.PUT, RequestMethod.POST})
@@ -173,7 +173,7 @@ public class SeoKeywordsController extends JeecgController<SeoKeywords, ISeoKeyw
      */
     @AutoLog(value = "关键词-通过id删除")
     @Operation(summary = "关键词-通过id删除")
-    @PreAuthorize("@jps.requiresPermissions('keywords:seo_keywords:delete')")
+    @PreAuthorize("@jps.requiresPermissions('seo:seo_keywords:delete')")
     @DeleteMapping(value = "/delete")
     public Result<String> delete(@RequestParam(name = "id", required = true) String id) {
         seoKeywordsService.removeById(id);
@@ -188,7 +188,7 @@ public class SeoKeywordsController extends JeecgController<SeoKeywords, ISeoKeyw
      */
     @AutoLog(value = "关键词-批量删除")
     @Operation(summary = "关键词-批量删除")
-    @PreAuthorize("@jps.requiresPermissions('keywords:seo_keywords:deleteBatch')")
+    @PreAuthorize("@jps.requiresPermissions('seo:seo_keywords:deleteBatch')")
     @DeleteMapping(value = "/deleteBatch")
     public Result<String> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
         this.seoKeywordsService.removeByIds(Arrays.asList(ids.split(",")));
@@ -217,7 +217,7 @@ public class SeoKeywordsController extends JeecgController<SeoKeywords, ISeoKeyw
      *
      * @param request
      */
-    @PreAuthorize("@jps.requiresPermissions('keywords:seo_keywords:exportXls')")
+    @PreAuthorize("@jps.requiresPermissions('seo:seo_keywords:exportXls')")
     @RequestMapping(value = "/exportXls")
     public ModelAndView exportXls(HttpServletRequest request, SeoKeywords seoKeywords) {
         return super.exportXls(request, seoKeywords, SeoKeywords.class, "关键词");
@@ -386,7 +386,7 @@ public class SeoKeywordsController extends JeecgController<SeoKeywords, ISeoKeyw
      * @param request
      * @return
      */
-    @PreAuthorize("@jps.requiresPermissions('keywords:seo_keywords:importExcel')")
+    @PreAuthorize("@jps.requiresPermissions('seo:seo_keywords:importExcel')")
     @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
     public Result<?> importExcel(HttpServletRequest request) {
         String siteCode = request.getParameter("siteCode");
@@ -402,8 +402,8 @@ public class SeoKeywordsController extends JeecgController<SeoKeywords, ISeoKeyw
         if (StringUtil.isEmpty(site.getDomain())) {
             return Result.error("站点域名未设置!");
         }
-        SeoPlanSubscription currentSeoAndSiteSubscription =
-                seoPlanSubscriptionService.getCurrentSeoAndSiteSubscription(site.getId());
+        UserPlanSubscription currentSeoAndSiteSubscription =
+                userPlanSubscriptionService.getCurrentSubscription(site.getId());
 
         if (currentSeoAndSiteSubscription == null) {
             return Result.error("当前站点没有有效的订阅套餐!");

+ 3 - 3
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/seo/controller/SeoKeywordsRankController.java

@@ -6,7 +6,7 @@ import lombok.extern.slf4j.Slf4j;
 
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.modules.adweb.seo.dto.ComprehensiveStatistics;
-import org.jeecg.modules.adweb.seo.entity.SeoPlanSubscription;
+import org.jeecg.modules.adweb.subscription.entity.UserPlanSubscription;
 import org.jeecg.modules.adweb.seo.service.ISeoKeywordsRankService;
 import org.jeecg.modules.adweb.site.entity.AdwebSite;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -38,9 +38,9 @@ public class SeoKeywordsRankController {
 
     /** 根据 站点code 获取 站点的 订阅Id */
     @GetMapping(value = "/getSubscriptionIdBySiteCode")
-    public Result<List<SeoPlanSubscription>> getSubscriptionIdBySiteCode(
+    public Result<List<UserPlanSubscription>> getSubscriptionIdBySiteCode(
             @RequestParam String siteCode) {
-        final List<SeoPlanSubscription> subscriptionIdBySiteCode =
+        final List<UserPlanSubscription> subscriptionIdBySiteCode =
                 seoKeywordsRankService.getSubscriptionIdBySiteCode(siteCode);
         return Result.OK(subscriptionIdBySiteCode);
     }

+ 0 - 171
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/seo/controller/SeoPlanSubscriptionController.java

@@ -1,171 +0,0 @@
-package org.jeecg.modules.adweb.seo.controller;
-
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-
-import io.swagger.v3.oas.annotations.Operation;
-import io.swagger.v3.oas.annotations.tags.Tag;
-
-import jakarta.servlet.http.HttpServletRequest;
-import jakarta.servlet.http.HttpServletResponse;
-
-import lombok.extern.slf4j.Slf4j;
-
-import org.jeecg.common.api.vo.Result;
-import org.jeecg.common.aspect.annotation.AutoLog;
-import org.jeecg.common.system.base.controller.JeecgController;
-import org.jeecg.common.system.query.QueryGenerator;
-import org.jeecg.modules.adweb.seo.entity.SeoPlanSubscription;
-import org.jeecg.modules.adweb.seo.service.ISeoPlanSubscriptionService;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.security.access.prepost.PreAuthorize;
-import org.springframework.web.bind.annotation.*;
-import org.springframework.web.servlet.ModelAndView;
-
-import java.util.Arrays;
-
-/**
- * @Description: seo套餐订购
- * @Author: jeecg-boot
- * @Date: 2024-10-15
- * @Version: V1.0
- */
-@Tag(name = "seo套餐订购")
-@RestController
-@RequestMapping("/serp/seoPlanSubscription")
-@Slf4j
-public class SeoPlanSubscriptionController
-        extends JeecgController<SeoPlanSubscription, ISeoPlanSubscriptionService> {
-    @Autowired private ISeoPlanSubscriptionService seoPlanSubscriptionService;
-
-    /**
-     * 分页列表查询
-     *
-     * @param seoPlanSubscription
-     * @param pageNo
-     * @param pageSize
-     * @param req
-     * @return
-     */
-    // @AutoLog(value = "seo套餐订购-分页列表查询")
-    @Operation(summary = "seo套餐订购-分页列表查询")
-    @GetMapping(value = "/list")
-    public Result<IPage<SeoPlanSubscription>> queryPageList(
-            SeoPlanSubscription seoPlanSubscription,
-            @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
-            @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
-            HttpServletRequest req) {
-        QueryWrapper<SeoPlanSubscription> queryWrapper =
-                QueryGenerator.initQueryWrapper(seoPlanSubscription, req.getParameterMap());
-        Page<SeoPlanSubscription> page = new Page<SeoPlanSubscription>(pageNo, pageSize);
-        IPage<SeoPlanSubscription> pageList = seoPlanSubscriptionService.page(page, queryWrapper);
-        return Result.OK(pageList);
-    }
-
-    /**
-     * 添加
-     *
-     * @param seoPlanSubscription
-     * @return
-     */
-    @AutoLog(value = "seo套餐订购-添加")
-    @Operation(summary = "seo套餐订购-添加")
-    @PreAuthorize("@jps.requiresPermissions('serp:seo_plan_subscription:add')")
-    @PostMapping(value = "/add")
-    public Result<String> add(@RequestBody SeoPlanSubscription seoPlanSubscription) {
-        seoPlanSubscriptionService.save(seoPlanSubscription);
-        return Result.OK("添加成功!");
-    }
-
-    /**
-     * 编辑
-     *
-     * @param seoPlanSubscription
-     * @return
-     */
-    @AutoLog(value = "seo套餐订购-编辑")
-    @Operation(summary = "seo套餐订购-编辑")
-    @PreAuthorize("@jps.requiresPermissions('serp:seo_plan_subscription:edit')")
-    @RequestMapping(
-            value = "/edit",
-            method = {RequestMethod.PUT, RequestMethod.POST})
-    public Result<String> edit(@RequestBody SeoPlanSubscription seoPlanSubscription) {
-        seoPlanSubscriptionService.updateById(seoPlanSubscription);
-        return Result.OK("编辑成功!");
-    }
-
-    /**
-     * 通过id删除
-     *
-     * @param id
-     * @return
-     */
-    @AutoLog(value = "seo套餐订购-通过id删除")
-    @Operation(summary = "seo套餐订购-通过id删除")
-    @PreAuthorize("@jps.requiresPermissions('serp:seo_plan_subscription:delete')")
-    @DeleteMapping(value = "/delete")
-    public Result<String> delete(@RequestParam(name = "id", required = true) String id) {
-        seoPlanSubscriptionService.removeById(id);
-        return Result.OK("删除成功!");
-    }
-
-    /**
-     * 批量删除
-     *
-     * @param ids
-     * @return
-     */
-    @AutoLog(value = "seo套餐订购-批量删除")
-    @Operation(summary = "seo套餐订购-批量删除")
-    @PreAuthorize("@jps.requiresPermissions('serp:seo_plan_subscription:deleteBatch')")
-    @DeleteMapping(value = "/deleteBatch")
-    public Result<String> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
-        this.seoPlanSubscriptionService.removeByIds(Arrays.asList(ids.split(",")));
-        return Result.OK("批量删除成功!");
-    }
-
-    /**
-     * 通过id查询
-     *
-     * @param id
-     * @return
-     */
-    // @AutoLog(value = "seo套餐订购-通过id查询")
-    @Operation(summary = "seo套餐订购-通过id查询")
-    @GetMapping(value = "/queryById")
-    public Result<SeoPlanSubscription> queryById(
-            @RequestParam(name = "id", required = true) String id) {
-        SeoPlanSubscription seoPlanSubscription = seoPlanSubscriptionService.getById(id);
-        if (seoPlanSubscription == null) {
-            return Result.error("未找到对应数据");
-        }
-        return Result.OK(seoPlanSubscription);
-    }
-
-    /**
-     * 导出excel
-     *
-     * @param request
-     * @param seoPlanSubscription
-     */
-    @PreAuthorize("@jps.requiresPermissions('serp:seo_plan_subscription:exportXls')")
-    @RequestMapping(value = "/exportXls")
-    public ModelAndView exportXls(
-            HttpServletRequest request, SeoPlanSubscription seoPlanSubscription) {
-        return super.exportXls(request, seoPlanSubscription, SeoPlanSubscription.class, "seo套餐订购");
-    }
-
-    /**
-     * 通过excel导入数据
-     *
-     * @param request
-     * @param response
-     * @return
-     */
-    @PreAuthorize("@jps.requiresPermissions('serp:seo_plan_subscription:importExcel')")
-    @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
-    public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
-        return super.importExcel(request, response, SeoPlanSubscription.class);
-    }
-}

+ 25 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/seo/dto/ComprehensiveStatistics.java

@@ -7,6 +7,15 @@ import lombok.Data;
  */
 @Data
 public class ComprehensiveStatistics {
+    /** 套餐名称 */
+    private String planName;
+
+    /** 套餐类型 - 是否SEO */
+    private String planType;
+
+    /** 套餐关键词 */
+    private Integer planKeywordNum;
+
     /** 套餐指定词 */
     private Integer planAppointKeywordNum;
 
@@ -22,12 +31,28 @@ public class ComprehensiveStatistics {
     /** 指定词 */
     private Integer appointKeywordNum;
 
+    /** 已达标指定词 */
+    private Integer achievedAppointKeywordNum;
+
     /** 长尾词 */
     private Integer longTailKeywordNum;
 
+    /** 已达标长尾词 */
+    private Integer achievedLongTailKeywordNum;
+
     /** 外链数 */
     private Integer outerLinkNum;
 
     /** 文章数 */
     private Integer articleNum;
+
+    /** 关键词数量及达标数量 */
+    @Data
+    public static class KeywordRankStats {
+        /** 1 指定词 2 长尾词 */
+        private Integer keywordType;
+
+        private Integer keywordNum;
+        private Integer achievedKeywordNum;
+    }
 }

+ 55 - 20
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/seo/mapper/SeoKeywordsMapper.java

@@ -5,8 +5,9 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import org.apache.ibatis.annotations.Param;
+import org.jeecg.modules.adweb.seo.dto.ComprehensiveStatistics;
 import org.jeecg.modules.adweb.seo.entity.SeoKeywords;
-import org.jeecg.modules.adweb.seo.entity.SeoPlanSubscription;
+import org.jeecg.modules.adweb.subscription.entity.UserPlanSubscription;
 import org.jeecg.modules.adweb.seo.vo.RankInfoVO;
 
 import java.util.List;
@@ -14,17 +15,19 @@ import java.util.List;
 /**
  * @Description: 关键词
  * @Author: jeecg-boot
- * @Date:   2024-10-15
+ * @Date: 2024-10-15
  * @Version: V1.0
  */
 public interface SeoKeywordsMapper extends BaseMapper<SeoKeywords> {
     /**
      * 根据站点和套餐id
+     *
      * @param siteCode
      * @param subscriptionId
      * @return
      */
-    List<String> getKeywordsLastSevenDays(String siteCode, String subscriptionId, Integer keywordType);
+    List<String> getKeywordsLastSevenDays(
+            String siteCode, String subscriptionId, Integer keywordType);
 
     /**
      * 查询关键词排名数据
@@ -32,7 +35,13 @@ public interface SeoKeywordsMapper extends BaseMapper<SeoKeywords> {
      * @param siteCode siteCode
      * @return 当日排名在前n页的数量
      */
-    RankInfoVO queryKeywordNumByRankRange(@Param("siteCode") String siteCode, @Param("subscriptionId") String subscriptionId, @Param("rankStart") Integer rankStart, @Param("rankEnd") Integer rankEnd, @Param("dateStr") String dateStr, @Param("keywordType") String keywordType);
+    RankInfoVO queryKeywordNumByRankRange(
+            @Param("siteCode") String siteCode,
+            @Param("subscriptionId") String subscriptionId,
+            @Param("rankStart") Integer rankStart,
+            @Param("rankEnd") Integer rankEnd,
+            @Param("dateStr") String dateStr,
+            @Param("keywordType") String keywordType);
 
     /**
      * 根据站点code获取关键词达标标准
@@ -47,19 +56,20 @@ public interface SeoKeywordsMapper extends BaseMapper<SeoKeywords> {
      *
      * @return 关键词列表
      */
-    IPage<SeoKeywords> getKeywordList(IPage<SeoKeywords> page,
-                                      Integer rankStart,
-                                      Integer rankEnd,
-                                      boolean isCustomer,
-                                      String keyword,
-                                      String siteCode,
-                                      Integer keywordType,
-                                      String datesStr,
-                                      String subscriptionId,
-                                      String column,
-                                      String order,
-                                      String buttonColumn,
-                                      String buttonSort);
+    IPage<SeoKeywords> getKeywordList(
+            IPage<SeoKeywords> page,
+            Integer rankStart,
+            Integer rankEnd,
+            boolean isCustomer,
+            String keyword,
+            String siteCode,
+            Integer keywordType,
+            String datesStr,
+            String subscriptionId,
+            String column,
+            String order,
+            String buttonColumn,
+            String buttonSort);
 
     /**
      * 获取当日需要DateForSEO Serp查询的关键词列表
@@ -70,6 +80,7 @@ public interface SeoKeywordsMapper extends BaseMapper<SeoKeywords> {
 
     /**
      * 关键词管理列表数据
+     *
      * @param page
      * @param siteCode
      * @param keywords
@@ -82,10 +93,21 @@ public interface SeoKeywordsMapper extends BaseMapper<SeoKeywords> {
      * @param keywordRank
      * @return
      */
-    IPage<SeoKeywords> getPageList(Page<SeoKeywords> page, String siteCode, String keywords, String subscriptionId, String lastSearchTime, String createTime, Integer keywordType, String column, String order, Integer keywordRank);
+    IPage<SeoKeywords> getPageList(
+            Page<SeoKeywords> page,
+            String siteCode,
+            String keywords,
+            String subscriptionId,
+            String lastSearchTime,
+            String createTime,
+            Integer keywordType,
+            String column,
+            String order,
+            Integer keywordRank);
 
     /**
      * 关键词管理列表数据
+     *
      * @param page
      * @param siteCode
      * @param keywords
@@ -98,7 +120,20 @@ public interface SeoKeywordsMapper extends BaseMapper<SeoKeywords> {
      * @param keywordRank
      * @return
      */
-    IPage<SeoKeywords> getPageListByCreateTime(Page<SeoKeywords> page, String siteCode, String keywords, String subscriptionId, String lastSearchTime, String createTime, Integer keywordType, String column, String order, Integer keywordRank);
+    IPage<SeoKeywords> getPageListByCreateTime(
+            Page<SeoKeywords> page,
+            String siteCode,
+            String keywords,
+            String subscriptionId,
+            String lastSearchTime,
+            String createTime,
+            Integer keywordType,
+            String column,
+            String order,
+            Integer keywordRank);
+
+    List<UserPlanSubscription> getSubscriptionIdBySiteCode(String siteCode);
 
-    List<SeoPlanSubscription> getSubscriptionIdBySiteCode(String siteCode);
+    List<ComprehensiveStatistics.KeywordRankStats> getKeywordsRankStats(
+            String siteCode, int targetRank);
 }

+ 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);
 }

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

@@ -1,36 +0,0 @@
-package org.jeecg.modules.adweb.seo.mapper;
-
-
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import org.apache.ibatis.annotations.Select;
-import org.jeecg.modules.adweb.seo.entity.SeoPlanSubscription;
-
-import java.util.Map;
-
-/**
- * @Description: seo套餐订购
- * @Author: jeecg-boot
- * @Date: 2024-10-15
- * @Version: V1.0
- */
-public interface SeoPlanSubscriptionMapper extends BaseMapper<SeoPlanSubscription> {
-    /**
-     * 根据站点code获取关键词达标标准
-     *
-     * @param siteCode 站点code
-     * @return 达标标准
-     */
-    int getKeywordStandard(String siteCode);
-
-    /**
-     * 根据站点id,查询站点的营销方案
-     *
-     * @return:
-     * @Author: luxiaoxiao
-     * @Date: 2021/4/6
-     */
-    @Select("select t1.plan_name planName, t1.keyword_count keywordCount, t1.service_time serviceTime, t1.price price,t2.plan_id planId " +
-            "from adweb_subscribe_plan t1 ,adweb_seo_plan_subscription t2 " +
-            "where t1.id = t2.plan_id AND t2.site_id = #{siteId} AND t2.status = 1")
-    Map<String, String> getSubscribePlanBySiteId(Integer siteId);
-}

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

@@ -4,13 +4,13 @@
     <select id="getKeywordsLastSevenDays" resultType="java.lang.String">
         SELECT t1.se_date
         FROM adweb_seo_keywords_serp t1,
-             adweb_seo_keywords t2
+        adweb_seo_keywords t2
         WHERE t2.`status` = 1
-          AND t1.keywords_id = t2.id
-          AND t2.app_key = 'adweb'
-          AND t2.site_code = #{siteCode}
-          AND t2.keyword_type = #{keywordType}
-          AND t2.subscription_id = #{subscriptionId}
+        AND t1.keywords_id = t2.id
+        AND t2.app_key = 'adweb'
+        AND t2.site_code = #{siteCode}
+        AND t2.keyword_type = #{keywordType}
+        AND t2.subscription_id = #{subscriptionId}
         GROUP BY t1.se_date
         ORDER BY t1.se_date DESC
         LIMIT 7
@@ -76,16 +76,16 @@
     </select>
     <select id="getKeywordStandard" resultType="java.lang.Integer">
         SELECT
-            IF(COUNT(*) = 0 OR t1.target IS NULL, 10, t1.target)
+        IF(COUNT(*) = 0 OR t1.target IS NULL, 10, t1.target)
         FROM
-            seo_market_plan t1,
-            adweb_seo_plan_subscription t2,
-            adweb_site t3
+        adweb_subscribe_plan t1,
+        adweb_sysuser_plan_subscription t2,
+        adweb_site t3
         WHERE
-            t2.`status` = 1
-          AND t1.id = t2.plan_id
-          AND t2.site_id = t3.id
-          AND t3.`code` = #{siteCode}
+        t2.`status` = 1
+        AND t1.id = t2.plan_id
+        AND t2.site_id = t3.id
+        AND t3.`code` = #{siteCode}
     </select>
     <select id="getKeywordList" resultType="org.jeecg.modules.adweb.seo.entity.SeoKeywords">
         SELECT
@@ -110,7 +110,7 @@
                 AND #{rankEnd} >= t1.last_rank
             </if>
             AND t1.app_key = 'adweb'
-            AND t1.`status` =  1
+            AND t1.`status` = 1
             <if test="!subscriptionId">
                 AND t1.subscription_id = #{subscriptionId}
             </if>
@@ -174,7 +174,7 @@
         <foreach collection="sideCodes" item="sideCode" open="(" separator="," close=")">
             #{sideCode}
         </foreach>
-        <if test = "keywordType != null">
+        <if test="keywordType != null">
             AND keyword_type = #{keywordType}
         </if>
         AND last_search_time <![CDATA[ <]]> CURDATE()
@@ -315,20 +315,30 @@
             ,last_rank ASC
         </if>
     </select>
+
     <select id="getSubscriptionIdBySiteCode"
-            resultType="org.jeecg.modules.adweb.seo.entity.SeoPlanSubscription">
+            resultType="org.jeecg.modules.adweb.subscription.entity.UserPlanSubscription">
         SELECT
-            t1.id,
-            t1.plan_id
+        t1.id,
+        t1.plan_id
         FROM
-            adweb_seo_plan_subscription t1,
-            adweb_site t2
+        adweb_sysuser_plan_subscription t1,
+        adweb_site t2
         WHERE
-            t1.site_id = t2.id
+        t1.site_id = t2.id
         AND
-            t1.`status` = 1
+        t1.`status` = 1
         AND
-            t2.`code` = #{siteCode}
+        t2.`code` = #{siteCode}
+    </select>
 
+    <select id="getKeywordsRankStats"
+            resultType="org.jeecg.modules.adweb.seo.dto.ComprehensiveStatistics$KeywordRankStats">
+        SELECT keyword_type, COUNT(*) AS keyword_num,
+        SUM(CASE WHEN last_rank BETWEEN 1 AND #{targetRank} THEN 1 ELSE 0 END) AS achieved_keyword_num
+        FROM adweb_seo_keywords
+        WHERE site_code = #{siteCode} AND status = 1
+        GROUP BY keyword_type
     </select>
+
 </mapper>

+ 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>

+ 0 - 18
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/seo/mapper/xml/SeoPlanSubscriptionMapper.xml

@@ -1,18 +0,0 @@
-<?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.seo.mapper.SeoPlanSubscriptionMapper">
-    <select id="getKeywordStandard" resultType="java.lang.Integer">
-        SELECT
-            IF(COUNT(*) = 0 OR t1.target IS NULL, 10, t1.target)
-        FROM
-            adweb_subscribe_plan t1,
-            adweb_seo_plan_subscription t2,
-            adweb_site t3
-        WHERE
-            t2.`status` = 1
-          AND t1.id = t2.plan_id
-          AND t2.site_id = t3.id
-          AND t3.`code` = #{siteCode}
-        GROUP BY t1.target
-    </select>
-</mapper>

+ 5 - 4
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/seo/service/ISeoKeywordsRankService.java

@@ -3,9 +3,9 @@ package org.jeecg.modules.adweb.seo.service;
 import org.apache.poi.ss.usermodel.Sheet;
 import org.jeecg.modules.adweb.seo.dto.ComprehensiveStatistics;
 import org.jeecg.modules.adweb.seo.entity.SeoKeywords;
-import org.jeecg.modules.adweb.seo.entity.SeoPlanSubscription;
 import org.jeecg.modules.adweb.seo.vo.SeoRankInfoVO;
 import org.jeecg.modules.adweb.site.entity.AdwebSite;
+import org.jeecg.modules.adweb.subscription.entity.UserPlanSubscription;
 
 import java.text.ParseException;
 import java.util.List;
@@ -25,17 +25,18 @@ public interface ISeoKeywordsRankService {
 
     Map getRankInfo(String siteCode) throws ParseException;
 
-    List<SeoRankInfoVO> getSeoRankInfo(String siteCode, String historyId) throws ParseException;
+    List<SeoRankInfoVO> getSeoRankInfo(String siteCode, String subscriptionId)
+            throws ParseException;
 
     void addRankInfoByIntervalTimeByType(
             List<SeoKeywords> keywordList,
             Integer keywordType,
             String siteCode,
-            String historyId,
+            String subscriptionId,
             List<String> dateList)
             throws Exception;
 
     void setSizeColumn(Sheet sheet, int size);
 
-    List<SeoPlanSubscription> getSubscriptionIdBySiteCode(String siteCode);
+    List<UserPlanSubscription> getSubscriptionIdBySiteCode(String siteCode);
 }

+ 4 - 3
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/seo/service/ISeoKeywordsService.java

@@ -18,11 +18,12 @@ import java.util.List;
  */
 public interface ISeoKeywordsService extends IService<SeoKeywords> {
 
-    List<String> getKeywordsLastSevenDays(String userFlag, Integer keywordType, String historyId);
+    List<String> getKeywordsLastSevenDays(
+            String userFlag, Integer keywordType, String subscriptionId);
 
     RankInfoVO getSeoRankInfo(
             String siteCode,
-            String historyId,
+            String subscriptionId,
             Integer rankStart,
             Integer rankEnd,
             String dateStr,
@@ -36,7 +37,7 @@ public interface ISeoKeywordsService extends IService<SeoKeywords> {
             String siteCode,
             Integer keywordType,
             boolean reachStandard,
-            String historyId,
+            String subscriptionId,
             String column,
             String order,
             String buttonColumn,

+ 0 - 38
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/seo/service/ISeoPlanSubscriptionService.java

@@ -1,38 +0,0 @@
-package org.jeecg.modules.adweb.seo.service;
-
-import com.baomidou.mybatisplus.extension.service.IService;
-
-import org.jeecg.common.api.vo.Result;
-import org.jeecg.common.system.vo.LoginUser;
-import org.jeecg.modules.adweb.seo.entity.SeoPlanSubscription;
-import org.jeecg.modules.adweb.subscribePlan.entity.SubscribePlan;
-
-/**
- * @Description: seo套餐订购
- * @Author: jeecg-boot
- * @Date: 2024-10-15
- * @Version: V1.0
- */
-public interface ISeoPlanSubscriptionService extends IService<SeoPlanSubscription> {
-
-    /**
-     * 绑定SEO套餐
-     *
-     * @param seoPlanSubscription
-     * @param sysUser
-     * @return
-     */
-    Result<?> addSeoPlanSubscription(SeoPlanSubscription seoPlanSubscription, LoginUser sysUser);
-
-    /**
-     * 新增套餐订阅记录
-     *
-     * @param seoPlanSubscription
-     * @param marketPlan
-     * @return
-     */
-    boolean addNewSubscription(SeoPlanSubscription seoPlanSubscription, SubscribePlan marketPlan);
-
-    /** 获取正在使用中的SEO套餐,如果没有使用中的SEO和建站套餐,则查询过期的SEO和建站套餐 */
-    SeoPlanSubscription getCurrentSeoAndSiteSubscription(Integer siteId);
-}

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

@@ -1,10 +1,10 @@
 package org.jeecg.modules.adweb.seo.service.impl;
 
+import static org.jeecg.modules.adweb.seo.dto.ComprehensiveStatistics.KeywordRankStats;
+
 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;
@@ -18,19 +18,21 @@ import org.jeecg.modules.adweb.common.constant.AdwebConstant;
 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.entity.SeoPlanSubscription;
 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.service.ISeoPlanSubscriptionService;
 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;
-import org.jeecg.modules.adweb.subscribePlan.entity.SubscribePlan;
-import org.jeecg.modules.adweb.subscribePlan.mapper.SubscribePlanMapper;
+import org.jeecg.modules.adweb.subscription.entity.SubscribePlan;
+import org.jeecg.modules.adweb.subscription.entity.UserPlanSubscription;
+import org.jeecg.modules.adweb.subscription.mapper.SubscribePlanMapper;
+import org.jeecg.modules.adweb.subscription.service.IUserPlanSubscriptionService;
 import org.jeecg.modules.adweb.system.service.SysAdwebApi;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -40,38 +42,29 @@ 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
 public class SeoKeywordsRankServiceImpl implements ISeoKeywordsRankService {
 
-    @Autowired
-    private IAdwebSiteService adwebSiteService;
+    @Autowired private IAdwebSiteService adwebSiteService;
+
+    @Autowired private SysAdwebApi sysAdwebApi;
 
-    @Resource
-    private SysAdwebApi sysAdwebApi;
+    @Autowired private ISiteUserPermissionService siteUserPermissionService;
 
-    @Autowired
-    private ISiteUserPermissionService siteUserPermissionService;
+    @Autowired private IUserPlanSubscriptionService userPlanSubscriptionService;
 
-    @Autowired
-    private ISeoPlanSubscriptionService seoPlanSubscriptionService;
+    @Autowired private ISeoKeywordsService seoKeywordsService;
 
-    @Autowired
-    private ISeoKeywordsService seoKeywordsService;
+    @Autowired private SeoKeywordsMapper seoKeywordsMapper;
 
-    @Resource
-    private SeoKeywordsMapper seoKeywordsMapper;
+    @Autowired private SeoKeywordsSerpMapper seoKeywordsSerpMapper;
 
-    @Autowired
-    private ISeoKeywordsSerpService seoKeywordsSerpService;
+    @Autowired private ISeoKeywordsSerpService seoKeywordsSerpService;
 
-    @Resource
-    private SubscribePlanMapper subscribePlanMapper;
+    @Autowired private SubscribePlanMapper subscribePlanMapper;
 
     @Override
     public List<AdwebSite> getAllSites() {
@@ -82,10 +75,13 @@ public class SeoKeywordsRankServiceImpl implements ISeoKeywordsRankService {
         LambdaQueryWrapper<AdwebSite> queryWrapper = new LambdaQueryWrapper<>();
         queryWrapper.select(AdwebSite::getId, AdwebSite::getName, AdwebSite::getCode);
         queryWrapper.orderByDesc(AdwebSite::getCreateTime);
-        queryWrapper.eq(AdwebSite::getStatus, AdwebConstant.STATUS).isNull(AdwebSite::getParentGroupCode);
+        queryWrapper
+                .eq(AdwebSite::getStatus, AdwebConstant.STATUS)
+                .isNull(AdwebSite::getParentGroupCode);
         if (sysAdwebApi.isChannelAdmin()) {
             List<String> channelGroupUids = sysAdwebApi.getChannelGroupUids();
-            List<String> codeList = siteUserPermissionService.getSiteCodeListByUids(channelGroupUids);
+            List<String> codeList =
+                    siteUserPermissionService.getSiteCodeListByUids(channelGroupUids);
             queryWrapper.in(AdwebSite::getCode, codeList);
         } else if (!sysAdwebApi.isAdmin()) {
             List<String> codeList = siteUserPermissionService.getSiteCodeList(sysUser.getId());
@@ -96,9 +92,7 @@ public class SeoKeywordsRankServiceImpl implements ISeoKeywordsRankService {
         return siteList;
     }
 
-    /**
-     * 放入营销方案名称
-     */
+    /** 放入营销方案名称 */
     private void setPlanName(List<AdwebSite> siteList) {
         if (CollectionUtils.isEmpty(siteList)) {
             return;
@@ -109,22 +103,29 @@ public class SeoKeywordsRankServiceImpl implements ISeoKeywordsRankService {
             siteIds.add(site.getId());
         }
 
-        LambdaQueryWrapper<SeoPlanSubscription> historyQueryWrapper = new LambdaQueryWrapper<>();
-        historyQueryWrapper.select(SeoPlanSubscription::getId, SeoPlanSubscription::getPlanId, SeoPlanSubscription::getSiteId, SeoPlanSubscription::getPlanName, SeoPlanSubscription::getPlanType);
-        historyQueryWrapper.in(SeoPlanSubscription::getSiteId, siteIds);
-        historyQueryWrapper.eq(SeoPlanSubscription::getStatus, 1);
-        List<SeoPlanSubscription> seoPlanSubscriptions = seoPlanSubscriptionService.list(historyQueryWrapper);
-        if (CollectionUtils.isEmpty(seoPlanSubscriptions)) {
+        LambdaQueryWrapper<UserPlanSubscription> subscriptionQueryWrapper =
+                new LambdaQueryWrapper<>();
+        subscriptionQueryWrapper.select(
+                UserPlanSubscription::getId,
+                UserPlanSubscription::getPlanId,
+                UserPlanSubscription::getSiteId,
+                UserPlanSubscription::getPlanName,
+                UserPlanSubscription::getPlanType);
+        subscriptionQueryWrapper.in(UserPlanSubscription::getSiteId, siteIds);
+        subscriptionQueryWrapper.eq(UserPlanSubscription::getStatus, 1);
+        List<UserPlanSubscription> userPlanSubscriptions =
+                userPlanSubscriptionService.list(subscriptionQueryWrapper);
+        if (CollectionUtils.isEmpty(userPlanSubscriptions)) {
             return;
         }
 
         for (AdwebSite site : siteList) {
-            for (SeoPlanSubscription seoPlanSubscription : seoPlanSubscriptions) {
-                if (seoPlanSubscription.getSiteId().equals(site.getId() + "")) {
-                    site.setPlanId(seoPlanSubscription.getPlanId());
-                    site.setPlanName(seoPlanSubscription.getPlanName());
-                    site.setSubscriptionId(seoPlanSubscription.getId());
-                    site.setPlanType(seoPlanSubscription.getPlanType());
+            for (UserPlanSubscription userPlanSubscription : userPlanSubscriptions) {
+                if (userPlanSubscription.getSiteId().equals(site.getId() + "")) {
+                    site.setPlanId(userPlanSubscription.getPlanId());
+                    site.setPlanName(userPlanSubscription.getPlanName());
+                    site.setSubscriptionId(userPlanSubscription.getId());
+                    site.setPlanType(userPlanSubscription.getPlanType());
                 }
             }
         }
@@ -142,8 +143,13 @@ public class SeoKeywordsRankServiceImpl implements ISeoKeywordsRankService {
         // 根据站点code获取站点
         AdwebSite siteByCode = adwebSiteService.getSiteByCode(siteCode);
         // 1.获取套餐数据
-        SubscribePlan subscribePlan = subscribePlanMapper.getSubscribePlanBySiteId(siteByCode.getId());
+        SubscribePlan subscribePlan =
+                subscribePlanMapper.getSubscribePlanBySiteId(siteByCode.getId());
         if (subscribePlan != null) {
+            // 添加套餐信息
+            comprehensiveStatistics.setPlanName(subscribePlan.getPlanName());
+            comprehensiveStatistics.setPlanType(subscribePlan.getPlanType());
+
             // 添加套餐数据
             comprehensiveStatistics.setPlanAppointKeywordNum(subscribePlan.getSpecifyKeyword());
             comprehensiveStatistics.setPlanLongTailKeywordNum(subscribePlan.getLongTailKeyword());
@@ -152,32 +158,44 @@ public class SeoKeywordsRankServiceImpl implements ISeoKeywordsRankService {
         }
         // 添加站点数据
         // 1.获取站点指定词数量
-        LambdaQueryWrapper<SeoKeywords> seoKeywordsQueryWrapper = new LambdaQueryWrapper<>();
-        seoKeywordsQueryWrapper.eq(SeoKeywords::getSiteCode, siteCode);
-        seoKeywordsQueryWrapper.eq(SeoKeywords::getStatus, 1);
-        seoKeywordsQueryWrapper.eq(SeoKeywords::getKeywordType, 1);
-        Long appointKeywordNum = seoKeywordsMapper.selectCount(seoKeywordsQueryWrapper);
-        // 2.获取站点关键词数量
-        LambdaQueryWrapper<SeoKeywords> seoKeywordsQueryWrapper1 = new LambdaQueryWrapper<>();
-        seoKeywordsQueryWrapper1.eq(SeoKeywords::getSiteCode, siteCode);
-        seoKeywordsQueryWrapper1.eq(SeoKeywords::getStatus, 1);
-        seoKeywordsQueryWrapper1.eq(SeoKeywords::getKeywordType, 2);
-        Long longTailKeywordNum = seoKeywordsMapper.selectCount(seoKeywordsQueryWrapper1);
-        comprehensiveStatistics.setAppointKeywordNum(Math.toIntExact(appointKeywordNum));
-        comprehensiveStatistics.setLongTailKeywordNum(Math.toIntExact(longTailKeywordNum));
+        List<KeywordRankStats> keywordRankStats =
+                seoKeywordsMapper.getKeywordsRankStats(
+                        siteCode,
+                        Optional.ofNullable(subscribePlan.getTarget()).orElse(10)); // 默认排名前10
+        for (KeywordRankStats rankStats : keywordRankStats) {
+            if (rankStats.getKeywordType() == 1) {
+                // 指定词
+                comprehensiveStatistics.setAppointKeywordNum(rankStats.getKeywordNum());
+                comprehensiveStatistics.setAchievedAppointKeywordNum(
+                        rankStats.getAchievedKeywordNum());
+            } else {
+                comprehensiveStatistics.setLongTailKeywordNum(rankStats.getKeywordNum());
+                comprehensiveStatistics.setAchievedLongTailKeywordNum(
+                        rankStats.getAchievedKeywordNum());
+            }
+        }
+
         return comprehensiveStatistics;
     }
 
     @Override
     public Map getRankInfo(String siteCode) throws ParseException {
-        //通过站点code获取站点id
+        // 通过站点code获取站点id
         AdwebSite siteByCode = adwebSiteService.getSiteByCode(siteCode);
-        SeoPlanSubscription seoPlanSubscription = seoPlanSubscriptionService.getCurrentSeoAndSiteSubscription(siteByCode.getId());
-        //通过站点获取订阅id
-        List<SeoRankInfoVO> seoRankInfos = this.getSeoRankInfo(siteCode, seoPlanSubscription.getId());
+        UserPlanSubscription userPlanSubscription =
+                userPlanSubscriptionService.getCurrentSubscription(siteByCode.getId());
+        // 通过站点获取订阅id
+        List<SeoRankInfoVO> seoRankInfos =
+                this.getSeoRankInfo(siteCode, userPlanSubscription.getId());
         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;
     }
 
@@ -252,7 +270,8 @@ public class SeoKeywordsRankServiceImpl implements ISeoKeywordsRankService {
         }
 
         // 长尾词
-        List<String> dateList = seoKeywordsService.getKeywordsLastSevenDays(siteCode, 2, subscriptionId);
+        List<String> dateList =
+                seoKeywordsService.getKeywordsLastSevenDays(siteCode, 2, subscriptionId);
         String dateStr = "";
         if (CollectionUtils.isNotEmpty(dateList)) {
             for (int i = 0; i < dateList.size(); i++) {
@@ -274,13 +293,18 @@ public class SeoKeywordsRankServiceImpl implements ISeoKeywordsRankService {
     }
 
     /**
-     * 给列表中的关键字增加排名信息
-     * 根据关键词类型
+     * 给列表中的关键字增加排名信息 根据关键词类型
      *
      * @param keywordList 关键词列表
      */
     @Override
-    public void addRankInfoByIntervalTimeByType(List<SeoKeywords> keywordList, Integer keywordType, String siteCode, String subscriptionId, List<String> dateList) throws Exception {
+    public void addRankInfoByIntervalTimeByType(
+            List<SeoKeywords> keywordList,
+            Integer keywordType,
+            String siteCode,
+            String subscriptionId,
+            List<String> dateList)
+            throws Exception {
         if (CollectionUtils.isEmpty(keywordList)) {
             return;
         }
@@ -298,17 +322,24 @@ public class SeoKeywordsRankServiceImpl implements ISeoKeywordsRankService {
             }
             datesStr = "(" + datesStr + ")";
         }
-        List<Integer> keywordIds = keywordList.stream().map(SeoKeywords::getId).collect(Collectors.toList());
-        List<SeoKeywordsSerp> serpList = seoKeywordsSerpService.list(new LambdaQueryWrapper<SeoKeywordsSerp>()
-                .in(SeoKeywordsSerp::getKeywordsId, keywordIds)
-                .in(SeoKeywordsSerp::getSeDate, dateList));
+        List<Integer> keywordIds =
+                keywordList.stream().map(SeoKeywords::getId).collect(Collectors.toList());
+        List<SeoKeywordsSerp> serpList =
+                seoKeywordsSerpService.list(
+                        new LambdaQueryWrapper<SeoKeywordsSerp>()
+                                .in(SeoKeywordsSerp::getKeywordsId, keywordIds)
+                                .in(SeoKeywordsSerp::getSeDate, dateList));
         List<SeoKeywordsSerp> noRepeatSerpList = new ArrayList<>();
         Map<String, Integer> serpMap = new HashMap<>();
         if (CollectionUtils.isNotEmpty(serpList)) {
             for (SeoKeywordsSerp seoKeywordsSerp : serpList) {
-                seoKeywordsSerp.setKey(seoKeywordsSerp.getKeywordsId() + "_" + seoKeywordsSerp.getSeDate());
+                seoKeywordsSerp.setKey(
+                        seoKeywordsSerp.getKeywordsId() + "_" + seoKeywordsSerp.getSeDate());
                 if (CollectionUtils.isNotEmpty(noRepeatSerpList)) {
-                    List<SeoKeywordsSerp> have = noRepeatSerpList.stream().filter(o -> o.getKey().equals(seoKeywordsSerp.getKey())).collect(Collectors.toList());
+                    List<SeoKeywordsSerp> have =
+                            noRepeatSerpList.stream()
+                                    .filter(o -> o.getKey().equals(seoKeywordsSerp.getKey()))
+                                    .collect(Collectors.toList());
                     if (CollectionUtils.isEmpty(have)) {
                         serpMap.put(seoKeywordsSerp.getKey(), seoKeywordsSerp.getRankAbsolute());
                         noRepeatSerpList.add(seoKeywordsSerp);
@@ -349,7 +380,7 @@ public class SeoKeywordsRankServiceImpl implements ISeoKeywordsRankService {
      * 自适应宽度(中文支持)
      *
      * @param sheet
-     * @param size  因为for循环从0开始,size值为 列数-1
+     * @param size 因为for循环从0开始,size值为 列数-1
      */
     @Override
     public void setSizeColumn(Sheet sheet, int size) {
@@ -357,7 +388,7 @@ public class SeoKeywordsRankServiceImpl implements ISeoKeywordsRankService {
             int columnWidth = sheet.getColumnWidth(columnNum) / 256;
             for (int rowNum = 0; rowNum <= sheet.getLastRowNum(); rowNum++) {
                 Row currentRow;
-                //当前行未被使用过
+                // 当前行未被使用过
                 if (sheet.getRow(rowNum) == null) {
                     currentRow = sheet.createRow(rowNum);
                 } else {
@@ -379,7 +410,7 @@ public class SeoKeywordsRankServiceImpl implements ISeoKeywordsRankService {
     }
 
     @Override
-    public List<SeoPlanSubscription> getSubscriptionIdBySiteCode(String siteCode) {
+    public List<UserPlanSubscription> getSubscriptionIdBySiteCode(String siteCode) {
         return seoKeywordsMapper.getSubscriptionIdBySiteCode(siteCode);
     }
 }

+ 12 - 12
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/seo/service/impl/SeoKeywordsServiceImpl.java

@@ -33,15 +33,15 @@ public class SeoKeywordsServiceImpl extends ServiceImpl<SeoKeywordsMapper, SeoKe
      *
      * @param userFlag
      * @param keywordType
-     * @param historyId
+     * @param subscriptionId
      * @return
      */
     @Override
     public List<String> getKeywordsLastSevenDays(
-            String userFlag, Integer keywordType, String historyId) {
+            String userFlag, Integer keywordType, String subscriptionId) {
         // 获取对应站点最近七天
         List<String> dateList =
-                seoKeywordsMapper.getKeywordsLastSevenDays(userFlag, historyId, keywordType);
+                seoKeywordsMapper.getKeywordsLastSevenDays(userFlag, subscriptionId, keywordType);
         return dateList;
     }
 
@@ -54,14 +54,14 @@ public class SeoKeywordsServiceImpl extends ServiceImpl<SeoKeywordsMapper, SeoKe
     @Override
     public RankInfoVO getSeoRankInfo(
             String siteCode,
-            String historyId,
+            String subscriptionId,
             Integer rankStart,
             Integer rankEnd,
             String dateStr,
             String keywordType) {
         // 指定词
         return seoKeywordsMapper.queryKeywordNumByRankRange(
-                siteCode, historyId, rankStart, rankEnd, dateStr, keywordType);
+                siteCode, subscriptionId, rankStart, rankEnd, dateStr, keywordType);
     }
 
     /**
@@ -78,7 +78,7 @@ public class SeoKeywordsServiceImpl extends ServiceImpl<SeoKeywordsMapper, SeoKe
             String siteCode,
             Integer keywordType,
             boolean reachStandard,
-            String historyId,
+            String subscriptionId,
             String column,
             String order,
             String buttonColumn,
@@ -119,7 +119,7 @@ public class SeoKeywordsServiceImpl extends ServiceImpl<SeoKeywordsMapper, SeoKe
                 siteCode,
                 keywordType,
                 datesStr,
-                historyId,
+                subscriptionId,
                 column,
                 order,
                 buttonColumn,
@@ -132,7 +132,7 @@ public class SeoKeywordsServiceImpl extends ServiceImpl<SeoKeywordsMapper, SeoKe
      * @param page
      * @param siteCode
      * @param keywords
-     * @param historyId
+     * @param subscriptionId
      * @param lastSearchTime
      * @param createTime
      * @param keywordType
@@ -146,7 +146,7 @@ public class SeoKeywordsServiceImpl extends ServiceImpl<SeoKeywordsMapper, SeoKe
             Page<SeoKeywords> page,
             String siteCode,
             String keywords,
-            String historyId,
+            String subscriptionId,
             String lastSearchTime,
             String createTime,
             Integer keywordType,
@@ -159,7 +159,7 @@ public class SeoKeywordsServiceImpl extends ServiceImpl<SeoKeywordsMapper, SeoKe
                     page,
                     siteCode,
                     keywords,
-                    historyId,
+                    subscriptionId,
                     lastSearchTime,
                     createTime,
                     keywordType,
@@ -172,7 +172,7 @@ public class SeoKeywordsServiceImpl extends ServiceImpl<SeoKeywordsMapper, SeoKe
                     page,
                     siteCode,
                     keywords,
-                    historyId,
+                    subscriptionId,
                     lastSearchTime,
                     createTime,
                     keywordType,
@@ -188,7 +188,7 @@ public class SeoKeywordsServiceImpl extends ServiceImpl<SeoKeywordsMapper, SeoKe
                 page,
                 siteCode,
                 keywords,
-                historyId,
+                subscriptionId,
                 lastSearchTime,
                 createTime,
                 keywordType,

+ 0 - 191
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/seo/service/impl/SeoPlanSubscriptionServiceImpl.java

@@ -1,191 +0,0 @@
-package org.jeecg.modules.adweb.seo.service.impl;
-
-import cn.hutool.core.date.DateTime;
-import cn.hutool.core.date.DateUnit;
-
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-
-import jakarta.annotation.Resource;
-
-import org.apache.commons.collections4.CollectionUtils;
-import org.jeecg.common.api.vo.Result;
-import org.jeecg.common.system.vo.LoginUser;
-import org.jeecg.modules.adweb.seo.entity.SeoPlanSubscription;
-import org.jeecg.modules.adweb.seo.mapper.SeoPlanSubscriptionMapper;
-import org.jeecg.modules.adweb.seo.service.ISeoPlanSubscriptionService;
-import org.jeecg.modules.adweb.subscribePlan.entity.SubscribePlan;
-import org.jeecg.modules.adweb.subscribePlan.service.ISubscribePlanService;
-import org.springframework.stereotype.Service;
-
-import java.util.Arrays;
-import java.util.Date;
-import java.util.List;
-
-/**
- * @Description: seo套餐订购
- * @Author: jeecg-boot
- * @Date: 2024-10-15
- * @Version: V1.0
- */
-@Service
-public class SeoPlanSubscriptionServiceImpl
-        extends ServiceImpl<SeoPlanSubscriptionMapper, SeoPlanSubscription>
-        implements ISeoPlanSubscriptionService {
-
-    @Resource private ISubscribePlanService subscribePlanService;
-
-    @Override
-    public Result<?> addSeoPlanSubscription(
-            SeoPlanSubscription seoPurchaseHistory, LoginUser sysUser) {
-        boolean result = false;
-
-        SubscribePlan marketPlan = subscribePlanService.getById(seoPurchaseHistory.getPlanId());
-        if (marketPlan == null) {
-            return Result.error("此套餐不存在");
-        }
-
-        if (sysUser != null) {
-            seoPurchaseHistory.setCreateBy(sysUser.getId());
-        } else {
-            seoPurchaseHistory.setCreateBy("system_auto");
-        }
-
-        // 如果不是续费客户(就是新客户)的话,直接入库,套餐开启时间即是现在
-        if (seoPurchaseHistory.getIsRenew() == null || seoPurchaseHistory.getIsRenew() == 0) {
-            LambdaQueryWrapper<SeoPlanSubscription> queryWrapper = new LambdaQueryWrapper<>();
-            queryWrapper.eq(SeoPlanSubscription::getSiteId, seoPurchaseHistory.getSiteId());
-            queryWrapper.eq(SeoPlanSubscription::getStatus, 1);
-            List<SeoPlanSubscription> seoPurchaseHistoryList = this.list(queryWrapper);
-            if (!CollectionUtils.isEmpty(seoPurchaseHistoryList)) {
-                return Result.error("站点存在使用中套餐,请到期后绑定!");
-            }
-            result = this.addNewSubscription(seoPurchaseHistory, marketPlan);
-        } else { // 续费
-            // 判断是否有正在使用的套餐,如果没有,新建status为1的套餐
-            LambdaQueryWrapper<SeoPlanSubscription> oldQueryWrapper = new LambdaQueryWrapper<>();
-            oldQueryWrapper.eq(SeoPlanSubscription::getSiteId, seoPurchaseHistory.getSiteId());
-            oldQueryWrapper.eq(SeoPlanSubscription::getStatus, 1);
-            List<SeoPlanSubscription> oldHistoryList = this.list(oldQueryWrapper);
-            if (CollectionUtils.isEmpty(oldHistoryList)) {
-                return Result.error("站点不存在使用中套餐,请先新增套餐");
-            } else {
-                LambdaQueryWrapper<SeoPlanSubscription> queryWrapper = new LambdaQueryWrapper<>();
-                queryWrapper.eq(SeoPlanSubscription::getSiteId, seoPurchaseHistory.getSiteId());
-                queryWrapper.eq(SeoPlanSubscription::getStatus, 2);
-                List<SeoPlanSubscription> seoPurchaseHistoryList = this.list(queryWrapper);
-                if (!CollectionUtils.isEmpty(seoPurchaseHistoryList)) {
-                    return Result.error("同一站点不能同时续费多个相同类型的套餐!");
-                }
-
-                if (seoPurchaseHistory.getIsCustom() == 0) {
-                    // ->不是自定义服务开启时间 需找到多个套餐服务结束时间最大的那个
-                    // 此站点所有对应的套餐的最大服务结束时间
-                    SeoPlanSubscription history =
-                            this.getOne(
-                                    new LambdaQueryWrapper<SeoPlanSubscription>()
-                                            .eq(
-                                                    SeoPlanSubscription::getSiteId,
-                                                    seoPurchaseHistory.getSiteId())
-                                            .and(
-                                                    wrapper ->
-                                                            wrapper.eq(
-                                                                            SeoPlanSubscription
-                                                                                    ::getStatus,
-                                                                            1)
-                                                                    .or()
-                                                                    .eq(
-                                                                            SeoPlanSubscription
-                                                                                    ::getStatus,
-                                                                            2))
-                                            .orderByDesc(SeoPlanSubscription::getServiceEndTime)
-                                            .last("limit 1"));
-                    Date maxEndTime = null;
-                    if (history == null || history.getServiceEndTime() == null) {
-                        maxEndTime = new Date();
-                    } else {
-                        maxEndTime = history.getServiceEndTime();
-                    }
-                    seoPurchaseHistory.setCreateTime(new Date());
-                    seoPurchaseHistory.setPlanStartTime(maxEndTime);
-                    seoPurchaseHistory.setStatus(2);
-                    seoPurchaseHistory.setPlanName(marketPlan.getPlanName());
-                    seoPurchaseHistory.setPlanCode(marketPlan.getPlanCode());
-                    seoPurchaseHistory.setPlanPrice(marketPlan.getPrice());
-                    seoPurchaseHistory.setPlanType(marketPlan.getMarketType());
-                    seoPurchaseHistory.setServiceMonth(marketPlan.getServiceTime());
-                    result = this.save(seoPurchaseHistory);
-                } else if (seoPurchaseHistory.getIsCustom() == 1) { // 是自定义套餐开启时间
-                    seoPurchaseHistory.setCreateTime(new Date());
-                    seoPurchaseHistory.setPlanName(marketPlan.getPlanName());
-                    seoPurchaseHistory.setPlanCode(marketPlan.getPlanCode());
-                    seoPurchaseHistory.setPlanPrice(marketPlan.getPrice());
-                    seoPurchaseHistory.setPlanType(marketPlan.getMarketType());
-                    DateTime today = cn.hutool.core.date.DateUtil.date();
-                    long betweenTime =
-                            cn.hutool.core.date.DateUtil.between(
-                                    seoPurchaseHistory.getPlanStartTime(),
-                                    today,
-                                    DateUnit.DAY,
-                                    false);
-                    if (betweenTime > 0) {
-                        return Result.error("自定义时间请选择于今天之后!");
-                    } else {
-                        // 如果有正在使用的套餐,才能设置为2,否则设置为1
-                        seoPurchaseHistory.setStatus(2);
-                    }
-                    seoPurchaseHistory.setServiceMonth(marketPlan.getServiceTime());
-                    result = this.save(seoPurchaseHistory);
-                }
-            }
-        }
-
-        if (result) {
-
-            return Result.OK("添加成功!");
-        }
-
-        return Result.error("添加失败!");
-    }
-
-    @Override
-    public boolean addNewSubscription(
-            SeoPlanSubscription seoPurchaseHistory, SubscribePlan marketPlan) {
-        boolean result = false;
-        try {
-            Date startTime = new Date();
-            seoPurchaseHistory.setCreateTime(startTime);
-            seoPurchaseHistory.setPlanStartTime(startTime);
-            seoPurchaseHistory.setStatus(1); // 使用中
-            seoPurchaseHistory.setPlanName(marketPlan.getPlanName());
-            seoPurchaseHistory.setPlanCode(marketPlan.getPlanCode());
-            seoPurchaseHistory.setPlanPrice(marketPlan.getPrice());
-            seoPurchaseHistory.setPlanType(marketPlan.getMarketType());
-            seoPurchaseHistory.setServiceMonth(marketPlan.getServiceTime());
-            result = this.save(seoPurchaseHistory);
-        } catch (Exception e) {
-            log.error("站点新绑定套餐失败", e);
-        }
-        return result;
-    }
-
-    /** 获取正在使用中的SEO套餐,如果没有使用中的SEO和建站套餐,则查询过期的SEO和建站套餐 */
-    @Override
-    public SeoPlanSubscription getCurrentSeoAndSiteSubscription(Integer siteId) {
-        LambdaQueryWrapper<SeoPlanSubscription> queryWrapper = new LambdaQueryWrapper<>();
-        queryWrapper.eq(SeoPlanSubscription::getSiteId, siteId);
-        queryWrapper.and(
-                wrapper ->
-                        wrapper.eq(SeoPlanSubscription::getPlanType, "SEO")
-                                .or()
-                                .eq(SeoPlanSubscription::getPlanType, "STATIONCONSTRUCTION"));
-        queryWrapper.in(SeoPlanSubscription::getStatus, Arrays.asList(1, -1));
-        queryWrapper.orderByDesc(
-                SeoPlanSubscription::getStatus, SeoPlanSubscription::getCreateTime);
-        List<SeoPlanSubscription> histories = this.list(queryWrapper);
-        if (CollectionUtils.isNotEmpty(histories)) {
-            return histories.get(0);
-        }
-        return null;
-    }
-}

+ 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;

+ 5 - 5
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/site/controller/AdwebSiteController.java

@@ -29,12 +29,12 @@ import org.jeecg.common.system.vo.LoginUser;
 import org.jeecg.common.util.FastJsonUtil;
 import org.jeecg.config.security.utils.SecureUtil;
 import org.jeecg.modules.adweb.common.constant.AdwebConstant;
-import org.jeecg.modules.adweb.seo.mapper.SeoPlanSubscriptionMapper;
 import org.jeecg.modules.adweb.site.dto.param.SiteStepDTO;
 import org.jeecg.modules.adweb.site.entity.AdwebSite;
 import org.jeecg.modules.adweb.site.entity.AdwebSitePermission;
 import org.jeecg.modules.adweb.site.entity.Sohoeb2bOrder;
 import org.jeecg.modules.adweb.site.service.*;
+import org.jeecg.modules.adweb.subscription.mapper.UserPlanSubscriptionMapper;
 import org.jeecg.modules.adweb.system.service.SysAdwebApi;
 import org.jeecg.modules.base.service.BaseCommonService;
 import org.springframework.security.access.prepost.PreAuthorize;
@@ -65,7 +65,7 @@ public class AdwebSiteController extends JeecgController<AdwebSite, IAdwebSiteSe
 
     @Resource private ISitePermissionService sitePermissionService;
 
-    @Resource private SeoPlanSubscriptionMapper seoPlanSubscriptionMapper;
+    @Resource private UserPlanSubscriptionMapper userPlanSubscriptionMapper;
 
     @Resource private SelfWebSiteService selfWebSiteService;
 
@@ -103,11 +103,11 @@ public class AdwebSiteController extends JeecgController<AdwebSite, IAdwebSiteSe
         // 给站点增加营销计划信息
         List<AdwebSite> siteList = pageList.getRecords();
         for (AdwebSite site : siteList) {
-            Map<String, String> marketPlan =
-                    seoPlanSubscriptionMapper.getSubscribePlanBySiteId(site.getId());
+            Map<String, String> subscribePlan =
+                    userPlanSubscriptionMapper.getSubscribePlanBySiteId(site.getId());
             JSONObject object =
                     FastJsonUtil.parseObject(
-                            FastJsonUtil.toJSONString(marketPlan), JSONObject.class);
+                            FastJsonUtil.toJSONString(subscribePlan), JSONObject.class);
             site.setSubscribePlan(object);
 
             // 设置建站进度

+ 3 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/site/dto/result/SiteBasicInfo.java

@@ -9,6 +9,9 @@ public class SiteBasicInfo {
     /** 套餐名称 */
     private String planName;
 
+    /** 套餐类型 - 是否SEO */
+    private String planType;
+
     /** 创建时间 */
     private String createTime;
 

+ 21 - 17
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/site/service/SelfWebSiteServiceCommon.java

@@ -1,8 +1,11 @@
 package org.jeecg.modules.adweb.site.service;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+
 import jakarta.annotation.Resource;
+
 import lombok.extern.slf4j.Slf4j;
+
 import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.jeecg.common.system.vo.LoginUser;
@@ -10,11 +13,11 @@ import org.jeecg.common.util.FastJsonUtil;
 import org.jeecg.modules.adweb.common.constant.AdwebConstant;
 import org.jeecg.modules.adweb.common.util.DateUtil;
 import org.jeecg.modules.adweb.enquiry.constant.EnquiryDistributeTypeConstant;
-import org.jeecg.modules.adweb.seo.entity.SeoPlanSubscription;
-import org.jeecg.modules.adweb.seo.service.ISeoPlanSubscriptionService;
 import org.jeecg.modules.adweb.site.entity.AdwebSite;
-import org.jeecg.modules.adweb.subscribePlan.entity.SubscribePlan;
-import org.jeecg.modules.adweb.subscribePlan.service.ISubscribePlanService;
+import org.jeecg.modules.adweb.subscription.entity.SubscribePlan;
+import org.jeecg.modules.adweb.subscription.entity.UserPlanSubscription;
+import org.jeecg.modules.adweb.subscription.service.ISubscribePlanService;
+import org.jeecg.modules.adweb.subscription.service.IUserPlanSubscriptionService;
 import org.jeecg.modules.adweb.theme.entity.AdwebTheme;
 import org.jeecg.modules.adweb.theme.service.IAdwebThemeService;
 import org.jeecg.modules.system.service.ISysUserTenantService;
@@ -22,11 +25,12 @@ import org.jeecg.modules.system.vo.SysUserTenantVo;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
-import javax.transaction.Transactional;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
 
+import javax.transaction.Transactional;
+
 @Service
 @Slf4j
 public class SelfWebSiteServiceCommon {
@@ -47,7 +51,7 @@ public class SelfWebSiteServiceCommon {
 
     @Resource private IAdwebThemeService adwebThemeService;
 
-    @Resource private ISeoPlanSubscriptionService seoPlanSubscriptionService;
+    @Resource private IUserPlanSubscriptionService userPlanSubscriptionService;
 
     @Resource private ISubscribePlanService subscribePlanService;
 
@@ -132,27 +136,27 @@ public class SelfWebSiteServiceCommon {
         log.info("===================绑定套餐,套餐id:{}==========================", planId);
         log.info(FastJsonUtil.toJSONString(adwebSite));
         if (StringUtils.isNotBlank(planId)) {
-            SubscribePlan seoMarketPlan = subscribePlanService.getById(planId);
-            if (!"SEO".equals(seoMarketPlan.getMarketType())) {
+            SubscribePlan subscribePlan = subscribePlanService.getById(planId);
+            if (!"SEO".equals(subscribePlan.getPlanType())) {
                 giveDay = 0;
                 compensateDay = 0;
             }
-            SeoPlanSubscription history = new SeoPlanSubscription();
-            history.setPlanId(planId);
-            history.setSiteId(adwebSite.getId() + "");
-            history.setIsRenew(0);
+            UserPlanSubscription subscription = new UserPlanSubscription();
+            subscription.setPlanId(planId);
+            subscription.setSiteId(adwebSite.getId() + "");
+            subscription.setIsRenew(0);
 
             if (giveDay != null) {
-                history.setGiveDay(giveDay);
+                subscription.setGiveDay(giveDay);
             } else {
-                history.setGiveDay(0);
+                subscription.setGiveDay(0);
             }
             if (compensateDay != null) {
-                history.setCompensateDay(compensateDay);
+                subscription.setCompensateDay(compensateDay);
             } else {
-                history.setCompensateDay(0);
+                subscription.setCompensateDay(0);
             }
-            seoPlanSubscriptionService.addSeoPlanSubscription(history, sysUser);
+            userPlanSubscriptionService.addUserPlanSubscription(subscription, sysUser);
         }
 
         log.info("================新站点授权===============");

+ 30 - 28
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/site/service/SiteManageService.java

@@ -10,11 +10,11 @@ import lombok.extern.slf4j.Slf4j;
 
 import org.apache.commons.lang3.StringUtils;
 import org.jeecg.modules.adweb.common.util.DateUtil;
-import org.jeecg.modules.adweb.seo.entity.SeoPlanSubscription;
-import org.jeecg.modules.adweb.seo.service.ISeoPlanSubscriptionService;
 import org.jeecg.modules.adweb.site.dto.result.SiteBasicInfo;
 import org.jeecg.modules.adweb.site.entity.AdwebSite;
 import org.jeecg.modules.adweb.site.mapper.AdwebSiteMapper;
+import org.jeecg.modules.adweb.subscription.entity.UserPlanSubscription;
+import org.jeecg.modules.adweb.subscription.service.IUserPlanSubscriptionService;
 import org.jeecg.modules.system.mapper.SysDictMapper;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -35,7 +35,7 @@ public class SiteManageService {
 
     @Resource private IAdwebSiteService adwebSiteService;
 
-    @Resource private ISeoPlanSubscriptionService seoPlanSubscriptionService;
+    @Resource private IUserPlanSubscriptionService userPlanSubscriptionService;
 
     @Resource private SysDictMapper sysDictMapper;
 
@@ -96,44 +96,45 @@ public class SiteManageService {
         siteBasicInfo.setPercentage(siteStatus * 100 / 6);
 
         // 获取绑定的套餐信息
-        SeoPlanSubscription history =
-                seoPlanSubscriptionService.getCurrentSeoAndSiteSubscription(adwebSite.getId());
+        UserPlanSubscription subscription =
+                userPlanSubscriptionService.getCurrentSubscription(adwebSite.getId());
         String defaultPlanName = sysDictMapper.getDefaultPlanName();
         SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
 
         // 绑定时间(提单时间)
         // 如果没有绑定套餐或绑定的为默认建站套餐
-        if (history == null
+        if (subscription == null
                 || (StringUtils.isNotEmpty(defaultPlanName)
-                        && defaultPlanName.equals(history.getPlanName()))) {
+                        && defaultPlanName.equals(subscription.getPlanName()))) {
             siteBasicInfo.setCreateTime(dateFormat.format(adwebSite.getCreateTime()));
         } else {
-            siteBasicInfo.setCreateTime(dateFormat.format(history.getCreateTime()));
+            siteBasicInfo.setCreateTime(dateFormat.format(subscription.getCreateTime()));
         }
 
-        // 套餐名称
-        if (history == null || StringUtils.isEmpty(history.getPlanName())) {
+        // 套餐名称及类型
+        if (subscription == null || StringUtils.isEmpty(subscription.getPlanName())) {
             siteBasicInfo.setPlanName("暂无套餐");
         } else {
-            siteBasicInfo.setPlanName(history.getPlanName());
+            siteBasicInfo.setPlanName(subscription.getPlanName());
+            siteBasicInfo.setPlanType(subscription.getPlanType());
         }
 
         // 预计服务到期时间
-        if (history == null || history.getServiceMonth() == null) {
+        if (subscription == null || subscription.getServiceMonth() == null) {
             return siteBasicInfo;
         }
 
         // 获取到期时间,需要判断到期时间是否是指定时间
-        if (history.getServiceStatus() == 0) {
-            Integer serverMonth = history.getServiceMonth();
-            int remainServerDays = getRemainServerDays(serverMonth, userFlag, history.getId());
+        if (subscription.getServiceStatus() == 0) {
+            Integer serverMonth = subscription.getServiceMonth();
+            int remainServerDays = getRemainServerDays(serverMonth, userFlag, subscription.getId());
             if (remainServerDays > 0) {
-                int giveDay = history.getGiveDay();
-                int compensateDay = history.getCompensateDay();
+                int giveDay = subscription.getGiveDay();
+                int compensateDay = subscription.getCompensateDay();
                 int totalGiveAndCompensateDay = giveDay + compensateDay;
                 log.info(
-                        "getSiteBasicInfo -- historyId:{},giveDay:{},compensateDay:{},totalGiveAndCompensateDay:{}",
-                        history.getId(),
+                        "getSiteBasicInfo -- subscriptionId:{},giveDay:{},compensateDay:{},totalGiveAndCompensateDay:{}",
+                        subscription.getId(),
                         giveDay,
                         compensateDay,
                         totalGiveAndCompensateDay);
@@ -151,13 +152,13 @@ public class SiteManageService {
                 siteBasicInfo.setEndTime("服务已到期");
             }
         } else {
-            Date serveEndTime = history.getServiceEndTime();
-            int giveDay = history.getGiveDay();
-            int compensateDay = history.getCompensateDay();
+            Date serveEndTime = subscription.getServiceEndTime();
+            int giveDay = subscription.getGiveDay();
+            int compensateDay = subscription.getCompensateDay();
             int totalGiveAndCompensateDay = giveDay + compensateDay;
             log.info(
-                    "getSiteBasicInfo -- historyId:{},giveDay:{},compensateDay:{},totalGiveAndCompensateDay:{}",
-                    history.getId(),
+                    "getSiteBasicInfo -- subscriptionId:{},giveDay:{},compensateDay:{},totalGiveAndCompensateDay:{}",
+                    subscription.getId(),
                     giveDay,
                     compensateDay,
                     totalGiveAndCompensateDay);
@@ -187,9 +188,9 @@ public class SiteManageService {
      * @param siteCode 站点的code
      * @return
      */
-    public int getRemainServerDays(int serverMonth, String siteCode, String historyId) {
+    public int getRemainServerDays(int serverMonth, String siteCode, String subscriptionId) {
         int serverDay = (serverMonth * 30) + (serverMonth / 2);
-        int reachStandardDays = this.getReachStandardDays(siteCode, historyId);
+        int reachStandardDays = this.getReachStandardDays(siteCode, subscriptionId);
         return serverDay - reachStandardDays;
     }
 
@@ -197,10 +198,11 @@ public class SiteManageService {
      * 查询关键词达标天数
      *
      * @param siteCode 站点code
-     * @param historyId 绑定的套餐
+     * @param subscriptionId 绑定的套餐
      * @return 关键词达标天数
      */
-    public int getReachStandardDays(String siteCode, String historyId) {
+    @Deprecated
+    public int getReachStandardDays(String siteCode, String subscriptionId) {
         // 查询关键词达标天数
         //        int specifyKeywordNum = 0;
         //        int longTailKeywordNum = 0;

+ 0 - 18
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/subscribePlan/mapper/xml/SubscribePlanMapper.xml

@@ -1,18 +0,0 @@
-<?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.subscribePlan.mapper.SubscribePlanMapper">
-
-    <select id="getSubscribePlanBySiteId"
-            resultType="org.jeecg.modules.adweb.subscribePlan.entity.SubscribePlan">
-        SELECT
-            t1.id,t1.plan_name,specify_keyword,long_tail_keyword,external_links,article
-        from
-            adweb_subscribe_plan t1,
-            adweb_seo_plan_subscription t2
-        where
-            t1.id = t2.plan_id
-            and t1.status = 1
-            and t2.status = 1
-            and t2.site_id = #{siteId}
-    </select>
-</mapper>

+ 26 - 21
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/subscribePlan/controller/SubscribePlanController.java → jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/subscription/controller/SubscribePlanController.java

@@ -1,21 +1,26 @@
-package org.jeecg.modules.adweb.subscribePlan.controller;
+package org.jeecg.modules.adweb.subscription.controller;
 
 import cn.hutool.core.util.RandomUtil;
+
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+
 import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.tags.Tag;
+
 import jakarta.servlet.http.HttpServletRequest;
 import jakarta.servlet.http.HttpServletResponse;
+
 import lombok.extern.slf4j.Slf4j;
+
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.aspect.annotation.AutoLog;
 import org.jeecg.common.system.base.controller.JeecgController;
 import org.jeecg.common.system.query.QueryGenerator;
-import org.jeecg.modules.adweb.subscribePlan.entity.SubscribePlan;
-import org.jeecg.modules.adweb.subscribePlan.service.ISubscribePlanService;
+import org.jeecg.modules.adweb.subscription.entity.SubscribePlan;
+import org.jeecg.modules.adweb.subscription.service.ISubscribePlanService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
@@ -36,7 +41,7 @@ import java.util.List;
 @RequestMapping("/adweb/subscribePlan")
 @Slf4j
 public class SubscribePlanController extends JeecgController<SubscribePlan, ISubscribePlanService> {
-    @Autowired private ISubscribePlanService seoMarketPlanService;
+    @Autowired private ISubscribePlanService subscribePlanService;
 
     //    @Autowired
     //	private IAdwebMaterialCheckService checkService;
@@ -61,7 +66,7 @@ public class SubscribePlanController extends JeecgController<SubscribePlan, ISub
         QueryWrapper<SubscribePlan> queryWrapper =
                 QueryGenerator.initQueryWrapper(subscribePlan, req.getParameterMap());
         Page<SubscribePlan> page = new Page<SubscribePlan>(pageNo, pageSize);
-        IPage<SubscribePlan> pageList = seoMarketPlanService.page(page, queryWrapper);
+        IPage<SubscribePlan> pageList = subscribePlanService.page(page, queryWrapper);
         return Result.OK(pageList);
     }
 
@@ -73,26 +78,26 @@ public class SubscribePlanController extends JeecgController<SubscribePlan, ISub
      */
     @AutoLog(value = "网站营销方案套餐表-添加")
     @Operation(summary = "网站营销方案套餐表-添加")
-    @PreAuthorize("@jps.requiresPermissions('adweb:seo_market_plan:add')")
+    @PreAuthorize("@jps.requiresPermissions('adweb:subscribe_plan:add')")
     @PostMapping(value = "/add")
     public Result<String> add(@RequestBody SubscribePlan subscribePlan) {
 
         subscribePlan.setCreateTime(new Date());
         LambdaQueryWrapper<SubscribePlan> queryWrapper = new LambdaQueryWrapper<>();
-        queryWrapper.eq(SubscribePlan::getMarketType, subscribePlan.getMarketType());
+        queryWrapper.eq(SubscribePlan::getPlanType, subscribePlan.getPlanType());
         queryWrapper.eq(SubscribePlan::getPlanName, subscribePlan.getPlanName());
         queryWrapper.ne(SubscribePlan::getStatus, 0);
-        List<SubscribePlan> seoMarketPlans = seoMarketPlanService.list(queryWrapper);
-        if (!seoMarketPlans.isEmpty()) {
+        List<SubscribePlan> subscribePlans = subscribePlanService.list(queryWrapper);
+        if (!subscribePlans.isEmpty()) {
             return Result.error("方案名称已存在!");
         }
         // 生成编码
-        subscribePlan.setPlanCode(subscribePlan.getMarketType() + getPlanCode());
+        subscribePlan.setPlanCode(subscribePlan.getPlanType() + getPlanCode());
         if (subscribePlan.getKeywordCount() == null) {
             subscribePlan.setKeywordCount(0);
         }
 
-        seoMarketPlanService.save(subscribePlan);
+        subscribePlanService.save(subscribePlan);
         return Result.OK("添加成功!");
     }
 
@@ -104,12 +109,12 @@ public class SubscribePlanController extends JeecgController<SubscribePlan, ISub
      */
     @AutoLog(value = "网站营销方案套餐表-编辑")
     @Operation(summary = "网站营销方案套餐表-编辑")
-    @PreAuthorize("@jps.requiresPermissions('adweb:seo_market_plan:edit')")
+    @PreAuthorize("@jps.requiresPermissions('adweb:subscribe_plan:edit')")
     @RequestMapping(
             value = "/edit",
             method = {RequestMethod.PUT, RequestMethod.POST})
     public Result<String> edit(@RequestBody SubscribePlan subscribePlan) {
-        seoMarketPlanService.updateById(subscribePlan);
+        subscribePlanService.updateById(subscribePlan);
         return Result.OK("编辑成功!");
     }
 
@@ -121,10 +126,10 @@ public class SubscribePlanController extends JeecgController<SubscribePlan, ISub
      */
     @AutoLog(value = "网站营销方案套餐表-通过id删除")
     @Operation(summary = "网站营销方案套餐表-通过id删除")
-    @PreAuthorize("@jps.requiresPermissions('adweb:seo_market_plan:delete')")
+    @PreAuthorize("@jps.requiresPermissions('adweb:subscribe_plan:delete')")
     @DeleteMapping(value = "/delete")
     public Result<String> delete(@RequestParam(name = "id", required = true) String id) {
-        seoMarketPlanService.removeById(id);
+        subscribePlanService.removeById(id);
         return Result.OK("删除成功!");
     }
 
@@ -136,10 +141,10 @@ public class SubscribePlanController extends JeecgController<SubscribePlan, ISub
      */
     @AutoLog(value = "网站营销方案套餐表-批量删除")
     @Operation(summary = "网站营销方案套餐表-批量删除")
-    @PreAuthorize("@jps.requiresPermissions('adweb:seo_market_plan:deleteBatch')")
+    @PreAuthorize("@jps.requiresPermissions('adweb:subscribe_plan:deleteBatch')")
     @DeleteMapping(value = "/deleteBatch")
     public Result<String> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
-        this.seoMarketPlanService.removeByIds(Arrays.asList(ids.split(",")));
+        this.subscribePlanService.removeByIds(Arrays.asList(ids.split(",")));
         return Result.OK("批量删除成功!");
     }
 
@@ -153,7 +158,7 @@ public class SubscribePlanController extends JeecgController<SubscribePlan, ISub
     @Operation(summary = "网站营销方案套餐表-通过id查询")
     @GetMapping(value = "/queryById")
     public Result<SubscribePlan> queryById(@RequestParam(name = "id", required = true) String id) {
-        SubscribePlan subscribePlan = seoMarketPlanService.getById(id);
+        SubscribePlan subscribePlan = subscribePlanService.getById(id);
         if (subscribePlan == null) {
             return Result.error("未找到对应数据");
         }
@@ -166,7 +171,7 @@ public class SubscribePlanController extends JeecgController<SubscribePlan, ISub
      * @param request
      * @param subscribePlan
      */
-    @PreAuthorize("@jps.requiresPermissions('adweb:seo_market_plan:exportXls')")
+    @PreAuthorize("@jps.requiresPermissions('adweb:subscribe_plan:exportXls')")
     @RequestMapping(value = "/exportXls")
     public ModelAndView exportXls(HttpServletRequest request, SubscribePlan subscribePlan) {
         return super.exportXls(request, subscribePlan, SubscribePlan.class, "网站营销方案套餐表");
@@ -179,7 +184,7 @@ public class SubscribePlanController extends JeecgController<SubscribePlan, ISub
      * @param response
      * @return
      */
-    @PreAuthorize("@jps.requiresPermissions('adweb:seo_market_plan:importExcel')")
+    @PreAuthorize("@jps.requiresPermissions('adweb:subscribe_plan:importExcel')")
     @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
     public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
         return super.importExcel(request, response, SubscribePlan.class);
@@ -191,7 +196,7 @@ public class SubscribePlanController extends JeecgController<SubscribePlan, ISub
         planCode = planCode.toUpperCase();
         LambdaQueryWrapper<SubscribePlan> queryWrapper = new LambdaQueryWrapper<>();
         queryWrapper.eq(SubscribePlan::getPlanCode, planCode);
-        int count = (int) seoMarketPlanService.count(queryWrapper);
+        int count = (int) subscribePlanService.count(queryWrapper);
         return count > 0 ? getPlanCode() : planCode;
     }
 

+ 172 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/subscription/controller/UserPlanSubscriptionController.java

@@ -0,0 +1,172 @@
+package org.jeecg.modules.adweb.subscription.controller;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.tags.Tag;
+
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletResponse;
+
+import lombok.extern.slf4j.Slf4j;
+
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.aspect.annotation.AutoLog;
+import org.jeecg.common.system.base.controller.JeecgController;
+import org.jeecg.common.system.query.QueryGenerator;
+import org.jeecg.modules.adweb.subscription.entity.UserPlanSubscription;
+import org.jeecg.modules.adweb.subscription.service.IUserPlanSubscriptionService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.servlet.ModelAndView;
+
+import java.util.Arrays;
+
+/**
+ * @Description: AdWeb套餐订购
+ * @Author: jeecg-boot
+ * @Date: 2024-10-15
+ * @Version: V1.0
+ */
+@Tag(name = "AdWeb套餐订购")
+@RestController
+@RequestMapping("/adweb/userPlanSubscription")
+@Slf4j
+public class UserPlanSubscriptionController
+        extends JeecgController<UserPlanSubscription, IUserPlanSubscriptionService> {
+    @Autowired private IUserPlanSubscriptionService userPlanSubscriptionService;
+
+    /**
+     * 分页列表查询
+     *
+     * @param userPlanSubscription
+     * @param pageNo
+     * @param pageSize
+     * @param req
+     * @return
+     */
+    // @AutoLog(value = "AdWeb套餐订购-分页列表查询")
+    @Operation(summary = "AdWeb套餐订购-分页列表查询")
+    @GetMapping(value = "/list")
+    public Result<IPage<UserPlanSubscription>> queryPageList(
+            UserPlanSubscription userPlanSubscription,
+            @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+            @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
+            HttpServletRequest req) {
+        QueryWrapper<UserPlanSubscription> queryWrapper =
+                QueryGenerator.initQueryWrapper(userPlanSubscription, req.getParameterMap());
+        Page<UserPlanSubscription> page = new Page<UserPlanSubscription>(pageNo, pageSize);
+        IPage<UserPlanSubscription> pageList = userPlanSubscriptionService.page(page, queryWrapper);
+        return Result.OK(pageList);
+    }
+
+    /**
+     * 添加
+     *
+     * @param userPlanSubscription
+     * @return
+     */
+    @AutoLog(value = "AdWeb套餐订购-添加")
+    @Operation(summary = "AdWeb套餐订购-添加")
+    @PreAuthorize("@jps.requiresPermissions('adweb:user_plan_subscription:add')")
+    @PostMapping(value = "/add")
+    public Result<String> add(@RequestBody UserPlanSubscription userPlanSubscription) {
+        userPlanSubscriptionService.save(userPlanSubscription);
+        return Result.OK("添加成功!");
+    }
+
+    /**
+     * 编辑
+     *
+     * @param userPlanSubscription
+     * @return
+     */
+    @AutoLog(value = "AdWeb套餐订购-编辑")
+    @Operation(summary = "AdWeb套餐订购-编辑")
+    @PreAuthorize("@jps.requiresPermissions('adweb:user_plan_subscription:edit')")
+    @RequestMapping(
+            value = "/edit",
+            method = {RequestMethod.PUT, RequestMethod.POST})
+    public Result<String> edit(@RequestBody UserPlanSubscription userPlanSubscription) {
+        userPlanSubscriptionService.updateById(userPlanSubscription);
+        return Result.OK("编辑成功!");
+    }
+
+    /**
+     * 通过id删除
+     *
+     * @param id
+     * @return
+     */
+    @AutoLog(value = "AdWeb套餐订购-通过id删除")
+    @Operation(summary = "AdWeb套餐订购-通过id删除")
+    @PreAuthorize("@jps.requiresPermissions('adweb:user_plan_subscription:delete')")
+    @DeleteMapping(value = "/delete")
+    public Result<String> delete(@RequestParam(name = "id", required = true) String id) {
+        userPlanSubscriptionService.removeById(id);
+        return Result.OK("删除成功!");
+    }
+
+    /**
+     * 批量删除
+     *
+     * @param ids
+     * @return
+     */
+    @AutoLog(value = "AdWeb套餐订购-批量删除")
+    @Operation(summary = "AdWeb套餐订购-批量删除")
+    @PreAuthorize("@jps.requiresPermissions('adweb:user_plan_subscription:deleteBatch')")
+    @DeleteMapping(value = "/deleteBatch")
+    public Result<String> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
+        this.userPlanSubscriptionService.removeByIds(Arrays.asList(ids.split(",")));
+        return Result.OK("批量删除成功!");
+    }
+
+    /**
+     * 通过id查询
+     *
+     * @param id
+     * @return
+     */
+    // @AutoLog(value = "AdWeb套餐订购-通过id查询")
+    @Operation(summary = "AdWeb套餐订购-通过id查询")
+    @GetMapping(value = "/queryById")
+    public Result<UserPlanSubscription> queryById(
+            @RequestParam(name = "id", required = true) String id) {
+        UserPlanSubscription userPlanSubscription = userPlanSubscriptionService.getById(id);
+        if (userPlanSubscription == null) {
+            return Result.error("未找到对应数据");
+        }
+        return Result.OK(userPlanSubscription);
+    }
+
+    /**
+     * 导出excel
+     *
+     * @param request
+     * @param userPlanSubscription
+     */
+    @PreAuthorize("@jps.requiresPermissions('adweb:user_plan_subscription:exportXls')")
+    @RequestMapping(value = "/exportXls")
+    public ModelAndView exportXls(
+            HttpServletRequest request, UserPlanSubscription userPlanSubscription) {
+        return super.exportXls(
+                request, userPlanSubscription, UserPlanSubscription.class, "AdWeb套餐订购");
+    }
+
+    /**
+     * 通过excel导入数据
+     *
+     * @param request
+     * @param response
+     * @return
+     */
+    @PreAuthorize("@jps.requiresPermissions('adweb:user_plan_subscription:importExcel')")
+    @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
+    public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
+        return super.importExcel(request, response, UserPlanSubscription.class);
+    }
+}

+ 56 - 79
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/subscribePlan/entity/SubscribePlan.java → jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/subscription/entity/SubscribePlan.java

@@ -1,13 +1,16 @@
-package org.jeecg.modules.adweb.subscribePlan.entity;
+package org.jeecg.modules.adweb.subscription.entity;
 
 import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.fasterxml.jackson.annotation.JsonFormat;
+
 import io.swagger.v3.oas.annotations.media.Schema;
+
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.experimental.Accessors;
+
 import org.jeecg.common.aspect.annotation.Dict;
 import org.jeecgframework.poi.excel.annotation.Excel;
 import org.springframework.format.annotation.DateTimeFormat;
@@ -15,7 +18,7 @@ import org.springframework.format.annotation.DateTimeFormat;
 import java.io.Serializable;
 
 /**
- * @Description: 网站营销方案套餐表
+ * @Description: AdWeb套餐表
  * @Author: jeecg-boot
  * @Date: 2024-09-27
  * @Version: V1.0
@@ -24,129 +27,103 @@ import java.io.Serializable;
 @TableName("adweb_subscribe_plan")
 @Accessors(chain = true)
 @EqualsAndHashCode(callSuper = false)
-@Schema(description = "网站营销方案套餐表")
+@Schema(description = "AdWeb套餐表")
 public class SubscribePlan implements Serializable {
     private static final long serialVersionUID = 1L;
 
-    /**
-     * 主键
-     */
+    /** 主键 */
     @TableId(type = IdType.ASSIGN_ID)
     @Schema(description = "主键")
     private java.lang.String id;
-    /**
-     * 创建人
-     */
+
+    /** 创建人 */
     @Schema(description = "创建人")
     private java.lang.String createBy;
-    /**
-     * 更新人
-     */
+
+    /** 更新人 */
     @Schema(description = "更新人")
     private java.lang.String updateBy;
-    /**
-     * 创建日期
-     */
+
+    /** 创建日期 */
     @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
     @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     @Schema(description = "创建日期")
     private java.util.Date createTime;
-    /**
-     * 更新日期
-     */
+
+    /** 更新日期 */
     @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
     @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     @Schema(description = "更新日期")
     private java.util.Date updateTime;
-    /**
-     * 营销方案编码
-     */
-    @Excel(name = "营销方案编码", width = 15)
-    @Schema(description = "营销方案编码")
+
+    /** 套餐编码 */
+    @Excel(name = "套餐编码", width = 15)
+    @Schema(description = "套餐编码")
     private java.lang.String planCode;
-    /**
-     * 套餐类型
-     */
-    @Excel(name = "套餐类型", width = 15)
-    @Schema(description = "套餐类型")
-    @Dict(dicCode = "dict_market_type")
-    private java.lang.String marketType;
-    /**
-     * 套餐名称
-     */
+
+    /** 套餐名称 */
     @Excel(name = "套餐名称", width = 15)
     @Schema(description = "套餐名称")
     private java.lang.String planName;
-    /**
-     * 关键词数量
-     */
+
+    /** 套餐类型 */
+    @Excel(name = "套餐类型", width = 15)
+    @Schema(description = "套餐类型")
+    @Dict(dicCode = "dict_plan_type")
+    private java.lang.String planType;
+
+    /** 关键词数量 */
     @Excel(name = "关键词数量", width = 15)
     @Schema(description = "关键词数量")
     private java.lang.Integer keywordCount;
-    /**
-     * 关键词达标目标
-     */
-    @Excel(name = "关键词达标目标", width = 15)
-    @Schema(description = "关键词达标目标")
+
+    /** 关键词达标目标排名 */
+    @Excel(name = "关键词达标目标排名", width = 15)
+    @Schema(description = "关键词达标目标排名")
     private java.lang.Integer target;
-    /**
-     * 服务时间
-     */
+
+    /** 服务时间 */
     @Excel(name = "服务时间", width = 15)
     @Schema(description = "服务时间")
     private java.lang.Integer serviceTime;
-    /**
-     * 状态
-     */
+
+    /** 状态 */
     @Excel(name = "状态", width = 15)
     @Schema(description = "状态")
     private java.lang.Integer status;
-    /**
-     * 价格
-     */
+
+    /** 价格 */
     @Excel(name = "价格", width = 15)
     @Schema(description = "价格")
     private java.lang.Double price;
 
-    /**
-     * 文章数量
-     */
-    @Excel(name = "文章数量", width = 15)
-    @Schema(description = "文章数量")
-    private java.lang.Integer article;
+    /** 指定词数量 */
+    @Excel(name = "指定词数量", width = 15)
+    @Schema(description = "指定词数量")
+    private java.lang.Integer specifyKeyword;
+
+    /** 长尾词数量 */
+    @Excel(name = "长尾词数量", width = 15)
+    @Schema(description = "长尾词数量")
+    private java.lang.Integer longTailKeyword;
 
-    /**
-     * 博客数量
-     */
+    /** 博客数量 */
     @Excel(name = "博客数量", width = 15)
     @Schema(description = "博客数量")
     private java.lang.Integer blog;
 
-    /**
-     * 外链数量
-     */
+    /** 文章数量 */
+    @Excel(name = "文章数量", width = 15)
+    @Schema(description = "文章数量")
+    private java.lang.Integer article;
+
+    /** 外链数量 */
     @Excel(name = "外链数量", width = 15)
     @Schema(description = "外链数量")
     private java.lang.Integer externalLinks;
 
-    /**
-     * 长尾词数量
-     */
-    @Excel(name = "长尾词数量", width = 15)
-    @Schema(description = "长尾词数量")
-    private java.lang.Integer longTailKeyword;
-
-    /**
-     * 访问数量
-     */
+    /** 访问数量 */
     @Excel(name = "访问数量", width = 15)
     @Schema(description = "访问数量")
     private java.lang.Integer pageView;
-
-    /**
-     * 指定词数量
-     */
-    @Excel(name = "指定词数量", width = 15)
-    @Schema(description = "指定词数量")
-    private java.lang.Integer specifyKeyword;
 }

+ 56 - 79
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/seo/entity/SeoPlanSubscription.java → jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/subscription/entity/UserPlanSubscription.java

@@ -1,13 +1,16 @@
-package org.jeecg.modules.adweb.seo.entity;
+package org.jeecg.modules.adweb.subscription.entity;
 
 import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.fasterxml.jackson.annotation.JsonFormat;
+
 import io.swagger.v3.oas.annotations.media.Schema;
+
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.experimental.Accessors;
+
 import org.jeecgframework.poi.excel.annotation.Excel;
 import org.springframework.format.annotation.DateTimeFormat;
 
@@ -15,168 +18,142 @@ import java.io.Serializable;
 import java.util.Date;
 
 /**
- * @Description: seo套餐订购
+ * @Description: AdWeb套餐订购
  * @Author: jeecg-boot
- * @Date: 2024-10-15
- * @Version: V1.0
+ * @Date: 2024-10-15@Version: V1.0
  */
 @Data
-@TableName("adweb_seo_plan_subscription")
+@TableName("adweb_sysuser_plan_subscription")
 @Accessors(chain = true)
 @EqualsAndHashCode(callSuper = false)
-@Schema(description = "seo套餐订购")
-public class SeoPlanSubscription implements Serializable {
+@Schema(description = "AdWeb套餐订购")
+public class UserPlanSubscription implements Serializable {
     private static final long serialVersionUID = 1L;
 
-    /**
-     * 主键
-     */
+    /** 主键 */
     @TableId(type = IdType.ASSIGN_ID)
     @Schema(description = "主键")
     private String id;
-    /**
-     * 站点
-     */
+
+    /** 站点 */
     @Excel(name = "站点", width = 15)
     @Schema(description = "站点")
     private String siteId;
-    /**
-     * 套餐
-     */
+
+    /** 套餐 */
     @Excel(name = "套餐", width = 15)
     @Schema(description = "套餐")
     private String planId;
-    /**
-     * 创建人
-     */
+
+    /** 创建人 */
     @Schema(description = "创建人")
     private String createBy;
-    /**
-     * 创建日期
-     */
+
+    /** 创建日期 */
     @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
     @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     @Schema(description = "创建日期")
     private Date createTime;
-    /**
-     * 状态
-     */
+
+    /** 状态 */
     @Excel(name = "状态", width = 15)
     @Schema(description = "状态")
     private Integer status;
-    /**
-     * 方案使用者ID
-     */
+
+    /** 方案使用者ID */
     @Excel(name = "方案使用者ID", width = 15)
     @Schema(description = "方案使用者ID")
     private String usedUid;
-    /**
-     * 方案类型
-     */
+
+    /** 方案类型 */
     @Excel(name = "方案类型", width = 15)
     @Schema(description = "方案类型")
     private String planType;
-    /**
-     * 方案价格
-     */
+
+    /** 方案价格 */
     @Excel(name = "方案价格", width = 15)
     @Schema(description = "方案价格")
     private Double planPrice;
-    /**
-     * 方案编码
-     */
+
+    /** 方案编码 */
     @Excel(name = "方案编码", width = 15)
     @Schema(description = "方案编码")
     private String planCode;
-    /**
-     * 方案名称
-     */
+
+    /** 方案名称 */
     @Excel(name = "方案名称", width = 15)
     @Schema(description = "方案名称")
     private String planName;
-    /**
-     * 指定关键词最早达标时间
-     */
+
+    /** 指定关键词最早达标时间 */
     @Excel(name = "指定关键词最早达标时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
     @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
     @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     @Schema(description = "指定关键词最早达标时间")
     private Date keywordsAchieveTime;
-    /**
-     * 是否续费
-     */
+
+    /** 是否续费 */
     @Excel(name = "是否续费", width = 15)
     @Schema(description = "是否续费")
     private Integer isRenew;
-    /**
-     * 是否自定义套餐开始时间
-     */
+
+    /** 是否自定义套餐开始时间 */
     @Excel(name = "是否自定义套餐开始时间", width = 15)
     @Schema(description = "是否自定义套餐开始时间")
     private Integer isCustom;
-    /**
-     * 套餐开启时间
-     */
+
+    /** 套餐开启时间 */
     @Excel(name = "套餐开启时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
     @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
     @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     @Schema(description = "套餐开启时间")
     private Date planStartTime;
-    /**
-     * 服务开启时间
-     */
+
+    /** 服务开启时间 */
     @Excel(name = "服务开启时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
     @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
     @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     @Schema(description = "服务开启时间")
     private Date serviceStartTime;
-    /**
-     * 服务到期时间
-     */
+
+    /** 服务到期时间 */
     @Excel(name = "服务到期时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
     @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
     @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     @Schema(description = "服务到期时间")
     private Date serviceEndTime;
-    /**
-     * 套餐详情的服务时长的按钮切换
-     */
+
+    /** 套餐详情的服务时长的按钮切换 */
     @Excel(name = "套餐详情的服务时长的按钮切换", width = 15)
     @Schema(description = "套餐详情的服务时长的按钮切换")
     private Integer serviceStatus;
-    /**
-     * 套餐时长(单位:月份)
-     */
+
+    /** 套餐时长(单位:月份) */
     @Excel(name = "套餐时长(单位:月份)", width = 15)
     @Schema(description = "套餐时长(单位:月份)")
     private Integer serviceMonth;
-    /**
-     * 0不需要提醒,1需要提醒
-     */
+
+    /** 0不需要提醒,1需要提醒 */
     @Excel(name = "0不需要提醒,1需要提醒", width = 15)
     @Schema(description = "0不需要提醒,1需要提醒")
     private Integer remind;
-    /**
-     * 备注
-     */
+
+    /** 备注 */
     @Excel(name = "备注", width = 15)
     @Schema(description = "备注")
     private String remark;
-    /**
-     * 优化人uid
-     */
+
+    /** 优化人uid */
     @Excel(name = "优化人uid", width = 15)
     @Schema(description = "优化人uid")
     private String optimizerUid;
-    /**
-     * 赠送天数
-     */
+
+    /** 赠送天数 */
     @Excel(name = "赠送天数", width = 15)
     @Schema(description = "赠送天数")
     private Integer giveDay;
-    /**
-     * 补偿天数
-     */
+
+    /** 补偿天数 */
     @Excel(name = "补偿天数", width = 15)
     @Schema(description = "补偿天数")
     private Integer compensateDay;

+ 2 - 2
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/subscribePlan/mapper/SubscribePlanMapper.java → jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/subscription/mapper/SubscribePlanMapper.java

@@ -1,6 +1,6 @@
-package org.jeecg.modules.adweb.subscribePlan.mapper;
+package org.jeecg.modules.adweb.subscription.mapper;
 
-import org.jeecg.modules.adweb.subscribePlan.entity.SubscribePlan;
+import org.jeecg.modules.adweb.subscription.entity.SubscribePlan;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 
 /**

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

@@ -0,0 +1,35 @@
+package org.jeecg.modules.adweb.subscription.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+import org.apache.ibatis.annotations.Select;
+import org.jeecg.modules.adweb.subscription.entity.UserPlanSubscription;
+
+import java.util.Map;
+
+/**
+ * @Description: AdWeb套餐订购
+ * @Author: jeecg-boot
+ * @Date: 2024-10-15
+ * @Version: V1.0
+ */
+public interface UserPlanSubscriptionMapper extends BaseMapper<UserPlanSubscription> {
+    /**
+     * 根据站点code获取关键词达标标准
+     *
+     * @param siteCode 站点code
+     * @return 达标标准
+     */
+    int getKeywordTarget(String siteCode);
+
+    /**
+     * 根据站点id,查询站点的营销方案
+     *
+     * @return: @Author: luxiaoxiao @Date: 2021/4/6
+     */
+    @Select(
+            "select t1.plan_name planName, t1.keyword_count keywordCount, t1.service_time serviceTime, t1.price price,t2.plan_id planId "
+                    + "from adweb_subscribe_plan t1 ,adweb_sysuser_plan_subscription t2 "
+                    + "where t1.id = t2.plan_id AND t2.site_id = #{siteId} AND t2.status = 1")
+    Map<String, String> getSubscribePlanBySiteId(Integer siteId);
+}

+ 18 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/subscription/mapper/xml/SubscribePlanMapper.xml

@@ -0,0 +1,18 @@
+<?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.SubscribePlanMapper">
+
+    <select id="getSubscribePlanBySiteId"
+            resultType="org.jeecg.modules.adweb.subscription.entity.SubscribePlan">
+        SELECT
+        t1.id, t1.plan_name, target, specify_keyword, long_tail_keyword, external_links, article
+        from
+        adweb_subscribe_plan t1,
+        adweb_sysuser_plan_subscription t2
+        where
+        t1.id = t2.plan_id
+        and t1.status = 1
+        and t2.status = 1
+        and t2.site_id = #{siteId}
+    </select>
+</mapper>

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

@@ -0,0 +1,18 @@
+<?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="getKeywordTarget" resultType="java.lang.Integer">
+        SELECT
+        IF(COUNT(*) = 0 OR t1.target IS NULL, 10, t1.target)
+        FROM
+        adweb_subscribe_plan t1,
+        adweb_sysuser_plan_subscription t2,
+        adweb_site t3
+        WHERE
+        t2.`status` = 1
+        AND t1.id = t2.plan_id
+        AND t2.site_id = t3.id
+        AND t3.`code` = #{siteCode}
+        GROUP BY t1.target
+    </select>
+</mapper>

+ 2 - 2
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/subscribePlan/service/ISubscribePlanService.java → jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/subscription/service/ISubscribePlanService.java

@@ -1,6 +1,6 @@
-package org.jeecg.modules.adweb.subscribePlan.service;
+package org.jeecg.modules.adweb.subscription.service;
 
-import org.jeecg.modules.adweb.subscribePlan.entity.SubscribePlan;
+import org.jeecg.modules.adweb.subscription.entity.SubscribePlan;
 import com.baomidou.mybatisplus.extension.service.IService;
 
 /**

+ 39 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/subscription/service/IUserPlanSubscriptionService.java

@@ -0,0 +1,39 @@
+package org.jeecg.modules.adweb.subscription.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.system.vo.LoginUser;
+import org.jeecg.modules.adweb.subscription.entity.SubscribePlan;
+import org.jeecg.modules.adweb.subscription.entity.UserPlanSubscription;
+
+/**
+ * @Description: AdWeb套餐订购
+ * @Author: jeecg-boot
+ * @Date: 2024-10-15
+ * @Version: V1.0
+ */
+public interface IUserPlanSubscriptionService extends IService<UserPlanSubscription> {
+
+    /**
+     * 绑定AdWeb套餐
+     *
+     * @param userPlanSubscription
+     * @param sysUser
+     * @return
+     */
+    Result<?> addUserPlanSubscription(UserPlanSubscription userPlanSubscription, LoginUser sysUser);
+
+    /**
+     * 新增套餐订阅记录
+     *
+     * @param userPlanSubscription
+     * @param subscribePlan
+     * @return
+     */
+    boolean addNewSubscription(
+            UserPlanSubscription userPlanSubscription, SubscribePlan subscribePlan);
+
+    /** 获取正在使用中的AdWeb套餐,如果没有使用中的SEO和建站套餐,则查询过期的套餐 */
+    UserPlanSubscription getCurrentSubscription(Integer siteId);
+}

+ 4 - 4
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/subscribePlan/service/impl/SubscribePlanServiceImpl.java → jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/subscription/service/impl/SubscribePlanServiceImpl.java

@@ -1,10 +1,10 @@
-package org.jeecg.modules.adweb.subscribePlan.service.impl;
+package org.jeecg.modules.adweb.subscription.service.impl;
 
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 
-import org.jeecg.modules.adweb.subscribePlan.entity.SubscribePlan;
-import org.jeecg.modules.adweb.subscribePlan.mapper.SubscribePlanMapper;
-import org.jeecg.modules.adweb.subscribePlan.service.ISubscribePlanService;
+import org.jeecg.modules.adweb.subscription.entity.SubscribePlan;
+import org.jeecg.modules.adweb.subscription.mapper.SubscribePlanMapper;
+import org.jeecg.modules.adweb.subscription.service.ISubscribePlanService;
 import org.springframework.stereotype.Service;
 
 /**

+ 192 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/subscription/service/impl/UserPlanSubscriptionServiceImpl.java

@@ -0,0 +1,192 @@
+package org.jeecg.modules.adweb.subscription.service.impl;
+
+import cn.hutool.core.date.DateTime;
+import cn.hutool.core.date.DateUnit;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+
+import jakarta.annotation.Resource;
+
+import org.apache.commons.collections4.CollectionUtils;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.system.vo.LoginUser;
+import org.jeecg.modules.adweb.subscription.entity.SubscribePlan;
+import org.jeecg.modules.adweb.subscription.entity.UserPlanSubscription;
+import org.jeecg.modules.adweb.subscription.mapper.UserPlanSubscriptionMapper;
+import org.jeecg.modules.adweb.subscription.service.ISubscribePlanService;
+import org.jeecg.modules.adweb.subscription.service.IUserPlanSubscriptionService;
+import org.springframework.stereotype.Service;
+
+import java.util.Arrays;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * @Description: AdWeb套餐订购
+ * @Author: jeecg-boot
+ * @Date: 2024-10-15
+ * @Version: V1.0
+ */
+@Service
+public class UserPlanSubscriptionServiceImpl
+        extends ServiceImpl<UserPlanSubscriptionMapper, UserPlanSubscription>
+        implements IUserPlanSubscriptionService {
+
+    @Resource private ISubscribePlanService subscribePlanService;
+
+    @Override
+    public Result<?> addUserPlanSubscription(
+            UserPlanSubscription userPlanSubscription, LoginUser sysUser) {
+        boolean result = false;
+
+        SubscribePlan subscribePlan =
+                subscribePlanService.getById(userPlanSubscription.getPlanId());
+        if (subscribePlan == null) {
+            return Result.error("此套餐不存在");
+        }
+
+        if (sysUser != null) {
+            userPlanSubscription.setCreateBy(sysUser.getId());
+        } else {
+            userPlanSubscription.setCreateBy("system_auto");
+        }
+
+        // 如果不是续费客户(就是新客户)的话,直接入库,套餐开启时间即是现在
+        if (userPlanSubscription.getIsRenew() == null || userPlanSubscription.getIsRenew() == 0) {
+            LambdaQueryWrapper<UserPlanSubscription> queryWrapper = new LambdaQueryWrapper<>();
+            queryWrapper.eq(UserPlanSubscription::getSiteId, userPlanSubscription.getSiteId());
+            queryWrapper.eq(UserPlanSubscription::getStatus, 1);
+            List<UserPlanSubscription> userPlanSubscriptionList = this.list(queryWrapper);
+            if (!CollectionUtils.isEmpty(userPlanSubscriptionList)) {
+                return Result.error("站点存在使用中套餐,请到期后绑定!");
+            }
+            result = this.addNewSubscription(userPlanSubscription, subscribePlan);
+        } else { // 续费
+            // 判断是否有正在使用的套餐,如果没有,新建status为1的套餐
+            LambdaQueryWrapper<UserPlanSubscription> oldQueryWrapper = new LambdaQueryWrapper<>();
+            oldQueryWrapper.eq(UserPlanSubscription::getSiteId, userPlanSubscription.getSiteId());
+            oldQueryWrapper.eq(UserPlanSubscription::getStatus, 1);
+            List<UserPlanSubscription> oldSubscriptionList = this.list(oldQueryWrapper);
+            if (CollectionUtils.isEmpty(oldSubscriptionList)) {
+                return Result.error("站点不存在使用中套餐,请先新增套餐");
+            } else {
+                LambdaQueryWrapper<UserPlanSubscription> queryWrapper = new LambdaQueryWrapper<>();
+                queryWrapper.eq(UserPlanSubscription::getSiteId, userPlanSubscription.getSiteId());
+                queryWrapper.eq(UserPlanSubscription::getStatus, 2);
+                List<UserPlanSubscription> userPlanSubscriptionList = this.list(queryWrapper);
+                if (!CollectionUtils.isEmpty(userPlanSubscriptionList)) {
+                    return Result.error("同一站点不能同时续费多个相同类型的套餐!");
+                }
+
+                if (userPlanSubscription.getIsCustom() == 0) {
+                    // ->不是自定义服务开启时间 需找到多个套餐服务结束时间最大的那个
+                    // 此站点所有对应的套餐的最大服务结束时间
+                    UserPlanSubscription subscription =
+                            this.getOne(
+                                    new LambdaQueryWrapper<UserPlanSubscription>()
+                                            .eq(
+                                                    UserPlanSubscription::getSiteId,
+                                                    userPlanSubscription.getSiteId())
+                                            .and(
+                                                    wrapper ->
+                                                            wrapper.eq(
+                                                                            UserPlanSubscription
+                                                                                    ::getStatus,
+                                                                            1)
+                                                                    .or()
+                                                                    .eq(
+                                                                            UserPlanSubscription
+                                                                                    ::getStatus,
+                                                                            2))
+                                            .orderByDesc(UserPlanSubscription::getServiceEndTime)
+                                            .last("limit 1"));
+                    Date maxEndTime = null;
+                    if (subscription == null || subscription.getServiceEndTime() == null) {
+                        maxEndTime = new Date();
+                    } else {
+                        maxEndTime = subscription.getServiceEndTime();
+                    }
+                    userPlanSubscription.setCreateTime(new Date());
+                    userPlanSubscription.setPlanStartTime(maxEndTime);
+                    userPlanSubscription.setStatus(2);
+                    userPlanSubscription.setPlanName(subscribePlan.getPlanName());
+                    userPlanSubscription.setPlanCode(subscribePlan.getPlanCode());
+                    userPlanSubscription.setPlanPrice(subscribePlan.getPrice());
+                    userPlanSubscription.setPlanType(subscribePlan.getPlanType());
+                    userPlanSubscription.setServiceMonth(subscribePlan.getServiceTime());
+                    result = this.save(userPlanSubscription);
+                } else if (userPlanSubscription.getIsCustom() == 1) { // 是自定义套餐开启时间
+                    userPlanSubscription.setCreateTime(new Date());
+                    userPlanSubscription.setPlanName(subscribePlan.getPlanName());
+                    userPlanSubscription.setPlanCode(subscribePlan.getPlanCode());
+                    userPlanSubscription.setPlanPrice(subscribePlan.getPrice());
+                    userPlanSubscription.setPlanType(subscribePlan.getPlanType());
+                    DateTime today = cn.hutool.core.date.DateUtil.date();
+                    long betweenTime =
+                            cn.hutool.core.date.DateUtil.between(
+                                    userPlanSubscription.getPlanStartTime(),
+                                    today,
+                                    DateUnit.DAY,
+                                    false);
+                    if (betweenTime > 0) {
+                        return Result.error("自定义时间请选择于今天之后!");
+                    } else {
+                        // 如果有正在使用的套餐,才能设置为2,否则设置为1
+                        userPlanSubscription.setStatus(2);
+                    }
+                    userPlanSubscription.setServiceMonth(subscribePlan.getServiceTime());
+                    result = this.save(userPlanSubscription);
+                }
+            }
+        }
+
+        if (result) {
+
+            return Result.OK("添加成功!");
+        }
+
+        return Result.error("添加失败!");
+    }
+
+    @Override
+    public boolean addNewSubscription(
+            UserPlanSubscription userPlanSubscription, SubscribePlan subscribePlan) {
+        boolean result = false;
+        try {
+            Date startTime = new Date();
+            userPlanSubscription.setCreateTime(startTime);
+            userPlanSubscription.setPlanStartTime(startTime);
+            userPlanSubscription.setStatus(1); // 使用中
+            userPlanSubscription.setPlanName(subscribePlan.getPlanName());
+            userPlanSubscription.setPlanCode(subscribePlan.getPlanCode());
+            userPlanSubscription.setPlanPrice(subscribePlan.getPrice());
+            userPlanSubscription.setPlanType(subscribePlan.getPlanType());
+            userPlanSubscription.setServiceMonth(subscribePlan.getServiceTime());
+            result = this.save(userPlanSubscription);
+        } catch (Exception e) {
+            log.error("站点新绑定套餐失败", e);
+        }
+        return result;
+    }
+
+    /** 获取正在使用中的AdWeb套餐,如果没有使用中的SEO和建站套餐,则查询过期的套餐 */
+    @Override
+    public UserPlanSubscription getCurrentSubscription(Integer siteId) {
+        LambdaQueryWrapper<UserPlanSubscription> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(UserPlanSubscription::getSiteId, siteId);
+        queryWrapper.and(
+                wrapper ->
+                        wrapper.eq(UserPlanSubscription::getPlanType, "SEO")
+                                .or()
+                                .eq(UserPlanSubscription::getPlanType, "STATIONCONSTRUCTION"));
+        queryWrapper.in(UserPlanSubscription::getStatus, Arrays.asList(1, -1));
+        queryWrapper.orderByDesc(
+                UserPlanSubscription::getStatus, UserPlanSubscription::getCreateTime);
+        List<UserPlanSubscription> userPlanSubscriptions = this.list(queryWrapper);
+        if (CollectionUtils.isNotEmpty(userPlanSubscriptions)) {
+            return userPlanSubscriptions.get(0);
+        }
+        return null;
+    }
+}

+ 2 - 2
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/mapper/xml/SysDictMapper.xml

@@ -247,10 +247,10 @@
         FROM sys_dict t1,
              sys_dict_item t2
         WHERE t1.id = t2.dict_id
-          AND t1.dict_code = 'default_market_plan'
+          AND t1.dict_code = 'default_subscribe_plan'
           AND t1.del_flag = 0
           AND t2.`status` = 1
-          AND t2.item_text = 'default_market_plan' LIMIT 1
+          AND t2.item_text = 'default_subscribe_plan' LIMIT 1
     </select>
 
 </mapper>

+ 1 - 1
jeecg-module-system/jeecg-system-start/src/main/resources/application-prod.yml

@@ -461,6 +461,6 @@ serverIp:
 
 ### 资源额度
 resource-quota:
-  default-website-quota: 3
+  default-website-quota: 1
   default-ai-power-quota: 200
   default-customs-data-quota: 100