| | |
| | | .where("'" + geocode.getCity() + "' like CONCAT('%', city, '%') and '" + geocode.getDistrict() + "' like CONCAT('%', district, '%') ")); |
| | | city = null != weatherCity ? weatherCity.getId().toString() : ""; |
| | | } |
| | | order = getOrderPrice(1, d, 0, order, city); |
| | | order.setCreateTime(new Date()); |
| | | order = getOrderPrice(1, d, 0D, order, city); |
| | | order.setState(null == order.getDriverId() ? 101 : 102); |
| | | order.setStatus(1); |
| | | order.setCreateTime(new Date()); |
| | | this.insert(order); |
| | | driverService.updateById(driver); |
| | | //推送状态 |
| | |
| | | * @param city 查询天气的城市 |
| | | * @return |
| | | */ |
| | | public Order getOrderPrice(Integer type, Double distance, Integer waitTime, Order order, String city){ |
| | | public Order getOrderPrice(Integer type, Double distance, Double waitTime, Order order, String city){ |
| | | distance = new BigDecimal(distance).setScale(0, BigDecimal.ROUND_UP).doubleValue(); |
| | | waitTime = new BigDecimal(waitTime).setScale(0, BigDecimal.ROUND_UP).doubleValue(); |
| | | order = getOrderInitialPrice(order); |
| | | SystemConfig systemConfig = systemConfigService.selectOne(new EntityWrapper<SystemConfig>().eq("type", 5)); |
| | | if(null == systemConfig){ |
| | |
| | | JSONObject jsonObject = JSON.parseObject(systemConfig.getContent()); |
| | | JSONArray chargeStandard = jsonObject.getJSONArray("ChargeStandard"); |
| | | JSONObject extraCost = jsonObject.getJSONObject("ExtraCost"); |
| | | Date date = new Date(); |
| | | Date date = order.getCreateTime(); |
| | | for (int i = 0; i < chargeStandard.size(); i++) { |
| | | JSONObject jsonObject1 = chargeStandard.getJSONObject(i); |
| | | String num1 = jsonObject1.getString("num1"); |
| | |
| | | } |
| | | |
| | | //计算额外费用 |
| | | Integer num1 = extraCost.getInteger("num1");//等待时长 |
| | | Double num1 = extraCost.getDouble("num1");//等待时长 |
| | | Double num2 = extraCost.getDouble("num2");//等待费 |
| | | Integer num3 = extraCost.getInteger("num3");//等待超出时长 |
| | | Double num3 = extraCost.getDouble("num3");//等待超出时长 |
| | | Double num4 = extraCost.getDouble("num4");//等到超出时长费用单价 X/分钟 |
| | | Double num5 = extraCost.getDouble("num5");//恶劣天气公里 |
| | | Double num6 = extraCost.getDouble("num6");//恶劣天气费 |
| | |
| | | order.setWaitTime(num1);//等待时长 |
| | | order.setWaitTimePrice(num2);//等待费用 |
| | | |
| | | Integer w = waitTime - num3; |
| | | Double w = waitTime - num1 - num3; |
| | | BigDecimal multiply = new BigDecimal(w).multiply(new BigDecimal(num4)); |
| | | order.setOutWaitTime(w);//等待时长超出分钟 |
| | | order.setOutWaitTimePrice(multiply.doubleValue());//等待时长超出费用 |
| | |
| | | order.setOverLongDistancePrice(0d);//超出长途里程费 |
| | | // order.setWaitTime(0);//等待时长 |
| | | order.setWaitTimePrice(0D);//等待费 |
| | | order.setOutWaitTime(0);//超出等待时长 |
| | | order.setOutWaitTime(0D);//超出等待时长 |
| | | order.setOutWaitTimePrice(0D);//超出等待时长费 |
| | | order.setBadWeatherDistance(0D);//恶劣天气里程 |
| | | order.setBadWeatherPrice(0D);//恶劣天气里程费 |
| | |
| | | */ |
| | | public void pushOrder(Order order){ |
| | | try { |
| | | /** |
| | | * 1.先找最大推单范围内的优推司机 -》 距离最近 |
| | | * 没有1 - 》 |
| | | * 2.按照后台推送配置在范围内查找合适司机 |
| | | * 合适司:积分 > 评分 > 距离 |
| | | * 3.司机没有接单直接将订单置入大厅 |
| | | */ |
| | | boolean lock = redisUtil.lock(5); |
| | | if(!lock){ |
| | | int num1 = 1; |
| | |
| | | } |
| | | } |
| | | } |
| | | /** |
| | | * 1.先找最大推单范围内的优推司机 -》 距离最近 |
| | | * 没有1 - 》 |
| | | * 2.按照后台推送配置在范围内查找合适司机 |
| | | * 合适司:积分 > 评分 > 距离 |
| | | * 3.司机没有接单直接将订单置入大厅 |
| | | */ |
| | | if(!lock){ |
| | | redisUtil.unlock(); |
| | | order.setHallOrder(1); |
| | | this.updateById(order); |
| | | ExtraPushOrder(order); |
| | | return; |
| | | } |
| | | SystemConfig systemConfig = systemConfigService.selectOne(new EntityWrapper<SystemConfig>().eq("type", 1)); |
| | | if(null == systemConfig){ |
| | | redisUtil.unlock(); |
| | |
| | | new Timer().schedule(new TimerTask() { |
| | | @Override |
| | | public void run() { |
| | | driver1.setServerStatus(1); |
| | | driverService.updateById(driver1); |
| | | |
| | | Order order1 = OrderServiceImpl.this.selectById(order.getId()); |
| | | if(order1.getState() == 101 || order1.getState() == 201){ |
| | | order1.setHallOrder(1); |
| | | OrderServiceImpl.this.updateById(order1); |
| | | |
| | | driver1.setServerStatus(1); |
| | | driverService.updateById(driver1); |
| | | ExtraPushOrder(order); |
| | | } |
| | | } |
| | |
| | | orderRefusalService.insert(orderRefusal); |
| | | |
| | | Driver driver = driverService.selectById(uid); |
| | | driver.setServerStatus(1); |
| | | driverService.updateById(driver); |
| | | |
| | | //扣除积分 |
| | | SystemConfig systemConfig = systemConfigService.selectOne(new EntityWrapper<SystemConfig>().eq("type", 4)); |
| | | if(null != systemConfig) { |
| | |
| | | num1++; |
| | | } |
| | | } |
| | | } |
| | | if(!lock){ |
| | | return ResultUtil.error("请重试"); |
| | | } |
| | | Order order = this.selectById(orderId); |
| | | Integer state = order.getState(); |
| | |
| | | order.setStartTime(new Date()); |
| | | } |
| | | //计算等待用户时长 |
| | | Integer w = new BigDecimal((System.currentTimeMillis() - order.getStartWaitTime().getTime()) / 60000).setScale(0, BigDecimal.ROUND_UP).intValue(); |
| | | Double w = new BigDecimal(Double.valueOf(System.currentTimeMillis() - order.getStartWaitTime().getTime()) / 60000).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue(); |
| | | order.setWaitTime(order.getWaitTime() + w); |
| | | order.setStartWaitTime(null); |
| | | break; |
| | |
| | | } |
| | | return ResultUtil.success(); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | |
| | | pushOrderInfoWarpper.setDriverLat(split[1]); |
| | | pushOrderInfoWarpper.setDriverLng(split[0]); |
| | | } |
| | | int w = 0; |
| | | Double w = 0D; |
| | | if(null != order.getStartWaitTime()){ |
| | | w = Double.valueOf((System.currentTimeMillis() - order.getStartWaitTime().getTime()) / 60000).intValue(); |
| | | w = Double.valueOf((System.currentTimeMillis() - order.getStartWaitTime().getTime()) / 60000); |
| | | } |
| | | pushOrderInfoWarpper.setWaitTime(order.getWaitTime() + w); |
| | | pushOrderInfoWarpper.setState(order.getState()); |
| | |
| | | .where("'" + geocode.getCity() + "' like CONCAT('%', city, '%') and '" + geocode.getDistrict() + "' like CONCAT('%', district, '%') ")); |
| | | city = null != weatherCity ? weatherCity.getId().toString() : ""; |
| | | } |
| | | order = getOrderPrice(1, d, 0, order, city); |
| | | order = getOrderPrice(1, d, 0D, order, city); |
| | | this.updateById(order); |
| | | return ResultUtil.success(); |
| | | } |
| | |
| | | return ResultUtil.error("操作失败"); |
| | | } |
| | | Order order = this.selectById(orderId); |
| | | if(state == 107 && order.getState() != 106){ |
| | | return ResultUtil.error("操作失败"); |
| | | } |
| | | if(state == 108 && order.getState() != 107){ |
| | | return ResultUtil.error("操作失败"); |
| | | } |
| | | order.setState(state); |
| | | |
| | | if(payType == 2 && state == 107){ |
| | |
| | | Coupon coupon = userToCouponService.queryCoupon(order.getUserId(), order.getOrderMoney()); |
| | | if(null != coupon){ |
| | | order.setCouponId(coupon.getId()); |
| | | order.setDiscountAmount(coupon.getCouponPreferentialAmount()); |
| | | order.setDiscountedPrice(coupon.getCouponPreferentialAmount()); |
| | | order.setPayMoney(order.getOrderMoney() - coupon.getCouponPreferentialAmount()); |
| | | }else{ |
| | | order.setPayMoney(order.getOrderMoney()); |
| | |
| | | SystemConfig systemConfig1 = systemConfigService.selectOne(new EntityWrapper<SystemConfig>().eq("type", 2)); |
| | | if(null != systemConfig1){ |
| | | JSONObject jsonObject1 = JSON.parseObject(systemConfig1.getContent()); |
| | | //司机推荐首单收入 |
| | | if(null != appUser.getInviterType() && appUser.getInviterType() == 2 && count == 1){ |
| | | //司机推荐用户收入 |
| | | if(null != appUser.getInviterType() && appUser.getInviterType() == 2){ |
| | | Double num1 = jsonObject1.getDouble("num1"); |
| | | num1 = (num3 >= num1 ? num1 : num3); |
| | | |
| | |
| | | accountChangeDetail.setType(1); |
| | | accountChangeDetail.setChangeType(5); |
| | | accountChangeDetail.setOldData(driver1.getCouponBalance() + driver1.getCommission()); |
| | | accountChangeDetail.setExplain("邀请用户首单奖励"); |
| | | accountChangeDetail.setExplain("邀请用户奖励"); |
| | | accountChangeDetail.setCreateTime(new Date()); |
| | | driver1.setCommission(driver1.getCommission() + num1); |
| | | accountChangeDetail.setNewData(driver1.getCouponBalance() + driver1.getCommission()); |
| | |
| | | } |
| | | } |
| | | //司机余额扣减抽佣金额,将金额先分账给平台 |
| | | if(order.getPayMoney() > payMoney){ |
| | | if(order.getPayMoney().compareTo(payMoney) > 0){ |
| | | driver = driverService.selectById(order.getDriverId()); |
| | | Double m = order.getPayMoney() - payMoney; |
| | | AccountChangeDetail accountChangeDetail = new AccountChangeDetail(); |
| | |
| | | @Override |
| | | public void completeCollection() { |
| | | List<Order> orders = this.selectList(new EntityWrapper<Order>().eq("state", 107).eq("status", 1) |
| | | .eq("payType", 3).last(" and UNIX_TIMESTAMP(getoffTime) + 120 <= UNIX_TIMESTAMP(now())")); |
| | | .eq("payType", 3).last(" and UNIX_TIMESTAMP(getoffTime) + 600 <= UNIX_TIMESTAMP(now())")); |
| | | for (Order order : orders) { |
| | | order.setState(108); |
| | | order.setPayTime(new Date()); |
| | | if(null != order.getCouponId()){ |
| | | UserToCoupon userToCoupon = userToCouponService.selectById(order.getCouponId()); |