puzhibing
2023-08-25 dccf96f22efad58f24fe496391c13339bd840d35
user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/OrderServiceImpl.java
@@ -119,6 +119,9 @@
    @Resource
    private ICompanyFundFlowService companyFundFlowService;
    @Autowired
    private IBranchOfficeService branchOfficeService;
    @Value("${wx.appletsAppid}")
    private String appletsAppid;
@@ -151,15 +154,28 @@
            estimatedCostsWarpper.setTravelTime(Integer.valueOf(distance.get("duration")) / 60);
        }
        String city = "";
        Integer branchOfficeId = null;
        District geocode = MapUtil.geocode(estimatedCosts.getStartLng().toString(), estimatedCosts.getStartLat().toString());
        if(null != geocode){
            WeatherCity weatherCity = weatherCityService.selectOne(new EntityWrapper<WeatherCity>()
                    .where("'" + geocode.getCity() + "' like CONCAT('%', city, '%') and '" + geocode.getDistrict() + "' like CONCAT('%', district, '%') "));
            city = null != weatherCity ? weatherCity.getId().toString() : "";
            String districtCode = geocode.getDistrictCode();
            BranchOffice branchOffice = branchOfficeService.selectOne(new EntityWrapper<BranchOffice>().eq("status", 1).eq("districtCode", districtCode));
            if(null == branchOffice){
                String cityCode = geocode.getCityCode();
                branchOffice = branchOfficeService.selectOne(new EntityWrapper<BranchOffice>().eq("status", 1).eq("cityCode", cityCode));
                if(null == branchOffice){
                    String provinceCode = geocode.getProvinceCode();
                    branchOffice = branchOfficeService.selectOne(new EntityWrapper<BranchOffice>().eq("status", 1).eq("provinceCode", provinceCode));
        }
            }
            if(null == branchOffice){
                return ResultUtil.error("起点暂无企业服务");
            }
            branchOfficeId = branchOffice.getId();
        }
        Order order1 = new Order();
        order1.setCreateTime(new Date());
        Order order = getOrderPrice(1, d, 0, order1, city);
        Order order = getOrderPrice(1, d, 0, order1, city, branchOfficeId);
        Double estimatedPrice = order.getEstimatedPrice();
        Coupon coupon = userToCouponService.queryCoupon(uid, estimatedPrice);
        if(null != coupon){
@@ -212,11 +228,9 @@
     * @param city          查询天气的城市
     * @return
     */
    public Order getOrderPrice(Integer type, Double distance, Integer waitTime, Order order, String city){
    public Order getOrderPrice(Integer type, Double distance, Integer waitTime, Order order, String city, Integer branchOfficeId){
        order = getOrderInitialPrice(order);
        Integer driverId = order.getDriverId();
        Driver driver = driverService.selectById(driverId);
        SystemConfig systemConfig = systemConfigService.selectOne(new EntityWrapper<SystemConfig>().eq("type", 5).eq("companyId",driver.getBranchOfficeId()));
        SystemConfig systemConfig = systemConfigService.selectOne(new EntityWrapper<SystemConfig>().eq("type", 5).eq("companyId", branchOfficeId));
        if(null == systemConfig){
            if(type == 1){//预估金额
                order.setEstimatedPrice(0D);
@@ -318,8 +332,6 @@
        Double num8 = extraCost.getDouble("num8");//恶劣天气超出公里单价 X/公里
        Double num9 = extraCost.getDouble("num9");//恶劣天气最高收取金额
        Double num10 = extraCost.getDouble("num10");//节假日收费
//        Double num11 = extraCost.getDouble("num11");//恶劣天气最高收取金额
//        Double num12 = extraCost.getDouble("num12");//恶劣天气最高收取金额
        //等待费用
        if(waitTime.compareTo(num1 * 60) >= 0){
@@ -333,13 +345,12 @@
        }
        //恶劣天气
        systemConfig = systemConfigService.selectOne(new EntityWrapper<SystemConfig>().eq("type", 8).eq("companyId",driver.getBranchOfficeId()));
        systemConfig = systemConfigService.selectOne(new EntityWrapper<SystemConfig>().eq("type", 8).eq("companyId", branchOfficeId));
        if(null != systemConfig){
            JSONObject jsonObject1 = JSON.parseObject(systemConfig.getContent());
            Integer num11 = jsonObject1.getInteger("num1");//开启恶劣天气计价
            Integer num31 = jsonObject1.getInteger("num3");
            if(1 == num11){
//                boolean badWeather = WeatherUtil.isBadWeather(city);
//                if(badWeather){
                    order.setBadWeatherDistance(num5);//恶劣天气公里
                    order.setBadWeatherPrice(num6);//恶劣天气费
                    if(distance.compareTo(num7) > 0){
@@ -359,20 +370,9 @@
                            order.setOverBadWeatherPrice(subtract.doubleValue());//恶劣天气超出公里费
                        }
                    }
//                }
            }
        }
        //节假日
        systemConfig = systemConfigService.selectOne(new EntityWrapper<SystemConfig>().eq("type", 9).eq("companyId",driver.getBranchOfficeId()));
        if(null != systemConfig){
            JSONObject jsonObject1 = JSON.parseObject(systemConfig.getContent());
            Integer num11 = jsonObject1.getInteger("num1");//开启恶劣天气计价
            if(1 == num11){
                BigDecimal bigDecimal = new BigDecimal(num10);
                order.setHolidayPrice(bigDecimal.doubleValue());
            if(1 == num31){//节假日
                order.setHolidayPrice(num10);
            }
        }
@@ -414,6 +414,7 @@
        order.setBadWeatherPrice(0D);//恶劣天气里程费
        order.setOverBadWeatherDistance(0D);//恶劣天气超出里程
        order.setOverBadWeatherPrice(0D);//恶劣天气超出里程费
        order.setHolidayPrice(0D);//节假日
        order.setDiscountedPrice(0D);//优惠金额
        order.setCouponId(null);//优惠券
        order.setDiscountAmount(0D);//折扣优惠金额
@@ -477,14 +478,27 @@
            order.setEstimatedTime(Integer.valueOf(distance.get("duration")) / 60);
        }
        String city = "";
        District geocode = MapUtil.geocode(order.getStartLng(), order.getStartLat());
        Integer branchOfficeId = null;
        District geocode = MapUtil.geocode(order.getStartLng().toString(), order.getStartLat().toString());
        if(null != geocode){
            WeatherCity weatherCity = weatherCityService.selectOne(new EntityWrapper<WeatherCity>()
                    .where("'" + geocode.getCity() + "' like CONCAT('%', city, '%') and '" + geocode.getDistrict() + "' like CONCAT('%', district, '%') "));
            city = null != weatherCity ? weatherCity.getId().toString() : "";
            String districtCode = geocode.getDistrictCode();
            BranchOffice branchOffice = branchOfficeService.selectOne(new EntityWrapper<BranchOffice>().eq("status", 1).eq("districtCode", districtCode));
            if(null == branchOffice){
                String cityCode = geocode.getCityCode();
                branchOffice = branchOfficeService.selectOne(new EntityWrapper<BranchOffice>().eq("status", 1).eq("cityCode", cityCode));
                if(null == branchOffice){
                    String provinceCode = geocode.getProvinceCode();
                    branchOffice = branchOfficeService.selectOne(new EntityWrapper<BranchOffice>().eq("status", 1).eq("provinceCode", provinceCode));
        }
            }
            if(null == branchOffice){
                return ResultUtil.error("起点暂无企业服务");
            }
            branchOfficeId = branchOffice.getId();
        }
        order.setCreateTime(new Date());
        order = getOrderPrice(1, d, 0, order, city);
        order = getOrderPrice(1, d, 0, order, city, branchOfficeId);
        if(null != travelOrder.getDriverId()){
            DriverWork driverWork = driverWorkService.selectOne(new EntityWrapper<DriverWork>().eq("driverId", travelOrder.getDriverId()).eq("status", 1));
            if(null == driverWork){
@@ -881,15 +895,27 @@
            order.setEstimatedTime(Integer.valueOf(distance.get("duration")) / 60);
        }
        String city = "";
        Integer branchOfficeId = null;
        District geocode = MapUtil.geocode(order.getStartLng().toString(), order.getStartLat().toString());
        if(null != geocode){
            WeatherCity weatherCity = weatherCityService.selectOne(new EntityWrapper<WeatherCity>()
                    .where("'" + geocode.getCity() + "' like CONCAT('%', city, '%') and '" + geocode.getDistrict() + "' like CONCAT('%', district, '%') "));
            city = null != weatherCity ? weatherCity.getId().toString() : "";
            String districtCode = geocode.getDistrictCode();
            BranchOffice branchOffice = branchOfficeService.selectOne(new EntityWrapper<BranchOffice>().eq("status", 1).eq("districtCode", districtCode));
            if(null == branchOffice){
                String cityCode = geocode.getCityCode();
                branchOffice = branchOfficeService.selectOne(new EntityWrapper<BranchOffice>().eq("status", 1).eq("cityCode", cityCode));
                if(null == branchOffice){
                    String provinceCode = geocode.getProvinceCode();
                    branchOffice = branchOfficeService.selectOne(new EntityWrapper<BranchOffice>().eq("status", 1).eq("provinceCode", provinceCode));
                }
            }
            if(null == branchOffice){
                return ResultUtil.error("起点暂无企业服务");
            }
            branchOfficeId = branchOffice.getId();
        }
        Order order1 = new Order();
        BeanUtils.copyProperties(order, order1);
        Order orderPrice = getOrderPrice(1, d, 0, order1, city);
        Order orderPrice = getOrderPrice(1, d, 0, order1, city, branchOfficeId);
        order.setEstimatedPrice(orderPrice.getEstimatedPrice());
        this.updateById(order);
@@ -942,6 +968,7 @@
        if(order.getState() < 107){
            orderPriceWarpper.setPayMoney(order.getOrderMoney());
        }
        orderPriceWarpper.setHolidayPrice(order.getHolidayPrice());
        return orderPriceWarpper;
    }