| | |
| | | import com.doumee.core.model.PageData; |
| | | import com.doumee.core.model.PageWrap; |
| | | import com.doumee.core.utils.DateUtil; |
| | | import com.doumee.core.utils.GeoUtils; |
| | | import com.doumee.core.utils.ID; |
| | | import com.doumee.core.utils.geocode.MapUtil; |
| | | import com.doumee.core.utils.Utils; |
| | |
| | | queryWrapper.like(StringUtils.isNotBlank(pageWrap.getModel().getTakeShopName()), "s2.name", pageWrap.getModel().getTakeShopName()); |
| | | queryWrapper.like(StringUtils.isNotBlank(pageWrap.getModel().getGoodsInfo()), Orders::getGoodsInfo, pageWrap.getModel().getGoodsInfo()); |
| | | queryWrapper.ge(pageWrap.getModel().getCreateStartTime() != null, Orders::getCreateTime, pageWrap.getModel().getCreateStartTime()); |
| | | queryWrapper.le(pageWrap.getModel().getCreateEndTime() != null, Orders::getCreateTime, pageWrap.getModel().getCreateEndTime()); |
| | | queryWrapper.le(pageWrap.getModel().getCreateEndTime() != null, Orders::getCreateTime, Utils.Date.getEnd(pageWrap.getModel().getCreateEndTime())); |
| | | queryWrapper.eq(pageWrap.getModel().getDepositShopId() != null, Orders::getDepositShopId, pageWrap.getModel().getDepositShopId()); |
| | | queryWrapper.eq(pageWrap.getModel().getType() != null, Orders::getType, pageWrap.getModel().getType()); |
| | | queryWrapper.eq(pageWrap.getModel().getStatus() != null, Orders::getStatus, pageWrap.getModel().getStatus()); |
| | |
| | | if (o.getStatus() != null) { |
| | | Constants.OrderStatus os = Constants.OrderStatus.getByKey(o.getStatus()); |
| | | o.setStatusDesc(os != null ? os.getValue() : ""); |
| | | } |
| | | if(Constants.equalsInteger(o.getIsUrgent(),Constants.ZERO)){ |
| | | o.setUrgentAmount(Constants.ZERO.longValue()); |
| | | } |
| | | } |
| | | return pageData; |
| | |
| | | // 3. 逐项计算运费:起步价 + 超出部分阶梯价 |
| | | List<ItemPriceVO> itemList = new ArrayList<>(); |
| | | long itemPriceTotal = 0L; |
| | | long maxExtraFeeTotal = 0L; // 最大超出距离费用(单价×数量) |
| | | |
| | | for (OrderItemDTO item : dto.getItems()) { |
| | | PricingRule rule = ruleMap.get(String.valueOf(item.getCategoryId())); |
| | |
| | | long extraPricePerUnit = Long.parseLong(rule.getFieldE()); |
| | | |
| | | // 阶梯计价:距离 ≤ 起步距离取起步价,超出按 ceil(超出距离/单位) × 单价累加 |
| | | long extraFee = 0L; |
| | | long unitPrice; |
| | | if (distanceKm.compareTo(startDistance) <= 0) { |
| | | unitPrice = startPrice; |
| | | } else { |
| | | BigDecimal extraKm = distanceKm.subtract(startDistance); |
| | | BigDecimal extraCount = extraKm.divide(extraDistanceUnit, 0, RoundingMode.CEILING); |
| | | unitPrice = startPrice + extraCount.longValue() * extraPricePerUnit; |
| | | extraFee = extraCount.longValue() * extraPricePerUnit; |
| | | unitPrice = startPrice + extraFee; |
| | | } |
| | | |
| | | long subtotal = unitPrice * item.getQuantity(); |
| | |
| | | vo.setExtraPrice(extraPricePerUnit); |
| | | itemList.add(vo); |
| | | |
| | | itemPriceTotal += subtotal; |
| | | // 所有物品的起步价×数量 累加 |
| | | itemPriceTotal += startPrice * item.getQuantity(); |
| | | // 记录最大的超出距离费用 |
| | | long extraFeeTotal = extraFee * item.getQuantity(); |
| | | if (extraFeeTotal > maxExtraFeeTotal) { |
| | | maxExtraFeeTotal = extraFeeTotal; |
| | | } |
| | | } |
| | | |
| | | // 多物品时只加最大的超出距离费用 |
| | | itemPriceTotal += maxExtraFeeTotal; |
| | | |
| | | // 4. 保价费用:报价金额 × 保价费率(字典 INSURANCE_RATE),元→分(保价金额>0时计费) |
| | | long insuranceFeeFen = 0L; |
| | |
| | | return; |
| | | } |
| | | Integer cityId = Integer.valueOf(orders.getCityId()); |
| | | boolean isRemote = Constants.equalsInteger(orders.getType(), Constants.ONE); |
| | | boolean isCompany = Constants.equalsInteger(depositShop.getCompanyType(), Constants.ONE); |
| | | |
| | | // 司机占比:fieldA=4(配送员) |
| | | // 司机占比:fieldA=4(配送员),始终从城市配置取 |
| | | BigDecimal driverRata = getRevenueShareRata(cityId, Constants.FOUR); |
| | | // 寄件门店占比:fieldA=0(企业寄)/1(个人寄) |
| | | int depositFieldA = Constants.equalsInteger(depositShop.getCompanyType(), Constants.ONE) ? Constants.ZERO : Constants.ONE; |
| | | BigDecimal depositShopRata = getRevenueShareRata(cityId, depositFieldA); |
| | | // 取件门店占比:无取件门店时比例为0 |
| | | BigDecimal takeShopRata = BigDecimal.ZERO; |
| | | if (takeShop != null) { |
| | | int takeFieldA = Constants.equalsInteger(takeShop.getCompanyType(), Constants.ONE) ? Constants.TWO : Constants.THREE; |
| | | takeShopRata = getRevenueShareRata(cityId, takeFieldA); |
| | | |
| | | // 存件门店占比 |
| | | BigDecimal depositShopRata; |
| | | if (isRemote) { |
| | | int fallbackFieldA = isCompany ? Constants.ZERO : Constants.ONE; |
| | | depositShopRata = getShopRevenueShare(depositShop, "remoteDeposit", cityId, fallbackFieldA); |
| | | } else { |
| | | int fallbackFieldA = isCompany ? Constants.FIVE : Constants.SIX; |
| | | depositShopRata = getShopRevenueShare(depositShop, "localDeposit", cityId, fallbackFieldA); |
| | | } |
| | | |
| | | // 计算薪酬(分):totalAmount 为分,rata 为比例值(如 0.15 表示 15%) |
| | | // 取件门店占比 |
| | | BigDecimal takeShopRata = BigDecimal.ZERO; |
| | | if (isRemote && takeShop != null) { |
| | | boolean takeIsCompany = Constants.equalsInteger(takeShop.getCompanyType(), Constants.ONE); |
| | | int fallbackFieldA = takeIsCompany ? Constants.TWO : Constants.THREE; |
| | | takeShopRata = getShopRevenueShare(takeShop, "remoteTake", cityId, fallbackFieldA); |
| | | } |
| | | |
| | | // 计算薪酬(分) |
| | | long driverFee = new BigDecimal(totalAmount).multiply(driverRata).longValue(); |
| | | long depositShopFee = new BigDecimal(totalAmount).multiply(depositShopRata).longValue(); |
| | | long takeShopFee = new BigDecimal(totalAmount).multiply(takeShopRata).longValue(); |
| | |
| | | * 从 pricing_rule 表获取分成比例(type=4) |
| | | * |
| | | * @param cityId 城市主键 |
| | | * @param fieldA 类型:0=企业寄, 1=个人寄, 2=企业取, 3=个人取, 4=配送员 |
| | | * @param fieldA 类型:0=异地企业寄, 1=异地个人寄, 2=异地企业取, 3=异地个人取, 4=配送员, 5=就地企业存, 6=就地个人存 |
| | | * @return 分成比例(如 0.15 表示 15%) |
| | | */ |
| | | private BigDecimal getRevenueShareRata(Integer cityId, int fieldA) { |
| | |
| | | .eq(PricingRule::getFieldA, String.valueOf(fieldA)) |
| | | .last("limit 1")); |
| | | if (rule != null && StringUtils.isNotBlank(rule.getFieldB())) { |
| | | // fieldB 存储的是百分比整数(如15表示15%),转换为小数比例(0.15) |
| | | // fieldB 存储的是百分比数字(如15表示15%),转换为小数比例(0.15) |
| | | return new BigDecimal(rule.getFieldB()).divide(new BigDecimal("100"), 4, BigDecimal.ROUND_HALF_UP); |
| | | } |
| | | return BigDecimal.ZERO; |
| | | } |
| | | |
| | | /** |
| | | * 获取门店收益占比:优先从门店 revenueShareConfig 取,无则兜底城市 pricing_rule |
| | | * |
| | | * @param shop 门店信息 |
| | | * @param jsonKey revenueShareConfig 中的键名 |
| | | * @param cityId 城市主键(兜底用) |
| | | * @param fallbackFieldA 兜底 pricing_rule fieldA 值 |
| | | * @return 分成比例 |
| | | */ |
| | | private BigDecimal getShopRevenueShare(ShopInfo shop, String jsonKey, Integer cityId, int fallbackFieldA) { |
| | | if (shop != null && StringUtils.isNotBlank(shop.getRevenueShareConfig())) { |
| | | try { |
| | | JSONObject config = JSONObject.parseObject(shop.getRevenueShareConfig()); |
| | | if (config != null && config.containsKey(jsonKey)) { |
| | | Double value = config.getDouble(jsonKey); |
| | | if (value != null) { |
| | | return new BigDecimal(value).divide(new BigDecimal("100"), 4, BigDecimal.ROUND_HALF_UP); |
| | | } |
| | | } |
| | | } catch (Exception ignored) { |
| | | } |
| | | } |
| | | return getRevenueShareRata(cityId, fallbackFieldA); |
| | | } |
| | | |
| | | @Override |
| | |
| | | .eq(status != null, Orders::getStatus, status) |
| | | .in(statusList != null, Orders::getStatus, statusList) |
| | | .orderByDesc(Orders::getCreateTime); |
| | | // 关键词搜索:收件人/收件人电话模糊、订单号精准 |
| | | if (model != null && StringUtils.isNotBlank(model.getKeyword())) { |
| | | String kw = model.getKeyword().trim(); |
| | | wrapper.and(w -> w.like(Orders::getTakeUser, kw) |
| | | .or().like(Orders::getTakePhone, kw) |
| | | .or().eq(Orders::getCode, kw)); |
| | | } |
| | | |
| | | IPage<Orders> orderPage = ordersMapper.selectJoinPage(p, Orders.class, wrapper); |
| | | List<MyOrderVO> voList = new ArrayList<>(); |
| | |
| | | } |
| | | |
| | | wrapper.eq(status != null, Orders::getStatus, status) |
| | | .in(statusList != null && !Constants.equalsInteger(combinedStatus, Constants.SEVEN), Orders::getStatus, statusList) |
| | | .orderByDesc(Orders::getId); |
| | | .in(statusList != null && !Constants.equalsInteger(combinedStatus, Constants.SEVEN), Orders::getStatus, statusList); |
| | | if(Objects.nonNull(model.getCombinedStatus())&&Constants.equalsInteger(model.getCombinedStatus(),Constants.OrderCombinedStatus.finished.getKey())){ |
| | | wrapper.orderByDesc(Orders::getFinishTime); |
| | | }else{ |
| | | wrapper.orderByDesc(Orders::getId); |
| | | } |
| | | // 关键词搜索:收件人/收件人电话模糊、订单号精准 |
| | | MyOrderDTO shopModel = pageWrap.getModel(); |
| | | if (shopModel != null && StringUtils.isNotBlank(shopModel.getKeyword())) { |
| | | String kw = shopModel.getKeyword().trim(); |
| | | wrapper.and(w -> w.like(Orders::getTakeUser, kw) |
| | | .or().like(Orders::getTakePhone, kw) |
| | | .or().eq(Orders::getCode, kw)); |
| | | } |
| | | |
| | | IPage<Orders> orderPage = ordersMapper.selectJoinPage(p, Orders.class, wrapper); |
| | | List<MyOrderVO> voList = new ArrayList<>(); |
| | |
| | | order.setWxExternalNo(wxTradeNo); |
| | | order.setPayAmount(order.getTotalAmount()); |
| | | order.setUpdateTime(now); |
| | | // 计算店铺订单序号:当前存件门店当天已支付订单数 + 1 |
| | | Date todayStart = DateUtil.getStartOfDay(now); |
| | | Long currentCount = ordersMapper.selectCount(new QueryWrapper<Orders>().lambda() |
| | | .eq(Orders::getDepositShopId, order.getDepositShopId()) |
| | | .eq(Orders::getPayStatus, Constants.ONE) |
| | | .ge(Orders::getPayTime, todayStart) |
| | | .eq(Orders::getDeleted, Constants.ZERO)); |
| | | order.setAutoNum(currentCount + 1); |
| | | // 生成会员核销码 |
| | | order.setMemberVerifyCode(generateVerifyCode()); |
| | | // 异地寄存:计算预计送达时间 |
| | |
| | | otherOrders.setUpdateTime(now); |
| | | otherOrdersMapper.updateById(otherOrders); |
| | | |
| | | // 4. 查询门店信息(通过注册会员主键关联) |
| | | // 4. 查询变更版本门店信息(通过注册会员主键关联) |
| | | ShopInfo shopInfo = shopInfoMapper.selectOne(new QueryWrapper<ShopInfo>().lambda() |
| | | .eq(ShopInfo::getRegionMemberId, otherOrders.getMemberId()) |
| | | .eq(ShopInfo::getDeleted, Constants.ZERO) |
| | | .eq(ShopInfo::getVersionType, Constants.ONE) |
| | | .last("limit 1")); |
| | | if (shopInfo == null) { |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(), "门店不存在"); |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(), "门店变更记录不存在"); |
| | | } |
| | | // 5. 更新门店状态:已支付押金 |
| | | shopInfo.setAuditStatus(Constants.THREE); // 3=已支付押金 |
| | | // 5. 更新变更版本支付状态 |
| | | Member member = memberMapper.selectById(otherOrders.getMemberId()); |
| | | shopInfo.setAuditStatus(Constants.THREE); |
| | | shopInfo.setPayStatus(Constants.ONE); |
| | | shopInfo.setPayTime(now); |
| | | shopInfo.setWxExternalNo(wxTradeNo); |
| | | shopInfo.setCode(otherOrders.getCode()); |
| | | Member member = memberMapper.selectById(otherOrders.getMemberId()); |
| | | if (member != null) { |
| | | shopInfo.setPayMemberOpenId(member.getOpenid()); |
| | | } |
| | | shopInfo.setUpdateTime(now); |
| | | shopInfoMapper.updateById(shopInfo); |
| | | |
| | | // 6. 同步更新正式版本状态为已支付押金 |
| | | if (shopInfo.getRelationShopId() != null) { |
| | | ShopInfo officialShop = shopInfoMapper.selectById(shopInfo.getRelationShopId()); |
| | | if (officialShop != null) { |
| | | officialShop.setAuditStatus(Constants.THREE); |
| | | officialShop.setUpdateTime(now); |
| | | shopInfoMapper.updateById(officialShop); |
| | | } |
| | | } |
| | | |
| | | // 短信通知门店:成功入驻 |
| | | String rawPassword = shopInfo.getTelephone() != null && shopInfo.getTelephone().length() >= 6 |
| | |
| | | } |
| | | order.setMemberVerifyCode(generateVerifyCode()); |
| | | ordersMapper.updateById(order); |
| | | // 寄存时图片必填 |
| | | if (images == null || images.isEmpty()) { |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "请上传寄存图片"); |
| | | } |
| | | // 保存寄存图片(obj_type=2 订单寄存图片,最多3张) |
| | | saveVerifyImages(order.getId(), images, Constants.FileType.ORDER_DEPOSIT.getKey(), shopId); |
| | | // 记录订单日志 |
| | |
| | | order.setStatus(Constants.OrderStatus.finished.getStatus()); |
| | | order.setConfirmArriveTime(now); |
| | | ordersMapper.updateById(order); |
| | | // 就地寄存(type=0)取件时图片不必填,其他类型取件必填 |
| | | if (!Constants.equalsInteger(order.getType(), Constants.ZERO)) { |
| | | if (images == null || images.isEmpty()) { |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "请上传取件图片"); |
| | | } |
| | | } |
| | | // 订单完成,释放核销码 |
| | | String verifyCode = order.getMemberVerifyCode(); |
| | | if (StringUtils.isNotBlank(verifyCode)) { |
| | |
| | | return "司机已取件,正运往目的地"; |
| | | } |
| | | if (Constants.equalsInteger(status, Constants.OrderStatus.arrived.getStatus())) { |
| | | return "行李已送达服务点,请及时前往取件"; |
| | | if(Constants.equalsInteger(order.getType(),Constants.ZERO)){ |
| | | return "行李已寄存,请凭取件码前往指定门店取件~"; |
| | | }else{ |
| | | return "行李已送达服务点,请及时前往取件"; |
| | | } |
| | | |
| | | } |
| | | if (Constants.equalsInteger(status, Constants.OrderStatus.finished.getStatus())) { |
| | | if (Constants.equalsInteger(order.getCommentStatus(), Constants.ONE)) { |
| | |
| | | "time", String.valueOf(noGrabMinutes)); |
| | | } |
| | | // 标记已通知 + 记录通知时间 |
| | | order.setPlatformSmsNotified(Constants.ONE); |
| | | order.setPlatformSmsNotifiedTime(now); |
| | | order.setUpdateTime(now); |
| | | ordersMapper.updateById(order); |
| | |
| | | if (StringUtils.isBlank(phone)) { |
| | | return; |
| | | } |
| | | if (!smsNotify.isEnabled()) { |
| | | return; |
| | | } |
| | | String content = smsNotify.format(paramPairs); |
| | | try { |
| | | JSONObject templateParam = new JSONObject(); |
| | |
| | | } |
| | | } |
| | | |
| | | //序号 |
| | | String sort = Constants.formatIntegerNum(shopId)+"-"+orders.getId(); |
| | | //序号:商铺ID-日期-自增长序号(如 32-06-001) |
| | | String dateStr = new SimpleDateFormat("dd").format(orders.getPayTime() != null ? orders.getPayTime() : new Date()); |
| | | String autoNumStr = String.format("%03d", orders.getAutoNum() != null ? orders.getAutoNum() : 0); |
| | | String sort = shopId + "-" + dateStr + "-" + autoNumStr; |
| | | // String content = printService.getPrintContent(shop.getName(), detailList, userInfo, orders.getCode(), orders.getRemark(), |
| | | String content = printService.getPrintContent(shop.getName(), detailList, userInfo, orders.getCode(), sort, |
| | | orders.getTakeLocationRemark(), |
| | |
| | | JPushUtil.sendByAliases(aliases, title, content, extras); |
| | | } |
| | | |
| | | @Override |
| | | public int notifyArrivalPickUp() { |
| | | String timeStr = operationConfigBiz.getConfig().getArrivalPickUpTime(); |
| | | if (StringUtils.isBlank(timeStr)) { |
| | | return 0; |
| | | } |
| | | int minutes; |
| | | try { |
| | | minutes = Integer.parseInt(timeStr); |
| | | } catch (NumberFormatException e) { |
| | | log.warn("即将到达取件时间配置异常: {}", timeStr); |
| | | return 0; |
| | | } |
| | | if (minutes <= 0) { |
| | | return 0; |
| | | } |
| | | // 计算时间窗口:当前时间 + minutes 就是"即将到达"的临界点 |
| | | Date now = new Date(); |
| | | Date threshold = new Date(now.getTime() + (long) minutes * 60 * 1000); |
| | | // 查询:status=5、未通知、就地寄存 or 异地(有取件门店)、预计取件时间在 now~threshold 之间 |
| | | List<Orders> orders = ordersMapper.selectList(new QueryWrapper<Orders>().lambda() |
| | | .eq(Orders::getStatus, Constants.OrderStatus.arrived.getStatus()) |
| | | .eq(Orders::getPayStatus, Constants.ONE) |
| | | .eq(Orders::getDeleted, Constants.ZERO) |
| | | .and(w -> w |
| | | .eq(Orders::getType, Constants.ZERO) |
| | | .or(w2 -> w2.eq(Orders::getType, Constants.ONE).isNotNull(Orders::getTakeShopId)) |
| | | ) |
| | | .ne(Orders::getPickUpNotifyStatus, Constants.ONE) |
| | | .isNotNull(Orders::getExpectedTakeTime) |
| | | .ge(Orders::getExpectedTakeTime, now) |
| | | .le(Orders::getExpectedTakeTime, threshold)); |
| | | if (orders == null || orders.isEmpty()) { |
| | | return 0; |
| | | } |
| | | int count = 0; |
| | | for (Orders order : orders) { |
| | | Member member = memberMapper.selectById(order.getMemberId()); |
| | | if (member != null && StringUtils.isNotBlank(member.getTelephone())) { |
| | | sendSmsNotify(member.getTelephone(), Constants.SmsNotify.MEMBER_TIME_OUT, |
| | | "orderNo", order.getCode()); |
| | | } |
| | | order.setPickUpNotifyStatus(Constants.ONE); |
| | | ordersMapper.updateById(order); |
| | | count++; |
| | | } |
| | | return count; |
| | | } |
| | | |
| | | @Override |
| | | public Boolean checkOperationRadius(Integer orderId, Integer userId, Integer userType, Double lng, Double lat) { |
| | | String radiusStr = operationConfigBiz.getConfig().getOperationRadius(); |
| | | if (StringUtils.isBlank(radiusStr)) { |
| | | return true; |
| | | } |
| | | double radiusM; |
| | | try { |
| | | radiusM = Double.parseDouble(radiusStr); |
| | | } catch (NumberFormatException e) { |
| | | return true; |
| | | } |
| | | if (radiusM <= 0) { |
| | | return true; |
| | | } |
| | | Orders order = ordersMapper.selectById(orderId); |
| | | if (order == null) { |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "订单不存在"); |
| | | } |
| | | BigDecimal targetLat; |
| | | BigDecimal targetLgt; |
| | | if (Constants.equalsInteger(userType, Constants.ZERO)) { |
| | | // 门店操作 |
| | | if (Constants.equalsInteger(order.getStatus(), Constants.OrderStatus.waitDeposit.getStatus())) { |
| | | // status=1 门店寄存核验 |
| | | if (!Constants.equalsInteger(order.getDepositShopId(), userId)) { |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "无权操作该订单"); |
| | | } |
| | | targetLat = order.getDepositLat(); |
| | | targetLgt = order.getDepositLgt(); |
| | | } else if (Constants.equalsInteger(order.getStatus(), Constants.OrderStatus.arrived.getStatus())) { |
| | | // status=5 门店完成核销 |
| | | if (Constants.equalsInteger(order.getType(), Constants.ZERO)) { |
| | | // 就地存取 → 对比存件门店 |
| | | if (!Constants.equalsInteger(order.getDepositShopId(), userId)) { |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "无权操作该订单"); |
| | | } |
| | | targetLat = order.getDepositLat(); |
| | | targetLgt = order.getDepositLgt(); |
| | | } else { |
| | | // 异地存取 → 对比取件门店 |
| | | if (!Constants.equalsInteger(order.getTakeShopId(), userId)) { |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "无权操作该订单"); |
| | | } |
| | | targetLat = order.getTakeLat(); |
| | | targetLgt = order.getTakeLgt(); |
| | | } |
| | | } else { |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "订单状态不允许此操作"); |
| | | } |
| | | } else if (Constants.equalsInteger(userType, Constants.ONE)) { |
| | | // 司机操作 |
| | | if (Constants.equalsInteger(order.getStatus(), Constants.OrderStatus.deposited.getStatus())) { |
| | | // status=2 司机取件 |
| | | if (!Constants.equalsInteger(order.getAcceptDriver(), userId)) { |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "无权操作该订单"); |
| | | } |
| | | targetLat = order.getDepositLat(); |
| | | targetLgt = order.getDepositLgt(); |
| | | } else if (Constants.equalsInteger(order.getStatus(), Constants.OrderStatus.delivering.getStatus())) { |
| | | // status=4 司机送达 |
| | | if (!Constants.equalsInteger(order.getAcceptDriver(), userId)) { |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "无权操作该订单"); |
| | | } |
| | | targetLat = order.getTakeLat(); |
| | | targetLgt = order.getTakeLgt(); |
| | | } else { |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "订单状态不允许此操作"); |
| | | } |
| | | } else { |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "用户类型不合法"); |
| | | } |
| | | if (targetLat == null || targetLgt == null) { |
| | | return true; |
| | | } |
| | | double distanceKm = GeoUtils.haversineDistance(lat, lng, targetLat.doubleValue(), targetLgt.doubleValue()); |
| | | return distanceKm * 1000 <= radiusM; |
| | | } |
| | | |
| | | } |