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

读书计划-v0.04

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

+ 6 - 1
launch-admin/src/main/java/com/webflux/launchadmin/mysql/controller/planNew/PlanNewCommonController.java

@@ -164,7 +164,12 @@ public class PlanNewCommonController {
                     JSONObject jsonObject = JSONUtil.parseObj(posterTemplate);
                     GoRequest goRequest = new GoRequest();
                     BeanUtil.copyProperties(jsonObject, goRequest);
-                    ServiceGroupSettingItemRequest serviceGroupSettingItemRequest = planReq.getBackgroupFxSetting().getFirst();
+                    ServiceGroupSettingItemRequest serviceGroupSettingItemRequest ;
+                    if(Objects.nonNull(planReq.getType()) && 5==planReq.getType()){
+                        serviceGroupSettingItemRequest =new ServiceGroupSettingItemRequest();
+                    }else {
+                      serviceGroupSettingItemRequest = planReq.getBackgroupFxSetting().getFirst();
+                    }
                     return goGenerateService.saveAndUpdatePlanGenerateImage0(goRequest,
                             goGenerateService.setCusqrcodeSetV(goRequest),// getStringBuilderMono(goRequest),
                             serviceGroupSettingItemRequest,

+ 1 - 1
launch-admin/src/main/java/com/webflux/launchadmin/mysql/controller/planNew/req/ReadBookPlanGetImageReq.java

@@ -17,7 +17,7 @@ public class ReadBookPlanGetImageReq {
      *海报客服Id
      */
     @NotEmpty(message = "channelCodeId 请求参数不可为空")
-    private  Long channelCodeId;
+    private  String channelCodeId;
 
     @NotEmpty(message = "wxExternalUserid 请求参数不可为空")
     private String wxExternalUserid;

+ 96 - 23
launch-admin/src/main/java/com/webflux/launchadmin/mysql/service/planNew/goGenerate/GoGenerateService.java

@@ -20,6 +20,8 @@ import com.webflux.launchadmin.mysql.entity.listening.ListeningPlanNew;
 import com.webflux.launchadmin.mysql.entity.planNew.*;
 import com.webflux.launchadmin.mysql.service.planNew.structure.GoRequest;
 import com.webflux.launchadmin.mysql.service.planNew.structure.Item;
+import com.webflux.launchadmin.mysql.service.readBookPlan.ReadBookPlanServicesImpl;
+import com.webflux.launchadmin.mysql.service.readBookPlan.ReadBookPlanServicesInterface;
 import com.webflux.launchcommon.returnObj.RStatus;
 import jakarta.annotation.Resource;
 import lombok.extern.slf4j.Slf4j;
@@ -53,6 +55,7 @@ public class GoGenerateService {
     @Resource
     private R2dbcEntityTemplate template;
 
+
     // http://wx-share-test.duiweize.com
     // http://wx-share-8.duiweize.com 正式
     public String goGenerate(String temStr) {
@@ -658,27 +661,32 @@ public class GoGenerateService {
             if (first5.isPresent()) {
                 Item item = first5.get();
                 Boolean isRandom = item.getIsRandom();
-                if (isRandom && Objects.nonNull(qsSetting.getStatus()) && qsSetting.getStatus() == 1
-                        && Objects.nonNull(qsSetting.getServiceGroupType()) && qsSetting.getServiceGroupType() == 2) {
-                    String kefu = qsSetting.getKefu();
-                    if (Objects.nonNull(kefu) && kefu.contains("[") && kefu.contains("]")) {
-                        JSONArray jsonArray = JSONUtil.parseArray(kefu);
-                        if (!jsonArray.isEmpty()) {
-                            String s = jsonArray.get(0, String.class);
-                            item.setV(s);
-                            item.setName("客服二维码");
-                        }
-                    } else {
-                        throw new BaseException("客服二维码 上传图片 为空");
-                    }
-                } else if (Objects.nonNull(qsSetting.getStatus()) && qsSetting.getStatus() == 0) {
-                    StringBuilder t6 = f.getT6();
-                    if ("".equals(t6)) {
-                        throw new BaseException("获取H5链接为空");
-                    }
-                    item.setV(t6.toString());
-                    item.setName("H5二维码");
-                }
+               if(Objects.nonNull(saveRequest.getType()) && 5==saveRequest.getType()){
+                   item.setV(f.getT6().toString());
+                   item.setName("客服二维码");
+              }else {
+                   if (isRandom && Objects.nonNull(qsSetting.getStatus()) && qsSetting.getStatus() == 1
+                           && Objects.nonNull(qsSetting.getServiceGroupType()) && qsSetting.getServiceGroupType() == 2) {
+                       String kefu = qsSetting.getKefu();
+                       if (Objects.nonNull(kefu) && kefu.contains("[") && kefu.contains("]")) {
+                           JSONArray jsonArray = JSONUtil.parseArray(kefu);
+                           if (!jsonArray.isEmpty()) {
+                               String s = jsonArray.get(0, String.class);
+                               item.setV(s);
+                               item.setName("客服二维码");
+                           }
+                       } else {
+                           throw new BaseException("客服二维码 上传图片 为空");
+                       }
+                   } else if (Objects.nonNull(qsSetting.getStatus()) && qsSetting.getStatus() == 0) {
+                       StringBuilder t6 = f.getT6();
+                       if ("".equals(t6)) {
+                           throw new BaseException("获取H5链接为空");
+                       }
+                       item.setV(t6.toString());
+                       item.setName("H5二维码");
+                   }
+               }
             }
             // 图片
             List<Image> t2 = f.getT2().stream().filter(ft -> Objects.nonNull(ft.id())).collect(Collectors.toList());
@@ -808,10 +816,75 @@ public class GoGenerateService {
         QrcodeInfo qrcodeInfo = new QrcodeInfo(null,first.isPresent()?first.get().getV():"",first3.isPresent()?first3.get().getV():"");
         return qrcodeInfo;
     }
+    @Value("${go.data.contactWay}")
+    private String contactWayUrl;
+
+    public String byCustomerIdGetUrl(String channelCodeId) {
+        //?channelCodeId=941873&state=1
+        long l = System.currentTimeMillis();
+        String body;
+        String url = contactWayUrl + "?channelCodeId="+channelCodeId+"&state="+l;
+        try {
+            body = HttpUtil.get(url, 100000);
+        } catch (Exception e) {
+            String format = StrUtil.format("请求【客服活码对外接口】errrr:{} channelCodeId:{} Get请求url:{}", e.getMessage(), channelCodeId, url);
+            log.error(format);
+            throw new BaseException(format);
+        }
+        if (Objects.isNull(body)||"".equals(body.trim())  ) {
+            String format = StrUtil.format("请求【客服活码对外接口】返回结果异常:{} channelCodeId:{} Get请求url:{}", body, channelCodeId, url);
+            log.error(format);
+            throw new BaseException(format);
+        }
+        JSONObject jsonObject;
+        try {
+            jsonObject = JSONUtil.parseObj(body);
+        }catch (Exception e){
+            String format = StrUtil.format("请求【客服活码对外接口】返回结果解析JSONERRR:{} channelCodeId:{} Get请求url:{} Body:{}", e.getMessage(), channelCodeId, url,body);
+            log.error(format);
+            throw new BaseException(format);
+        }
+        if (jsonObject.containsKey("code")
+                && Objects.nonNull(jsonObject.get("code"))
+                && jsonObject.get("code", Integer.class) == 200
+                && jsonObject.containsKey("data")
+                && Objects.nonNull(jsonObject.get("data"))
+        ) {
+            return jsonObject.get("data", String.class);
+        }else {
+            String format = StrUtil.format("请求【客服活码对外接口】返回结果失败 channelCodeId:{} Get请求url:{} Body:{}",  channelCodeId, url,body);
+            log.error(format);
+            throw new BaseException(format);
+        }
+    }
 
     public Mono<StringBuilder> getImportDomain(PlanReq saveRequest) {
-        if (Objects.isNull(saveRequest.getImportDomain()) || "".equals(saveRequest.getImportDomain())) {
-            throw new BaseException("入口页域名值不可为空");
+        if(Objects.nonNull(saveRequest.getType()) && 5==saveRequest.getType()){
+            String configJson = saveRequest.getConfigJson();
+            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());
+                }
+                String s = byCustomerIdGetUrl(posterCustomerServiceId);
+                return Mono.just(new StringBuilder(s));
+            }
+            //saveRequest.setImportDomain(String.valueOf(saveRequest.getGroupId()));
+        }else {
+            if (Objects.isNull(saveRequest.getImportDomain()) || "".equals(saveRequest.getImportDomain())) {
+                throw new BaseException("入口页域名值不可为空");
+            }
         }
         return template.select(Query.query(Criteria.where("group_type_id").is(saveRequest.getImportDomain())
                         .and("status").is(1)

+ 2 - 41
launch-admin/src/main/java/com/webflux/launchadmin/mysql/service/readBookPlan/ReadBookPlanServicesImpl.java

@@ -44,8 +44,7 @@ public class ReadBookPlanServicesImpl implements ReadBookPlanServicesInterface{
 
     @Resource
     private R2dbcEntityTemplate template;
-    @Value("${go.data.contactWay}")
-    private String contactWayUrl;
+
     @Value("${go.data.getAvatarByWxUid}")
     private String getAvatarByWxUid;
     @Resource
@@ -166,44 +165,6 @@ public class ReadBookPlanServicesImpl implements ReadBookPlanServicesInterface{
         }
     }
 
-    public String byCustomerIdGetUrl(Long channelCodeId) {
-        //?channelCodeId=941873&state=1
-        long l = System.currentTimeMillis();
-        String body;
-        String url = contactWayUrl + "?channelCodeId="+channelCodeId+"&state="+l;
-        try {
-            body = HttpUtil.get(url, 100000);
-        } catch (Exception e) {
-            String format = StrUtil.format("请求【客服活码对外接口】errrr:{} channelCodeId:{} Get请求url:{}", e.getMessage(), channelCodeId, url);
-            log.error(format);
-            throw new BaseException(format);
-        }
-        if (Objects.isNull(body)||"".equals(body.trim())  ) {
-            String format = StrUtil.format("请求【客服活码对外接口】返回结果异常:{} channelCodeId:{} Get请求url:{}", body, channelCodeId, url);
-            log.error(format);
-            throw new BaseException(format);
-        }
-        JSONObject jsonObject;
-        try {
-            jsonObject = JSONUtil.parseObj(body);
-        }catch (Exception e){
-            String format = StrUtil.format("请求【客服活码对外接口】返回结果解析JSONERRR:{} channelCodeId:{} Get请求url:{} Body:{}", e.getMessage(), channelCodeId, url,body);
-            log.error(format);
-            throw new BaseException(format);
-        }
-        if (jsonObject.containsKey("code")
-                && Objects.nonNull(jsonObject.get("code"))
-                && jsonObject.get("code", Integer.class) == 200
-                && jsonObject.containsKey("data")
-                && Objects.nonNull(jsonObject.get("data"))
-        ) {
-            return jsonObject.get("data", String.class);
-        }else {
-            String format = StrUtil.format("请求【客服活码对外接口】返回结果失败 channelCodeId:{} Get请求url:{} Body:{}",  channelCodeId, url,body);
-            log.error(format);
-            throw new BaseException(format);
-        }
-    }
 
     public Mono<String> readBookGenerateImagePasePoster(GoRequest goRequest,
                                                         Mono<List<StringBuilder>> stringBuilderMono,
@@ -452,7 +413,7 @@ public class ReadBookPlanServicesImpl implements ReadBookPlanServicesInterface{
                 Mono<String> url;
                 if(item.getIsChannel()){
                     //用客服
-                    url = Mono.just(byCustomerIdGetUrl(request.getChannelCodeId()));
+                    url = Mono.just(goGenerateService.byCustomerIdGetUrl(request.getChannelCodeId()));
                   return   Mono.zip(Mono.just(item),url).flatMap(f->{
                         f.getT1().setV(f.getT2());
                         f.getT1().setName("客服二维码");