| | |
| | | import com.stylefeng.guns.modular.system.service.*; |
| | | import com.stylefeng.guns.modular.taxi.model.TransactionDetails; |
| | | import com.stylefeng.guns.modular.taxi.service.ITransactionDetailsService; |
| | | import com.stylefeng.guns.modular.transfer.model.OrderTransferCar; |
| | | import com.stylefeng.guns.modular.transfer.server.IOrderTransferService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | |
| | | @Autowired |
| | | private IOrderEvaluateService orderEvaluateService; |
| | | |
| | | @Autowired |
| | | private IOrderTransferService orderTransferService; |
| | | |
| | | private String path = "http://120.77.11.218:8868/"; |
| | | |
| | | |
| | |
| | | OrderCancel query = null; |
| | | try { |
| | | query = orderCancelService.query(orderId, 1, null, null, 2); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | Map<String, String> geocode = null; |
| | | try { |
| | | geocode = gdMapGeocodingUtil.geocode(orderPrivateCar.getBoardingLon().toString(), |
| | | orderPrivateCar.getBoardingLat().toString()); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | JSONObject jsonObject = new JSONObject(); |
| | | jsonObject.put("Address", Integer.valueOf(geocode.get("districtCode")));//上车地点行政区划代码 |
| | | jsonObject.put("OrderId", orderPrivateCar.getOrderNum());//订单编号 |
| | | jsonObject.put("OrderTime", orderPrivateCar.getOrderNum());//订单时间YYYYMMDDhhmmss |
| | | jsonObject.put("CancelTime", query.getInsertTime());//订单撤销时间YYYYMMDDhhmmss |
| | | jsonObject.put("Operator", "1");//撤销发起方(1:乘客,2:驾驶员,3:平台公司) |
| | | jsonObject.put("CancelTypeCode", driver.getDriveCard());//机动车驾驶证编号 |
| | | jsonObject.put("CancelReason", query.getReason());//撤销或违约原因 |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("orderCancel", jsonObject.toJSONString()); |
| | | |
| | | Map<String, String> header = new HashMap<>(); |
| | | header.put("Connection", "keep-alive"); |
| | | header.put("Content-Type", "application/x-www-form-urlencoded"); |
| | | header.put("Accept", "*/*"); |
| | | header.put("Accept-Encoding", "gzip"); |
| | | header.put("Accept-Charset", "utf-8"); |
| | | String result = httpClientUtil.pushHttpRequset("POST", path + "ministryOfTransport/orderCancel", map, header,"form"); |
| | | System.err.println("----------------------------订单撤销接口------------------:" + result); |
| | | } |
| | | |
| | | public void transOrderCancel(Integer orderId){ |
| | | OrderPrivateCar orderPrivateCar = orderPrivateCarService.selectById(orderId); |
| | | Driver driver = driverService.selectById(orderPrivateCar.getDriverId()); |
| | | OrderCancel query = null; |
| | | try { |
| | | query = orderCancelService.query(orderId, 7, null, null, 2); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | |
| | | |
| | | |
| | | /** |
| | | * 经营支付接口 |
| | | * @param orderId |
| | | */ |
| | | public void operatePayTransfer(Integer orderId){ |
| | | OrderTransferCar orderPrivateCar = orderTransferService.selectById(orderId); |
| | | Driver driver = driverService.selectById(orderPrivateCar.getDriverId()); |
| | | Map<String, Object> query = systemPriceMapper.query(orderPrivateCar.getCompanyId(), 1, orderPrivateCar.getServerCarModelId()); |
| | | Car car = carMapper.selectById(orderPrivateCar.getCarId()); |
| | | ServerCarModel serverCarModel = serverCarModelMapper.selectById(orderPrivateCar.getServerCarModelId()); |
| | | // TransactionDetails transactionDetails = transactionDetailsService.selectById(new EntityWrapper<TransactionDetails>().eq("orderId", orderId).eq("orderType", 1)); |
| | | JSONObject jsonObject = new JSONObject(); |
| | | jsonObject.put("OrderId", orderPrivateCar.getOrderNum());//订单号 |
| | | jsonObject.put("OnArea", 450204);//上车位置行政区划代码 |
| | | jsonObject.put("DriverName", driver.getName());//机动车驾驶员 |
| | | jsonObject.put("LicenseId", driver.getDriveCard());//机动车驾驶证号 |
| | | jsonObject.put("FareType", query.get("id").toString());//运价类型编码(由网约车公司定义,与运价信息接口保持一街) |
| | | jsonObject.put("VehicleNo", car.getCarLicensePlate());//车辆号牌 |
| | | jsonObject.put("BookDepTime", orderPrivateCar.getTravelTime());//预计上车时间YYYYMMDDhhmmss |
| | | jsonObject.put("WaitTime", orderPrivateCar.getWait() * 60);//等待时间(秒) |
| | | jsonObject.put("DepLongitude", orderPrivateCar.getBoardingLon());//车辆出发经度 |
| | | jsonObject.put("DepLatitude", orderPrivateCar.getBoardingLat());//车辆出发纬度 |
| | | jsonObject.put("DepArea", orderPrivateCar.getBoardingAddress());//上车点 |
| | | jsonObject.put("DepTime", orderPrivateCar.getBoardingTime());//上车时间YYYYMMDDhhmmss |
| | | jsonObject.put("DestLongitude", orderPrivateCar.getGetoffLon());//车辆到达经度 |
| | | jsonObject.put("DestLatitude", orderPrivateCar.getGetoffLat());//车辆到达纬度 |
| | | jsonObject.put("DestArea", orderPrivateCar.getGetoffAddress());//下车地点 |
| | | jsonObject.put("DestTime", orderPrivateCar.getGetoffTime());//下车时间YYYYMMDDhhmmss |
| | | jsonObject.put("BookModel", serverCarModel.getName());//预定车型 |
| | | jsonObject.put("Model", serverCarModel.getName());//实际使用车型 |
| | | jsonObject.put("DriveMile", Double.valueOf(orderPrivateCar.getMileage() / 1000).intValue());//载客里程(km) |
| | | jsonObject.put("DriveTime", Double.valueOf((orderPrivateCar.getGetoffTime().getTime() - orderPrivateCar.getBoardingTime().getTime()) / 1000).intValue());//载客时间(秒) |
| | | List<OrderPosition> orderPositions = null; |
| | | try { |
| | | orderPositions = orderPositionService.queryPosition(orderId, 7); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | int distance = 0; |
| | | if(orderPositions.size() > 0){ |
| | | OrderPosition orderPosition = orderPositions.get(0); |
| | | Map<String, String> distance1 = gdMapElectricFenceUtil.getDistance(orderPosition.getLon() + "," + orderPosition.getLat(), orderPrivateCar.getBoardingLon() + "," + orderPrivateCar.getBoardingLat(), 1); |
| | | distance = Integer.valueOf(distance1.get("distance")) / 1000; |
| | | } |
| | | jsonObject.put("WaitMile", distance);//空驶里程(km) |
| | | jsonObject.put("FactPrice", orderPrivateCar.getPayMoney());//实收金额(元) |
| | | jsonObject.put("Price", orderPrivateCar.getOrderMoney());//应收金额(元) |
| | | jsonObject.put("CashPrice", orderPrivateCar.getPayType() == 3 ? orderPrivateCar.getPayMoney() : 0);//现金支付金额(元) |
| | | jsonObject.put("LineName", orderPrivateCar.getPayType() != 3 ? "" : "");//电子支付机构 |
| | | jsonObject.put("LinePrice", orderPrivateCar.getPayType() != 3 ? orderPrivateCar.getPayMoney() : 0);//电子支付金额(元) |
| | | jsonObject.put("PosName", "");//POS机支付机构 |
| | | jsonObject.put("PosPrice", 0);//POS机支付金额(元) |
| | | jsonObject.put("BenfitPrice", (orderPrivateCar.getRedPacketMoney() == null ? 0 : orderPrivateCar.getRedPacketMoney()) |
| | | + (orderPrivateCar.getCouponMoney() == null ? 0 : orderPrivateCar.getCouponMoney()) |
| | | + (orderPrivateCar.getDurationMoney() == null ? 0 : orderPrivateCar.getDurationMoney()));//优惠金额(元) |
| | | jsonObject.put("BookTip", 0);//预约服务费(元) |
| | | jsonObject.put("PassengerTip", (orderPrivateCar.getParkMoney() == null ? 0 : orderPrivateCar.getParkMoney()) |
| | | + (orderPrivateCar.getRoadTollMoney() == null ? 0 : orderPrivateCar.getRoadTollMoney()));//附加费(元) |
| | | Map<String, Double> map1 = this.setTransferMoney(orderPrivateCar); |
| | | Double amount3 = map1.get("amount3");//其他时间段 |
| | | Double amount2 = map1.get("amount2");//高峰时段 |
| | | Double amount1 = map1.get("amount1");//夜间时段 |
| | | jsonObject.put("PeakUpPrice", null != amount2 ? (amount2 - amount3) : 0);//高峰时段时间加价金额(元) |
| | | jsonObject.put("NightUpPrice", null != amount1 ? (amount1 - amount3) : 0);//夜间时段里程加价金额(元) |
| | | jsonObject.put("FarUpPrice", orderPrivateCar.getLongDistanceMoney() == null ? 0 : orderPrivateCar.getLongDistanceMoney());//远途加价金额(元) |
| | | jsonObject.put("OtherUpPrice", (orderPrivateCar.getDurationMoney() == null ? 0 : orderPrivateCar.getDurationMoney()) |
| | | + (orderPrivateCar.getWaitMoney() == null ? 0 : orderPrivateCar.getWaitMoney()));//其他加价金额(元) |
| | | jsonObject.put("PayState", 1);//结算状态(0:未结算,1:已结算,2:未知) |
| | | jsonObject.put("PayTime", new Date());//乘客结算时间YYYYMMDDhhmmss |
| | | jsonObject.put("OrderMatchTime", new Date());//订单完成时间YYYYMMDDhhmmss |
| | | jsonObject.put("InvoiceStatus", "0");//发票状态(0:未开票,1:已开票,2:未知) |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("operatePay", jsonObject.toJSONString()); |
| | | |
| | | Map<String, String> header = new HashMap<>(); |
| | | header.put("Connection", "keep-alive"); |
| | | header.put("Content-Type", "application/x-www-form-urlencoded"); |
| | | header.put("Accept", "*/*"); |
| | | header.put("Accept-Encoding", "gzip"); |
| | | header.put("Accept-Charset", "utf-8"); |
| | | String result = httpClientUtil.pushHttpRequset("POST", path + "ministryOfTransport/operatePay", map, header,"form"); |
| | | System.err.println("------------------------经营支付接口----------------------:" + result); |
| | | } |
| | | |
| | | /** |
| | | * 乘客评价信息 |
| | | * @param id |
| | | */ |
| | |
| | | map.put("amount3", amount3); |
| | | return map; |
| | | } |
| | | |
| | | |
| | | private Map<String, Double> setTransferMoney(OrderTransferCar orderPrivateCar) { |
| | | Map<String, Object> query1 = systemPriceMapper.query(orderPrivateCar.getCompanyId(), 1, orderPrivateCar.getServerCarModelId()); |
| | | Map<String, Double> map = new HashMap<>(); |
| | | //开始根据不同的方式计算金额 |
| | | double amount1 = 0; |
| | | double amount2 = 0; |
| | | double amount3 = 0; |
| | | JSONObject jsonObject = JSON.parseObject(query1.get("content").toString()); |
| | | Double num1 = jsonObject.getDouble("num1");//起步价(元) |
| | | Double num2 = jsonObject.getDouble("num2");//起步公里(公里) |
| | | Double num3 = jsonObject.getDouble("num3");//起步时间(分钟) |
| | | Double num4 = jsonObject.getDouble("num4");//里程费(元) |
| | | Double num5 = jsonObject.getDouble("num5");//时长费(分钟) |
| | | Double num6 = jsonObject.getDouble("num6");//等待费(分钟) |
| | | Double num7 = jsonObject.getDouble("num7");//等待费(元) |
| | | Double num8 = jsonObject.getDouble("num8");//远途费(公里) |
| | | Double num9 = jsonObject.getDouble("num9");//远途费(公里) |
| | | Double num10 = jsonObject.getDouble("num10");//远途费(元) |
| | | Double num11 = jsonObject.getDouble("num11");//远途费(公里) |
| | | Double num12 = jsonObject.getDouble("num12");//远途费(公里) |
| | | Double num13 = jsonObject.getDouble("num13");//远途费(元) |
| | | Double num14 = jsonObject.getDouble("num14");//远途费(公里) |
| | | Double num15 = jsonObject.getDouble("num15");//远途费(元) |
| | | String num16 = jsonObject.getString("num16");//夜间费(开始时间) |
| | | Double num17 = jsonObject.getDouble("num17");//夜间费(元) |
| | | Double num18 = jsonObject.getDouble("num18");//夜间费(元) |
| | | Double num19 = jsonObject.getDouble("num19");//夜间费(元) |
| | | Double num20 = jsonObject.getDouble("num20");//夜间费(元) |
| | | Double num21 = jsonObject.getDouble("num21");//夜间费(元) |
| | | Double num22 = jsonObject.getDouble("num22");//夜间费(元) |
| | | String num23 = jsonObject.getString("num23");//高峰费(开始时间) |
| | | String num24 = jsonObject.getString("num24");//高峰费(开始时间) |
| | | Double num25 = jsonObject.getDouble("num25");//高峰费(元) |
| | | Double num26 = jsonObject.getDouble("num26");//高峰费(元) |
| | | Double num27 = jsonObject.getDouble("num27");//高峰费(元) |
| | | Double num28 = jsonObject.getDouble("num28");//高峰费(元) |
| | | Double num29 = jsonObject.getDouble("num29");//高峰费(元) |
| | | Double num30 = jsonObject.getDouble("num30");//高峰费(元) |
| | | |
| | | Date date = new Date(); |
| | | double d = (null == orderPrivateCar.getMileage() ? 0D : orderPrivateCar.getMileage()) / 1000;//实际公里 |
| | | double t = ((orderPrivateCar.getEndServiceTime().getTime() - orderPrivateCar.getStartServiceTime().getTime()) / 60000) + 1;//实际时间(不满一分钟按一分钟算) |
| | | double w = ((orderPrivateCar.getStartServiceTime().getTime() - orderPrivateCar.getArriveTime().getTime()) / 60000) + 1;//等待分钟(不满一分钟按一分钟算) |
| | | double d1 = (d - num2) < 0 ? 0 : d - num2;//超出起步里程的公里 |
| | | double t1 = (t - num3) < 0 ? 0 : new BigDecimal(t - num3).setScale(0, BigDecimal.ROUND_UP).doubleValue();//超过起步分钟数的时间 |
| | | double w1 = (w - num6) < 0 ? 0 : new BigDecimal(w - num6).setScale(0, BigDecimal.ROUND_UP).doubleValue();//超出等待时间的时间 |
| | | double yt1 = 0;//远途1段 |
| | | double yt2 = 0;//远途2段 |
| | | double yt3 = 0;//远途3段 |
| | | |
| | | |
| | | //夜间服务处理逻辑 |
| | | Calendar s = Calendar.getInstance(); |
| | | s.setTime(date); |
| | | s.set(Calendar.HOUR_OF_DAY, Integer.valueOf(num16.split(" - ")[0].split(":")[0])); |
| | | s.set(Calendar.MINUTE, Integer.valueOf(num16.split(" - ")[0].split(":")[1])); |
| | | |
| | | Calendar e = Calendar.getInstance(); |
| | | e.setTime(date); |
| | | e.set(Calendar.HOUR_OF_DAY, Integer.valueOf(num16.split(" - ")[1].split(":")[0])); |
| | | e.set(Calendar.MINUTE, Integer.valueOf(num16.split(" - ")[1].split(":")[1])); |
| | | |
| | | if(date.getTime() > s.getTimeInMillis() && date.getTime() < e.getTimeInMillis()){ |
| | | if(d > num8.doubleValue() && d <= num9.doubleValue()){ |
| | | yt1 = num20 * (d - num8); |
| | | } |
| | | if(d > num9.doubleValue()){ |
| | | yt1 = num20 * (num9 - num8); |
| | | } |
| | | if(d > num11.doubleValue() || d <= num12.doubleValue()){ |
| | | yt2 = num21 * (d - num11); |
| | | } |
| | | if(d > num12.doubleValue()){ |
| | | yt2 = num21 * (num12 - num11); |
| | | } |
| | | if(d > num14.doubleValue()){ |
| | | yt3 = num22 * (d - num14); |
| | | } |
| | | amount1 = num17 + (d1 * num18) + (t1 * num19) + (w1 * num7) + yt1 + yt2 + yt3; |
| | | map.put("amount1", amount1); |
| | | } |
| | | |
| | | |
| | | //高峰时段处理逻辑 |
| | | Calendar s1 = Calendar.getInstance(); |
| | | s1.setTime(date); |
| | | s1.set(Calendar.HOUR_OF_DAY, Integer.valueOf(num23.split(" - ")[0].split(":")[0])); |
| | | s1.set(Calendar.MINUTE, Integer.valueOf(num23.split(" - ")[0].split(":")[1])); |
| | | |
| | | Calendar e1 = Calendar.getInstance(); |
| | | e1.setTime(date); |
| | | e1.set(Calendar.HOUR_OF_DAY, Integer.valueOf(num23.split(" - ")[1].split(":")[0])); |
| | | e1.set(Calendar.MINUTE, Integer.valueOf(num23.split(" - ")[1].split(":")[1])); |
| | | |
| | | Calendar s2 = Calendar.getInstance(); |
| | | s2.setTime(date); |
| | | s2.set(Calendar.HOUR_OF_DAY, Integer.valueOf(num24.split(" - ")[0].split(":")[0])); |
| | | s2.set(Calendar.MINUTE, Integer.valueOf(num24.split(" - ")[0].split(":")[1])); |
| | | |
| | | Calendar e2 = Calendar.getInstance(); |
| | | e2.setTime(date); |
| | | e2.set(Calendar.HOUR_OF_DAY, Integer.valueOf(num24.split(" - ")[1].split(":")[0])); |
| | | e2.set(Calendar.MINUTE, Integer.valueOf(num24.split(" - ")[1].split(":")[1])); |
| | | |
| | | if((date.getTime() > s1.getTimeInMillis() && date.getTime() < e1.getTimeInMillis()) || (date.getTime() > s2.getTimeInMillis() && date.getTime() < e2.getTimeInMillis())){ |
| | | if(d > num8.doubleValue() && d <= num9.doubleValue()){ |
| | | yt1 = num28 * (d - num8); |
| | | } |
| | | if(d > num9.doubleValue()){ |
| | | yt1 = num28 * (num9 - num8); |
| | | } |
| | | if(d > num11.doubleValue() && d <= num12.doubleValue()){ |
| | | yt2 = num29 * (d - num11); |
| | | } |
| | | if(d > num12.doubleValue()){ |
| | | yt2 = num29 * (num12 - num11); |
| | | } |
| | | if(d > num14.doubleValue()){ |
| | | yt3 = num30 * (d - num14); |
| | | } |
| | | amount2 = num25 + (d1 * num26) + (t1 * num27) + (w1 * num7) + yt1 + yt2 + yt3; |
| | | map.put("amount2", amount2); |
| | | } |
| | | |
| | | //其他时间段的计算 |
| | | if(d > num8.doubleValue() && d <= num9.doubleValue()){ |
| | | yt1 = num10 * (d - num8); |
| | | } |
| | | if(d > num9.doubleValue()){ |
| | | yt1 = num10 * (num9 - num8); |
| | | } |
| | | if(d > num11.doubleValue() && d <= num12.doubleValue()){ |
| | | yt2 = num13 * (d - num11); |
| | | } |
| | | if(d > num12.doubleValue()){ |
| | | yt2 = num13 * (num12 - num11); |
| | | } |
| | | if(d > num14.doubleValue()){ |
| | | yt3 = num15 * (d - num14); |
| | | } |
| | | amount3 = num1 + (d1 * num4) + (t1 * num5) + (w1 * num7) + yt1 + yt2 + yt3; |
| | | map.put("amount3", amount3); |
| | | return map; |
| | | } |
| | | } |