|
|
@@ -7,15 +7,18 @@ import cn.hutool.core.util.StrUtil;
|
|
|
import cn.hutool.json.JSONArray;
|
|
|
import cn.hutool.json.JSONObject;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
-import com.alibaba.fastjson.JSON;
|
|
|
+import com.plumelog.core.util.LogExceptionStackTrace;
|
|
|
import com.webflux.launchadmin.global.BaseException;
|
|
|
-import com.webflux.launchadmin.mysql.controller.planNew.req.*;
|
|
|
+import com.webflux.launchadmin.mysql.controller.planNew.req.KefuRequest;
|
|
|
+import com.webflux.launchadmin.mysql.controller.planNew.req.OutDomainRequest;
|
|
|
+import com.webflux.launchadmin.mysql.controller.planNew.req.PlanNewCommonMaterialReq;
|
|
|
+import com.webflux.launchadmin.mysql.controller.planNew.req.PlanNewCommonShareReq;
|
|
|
import com.webflux.launchadmin.mysql.controller.planNew.res.*;
|
|
|
import com.webflux.launchadmin.mysql.controller.takeawayController.res.TakeawayH5Data;
|
|
|
import com.webflux.launchadmin.mysql.entity.groupUsers.GroupUsers;
|
|
|
import com.webflux.launchadmin.mysql.entity.listening.ListeningPlanNew;
|
|
|
import com.webflux.launchadmin.mysql.entity.planNew.*;
|
|
|
-import com.webflux.launchadmin.mysql.entity.redis.RedisKey;
|
|
|
+import com.webflux.launchadmin.mysql.service.planNew.PlanServiceInterface;
|
|
|
import com.webflux.launchadmin.mysql.service.planNew.goGenerate.GoGenerateService;
|
|
|
import com.webflux.launchadmin.mysql.service.planNew.ipAnalyze.IpAnalyzeServiceInterface;
|
|
|
import com.webflux.launchadmin.mysql.service.planNew.structure.GoRequest;
|
|
|
@@ -24,16 +27,12 @@ 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;
|
|
|
import org.springframework.data.domain.Sort;
|
|
|
import org.springframework.data.r2dbc.core.R2dbcEntityTemplate;
|
|
|
-import org.springframework.data.redis.core.ReactiveRedisTemplate;
|
|
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
|
|
import org.springframework.data.relational.core.query.Criteria;
|
|
|
import org.springframework.data.relational.core.query.Query;
|
|
|
-import org.springframework.http.server.reactive.ServerHttpRequest;
|
|
|
-import org.springframework.scheduling.annotation.Scheduled;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.web.server.ServerWebExchange;
|
|
|
import reactor.core.publisher.Mono;
|
|
|
@@ -62,19 +61,22 @@ public class PlanNewCommonOutController {
|
|
|
@Resource
|
|
|
private GoGenerateService goGenerateService;
|
|
|
@Resource
|
|
|
- private ReactiveRedisTemplate<String, Object> reactiveRedisTemplate;
|
|
|
+ private StringRedisTemplate stringRedisTemplate;
|
|
|
@Resource
|
|
|
private TakeawayServicesInterface takeawayServicesInterface;
|
|
|
@Resource
|
|
|
private IpAnalyzeServiceInterface ipAnalyzeServiceInterface;
|
|
|
+ @Resource
|
|
|
+ private PlanServiceInterface planServiceInterface;
|
|
|
private static final ConcurrentHashMap<String, Integer> MAP = new ConcurrentHashMap<>();
|
|
|
|
|
|
- @Scheduled(cron = "1 1 4 * * ?")
|
|
|
- public void clearUserContextHashMap() {
|
|
|
- log.info("清空计划-H5用户Map数据》》》》》》》》》》》》》》》》》》》》》》开始");
|
|
|
- MAP.clear();
|
|
|
- log.info("清空计划-H5用户Map数据》》》》》》》》》》》》》》》》》》》》》》 结束");
|
|
|
- }
|
|
|
+ // @Scheduled(cron = "1 1 4 * * ?")
|
|
|
+ // @SchedulerLock(name = "launch:PlanNewCommonOutController:clearUserContextHashMap", lockAtLeastFor = "PT5S", lockAtMostFor = "PT15M")
|
|
|
+ // public void clearUserContextHashMap() {
|
|
|
+ // log.info("清空计划-H5用户Map数据》》》》》》》》》》》》》》》》》》》》》》开始");
|
|
|
+ // MAP.clear();
|
|
|
+ // log.info("清空计划-H5用户Map数据》》》》》》》》》》》》》》》》》》》》》》 结束");
|
|
|
+ // }
|
|
|
|
|
|
/**
|
|
|
* 通过 code 获取计划配置H5信息
|
|
|
@@ -87,8 +89,8 @@ public class PlanNewCommonOutController {
|
|
|
|
|
|
|
|
|
Mono<PlanNewCommon> planNewCommonMono = template.selectOne(Query.query(Criteria.where("code").is(code)), PlanNewCommon.class)
|
|
|
- .switchIfEmpty(Mono.error(new BaseException("计划code异常")))
|
|
|
- .onErrorResume(throwable -> Mono.error(new Exception(throwable.getMessage() + "1")));
|
|
|
+ .switchIfEmpty(Mono.error(new BaseException("计划code异")))
|
|
|
+ .onErrorResume(throwable -> Mono.error(new BaseException("计划code异")));
|
|
|
Mono<PlanNewCommonRes> resMono = planNewCommonMono.flatMap(f -> {
|
|
|
// 群成员
|
|
|
Mono<List<GroupUserRes>> groupUserResMono = Mono.just(new ArrayList<>());
|
|
|
@@ -96,16 +98,16 @@ public class PlanNewCommonOutController {
|
|
|
Mono<List<Image>> imageMono = template.select(Query.query(Criteria.where("type").is(1)
|
|
|
.and("group_type_id").is(f.groupId())
|
|
|
.and("deleted_at").isNull()), Image.class)
|
|
|
- .onErrorResume(throwable -> Mono.error(new Exception(throwable.getMessage() + "2"))).collectList();
|
|
|
+ .onErrorResume(throwable -> Mono.error(new BaseException("获取群封面异常"))).collectList();
|
|
|
// 群名称
|
|
|
Mono<List<Material>> textMono = template.select(Query.query(Criteria.where("type").is(4)
|
|
|
.and("deleted_at").isNull()
|
|
|
.and("group_type_id").is(f.groupId())), Material.class)
|
|
|
- .onErrorResume(throwable -> Mono.error(new Exception(throwable.getMessage() + "3"))).collectList();
|
|
|
+ .onErrorResume(throwable -> Mono.error(new BaseException("获取群名称异常"))).collectList();
|
|
|
if (3 == f.type()) {
|
|
|
// 交友裂变, 需要群成员
|
|
|
Mono<List<GroupUsers>> groupUsersMono = template.select(Query.query(Criteria.where("group_users_type").is(f.groupId())).limit(14), GroupUsers.class)
|
|
|
- .onErrorResume(throwable -> Mono.error(new Exception(throwable.getMessage() + "4"))).collectList();
|
|
|
+ .onErrorResume(throwable -> Mono.error(new BaseException("获取群成员异常"))).collectList();
|
|
|
groupUserResMono = groupUsersMono.flatMap(groupUsers -> {
|
|
|
List<GroupUserRes> groupUserResList = groupUsers.stream().map(groupUsers1 -> {
|
|
|
GroupUserRes groupUserRes = new GroupUserRes();
|
|
|
@@ -195,7 +197,7 @@ public class PlanNewCommonOutController {
|
|
|
public Mono<RStatus<byte[]>> kefuList(@RequestBody KefuRequest request) {
|
|
|
Mono<PlanNewCommon> code = template.selectOne(Query.query(Criteria.where("code").is(request.getCode())), PlanNewCommon.class)
|
|
|
.switchIfEmpty(Mono.error(new BaseException("code查询返回结构为空")))
|
|
|
- .onErrorResume(throwable -> Mono.error(new Exception("通过code查询计划异常::" + throwable.getMessage())));
|
|
|
+ .onErrorResume(throwable -> Mono.error(new BaseException("code查询返回结构为空")));
|
|
|
Mono<DataListsKefu> dataListsKefuMono = code.flatMap(planNew -> {
|
|
|
Mono<List<Image>> image = template.select(Query.query(Criteria.where("type").is(5)
|
|
|
.and("deleted_at").isNull()
|
|
|
@@ -203,13 +205,13 @@ public class PlanNewCommonOutController {
|
|
|
.collectList()
|
|
|
.switchIfEmpty(Mono.error(new BaseException(StrUtil.format("通过计划groupId:{}查询Image返回结构为空", planNew.groupId()))))
|
|
|
.onErrorResume(throwable ->
|
|
|
- Mono.error(new Exception(StrUtil.format("通过计划groupId:{}查询Image返回结果error:{}", planNew.groupId(), throwable.getMessage()))));
|
|
|
+ Mono.error(new BaseException(StrUtil.format("通过计划groupId:{}查询Image返回结果error:{}", planNew.groupId(), LogExceptionStackTrace.erroStackTrace(throwable).toString()))));
|
|
|
Mono<List<Material>> text = template.select(Query.query(Criteria.where("type").is(11)
|
|
|
.and("group_type_id").is(planNew.groupId())
|
|
|
.and("deleted_at").isNull()), Material.class)
|
|
|
.switchIfEmpty(Mono.error(new BaseException(StrUtil.format("通过计划groupId:{}查询Material返回结构为空", planNew.groupId()))))
|
|
|
.onErrorResume(throwable ->
|
|
|
- Mono.error(new Exception(StrUtil.format("通过计划groupId:{}查询Material返回结果error:{}", planNew.groupId(), throwable.getMessage()))))
|
|
|
+ Mono.error(new BaseException(StrUtil.format("通过计划groupId:{}查询Material返回结果error:{}", planNew.groupId(), LogExceptionStackTrace.erroStackTrace(throwable).toString()))))
|
|
|
.collectList();
|
|
|
Mono<List<H5ImageAndText>> arrayListMono = Mono.zip(Mono.just(planNew), image, text).flatMap(f -> {
|
|
|
// H5ImageAndText
|
|
|
@@ -218,7 +220,7 @@ public class PlanNewCommonOutController {
|
|
|
List<Image> t3 = f.getT2();
|
|
|
List<Material> t4 = f.getT3();
|
|
|
if (t3.size() < integer || t4.size() < integer) {
|
|
|
- throw new BaseException("图片或文字素材小于计划设置数");
|
|
|
+ return Mono.error(new BaseException("图片或文字素材小于计划设置数"));
|
|
|
}
|
|
|
ArrayList<Long> listImg = new ArrayList<>();
|
|
|
ArrayList<Long> listTxt = new ArrayList<>();
|
|
|
@@ -288,10 +290,10 @@ public class PlanNewCommonOutController {
|
|
|
} else if (2 == request.getTypePlan()) {
|
|
|
// 听书裂变
|
|
|
return this.getListeningPlan(request);
|
|
|
- } else if(3==request.getTypePlan()){
|
|
|
+ } else if (3 == request.getTypePlan()) {
|
|
|
// 交友裂变
|
|
|
return this.getFriendPlan(request);
|
|
|
- }else if(4==request.getTypePlan()){
|
|
|
+ } else if (4 == request.getTypePlan()) {
|
|
|
return this.getTakeaway(request);
|
|
|
}
|
|
|
throw new BaseException("typePlan 类型错误");
|
|
|
@@ -304,7 +306,7 @@ public class PlanNewCommonOutController {
|
|
|
Mono<PlanNew> code1 = template
|
|
|
.selectOne(Query.query(Criteria.where("code").is(request.getCode())), PlanNew.class)
|
|
|
.switchIfEmpty(Mono.error(new BaseException("计划code异常 返回结果为空")))
|
|
|
- .onErrorResume(throwable -> Mono.error(new Exception(throwable.getMessage())));
|
|
|
+ .onErrorResume(throwable -> Mono.error(new BaseException("计划code异常" + throwable.getMessage())));
|
|
|
Mono<DomainSelectRes> domainSelectResMono1 = code1.flatMap(f -> {
|
|
|
Mono<String> stringMono;
|
|
|
if (f.transferPageBl() == 1 && Objects.nonNull(f.transferPageDomain())) {
|
|
|
@@ -314,7 +316,7 @@ public class PlanNewCommonOutController {
|
|
|
.and("type").is(5)
|
|
|
.and("deleted_at").isNull()), DomainSelect.class)
|
|
|
.switchIfEmpty(Mono.error(new BaseException("transferPageDomain 域名查詢為空 group_type_id:::" + f.transferPageDomain())))
|
|
|
- .onErrorResume(throwable -> Mono.error(new Exception(throwable.getMessage()))).collectList().flatMap(fff -> {
|
|
|
+ .onErrorResume(throwable -> Mono.error(new BaseException("transferPageDomain 域名查詢為空 group_type_id:::" + f.transferPageDomain()))).collectList().flatMap(fff -> {
|
|
|
if (!fff.isEmpty()) {
|
|
|
DomainSelect domainSelect = fff.get(RandomUtil.randomInt(0, fff.size()));
|
|
|
String string = RandomUtil.randomString("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", 6);
|
|
|
@@ -322,7 +324,7 @@ public class PlanNewCommonOutController {
|
|
|
return Mono.just(string + "." + domain1);
|
|
|
|
|
|
} else {
|
|
|
- throw new BaseException("transferPageDomain 中轉域名查詢為空 group_type_id:::" + f.transferPageDomain());
|
|
|
+ return Mono.error(new BaseException("transferPageDomain 中轉域名查詢為空 group_type_id:::" + f.transferPageDomain()));
|
|
|
}
|
|
|
});
|
|
|
} else {
|
|
|
@@ -336,14 +338,14 @@ public class PlanNewCommonOutController {
|
|
|
.and("type").is(4)
|
|
|
.and("deleted_at").isNull()), DomainSelect.class)
|
|
|
.switchIfEmpty(Mono.error(new BaseException("backgroupDomain 域名查询为空 group_type_id" + f.backgroupDomain())))
|
|
|
- .onErrorResume(throwable -> Mono.error(new Exception(throwable.getMessage()))).collectList().flatMap(fff -> {
|
|
|
+ .onErrorResume(throwable -> Mono.error(new BaseException("backgroupDomain 域名查询为空 group_type_id" + f.backgroupDomain()))).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" + f.backgroupDomain());
|
|
|
+ return Mono.error(new BaseException("backgroupDomain 背景域名查詢為空 group_type_id" + f.backgroupDomain()));
|
|
|
}
|
|
|
});
|
|
|
} else {
|
|
|
@@ -355,7 +357,7 @@ public class PlanNewCommonOutController {
|
|
|
.and("type").is(request.getType())
|
|
|
.and("deleted_at").isNull()), DomainSelect.class)
|
|
|
.switchIfEmpty(Mono.error(new BaseException("查询domain 返回结果为空")))
|
|
|
- .onErrorResume(throwable -> Mono.error(new Exception(throwable.getMessage()))).collectList().flatMap(fm -> {
|
|
|
+ .onErrorResume(throwable -> Mono.error(new BaseException("查询domain 返回结果为空"))).collectList().flatMap(fm -> {
|
|
|
// DomainSelectRes domainSelectRes = new DomainSelectRes();
|
|
|
int i = RandomUtil.randomInt(0, fm.size());
|
|
|
String domain = fm.get(i).domain();
|
|
|
@@ -382,14 +384,14 @@ public class PlanNewCommonOutController {
|
|
|
private Mono<RStatus<DomainSelectRes>> getListeningPlan(OutDomainRequest request) {
|
|
|
Mono<ListeningPlanNew> code1 = template.selectOne(Query.query(Criteria.where("code").is(request.getCode())), ListeningPlanNew.class)
|
|
|
.switchIfEmpty(Mono.error(new BaseException("计划code异常 返回结果为空")))
|
|
|
- .onErrorResume(throwable -> Mono.error(new Exception(throwable.getMessage())));
|
|
|
+ .onErrorResume(throwable -> Mono.error(new BaseException("计划code异常")));
|
|
|
Mono<DomainSelectRes> domainSelectResMono1 = code1.flatMap(f -> template.select(Query.query(Criteria
|
|
|
.where("group_type_id").is(f.groupId())
|
|
|
.and("status").is(1)
|
|
|
.and("type").is(request.getType())
|
|
|
.and("deleted_at").isNull()), DomainSelect.class)
|
|
|
.switchIfEmpty(Mono.error(new BaseException("查询domain 返回结果为空")))
|
|
|
- .onErrorResume(throwable -> Mono.error(new Exception(throwable.getMessage()))).collectList()
|
|
|
+ .onErrorResume(throwable -> Mono.error(new BaseException("查询domain 返回结果为空"))).collectList()
|
|
|
.flatMap(fm -> {
|
|
|
DomainSelectRes domainSelectRes = new DomainSelectRes();
|
|
|
int i = RandomUtil.randomInt(0, fm.size());
|
|
|
@@ -417,7 +419,7 @@ public class PlanNewCommonOutController {
|
|
|
.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())))
|
|
|
+ .onErrorResume(throwable -> Mono.error(new BaseException("查询domain 返回结果为空")))
|
|
|
.collectList().flatMap(fm -> {
|
|
|
int i = RandomUtil.randomInt(0, fm.size());
|
|
|
String domain = fm.get(i).domain();
|
|
|
@@ -426,21 +428,21 @@ public class PlanNewCommonOutController {
|
|
|
});
|
|
|
}
|
|
|
Mono<String> transferPageDomain;
|
|
|
- if ( Objects.nonNull(request.getTransferPageDomain()) && StringUtils.isNotEmpty(request.getTransferPageDomain())) {
|
|
|
+ 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)
|
|
|
+ .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 -> {
|
|
|
+ .onErrorResume(throwable -> Mono.error(new BaseException(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());
|
|
|
+ return Mono.error(new BaseException("transferPageDomain 中轉域名查詢為空 group_type_id:::" + request.getTransferPageDomain()));
|
|
|
}
|
|
|
});
|
|
|
} else {
|
|
|
@@ -449,25 +451,25 @@ public class PlanNewCommonOutController {
|
|
|
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)
|
|
|
+ .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 -> {
|
|
|
+ .onErrorResume(throwable -> Mono.error(new BaseException(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());
|
|
|
+ return Mono.error(new BaseException("backgroupDomain 背景域名查詢為空 group_type_id" + request.getBackgroupDomain()));
|
|
|
}
|
|
|
});
|
|
|
} else {
|
|
|
backgroupDomain = Mono.just(" ");
|
|
|
}
|
|
|
- Mono<DomainSelectRes> res = Mono.zip(stringMono,transferPageDomain,backgroupDomain).flatMap(tuple3 -> {
|
|
|
+ Mono<DomainSelectRes> res = Mono.zip(stringMono, transferPageDomain, backgroupDomain).flatMap(tuple3 -> {
|
|
|
DomainSelectRes domainSelectRes = new DomainSelectRes();
|
|
|
domainSelectRes.setDomain(tuple3.getT1());
|
|
|
domainSelectRes.setTransferPageDomain(tuple3.getT2());
|
|
|
@@ -478,18 +480,19 @@ public class PlanNewCommonOutController {
|
|
|
});
|
|
|
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)
|
|
|
+ .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())))
|
|
|
+ .onErrorResume(throwable -> Mono.error(new BaseException(throwable.getMessage())))
|
|
|
.collectList().flatMap(fm -> {
|
|
|
int i = RandomUtil.randomInt(0, fm.size());
|
|
|
String domain = fm.get(i).domain();
|
|
|
@@ -517,7 +520,7 @@ public class PlanNewCommonOutController {
|
|
|
public Mono<RStatus<PlanNewCommonMaterialRes>> getCommonMaterial(@RequestBody PlanNewCommonMaterialReq request) {
|
|
|
Mono<PlanNewCommon> planNewCommonMono = template.selectOne(Query.query(Criteria.where("code").is(request.getCode())), PlanNewCommon.class)
|
|
|
.switchIfEmpty(Mono.error(new BaseException("计划code异常 返回结果为空")))
|
|
|
- .onErrorResume(throwable -> Mono.error(new Exception(throwable.getMessage())));
|
|
|
+ .onErrorResume(throwable -> Mono.error(new BaseException("计划code异常")));
|
|
|
Mono<PlanNewCommonMaterialRes> materialResMono = planNewCommonMono.flatMap(plan -> {
|
|
|
// 群音频
|
|
|
Mono<Audio> groupAudio = this.getAudio(request.getAudioId());
|
|
|
@@ -531,7 +534,7 @@ public class PlanNewCommonOutController {
|
|
|
returnLoop = template.selectOne(Query.query(Criteria.where("id").is(request.getReturnLoopId())
|
|
|
.and("deleted_at").isNull()), ReturnLoop.class)
|
|
|
.switchIfEmpty(Mono.just(getReturnLoop()))
|
|
|
- .onErrorResume(throwable -> Mono.error(new Exception(throwable.getMessage() + "3")));
|
|
|
+ .onErrorResume(throwable -> Mono.error(new BaseException("查询返回广告异常")));
|
|
|
}
|
|
|
// 分享背景组
|
|
|
Mono<List<BackgroupImageItem>> backgroupImageItemMono;
|
|
|
@@ -541,17 +544,17 @@ public class PlanNewCommonOutController {
|
|
|
backgroupImageItemMono = template.select(Query.query(Criteria
|
|
|
.where("group_id").is(request.getBackgroundGroupId())), BackgroupImageItem.class).collectList()
|
|
|
.switchIfEmpty(Mono.just(List.of()))
|
|
|
- .onErrorResume(throwable -> Mono.error(new Exception(throwable.getMessage() + "4")));
|
|
|
+ .onErrorResume(throwable -> Mono.error(new BaseException("查询分享背景组异常")));
|
|
|
}
|
|
|
- Mono<TakeawayH5Data> takeaway ;
|
|
|
+ Mono<TakeawayH5Data> takeaway;
|
|
|
if (Objects.nonNull(request.getTakeawayId()) && request.getTakeawayId() > 0) {
|
|
|
takeaway = takeawayServicesInterface.getTakeaway(request.getTakeawayId())
|
|
|
- .switchIfEmpty(Mono.error(new BaseException("查询外卖模版数据异常 查询结果为空")))
|
|
|
- .onErrorResume(e->Mono.error(new BaseException("查询外卖模版数据异常:::"+e.getMessage())));
|
|
|
- }else {
|
|
|
- takeaway=Mono.just(new TakeawayH5Data());
|
|
|
+ .switchIfEmpty(Mono.just(new TakeawayH5Data()))
|
|
|
+ .onErrorResume(e -> Mono.error(new BaseException("查询外卖模版数据异常:::" + e.getMessage())));
|
|
|
+ } else {
|
|
|
+ takeaway = Mono.just(new TakeawayH5Data());
|
|
|
}
|
|
|
- return Mono.zip(groupAudio, retAudio, returnLoop, backgroupImageItemMono,takeaway).flatMap(f -> {
|
|
|
+ return Mono.zip(groupAudio, retAudio, returnLoop, backgroupImageItemMono, takeaway).flatMap(f -> {
|
|
|
PlanNewCommonMaterialRes materialRes = new PlanNewCommonMaterialRes();
|
|
|
materialRes.setGroupAudio(f.getT1());
|
|
|
materialRes.setRetAudio(f.getT2());
|
|
|
@@ -606,17 +609,15 @@ public class PlanNewCommonOutController {
|
|
|
*/
|
|
|
@PostMapping("planCommonShare")
|
|
|
public Mono<RStatus<PlanNewCommonShareRes>> planCommonShare(@RequestBody PlanNewCommonShareReq request) {
|
|
|
- if (MAP.containsKey(request.getUnique())) {
|
|
|
- Integer integer = MAP.get(request.getUnique());
|
|
|
- MAP.put(request.getUnique(), integer + 1);
|
|
|
- request.setUserVisits(integer + 1);
|
|
|
- } else {
|
|
|
- MAP.put(request.getUnique(), 0);
|
|
|
- request.setUserVisits(0);
|
|
|
+ if (request.getCode() == null || request.getCode().isEmpty()) {
|
|
|
+ throw new BaseException("code不能为空");
|
|
|
}
|
|
|
Mono<PlanNewCommon> planNewCommonMono = template.selectOne(Query.query(Criteria.where("code").is(request.getCode())), PlanNewCommon.class)
|
|
|
.switchIfEmpty(Mono.error(new BaseException(" code错误")))
|
|
|
- .onErrorResume(throwable -> Mono.error(new Exception(throwable.getMessage())));
|
|
|
+ .onErrorResume(throwable -> Mono.error(new BaseException(" code错误")));
|
|
|
+ // 记录访问
|
|
|
+ Integer visits = planServiceInterface.setUserVisitsToRedis(request.getUnique(), request.getCode());
|
|
|
+ request.setUserVisits(visits);
|
|
|
Mono<PlanNewCommonShareRes> resMono = planNewCommonMono.flatMap(plan -> {
|
|
|
Mono<StringBuilder> stringBuilderMono;
|
|
|
boolean isQs = Objects.nonNull(request.getWx_user_id()) && !request.getWx_user_id().isEmpty();
|
|
|
@@ -627,7 +628,7 @@ public class PlanNewCommonOutController {
|
|
|
if (Objects.nonNull(request.getRedirectType()) && request.getRedirectType() == 2) {
|
|
|
stringBuilderMono = goGenerateService.byPlanNewIdGetUrlCommon(request.getRedirectPlanId(), isQs, request.getGroupIdQs());
|
|
|
} else {
|
|
|
- stringBuilderMono = Mono.just(new StringBuilder(request.getLink()));
|
|
|
+ stringBuilderMono = Mono.just(new StringBuilder(request.getLink() == null ? "" : request.getLink()));
|
|
|
}
|
|
|
Mono<PlanNewCommon> code = Mono.just(plan);
|
|
|
return Mono.zip(code, getPosterTemplate(code), getPoster(code), getPlanNewBackgroupPoster(code), getEwm(code), stringBuilderMono).flatMap(f -> {
|
|
|
@@ -656,7 +657,7 @@ public class PlanNewCommonOutController {
|
|
|
int v = userVisits % qs.size();
|
|
|
res.setQsSetting(qs.get(v));
|
|
|
if (f.getT6().toString().isEmpty()) {
|
|
|
- throw new BaseException("计划链接 查询匹配域名为空");
|
|
|
+ return Mono.error(new BaseException("计划链接 查询匹配域名为空"));
|
|
|
}
|
|
|
res.setLink(f.getT6().toString());
|
|
|
} else {
|
|
|
@@ -678,7 +679,7 @@ public class PlanNewCommonOutController {
|
|
|
int v = userVisits % fx.size();
|
|
|
res.setFxSetting(fx.get(v));
|
|
|
if (f.getT6().toString().isEmpty()) {
|
|
|
- throw new BaseException("计划链接 查询匹配域名为空");
|
|
|
+ return Mono.error(new BaseException("计划链接 查询匹配域名为空"));
|
|
|
}
|
|
|
res.setLink(f.getT6().toString());
|
|
|
} else {
|
|
|
@@ -736,21 +737,21 @@ public class PlanNewCommonOutController {
|
|
|
qrcodeInfoMono = template.insert(stringBuilder)
|
|
|
.onErrorResume(throwable -> Mono.error(new BaseException("插入QrcodeInfo异常::::" + throwable.getMessage())));
|
|
|
}
|
|
|
- return Mono.zip(Mono.just(fm),qrcodeInfoMono).flatMap(fm1->{
|
|
|
- if (Objects.nonNull(fm1.getT2().id())) {
|
|
|
- goRequest.getItem()
|
|
|
- .stream()
|
|
|
- .filter(filter -> "cusqrcode".equals(filter.getT())
|
|
|
- && filter.getIsRandom()
|
|
|
- && 1 == filter.getType()).collect(Collectors.toList()).forEach(fe -> {
|
|
|
- if (Objects.nonNull(fe.getV())) {
|
|
|
- if (fe.getV().contains("?")){
|
|
|
- String cusqrcode = fe.getV() + "&id=" + fm1.getT2().id();
|
|
|
- fe.setV(cusqrcode);
|
|
|
- }else{
|
|
|
- String cusqrcode = fe.getV() + "?id=" + fm1.getT2().id();
|
|
|
- fe.setV(cusqrcode);
|
|
|
- }
|
|
|
+ if (Objects.nonNull(ret)) {
|
|
|
+ JSONObject jsonObject1;
|
|
|
+ try {
|
|
|
+ jsonObject1 = JSONUtil.parseObj(ret);
|
|
|
+ } catch (Exception e) {
|
|
|
+ return Mono.error(new BaseException(e.getMessage() + "---" + JSONUtil.parseObj(goRequest) + " error:" + LogExceptionStackTrace.erroStackTrace(e).toString()));
|
|
|
+ }
|
|
|
+ if (jsonObject1.containsKey("code") && jsonObject1.get("code", Integer.class) == 0 && jsonObject1.containsKey("data")) {
|
|
|
+ JSONObject data = jsonObject1.get("data", JSONObject.class);
|
|
|
+ if (data.containsKey("Url")) {
|
|
|
+ String url = data.get("Url", String.class);
|
|
|
+ if (Objects.nonNull(request.getWx_user_id()) && !request.getWx_user_id().isEmpty() && 3 != fm.getPlanNew().type()) {
|
|
|
+ fm.setQsGenerateImagesUrl(url);
|
|
|
+ } else {
|
|
|
+ fm.setFxGenerateImagesUrl(url);
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
@@ -835,7 +836,7 @@ public class PlanNewCommonOutController {
|
|
|
try {
|
|
|
jsonObject = JSONUtil.parseObj(posterTemplate);
|
|
|
} catch (Exception e) {
|
|
|
- throw new BaseException(e.getMessage() + "---" + posterTemplate);
|
|
|
+ return Mono.error(new BaseException(e.getMessage() + "---" + posterTemplate + " error:" + LogExceptionStackTrace.erroStackTrace(e).toString()));
|
|
|
}
|
|
|
GoRequest goRequest = new GoRequest();
|
|
|
BeanUtil.copyProperties(jsonObject, goRequest);
|