Browse Source

Merge branch 'cpq-dev' of wangfan/adweb3-server into master

chenpeiqing 3 months ago
parent
commit
7b9bcf3873

+ 27 - 3
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/site/controller/AdwebSiteManageController.java

@@ -17,6 +17,7 @@ import org.jeecg.common.system.base.controller.JeecgController;
 import org.jeecg.common.system.vo.LoginUser;
 import org.jeecg.config.security.utils.SecureUtil;
 import org.jeecg.modules.adweb.common.mapper.CommonMapper;
+import org.jeecg.modules.adweb.common.util.DateUtil;
 import org.jeecg.modules.adweb.site.dto.WordPressConfig;
 import org.jeecg.modules.adweb.site.dto.result.SiteBasicInfo;
 import org.jeecg.modules.adweb.site.entity.AdwebSite;
@@ -29,11 +30,10 @@ import org.jeecg.modules.adweb.system.service.SysAdwebApi;
 import org.jeecg.modules.system.entity.SysUser;
 import org.jeecg.modules.system.entity.SysUserTenant;
 import org.jeecg.modules.system.service.ISysUserTenantService;
+import org.springframework.context.annotation.Lazy;
 import org.springframework.web.bind.annotation.*;
 
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
+import java.util.*;
 import java.util.stream.Collectors;
 
 /**
@@ -48,6 +48,7 @@ import java.util.stream.Collectors;
 @Slf4j
 public class AdwebSiteManageController extends JeecgController<AdwebSite, IAdwebSiteService> {
 
+    @Lazy
     @Resource
     private IAdwebSiteService adwebSiteManageService;
 
@@ -195,6 +196,29 @@ public class AdwebSiteManageController extends JeecgController<AdwebSite, IAdweb
         return Result.OK("操作成功!");
     }
 
+    /**
+     * 订单数据配置及站点信息
+     *
+     * @param siteCode
+     * @return
+     */
+    @GetMapping(value = "/getSiteOrderInfo")
+    public Result<?> getSiteOrderInfo(String siteCode) {
+        log.info("siteCode:{}", siteCode);
+        LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+        log.info("loginUser:{}", loginUser);
+
+        Map<String, Object> resultMap = new HashMap<>();
+        Sohoeb2bOrder siteOrderPost = sohoeb2bOrderService.getBySiteCode(siteCode);
+        log.info("siteOrderPost:{}", siteOrderPost);
+        if (siteOrderPost != null) {
+            resultMap.put("orderUrl", siteOrderPost.getOrderUrl() + "&master=" + (adwebSiteManageService.hasSub(loginUser) ? 1 : 0) + "&username=" + loginUser.getUsername() + "&time=" + DateUtil.getDate().getTime());
+            return Result.OK(resultMap);
+        }
+
+        return Result.error("站点订单Url未设置!");
+    }
+
     private Boolean validateSiteCode(String code) {
         LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
 

+ 8 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/site/service/IAdwebSiteService.java

@@ -1,6 +1,7 @@
 package org.jeecg.modules.adweb.site.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
+import org.jeecg.common.system.vo.LoginUser;
 import org.jeecg.modules.adweb.site.dto.WordPressConfig;
 import org.jeecg.modules.adweb.site.entity.AdwebSite;
 
@@ -68,4 +69,11 @@ public interface IAdwebSiteService extends IService<AdwebSite> {
     List<String> getAllActiveSiteCodes();
 
     boolean updateSiteFlow(String siteCode);
+
+    /**
+     * 判断此账号是有子账号或者此账号本身是子账号
+     *
+     * @return
+     */
+    boolean hasSub(LoginUser loginUser);
 }

+ 17 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/site/service/impl/AdwebSiteServiceImpl.java

@@ -23,9 +23,11 @@ import org.jeecg.modules.adweb.site.mapper.AdwebSiteMapper;
 import org.jeecg.modules.adweb.site.service.IAdwebSiteService;
 import org.jeecg.modules.adweb.site.service.IAdwebUserWpsiteService;
 import org.jeecg.modules.adweb.site.service.ISiteUserPermissionService;
+import org.jeecg.modules.adweb.system.service.IMasterSubAccountRelationService;
 import org.jeecg.modules.system.mapper.SysUserRoleMapper;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Lazy;
 import org.springframework.stereotype.Service;
 
 import java.util.ArrayList;
@@ -51,6 +53,10 @@ public class AdwebSiteServiceImpl extends ServiceImpl<AdwebSiteMapper, AdwebSite
     @Autowired
     private ISiteUserPermissionService siteUserPermissionService;
 
+    @Lazy
+    @Resource
+    private IMasterSubAccountRelationService masterSubAccountRelationService;
+
     @Resource
     private ISysBaseAPI sysBaseAPI;
 
@@ -270,4 +276,15 @@ public class AdwebSiteServiceImpl extends ServiceImpl<AdwebSiteMapper, AdwebSite
         updateWrapper.set("site_current_step", currentDictModel.getText());
         return this.update(updateWrapper);
     }
+
+    /**
+     * 判断此账户有无子账户
+     *
+     * @return
+     */
+    @Override
+    public boolean hasSub(LoginUser loginUser) {
+        List<String> idList = masterSubAccountRelationService.getSubAccountIdByMaster(loginUser.getId());
+        return CollectionUtils.isNotEmpty(idList);
+    }
 }

+ 19 - 24
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/system/service/impl/MasterSubAccountRelationServiceImpl.java

@@ -3,17 +3,14 @@ package org.jeecg.modules.adweb.system.service.impl;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-
 import jakarta.annotation.Resource;
-
 import lombok.extern.slf4j.Slf4j;
-
 import org.apache.commons.collections4.CollectionUtils;
-import org.jeecg.common.system.api.ISysBaseAPI;
 import org.jeecg.modules.adweb.system.entity.MasterSubAccountRelation;
 import org.jeecg.modules.adweb.system.mapper.MasterSubAccountRelationMapper;
 import org.jeecg.modules.adweb.system.service.IMasterSubAccountRelationService;
 import org.jeecg.modules.adweb.system.service.SysAdwebApi;
+import org.springframework.context.annotation.Lazy;
 import org.springframework.stereotype.Service;
 
 import java.util.Arrays;
@@ -25,58 +22,56 @@ import java.util.stream.Collectors;
 @Slf4j
 public class MasterSubAccountRelationServiceImpl extends ServiceImpl<MasterSubAccountRelationMapper, MasterSubAccountRelation> implements IMasterSubAccountRelationService {
 
-    @Resource
-    private ISysBaseAPI sysBaseAPI;
-
+    @Lazy
     @Resource
     private SysAdwebApi sysAdwebApi;
 
     @Override
-    public String getMasterAccountIdBySub(String subId){
+    public String getMasterAccountIdBySub(String subId) {
         String masterId = "";
         LambdaQueryWrapper<MasterSubAccountRelation> query = new LambdaQueryWrapper<>();
-        query.eq(MasterSubAccountRelation::getSubId,subId);
-        query.eq(MasterSubAccountRelation::getStatus,1);
+        query.eq(MasterSubAccountRelation::getSubId, subId);
+        query.eq(MasterSubAccountRelation::getStatus, 1);
         MasterSubAccountRelation relation = null;
         try {
             relation = this.getBaseMapper().selectOne(query);
-            if(relation != null){
+            if (relation != null) {
                 masterId = relation.getMasterId();
             }
-        } catch (Exception e){
+        } catch (Exception e) {
             log.error("通过子账户ID获取主账户ID失败");
         }
         return masterId;
     }
 
     @Override
-    public String getMasterAccountNameBySub(String subId){
+    public String getMasterAccountNameBySub(String subId) {
         String masterName = "";
         LambdaQueryWrapper<MasterSubAccountRelation> query = new LambdaQueryWrapper<>();
-        query.eq(MasterSubAccountRelation::getSubId,subId);
-        query.eq(MasterSubAccountRelation::getStatus,1);
+        query.eq(MasterSubAccountRelation::getSubId, subId);
+        query.eq(MasterSubAccountRelation::getStatus, 1);
         MasterSubAccountRelation relation = null;
         try {
             relation = this.getBaseMapper().selectOne(query);
-            if(relation != null){
+            if (relation != null) {
                 masterName = relation.getMasterName();
             }
-        } catch (Exception e){
+        } catch (Exception e) {
             log.error("通过子账户ID获取主账户ID失败");
         }
         return masterName;
     }
 
     @Override
-    public List<String> getSubAccountIdByMaster(String masterId){
+    public List<String> getSubAccountIdByMaster(String masterId) {
         List<String> subIdList = null;
         LambdaQueryWrapper<MasterSubAccountRelation> query = new LambdaQueryWrapper<>();
-        query.eq(MasterSubAccountRelation::getMasterId,masterId);
-        query.eq(MasterSubAccountRelation::getStatus,1);
+        query.eq(MasterSubAccountRelation::getMasterId, masterId);
+        query.eq(MasterSubAccountRelation::getStatus, 1);
         List<MasterSubAccountRelation> relationList = null;
         try {
             relationList = this.getBaseMapper().selectList(query);
-        } catch (Exception e){
+        } catch (Exception e) {
             log.error("通过主账户ID获取子账户ID失败");
         }
         subIdList = relationList.stream().map(MasterSubAccountRelation::getSubId).collect(Collectors.toList());
@@ -84,13 +79,13 @@ public class MasterSubAccountRelationServiceImpl extends ServiceImpl<MasterSubAc
     }
 
     @Override
-    public void insertAccountRelation(MasterSubAccountRelation relation){
+    public void insertAccountRelation(MasterSubAccountRelation relation) {
         relation.setCreateTime(new Date());
         try {
-            if(relation != null){
+            if (relation != null) {
                 this.getBaseMapper().insert(relation);
             }
-        }catch (Exception e){
+        } catch (Exception e) {
             log.error("保存主账户和子账户ID失败");
         }
     }