同步代码
This commit is contained in:
parent
3748fe0e6e
commit
824bcc98cf
|
@ -19,6 +19,8 @@ import org.springframework.web.bind.annotation.RequestBody;
|
|||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static com.chint.infrastructure.constant.CommonMessageConstant.SUCCESS;
|
||||
|
||||
@Slf4j
|
||||
|
@ -86,4 +88,10 @@ public class OrderOutController {
|
|||
return Result.Success(SUCCESS, tripCallback);
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation("分页查询行程规划订单")
|
||||
@PostMapping("/query/not/submit")
|
||||
public Result<List<RouteOrderPageRes>> queryNotSubmit(@RequestBody OrderQueryData queryData) {
|
||||
return Result.Success(SUCCESS, orderQuery.queryNotSubmit(queryData));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@ import java.util.stream.Stream;
|
|||
|
||||
import static com.chint.infrastructure.constant.OrderConstant.ORDER_EVENT_CANCEL_NAME;
|
||||
import static com.chint.infrastructure.constant.OrderConstant.ORDER_EVENT_PREPARE_NAME;
|
||||
import static com.chint.infrastructure.constant.RouteConstant.ORDER_STATUS_APPROVAL;
|
||||
import static com.chint.infrastructure.constant.SupplierNameConstant.SUPPLIER_C_TRIP;
|
||||
|
||||
@Service
|
||||
|
@ -60,6 +61,7 @@ public class OrderQuery {
|
|||
@Autowired
|
||||
private EstimateAdapter estimateAdapter;
|
||||
|
||||
|
||||
public RouteOrder queryByOrderId(OrderQueryData queryData) {
|
||||
return routeRepository.queryById(queryData.getRouteId()).reloadStatus();
|
||||
}
|
||||
|
@ -299,7 +301,7 @@ public class OrderQuery {
|
|||
};
|
||||
}
|
||||
|
||||
public RouteOrderRes queryRouteRes(RouteOrder routeOrder){
|
||||
public RouteOrderRes queryRouteRes(RouteOrder routeOrder) {
|
||||
RouteOrderRes routeOrderRes = RouteOrderRes.copyFrom(routeOrder);
|
||||
List<Leg> legItems = routeOrder.getLegItems();
|
||||
orderDomainService.queryLocation(legItems);
|
||||
|
@ -320,4 +322,11 @@ public class OrderQuery {
|
|||
.toList());
|
||||
return routeOrderRes;
|
||||
}
|
||||
|
||||
public List<RouteOrderPageRes> queryNotSubmit(OrderQueryData queryData) {
|
||||
List<RouteOrder> byActualOrderNoNotNull = routeRepository.findByActualOrderNoNotNull(queryData);
|
||||
return byActualOrderNoNotNull.stream().filter(order -> order.reloadStatus().getOrderStatus().equals(ORDER_STATUS_APPROVAL))
|
||||
.map(OrderQuery::getRouteOrderPageRes)
|
||||
.toList();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,25 +9,25 @@ import com.chint.domain.exceptions.NotFoundException;
|
|||
import com.chint.domain.exceptions.OrderException;
|
||||
import com.chint.domain.factoriy.leg.LegFactory;
|
||||
import com.chint.domain.factoriy.order.OrderFactory;
|
||||
import com.chint.domain.repository.LegRepository;
|
||||
import com.chint.domain.repository.RouteRepository;
|
||||
import com.chint.domain.service.OrderDomainService;
|
||||
import com.chint.domain.value_object.*;
|
||||
import com.chint.infrastructure.constant.CommonMessageConstant;
|
||||
import com.chint.infrastructure.constant.DataMessageConstant;
|
||||
import com.chint.infrastructure.constant.LegConstant;
|
||||
import com.chint.infrastructure.constant.RouteConstant;
|
||||
import com.chint.infrastructure.echo_framework.command.Command;
|
||||
import com.chint.interfaces.rest.ctrip.CTripOrderSearchRequest;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import static com.chint.infrastructure.constant.CommonMessageConstant.ORDER_STATUS_ERROR;
|
||||
import static com.chint.infrastructure.constant.LegConstant.LEG_STATUS_PREPARE;
|
||||
import static com.chint.infrastructure.constant.RouteConstant.ORDER_STATUS_PREPARE;
|
||||
|
||||
@Service
|
||||
|
@ -45,6 +45,8 @@ public class OrderApplicationService {
|
|||
@Autowired
|
||||
private LegFactory legFactory;
|
||||
|
||||
@Autowired
|
||||
private LegRepository legRepository;
|
||||
|
||||
|
||||
@Transactional
|
||||
|
@ -156,5 +158,13 @@ public class OrderApplicationService {
|
|||
|
||||
@Transactional
|
||||
public void changeLeg(AddLegData addLegData) {
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd hh:mm:ss");
|
||||
LegData legData = addLegData.getLegData();
|
||||
Leg byLegId = legRepository.findByLegId(legData.getLegId());
|
||||
byLegId.setStartTime(LocalDateTime.parse(legData.getStartTime(), formatter));
|
||||
byLegId.setEndTime(LocalDateTime.parse(legData.getEndTime(), formatter));
|
||||
byLegId.setOriginId(legData.getOriginId());
|
||||
byLegId.setDestinationId(legData.getDestinationId());
|
||||
legRepository.save(byLegId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,8 @@ import org.springframework.data.annotation.Id;
|
|||
import org.springframework.data.annotation.Transient;
|
||||
import org.springframework.data.relational.core.mapping.Table;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Table("leg_extension_field")
|
||||
public class LegExtensionField {
|
||||
|
@ -13,6 +15,9 @@ public class LegExtensionField {
|
|||
private Long id;
|
||||
private Long legId;
|
||||
private Integer amountType;
|
||||
private String locationIds;
|
||||
@Transient
|
||||
private List<Location> locationList;
|
||||
@Transient
|
||||
private String amountTypeName;
|
||||
@Transient
|
||||
|
|
|
@ -21,7 +21,7 @@ public class LegEventListener {
|
|||
|
||||
// @TransitionTo(command = "LegPrepareCommand", order = 0)
|
||||
public void onLegStatusChange(LegPrepareCommand command) {
|
||||
Leg leg = legRepository.findByLegId(Leg.of(command.getLegId()));
|
||||
Leg leg = legRepository.findByLegId(command.getLegId());
|
||||
LegEvent legEvent = legEventFactory.creatLegEvent(command.getLegEventType());
|
||||
leg.addEvent(legEvent);
|
||||
legRepository.save(leg);
|
||||
|
|
|
@ -14,5 +14,7 @@ public interface LegRepository {
|
|||
|
||||
void saveAll(List<Leg> legs);
|
||||
|
||||
Leg findByLegId(Leg leg);
|
||||
Leg findByLegId(Long legId);
|
||||
|
||||
|
||||
}
|
|
@ -62,7 +62,7 @@ public class LegEventHandler implements LegEventService {
|
|||
@Transactional
|
||||
@Override
|
||||
public void prepareLeg(LegPrepareCommand command) {
|
||||
Leg leg = legRepository.findByLegId(Leg.of(command.getLegId()));
|
||||
Leg leg = legRepository.findByLegId(command.getLegId());
|
||||
if (leg.getEventList().isEmpty()) {
|
||||
LegEvent legEvent = legEventFactory.creatLegEvent(command.getLegEventType());
|
||||
leg.addEvent(legEvent);
|
||||
|
@ -174,7 +174,7 @@ public class LegEventHandler implements LegEventService {
|
|||
@Override
|
||||
public ResultContainer orderLeg(LegOrderedCommand command) {
|
||||
//如果筛选事件可能会是错误,需要用户手动添加并修改事件 , 因此会进行额外出发修改下单事件。
|
||||
Leg leg = legRepository.findByLegId(Leg.of(command.getLegId()));
|
||||
Leg leg = legRepository.findByLegId(command.getLegId());
|
||||
//因为orderDetail已经进行持久化保存 ,只需要从数据库进行查询
|
||||
OrderDetail orderDetail = orderDetailRepository.findById(command.getOrderDetailId());
|
||||
LegEvent legEvent = legEventFactory
|
||||
|
@ -190,7 +190,7 @@ public class LegEventHandler implements LegEventService {
|
|||
@Override
|
||||
public void payForLeg(LegPayedCommand command) {
|
||||
// PayLegData data = command.getData();
|
||||
Leg leg = legRepository.findByLegId(Leg.of(command.getLegId()));
|
||||
Leg leg = legRepository.findByLegId(command.getLegId());
|
||||
LegEvent legEvent = legEventFactory.creatLegEvent(command.getLegEventType());
|
||||
leg.addEvent(legEvent);
|
||||
legRepository.save(leg);
|
||||
|
@ -199,7 +199,7 @@ public class LegEventHandler implements LegEventService {
|
|||
@Transactional
|
||||
@Override
|
||||
public void finishLeg(LegFinishedCommand command) {
|
||||
Leg leg = legRepository.findByLegId(Leg.of(command.getLegId()));
|
||||
Leg leg = legRepository.findByLegId(command.getLegId());
|
||||
LegEvent legEvent = legEventFactory.creatLegEvent(command.getLegEventType());
|
||||
leg.addEvent(legEvent);
|
||||
legRepository.save(leg);
|
||||
|
|
|
@ -39,7 +39,7 @@ public class LegRepositoryImpl implements LegRepository {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Leg findByLegId(Leg leg) {
|
||||
return legRepository.findById(leg.getLegId()).orElseThrow(()->new NotFoundException(NOT_FOUND));
|
||||
public Leg findByLegId(Long legId) {
|
||||
return legRepository.findById(legId).orElseThrow(()->new NotFoundException(NOT_FOUND));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue