xuhy
2023-08-11 1172de622b5e615677918d4fa0f02a9b2766171c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
package com.stylefeng.guns.modular.crossCity.controller;
 
 
import com.stylefeng.guns.modular.crossCity.server.IOrderCrossCityService;
import com.stylefeng.guns.modular.crossCity.warpper.OrderCrossCityWarpper;
import com.stylefeng.guns.modular.system.service.IUserInfoService;
import com.stylefeng.guns.modular.system.util.ResultUtil;
import com.stylefeng.guns.modular.system.util.SystemException;
import com.stylefeng.guns.modular.system.warpper.BaseWarpper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
 
import javax.servlet.http.HttpServletRequest;
import java.util.Date;
 
@Api
@RestController
@RequestMapping("")
public class OrderCrossCityController {
 
    @Autowired
    private IOrderCrossCityService orderCrossCityService;
 
    @Autowired
    private IUserInfoService userInfoService;
 
 
 
    @ResponseBody
    @RequestMapping(value = "/base/orderCrossCity/queryOrderMoney", method = RequestMethod.POST)
    @ApiOperation(value = "获取跨城的支付金额", tags = {"用户端-跨城"}, notes = "distance:距离数(米),price:支付金额")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "起点坐标(103.32123,30.6232)", name = "startLonLat", required = true, dataType = "string"),
            @ApiImplicitParam(value = "终点坐标(103.32123,30.6232)", name = "endLonLat", required = true, dataType = "string"),
            @ApiImplicitParam(value = "乘车人数", name = "peopleNumber", required = true, dataType = "int"),
            @ApiImplicitParam(value = "出行方式(1=拼车,2=包车)", name = "travelMode", required = true, dataType = "int"),
            @ApiImplicitParam(value = "线路id", name = "lineId", required = true, dataType = "int"),
            @ApiImplicitParam(value = "服务车型id", name = "serverCarModelId", required = true, dataType = "int"),
            @ApiImplicitParam(value = "车辆总座位数", name = "totalSeat", required = true, dataType = "int"),
            @ApiImplicitParam(value = "座位编号(1,3,4)", name = "seatNumber", required = true, dataType = "int")
    })
    public ResultUtil queryOrderMoney(String startLonLat, String endLonLat, Integer peopleNumber, Integer travelMode,
                                      Integer lineId, Integer serverCarModelId, Integer totalSeat, String seatNumber){
        try {
            return orderCrossCityService.queryOrderMoney(startLonLat, endLonLat, peopleNumber, travelMode, lineId, serverCarModelId, totalSeat, seatNumber);
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
 
 
    /**
     * 跨城出行下单操作
     * @param orderCrossCityWarpper
     * @param request
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/api/orderCrossCity/orderCrossCity", method = RequestMethod.POST)
    @ApiOperation(value = "跨城出行下单操作", tags = {"用户端-跨城"}, notes = "先进行下单操作,再根据返回的订单id进行支付")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
    })
    public ResultUtil<BaseWarpper> orderCrossCity(OrderCrossCityWarpper orderCrossCityWarpper, HttpServletRequest request){
        try {
            Integer uid = userInfoService.getUserIdFormRedis(request);
            if(null == uid){
                return ResultUtil.tokenErr();
            }
            return orderCrossCityService.orderCrossCity(orderCrossCityWarpper, uid);
        } catch (SystemException se){
          return ResultUtil.error(se.getMessage());
        } catch (Exception e){
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
 
 
    /**
     * 摆渡车下单
     * @param serverCarModelIds
     * @param travelTime
     * @param placementLon
     * @param placementLat
     * @param startLon
     * @param startLat
     * @param startAddress
     * @param endLon
     * @param endLat
     * @param endAddress
     * @param orderSource
     * @param request
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/api/orderCrossCity/saveOrderFerry", method = RequestMethod.POST)
    @ApiOperation(value = "摆渡车下单", tags = {"用户端-跨城"}, notes = "车型id多个以逗号分隔,出租车传0")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "服务车型id(多个以逗号分隔,出租车传0)", name = "serverCarModelIds", required = false, dataType = "string"),
            @ApiImplicitParam(value = "出行时间(2020-08-20 10:10)", name = "travelTime", required = true, dataType = "string"),
            @ApiImplicitParam(value = "下单地点经度", name = "placementLon", required = true, dataType = "string"),
            @ApiImplicitParam(value = "下单地点纬度", name = "placementLat", required = true, dataType = "string"),
            @ApiImplicitParam(value = "起点经度", name = "startLon", required = true, dataType = "string"),
            @ApiImplicitParam(value = "起点纬度", name = "startLat", required = true, dataType = "string"),
            @ApiImplicitParam(value = "起点地址", name = "startAddress", required = true, dataType = "string"),
            @ApiImplicitParam(value = "终点经度", name = "endLon", required = true, dataType = "string"),
            @ApiImplicitParam(value = "终点纬度", name = "endLat", required = true, dataType = "string"),
            @ApiImplicitParam(value = "终点地址", name = "endAddress", required = true, dataType = "string"),
            @ApiImplicitParam(value = "跨城订单id", name = "crossCityOrderId", required = true, dataType = "int"),
            @ApiImplicitParam(value = "摆渡方位(1=跨城起点,2=跨城终点)", name = "place", required = true, dataType = "int"),
            @ApiImplicitParam(value = "订单来源(1:APP下单,2:扫码下单,3:小程序下单,4:司机下单,5:调度下单)", name = "orderSource", required = true, dataType = "int"),
            @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
    })
    public ResultUtil<BaseWarpper> saveOrderFerry(String serverCarModelIds, Date travelTime, String placementLon, String placementLat, String startLon,
                                                  String startLat, String startAddress, String endLon, String endLat, String endAddress, Integer crossCityOrderId, Integer place, Integer orderSource, HttpServletRequest request){
        try {
            Integer uid = userInfoService.getUserIdFormRedis(request);
            if(null == uid){
                return ResultUtil.tokenErr();
            }
            return orderCrossCityService.saveOrderFerry(serverCarModelIds, travelTime, placementLon, placementLat, startLon, startLat, startAddress, endLon, endLat, endAddress, crossCityOrderId, place, orderSource, uid);
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
 
 
}