|
@@ -7,9 +7,13 @@ import com.github.pagehelper.Page;
|
|
|
import com.jpsoft.bus.config.OSSConfig;
|
|
|
import com.jpsoft.bus.modules.base.dto.PassengerOrderDTO;
|
|
|
import com.jpsoft.bus.modules.base.entity.OrderInfo;
|
|
|
+import com.jpsoft.bus.modules.base.entity.PaymentInfo;
|
|
|
import com.jpsoft.bus.modules.base.service.OrderInfoService;
|
|
|
+import com.jpsoft.bus.modules.base.service.PaymentInfoService;
|
|
|
+import com.jpsoft.bus.modules.bus.dto.DriverBuyTicketDTO;
|
|
|
import com.jpsoft.bus.modules.bus.dto.PassengerDetailDTO;
|
|
|
import com.jpsoft.bus.modules.bus.dto.StationStatusDTO;
|
|
|
+import com.jpsoft.bus.modules.bus.dto.VehicleStationDTO;
|
|
|
import com.jpsoft.bus.modules.bus.entity.*;
|
|
|
import com.jpsoft.bus.modules.bus.service.*;
|
|
|
import com.jpsoft.bus.modules.common.dto.MessageResult;
|
|
@@ -18,10 +22,7 @@ import com.jpsoft.bus.modules.common.utils.CommonUtil;
|
|
|
import com.jpsoft.bus.modules.common.utils.JwtUtil;
|
|
|
import com.jpsoft.bus.modules.common.utils.OSSUtil;
|
|
|
import com.jpsoft.bus.modules.common.utils.PojoUtils;
|
|
|
-import io.swagger.annotations.Api;
|
|
|
-import io.swagger.annotations.ApiImplicitParam;
|
|
|
-import io.swagger.annotations.ApiImplicitParams;
|
|
|
-import io.swagger.annotations.ApiOperation;
|
|
|
+import io.swagger.annotations.*;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.bouncycastle.crypto.signers.ECDSASigner;
|
|
@@ -52,6 +53,9 @@ public class DriverApiController {
|
|
|
@Autowired
|
|
|
private OSSConfig ossConfig;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private PaymentInfoService paymentInfoService;
|
|
|
+
|
|
|
@Autowired
|
|
|
private ShiftInfoService shiftInfoService;
|
|
|
|
|
@@ -636,18 +640,35 @@ public class DriverApiController {
|
|
|
@ApiImplicitParam(name = "ticketDownStationId", value = "乘客买票下车站点id", required = true, paramType = "form"),
|
|
|
@ApiImplicitParam(name = "ticketType", value = "购票类型(1:儿童票,2:成人票)", required = true, paramType = "form"),
|
|
|
@ApiImplicitParam(name = "goodsTicket", value = "货票金额", required = true, paramType = "form"),
|
|
|
+ @ApiImplicitParam(name = "totalFee", value = "总金额", required = true, paramType = "form"),
|
|
|
@ApiImplicitParam(name = "payName", value = "cash:现金,ticket:车票,wechat:微信,alipay:支付宝", required = true, paramType = "form"),
|
|
|
})
|
|
|
- public MessageResult<Map> driverCreateOrder(String id,String token, @RequestAttribute String subject) {
|
|
|
- MessageResult<Map> messageResult = new MessageResult<>();
|
|
|
+ public MessageResult<DriverBuyTicketDTO> driverCreateOrder(String id,String ticketUpStationId,String ticketDownStationId,String ticketType,String goodsTicket,String totalFee,String payName,String token, @RequestAttribute String subject) {
|
|
|
+ MessageResult<DriverBuyTicketDTO> messageResult = new MessageResult<>();
|
|
|
|
|
|
try {
|
|
|
|
|
|
+ VehicleInfo vehicleInfo = vehicleInfoService.get(subject);
|
|
|
+ if (vehicleInfo == null){
|
|
|
+ throw new Exception("当前车辆不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ PaymentInfo paymentInfo = paymentInfoService.findByCompanyId(vehicleInfo.getCompanyId());
|
|
|
+ if (paymentInfo == null){
|
|
|
+ throw new Exception("车辆对应公司为配置收款账户");
|
|
|
+ }
|
|
|
|
|
|
+ List<ShiftInfo> shiftInfoList = shiftInfoService.findByVehicleIdAndStatus(vehicleInfo.getId(),"1");
|
|
|
+ if (shiftInfoList.size() == 0){
|
|
|
+ throw new Exception("车辆没有相关班次信息");
|
|
|
+ }
|
|
|
|
|
|
+ PassengerInfo passengerInfo = passengerInfoService.get(id);
|
|
|
|
|
|
|
|
|
+ DriverBuyTicketDTO driverBuyTicketDTO = passengerInfoService.driverBuyTicket(passengerInfo,ticketUpStationId,ticketDownStationId,ticketType,goodsTicket,totalFee,payName,paymentInfo.getId());
|
|
|
|
|
|
+ messageResult.setData(driverBuyTicketDTO);
|
|
|
messageResult.setResult(true);
|
|
|
messageResult.setCode(200);
|
|
|
} catch (Exception ex) {
|
|
@@ -676,7 +697,10 @@ public class DriverApiController {
|
|
|
|
|
|
PriceInfo priceInfo = priceInfoService.findByStartStationAndEndStation(ticketUpStationId,ticketDownStationId);
|
|
|
if (priceInfo == null){
|
|
|
- throw new Exception("站点间没有价格标准");
|
|
|
+ PriceInfo priceInfo1 = priceInfoService.findByStartStationAndEndStation(ticketDownStationId,ticketUpStationId);
|
|
|
+ if (priceInfo1 == null){
|
|
|
+ throw new Exception("站点间无费用设置");
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
BigDecimal price = priceInfo.getPrice();
|
|
@@ -699,6 +723,141 @@ public class DriverApiController {
|
|
|
return messageResult;
|
|
|
}
|
|
|
|
|
|
+ @PostMapping("getPayType")
|
|
|
+ @ApiOperation(value = "获取可用支付方式")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "token", value = "令牌", paramType = "form"),
|
|
|
+ @ApiImplicitParam(name = "subject", value = "目标(不传)", paramType = "form")
|
|
|
+ })
|
|
|
+ public MessageResult<Map> getPayType(String token, @RequestAttribute String subject) {
|
|
|
+ MessageResult<Map> messageResult = new MessageResult<>();
|
|
|
+
|
|
|
+ try {
|
|
|
+
|
|
|
+ VehicleInfo vehicleInfo = vehicleInfoService.get(subject);
|
|
|
+ if (vehicleInfo == null){
|
|
|
+ throw new Exception("当前车辆不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ List<String> list = new ArrayList<>();
|
|
|
+ list.add("cash");
|
|
|
+ list.add("ticket");
|
|
|
+ PaymentInfo paymentInfo = paymentInfoService.findByCompanyId(vehicleInfo.getCompanyId());
|
|
|
+ if (paymentInfo != null){
|
|
|
+ if (StringUtils.isNotBlank(paymentInfo.getSubMchId())){
|
|
|
+ list.add("wechat");
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(paymentInfo.getAppAuthToken())){
|
|
|
+ list.add("alipay");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String,Object> map = new HashMap<>();
|
|
|
+ map.put("list",list);
|
|
|
+
|
|
|
+
|
|
|
+ messageResult.setData(map);
|
|
|
+ messageResult.setResult(true);
|
|
|
+ messageResult.setCode(200);
|
|
|
+ } catch (Exception ex) {
|
|
|
+ log.error(ex.getMessage(),ex);
|
|
|
+ messageResult.setResult(false);
|
|
|
+ messageResult.setMessage(ex.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ return messageResult;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @PostMapping("busShiftAllStation")
|
|
|
+ @ApiOperation(value = "车辆班次所有站点信息")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "token", value = "令牌", paramType = "form"),
|
|
|
+ @ApiImplicitParam(name = "subject", value = "目标(不传)", paramType = "form")
|
|
|
+ })
|
|
|
+ public MessageResult<List<VehicleStationDTO>> busShiftAllStation(String token, @RequestAttribute String subject) {
|
|
|
+ MessageResult<List<VehicleStationDTO>> messageResult = new MessageResult<>();
|
|
|
+
|
|
|
+ try {
|
|
|
+
|
|
|
+ VehicleInfo vehicleInfo = vehicleInfoService.get(subject);
|
|
|
+ if (vehicleInfo == null){
|
|
|
+ throw new Exception("当前车辆不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ List<ShiftInfo> shiftInfoList = shiftInfoService.findByVehicleIdAndStatus(vehicleInfo.getId(),"1");
|
|
|
+ if (shiftInfoList.size() == 0){
|
|
|
+ throw new Exception("车辆没有相关班次信息");
|
|
|
+ }
|
|
|
+
|
|
|
+ ShiftInfo shiftInfo = shiftInfoList.get(0);
|
|
|
+
|
|
|
+ List<StationInfo> stationInfoList = stationInfoService.findByRouteId(shiftInfo.getRouteId());
|
|
|
+
|
|
|
+ List<VehicleStationDTO> vehicleStationDTOList = new ArrayList<>();
|
|
|
+ if (stationInfoList.size()>0){
|
|
|
+ StationInfo currentStation = stationInfoService.get(shiftInfo.getCurrentStationId());
|
|
|
+
|
|
|
+ int size = stationInfoList.size();
|
|
|
+ Integer index = stationInfoList.indexOf(currentStation);
|
|
|
+ if (shiftInfo.getStartStationId().equals(stationInfoList.get(0).getId())){
|
|
|
+ for (int n = 0;n<size;n++){
|
|
|
+ StationInfo stationInfo = stationInfoList.get(n);
|
|
|
+ VehicleStationDTO vehicleStationDTO = new VehicleStationDTO();
|
|
|
+ vehicleStationDTO.setId(stationInfo.getId());
|
|
|
+ vehicleStationDTO.setStationName(stationInfo.getName());
|
|
|
+ if (n < index){
|
|
|
+ vehicleStationDTO.setStatus("1");
|
|
|
+
|
|
|
+ }
|
|
|
+ if (n == index){
|
|
|
+ vehicleStationDTO.setStatus("2");
|
|
|
+ }
|
|
|
+ if (n > index){
|
|
|
+ vehicleStationDTO.setStatus("3");
|
|
|
+ }
|
|
|
+ vehicleStationDTOList.add(vehicleStationDTO);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (shiftInfo.getEndStationId().equals(stationInfoList.get(0).getId())){
|
|
|
+ for (int n = size-1;n>=0;n--){
|
|
|
+ StationInfo stationInfo = stationInfoList.get(n);
|
|
|
+ VehicleStationDTO vehicleStationDTO = new VehicleStationDTO();
|
|
|
+ vehicleStationDTO.setId(stationInfo.getId());
|
|
|
+ vehicleStationDTO.setStationName(stationInfo.getName());
|
|
|
+ if (n < index){
|
|
|
+ vehicleStationDTO.setStatus("3");
|
|
|
+
|
|
|
+ }
|
|
|
+ if (n == index){
|
|
|
+ vehicleStationDTO.setStatus("2");
|
|
|
+ }
|
|
|
+ if (n > index){
|
|
|
+ vehicleStationDTO.setStatus("1");
|
|
|
+ }
|
|
|
+ vehicleStationDTOList.add(vehicleStationDTO);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ messageResult.setData(vehicleStationDTOList);
|
|
|
+ messageResult.setResult(true);
|
|
|
+ messageResult.setCode(200);
|
|
|
+ } catch (Exception ex) {
|
|
|
+ log.error(ex.getMessage(),ex);
|
|
|
+ messageResult.setResult(false);
|
|
|
+ messageResult.setMessage(ex.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ return messageResult;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
}
|