FengChaoYu 1 tahun lalu
induk
melakukan
aef6700d34

+ 12 - 2
mall-miniapp-service/src/main/java/com/gree/mall/miniapp/logic/workorder/ChangeOrderLogic.java

@@ -34,6 +34,7 @@ import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -107,6 +108,15 @@ public class ChangeOrderLogic {
     @Resource
     GoodsCategoryItemService goodsCategoryItemService;
 
+    @Value("${ali.oss.endpoint.ww}")
+    private String OSS_WW;
+
+    @Value("${sys.url}")
+    private String sysUrl;
+
+    @Value("${server.servlet.context-path}")
+    private String contextPath;
+
 
     private final OldProductManagerService oldProductManagerService;
     private final OldProductManagerItemService oldProductManagerItemService;
@@ -231,7 +241,7 @@ public class ChangeOrderLogic {
         // 生成的文件的存放路径
         File mkdir = FileUtil.mkdir(path + "/tmp/report" );
 
-        File file= CommonUtils.getFileByHttpURL(patch, mkdir.getPath());
+        File file= CommonUtils.getFileByHttpURL(patch, mkdir.getPath(), OSS_WW, sysUrl + contextPath);
 
 
         String contentType = FileNameUtil.getSuffix(patch);
@@ -324,7 +334,7 @@ public class ChangeOrderLogic {
         // 生成的文件的存放路径
         File mkdir = FileUtil.mkdir(path + "/tmp/report" );
 
-        File fileByHttpURL = CommonUtils.getFileByHttpURL(patch, mkdir.getPath());
+        File fileByHttpURL = CommonUtils.getFileByHttpURL(patch, mkdir.getPath(), OSS_WW, sysUrl + contextPath);
         File file = FileUtil.file(fileName+"/test2_result.png");
 
         URL url = new URL(patch);

+ 2 - 0
mall-miniapp-service/src/main/java/com/gree/mall/miniapp/schedule/AllinpaySchedule.java

@@ -10,6 +10,7 @@ import com.gree.mall.miniapp.logic.material.WebsitSalesLogic;
 import com.gree.mall.miniapp.plus.entity.WebsitSalesPayOrder;
 import com.gree.mall.miniapp.plus.service.WebsitSalesPayOrderService;
 import lombok.extern.slf4j.Slf4j;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
 import org.springframework.integration.redis.util.RedisLockRegistry;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Component;
@@ -22,6 +23,7 @@ import java.util.concurrent.locks.Lock;
 
 @Component
 @Slf4j
+@ConditionalOnProperty(name = "schedule.enable", havingValue = "true", matchIfMissing = true)
 public class AllinpaySchedule {
 
     @Resource

+ 10 - 2
mall-miniapp-service/src/main/java/com/gree/mall/miniapp/utils/CommonUtils.java

@@ -1,6 +1,7 @@
 package com.gree.mall.miniapp.utils;
 
 
+import cn.hutool.core.util.StrUtil;
 import com.gree.mall.miniapp.constant.Constant;
 import com.gree.mall.miniapp.exception.RemoteServiceException;
 import org.apache.commons.lang3.StringUtils;
@@ -261,19 +262,26 @@ public class CommonUtils {
     /**
      * 根据URL地址获取文件
      * @param path URL网络地址
+     * @param checkStr
+     * @param replacePrefix
      * @return File
      */
-    public static File getFileByHttpURL(String path,String address){
+    public static File getFileByHttpURL(String path, String address, String checkStr, String replacePrefix){
         String newUrl = path.split("[?]")[0];
         String[] suffix = newUrl.split("/");
         //得到最后一个分隔符后的名字
         String fileName = suffix[suffix.length - 1];
+        String reqUrl = path;
+        if (path.contains(checkStr)) {
+            int endIndex = path.indexOf(checkStr) + checkStr.length();
+            reqUrl = StrUtil.replace(reqUrl, 0, endIndex, replacePrefix + "/img/get?key=");
+        }
         File file = null;
         InputStream inputStream = null;
         OutputStream outputStream = null;
         try{
             file = new File(address+"/"+fileName);//创建临时文件
-            URL urlFile = new URL(path);
+            URL urlFile = new URL(reqUrl);
             inputStream = urlFile.openStream();
             outputStream = new FileOutputStream(file);