同步租电子订单

This commit is contained in:
2025-09-07 19:46:26 +08:00
parent f1fe0e8b02
commit bfa07660cb
3 changed files with 62 additions and 0 deletions

View File

@ -22,6 +22,7 @@ import com.sczx.order.thirdpart.dto.req.CarQueryConditionReq;
import com.sczx.order.thirdpart.integration.CarInteg;
import com.sczx.order.thirdpart.integration.PayInteg;
import com.sczx.order.thirdpart.integration.StoreInteg;
import com.sczx.order.thirdpart.integration.SyncInteg;
import com.sczx.order.utils.JwtUtil;
import com.sczx.order.utils.OrderUtil;
import com.sczx.order.utils.RedisUtil;
@ -78,6 +79,9 @@ public class OrderServiceImpl implements OrderService {
@Autowired
private PayService payService;
@Autowired
private SyncInteg syncInteg;
@Override
public OrderMainPO queryOrderMainPoByOrderNo(String orderNo, String delFlag) {
LambdaQueryWrapper<OrderMainPO> currentOrderWrapper = new LambdaQueryWrapper<>();
@ -822,6 +826,16 @@ public class OrderServiceImpl implements OrderService {
.set(CarPO::getBrsStatus, CarStatusEnum.RENT_ING.getCode());
carRepo.update(carPOLambdaUpdateWrapper);
//同步租电订单
LambdaQueryWrapper<OrderSubPO> querySubBatteryWrapper = new LambdaQueryWrapper<>();
querySubBatteryWrapper.eq(OrderSubPO::getOrderId, orderMainPO.getOrderId())
.eq(OrderSubPO::getSuborderType, SubOrderTypeEnum.RENTBATTEY.getCode())
.orderByDesc(OrderSubPO::getCreatedAt)
.last(" limit 1");
OrderSubPO renBatteryOrderSubPO = orderSubRepo.getOne(queryWrapper);
Long batterySubOrderId = renBatteryOrderSubPO.getSuborderId();
syncInteg.sendSubOrderId(batterySubOrderId);
return getOrderInfoByOrderNo(bindCarToOrderReq.getOrderNo());
} catch (Exception e){
log.warn("绑定车辆失败",e);

View File

@ -0,0 +1,15 @@
package com.sczx.order.thirdpart.facade;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
@FeignClient(name = "sczx-sync", url = "${sczx-sync.ribbon.listOfServers:}")
public interface SyncFacade {
@GetMapping("/send/subOrder")
Map<String, String> sendSubOrderId(Long subOrderId);
}

View File

@ -0,0 +1,33 @@
package com.sczx.order.thirdpart.integration;
import com.sczx.order.exception.InnerException;
import com.sczx.order.thirdpart.facade.SyncFacade;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Map;
@Slf4j
@Component
public class SyncInteg {
@Autowired
private SyncFacade syncFacade;
public Map<String, String> sendSubOrderId(Long subOrderId){
try{
Map<String, String> result = syncFacade.sendSubOrderId(subOrderId);
if(result.get("code") == "200"){
return result;
}
} catch (Exception e){
log.error("发送租电订单同步失败",e);
throw new InnerException("发送租电订单同步失败");
}
return null;
}
}