6.5
luodangjia
2024-06-05 06c5eda038f967dc0c0261e16eff0ad1a18e41e7
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
package com.stylefeng.guns.modular.transfer.controller;
 
 
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.stylefeng.guns.modular.specialTrain.server.IOrderPrivateCarService;
import com.stylefeng.guns.modular.system.dao.TOpenCitySiteMapper;
import com.stylefeng.guns.modular.system.model.OpenCity;
import com.stylefeng.guns.modular.system.model.TOpenCitySite;
import com.stylefeng.guns.modular.system.service.IOpenCityService;
import com.stylefeng.guns.modular.system.service.IOrderService;
import com.stylefeng.guns.modular.system.service.IUserInfoService;
import com.stylefeng.guns.modular.system.util.AmapGeocoding;
import com.stylefeng.guns.modular.system.util.ResultUtil;
import com.stylefeng.guns.modular.system.warpper.BaseWarpper;
import com.stylefeng.guns.modular.transfer.model.SiteDto;
import com.stylefeng.guns.modular.transfer.server.IOrderTransferService;
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.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
 
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
 
@Api
@RestController
@RequestMapping("")
public class OrderTransferController {
 
    @Autowired
    private IOrderTransferService orderPrivateCarService;
 
    @Autowired
    private IUserInfoService userInfoService;
 
 
 
    /**
     * 专车下单
     * @param serverCarModelId
     * @param travelTime
     * @param orderType
     * @param substitute
     * @param placementLon
     * @param placementLat
     * @param startLon
     * @param startLat
     * @param startAddress
     * @param endLon
     * @param endLat
     * @param endAddress
     * @param passengers
     * @param passengersPhone
     * @param orderSource
     * @param driverId
     * @param request
     * @return
     */
    @ResponseBody
    @PostMapping("/api/transfer/saveTransferCar")
    @ApiOperation(value = "接送机下单/扫码下单", tags = {"用户端-接送机"}, notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "订单类型(1=普通订单,2=摆渡订单)", name = "type", required = true, dataType = "int"),
            @ApiImplicitParam(value = "服务车型id(扫码下单不用上传)", name = "serverCarModelId", required = false, dataType = "int"),
            @ApiImplicitParam(value = "出行时间(2020-08-20 10:10)", name = "travelTime", required = true, dataType = "string"),
            @ApiImplicitParam(value = "是否预约(1=否,2=是)", name = "orderType", required = true, dataType = "int"),
            @ApiImplicitParam(value = "是否代下单(0=否,1=是)", name = "substitute", required = true, dataType = "int"),
            @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 = "订单来源(1:APP下单,2:扫码下单,3:小程序下单,4:司机下单,5:调度下单)", name = "orderSource", required = true, dataType = "int"),
            @ApiImplicitParam(value = "司机id(扫码下单必传)", name = "driverId", required = false, dataType = "int"),
            @ApiImplicitParam(value = "乘客姓名(代下单必传)", name = "passengers", required = false, dataType = "string"),
            @ApiImplicitParam(value = "乘客电话(代下单必传)", name = "passengersPhone", required = false, dataType = "string"),
            @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
    })
    public ResultUtil<BaseWarpper> saveOrderPrivateCar(Integer serverCarModelId, Date travelTime, Integer orderType, Integer substitute, String placementLon, String placementLat, String startLon, String startLat,
                                                       String startAddress, String endLon, String endLat, String endAddress, String passengers, String passengersPhone, Integer orderSource, Integer driverId,
                                                       Integer type, HttpServletRequest request){
        try {
            Integer uid = userInfoService.getUserIdFormRedis(request);
            if(null == uid){
                return ResultUtil.tokenErr();
            }
            return orderPrivateCarService.saveOrderPrivateCar(serverCarModelId, travelTime, orderType, substitute, placementLon, placementLat,
                    startLon, startLat, startAddress, endLon, endLat, endAddress, passengers, passengersPhone, orderSource, driverId, type, uid);
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
 
    /**
     * 专车下单
     * @param serverCarModelId
     * @param travelTime
     * @param orderType
     * @param substitute
     * @param placementLon
     * @param placementLat
     * @param startLon
     * @param startLat
     * @param startAddress
     * @param endLon
     * @param endLat
     * @param endAddress
     * @param passengers
     * @param passengersPhone
     * @param orderSource
     * @param driverId
     * @param request
     * @return
     */
    @ResponseBody
    @PostMapping("/api/transferCar/saveTransferCars")
    @ApiOperation(value = "接送机下单/扫码下单[2024.05.11]", tags = {"用户端-接送机"}, notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "订单类型(1=普通订单,2=摆渡订单)", name = "type", required = true, dataType = "int"),
            @ApiImplicitParam(value = "服务车型id(扫码下单不用上传)", name = "serverCarModelId", required = false, dataType = "int"),
            @ApiImplicitParam(value = "出行时间(2020-08-20 10:10)", name = "travelTime", required = true, dataType = "string"),
            @ApiImplicitParam(value = "是否预约(1=否,2=是)", name = "orderType", required = true, dataType = "int"),
            @ApiImplicitParam(value = "是否代下单(0=否,1=是)", name = "substitute", required = true, dataType = "int"),
            @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 = false, dataType = "string"),
            @ApiImplicitParam(value = "终点纬度", name = "endLat", required = false, dataType = "string"),
            @ApiImplicitParam(value = "终点地址", name = "endAddress", required = false, dataType = "string"),
            @ApiImplicitParam(value = "订单来源(1:APP下单,2:扫码下单,3:小程序下单,4:司机下单,5:调度下单)", name = "orderSource", required = true, dataType = "int"),
            @ApiImplicitParam(value = "司机id(扫码下单必传)", name = "driverId", required = false, dataType = "int"),
            @ApiImplicitParam(value = "乘客姓名(代下单必传)", name = "passengers", required = false, dataType = "string"),
            @ApiImplicitParam(value = "乘客电话(代下单必传)", name = "passengersPhone", required = false, dataType = "string"),
            @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
    })
    public ResultUtil<BaseWarpper> saveOrderPrivateCars(Integer serverCarModelId, Date travelTime, Integer orderType, Integer substitute, String placementLon, String placementLat, String startLon, String startLat,
                                                       String startAddress, String endLon, String endLat, String endAddress, String passengers, String passengersPhone, Integer orderSource, Integer driverId,
                                                       Integer type, HttpServletRequest request){
        try {
            Integer uid = userInfoService.getUserIdFormRedis(request);
            if(null == uid){
                return ResultUtil.tokenErr();
            }
            return orderPrivateCarService.saveOrderPrivateCars(serverCarModelId, travelTime, orderType, substitute, placementLon, placementLat,
                    startLon, startLat, startAddress, endLon, endLat, endAddress, passengers, passengersPhone, orderSource, driverId, type, uid);
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
 
    @Autowired
    private IOpenCityService openCityService;
    @Autowired
    private TOpenCitySiteMapper openCitySiteMapper;
    @ResponseBody
    @PostMapping("/api/get/site")
    @ApiOperation(value = "获取站点", tags = {"用户端-接送机"}, notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
    })
    public ResultUtil site(double latitude, double longitude) throws Exception {
        //获取当前城市名称
        String cityName = AmapGeocoding.getCityName(latitude, longitude);
        //查询ids
        List<OpenCity> cityName1 = openCityService.selectList(new EntityWrapper<OpenCity>().eq("cityName", cityName).ne("flag",3));
        List<Integer> ids = new ArrayList<>();
        for (OpenCity openCity : cityName1) {
            ids.add(openCity.getId());
        }
        if (ids.isEmpty()){
            return ResultUtil.error("当前城市暂无开通站点");
        }
 
        List<TOpenCitySite> tOpenCitySites = openCitySiteMapper.selectList(new EntityWrapper<TOpenCitySite>().in("openCityId",ids).ne("flag",3));
        List<TOpenCitySite> jichang = new ArrayList<>();
        List<TOpenCitySite> dongche = new ArrayList<>();
 
        for (TOpenCitySite tOpenCitySite : tOpenCitySites) {
            if (tOpenCitySite.getType()==1){
                jichang.add(tOpenCitySite);
            }
            if (tOpenCitySite.getType()==2){
                dongche.add(tOpenCitySite);
            }
        }
 
        SiteDto siteDto = new SiteDto();
        siteDto.setDongche(dongche);
        siteDto.setJichang(jichang);
        return ResultUtil.success(siteDto);
    }
 
}