Pu Zhibing
2025-04-16 f42db41e022d2261818ca9c8560c4af482176097
提交1.1基础版本
5个文件已删除
1个文件已添加
6个文件已修改
31032 ■■■■■ 已修改文件
UserOKTravel/guns-admin/doc/Guns 技术文档 v1.0.pdf 补丁 | 查看 | 原始文档 | blame | 历史
UserOKTravel/guns-admin/replay_pid13628.log 4448 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
UserOKTravel/guns-admin/sql/guns.sql 384 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
UserOKTravel/guns-admin/sql/oktravel.sql 25883 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
UserOKTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/dao/SystemPriceMapper.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
UserOKTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/dao/mapping/SystemPriceMapper.xml 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
UserOKTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/taxi/controller/OrderTaxiController.java 60 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
UserOKTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/taxi/service/IOrderTaxiService.java 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
UserOKTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/taxi/service/impl/OrderTaxiServiceImpl.java 164 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
UserOKTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/taxi/warpper/ForecastPriceWarpper.java 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
UserOKTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/taxi/warpper/OrderTaxiWarpper.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
UserOKTravel/guns-rest/db/guns_rest.sql 38 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
UserOKTravel/guns-admin/doc/Guns 技术文档 v1.0.pdf
Binary files differ
UserOKTravel/guns-admin/replay_pid13628.log
File was deleted
UserOKTravel/guns-admin/sql/guns.sql
File was deleted
UserOKTravel/guns-admin/sql/oktravel.sql
File was deleted
UserOKTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/dao/SystemPriceMapper.java
@@ -17,4 +17,14 @@
     */
    Map<String, Object> query(@Param("companyId") Integer companyId, @Param("type") Integer type,
                              @Param("serverCarModelId") Integer serverCarModelId);
    /**
     * 获取价格
     * @param companyId
     * @param type
     * @return
     */
    Map<String, Object> query1(@Param("companyId") Integer companyId, @Param("type") Integer type);
}
UserOKTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/dao/mapping/SystemPriceMapper.xml
@@ -23,4 +23,14 @@
            and serverCarModelId = #{serverCarModelId}
        </if>
    </select>
    <select id="query1" resultType="map">
        select
        id as id,
        content as content
        from t_system_price where companyId = #{companyId}
        <if test="null != type">
            and `type` = #{type}
        </if>
    </select>
</mapper>
UserOKTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/taxi/controller/OrderTaxiController.java
@@ -1,23 +1,28 @@
package com.stylefeng.guns.modular.taxi.controller;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.stylefeng.guns.modular.system.dao.SystemPriceMapper;
import com.stylefeng.guns.modular.system.model.Company;
import com.stylefeng.guns.modular.system.service.*;
import com.stylefeng.guns.modular.system.util.GDMapElectricFenceUtil;
import com.stylefeng.guns.modular.system.util.MD5AndKL;
import com.stylefeng.guns.modular.system.util.ResultUtil;
import com.stylefeng.guns.modular.system.warpper.BaseWarpper;
import com.stylefeng.guns.modular.taxi.model.OrderTaxi;
import com.stylefeng.guns.modular.taxi.service.IOrderTaxiService;
import com.stylefeng.guns.modular.taxi.warpper.ForecastPriceWarpper;
import com.stylefeng.guns.modular.taxi.warpper.OrderTaxiWarpper;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.util.*;
/**
 * 出租车订单控制器
@@ -62,8 +67,51 @@
            return ResultUtil.runErr();
        }
    }
    @ResponseBody
    @GetMapping("/api/taxi/getForecastPrice")
    @ApiOperation(value = "出租车获取预估费用【1.1】", tags = {"用户端-出租车"}, notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
    })
    public ResultUtil<Double> getForecastPrice(ForecastPriceWarpper warpper){
        return orderTaxiService.getForecastPrice(warpper);
    }
    @ResponseBody
    @GetMapping("/api/taxi/getAllForecastPrice")
    @ApiOperation(value = "出租车获取两种计费预估费用【1.1】", tags = {"用户端-出租车"}, notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
    })
    public ResultUtil<Map<String, Double>> getAllForecastPrice(ForecastPriceWarpper warpper){
        try {
            warpper.setPayManner(1);
            ResultUtil<Double> resultUtil = orderTaxiService.getForecastPrice(warpper);
            if(resultUtil.getCode() != 200){
                return ResultUtil.error(resultUtil.getMsg());
            }
            double amount = resultUtil.getData();
            Map<String, Double> map = new HashMap<>();
            map.put("online", amount);
            amount = amount + (new BigDecimal(Math.random()).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
            map.put("offline", amount);
            return ResultUtil.success(map);
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
UserOKTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/taxi/service/IOrderTaxiService.java
@@ -7,6 +7,7 @@
import com.stylefeng.guns.modular.system.warpper.OrderServerWarpper;
import com.stylefeng.guns.modular.system.warpper.OrderStatusWarpper;
import com.stylefeng.guns.modular.taxi.model.OrderTaxi;
import com.stylefeng.guns.modular.taxi.warpper.ForecastPriceWarpper;
import com.stylefeng.guns.modular.taxi.warpper.OrderTaxiWarpper;
import java.util.Date;
@@ -27,8 +28,14 @@
     * @throws Exception
     */
    ResultUtil<BaseWarpper> taxiOrder(OrderTaxi orderTaxi, Integer uid,String areaCode) throws Exception;
    /**
     * 获取预估金额
     * @param warpper
     * @return
     */
    ResultUtil<Double> getForecastPrice(ForecastPriceWarpper warpper);
    /**
     * 继续推送操作
     * @param id
UserOKTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/taxi/service/impl/OrderTaxiServiceImpl.java
@@ -29,6 +29,7 @@
import com.stylefeng.guns.modular.taxi.service.IOrderTaxiService;
import com.stylefeng.guns.modular.taxi.service.IPaymentRecordService;
import com.stylefeng.guns.modular.taxi.service.ITransactionDetailsService;
import com.stylefeng.guns.modular.taxi.warpper.ForecastPriceWarpper;
import com.stylefeng.guns.modular.taxi.warpper.OrderTaxiWarpper;
import org.bouncycastle.crypto.tls.MACAlgorithm;
import org.springframework.beans.factory.annotation.Autowired;
@@ -155,6 +156,9 @@
    @Autowired
    private IOrderPrivateCarService orderPrivateCarService;
    @Resource
    private SystemPriceMapper systemPriceMapper;
    @Autowired
    private IOrderCrossCityService orderCrossCityService;
@@ -245,6 +249,18 @@
        UserInfo userInfo = userInfoService.selectById(uid);
        orderTaxi.setPassengersPhone(userInfo.getPhone());
        orderTaxi.setPassengers(userInfo.getNickName());
        //获取费用金额
        ForecastPriceWarpper warpper = new ForecastPriceWarpper();
        warpper.setPayManner(orderTaxi.getPayManner());
        warpper.setStartLat(orderTaxi.getStartLat());
        warpper.setStartLon(orderTaxi.getStartLon());
        warpper.setEndLat(orderTaxi.getEndLat());
        warpper.setEndLon(orderTaxi.getEndLon());
        ResultUtil<Double> forecastPrice = getForecastPrice(warpper);
        if(forecastPrice.getCode() != 200){
            return ResultUtil.error(forecastPrice.getMsg());
        }
        orderTaxi.setOrderMoney(forecastPrice.getData());
        if (!StringUtils.hasLength(orderTaxi.getPassengers())  || StringUtils.hasLength(orderTaxi.getPassengersPhone()) ){
            // 如果没有填写乘车人电话或者姓名 那么用用户的
@@ -333,8 +349,152 @@
        baseWarpper.setId(orderTaxi.getId());
        return ResultUtil.success(baseWarpper);
    }
    @Override
    public ResultUtil<Double> getForecastPrice(ForecastPriceWarpper warpper) {
        try {
            Company query = companyCityService.query(String.valueOf(warpper.getStartLon()), String.valueOf(warpper.getStartLat()));//获取起点所属分公司
            if(null == query){
                return ResultUtil.error("获取企业失败");
            }
            Map<String, String> distance = gdMapElectricFenceUtil.getDistance(warpper.getStartLon() + "," + warpper.getStartLat(),
                    warpper.getEndLon() + "," + warpper.getEndLat(), 1);
            if(null == distance){
                return ResultUtil.error("计算行驶距离失败");
            }
            double d = new BigDecimal(distance.get("distance")).divide(new BigDecimal(1000)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue();
            double t = new BigDecimal(distance.get("duration")).divide(new BigDecimal(60)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue();
            double amount = setMoney2(query.getId(), d, t);
            if(warpper.getPayManner() == 2){//其他支付,不需要操作,直接完成订单
                amount = amount + (new BigDecimal(Math.random()).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
            }
            return ResultUtil.success(amount);
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
    /**
     * 计算价格
     * @return
     * @throws Exception
     */
    public double setMoney2(Integer companyId, Double mileage, Double time) throws Exception {
        Map<String, Object> query1 = systemPriceMapper.query1(companyId, 2);
        //开始根据不同的方式计算金额
        JSONObject jsonObject = JSON.parseObject(String.valueOf(query1.get("content")));
        double amount = calculationPrice(jsonObject, mileage, time);
        return amount;
    }
    public double calculationPrice(JSONObject rule, double d, double t) throws Exception {
        double amount = 0.0;
        //等待费
        Date date = new Date();
        double d1 = (d - rule.getDouble("num2")) < 0 ? 0 : d - rule.getDouble("num2");//超出起步里程的公里
        double t1 = (t - rule.getDouble("num3")) < 0 ? 0 : t - rule.getDouble("num3");//超过起步分钟数的时间
        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(rule.getString("num14").split(" - ")[0].split(":")[0]));
        s.set(Calendar.MINUTE, Integer.valueOf(rule.getString("num14").split(" - ")[0].split(":")[1]));
        Calendar e = Calendar.getInstance();
        e.setTime(date);
        e.set(Calendar.HOUR_OF_DAY, Integer.valueOf(rule.getString("num14").split(" - ")[1].split(":")[0]));
        e.set(Calendar.MINUTE, Integer.valueOf(rule.getString("num14").split(" - ")[1].split(":")[1]));
        if(date.getTime() > s.getTimeInMillis() && date.getTime() < e.getTimeInMillis()){
            if(d > rule.getDouble("num6") && d < rule.getDouble("num7")){
                yt1 = rule.getDouble("num18") * d;
            }
            if(d >  rule.getDouble("num9") && d < rule.getDouble("num10")){
                yt1 = rule.getDouble("num18") * rule.getDouble("num7");
                yt2 = rule.getDouble("num19") * (d - rule.getDouble("num9"));
            }
            if(d > rule.getDouble("num12")){
                yt1 = rule.getDouble("num18") * rule.getDouble("num7");
                yt2 = rule.getDouble("num19") * (rule.getDouble("num10") - rule.getDouble("num9"));
                yt3 = rule.getDouble("num20") * (d - rule.getDouble("num12"));
            }
            Double startMoney = rule.getDouble("num15");//起步价
            Double mileageMoney = (new BigDecimal(d1 * rule.getDouble("num16")).setScale(2, BigDecimal.ROUND_DOWN).doubleValue());//里程费
            Double durationMoney = (new BigDecimal(t1 * rule.getDouble("num17")).setScale(2, BigDecimal.ROUND_DOWN).doubleValue());//时长费
            Double longDistanceMoney = (new BigDecimal(yt1 + yt2 + yt3).setScale(2, BigDecimal.ROUND_DOWN).doubleValue());//远途费
            amount = startMoney + mileageMoney + durationMoney + longDistanceMoney;
        }else{
            Calendar s1 = Calendar.getInstance();
            s1.setTime(date);
            s1.set(Calendar.HOUR_OF_DAY, Integer.valueOf(rule.getString("num21").split(" - ")[0].split(":")[0]));
            s1.set(Calendar.MINUTE, Integer.valueOf(rule.getString("num21").split(" - ")[0].split(":")[1]));
            Calendar e1 = Calendar.getInstance();
            e1.setTime(date);
            e1.set(Calendar.HOUR_OF_DAY, Integer.valueOf(rule.getString("num21").split(" - ")[1].split(":")[0]));
            e1.set(Calendar.MINUTE, Integer.valueOf(rule.getString("num21").split(" - ")[1].split(":")[1]));
            Calendar s2 = Calendar.getInstance();
            s2.setTime(date);
            s2.set(Calendar.HOUR_OF_DAY, Integer.valueOf(rule.getString("num22").split(" - ")[0].split(":")[0]));
            s2.set(Calendar.MINUTE, Integer.valueOf(rule.getString("num22").split(" - ")[0].split(":")[1]));
            Calendar e2 = Calendar.getInstance();
            e2.setTime(date);
            e2.set(Calendar.HOUR_OF_DAY, Integer.valueOf(rule.getString("num22").split(" - ")[1].split(":")[0]));
            e2.set(Calendar.MINUTE, Integer.valueOf(rule.getString("num22").split(" - ")[1].split(":")[1]));
            //高峰时段处理逻辑
            if((date.getTime() > s1.getTimeInMillis() && date.getTime() < e1.getTimeInMillis()) || (date.getTime() > s2.getTimeInMillis() && date.getTime() < e2.getTimeInMillis())){
                if(d > rule.getDouble("num6") && d < rule.getDouble("num7")){
                    yt1 = rule.getDouble("num26") * d;
                }
                if(d >  rule.getDouble("num9") && d < rule.getDouble("num10")){
                    yt1 = rule.getDouble("num26") * rule.getDouble("num7");
                    yt2 = rule.getDouble("num27") * (d - rule.getDouble("num9"));
                }
                if(d > rule.getDouble("num12")){
                    yt1 = rule.getDouble("num26") * rule.getDouble("num7");
                    yt2 = rule.getDouble("num27") * (rule.getDouble("num10") - rule.getDouble("num9"));
                    yt3 = rule.getDouble("num28") * (d - rule.getDouble("num12"));
                }
                Double startMoney = (rule.getDouble("num23"));//起步价
                Double mileageMoney = (new BigDecimal(d1 * rule.getDouble("num24")).setScale(2, BigDecimal.ROUND_DOWN).doubleValue());//里程费
                Double durationMoney = (new BigDecimal(t1 * rule.getDouble("num25")).setScale(2, BigDecimal.ROUND_DOWN).doubleValue());//时长费
                Double longDistanceMoney = (new BigDecimal(yt1 + yt2 + yt3).setScale(2, BigDecimal.ROUND_DOWN).doubleValue());//远途费
                amount = startMoney + mileageMoney + durationMoney + longDistanceMoney;
            }else{
                //其他时间段的计算
                if(d > rule.getDouble("num6") && d < rule.getDouble("num7")){
                    yt1 = rule.getDouble("num8") * d;
                }
                if(d >  rule.getDouble("num9") && d < rule.getDouble("num10")){
                    yt1 = rule.getDouble("num8") * rule.getDouble("num7");
                    yt2 = rule.getDouble("num11") * (d - rule.getDouble("num9"));
                }
                if(d > rule.getDouble("num12")){
                    yt1 = rule.getDouble("num8") * rule.getDouble("num7");
                    yt2 = rule.getDouble("num11") * (rule.getDouble("num10") - rule.getDouble("num9"));
                    yt3 = rule.getDouble("num13") * (d - rule.getDouble("num12"));
                }
                Double startMoney = (rule.getDouble("num1"));//起步价
                Double mileageMoney = (new BigDecimal(d1 * rule.getDouble("num4")).setScale(2, BigDecimal.ROUND_DOWN).doubleValue());//里程费
                Double durationMoney = (new BigDecimal(t1 * rule.getDouble("num5")).setScale(2, BigDecimal.ROUND_DOWN).doubleValue());//时长费
                Double longDistanceMoney = (new BigDecimal(yt1 + yt2 + yt3).setScale(2, BigDecimal.ROUND_DOWN).doubleValue());//远途费
                amount = startMoney + mileageMoney + durationMoney + longDistanceMoney;
            }
        }
        return amount;
    }
    /**
     * 继续执行推动等待操作
     * @param id
UserOKTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/taxi/warpper/ForecastPriceWarpper.java
New file
@@ -0,0 +1,22 @@
package com.stylefeng.guns.modular.taxi.warpper;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
 * @author zhibing.pu
 * @Date 2025/4/15 22:04
 */
@Data
public class ForecastPriceWarpper {
    @ApiModelProperty(dataType = "double", required = true, value = "起点经度")
    private Double startLon;
    @ApiModelProperty(dataType = "double", required = true, value = "起点纬度")
    private Double startLat;
    @ApiModelProperty(dataType = "double", required = true, value = "终点经度")
    private Double endLon;
    @ApiModelProperty(dataType = "double", required = true, value = "终点纬度")
    private Double endLat;
    @ApiModelProperty(dataType = "int", required = false, value = "支付方式 1=线上计费 2=打表计费")
    private Integer payManner;
}
UserOKTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/taxi/warpper/OrderTaxiWarpper.java
@@ -46,7 +46,7 @@
    @ApiModelProperty(dataType = "int", required = true, value = "是否是老年人(0=否,1=是)")
    private Integer oldPeople;
    @ApiModelProperty(dataType = "int", required = true, value = "支付方式 1=平台支付 2=其他支付")
    @ApiModelProperty(dataType = "int", required = true, value = "支付方式 1=线上计费 2=打表计费")
    private Integer payManner;
    @ApiModelProperty(dataType = "int", required = true, value = "区域code")
    private String areaCode;
UserOKTravel/guns-rest/db/guns_rest.sql
File was deleted