Просмотр исходного кода

交友裂变返回分享背景组域名给前端-v0.01

(cherry picked from commit d602b13044113568c4ab1d0f9cc40e2caaa42dc5)
MOKASZ\lw12420 2 лет назад
Родитель
Сommit
a9c502e4cd

+ 77 - 2
launch-admin/src/main/java/com/webflux/launchadmin/mysql/controller/planNew/PlanNewCommonOutController.java

@@ -22,6 +22,7 @@ import com.webflux.launchadmin.mysql.service.planNew.structure.GoRequest;
 import com.webflux.launchadmin.mysql.service.planNew.structure.Item;
 import com.webflux.launchadmin.mysql.service.takeaway.TakeawayServicesInterface;
 import com.webflux.launchcommon.returnObj.RStatus;
+import com.webflux.launchcommon.utils.StringUtils;
 import jakarta.annotation.Resource;
 import jakarta.json.Json;
 import lombok.extern.slf4j.Slf4j;
@@ -268,11 +269,13 @@ public class PlanNewCommonOutController {
         } else if (2 == request.getTypePlan()) {
             // 听书裂变
             return this.getListeningPlan(request);
-        } else {
+        } else if(3==request.getTypePlan()){
             // 交友裂变
             return this.getFriendPlan(request);
+        }else if(4==request.getTypePlan()){
+            return this.getTakeaway(request);
         }
-       // throw new BaseException("typePlan 类型错误");
+        throw new BaseException("typePlan 类型错误");
     }
 
     /**
@@ -403,6 +406,78 @@ public class PlanNewCommonOutController {
                         return Mono.just(string + "." + domain);
                     });
         }
+        Mono<String> transferPageDomain;
+        if ( Objects.nonNull(request.getTransferPageDomain()) && StringUtils.isNotEmpty(request.getTransferPageDomain())) {
+            transferPageDomain = template.select(Query.query(Criteria
+                    .where("group_type_id").is(request.getTransferPageDomain())
+                    .and("status").is(1)
+                    .and("type").is(5)
+                    .and("deleted_at").isNull()), DomainSelect.class)
+                    .switchIfEmpty(Mono.error(new BaseException("transferPageDomain 域名查詢為空 group_type_id:::" + request.getTransferPageDomain())))
+                    .onErrorResume(throwable -> Mono.error(new Exception(throwable.getMessage()))).collectList().flatMap(fff -> {
+                        if (!fff.isEmpty()) {
+                            DomainSelect domainSelect = fff.get(RandomUtil.randomInt(0, fff.size()));
+                            String string = RandomUtil.randomString("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", 6);
+                            String domain1 = domainSelect.domain();
+                            return Mono.just(string + "." + domain1);
+                        } else {
+                            throw new BaseException("transferPageDomain 中轉域名查詢為空 group_type_id:::" +  request.getTransferPageDomain());
+                        }
+                    });
+        } else {
+            transferPageDomain = Mono.just(" ");
+        }
+        Mono<String> backgroupDomain;
+        if (Objects.nonNull(request.getBackgroupDomain()) && StringUtils.isNotEmpty(request.getBackgroupDomain())) {
+            backgroupDomain = template.select(Query.query(Criteria
+                    .where("group_type_id").is(request.getBackgroupDomain())
+                    .and("status").is(1)
+                    .and("type").is(4)
+                    .and("deleted_at").isNull()), DomainSelect.class)
+                    .switchIfEmpty(Mono.error(new BaseException("backgroupDomain 域名查询为空 group_type_id" + request.getBackgroupDomain())))
+                    .onErrorResume(throwable -> Mono.error(new Exception(throwable.getMessage()))).collectList().flatMap(fff -> {
+                        if (!fff.isEmpty()) {
+                            DomainSelect domainSelect = fff.get(RandomUtil.randomInt(0, fff.size()));
+                            String string = RandomUtil.randomString("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", 6);
+                            String domain1 = domainSelect.domain();
+                            return Mono.just(string + "." + domain1);
+                        } else {
+                            throw new BaseException("backgroupDomain 背景域名查詢為空 group_type_id" + request.getBackgroupDomain());
+                        }
+                    });
+        } else {
+            backgroupDomain = Mono.just(" ");
+        }
+        Mono<DomainSelectRes> res = Mono.zip(stringMono,transferPageDomain,backgroupDomain).flatMap(tuple3 -> {
+            DomainSelectRes domainSelectRes = new DomainSelectRes();
+            domainSelectRes.setDomain(tuple3.getT1());
+            domainSelectRes.setTransferPageDomain(tuple3.getT2());
+            domainSelectRes.setBackgroupDomain(tuple3.getT3());
+            domainSelectRes.setPath("");
+            domainSelectRes.setUnique(IdUtil.fastSimpleUUID());
+            return Mono.just(domainSelectRes);
+        });
+        return RStatus.success(res);
+    }
+    private Mono<RStatus<DomainSelectRes>> getTakeaway(OutDomainRequest request) {
+        Mono<String> stringMono;
+        if (StrUtil.isBlank(request.getLandingPageDomain()) || request.getLandingPageDomain().trim().isEmpty()) {
+            stringMono = Mono.just(" ");
+        } else {
+            stringMono = template.select(Query.query(Criteria
+                    .where("group_type_id").is(request.getLandingPageDomain())
+                    .and("status").is(1)
+                    .and("deleted_at").isNull()
+                    .and("type").is(request.getType())), DomainSelect.class)
+                    .switchIfEmpty(Mono.error(new BaseException("查询domain 返回结果为空")))
+                    .onErrorResume(throwable -> Mono.error(new Exception(throwable.getMessage())))
+                    .collectList().flatMap(fm -> {
+                        int i = RandomUtil.randomInt(0, fm.size());
+                        String domain = fm.get(i).domain();
+                        String string = RandomUtil.randomString("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", 6);
+                        return Mono.just(string + "." + domain);
+                    });
+        }
         Mono<DomainSelectRes> res = stringMono.flatMap(fff -> {
             DomainSelectRes domainSelectRes = new DomainSelectRes();
             domainSelectRes.setDomain(fff);

+ 9 - 0
launch-admin/src/main/java/com/webflux/launchadmin/mysql/controller/planNew/req/OutDomainRequest.java

@@ -17,4 +17,13 @@ public class OutDomainRequest {
     private Integer type;
     /** 落地页域名 */
     private String landingPageDomain;
+    /**
+     * 中转页域名
+     */
+    private String transferPageDomain;
+
+    /**
+     * 背景组域名
+     */
+    private String backgroupDomain;
 }