| | |
| | | if (driver != null) { |
| | | String fileName = driver.getQrCode(); |
| | | if (fileName == null || "".equals(fileName)) { |
| | | String appletPath = "pages/index/index"; |
| | | String appletPath = "pages/home/home"; |
| | | String scene = "driverId=" + driverId; |
| | | String unlimitQrcodeUrl = weChatUtil.getUnlimitQrcode(appletPath, scene); |
| | | if (unlimitQrcodeUrl != null) { |
| | |
| | | } |
| | | |
| | | // 4. 生成小程序码 |
| | | String page = "pages/index/index"; // 小程序跳转页面 |
| | | String page = "pages/home/home"; // 小程序跳转页面 |
| | | String unlimitQrcodeUrl = weChatUtil.getUnlimitQrcode(page, scene); |
| | | // 6. 返回结果 |
| | | BaseWarpper baseWarpper = new BaseWarpper(); |
| | |
| | | transactionDetailsService.saveData(driverId, "跨城出行订单", order.getOrderMoney(), 2, 1, 2, 3, order.getId()); |
| | | return ResultUtil.success(); |
| | | } else if (type == 2) { |
| | | String path = "pages/index/index"; |
| | | String path = "pages/home/home"; |
| | | String unlimitQrcode = weChatUtil.getUnlimitQrcode(path, "default"); |
| | | return ResultUtil.success(unlimitQrcode); |
| | | } |
| | |
| | | param.put("scene", scene); |
| | | param.put("page", page); |
| | | param.put("env_version", envVersion); |
| | | param.put("check_path",false); |
| | | HttpHeaders httpHeaders = new HttpHeaders(); |
| | | MediaType type=MediaType.parseMediaType("application/json;charset=UTF-8"); |
| | | httpHeaders.setContentType(type); |
| | |
| | | List<Object> list = new ArrayList<>(); |
| | | System.out.println(tDrivers.toString()); |
| | | for (TDriver tDriver : tDrivers) { |
| | | Map<String, Object> d = new HashMap<>(); |
| | | String value = (String) redisTemplate.opsForValue().get("dache:DRIVER" + tDriver.getId()); |
| | | System.out.println(value); |
| | | if (ToolUtil.isEmpty(value)) { |
| | | continue; |
| | | try { |
| | | Map<String, Object> d = new HashMap<>(); |
| | | String value = (String) redisTemplate.opsForValue().get("dache:DRIVER" + tDriver.getId()); |
| | | System.out.println(value); |
| | | if (ToolUtil.isEmpty(value)) { |
| | | continue; |
| | | } |
| | | d.put("driver", tDriver); |
| | | d.put("lon", value.split(",")[0]); |
| | | d.put("lat", value.split(",")[1]); |
| | | list.add(d); |
| | | }catch (Exception ignore){ |
| | | |
| | | } |
| | | d.put("driver", tDriver); |
| | | d.put("lon", value.split(",")[0]); |
| | | d.put("lat", value.split(",")[1]); |
| | | list.add(d); |
| | | |
| | | } |
| | | map.put("driver", list); |
| | | |
| | |
| | | return buildCbyzxCallbackResponse(1, "order not found"); |
| | | } |
| | | if (orderRide.getState() == null || orderRide.getState() != 2) { |
| | | orderRide.setOutNum(orderId); |
| | | // orderRide.setOutNum(orderId); |
| | | orderRide.setPayTime(new Date()); |
| | | orderRide.setPayType(2); |
| | | orderRide.setState(2); |
| | |
| | | return ApiJson.returnNG("用户信息不存在"); |
| | | } |
| | | String outTradeNo = orderId + "_8_" + UUIDUtil.getRandomCode(5); |
| | | orderRide.setOutNum(outTradeNo); |
| | | JSONObject response = cbyzxOrderPayHelper.createOrder(orderRide.getUserId(), userInfo.getAppletsOpenId(), outTradeNo, orderRide.getMoney()); |
| | | if (!cbyzxOrderPayHelper.isCreateSuccess(response)) { |
| | | return ApiJson.returnNG(cbyzxOrderPayHelper.extractMessage(response), response); |
| | | } |
| | | orderRideService.updateById(orderRide); |
| | | return ApiJson.returnOK(response); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | |
| | | userInfoService.updateById(userInfo); |
| | | }else if(orderRide.getPayType()==2){ |
| | | //微信 |
| | | Integer money = new Double(orderRide.getMoney() * 100).intValue(); |
| | | Integer tMoney_ = new Double(orderRide.getTuiMoney()* 100).intValue(); |
| | | PayUtil.refundForWxpay(1, financial.getLsType(), orderRide.getOrderNum(), finNum, money,tMoney_ , "2"); |
| | | // Integer money = new Double(orderRide.getMoney() * 100).intValue(); |
| | | // Integer tMoney_ = new Double(orderRide.getTuiMoney()* 100).intValue(); |
| | | // PayUtil.refundForWxpay(1, financial.getLsType(), orderRide.getOrderNum(), finNum, money,tMoney_ , "2"); |
| | | |
| | | CbyzxPayUtil.ClosePayOrderRequest request = new CbyzxPayUtil.ClosePayOrderRequest(); |
| | | request.setOutRequestNo(orderRide.getOutNum()); |
| | | request.setRefundOutRequestNo(buildPrepayRefundOutNo(orderRide.getId())); |
| | | request.setRefundAmount(toFen(orderRide.getTuiMoney())); |
| | | request.setRefundDesc("顺风车订单取消退款"); |
| | | com.alibaba.fastjson.JSONObject response = CbyzxPayUtil.closePayOrder(request); |
| | | if (!isPrivateCarPrepayRefundSuccess(response)) { |
| | | throw new RuntimeException(extractPrivateCarRefundMessage(response)); |
| | | } |
| | | |
| | | }else if(orderRide.getPayType()==3){ |
| | | |
| | |
| | | orderRideService.updateAllColumnById(orderRide); |
| | | } |
| | | |
| | | private String buildPrepayRefundOutNo(Integer orderId) { |
| | | return "PREPAY_REFUND_8_" + orderId+ToolUtil.getRandomString(5); |
| | | } |
| | | |
| | | private Integer toFen(Double amount) { |
| | | return new BigDecimal(String.valueOf(amount)).multiply(new BigDecimal("100")).setScale(0, RoundingMode.HALF_UP).intValue(); |
| | | } |
| | | |
| | | private boolean isPrivateCarPrepayRefundSuccess(com.alibaba.fastjson.JSONObject response) { |
| | | if (response == null) { |
| | | return false; |
| | | } |
| | | Object code = response.get("code"); |
| | | if (code == null || !"0".equals(String.valueOf(code))) { |
| | | return false; |
| | | } |
| | | com.alibaba.fastjson.JSONObject data = response.getJSONObject("data"); |
| | | return data != null && Boolean.TRUE.equals(data.getBoolean("isSuccess")); |
| | | } |
| | | |
| | | private String extractPrivateCarRefundMessage(com.alibaba.fastjson.JSONObject response) { |
| | | if (response == null) { |
| | | return "微信退款失败"; |
| | | } |
| | | com.alibaba.fastjson.JSONObject data = response.getJSONObject("data"); |
| | | if (data != null && ToolUtil.isNotEmpty(data.getString("failReason"))) { |
| | | return data.getString("failReason"); |
| | | } |
| | | String msg = response.getString("msg"); |
| | | return ToolUtil.isNotEmpty(msg) ? msg : "微信退款失败"; |
| | | } |
| | | |
| | | /** |
| | | * 司机行程取消 |
| | | * @param orderId |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 根据起终点经纬度计算出租车预估金额 |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/api/taxi/taxiPreAmountCalculate") |
| | | @ApiOperation(value = "根据起终点经纬度计算出租车预估金额", tags = {"用户端-出租车"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "起点经度", name = "startLon", required = true, dataType = "double"), |
| | | @ApiImplicitParam(value = "起点纬度", name = "startLat", required = true, dataType = "double"), |
| | | @ApiImplicitParam(value = "终点经度", name = "endLon", required = true, dataType = "double"), |
| | | @ApiImplicitParam(value = "终点纬度", name = "endLat", required = true, dataType = "double") |
| | | }) |
| | | public ResultUtil<BaseWarpper> taxiPreAmountCalculate(Double startLon, Double startLat, Double endLon, Double endLat){ |
| | | try { |
| | | return orderTaxiService.taxiPreAmountCalculate(startLon, startLat, endLon, endLat); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return ResultUtil.runErr(); |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | a.state as state, |
| | | DATE_FORMAT(a.insertTime, '%Y-%m-%d %H:%i:%s') as insertTime, |
| | | DATE_FORMAT(a.travelTime, '%m月%d日 %H:%i') as travelTime, |
| | | DATE_FORMAT(a.travelTime, '%Y-%m-%d %H:%i:%s') as travelTime1, |
| | | DATE_FORMAT(a.arriveTime, '%Y-%m-%d %H:%i:%s') as arriveTime, |
| | | a.startLon as startLon, |
| | | a.startLat as startLat, |
| | |
| | | */ |
| | | ResultUtil payTaxiOrder1(Integer payType, Integer orderId, Integer objectId, Integer objectType, Integer type, String path, String ip)throws Exception; |
| | | |
| | | /** |
| | | * 根据起终点经纬度计算出租车预估金额 |
| | | * @param startLon 起点经度 |
| | | * @param startLat 起点纬度 |
| | | * @param endLon 终点经度 |
| | | * @param endLat 终点纬度 |
| | | * @return 预估金额 |
| | | * @throws Exception |
| | | */ |
| | | ResultUtil<BaseWarpper> taxiPreAmountCalculate(Double startLon, Double startLat, Double endLon, Double endLat) throws Exception; |
| | | |
| | | |
| | | |
| | | /** |
| | |
| | | return map; |
| | | } |
| | | |
| | | @Override |
| | | public ResultUtil<BaseWarpper> taxiPreAmountCalculate(Double startLon, Double startLat, Double endLon, Double endLat) throws Exception { |
| | | BaseWarpper baseWarpper = new BaseWarpper(); |
| | | Double estimateAmount = 0D; |
| | | try { |
| | | if (startLon != null && startLat != null && endLon != null && endLat != null) { |
| | | Map<String, String> startGeocode = gdMapGeocodingUtil.geocode(String.valueOf(startLon), String.valueOf(startLat)); |
| | | Company query = companyCityService.query(String.valueOf(startLon), String.valueOf(startLat)); |
| | | if (startGeocode != null && query != null) { |
| | | Map<String, String> distance = gdMapElectricFenceUtil.getDistance( |
| | | startLon + "," + startLat, |
| | | endLon + "," + endLat, |
| | | 1 |
| | | ); |
| | | if (distance != null) { |
| | | double distanceMeters = Double.parseDouble(distance.get("distance")); |
| | | long durationSeconds = Long.parseLong(distance.get("duration")); |
| | | ServerCarModelWarpper textPrice = serverCarModelService.getTextPrice(query.getId(), distanceMeters, durationSeconds, 0, 2, startGeocode); |
| | | if (textPrice != null && textPrice.getAmount() != null && textPrice.getAmount().get("zongfeiyong") != null) { |
| | | estimateAmount = Double.valueOf(textPrice.getAmount().get("zongfeiyong").toString()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } catch (Exception ignore) { |
| | | estimateAmount = 0D; |
| | | } |
| | | baseWarpper.setAmount(estimateAmount); |
| | | baseWarpper.setEstimateAmount(estimateAmount); |
| | | return ResultUtil.success(baseWarpper); |
| | | } |
| | | |
| | | private void taxiPreAmountCalculate(OrderTaxi orderTaxi, Map<String, Object> map) { |
| | | try { |
| | | Map<String, String> startGeocode = gdMapGeocodingUtil.geocode(String.valueOf(orderTaxi.getStartLon()), String.valueOf(orderTaxi.getStartLat())); |
| | | Company query = companyCityService.query(String.valueOf(orderTaxi.getStartLon()), String.valueOf(orderTaxi.getStartLat())); |
| | | if (orderTaxi.getEndLon() != null && orderTaxi.getEndLat() != null && startGeocode != null) { |
| | | Map<String, String> distance = gdMapElectricFenceUtil.getDistance( |
| | | orderTaxi.getStartLon() + "," + orderTaxi.getStartLat(), |
| | | orderTaxi.getEndLon() + "," + orderTaxi.getEndLat(), |
| | | 1 |
| | | ); |
| | | System.out.println("距离获取890"); |
| | | if (distance != null) { |
| | | double distanceMeters = Double.parseDouble(distance.get("distance")); |
| | | long durationSeconds = Long.parseLong(distance.get("duration")); |
| | | ServerCarModelWarpper textPrice = serverCarModelService.getTextPrice(query.getId(), distanceMeters, durationSeconds, 0, 2, startGeocode); |
| | | System.out.println("费用计算895"); |
| | | if (textPrice != null && textPrice.getAmount() != null && textPrice.getAmount().get("zongfeiyong") != null) { |
| | | Double estimateAmount = Double.valueOf(textPrice.getAmount().get("zongfeiyong").toString()); |
| | | map.put("orderMoney", estimateAmount); |
| | | map.put("estimateAmount", estimateAmount); |
| | | } else { |
| | | map.put("orderMoney", 0); |
| | | map.put("estimateAmount", 0); |
| | | } |
| | | } else { |
| | | map.put("orderMoney", 0); |
| | | map.put("estimateAmount", 0); |
| | | } |
| | | ResultUtil<BaseWarpper> result = taxiPreAmountCalculate(orderTaxi.getStartLon(), orderTaxi.getStartLat(), orderTaxi.getEndLon(), orderTaxi.getEndLat()); |
| | | if (ResultUtil.SUCCESS.equals(result.getCode()) && result.getData() != null) { |
| | | BaseWarpper baseWarpper = result.getData(); |
| | | map.put("orderMoney", baseWarpper.getAmount() == null ? 0 : baseWarpper.getAmount()); |
| | | map.put("estimateAmount", baseWarpper.getEstimateAmount() == null ? 0 : baseWarpper.getEstimateAmount()); |
| | | } else { |
| | | map.put("orderMoney", 0); |
| | | map.put("estimateAmount", 0); |