| | |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.models.auth.In; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | |
| | | import java.io.File; |
| | | import java.io.FileInputStream; |
| | | import java.io.InputStreamReader; |
| | | import java.math.BigDecimal; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | |
| | | return ResultUtil.runErr(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 司机改价 |
| | | * @param orderId |
| | | * @param orderType |
| | | * @return |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/api/order/updatePrice") |
| | | @ApiOperation(value = "司机修改费用[0731]", tags = {"司机端-服务中"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "订单id", name = "orderId", required = true, dataType = "int"), |
| | | @ApiImplicitParam(value = "订单类型(1=专车,2=快车,3=城际)", name = "orderType", required = true, dataType = "int"), |
| | | @ApiImplicitParam(value = "价格类型 1=原价格 2=预估价 3=修改价", name = "priceType", required = true, dataType = "int"), |
| | | @ApiImplicitParam(value = "改价金额", name = "updatePrice", required = true, dataType = "BigDecimal"), |
| | | @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResultUtil updatePrice(Integer orderId, Integer orderType, Integer priceType, BigDecimal updatePrice){ |
| | | try{ |
| | | orderService.updatePrice(orderId, orderType, priceType, updatePrice); |
| | | return ResultUtil.success(); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return ResultUtil.runErr(); |
| | | } |
| | | } |
| | | |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.annotations.TableId; |
| | | import com.baomidou.mybatisplus.annotations.TableName; |
| | | import com.baomidou.mybatisplus.enums.IdType; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | |
| | | @TableField("passengersPhone") |
| | | private String passengersPhone; |
| | | /** |
| | | * 订单状态(1=待接单,2=待出发,3=待到达预约地点,4=待乘客上车,5=服务中,6=完成服务,7=待支付,8=待评价,9=已完成,10=已取消,11=改派中,12=取消待支付) |
| | | * 订单状态(1=待接单,2=待出发,3=待到达预约地点,4=待乘客上车,5=服务中,6=完成服务,7=待支付,8=待评价,9=已完成,10=已取消,11=改派中,12=取消待支付,13=待改价) |
| | | */ |
| | | @TableField("state") |
| | | private Integer state; |
| | |
| | | */ |
| | | private Integer isAbnormal; |
| | | |
| | | @ApiModelProperty(value = "是否异常 1=是 0=否") |
| | | @TableField("isException") |
| | | private Integer isException; |
| | | @ApiModelProperty(value = "修改后的价格") |
| | | @TableField("updatePrice") |
| | | private BigDecimal updatePrice; |
| | | @ApiModelProperty(value = "价格类型 1=原价格 2=预估价 3=修改价") |
| | | @TableField("priceType") |
| | | private Integer priceType; |
| | | @ApiModelProperty(value = "预估价") |
| | | @TableField("estimatedPrice") |
| | | private BigDecimal estimatedPrice; |
| | | |
| | | @ApiModelProperty(value = "上一次定位推送时间") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | @TableField("lastPushTime") |
| | | private LocalDateTime lastPushTime; |
| | | |
| | | @ApiModelProperty(value = "修改价格审核 1=待审核 2=通过") |
| | | @TableField("priceAuditState") |
| | | private Integer priceAuditState; |
| | | |
| | | public Integer getPriceAuditState() { |
| | | return priceAuditState; |
| | | } |
| | | |
| | | public void setPriceAuditState(Integer priceAuditState) { |
| | | this.priceAuditState = priceAuditState; |
| | | } |
| | | |
| | | public LocalDateTime getLastPushTime() { |
| | | return lastPushTime; |
| | | } |
| | | |
| | | public void setLastPushTime(LocalDateTime lastPushTime) { |
| | | this.lastPushTime = lastPushTime; |
| | | } |
| | | |
| | | public Integer getIsException() { |
| | | return isException; |
| | | } |
| | | |
| | | public void setIsException(Integer isException) { |
| | | this.isException = isException; |
| | | } |
| | | |
| | | public BigDecimal getUpdatePrice() { |
| | | return updatePrice; |
| | | } |
| | | |
| | | public void setUpdatePrice(BigDecimal updatePrice) { |
| | | this.updatePrice = updatePrice; |
| | | } |
| | | |
| | | public Integer getPriceType() { |
| | | return priceType; |
| | | } |
| | | |
| | | public void setPriceType(Integer priceType) { |
| | | this.priceType = priceType; |
| | | } |
| | | |
| | | public BigDecimal getEstimatedPrice() { |
| | | return estimatedPrice; |
| | | } |
| | | |
| | | public void setEstimatedPrice(BigDecimal estimatedPrice) { |
| | | this.estimatedPrice = estimatedPrice; |
| | | } |
| | | |
| | | public Integer getIsAbnormal() { |
| | | return isAbnormal; |
| | | } |
| | |
| | | import com.stylefeng.guns.modular.system.warpper.BaseWarpper; |
| | | import com.stylefeng.guns.modular.taxi.model.OrderTaxi; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | |
| | | */ |
| | | void getTrackId(Integer orderId, Integer trackId); |
| | | |
| | | /** |
| | | * 修改订单价格 |
| | | * @param orderId |
| | | * @param priceType |
| | | * @param updatePrice |
| | | */ |
| | | void updatePrice(Integer orderId, Integer priceType, BigDecimal updatePrice); |
| | | |
| | | } |
| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.util.StringUtils; |
| | | |
| | | import javax.annotation.Resource; |
| | |
| | | import java.math.BigDecimal; |
| | | import java.math.MathContext; |
| | | import java.math.RoundingMode; |
| | | import java.time.Duration; |
| | | import java.time.LocalDateTime; |
| | | import java.util.*; |
| | | |
| | | |
| | |
| | | |
| | | @Autowired |
| | | private IIncomeService incomeService; |
| | | @Autowired |
| | | private ISpecialAreaBillingService specialAreaBillingService; |
| | | |
| | | |
| | | @Value("${filePath}") |
| | |
| | | orderPrivateCar.setArriveTime(orderPrivateCar.getStartServiceTime()); |
| | | } |
| | | orderPrivateCar = this.setMoney(orderPrivateCar, 0D, 0D);//计算费用 |
| | | |
| | | // 查询起点或者终点在特殊区域中 |
| | | List<SpecialAreaBilling> specialAreaBillings = specialAreaBillingService.selectList(new EntityWrapper<SpecialAreaBilling>() |
| | | .eq("state", 1)); |
| | | if(!CollectionUtils.isEmpty(specialAreaBillings)){ |
| | | // 判断起点或者终点在特殊区域中 |
| | | Iterator<SpecialAreaBilling> iterator = specialAreaBillings.iterator(); |
| | | while (iterator.hasNext()) { |
| | | SpecialAreaBilling specialAreaBilling = iterator.next(); |
| | | // 起点 |
| | | Double startLon = orderPrivateCar.getStartLon(); |
| | | Double startLat = orderPrivateCar.getStartLat(); |
| | | boolean start = ElectricFenceUtil.monitorElectricFenc(specialAreaBilling.getCoordinate(), startLon + "," + startLat); |
| | | // 终点 |
| | | Double endLon = orderPrivateCar.getEndLon(); |
| | | Double endLat = orderPrivateCar.getEndLat(); |
| | | boolean end = ElectricFenceUtil.monitorElectricFenc(specialAreaBilling.getCoordinate(), endLon + "," + endLat); |
| | | if(!start && !end){ |
| | | iterator.remove(); |
| | | } |
| | | } |
| | | if(!CollectionUtils.isEmpty(specialAreaBillings)){ |
| | | // 拿到价格系数最高的特殊区域 |
| | | specialAreaBillings.sort(new Comparator<SpecialAreaBilling>() { |
| | | @Override |
| | | public int compare(SpecialAreaBilling o1, SpecialAreaBilling o2) { |
| | | return o2.getPriceCoefficient().compareTo(o1.getPriceCoefficient()); |
| | | } |
| | | }); |
| | | BigDecimal priceCoefficient = specialAreaBillings.get(0).getPriceCoefficient(); |
| | | orderPrivateCar.setOrderMoney(Objects.nonNull(orderPrivateCar.getOrderMoney())?new BigDecimal(orderPrivateCar.getOrderMoney()).multiply(priceCoefficient).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue():0D); |
| | | orderPrivateCar.setStartMoney(Objects.nonNull(orderPrivateCar.getStartMoney())?new BigDecimal(orderPrivateCar.getStartMoney()).multiply(priceCoefficient).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue():0D); |
| | | orderPrivateCar.setMileageMoney(Objects.nonNull(orderPrivateCar.getMileageMoney())?new BigDecimal(orderPrivateCar.getMileageMoney()).multiply(priceCoefficient).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue():0D); |
| | | orderPrivateCar.setDurationMoney(Objects.nonNull(orderPrivateCar.getDurationMoney())?new BigDecimal(orderPrivateCar.getDurationMoney()).multiply(priceCoefficient).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue():0D); |
| | | orderPrivateCar.setWaitMoney(Objects.nonNull(orderPrivateCar.getWaitMoney())?new BigDecimal(orderPrivateCar.getWaitMoney()).multiply(priceCoefficient).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue():0D); |
| | | orderPrivateCar.setLongDistanceMoney(Objects.nonNull(orderPrivateCar.getLongDistanceMoney())?new BigDecimal(orderPrivateCar.getLongDistanceMoney()).multiply(priceCoefficient).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue():0D); |
| | | orderPrivateCar.setParkMoney(Objects.nonNull(orderPrivateCar.getParkMoney())?new BigDecimal(orderPrivateCar.getParkMoney()).multiply(priceCoefficient).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue():0D); |
| | | orderPrivateCar.setRoadTollMoney(Objects.nonNull(orderPrivateCar.getRoadTollMoney())?new BigDecimal(orderPrivateCar.getRoadTollMoney()).multiply(priceCoefficient).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue():0D); |
| | | } |
| | | } |
| | | |
| | | orderPrivateCar.setPayManner(type); |
| | | orderPrivateCar.setParkMoney(null == parkingFee ? 0D : parkingFee); |
| | | orderPrivateCar.setRoadTollMoney(null == crossingFee ? 0D : crossingFee); |
| | |
| | | // orderPrivateCar.setTelX(""); |
| | | // orderPrivateCar.setBindId(""); |
| | | // } |
| | | // 判断预估金额和订单金额差异是否大于3元 |
| | | if(BigDecimal.valueOf(orderPrivateCar.getOrderMoney()).subtract(orderPrivateCar.getEstimatedPrice()).abs().doubleValue() > 3){ |
| | | orderPrivateCar.setIsException(1); |
| | | } |
| | | if(orderPrivateCar.getIsException() == 1){ |
| | | orderPrivateCar.setState(13); |
| | | } |
| | | this.updateById(orderPrivateCar); |
| | | |
| | | |
| | |
| | | @Override |
| | | public boolean calculateMileage(Integer orderId, String lon, String lat) throws Exception { |
| | | OrderPrivateCar orderPrivateCar = this.selectById(orderId); |
| | | // 判断距离上一次推送时间是否超过1分钟 |
| | | if(Objects.nonNull(orderPrivateCar.getLastPushTime())){ |
| | | LocalDateTime now = LocalDateTime.now(); |
| | | if(Duration.between(orderPrivateCar.getLastPushTime(), now).toMinutes() > 1){ |
| | | orderPrivateCar.setIsException(1); |
| | | } |
| | | orderPrivateCar.setLastPushTime(now); |
| | | }else { |
| | | orderPrivateCar.setLastPushTime(LocalDateTime.now()); |
| | | } |
| | | OrderPosition orderPosition = orderPositionService.queryNew(orderId, 1); |
| | | String now = lon + "," + lat; |
| | | String old = null; |
| | |
| | | orderPrivateCar.setTrackId(String.valueOf(trackId)); |
| | | this.updateById(orderPrivateCar); |
| | | } |
| | | |
| | | @Override |
| | | public void updatePrice(Integer orderId, Integer priceType, BigDecimal updatePrice) { |
| | | OrderPrivateCar orderPrivateCar = this.selectById(orderId); |
| | | orderPrivateCar.setPriceType(priceType); |
| | | orderPrivateCar.setUpdatePrice(updatePrice); |
| | | orderPrivateCar.setPriceAuditState(1); |
| | | this.updateById(orderPrivateCar); |
| | | } |
| | | } |
New file |
| | |
| | | package com.stylefeng.guns.modular.system.dao; |
| | | |
| | | import com.baomidou.mybatisplus.mapper.BaseMapper; |
| | | import com.stylefeng.guns.modular.system.model.Phone; |
| | | import com.stylefeng.guns.modular.system.model.SpecialAreaBilling; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.util.List; |
| | | |
| | | public interface SpecialAreaBillingMapper extends BaseMapper<SpecialAreaBilling> { |
| | | |
| | | } |
New file |
| | |
| | | package com.stylefeng.guns.modular.system.model; |
| | | |
| | | import com.baomidou.mybatisplus.annotations.TableField; |
| | | import com.baomidou.mybatisplus.annotations.TableId; |
| | | import com.baomidou.mybatisplus.annotations.TableName; |
| | | import com.baomidou.mybatisplus.enums.IdType; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 特殊区域计费 |
| | | */ |
| | | @TableName("t_special_area_billing") |
| | | public class SpecialAreaBilling { |
| | | /** |
| | | * 主键 |
| | | */ |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | @TableField("id") |
| | | private Integer id; |
| | | /** |
| | | * 区域名称 |
| | | */ |
| | | @TableField("areaName") |
| | | private String areaName; |
| | | /** |
| | | * 价格系数 |
| | | */ |
| | | @TableField("priceCoefficient") |
| | | private BigDecimal priceCoefficient; |
| | | /** |
| | | * 备注 |
| | | */ |
| | | @TableField("remark") |
| | | private String remark; |
| | | /** |
| | | * 电子围栏坐标(多组以下划线分隔) |
| | | */ |
| | | @TableField("coordinate") |
| | | private String coordinate; |
| | | /** |
| | | * 电子围栏gid(多组以下划线分隔) |
| | | */ |
| | | @TableField("gid") |
| | | private String gid; |
| | | /** |
| | | * 状态(1=正常,2=冻结,3=删除) |
| | | */ |
| | | @TableField("state") |
| | | private Integer state; |
| | | /** |
| | | * 添加时间 |
| | | */ |
| | | @TableField("insertTime") |
| | | private Date insertTime; |
| | | |
| | | public Integer getId() { |
| | | return id; |
| | | } |
| | | |
| | | public void setId(Integer id) { |
| | | this.id = id; |
| | | } |
| | | |
| | | public String getAreaName() { |
| | | return areaName; |
| | | } |
| | | |
| | | public void setAreaName(String areaName) { |
| | | this.areaName = areaName; |
| | | } |
| | | |
| | | public BigDecimal getPriceCoefficient() { |
| | | return priceCoefficient; |
| | | } |
| | | |
| | | public void setPriceCoefficient(BigDecimal priceCoefficient) { |
| | | this.priceCoefficient = priceCoefficient; |
| | | } |
| | | |
| | | public String getRemark() { |
| | | return remark; |
| | | } |
| | | |
| | | public void setRemark(String remark) { |
| | | this.remark = remark; |
| | | } |
| | | |
| | | public String getCoordinate() { |
| | | return coordinate; |
| | | } |
| | | |
| | | public void setCoordinate(String coordinate) { |
| | | this.coordinate = coordinate; |
| | | } |
| | | |
| | | public String getGid() { |
| | | return gid; |
| | | } |
| | | |
| | | public void setGid(String gid) { |
| | | this.gid = gid; |
| | | } |
| | | |
| | | public Integer getState() { |
| | | return state; |
| | | } |
| | | |
| | | public void setState(Integer state) { |
| | | this.state = state; |
| | | } |
| | | |
| | | public Date getInsertTime() { |
| | | return insertTime; |
| | | } |
| | | |
| | | public void setInsertTime(Date insertTime) { |
| | | this.insertTime = insertTime; |
| | | } |
| | | |
| | | @Override |
| | | public String toString() { |
| | | return "SpecialAreaBilling{" + |
| | | "id=" + id + |
| | | ", areaName='" + areaName + '\'' + |
| | | ", priceCoefficient=" + priceCoefficient + |
| | | ", remark='" + remark + '\'' + |
| | | ", coordinate='" + coordinate + '\'' + |
| | | ", gid='" + gid + '\'' + |
| | | ", state=" + state + |
| | | ", insertTime=" + insertTime + |
| | | '}'; |
| | | } |
| | | } |
| | |
| | | import com.stylefeng.guns.modular.system.util.ResultUtil; |
| | | import com.stylefeng.guns.modular.system.warpper.OrderListWarpper; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | |
| | | * @return |
| | | */ |
| | | void getTrackId(Integer orderId, Integer orderType, Integer trackId); |
| | | |
| | | /** |
| | | * 修改订单价格 |
| | | * @param orderId |
| | | * @param orderType |
| | | * @param priceType |
| | | * @param updatePrice |
| | | * @return |
| | | */ |
| | | void updatePrice(Integer orderId, Integer orderType, Integer priceType, BigDecimal updatePrice); |
| | | } |
New file |
| | |
| | | package com.stylefeng.guns.modular.system.service; |
| | | |
| | | import com.baomidou.mybatisplus.service.IService; |
| | | import com.stylefeng.guns.modular.system.model.Phone; |
| | | import com.stylefeng.guns.modular.system.model.SpecialAreaBilling; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | public interface ISpecialAreaBillingService extends IService<SpecialAreaBilling> { |
| | | |
| | | } |
| | |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.*; |
| | |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void updatePrice(Integer orderId, Integer orderType, Integer priceType, BigDecimal updatePrice) { |
| | | switch (orderType){ |
| | | case 1: |
| | | orderPrivateCarService.updatePrice(orderId,priceType,updatePrice); |
| | | break; |
| | | case 2: |
| | | break; |
| | | } |
| | | } |
| | | |
| | | @Autowired |
| | | private ISystemNoticeService systemNoticeService; |
| | | |
New file |
| | |
| | | package com.stylefeng.guns.modular.system.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import com.stylefeng.guns.modular.system.dao.PhoneMapper; |
| | | import com.stylefeng.guns.modular.system.dao.SpecialAreaBillingMapper; |
| | | import com.stylefeng.guns.modular.system.model.Phone; |
| | | import com.stylefeng.guns.modular.system.model.SpecialAreaBilling; |
| | | import com.stylefeng.guns.modular.system.service.IPhoneService; |
| | | import com.stylefeng.guns.modular.system.service.ISpecialAreaBillingService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | |
| | | @Service |
| | | public class SpecialAreaBillingServiceImpl extends ServiceImpl<SpecialAreaBillingMapper, SpecialAreaBilling> implements ISpecialAreaBillingService { |
| | | |
| | | } |
New file |
| | |
| | | package com.stylefeng.guns.modular.system.util; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 电子围栏工具类 |
| | | */ |
| | | public class ElectricFenceUtil { |
| | | |
| | | // public static void main(String[] args) { |
| | | // boolean b = monitorElectricFenc("30.96233482687816,114.0918266313389;30.688443972530024,113.79746988182933;30.278129271486836,114.13781987344977;30.250180498063333,114.57475567350305;30.513377702529993,114.74493066931328;30.755997553111357,114.7725266145798;30.966298453688317,114.5747556735030", "114.311754,30.598604"); |
| | | // System.err.println(b); |
| | | // } |
| | | |
| | | |
| | | /** |
| | | * @return |
| | | */ |
| | | public static boolean monitorElectricFenc(String coordinate, String locations){ |
| | | return areaMonitoring(coordinate, locations); |
| | | } |
| | | public static boolean areaMonitoring(String coordinate, String lonLat){ |
| | | boolean flag = false; |
| | | String[] split = coordinate.split(";"); |
| | | List<Double> pointsX = new ArrayList<>(); |
| | | List<Double> pointsY = new ArrayList<>(); |
| | | for (String s : split) { |
| | | pointsX.add(Double.valueOf(s.split(",")[1])); |
| | | pointsY.add(Double.valueOf(s.split(",")[0])); |
| | | } |
| | | String lon1 = lonLat.split(",")[0]; |
| | | String lat1 = lonLat.split(",")[1]; |
| | | boolean inPolygon = isInPolygon(Double.valueOf(lon1), Double.valueOf(lat1), pointsX, pointsY); |
| | | if (inPolygon){ |
| | | flag = true; |
| | | } |
| | | return flag; |
| | | } |
| | | |
| | | |
| | | /** |
| | | // * 判断点是否在多边形内 |
| | | // * @param px 测试点 |
| | | // * @param polygonXA 多边形的点 |
| | | // * @return boolean true:在多边形内, false:在多边形外 |
| | | // * @throws |
| | | // * @Title: IsPointInPoly |
| | | // */ |
| | | public static boolean isInPolygon(double px, double py,List<Double> polygonXA, List<Double> polygonYA) { |
| | | boolean isInside = false; |
| | | double ESP = 1e-9; |
| | | int count = 0; |
| | | double linePoint1x; |
| | | double linePoint1y; |
| | | double linePoint2x = 180; |
| | | double linePoint2y; |
| | | |
| | | linePoint1x = px; |
| | | linePoint1y = py; |
| | | linePoint2y = py; |
| | | |
| | | for (int i = 0; i < polygonXA.size() - 1; i++) { |
| | | double cx1 = polygonXA.get(i); |
| | | double cy1 = polygonYA.get(i); |
| | | double cx2 = polygonXA.get(i + 1); |
| | | double cy2 = polygonYA.get(i + 1); |
| | | if (isPointOnLine(px, py, cx1, cy1, cx2, cy2)) { |
| | | return true; |
| | | } |
| | | if (Math.abs(cy2 - cy1) < ESP) { |
| | | continue; |
| | | } |
| | | |
| | | if (isPointOnLine(cx1, cy1, linePoint1x, linePoint1y, linePoint2x, |
| | | linePoint2y)) { |
| | | if (cy1 > cy2) |
| | | count++; |
| | | } else if (isPointOnLine(cx2, cy2, linePoint1x, linePoint1y, |
| | | linePoint2x, linePoint2y)) { |
| | | if (cy2 > cy1) |
| | | count++; |
| | | } else if (isIntersect(cx1, cy1, cx2, cy2, linePoint1x, |
| | | linePoint1y, linePoint2x, linePoint2y)) { |
| | | count++; |
| | | } |
| | | } |
| | | if (count % 2 == 1) { |
| | | isInside = true; |
| | | } |
| | | |
| | | return isInside; |
| | | } |
| | | public static double Multiply(double px0, double py0, double px1, double py1, |
| | | double px2, double py2) { |
| | | return ((px1 - px0) * (py2 - py0) - (px2 - px0) * (py1 - py0)); |
| | | } |
| | | |
| | | public static boolean isPointOnLine(double px0, double py0, double px1, |
| | | double py1, double px2, double py2) { |
| | | boolean flag = false; |
| | | double ESP = 1e-9; |
| | | if ((Math.abs(Multiply(px0, py0, px1, py1, px2, py2)) < ESP) |
| | | && ((px0 - px1) * (px0 - px2) <= 0) |
| | | && ((py0 - py1) * (py0 - py2) <= 0)) { |
| | | flag = true; |
| | | } |
| | | return flag; |
| | | } |
| | | |
| | | public static boolean isIntersect(double px1, double py1, double px2, double py2, |
| | | double px3, double py3, double px4, double py4) { |
| | | boolean flag = false; |
| | | double d = (px2 - px1) * (py4 - py3) - (py2 - py1) * (px4 - px3); |
| | | if (d != 0) { |
| | | double r = ((py1 - py3) * (px4 - px3) - (px1 - px3) * (py4 - py3)) |
| | | / d; |
| | | double s = ((py1 - py3) * (px2 - px1) - (px1 - px3) * (py2 - py1)) |
| | | / d; |
| | | if ((r >= 0) && (r <= 1) && (s >= 0) && (s <= 1)) { |
| | | flag = true; |
| | | } |
| | | } |
| | | return flag; |
| | | } |
| | | |
| | | } |
| | |
| | | private final static Logger logger = LoggerFactory.getLogger(GunsApplication.class); |
| | | |
| | | public static void main(String[] args) { |
| | | try{ |
| | | SpringApplication.run(GunsApplication.class, args); |
| | | logger.info("GunsApplication is success!"); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | @Bean //通过ip地址调用 |
| | |
| | | package com.stylefeng.guns.modular.system.model; |
| | | |
| | | import com.baomidou.mybatisplus.annotations.TableField; |
| | | import com.baomidou.mybatisplus.enums.FieldFill; |
| | | import com.baomidou.mybatisplus.enums.IdType; |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | |
| | | private String idCardPositive; |
| | | //身份证反面 |
| | | private String idCardReverse; |
| | | //限制接单分钟 |
| | | @TableField(value = "limitationTime") |
| | | private Integer limitationTime; |
| | | |
| | | public Integer getLimitationTime() { |
| | | return limitationTime; |
| | | } |
| | | |
| | | public void setLimitationTime(Integer limitationTime) { |
| | | this.limitationTime = limitationTime; |
| | | } |
| | | |
| | | public String getIdCardPositive() { |
| | | return idCardPositive; |
| | |
| | | package com.stylefeng.guns.modular.system.model; |
| | | |
| | | import com.baomidou.mybatisplus.annotations.TableField; |
| | | import com.baomidou.mybatisplus.enums.IdType; |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | import java.util.Date; |
| | | import com.baomidou.mybatisplus.annotations.TableId; |
| | | import com.baomidou.mybatisplus.activerecord.Model; |
| | | import com.baomidou.mybatisplus.annotations.TableName; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | |
| | | * 是否异常 1=是,0=否 |
| | | */ |
| | | private Integer isAbnormal; |
| | | @ApiModelProperty(value = "是否异常 1=是 0=否") |
| | | @TableField("isException") |
| | | private Integer isException; |
| | | @ApiModelProperty(value = "修改后的价格") |
| | | @TableField("updatePrice") |
| | | private BigDecimal updatePrice; |
| | | @ApiModelProperty(value = "价格类型 1=原价格 2=预估价 3=修改价") |
| | | @TableField("priceType") |
| | | private Integer priceType; |
| | | @ApiModelProperty(value = "预估价") |
| | | @TableField("estimatedPrice") |
| | | private BigDecimal estimatedPrice; |
| | | |
| | | @ApiModelProperty(value = "上一次定位推送时间") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | @TableField("lastPushTime") |
| | | private LocalDateTime lastPushTime; |
| | | |
| | | @ApiModelProperty(value = "修改价格审核 1=待审核 2=通过") |
| | | @TableField("priceAuditState") |
| | | private Integer priceAuditState; |
| | | |
| | | public Integer getPriceAuditState() { |
| | | return priceAuditState; |
| | | } |
| | | |
| | | public void setPriceAuditState(Integer priceAuditState) { |
| | | this.priceAuditState = priceAuditState; |
| | | } |
| | | |
| | | public LocalDateTime getLastPushTime() { |
| | | return lastPushTime; |
| | | } |
| | | |
| | | public void setLastPushTime(LocalDateTime lastPushTime) { |
| | | this.lastPushTime = lastPushTime; |
| | | } |
| | | |
| | | public Integer getIsException() { |
| | | return isException; |
| | | } |
| | | |
| | | public void setIsException(Integer isException) { |
| | | this.isException = isException; |
| | | } |
| | | |
| | | public BigDecimal getUpdatePrice() { |
| | | return updatePrice; |
| | | } |
| | | |
| | | public void setUpdatePrice(BigDecimal updatePrice) { |
| | | this.updatePrice = updatePrice; |
| | | } |
| | | |
| | | public Integer getPriceType() { |
| | | return priceType; |
| | | } |
| | | |
| | | public void setPriceType(Integer priceType) { |
| | | this.priceType = priceType; |
| | | } |
| | | |
| | | public BigDecimal getEstimatedPrice() { |
| | | return estimatedPrice; |
| | | } |
| | | |
| | | public void setEstimatedPrice(BigDecimal estimatedPrice) { |
| | | this.estimatedPrice = estimatedPrice; |
| | | } |
| | | public Integer getIsAbnormal() { |
| | | return isAbnormal; |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取空闲司机数量前十位 |
| | | * @param type 业务类型(1=专车,2=快车,3=城际,4=小件物流-同城,5=小件物流-跨城,6=公务用车) |
| | | * @return |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/base/driver/queryDriverLimitTen") |
| | | @ApiOperation(value = "获取空闲司机数量前十位[0731]", tags = {"用户端-首页"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "业务类型(1=专车,2=快车,3=城际,4=小件物流-同城,5=小件物流-跨城,6=公务用车)", name = "type", required = true, dataType = "int"), |
| | | @ApiImplicitParam(value = "乘客当前定位经度", name = "lon", required = true, dataType = "double"), |
| | | @ApiImplicitParam(value = "乘客当前定位纬度", name = "lat", required = true, dataType = "double") |
| | | }) |
| | | public ResultUtil<BaseWarpper> queryDriverLimitTen(Integer type, Double lon, Double lat){ |
| | | try { |
| | | List<Driver> list = driverService.queryDriverLimitTen(type, lon, lat); |
| | | BaseWarpper baseWarpper = new BaseWarpper(); |
| | | baseWarpper.setNumber(list.size()); |
| | | return ResultUtil.success(baseWarpper); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return ResultUtil.runErr(); |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | | |
| | | @Api |
| | |
| | | @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(value = "预估价", name = "estimatedPrice", required = false, dataType = "BigDecimal"), |
| | | @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){ |
| | | Integer type, BigDecimal estimatedPrice, 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); |
| | | startLon, startLat, startAddress, endLon, endLat, endAddress, passengers, passengersPhone, orderSource, driverId, type, uid,estimatedPrice); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return ResultUtil.runErr(); |
| | |
| | | import com.baomidou.mybatisplus.annotations.TableId; |
| | | import com.baomidou.mybatisplus.annotations.TableName; |
| | | import com.baomidou.mybatisplus.enums.IdType; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | |
| | | private BigDecimal freeMoney; |
| | | |
| | | private Integer isplatPay; |
| | | @ApiModelProperty(value = "是否异常 1=是 0=否") |
| | | @TableField("isException") |
| | | private Integer isException; |
| | | @ApiModelProperty(value = "修改后的价格") |
| | | @TableField("updatePrice") |
| | | private BigDecimal updatePrice; |
| | | @ApiModelProperty(value = "价格类型 1=原价格 2=预估价 3=修改价") |
| | | @TableField("priceType") |
| | | private Integer priceType; |
| | | @ApiModelProperty(value = "预估价") |
| | | @TableField("estimatedPrice") |
| | | private BigDecimal estimatedPrice; |
| | | |
| | | @ApiModelProperty(value = "上一次定位推送时间") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | @TableField("lastPushTime") |
| | | private LocalDateTime lastPushTime; |
| | | |
| | | @ApiModelProperty(value = "修改价格审核 1=待审核 2=通过") |
| | | @TableField("priceAuditState") |
| | | private Integer priceAuditState; |
| | | |
| | | public Integer getPriceAuditState() { |
| | | return priceAuditState; |
| | | } |
| | | |
| | | public void setPriceAuditState(Integer priceAuditState) { |
| | | this.priceAuditState = priceAuditState; |
| | | } |
| | | |
| | | public LocalDateTime getLastPushTime() { |
| | | return lastPushTime; |
| | | } |
| | | |
| | | public void setLastPushTime(LocalDateTime lastPushTime) { |
| | | this.lastPushTime = lastPushTime; |
| | | } |
| | | |
| | | public Integer getIsException() { |
| | | return isException; |
| | | } |
| | | |
| | | public void setIsException(Integer isException) { |
| | | this.isException = isException; |
| | | } |
| | | |
| | | public BigDecimal getUpdatePrice() { |
| | | return updatePrice; |
| | | } |
| | | |
| | | public void setUpdatePrice(BigDecimal updatePrice) { |
| | | this.updatePrice = updatePrice; |
| | | } |
| | | |
| | | public Integer getPriceType() { |
| | | return priceType; |
| | | } |
| | | |
| | | public void setPriceType(Integer priceType) { |
| | | this.priceType = priceType; |
| | | } |
| | | |
| | | public BigDecimal getEstimatedPrice() { |
| | | return estimatedPrice; |
| | | } |
| | | |
| | | public void setEstimatedPrice(BigDecimal estimatedPrice) { |
| | | this.estimatedPrice = estimatedPrice; |
| | | } |
| | | public Integer getIsplatPay() { |
| | | return isplatPay; |
| | | } |
| | |
| | | import com.stylefeng.guns.modular.system.warpper.OrderServerWarpper; |
| | | import com.stylefeng.guns.modular.taxi.model.OrderTaxi; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | |
| | | * @throws Exception |
| | | */ |
| | | ResultUtil<BaseWarpper> saveOrderPrivateCar(Integer serverCarModelId, Date travelTime, Integer reservation, Integer instead, String placementLon, String placementLat, |
| | | String startLon, String startLat, String startAddress, String endLon, String endLat, String endAddress, String name, String phone, Integer orderSource, Integer driverId, Integer type, Integer uid) throws Exception; |
| | | String startLon, String startLat, String startAddress, String endLon, String endLat, String endAddress, String name, |
| | | String phone, Integer orderSource, Integer driverId, Integer type, Integer uid, BigDecimal estimatedPrice) throws Exception; |
| | | |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Override |
| | | public synchronized ResultUtil<BaseWarpper> saveOrderPrivateCar(Integer serverCarModelId, Date travelTime, Integer reservation, Integer instead, String placementLon, String placementLat, String startLon, String startLat, |
| | | String startAddress, String endLon, String endLat, String endAddress, String name, String phone, Integer orderSource, Integer driverId, Integer type, Integer uid) throws Exception { |
| | | String startAddress, String endLon, String endLat, String endAddress, String name, String phone, Integer orderSource, Integer driverId, Integer type, Integer uid,BigDecimal estimatedPrice) throws Exception { |
| | | |
| | | //如果出行时间大于当前10分钟则默认为预约单 |
| | | if(travelTime.getTime() > (System.currentTimeMillis() + 600000)){ |
| | |
| | | orderPrivateCar.setTravelTime(travelTime); |
| | | orderPrivateCar.setOrderType(reservation); |
| | | orderPrivateCar.setOrderSource(orderSource); |
| | | orderPrivateCar.setEstimatedPrice(estimatedPrice); |
| | | if(orderSource == 2){//扫码下单 |
| | | Driver driver = driverService.selectById(driverId); |
| | | if(null == driver){ |
| | |
| | | } |
| | | // 判断该司机是否有30分钟内预约单 |
| | | long count = orderPrivateCarss.stream().filter(s -> s.getDriverId().equals(driver1.getId()) && |
| | | DateUtil.dateToLocalDateTime(s.getTravelTime()).minusMinutes(30).isBefore(LocalDateTime.now())).count(); |
| | | DateUtil.dateToLocalDateTime(s.getTravelTime()).minusMinutes(query.getLimitationTime()).isBefore(LocalDateTime.now())).count(); |
| | | if (count > 0) { |
| | | continue; |
| | | } |
| | |
| | | for(Driver driver : list){//开始进行推送 |
| | | // 判断该司机是否有30分钟内预约单 |
| | | long count = orderPrivateCars.stream().filter(orderPrivateCar1 -> driver.getId().equals(orderPrivateCar1.getDriverId()) |
| | | && DateUtil.dateToLocalDateTime(orderPrivateCar1.getTravelTime()).minusMinutes(31).isBefore(LocalDateTime.now()) |
| | | && DateUtil.dateToLocalDateTime(orderPrivateCar1.getTravelTime()).minusMinutes(query.getLimitationTime()).isBefore(LocalDateTime.now()) |
| | | && DateUtil.dateToLocalDateTime(orderPrivateCar1.getTravelTime()).isAfter(LocalDateTime.now())).count(); |
| | | if(orderPrivateCar.getOrderType() == 2 && orderPrivateCarDriverIds.contains(driver.getId())){ |
| | | continue; |
| | |
| | | if(i == querys.size() && state == 1){ |
| | | pushUtil.pushEndPush(1, orderPrivateCar.getUserId(), orderPrivateCar.getId(), 1); |
| | | orderIds.remove(orderPrivateCar.getId()); |
| | | |
| | | // 第三轮取消订单 |
| | | orderPrivateCar.setState(10); |
| | | orderPrivateCarMapper.updateById(orderPrivateCar); |
| | | // 添加站内信 |
| | | systemNoticeService.addSystemNotice(1, "当前区域未能及时为您匹配到合适车辆。为避免耽误您的行程,系统已自动取消订单,建议您稍后重新尝试。", orderPrivateCar.getUserId(), 1); |
| | | // TODO 0731 添加短信发送 |
| | | |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | |
| | | state as state, |
| | | flag as flag, |
| | | upload as upload, |
| | | insertTime as insertTime |
| | | insertTime as insertTime, |
| | | limitationTime as limitationTime |
| | | from t_company where flag != 3 and state = 0 and id in ( |
| | | select companyId from t_company_city where state = 1 |
| | | <if test="null != province and null != city and null != code"> |
| | |
| | | */ |
| | | @TableField("insertTime") |
| | | private Date insertTime; |
| | | //限制接单分钟 |
| | | @TableField(value = "limitationTime") |
| | | private Integer limitationTime; |
| | | |
| | | public Integer getLimitationTime() { |
| | | return limitationTime; |
| | | } |
| | | |
| | | public void setLimitationTime(Integer limitationTime) { |
| | | this.limitationTime = limitationTime; |
| | | } |
| | | public Integer getId() { |
| | | return id; |
| | | } |
| | |
| | | * @throws Exception |
| | | */ |
| | | List<BaseWarpper> queryBusiness(Integer uid) throws Exception; |
| | | |
| | | List<Driver> queryDriverLimitTen(Integer type, Double lon, Double lat); |
| | | } |
| | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Service |
| | | public class DriverServiceImpl extends ServiceImpl<DriverMapper, Driver> implements IDriverService { |
| | |
| | | } |
| | | return maps; |
| | | } |
| | | |
| | | @Override |
| | | public List<Driver> queryDriverLimitTen(Integer type, Double lon, Double lat) { |
| | | List<Driver> drivers = driverMapper.queryIdleDriver(type, null); |
| | | if(drivers.size() > 10){ |
| | | return drivers.stream().limit(10).collect(Collectors.toList()); |
| | | }else { |
| | | return drivers; |
| | | } |
| | | } |
| | | } |