|
@@ -8,10 +8,7 @@ import cn.hutool.json.JSONArray;
|
|
|
import cn.hutool.json.JSONObject;
|
|
import cn.hutool.json.JSONObject;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
import cn.hutool.json.JSONUtil;
|
|
|
import com.webflux.launchadmin.global.BaseException;
|
|
import com.webflux.launchadmin.global.BaseException;
|
|
|
-import com.webflux.launchadmin.mysql.controller.planNew.req.HftRequest;
|
|
|
|
|
-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.req.*;
|
|
|
import com.webflux.launchadmin.mysql.controller.planNew.res.*;
|
|
import com.webflux.launchadmin.mysql.controller.planNew.res.*;
|
|
|
import com.webflux.launchadmin.mysql.entity.groupUsers.GroupUsers;
|
|
import com.webflux.launchadmin.mysql.entity.groupUsers.GroupUsers;
|
|
|
import com.webflux.launchadmin.mysql.entity.listening.ListeningPlanNew;
|
|
import com.webflux.launchadmin.mysql.entity.listening.ListeningPlanNew;
|
|
@@ -34,6 +31,7 @@ import reactor.core.publisher.Mono;
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
import java.util.concurrent.ConcurrentHashMap;
|
|
import java.util.concurrent.ConcurrentHashMap;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
+import java.util.stream.IntStream;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 通用计划-H5
|
|
* 通用计划-H5
|
|
@@ -127,6 +125,93 @@ public class PlanNewCommonOutController {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
|
|
+ * 客服列表
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param request
|
|
|
|
|
+ * @return {@link Mono}<{@link RStatus}<{@link DataListsKefu}>>
|
|
|
|
|
+ */
|
|
|
|
|
+ @PostMapping("kefuList")
|
|
|
|
|
+ public Mono<RStatus<DataListsKefu>> 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())));
|
|
|
|
|
+ Mono<DataListsKefu> dataListsKefuMono = code.flatMap(planNew -> {
|
|
|
|
|
+ Mono<List<Image>> image = template.select(Query.query(Criteria.where("type").is(5)
|
|
|
|
|
+ .and("deleted_at").isNull()
|
|
|
|
|
+ .and("group_type_id").is(planNew.groupId())), Image.class)
|
|
|
|
|
+ .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<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()))))
|
|
|
|
|
+ .collectList();
|
|
|
|
|
+ Mono<List<H5ImageAndText>> arrayListMono = Mono.zip(Mono.just(planNew), image, text).flatMap(f -> {
|
|
|
|
|
+ // H5ImageAndText
|
|
|
|
|
+ // 群数量, 默认6
|
|
|
|
|
+ int integer = request.getPageShow() == null || request.getPageShow() <= 0 ? 6 : request.getPageShow();
|
|
|
|
|
+ List<Image> t3 = f.getT2();
|
|
|
|
|
+ List<Material> t4 = f.getT3();
|
|
|
|
|
+ if (t3.size() < integer || t4.size() < integer) {
|
|
|
|
|
+ throw new BaseException("图片或文字素材小于计划设置数");
|
|
|
|
|
+ }
|
|
|
|
|
+ ArrayList<Long> listImg = new ArrayList<>();
|
|
|
|
|
+ ArrayList<Long> listTxt = new ArrayList<>();
|
|
|
|
|
+ List<H5ImageAndText> h5ImageAndTexts = new ArrayList<>();
|
|
|
|
|
+ IntStream.range(0, integer).forEach(i -> {
|
|
|
|
|
+ List<Image> collect = t3.stream().filter(fff -> !listImg.contains(fff.id())).toList();
|
|
|
|
|
+ Image image1 = collect.get(RandomUtil.randomInt(0, collect.size()));
|
|
|
|
|
+ listImg.add(image1.id());
|
|
|
|
|
+ List<Material> collect1 = t4.stream().filter(fff -> !listTxt.contains(fff.id())).toList();
|
|
|
|
|
+ Material material = collect1.get(RandomUtil.randomInt(0, collect1.size()));
|
|
|
|
|
+ listTxt.add(material.id());
|
|
|
|
|
+ H5ImageAndText h5ImageAndText = new H5ImageAndText();
|
|
|
|
|
+ h5ImageAndText.setImage(image1.image());
|
|
|
|
|
+ h5ImageAndText.setName(material.content());
|
|
|
|
|
+ h5ImageAndText.setRemark(material.remark());
|
|
|
|
|
+ h5ImageAndTexts.add(h5ImageAndText);
|
|
|
|
|
+ });
|
|
|
|
|
+ return Mono.just(h5ImageAndTexts);
|
|
|
|
|
+ });
|
|
|
|
|
+ Mono<List<BackgroupImageItem>> backgroupImageItem = Mono.just(List.of());
|
|
|
|
|
+ if (Objects.nonNull(request.getBackgroundGroupId()) && request.getBackgroundGroupId() > 0) {
|
|
|
|
|
+ backgroupImageItem = Mono.just(planNew)
|
|
|
|
|
+ .filter(ft -> Objects.nonNull(request.getBackgroundGroupId()))
|
|
|
|
|
+ .flatMap(plan -> template.select(Query.query(Criteria.where("group_id")
|
|
|
|
|
+ .is(request.getBackgroundGroupId())), BackgroupImageItem.class).collectList())
|
|
|
|
|
+ .switchIfEmpty(Mono.just(List.of()));
|
|
|
|
|
+ }
|
|
|
|
|
+ Mono<Audio> retAudioId = Mono.just(new Audio(null, null, null, null, null, null, null, null));
|
|
|
|
|
+ if (Objects.nonNull(request.getRetAudioId()) && request.getRetAudioId() > 0) {
|
|
|
|
|
+ retAudioId = template.selectOne(Query.query(Criteria.where("id").is(request.getRetAudioId())), Audio.class)
|
|
|
|
|
+ .switchIfEmpty(Mono.error(new BaseException(StrUtil.format("通过计划retAudioId:{}查询音频为空", request.getRetAudioId()))))
|
|
|
|
|
+ .onErrorResume(throwable -> Mono.error(new BaseException(StrUtil.format("通过计划retAudioId:{}查询音频Error::", request.getRetAudioId(), throwable.getMessage()))));
|
|
|
|
|
+ }
|
|
|
|
|
+ Mono<DataListsKefu> dataListsMono = Mono.zip(Mono.just(planNew), backgroupImageItem, retAudioId, arrayListMono).flatMap(f -> {
|
|
|
|
|
+ DataListsKefu dataLists = new DataListsKefu();
|
|
|
|
|
+ dataLists.setPlanNewCommon(f.getT1());
|
|
|
|
|
+ dataLists.setBaiduDot(request.getBaiduDot());
|
|
|
|
|
+ List<BackgroupImageItem> t2 = f.getT2();
|
|
|
|
|
+ if (!t2.isEmpty()) {
|
|
|
|
|
+ List<String> collect = t2.stream().map(BackgroupImageItem::image).collect(Collectors.toList());
|
|
|
|
|
+ dataLists.setShareQrurl(collect);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (Objects.nonNull(f.getT3().id())) {
|
|
|
|
|
+ dataLists.setRetAudio(f.getT3());
|
|
|
|
|
+ }
|
|
|
|
|
+ dataLists.setImages(f.getT4());
|
|
|
|
|
+ return Mono.just(dataLists);
|
|
|
|
|
+ });
|
|
|
|
|
+ return dataListsMono;
|
|
|
|
|
+ });
|
|
|
|
|
+ return RStatus.successList(dataListsKefuMono);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
* 查询domain
|
|
* 查询domain
|
|
|
*
|
|
*
|
|
|
* @param request
|
|
* @param request
|
|
@@ -353,6 +438,13 @@ public class PlanNewCommonOutController {
|
|
|
return new ReturnLoop(-1L, null, null, null, null, null, null, null, null, null, null, null, null, null);
|
|
return new ReturnLoop(-1L, null, null, null, null, null, null, null, null, null, null, null, null, null);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * H5分享
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param request
|
|
|
|
|
+ * @return {@link Mono}<{@link RStatus}<{@link PlanNewCommonShareRes}>>
|
|
|
|
|
+ */
|
|
|
|
|
+ @PostMapping("planCommonShare")
|
|
|
public Mono<RStatus<PlanNewCommonShareRes>> planCommonShare(@RequestBody PlanNewCommonShareReq request) {
|
|
public Mono<RStatus<PlanNewCommonShareRes>> planCommonShare(@RequestBody PlanNewCommonShareReq request) {
|
|
|
if (MAP.containsKey(request.getUnique())) {
|
|
if (MAP.containsKey(request.getUnique())) {
|
|
|
Integer integer = MAP.get(request.getUnique());
|
|
Integer integer = MAP.get(request.getUnique());
|
|
@@ -367,9 +459,13 @@ public class PlanNewCommonOutController {
|
|
|
.onErrorResume(throwable -> Mono.error(new Exception(throwable.getMessage())));
|
|
.onErrorResume(throwable -> Mono.error(new Exception(throwable.getMessage())));
|
|
|
Mono<PlanNewCommonShareRes> resMono = planNewCommonMono.flatMap(plan -> {
|
|
Mono<PlanNewCommonShareRes> resMono = planNewCommonMono.flatMap(plan -> {
|
|
|
Mono<StringBuilder> stringBuilderMono;
|
|
Mono<StringBuilder> stringBuilderMono;
|
|
|
|
|
+ boolean isQs = Objects.nonNull(request.getWx_user_id()) && !request.getWx_user_id().isEmpty();
|
|
|
|
|
+ if (3 == plan.type()) {
|
|
|
|
|
+ // 交友裂变无清水分类
|
|
|
|
|
+ isQs = false;
|
|
|
|
|
+ }
|
|
|
if (Objects.nonNull(request.getRedirectType()) && request.getRedirectType() == 2) {
|
|
if (Objects.nonNull(request.getRedirectType()) && request.getRedirectType() == 2) {
|
|
|
- stringBuilderMono = goGenerateService.byPlanNewIdGetUrl(request.getRedirectPlanId(),
|
|
|
|
|
- Objects.nonNull(request.getWx_user_id()) && !request.getWx_user_id().isEmpty());
|
|
|
|
|
|
|
+ stringBuilderMono = goGenerateService.byPlanNewIdGetUrlCommon(request.getRedirectPlanId(), isQs, request.getGroupIdQs());
|
|
|
} else {
|
|
} else {
|
|
|
stringBuilderMono = Mono.just(new StringBuilder(request.getLink()));
|
|
stringBuilderMono = Mono.just(new StringBuilder(request.getLink()));
|
|
|
}
|
|
}
|
|
@@ -389,8 +485,8 @@ public class PlanNewCommonOutController {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
Map<Integer, List<PlanNewBackgroupPoster>> backgroupPoster = f.getT4().stream().collect(Collectors.groupingBy(PlanNewBackgroupPoster::qsOrFx));
|
|
Map<Integer, List<PlanNewBackgroupPoster>> backgroupPoster = f.getT4().stream().collect(Collectors.groupingBy(PlanNewBackgroupPoster::qsOrFx));
|
|
|
- // 营销-清水
|
|
|
|
|
- if (Objects.nonNull(request.getWx_user_id()) && !request.getWx_user_id().isEmpty()) {
|
|
|
|
|
|
|
+ // 营销-清水, 交友裂变无清水背景
|
|
|
|
|
+ if (Objects.nonNull(request.getWx_user_id()) && !request.getWx_user_id().isEmpty() && 3 != plan.type()) {
|
|
|
List<PlanNewBackgroupPoster> qs = backgroupPoster.get(2).stream()
|
|
List<PlanNewBackgroupPoster> qs = backgroupPoster.get(2).stream()
|
|
|
.sorted(Comparator.comparing(PlanNewBackgroupPoster::index))
|
|
.sorted(Comparator.comparing(PlanNewBackgroupPoster::index))
|
|
|
.toList();
|
|
.toList();
|
|
@@ -439,7 +535,7 @@ public class PlanNewCommonOutController {
|
|
|
return Mono.just(res);
|
|
return Mono.just(res);
|
|
|
});
|
|
});
|
|
|
});
|
|
});
|
|
|
- Mono<PlanNewCommonShareRes> resMono1 = this.setEndData(request, setFmV(request, setAudioV(request, resMono)));
|
|
|
|
|
|
|
+ Mono<PlanNewCommonShareRes> resMono1 = this.setEndData(request, setFmV(setAudioV(request, resMono)));
|
|
|
return RStatus.successList(resMono1);
|
|
return RStatus.successList(resMono1);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -454,7 +550,8 @@ public class PlanNewCommonOutController {
|
|
|
}
|
|
}
|
|
|
String posterTemplate = poster.posterTemplate();
|
|
String posterTemplate = poster.posterTemplate();
|
|
|
GoRequest goRequest;
|
|
GoRequest goRequest;
|
|
|
- if (Objects.nonNull(request.getWx_user_id()) && !request.getWx_user_id().isEmpty()) {
|
|
|
|
|
|
|
+ // 交友裂变无清水分类
|
|
|
|
|
+ if (Objects.nonNull(request.getWx_user_id()) && !request.getWx_user_id().isEmpty() && 3 != fm.getPlanNew().type()) {
|
|
|
PlanNewBackgroupPoster qsSetting = fm.getQsSetting();
|
|
PlanNewBackgroupPoster qsSetting = fm.getQsSetting();
|
|
|
goRequest = setNameVal(posterTemplate, qsSetting, fm.getSpare());
|
|
goRequest = setNameVal(posterTemplate, qsSetting, fm.getSpare());
|
|
|
} else {
|
|
} else {
|
|
@@ -479,7 +576,7 @@ public class PlanNewCommonOutController {
|
|
|
JSONObject data = jsonObject1.get("data", JSONObject.class);
|
|
JSONObject data = jsonObject1.get("data", JSONObject.class);
|
|
|
if (data.containsKey("Url")) {
|
|
if (data.containsKey("Url")) {
|
|
|
String url = data.get("Url", String.class);
|
|
String url = data.get("Url", String.class);
|
|
|
- if (Objects.nonNull(request.getWx_user_id()) && !request.getWx_user_id().isEmpty()) {
|
|
|
|
|
|
|
+ if (Objects.nonNull(request.getWx_user_id()) && !request.getWx_user_id().isEmpty() && 3 != fm.getPlanNew().type()) {
|
|
|
fm.setQsGenerateImagesUrl(url);
|
|
fm.setQsGenerateImagesUrl(url);
|
|
|
} else {
|
|
} else {
|
|
|
fm.setFxGenerateImagesUrl(url);
|
|
fm.setFxGenerateImagesUrl(url);
|
|
@@ -536,7 +633,7 @@ public class PlanNewCommonOutController {
|
|
|
/**
|
|
/**
|
|
|
* 设置封面等
|
|
* 设置封面等
|
|
|
*/
|
|
*/
|
|
|
- private Mono<PlanNewCommonShareRes> setFmV(PlanNewCommonShareReq request, Mono<PlanNewCommonShareRes> zip) {
|
|
|
|
|
|
|
+ private Mono<PlanNewCommonShareRes> setFmV(Mono<PlanNewCommonShareRes> zip) {
|
|
|
Mono<PlanNewCommonShareRes> resMono = zip.flatMap(fm -> {
|
|
Mono<PlanNewCommonShareRes> resMono = zip.flatMap(fm -> {
|
|
|
Poster poster = fm.getPoster();
|
|
Poster poster = fm.getPoster();
|
|
|
if (Objects.isNull(poster)) {
|
|
if (Objects.isNull(poster)) {
|
|
@@ -581,7 +678,7 @@ public class PlanNewCommonOutController {
|
|
|
private Mono<PlanNewCommonShareRes> setAudioV(PlanNewCommonShareReq request, Mono<PlanNewCommonShareRes> resMono) {
|
|
private Mono<PlanNewCommonShareRes> setAudioV(PlanNewCommonShareReq request, Mono<PlanNewCommonShareRes> resMono) {
|
|
|
Mono<PlanNewCommonShareRes> zip = resMono.flatMap(f -> {
|
|
Mono<PlanNewCommonShareRes> zip = resMono.flatMap(f -> {
|
|
|
Mono<Audio> id = null;
|
|
Mono<Audio> id = null;
|
|
|
- if (Objects.nonNull(request.getWx_user_id()) && !request.getWx_user_id().isEmpty()) {
|
|
|
|
|
|
|
+ if (Objects.nonNull(request.getWx_user_id()) && !request.getWx_user_id().isEmpty() && 3 != f.getPlanNew().type() ) {
|
|
|
PlanNewBackgroupPoster qsSetting = f.getQsSetting();
|
|
PlanNewBackgroupPoster qsSetting = f.getQsSetting();
|
|
|
if (Objects.nonNull(qsSetting) && Objects.nonNull(qsSetting.audioId()) && 0 != qsSetting.audioId()) {
|
|
if (Objects.nonNull(qsSetting) && Objects.nonNull(qsSetting.audioId()) && 0 != qsSetting.audioId()) {
|
|
|
id = template.selectOne(Query.query(Criteria.where("id").is(qsSetting.audioId()).and("deleted_at").isNull()), Audio.class);
|
|
id = template.selectOne(Query.query(Criteria.where("id").is(qsSetting.audioId()).and("deleted_at").isNull()), Audio.class);
|