| | |
| | | package com.stylefeng.guns.modular.api; |
| | | |
| | | import com.google.api.Http; |
| | | import com.stylefeng.guns.modular.system.model.Company; |
| | | import com.stylefeng.guns.modular.system.model.Driver; |
| | | import com.stylefeng.guns.modular.system.service.IDriverService; |
| | | import com.stylefeng.guns.modular.system.service.IOrderEvaluateService; |
| | | import com.stylefeng.guns.modular.system.model.UserInfo; |
| | | import com.stylefeng.guns.modular.system.service.*; |
| | | import com.stylefeng.guns.modular.system.util.ResultUtil; |
| | | import com.stylefeng.guns.modular.system.warpper.BaseWarpper; |
| | | import com.stylefeng.guns.modular.system.warpper.DriverInfoWarpper; |
| | |
| | | import org.springframework.web.bind.annotation.ResponseBody; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | |
| | | |
| | | @Autowired |
| | | private IOrderEvaluateService orderEvaluateService; |
| | | |
| | | @Resource |
| | | private IUserInfoService userInfoService; |
| | | |
| | | @Autowired |
| | | private ICompanyCityService companyCityService; |
| | | |
| | | |
| | | |
| | |
| | | @ApiImplicitParam(value = "乘客当前定位经度", name = "lon", required = true, dataType = "double"), |
| | | @ApiImplicitParam(value = "乘客当前定位纬度", name = "lat", required = true, dataType = "double") |
| | | }) |
| | | public ResultUtil<BaseWarpper> queryIdleDriver(Integer type, Double lon, Double lat){ |
| | | public ResultUtil<BaseWarpper> queryIdleDriver(Integer type, Double lon, Double lat, HttpServletRequest request){ |
| | | try { |
| | | Integer uid = userInfoService.getUserIdFormRedis(request); |
| | | if(null != uid){ |
| | | UserInfo userInfo = userInfoService.selectById(uid); |
| | | Company company = companyCityService.query1(uid, lon.toString(), lat.toString()); |
| | | if(null != userInfo && null != company){ |
| | | System.err.println("-----更新用户所属公司-----"); |
| | | userInfo.setCompanyId(company.getId()); |
| | | userInfoService.updateById(userInfo); |
| | | } |
| | | } |
| | | List<Driver> list = driverService.queryIdleDriver(type, lon, lat, 5D, null); |
| | | BaseWarpper baseWarpper = new BaseWarpper(); |
| | | baseWarpper.setNumber(list.size()); |
| | |
| | | |
| | | |
| | | /** |
| | | * 获取正在进行中的订单 |
| | | * 获取正在sudo rm -rf的订单 |
| | | * @param request |
| | | * @return |
| | | */ |
| | |
| | | if(ToolUtil.isEmpty(userInfo.getPhone())){ |
| | | return ResultUtil.error(language == 1 ? "请先绑定手机号码" : language == 2 ? "Please bind your mobile phone number first." : "Veuillez d’abord vous inscrire en liant votre numéro de téléphone portable."); |
| | | } |
| | | String[] split1 = placementLon.split(","); |
| | | Company company = companyCityService.query1(uid, split1[0], split1[1]); |
| | | Company company = companyCityService.query1(uid, placementLon, placementLat); |
| | | if(null != userInfo && null != company){ |
| | | userInfo.setCompanyId(company.getId()); |
| | | userInfoService.updateById(userInfo); |
| | |
| | | if(orderLogistics.getState() > 5 && orderLogistics.getState() != 11 && orderLogistics.getState() != 12){ |
| | | return ResultUtil.error(language == 1 ? "取消订单失败,不合法的操作" : language == 2 ? "Failed to cancel order, illegal operation." : "Échec de l’annulation de la commande, opération illégale."); |
| | | } |
| | | |
| | | orderCancelService.delete(new EntityWrapper<OrderCancel>().eq("orderId", orderLogistics.getId()).eq("orderType", 4)); |
| | | if(null == orderLogistics.getDriverId()){//没有接单的情况 |
| | | integer = orderCancelService.saveData(id, 4, language == 1 ? "无司机接单" : language == 2 ? "No driver to take orders" : "Pas de chauffeur pour prendre les commandes", language == 1 ? "无司机接单" : language == 2 ? "No driver to take orders" : "Pas de chauffeur pour prendre les commandes", null, null, 2, 1, uid); |
| | | integer = orderCancelService.saveData(id, 4, language == 1 ? "无司机接单" : language == 2 ? "No driver to take orders" : "Pas de chauffeur pour prendre les commandes", language == 1 ? "无司机接单" : language == 2 ? "No driver to take orders" : "Pas de chauffeur pour prendre les commandes", null, 0D, 2, 1, uid); |
| | | orderLogistics.setState(10); |
| | | this.updateById(orderLogistics); |
| | | }else { |
| | | BaseWarpper data = queryCancleAmount(id, language).getData(); |
| | | Double amount = data.getAmount(); |
| | | if(0 == amount){ |
| | | integer = orderCancelService.saveData(id, 4, reason, remark, null, null, 2, 1, uid); |
| | | integer = orderCancelService.saveData(id, 4, reason, remark, null, 0D, 2, 1, uid); |
| | | if(5 == orderLogistics.getState()){ |
| | | orderLogistics.setState(6); |
| | | orderLogistics.setGetoffLon(lon); |
| | |
| | | @TableField("estimatedMileage") |
| | | private Double estimatedMileage; |
| | | /** |
| | | * 司机预估到达预约单时间 |
| | | * 司机预估到达预约点时间 |
| | | */ |
| | | @TableField("estimateArriveTime") |
| | | private Date estimateArriveTime; |
| | |
| | | if(ToolUtil.isEmpty(userInfo.getPhone())){ |
| | | return ResultUtil.error(language == 1 ? "请先绑定手机号码" : language == 2 ? "Please bind your mobile phone number first." : "Veuillez d’abord vous inscrire en liant votre numéro de téléphone portable."); |
| | | } |
| | | String[] split1 = placementLon.split(","); |
| | | Company company = companyCityService.query1(uid, split1[0], split1[1]); |
| | | Company company = companyCityService.query1(uid, placementLon, placementLat); |
| | | if(null != userInfo && null != company){ |
| | | userInfo.setCompanyId(company.getId()); |
| | | userInfoService.updateById(userInfo); |
| | |
| | | orderPrivateCar.setServerCarModelId(query1.getServerCarModelId()); |
| | | orderPrivateCar.setSnatchOrderTime(new Date()); |
| | | |
| | | String value = redisUtil.getValue("DRIVER" + driver.getId()); |
| | | if(ToolUtil.isNotEmpty(value)) { |
| | | String[] split = value.split(","); |
| | | DistancematrixVo distancematrix = GoogleMapUtil.getDistancematrix(orderPrivateCar.getStartLat(), orderPrivateCar.getStartLon(), Double.valueOf(split[1]), Double.valueOf(split[0]), tripId); |
| | | //超时时间 |
| | | long timeOut = System.currentTimeMillis() + (distancematrix.getDuration() * 1000); |
| | | orderPrivateCar.setEstimateArriveTime(new Date(timeOut)); |
| | | orderPrivateCar.setEstimateArriveMileage(distancematrix.getDistance()); |
| | | } |
| | | |
| | | dr.setState(3); |
| | | driverService.updateById(dr); |
| | | this.updateById(orderPrivateCar); |
| | |
| | | long t = object.getInteger("driverTimeout") * 60000L; |
| | | //司机超时未到达起点,免费取消 |
| | | if(orderPrivateCar.getOrderType() == 1){ |
| | | if(orderPrivateCar.getState() == 1 || orderPrivateCar.getState() == 11){ |
| | | baseWarpper.setAmount(0D); |
| | | return ResultUtil.success(baseWarpper); |
| | | } |
| | | if(orderPrivateCar.getState() <= 3 && orderPrivateCar.getEstimateArriveTime().getTime() + t <= System.currentTimeMillis()){ |
| | | baseWarpper.setAmount(amount); |
| | | return ResultUtil.success(baseWarpper); |
| | |
| | | return ResultUtil.error(language == 1 ? "取消订单失败,不合法的操作" : language == 2 ? "Failed to cancel order, illegal operation." : "Échec de l’annulation de la commande, opération illégale."); |
| | | } |
| | | |
| | | orderCancelService.delete(new EntityWrapper<OrderCancel>().eq("orderId", orderPrivateCar.getId()).eq("orderType", 1)); |
| | | |
| | | //服务中也可以取消订单,所以取消订单时需要计算订单费用 |
| | | if(null == orderPrivateCar.getDriverId()){//没有接单的情况 |
| | | if(orderPrivateCar.getType() == 2){//摆渡车 |
| | |
| | | orderTaxiService.updateById(orderTaxi); |
| | | } |
| | | }else{ |
| | | integer = orderCancelService.saveData(id, 1, language == 1 ? "无司机接单" : language == 2 ? "No driver to take orders" : "Pas de chauffeur pour prendre les commandes", language == 1 ? "无司机接单" : language == 2 ? "No driver to take orders" : "Pas de chauffeur pour prendre les commandes", null, null, 2, 1, uid); |
| | | integer = orderCancelService.saveData(id, 1, language == 1 ? "无司机接单" : language == 2 ? "No driver to take orders" : "Pas de chauffeur pour prendre les commandes", language == 1 ? "无司机接单" : language == 2 ? "No driver to take orders" : "Pas de chauffeur pour prendre les commandes", null, 0D, 2, 1, uid); |
| | | orderPrivateCar.setState(10); |
| | | this.updateById(orderPrivateCar); |
| | | } |
| | |
| | | BaseWarpper data = queryCancleAmount(id, language).getData(); |
| | | Double amount = data.getAmount(); |
| | | if(0 == amount){ |
| | | integer = orderCancelService.saveData(id, 1, reason, remark, null, null, 2, 1, uid); |
| | | integer = orderCancelService.saveData(id, 1, reason, remark, null, 0D, 2, 1, uid); |
| | | if(5 == orderPrivateCar.getState()){ |
| | | orderPrivateCar.setState(6); |
| | | orderPrivateCar.setGetoffLon(lon); |
| | |
| | | //计算折扣 |
| | | UserActivityDiscount1 query2 = userActivityDiscount1Mapper.query(orderPrivateCar.getCompanyId()); |
| | | if(null != query2){ |
| | | Integer orderNum=this.selectCount(new EntityWrapper<OrderPrivateCar>().eq("userId",orderPrivateCar.getUserId()).eq("activityId",query2.getId()).last(" and to_days(getoffTime) = to_days(now())")); |
| | | Integer orderNum=this.selectCount(new EntityWrapper<OrderPrivateCar>().eq("userId",orderPrivateCar.getUserId()) |
| | | .eq("activityId",query2.getId()).last(" and to_days(getoffTime) = to_days(now())")); |
| | | if(query2.getDistance()*1000>orderPrivateCar.getMileage() && query2.getOrderNum()>orderNum){ |
| | | Double special = query2.getSpecial(); |
| | | if(null != special){ |
| | |
| | | Integer driverTimeOutTime = 0; |
| | | Integer driverTimeOut = 0; |
| | | CancleOrder cancleOrder = cancleOrderService.selectOne(new EntityWrapper<CancleOrder>().eq("companyId", companyId)); |
| | | if(null != cancleOrder){ |
| | | JSONObject jsonObject = JSON.parseObject(cancleOrder.getContent()); |
| | | int driverTimeout1 = jsonObject.getIntValue("driverTimeout"); |
| | | if(orderPrivateCar.getOrderType() == 1 && null != orderPrivateCar.getEstimateArriveTime()){ |
| | |
| | | driverTimeOut = 1; |
| | | } |
| | | } |
| | | } |
| | | |
| | | map.put("driverTimeOutTime", driverTimeOutTime); |
| | | map.put("driverTimeOut", driverTimeOut); |
| | |
| | | return updateTrip(tripStatus, vehicleId, numberOfPassengers, tripId, start_lat, start_lng, end_lat, end_lng); |
| | | } |
| | | } |
| | | if(code == 404){ |
| | | return true; |
| | | } |
| | | logger.error("修改行程异常: tripId={} body={}", tripId, response.body()); |
| | | return false; |
| | | } |