Pu Zhibing
7 天以前 eaa61bc9ecd9158f192f9999845cb2f05e6970fb
driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/api/DriverController.java
@@ -1,11 +1,13 @@
package com.supersavedriving.driver.modular.system.api;
import cn.hutool.core.io.FileUtil;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.heredata.hos.model.bucket.Bucket;
import com.supersavedriving.driver.modular.system.dao.MonthOrderMapper;
import com.supersavedriving.driver.modular.system.model.*;
import com.supersavedriving.driver.modular.system.service.*;
@@ -13,8 +15,6 @@
import com.supersavedriving.driver.modular.system.util.MallBook.model.InterfaceResponse;
import com.supersavedriving.driver.modular.system.util.MiniPay.MiniAppPay;
import com.supersavedriving.driver.modular.system.util.juhe.OCRUtil;
import com.supersavedriving.driver.modular.system.util.qianyuntong.NCOSSUtil;
import com.supersavedriving.driver.modular.system.util.qianyuntong.QianYunTongConfig;
import com.supersavedriving.driver.modular.system.util.qianyuntong.SMSUtil;
import com.supersavedriving.driver.modular.system.util.qianyuntong.model.SendSmsRequest;
import com.supersavedriving.driver.modular.system.util.separateAccounts.StrUtil;
@@ -33,12 +33,14 @@
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.InputStream;
import java.io.PrintWriter;
import java.time.LocalDateTime;
@@ -86,8 +88,6 @@
    @Autowired
    private ISystemConfigService systemConfigService;
    @Autowired
    private IEditionService editionService;
@@ -99,9 +99,12 @@
    @Autowired
    private TCheckFacilitatorService checkFacilitatorService;
    @Resource
    private QianYunTongConfig qianYunTongConfig;
    @Value("${filePath}")
    private String filePath;
    @Value("${qyt.admin_url}")
    private String adminUrl;
@@ -164,6 +167,8 @@
            return new ResponseWarpper(500, e.getMessage());
        }
    }
    @ResponseBody
    @PostMapping("/base/driver/orcPhoto")
//    @ServiceLog(name = "司机注册申请", url = "/base/driver/driverRegister")
@@ -920,7 +925,6 @@
    /**
     * 账户余额充值支付回调
     * @param response
     */
    @ResponseBody
    @PostMapping("/base/driver/balanceRechargeCallback")
@@ -1179,29 +1183,15 @@
            InputStream inputStream = file.getInputStream();
            String name = file.getOriginalFilename();
            name = UUIDUtil.getRandomCode() + name.substring(name.lastIndexOf("."));
            QianYunTongConfig qianYunTongConfig1 = qianYunTongConfig.getQianYunTongConfig();
            String bucketName = qianYunTongConfig1.getBucketName();
            Bucket grjyTest = NCOSSUtil.getBucketInfo(bucketName);
            if (null == grjyTest) {
                //创建桶
                Boolean bucket = NCOSSUtil.createBucket(bucketName);
                if (!bucket) {
                    throw new RuntimeException("创建存储桶失败");
                }
                //设置桶策略
                String policyText = "{\"Version\":\"2025-06-23\",\"Statement\":[{\"Sid\":\"Stmt20250623\",\"Action\":[\"GetObject\"],\"Effect\":\"Allow\",\"Resource\":\"" + bucketName + "/*\",\"Principal\":\"*\"}]}";
                Boolean bucketPolicy = NCOSSUtil.setBucketPolicy(bucketName, policyText);
                if (!bucketPolicy) {
                    throw new RuntimeException("设置桶策略失败");
                }
            File file1 = FileUtil.writeFromStream(inputStream, new File(filePath + name));
            HttpRequest post = HttpUtil.createPost(adminUrl + "/upload/image");
            HttpRequest form = post.form("file", file1);
            HttpResponse execute = form.execute();
            int status = execute.getStatus();
            if(200 != status){
                throw new RuntimeException("上传图片异常");
            }
            //上传对象
            String key = "imgs/daijia/user/" + name;
            String object = NCOSSUtil.putObject(bucketName, key, inputStream);
            if (null == object) {
                throw new RuntimeException("上传图片失败");
            }
            return ResponseWarpper.success("https://traffic.qytzt.cn/v1/AUTH_" + qianYunTongConfig1.getAccount() + "/" + bucketName + "/" + key);
            return ResponseWarpper.success(execute.body());
        }catch (Exception e){
            e.printStackTrace();
            return new ResponseWarpper(500, e.getMessage());