|
|
@@ -10,6 +10,7 @@ import cn.hutool.json.JSONObject;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
import com.webflux.launchadmin.global.BaseException;
|
|
|
import com.webflux.launchadmin.mysql.controller.planNew.req.PlanReq;
|
|
|
+import com.webflux.launchadmin.mysql.controller.planNew.req.ReadBookPlanGetImageOutReq;
|
|
|
import com.webflux.launchadmin.mysql.controller.planNew.req.ReadBookPlanGetImageReq;
|
|
|
import com.webflux.launchadmin.mysql.controller.planNew.req.ServiceGroupSettingItemRequest;
|
|
|
import com.webflux.launchadmin.mysql.controller.planNew.res.ReadBookGetOneMaterialRes;
|
|
|
@@ -76,6 +77,64 @@ public class ReadBookPlanServicesImpl implements ReadBookPlanServicesInterface{
|
|
|
return Mono.just(readBookGetPosterImageRes);
|
|
|
}));
|
|
|
}
|
|
|
+ @Override
|
|
|
+ public Mono<ReadBookGetPosterImageRes> readBookGetPosterOut(ReadBookPlanGetImageOutReq request1) {
|
|
|
+ Mono<PlanNewCommon> planNewCommonMono = template.selectOne(Query.query(Criteria.where("code")
|
|
|
+ .is(request1.getCode())), PlanNewCommon.class)
|
|
|
+ .switchIfEmpty(Mono.error(new BaseException("code错误")))
|
|
|
+ .onErrorResume(throwable -> Mono.error(new BaseException("请求异常:"+throwable.getMessage())));
|
|
|
+ return planNewCommonMono.flatMap(plan -> template.select(Query.query(Criteria.where("poster_template_id")
|
|
|
+ .is(plan.posterTemplateId()))
|
|
|
+ .sort(Sort.by(Sort.Order.asc("created_at"))), Poster.class)
|
|
|
+ .collectList()
|
|
|
+ .flatMap(posters -> {
|
|
|
+ ReadBookPlanGetImageReq request = new ReadBookPlanGetImageReq();
|
|
|
+ if(Objects.nonNull(plan.type()) && 5==plan.type()){
|
|
|
+ String configJson = plan.configJson();
|
|
|
+ if(Objects.nonNull(configJson) ){
|
|
|
+ JSONObject jsonObject;
|
|
|
+ try {
|
|
|
+ jsonObject = JSONUtil.parseObj(configJson);
|
|
|
+ }catch (Exception e){
|
|
|
+ throw new BaseException("解析configJson异常"+e.getMessage());
|
|
|
+ }
|
|
|
+ if(!jsonObject.containsKey("posterCustomerServiceId")){
|
|
|
+ throw new BaseException("解析configJson 不包含字段 posterCustomerServiceId");
|
|
|
+ }
|
|
|
+ String posterCustomerServiceId ;
|
|
|
+ try {
|
|
|
+ posterCustomerServiceId = jsonObject.get("posterCustomerServiceId", String.class);
|
|
|
+ }catch (Exception e){
|
|
|
+ throw new BaseException("解析posterCustomerServiceId异常"+e.getMessage());
|
|
|
+ }
|
|
|
+ request.setChannelCodeId(posterCustomerServiceId);
|
|
|
+ request.setCode(request1.getCode());
|
|
|
+ request.setWxExternalUserid(request1.getWxExternalUserid());
|
|
|
+ // String s = byCustomerIdGetUrl(posterCustomerServiceId);
|
|
|
+ //return Mono.just(new StringBuilder(s));
|
|
|
+ }
|
|
|
+ //saveRequest.setImportDomain(String.valueOf(saveRequest.getGroupId()));
|
|
|
+ }
|
|
|
+ Poster poster = posters.get(RandomUtil.randomInt(0, posters.size()));
|
|
|
+ String posterTemplate = poster.posterTemplate();
|
|
|
+ JSONObject jsonObject = JSONUtil.parseObj(posterTemplate);
|
|
|
+ GoRequest goRequest = new GoRequest();
|
|
|
+ BeanUtil.copyProperties(jsonObject, goRequest);
|
|
|
+ return readBookGenerateImagePasePoster(goRequest,
|
|
|
+ goGenerateService.setCusqrcodeSetV(goRequest),//设置自定义二维码
|
|
|
+ setQrcodeV(goRequest, request, plan), request).onErrorResume(throwable -> {
|
|
|
+ if (Objects.nonNull(request.getCatchString()) && !"".equals(request.getCatchString())) {
|
|
|
+ return Mono.just(request.getCatchString());
|
|
|
+ }else {
|
|
|
+ return Mono.error(new BaseException(throwable.getMessage()));
|
|
|
+ }
|
|
|
+ });//设置二维码
|
|
|
+ }).flatMap(s -> {
|
|
|
+ ReadBookGetPosterImageRes readBookGetPosterImageRes = new ReadBookGetPosterImageRes();
|
|
|
+ readBookGetPosterImageRes.setPosterImagesUrl(s);
|
|
|
+ return Mono.just(readBookGetPosterImageRes);
|
|
|
+ }));
|
|
|
+ }
|
|
|
|
|
|
@Override
|
|
|
public Mono<ReadBookGetOneMaterialRes> readBookGetOneMaterial(String code,Integer type) {
|
|
|
@@ -403,6 +462,7 @@ public class ReadBookPlanServicesImpl implements ReadBookPlanServicesInterface{
|
|
|
});
|
|
|
return stringMono;
|
|
|
}
|
|
|
+
|
|
|
//设置自定义二维码
|
|
|
private Mono<Boolean> setQrcodeV(GoRequest goRequest,ReadBookPlanGetImageReq request,PlanNewCommon plan){
|
|
|
Optional<Item> first = goRequest.getItem().stream().filter(fz -> "qrcode".equals(fz.getT())).findFirst();
|
|
|
@@ -414,6 +474,7 @@ public class ReadBookPlanServicesImpl implements ReadBookPlanServicesInterface{
|
|
|
//用计划
|
|
|
url = byGroupIdGetUrl(Mono.just(plan));
|
|
|
return Mono.zip(Mono.just(item),url).flatMap(f->{
|
|
|
+ request.setCatchString(f.getT2());
|
|
|
f.getT1().setV(f.getT2());
|
|
|
f.getT1().setName("客服二维码");
|
|
|
return Mono.just(true);
|