Commit 11266757 by zhangxw

Merge branch 'v1.5.0' of http://192.168.3.233:8090/usedCarAuction/aus into v1.5.0

2 parents 342e3593 f1a528c7
......@@ -103,6 +103,9 @@ aliyun:
accessKeySecret: iYJdlgs6khO53YqoQYDOtHXCk83d5C
bucketName: jinrong-huidan-test
region: cn-shenzhen
roleArn: acs:ram::1312972928453148:role/ramosstest
roleSessionName: ramoss-aus-session
durationSeconds: 3600
esign:
appId: 7439084933
appKey: fecd5f39bf93cdfe6e704b62390bcc29
......
package com.glsx.usedcar.handler;
import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.auth.sts.AssumeRoleRequest;
import com.aliyuncs.auth.sts.AssumeRoleResponse;
import com.aliyuncs.profile.DefaultProfile;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.summerframework.core.enums.ErrorCodeEnum;
import org.summerframework.core.exception.BusinessCodeException;
/**
* @author yangwei
* @version 1.0
* @since 2026/04/24 12:07
*/
@Slf4j
@Component
public class AliyunOssHandler {
@Value("${aliyun.oss.accessKeyId}")
private String accessKeyId;
@Value("${aliyun.oss.accessKeySecret}")
private String accessKeySecret;
@Value("${aliyun.oss.region}")
private String regionId;
@Value("${aliyun.oss.roleArn}")
private String roleArn;
@Value("${aliyun.oss.roleSessionName}")
private String roleSessionName;
@Value("${aliyun.oss.durationSeconds}")
private Long durationSeconds;
/**
* 获取临时角色token
* @author yangwei
* @since 2026/4/24 12:21
* @return com.glsx.usedcar.handler.AliyunToken
*/
public AliyunToken getToken() {
DefaultProfile profile = DefaultProfile.getProfile(regionId, accessKeyId, accessKeySecret);
AssumeRoleResponse response = getAssumeRoleResponse(profile);
AliyunToken aliyunToken = new AliyunToken();
aliyunToken.setSecurityToken(response.getCredentials().getSecurityToken());
aliyunToken.setLsaccessKeyId(response.getCredentials().getAccessKeyId());
aliyunToken.setLsaccessKeySecret(response.getCredentials().getAccessKeySecret());
return aliyunToken;
}
/**
* 获取临时安全令牌扮演
* @author yangwei
* @since 2026/4/24 12:20
* @param profile 环境配置文件
* @return com.aliyuncs.auth.sts.AssumeRoleResponse
*/
private AssumeRoleResponse getAssumeRoleResponse(DefaultProfile profile) {
IAcsClient client = new DefaultAcsClient(profile);
// 创建获取临时安全令牌的请求
AssumeRoleRequest request = new AssumeRoleRequest();
request.setRoleArn(roleArn);
request.setRoleSessionName(roleSessionName);
request.setDurationSeconds(durationSeconds);
// 发送请求并获取临时安全令牌
AssumeRoleResponse response;
try {
response = client.getAcsResponse(request);
} catch (com.aliyuncs.exceptions.ClientException e) {
throw new BusinessCodeException(ErrorCodeEnum.INSPECTOR_LOGIN_CODE_ERROR);
}
return response;
}
}
package com.glsx.usedcar.handler;
import lombok.Data;
import java.io.Serializable;
@Data
public class AliyunToken implements Serializable {
private String lsaccessKeyId;
private String lsaccessKeySecret;
private String securityToken;
}
......@@ -166,6 +166,12 @@ public class AuctionOrderService extends AbstractAuctionService {
returnDeposit(deposit, "订单取消,退还保证金,订单号:" + auctionOrder.getOrderCode(), auctionOrder.getAccount());
auctionOrder.setCancelReason(order.getCancelReason());
auctionOrder.resetOrderState(AuctionOrder.OrderState.CANCELED, Vehicle.VehicleState.PRICED);
AuctionVehicle auctionAndVehicle = auctionVehicleDao.findTopByAuctionAndVehicle(auctionOrder.getAuction(), auctionOrder.getVehicle());
Vehicle vehicle = auctionAndVehicle.getVehicle();
if (vehicle != null) {
vehicle.setVehicleState(Vehicle.VehicleState.PRICED);
}
vrAuditService.syncVrAuditStatus(auctionAndVehicle);
gscInvoker.pushAuction(auctionOrder);
return auctionOrder;
}
......@@ -226,6 +232,10 @@ public class AuctionOrderService extends AbstractAuctionService {
Deposit deposit = depositDao.findByAuctionVehicle_AuctionAndAuctionVehicle_VehicleAndDepositStateAndAccount(auctionOrder.getAuction(), vehicle, Deposit.DepositState.FREEZE, account);
returnDeposit(deposit, "拍卖成功,退还保证金,订单号:" + auctionOrder.getOrderCode(), account);
AuctionVehicle auctionAndVehicle = auctionVehicleDao.findTopByAuctionAndVehicle(auctionOrder.getAuction(), auctionOrder.getVehicle());
Vehicle v = auctionAndVehicle.getVehicle();
if (v != null) {
v.setVehicleState(Vehicle.VehicleState.COMPLETED);
}
vrAuditService.syncVrAuditStatus(auctionAndVehicle);
// 审批通过,创建订单快照
orderSnapshotService.createFromAuctionOrder(auctionOrder);
......
......@@ -1135,8 +1135,24 @@ public class VrAuditService {
// 设置评估与交易 EvaluationTransaction
EvaluationTransaction evaluationTransaction = new EvaluationTransaction();
evaluationTransaction.setOverallRating(1); // 车辆整体评级默认1-优
evaluationTransaction.setEvalOrderNo(""); // 评估单编号,默认空
evaluationTransaction.setEvalOpinion(""); // 评估意见,默认空
evaluationTransaction.setSellerMerchantName("");
evaluationTransaction.setSellerName(""); // 销售顾问
vehicle.setEvaluationTransaction(evaluationTransaction);
// 设置车辆保管信息 CustodianInfo
CustodianInfo custodianInfo = new CustodianInfo();
custodianInfo.setCustodianName(""); // 保管人姓名,默认发拍人
custodianInfo.setCustodianPhone(""); // 保管人联系方式
vehicle.setCustodianInfo(custodianInfo);
// 设置车主信息 OwnerInfo
OwnerInfo ownerInfo = new OwnerInfo();
ownerInfo.setPreviousOwnerName(""); // 车主姓名,默认空
ownerInfo.setPreviousOwnerPhone(""); // 车主联系方式,默认空
vehicle.setOwnerInfo(ownerInfo);
// 设置车辆图片 carImages
List<CarImage> carImages = buildCarImages(vrAudit);
vehicle.setCarImages(carImages);
......
......@@ -23,6 +23,7 @@ public enum ErrorCodeEnum {
BUSINESS_BUSY(1010, "业务繁忙,请稍后重试"),
COMMON_ERROR(1000000, "{0}"),
DATA_INCOMPLETE(1000001, "数据不完整:[{0}]"),
GET_TEMPORARY_SAFE_TOKEN_FAILED(1000002, "获取临时安全令牌失败"),
/* 七位错误码,第一位标志位,前三位模块,后三位具体错误码 */
/** 检测模块 1001 */
......
......@@ -9,7 +9,7 @@ import org.springframework.data.domain.AuditorAware;
*
*/
@Configuration
public class BeanConfig {
public class InspectorBeanConfig {
@Bean
public AuditorAware<String> auditorProvider() {
......
package com.glsx.usedcar.controller;
import com.glsx.usedcar.handler.AliyunOssHandler;
import com.glsx.usedcar.handler.AliyunToken;
import com.glsx.usedcar.resp.BaseResp;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @author yangwei
* @version 1.0
* @since 2026/04/24 12:10
*/
@RestController
@RequiredArgsConstructor
@RequestMapping("/rest/oss")
@Tag(name = "aliyun-oss前端控制器", description = "阿里云OSS相关操作")
public class OssController {
private final AliyunOssHandler aliyunOssHandler;
@GetMapping("/getToken")
@Operation(summary = "获取token信息", description = "获取oss临时凭证")
@ApiResponse(responseCode = "200", description = "获取OSS临时凭证")
public BaseResp<AliyunToken> getToken() {
return BaseResp.success(aliyunOssHandler.getToken());
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!