|
@@ -278,6 +278,12 @@ public class PassengerInfoServiceImpl implements PassengerInfoService {
|
|
|
public void createOrder(VehicleInfo vehicleInfo, ShiftInfo shiftInfo, String openId, String mergeOrderId,String passengerIds, String ticketUpStationId, String ticketDownStationId, String ticketType, String goodsTicket, String totalFee) throws Exception {
|
|
|
|
|
|
|
|
|
+ //乘客id集合
|
|
|
+ List<String> passengerList = Arrays.asList(passengerIds.split(","));
|
|
|
+ if (passengerList.size() == 0) {
|
|
|
+ throw new Exception("乘客不存在");
|
|
|
+ }
|
|
|
+
|
|
|
PriceInfo priceInfo = priceInfoService.findByStartStationAndEndStation(ticketUpStationId, ticketDownStationId);
|
|
|
if (priceInfo == null) {
|
|
|
PriceInfo priceInfo1 = priceInfoService.findByStartStationAndEndStation(ticketDownStationId, ticketUpStationId);
|
|
@@ -291,9 +297,11 @@ public class PassengerInfoServiceImpl implements PassengerInfoService {
|
|
|
price = price.divide(new BigDecimal(2));
|
|
|
}
|
|
|
|
|
|
+ BigDecimal totalTicketPrice =price.multiply(new BigDecimal(passengerList.size()));
|
|
|
+
|
|
|
BigDecimal goodTicketPrice = new BigDecimal(goodsTicket);
|
|
|
|
|
|
- BigDecimal total = price.add(goodTicketPrice);
|
|
|
+ BigDecimal total = totalTicketPrice.add(goodTicketPrice);
|
|
|
if (total.compareTo(new BigDecimal(totalFee)) != 0) {
|
|
|
throw new Exception("票价有误,请重新创建");
|
|
|
}
|
|
@@ -322,11 +330,7 @@ public class PassengerInfoServiceImpl implements PassengerInfoService {
|
|
|
throw new Exception("对应公司收款账户异常,请核验");
|
|
|
}
|
|
|
|
|
|
- //乘客id集合
|
|
|
- List<String> passengerList = Arrays.asList(passengerIds.split(","));
|
|
|
- if (passengerList.size() == 0) {
|
|
|
- throw new Exception("乘客不存在");
|
|
|
- }
|
|
|
+
|
|
|
|
|
|
String mergeId = mergeOrderId;
|
|
|
if (StringUtils.isBlank(mergeOrderId)){
|
|
@@ -346,6 +350,7 @@ public class PassengerInfoServiceImpl implements PassengerInfoService {
|
|
|
|
|
|
String upStationId = passengerInfo0.getUpStationId();
|
|
|
|
|
|
+ Boolean goodTicketStatus = false;
|
|
|
for (String passengerId : passengerList) {
|
|
|
|
|
|
OrderInfo orderInfo0 = orderInfoService.findByPassengerIdMergeOrderId(passengerId,mergeId);
|
|
@@ -370,15 +375,33 @@ public class PassengerInfoServiceImpl implements PassengerInfoService {
|
|
|
orderInfo.setPaymentId(paymentId);
|
|
|
orderInfo.setPassengerId(passengerId);
|
|
|
orderInfo.setTicketType(ticketType);
|
|
|
- orderInfo.setGoodsTicket(new BigDecimal(goodsTicket));
|
|
|
+
|
|
|
+ if (!goodTicketStatus){
|
|
|
+ orderInfo.setGoodsTicket(new BigDecimal(goodsTicket));
|
|
|
+ goodTicketStatus = true;
|
|
|
+ }
|
|
|
+
|
|
|
orderInfo.setMergeOrderId(mergeId);
|
|
|
orderInfo.setTicketUpStationId(ticketUpStationId);
|
|
|
orderInfo.setTicketDownStationId(ticketDownStationId);
|
|
|
orderInfoService.insert(orderInfo);
|
|
|
|
|
|
+ }else {
|
|
|
+ throw new Exception("乘客已下车或已购票");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void updatePassengerOrder(OrderInfo orderInfo, String ticketUpStationId, String ticketDownStationId, String ticketType, String goodsTicket, String totalFee) {
|
|
|
+
|
|
|
+ orderInfo.setTicketUpStationId(ticketUpStationId);
|
|
|
+ orderInfo.setTicketDownStationId(ticketDownStationId);
|
|
|
+ orderInfo.setTotalFee(new BigDecimal(totalFee));
|
|
|
+ orderInfo.setTicketType(ticketType);
|
|
|
+ orderInfo.setGoodsTicket(new BigDecimal(goodsTicket));
|
|
|
+ orderInfoService.update(orderInfo);
|
|
|
+ }
|
|
|
}
|