| | |
| | | import com.stylefeng.guns.modular.system.warpper.MerchantCouponListWarpper; |
| | | import com.stylefeng.guns.modular.taxi.dao.OrderTaxiMapper; |
| | | import com.stylefeng.guns.modular.taxi.model.OrderTaxi; |
| | | import org.apache.commons.lang.StringUtils; |
| | | import org.apache.commons.lang.time.DateFormatUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | |
| | | |
| | | @Autowired |
| | | private DateUtil dateUtil; |
| | | |
| | | @Resource |
| | | private LinePriceMapper linePriceMapper; |
| | | |
| | | @Resource |
| | | private LineMapper lineMapper; |
| | |
| | | Double totalMoney = 0D; |
| | | for(Map<String, Object> m : order){ |
| | | String phone = String.valueOf(m.get("phone")); |
| | | String s = phone.substring(0, 3) + "xxxx" + phone.substring(7 ); |
| | | String s = phone.substring(0, 3) + "****" + phone.substring(7 ); |
| | | m.put("realPhone", s); |
| | | if(m.get("telX")!=null){ |
| | | System.out.println(111); |
| | |
| | | serverMoney += income.getMoney(); |
| | | } |
| | | } |
| | | String dispatchPhone = null; |
| | | if (orderCrossCity.getLineId() <= -1) { |
| | | LineShiftDriver lineShiftDriver = lineShiftDriverMapper.selectById(orderCrossCity.getLineShiftDriverId()); |
| | | DriverSelfTrip driverSelfTrip = driverSelfTripMapper.selectById(lineShiftDriver.getCustomerId()); |
| | |
| | | map.put("lineId", orderCrossCity.getLineId()); |
| | | } else { |
| | | Line line = lineService.selectById(orderCrossCity.getLineId()); |
| | | map.put("line", line.getName()); |
| | | map.put("line", line == null ? "" : line.getName()); |
| | | map.put("lineId", orderCrossCity.getLineId()); |
| | | dispatchPhone = line == null ? null : line.getDispatchPhone(); |
| | | } |
| | | map.put("peopleNumber", num); |
| | | map.put("orderNumber", orderCrossCity.getOrderNum()); |
| | |
| | | map.put("serverMoney", new BigDecimal(serverMoney).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | OpenCity openCity = openCityService.openCity1(orderCrossCity.getStartLon().toString(), orderCrossCity.getStartLat().toString()); |
| | | Phone phone = phoneMapper.queryInfo(openCity == null ? 0 : openCity.getId(), 1, 1); |
| | | map.put("emergencyCall", null != phone ? phone.getPhone() : "110"); |
| | | map.put("emergencyCall", StringUtils.isNotBlank(dispatchPhone) ? dispatchPhone : (null != phone ? phone.getPhone() : "110")); |
| | | if (!order.isEmpty()){ |
| | | map.put("lineShiftDriverId", order.get(0).get("lineShiftDriverId")); |
| | | } |
| | |
| | | lineShiftDriver.setLaveSeatNumber(""); |
| | | }else{//拼车 |
| | | lineShiftDriver.setLaveSeat(lineShiftDriver.getLaveSeat() - orderCrossCity.getPeopleNumber()); |
| | | String[] split = orderCrossCity.getSeatNumber().split(","); |
| | | String[] split1 = lineShiftDriver.getLaveSeatNumber().split(","); |
| | | String seatNumber = ""; |
| | | //先判断选中座位号和剩余座位号是否匹配 |
| | | for(String spl : split){ |
| | | boolean b = true; |
| | | for(String sp : split1){ |
| | | if(ToolUtil.isNotEmpty(spl) && ToolUtil.isNotEmpty(sp) && sp.equals(spl)){ |
| | | b = false; |
| | | break; |
| | | } |
| | | } |
| | | if(b){ |
| | | throw new SystemException("您选中的" + spl + "号座位已被占用,请选择其他座位!"); |
| | | } |
| | | } |
| | | for(String sp : split1){ |
| | | boolean b = true; |
| | | |
| | | if (StringUtils.isNotEmpty(orderCrossCity.getSeatNumber())){ |
| | | // 用户已选座的情况 |
| | | String[] split = orderCrossCity.getSeatNumber().split(","); |
| | | String seatNumber = ""; |
| | | //先判断选中座位号和剩余座位号是否匹配 |
| | | for(String spl : split){ |
| | | if(ToolUtil.isNotEmpty(spl) && ToolUtil.isNotEmpty(sp) && sp.equals(spl)){ |
| | | b = false; |
| | | break; |
| | | boolean b = true; |
| | | for(String sp : split1){ |
| | | if(ToolUtil.isNotEmpty(spl) && ToolUtil.isNotEmpty(sp) && sp.equals(spl)){ |
| | | b = false; |
| | | break; |
| | | } |
| | | } |
| | | if(b){ |
| | | throw new SystemException("您选中的" + spl + "号座位已被占用,请选择其他座位!"); |
| | | } |
| | | } |
| | | if(b && ToolUtil.isNotEmpty(sp)){ |
| | | seatNumber += (sp + ","); |
| | | for(String sp : split1){ |
| | | boolean b = true; |
| | | for(String spl : split){ |
| | | if(ToolUtil.isNotEmpty(spl) && ToolUtil.isNotEmpty(sp) && sp.equals(spl)){ |
| | | b = false; |
| | | break; |
| | | } |
| | | } |
| | | if(b && ToolUtil.isNotEmpty(sp)){ |
| | | seatNumber += (sp + ","); |
| | | } |
| | | } |
| | | lineShiftDriver.setLaveSeatNumber(ToolUtil.isNotEmpty(seatNumber) ? seatNumber.substring(0, seatNumber.length() - 1) : ""); |
| | | } else { |
| | | // 用户未选座的情况,自动分配剩余座位的前peopleNumber个 |
| | | StringBuilder assignedSeats = new StringBuilder(); |
| | | StringBuilder remainingSeats = new StringBuilder(); |
| | | |
| | | for(int i = 0; i < split1.length; i++){ |
| | | if(ToolUtil.isEmpty(split1[i])){ |
| | | continue; |
| | | } |
| | | |
| | | if(i < orderCrossCity.getPeopleNumber()){ |
| | | // 分配给当前订单的座位 |
| | | if(assignedSeats.length() > 0){ |
| | | assignedSeats.append(","); |
| | | } |
| | | assignedSeats.append(split1[i]); |
| | | } else { |
| | | // 剩余的座位 |
| | | if(remainingSeats.length() > 0){ |
| | | remainingSeats.append(","); |
| | | } |
| | | remainingSeats.append(split1[i]); |
| | | } |
| | | } |
| | | |
| | | // 设置订单的座位号 |
| | | orderCrossCity.setSeatNumber(assignedSeats.toString()); |
| | | this.updateById(orderCrossCity); |
| | | |
| | | // 更新班次的剩余座位号 |
| | | lineShiftDriver.setLaveSeatNumber(remainingSeats.toString()); |
| | | } |
| | | lineShiftDriver.setLaveSeatNumber(ToolUtil.isNotEmpty(seatNumber) ? seatNumber.substring(0, seatNumber.length() - 1) : ""); |
| | | } |
| | | lineShiftDriverMapper.updateById(lineShiftDriver); |
| | | |
| | |
| | | } |
| | | |
| | | Map<String, Object> map = new HashMap<>(); |
| | | double distance1 = distance.doubleValue() / 1000;//公里 |
| | | map.put("distance", distance); |
| | | |
| | | /** |
| | | * 1.固定价格的包车是整车价格 |
| | | * 2.五座车和七座车的优惠系数是中间特殊位置的优惠折扣 |
| | | * 3.包车的情况不享受中间特殊位置的优惠折扣 |
| | | * 4.浮动计费拼车如果选中中间特殊位置既享受优惠系数又享受中间特殊位置的优惠折扣 |
| | | */ |
| | | Map<String, Object> query = linePriceMapper.query(lineId, serverCarModelId); |
| | | if(null == query){ |
| | | map.put("distance", 0); |
| | | map.put("price", 0); |
| | | return ResultUtil.success(map); |
| | | } |
| | | String content = query.get("content").toString(); |
| | | JSONObject jsonObject = JSON.parseObject(content); |
| | | if(Integer.valueOf(query.get("type").toString()) == 1){//固定金额 |
| | | double num1 = Double.valueOf(jsonObject.getString("num1")).doubleValue(); |
| | | double num2 = Double.valueOf(jsonObject.getString("num2")).doubleValue(); |
| | | double num3 = Double.valueOf(jsonObject.getString("num3")).doubleValue(); |
| | | double num4 = Double.valueOf(jsonObject.getString("num4")).doubleValue(); |
| | | if(travelMode == 1){//拼车 |
| | | String[] split = seatNumber.split(","); |
| | | boolean b = false; |
| | | for(String s : split){ |
| | | if((totalSeat == 4 && s.equals("3")) || (totalSeat == 6 && s.equals("5"))){ |
| | | b = true; |
| | | break; |
| | | } |
| | | } |
| | | double price1 = 0D; |
| | | if(b){ |
| | | price1 = num1 * (totalSeat == 4 ? num3 : num4); |
| | | peopleNumber -= 1; |
| | | } |
| | | double price = (num1 * peopleNumber) + price1; |
| | | map.put("price", new BigDecimal(price).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | }else{ |
| | | map.put("price", num2);//包车价 |
| | | } |
| | | |
| | | }else{//浮动计费 |
| | | //计算公式:实际历程 * 基础单价 * (参考费用 / (参考里程 * 基础单价)) + (实际历程 - 参考里程) * 基础单价 * 优惠系数 |
| | | double num1 = Double.valueOf(jsonObject.getString("num1")).doubleValue();//参考价格 |
| | | double num2 = Double.valueOf(jsonObject.getString("num2")).doubleValue();//参考里程 |
| | | double num3 = Double.valueOf(jsonObject.getString("num3")).doubleValue();//保底价 |
| | | double num4 = Double.valueOf(jsonObject.getString("num4")).doubleValue();//超出参考里程优惠系数 |
| | | double num5 = Double.valueOf(jsonObject.getString("num5")).doubleValue();//低于参考里程优惠系数 |
| | | double num6 = Double.valueOf(jsonObject.getString("num6")).doubleValue();//包车系数 |
| | | double num7 = Double.valueOf(jsonObject.getString("num7")).doubleValue();//五座系数 |
| | | double num8 = Double.valueOf(jsonObject.getString("num8")).doubleValue();//七座系数 |
| | | |
| | | |
| | | /** |
| | | * 1、实际里程>=参考里程 |
| | | * 参考价+((实际里程-参考里程)*(参考价/参考里程)*超出参考里程优惠系数) |
| | | * |
| | | * 2、实际里程<参考里程 |
| | | * 参考价-(参考里程-实际路程)*(参考价/参考里程)*低于参考里程优惠系数 |
| | | */ |
| | | double unitPrice = 0d; |
| | | if(distance1 > num2){//1 |
| | | unitPrice = num1 + ((distance1 - num2) * (num1 / num2) * num4); |
| | | } |
| | | if(distance1 < num2){//2 |
| | | unitPrice = num1 - ((num2 - distance1) * (num1 / num2) * num5); |
| | | } |
| | | if(distance1 == num2){ |
| | | unitPrice = num1; |
| | | } |
| | | if(travelMode == 1){//拼车 |
| | | String[] split = seatNumber.split(","); |
| | | boolean b = false; |
| | | for(String s : split){ |
| | | if((totalSeat == 4 && s.equals("3")) || (totalSeat == 6 && s.equals("5"))){ |
| | | b = true; |
| | | break; |
| | | } |
| | | } |
| | | double price1 = 0D; |
| | | if(b){ |
| | | price1 = unitPrice * (totalSeat == 4 ? num7 : num8); |
| | | peopleNumber -= 1; |
| | | } |
| | | double price = (unitPrice * peopleNumber) + price1; |
| | | map.put("price", new BigDecimal(num3 > price ? num3 : price).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | }else{ |
| | | double price = unitPrice * totalSeat * num6; |
| | | map.put("price", new BigDecimal(num3 > price ? num3 : price).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | } |
| | | } |
| | | Integer pricePeopleNumber = travelMode != null && travelMode == 2 && totalSeat != null && totalSeat > 0 ? totalSeat : peopleNumber; |
| | | BigDecimal unitPrice = queryDefaultLineDestinationPrice(lineId, totalSeat); |
| | | map.put("price", unitPrice == null ? -1 : multiplyPeopleNumber(unitPrice, pricePeopleNumber).doubleValue()); |
| | | return ResultUtil.success(map); |
| | | } |
| | | |
| | |
| | | Map<String, Object> destination = lineMapper.queryLineDestinationById(lineDestinationId, lineId); |
| | | BigDecimal unitPrice = null; |
| | | if (destination != null) { |
| | | unitPrice = totalSeat != null && totalSeat == 6 ? getBigDecimal(destination.get("price7")) : getBigDecimal(destination.get("price5")); |
| | | if (unitPrice == null) { |
| | | unitPrice = getBigDecimal(destination.get("price5")); |
| | | } |
| | | unitPrice = getDestinationPrice(destination, totalSeat); |
| | | } |
| | | map.put("price", unitPrice == null ? -1 : multiplyPeopleNumber(unitPrice, peopleNumber).doubleValue()); |
| | | return ResultUtil.success(map); |
| | |
| | | map.put("price", -1); |
| | | return ResultUtil.success(map); |
| | | } |
| | | BigDecimal defaultPrice5 = getBigDecimal(destinations.get(0).get("price5")); |
| | | BigDecimal defaultPrice = getDestinationPrice(destinations.get(0), totalSeat); |
| | | BigDecimal matchedPrice = null; |
| | | for (Map<String, Object> destination : destinations) { |
| | | if (isPointInDestinationFence(destination, endLon, endLat)) { |
| | | matchedPrice = totalSeat != null && totalSeat == 6 ? getBigDecimal(destination.get("price7")) : getBigDecimal(destination.get("price5")); |
| | | if (matchedPrice == null) { |
| | | matchedPrice = getBigDecimal(destination.get("price5")); |
| | | } |
| | | matchedPrice = getDestinationPrice(destination, totalSeat); |
| | | break; |
| | | } |
| | | } |
| | | BigDecimal finalPrice = matchedPrice == null ? defaultPrice5 : matchedPrice; |
| | | BigDecimal finalPrice = matchedPrice == null ? defaultPrice : matchedPrice; |
| | | map.put("price", finalPrice == null ? -1 : multiplyPeopleNumber(finalPrice, peopleNumber).doubleValue()); |
| | | return ResultUtil.success(map); |
| | | } |
| | |
| | | if (destinations == null || destinations.size() == 0) { |
| | | return null; |
| | | } |
| | | BigDecimal defaultPrice5 = getBigDecimal(destinations.get(0).get("price5")); |
| | | BigDecimal defaultPrice = getDestinationPrice(destinations.get(0), lineShiftDriver.getTotalSeat()); |
| | | for (Map<String, Object> destination : destinations) { |
| | | if (isPointInDestinationFence(destination, endLon, endLat)) { |
| | | if (lineShiftDriver.getTotalSeat() != null && lineShiftDriver.getTotalSeat() == 6) { |
| | | BigDecimal price7 = getBigDecimal(destination.get("price7")); |
| | | return price7 == null ? defaultPrice5 : price7; |
| | | } |
| | | BigDecimal price5 = getBigDecimal(destination.get("price5")); |
| | | return price5 == null ? defaultPrice5 : price5; |
| | | BigDecimal price = getDestinationPrice(destination, lineShiftDriver.getTotalSeat()); |
| | | return price == null ? defaultPrice : price; |
| | | } |
| | | } |
| | | return defaultPrice5; |
| | | return defaultPrice; |
| | | } |
| | | |
| | | private boolean isPointInDestinationFence(Map<String, Object> destination, Double lon, Double lat) { |
| | |
| | | } |
| | | } |
| | | |
| | | private BigDecimal queryDefaultLineDestinationPrice(Integer lineId, Integer totalSeat) { |
| | | List<Map<String, Object>> destinations = lineMapper.queryLineDestinations(lineId); |
| | | if (destinations == null || destinations.size() == 0) { |
| | | return null; |
| | | } |
| | | return getDestinationPrice(destinations.get(0), totalSeat); |
| | | } |
| | | |
| | | private BigDecimal getDestinationPrice(Map<String, Object> destination, Integer totalSeat) { |
| | | if (destination == null) { |
| | | return null; |
| | | } |
| | | BigDecimal price = totalSeat != null && totalSeat == 6 |
| | | ? getBigDecimal(destination.get("price7")) |
| | | : getBigDecimal(destination.get("price5")); |
| | | return price == null ? getBigDecimal(destination.get("price5")) : price; |
| | | } |
| | | |
| | | private BigDecimal multiplyPeopleNumber(BigDecimal price, Integer peopleNumber) { |
| | | if (price == null || peopleNumber == null || peopleNumber <= 0) { |
| | | return null; |
| | |
| | | * @throws Exception |
| | | */ |
| | | public synchronized String getOrderNum(Integer driverId, Integer lineShiftDriverId) throws Exception{ |
| | | List<OrderCrossCity> orderCrossCities = orderCrossCityMapper.queryOrders(driverId, lineShiftDriverId, Arrays.asList(2, 3, 4, 7)); |
| | | List<OrderCrossCity> orderCrossCities = orderCrossCityMapper.queryOrders(driverId, lineShiftDriverId, Arrays.asList(2, 3, 4, 5, 6, 7)); |
| | | if(orderCrossCities.size() > 0){ |
| | | return orderCrossCities.get(0).getOrderNum(); |
| | | } |
| | |
| | | return ResultUtil.error("该乘客有未完成的订单"); |
| | | } |
| | | |
| | | // 9. 检查司机是否正在服务中 |
| | | List<OrderCrossCity> orderCrossCities2 = orderCrossCityMapper.queryOrders(driverId, warpper.getLineShiftDriverId(), Arrays.asList(5)); |
| | | if (orderCrossCities2.size() > 0) { |
| | | return ResultUtil.error("司机正在服务中"); |
| | | } |
| | | // // 9. 检查司机是否正在服务中 |
| | | // List<OrderCrossCity> orderCrossCities2 = orderCrossCityMapper.queryOrders(driverId, warpper.getLineShiftDriverId(), Arrays.asList(5)); |
| | | // if (orderCrossCities2.size() > 0) { |
| | | // return ResultUtil.error("司机正在服务中"); |
| | | // } |
| | | |
| | | // // 10. 计算价格 |
| | | // Map<String, String> distanceMap = gdMapElectricFenceUtil.getDistance( |
| | |
| | | if (!cbyzxOrderPayHelper.isCreateSuccess(response)) { |
| | | return ResultUtil.error(cbyzxOrderPayHelper.extractMessage(response), response); |
| | | } |
| | | order.setPayManner(1); |
| | | orderCrossCityMapper.updateById(order); |
| | | paymentRecordService.saveData(1, order.getDriverId(), 2, crossCityOrderId, 3, 1, order.getOrderMoney(), outTradeNo, 1); |
| | | return ResultUtil.success(response); |
| | | } else if (type == 3) { |
| | | order.setState(2); |
| | | order.setPayMoney(0.00); |
| | | order.setPayManner(2); |
| | | order.setPayMoney(order.getOrderMoney()); |
| | | orderCrossCityMapper.updateById(order); |
| | | |
| | | |
| | |
| | | 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); |
| | | } |