| | |
| | | import com.doumee.dao.vo.DriverCancelLimitVO; |
| | | import com.doumee.dao.vo.DriverCenterVO; |
| | | import com.doumee.dao.vo.DriverGrabOrderVO; |
| | | import com.doumee.dao.system.model.SystemUser; |
| | | import com.doumee.service.system.SystemUserService; |
| | | import com.doumee.dao.vo.DriverOrderDetailVO; |
| | | import com.doumee.core.utils.aliyun.AliSmsService; |
| | | import com.doumee.service.business.DriverInfoService; |
| | |
| | | |
| | | @Autowired |
| | | private AreasBizImpl areasBiz; |
| | | |
| | | @Autowired |
| | | private SystemUserService systemUserService; |
| | | |
| | | /** |
| | | * 发送订单站内信通知 |
| | |
| | | .select(" ( select ifnull(sum(r.OPT_TYPE * r.AMOUNT),0) from revenue r where r.MEMBER_TYPE = 1 and r.MEMBER_ID= t.id and r.VAILD_STATUS = 1 ) as memberAmount ") |
| | | .selectAs(Category::getName,DriverInfo::getCarTypeName) |
| | | .leftJoin(Category.class, Category::getId,DriverInfo::getCarType); |
| | | for (PageWrap.SortData sortData : pageWrap.getSorts()) { |
| | | if (sortData.getDirection().equalsIgnoreCase(PageWrap.DESC)) { |
| | | queryWrapper.orderByDesc(sortData.getProperty()); |
| | | } else { |
| | | queryWrapper.orderByAsc(sortData.getProperty()); |
| | | } |
| | | } |
| | | queryWrapper.orderByDesc(DriverInfo::getId); |
| | | PageData<DriverInfo> pageData = PageData.from(driverInfoMapper.selectPage(page, queryWrapper)); |
| | | for (DriverInfo d : pageData.getRecords()) { |
| | | d.setGender(Constants.getGenderByIdCard(d.getIdcard())); |
| | |
| | | String code = RandomStringUtils.randomNumeric(6); |
| | | // 发送短信 |
| | | String templateParam = "{\"code\":\"" + code + "\"}"; |
| | | AliSmsService.sendSms(telephone, "SMS_491325122", templateParam); |
| | | AliSmsService.sendSms(telephone, Constants.SmsNotify.VERIFY_CODE.getTemplateCode(), templateParam); |
| | | // 保存短信记录 |
| | | Smsrecord smsrecord = new Smsrecord(); |
| | | smsrecord.setDeleted(Constants.ZERO); |
| | |
| | | driverInfo.setMemberId(member.getId()); |
| | | driverInfo.setStatus(Constants.ZERO); |
| | | driverInfo.setAuditStatus(99); |
| | | driverInfo.setJpushAlias(org.springframework.util.DigestUtils.md5DigestAsHex(telephone.getBytes())); |
| | | driverInfoMapper.insert(driverInfo); |
| | | } |
| | | |
| | |
| | | } |
| | | // 状态校验:auditStatus=null(未提交)或auditStatus=2(审批驳回)可提交认证 |
| | | if (driverInfo.getAuditStatus() != null |
| | | && !Constants.equalsInteger(driverInfo.getAuditStatus(), Constants.TWO)) { |
| | | && !(Constants.equalsInteger(driverInfo.getAuditStatus(), Constants.TWO)||Constants.equalsInteger(driverInfo.getAuditStatus(), 99))) { |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "当前状态不允许提交认证"); |
| | | } |
| | | // 根据车辆类型判断是否需要驾驶证 |
| | |
| | | if (Objects.nonNull(category)) { |
| | | driverInfo.setCarTypeName(category.getName()); |
| | | driverInfo.setNeedLicense(Constants.equalsInteger(Integer.valueOf(category.getOtherField()), Constants.ONE) ? Constants.ONE : Constants.ZERO); |
| | | driverInfo.setDriverType(category.getDetail()); |
| | | } |
| | | } |
| | | // 查询省市区信息 |
| | |
| | | // 审批结果:auditDTO.auditStatus 0=通过→auditStatus=1,1=拒绝→auditStatus=2 |
| | | Integer newAuditStatus; |
| | | if (Constants.equalsInteger(auditDTO.getAuditStatus(), Constants.ZERO)) { |
| | | newAuditStatus = Constants.ONE; // 审批通过 |
| | | newAuditStatus = Constants.THREE; // 审批通过 |
| | | // 审批通过时司机定级为必填 |
| | | if (auditDTO.getDriverLevel() == null || auditDTO.getDriverLevel() < 1 || auditDTO.getDriverLevel() > 5) { |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "审批通过时必须填写司机定级"); |
| | |
| | | } |
| | | } |
| | | } |
| | | // 查询审批人名称 |
| | | if (driverInfo.getAuditUser() != null) { |
| | | try { |
| | | SystemUser auditUser = systemUserService.findById(driverInfo.getAuditUser()); |
| | | if (auditUser != null) { |
| | | driverInfo.setAuditUserName(auditUser.getRealname()); |
| | | } |
| | | } catch (Exception e) { |
| | | // 审批人已删除等异常忽略 |
| | | } |
| | | } |
| | | return driverInfo; |
| | | } |
| | | |
| | | @Override |
| | | public DriverInfo updateDriverInfo(DriverVerifyRequest request) { |
| | | Integer id = request.getId(); |
| | | if (id == null) { |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "司机主键不能为空"); |
| | | } |
| | | DriverInfo driverInfo = driverInfoMapper.selectById(id); |
| | | if (Objects.isNull(driverInfo) || Constants.equalsInteger(driverInfo.getDeleted(), Constants.ONE)) { |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY); |
| | | } |
| | | Date now = new Date(); |
| | | driverInfoMapper.update(new UpdateWrapper<DriverInfo>().lambda() |
| | | .set(DriverInfo::getName, request.getName()) |
| | | .set(DriverInfo::getIdcard, request.getIdcard()) |
| | | .set(DriverInfo::getMaritalStatus, request.getMaritalStatus()) |
| | | .set(DriverInfo::getAreaId, request.getAreaId()) |
| | | .set(DriverInfo::getLivePlace, request.getLivePlace()) |
| | | .set(DriverInfo::getCarCode, request.getCarCode()) |
| | | .set(DriverInfo::getCarType, request.getCarType()) |
| | | .set(DriverInfo::getCarColor, request.getCarColor()) |
| | | .set(DriverInfo::getCardStartDate, request.getCardStartDate()) |
| | | .set(DriverInfo::getCardEndDate, request.getCardEndDate()) |
| | | .set(DriverInfo::getIdcardImg, request.getIdcardImg()) |
| | | .set(DriverInfo::getIdcardImgBack, request.getIdcardImgBack()) |
| | | .set(DriverInfo::getAliAccount, request.getAliAccount()) |
| | | .set(DriverInfo::getAliName, request.getAliName()) |
| | | .set(DriverInfo::getUpdateTime, now) |
| | | .eq(DriverInfo::getId, id)); |
| | | |
| | | // 删除旧的照片记录并保存新的 |
| | | multifileMapper.delete(new QueryWrapper<Multifile>().lambda() |
| | | .eq(Multifile::getObjId, id) |
| | | .in(Multifile::getObjType, |
| | | Constants.FileType.DRIVER_CAR.getKey(), |
| | | Constants.FileType.DRIVER_LICENSE.getKey(), |
| | | Constants.FileType.DRIVER_OTHER.getKey())); |
| | | if (!CollectionUtils.isEmpty(request.getCarImgUrls())) { |
| | | saveMultifileList(id, Constants.FileType.DRIVER_CAR.getKey(), request.getCarImgUrls(), now); |
| | | } |
| | | if (!CollectionUtils.isEmpty(request.getLicenseImgUrls())) { |
| | | saveMultifileList(id, Constants.FileType.DRIVER_LICENSE.getKey(), request.getLicenseImgUrls(), now); |
| | | } |
| | | if (!CollectionUtils.isEmpty(request.getOtherImgUrls())) { |
| | | saveMultifileList(id, Constants.FileType.DRIVER_OTHER.getKey(), request.getOtherImgUrls(), now); |
| | | } |
| | | |
| | | return getDetail(id); |
| | | } |
| | | |
| | | @Override |
| | |
| | | vo.setCarCode(driver.getCarCode()); |
| | | vo.setScore(driver.getScore() != null ? driver.getScore().toPlainString() : "0"); |
| | | vo.setDriverLevel(driver.getDriverLevel()); |
| | | vo.setDriverLevelName(Constants.getDriverLevelName(driver.getDriverLevel())); |
| | | vo.setAuditStatus(driver.getAuditStatus()); |
| | | vo.setAuditRemark(driver.getAuditRemark()); |
| | | vo.setBalance(driver.getBalance() != null ? driver.getBalance() : 0L); |
| | |
| | | + systemDictDataBiz.queryByCode(Constants.OSS, Constants.MEMBER_FILES).getCode(); |
| | | vo.setFullImgUrl(imgPrefix + driver.getImgurl()); |
| | | } |
| | | |
| | | // 今日预计佣金:revenue表中今天的收入记录金额之和 |
| | | Category category = categoryMapper.selectById(driver.getCarType()); |
| | | if(Objects.nonNull(category)&&StringUtils.isNotBlank(category.getDetail())){ |
| | | vo.setDriverType(category.getDetail()); |
| | | } |
| | | // 今日预计佣金:今日接单的司机佣金 + 平台奖励金 |
| | | Date now = new Date(); |
| | | Calendar cal = Calendar.getInstance(); |
| | | cal.setTime(now); |
| | |
| | | cal.set(Calendar.MILLISECOND, 0); |
| | | Date todayStart = cal.getTime(); |
| | | |
| | | QueryWrapper<Revenue> revenueWrapper = new QueryWrapper<>(); |
| | | revenueWrapper.lambda() |
| | | .eq(Revenue::getMemberId, memberId) |
| | | .eq(Revenue::getMemberType, Constants.ONE) |
| | | .eq(Revenue::getOptType, Constants.ONE) |
| | | .eq(Revenue::getDeleted, Constants.ZERO) |
| | | .ge(Revenue::getCreateTime, todayStart); |
| | | revenueWrapper.select("IFNULL(SUM(AMOUNT),0) as amount"); |
| | | Revenue sumResult = revenueMapper.selectOne(revenueWrapper); |
| | | vo.setTodayCommission(sumResult != null && sumResult.getAmount() != null ? sumResult.getAmount() : 0L); |
| | | QueryWrapper<Orders> commissionWrapper = new QueryWrapper<>(); |
| | | commissionWrapper.lambda() |
| | | .eq(Orders::getAcceptDriver, driver.getId()) |
| | | .eq(Orders::getDeleted, Constants.ZERO) |
| | | .ge(Orders::getAcceptTime, todayStart); |
| | | commissionWrapper.select("IFNULL(SUM(DRIVER_FEE),0) as driverFee", "IFNULL(SUM(PLATFORM_REWARD_AMOUNT),0) as platformRewardAmount"); |
| | | Orders commissionResult = ordersMapper.selectOne(commissionWrapper); |
| | | long driverFee = commissionResult != null && commissionResult.getDriverFee() != null ? commissionResult.getDriverFee() : 0L; |
| | | long rewardAmount = commissionResult != null && commissionResult.getPlatformRewardAmount() != null ? commissionResult.getPlatformRewardAmount() : 0L; |
| | | vo.setTodayCommission(driverFee + rewardAmount); |
| | | |
| | | // 今日接单数:今天完成的订单数(acceptDriver=司机主键,状态=已完成) |
| | | Long todayOrderCount = ordersMapper.selectCount(new QueryWrapper<Orders>().lambda() |
| | |
| | | .select("c2.other_field as c2OtherField") |
| | | .select("c2.name as goodLevelName") |
| | | // 是否存在特大尺寸 |
| | | .select("IF(EXISTS(SELECT 1 FROM orders_detail od JOIN category c3 ON c3.id = od.LUGGAGE_ID AND c3.TYPE = 4 AND c3.OTHER_FIELD = '1' WHERE od.ORDER_ID = t.ID AND od.DELETED = 0), 1, 0) as hasOversized") |
| | | .select("IF(EXISTS(SELECT 1 FROM orders_detail od JOIN category c3 ON c3.id = od.LUGGAGE_ID AND c3.TYPE = 4 AND c3.detail = '1' WHERE od.ORDER_ID = t.ID AND od.DELETED = 0), 1, 0) as hasOversized") |
| | | // JOIN |
| | | .leftJoin("shop_info s1 on s1.id = t.DEPOSIT_SHOP_ID and s1.DELETED = 0") |
| | | .leftJoin("shop_info s2 on s2.id = t.TAKE_SHOP_ID and s2.DELETED = 0") |
| | |
| | | .select("s1.address", Orders::getDepositShopAddress) |
| | | .select("s2.name", Orders::getTakeShopName) |
| | | .select("s2.address", Orders::getTakeShopAddress) |
| | | .select("s1.link_phone", Orders::getDepositShopLinkPhone) |
| | | .select("s2.link_phone as takeShopLinkPhone") |
| | | .select("c2.other_field as c2OtherField") |
| | | .select("c2.name as goodLevelName") |
| | | .select("IF(EXISTS(SELECT 1 FROM orders_detail od JOIN category c3 ON c3.id = od.LUGGAGE_ID AND c3.TYPE = 4 AND c3.OTHER_FIELD = '1' WHERE od.ORDER_ID = t.ID AND od.DELETED = 0), 1, 0) as hasOversized") |
| | | .leftJoin("shop_info s1 on s1.id = t.DEPOSIT_SHOP_ID and s1.DELETED = 0") |
| | | .leftJoin("shop_info s2 on s2.id = t.TAKE_SHOP_ID and s2.DELETED = 0") |
| | | .leftJoin("category c1 on c1.id = t.GOOD_TYPE and c1.DELETED = 0") |
| | | .leftJoin("category c2 on c2.id = c1.RELATION_ID and c2.DELETED = 0 and c2.TYPE = 3") |
| | | .leftJoin("shop_info s1 on s1.id = t.DEPOSIT_SHOP_ID ") |
| | | .leftJoin("shop_info s2 on s2.id = t.TAKE_SHOP_ID ") |
| | | .leftJoin("category c1 on c1.id = t.GOOD_TYPE ") |
| | | .leftJoin("category c2 on c2.id = c1.RELATION_ID and c2.TYPE = 3") |
| | | .eq(Orders::getAcceptDriver, driver.getId()) |
| | | .eq(Orders::getType, Constants.ONE) |
| | | .eq(Objects.nonNull(dto.getStatus()),Orders::getStatus, dto.getStatus()) |
| | |
| | | wrapper.selectAll(Orders.class) |
| | | .select("s1.name", Orders::getDepositShopName) |
| | | .select("s1.address", Orders::getDepositShopAddress) |
| | | .select("s1.link_phone", Orders::getDepositShopLinkPhone) |
| | | .select("s2.name", Orders::getTakeShopName) |
| | | .select("s2.address", Orders::getTakeShopAddress) |
| | | .select("s2.link_phone as takeShopLinkPhone") |
| | | .select("c2.other_field as c2OtherField") |
| | | .select("s2.link_phone", Orders::getTakeShopLinkPhone) |
| | | .select("c1.other_field as c2OtherField") |
| | | .select("c1.name as goodTypeName") |
| | | .select("IF(EXISTS(SELECT 1 FROM orders_detail od JOIN category c3 ON c3.id = od.LUGGAGE_ID AND c3.TYPE = 4 AND c3.OTHER_FIELD = '1' WHERE od.ORDER_ID = t.ID AND od.DELETED = 0), 1, 0) as hasOversized") |
| | | .leftJoin("shop_info s1 on s1.id = t.DEPOSIT_SHOP_ID and s1.DELETED = 0") |
| | | .leftJoin("shop_info s2 on s2.id = t.TAKE_SHOP_ID and s2.DELETED = 0") |
| | |
| | | vo.setTakeShopId(base.getTakeShopId()); |
| | | |
| | | vo.setTakeDistance(base.getTakeDistance()); |
| | | vo.setContactPhone(base.getContactPhone()); |
| | | |
| | | // 联系电话:按订单状态返回 |
| | | vo.setDepositShopPhone(order.getDepositShopLinkPhone()); |
| | | if (Constants.equalsInteger(order.getStatus(), Constants.OrderStatus.delivering.getStatus()) |
| | | || Constants.equalsInteger(order.getStatus(), Constants.OrderStatus.arrived.getStatus())) { |
| | | if (order.getTakeShopId() != null && StringUtils.isNotBlank(order.getTakeShopLinkPhone())) { |
| | | vo.setTakeContactPhone(order.getTakeShopLinkPhone()); |
| | | } else { |
| | | vo.setTakeContactPhone(order.getTakePhone()); |
| | | } |
| | | } |
| | | vo.setDriverFee(base.getDriverFee()); |
| | | vo.setUrgentAmount(base.getUrgentAmount()); |
| | | vo.setPlatformRewardAmount(order.getPlatformRewardAmount()); |
| | | vo.setIsValuable(base.getIsValuable()); |
| | | vo.setGoodLevelName(base.getGoodLevelName()); |
| | | vo.setGoodTypeName(order.getGoodTypeName()); |
| | | vo.setHasOversized(base.getHasOversized()); |
| | | vo.setDriverVerifyCode(base.getDriverVerifyCode()); |
| | | |
| | |
| | | // 详情特有字段 |
| | | vo.setStatus(order.getStatus()); |
| | | vo.setStatusDesc(getStatusDesc(order.getStatus())); |
| | | vo.setCreateTime(order.getCreateTime()); |
| | | vo.setAcceptTime(order.getAcceptTime()); |
| | | vo.setDriverTakeTime(order.getDriverTakeTime()); |
| | | vo.setFinishTime(order.getFinishTime()); |
| | | vo.setRemark(order.getRemark()); |
| | | |
| | | // 客户信息 |
| | | String customerInfo = ""; |
| | |
| | | vo.setCustomerInfo(customerInfo); |
| | | |
| | | // 导航经纬度(使用Orders自带坐标) |
| | | if (Constants.equalsInteger(order.getStatus(), Constants.TWO)) { |
| | | if (Constants.equalsInteger(order.getStatus(), Constants.OrderStatus.accepted.getStatus())) { |
| | | if (order.getDepositLgt() != null && order.getDepositLat() != null) { |
| | | vo.setNavigateLat(order.getDepositLgt().doubleValue()); |
| | | vo.setNavigateLng(order.getDepositLat().doubleValue()); |
| | | } |
| | | } else { |
| | | } else if(Constants.equalsInteger(order.getStatus(), Constants.OrderStatus.delivering.getStatus())){ |
| | | if (order.getTakeLgt() != null && order.getTakeLat() != null) { |
| | | vo.setNavigateLat(order.getTakeLgt().doubleValue()); |
| | | vo.setNavigateLng(order.getTakeLat().doubleValue()); |
| | | } |
| | | } |
| | | |
| | | // 异地寄存实时经纬度(按状态返回) |
| | | if (Constants.ONE.equals(order.getType())) { |
| | | // 司机自身经纬度 |
| | | vo.setDriverLng(driverLng); |
| | | vo.setDriverLat(driverLat); |
| | | |
| | | // status=3(已接单):返回存件门店经纬度 |
| | | if (Constants.equalsInteger(order.getStatus(), Constants.OrderStatus.accepted.getStatus())) { |
| | | if (order.getDepositShopId() != null) { |
| | | ShopInfo depositShop = shopInfoMapper.selectById(order.getDepositShopId()); |
| | | if (depositShop != null) { |
| | | vo.setDepositShopLng(depositShop.getLongitude()); |
| | | vo.setDepositShopLat(depositShop.getLatitude()); |
| | | } |
| | | } |
| | | } |
| | | // status=4(配送中):返回取件点经纬度 |
| | | if (Constants.equalsInteger(order.getStatus(), Constants.OrderStatus.delivering.getStatus())) { |
| | | if (order.getTakeShopId() != null) { |
| | | ShopInfo takeShop = shopInfoMapper.selectById(order.getTakeShopId()); |
| | | if (takeShop != null) { |
| | | vo.setTakeLng(takeShop.getLongitude()); |
| | | vo.setTakeLat(takeShop.getLatitude()); |
| | | } |
| | | } else if (order.getTakeLgt() != null && order.getTakeLat() != null) { |
| | | vo.setTakeLng(order.getTakeLgt().doubleValue()); |
| | | vo.setTakeLat(order.getTakeLat().doubleValue()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | vo.setDepositShopLng(order.getDepositLgt().doubleValue()); |
| | | vo.setDepositShopLat(order.getDepositLat().doubleValue()); |
| | | vo.setTakeLng(order.getTakeLgt().doubleValue()); |
| | | vo.setTakeLat(order.getTakeLat().doubleValue()); |
| | | vo.setDriverLng(driverLng); |
| | | vo.setDriverLat(driverLat); |
| | | // 下单附件图片 |
| | | String imgPrefix = systemDictDataBiz.queryByCode(Constants.OSS, Constants.RESOURCE_PATH).getCode() |
| | | + systemDictDataBiz.queryByCode(Constants.OSS, Constants.MEMBER_FILES).getCode(); |
| | | + systemDictDataBiz.queryByCode(Constants.OSS, Constants.ORDERS_FILES).getCode(); |
| | | vo.setOrderImages(getFileUrls(orderId, Constants.FileType.ORDER_FILE.getKey(), imgPrefix)); |
| | | |
| | | // 评价信息 |
| | |
| | | if (!Constants.ONE.equals(order.getType())) { |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "仅异地寄存订单可取消"); |
| | | } |
| | | if (!Constants.TWO.equals(order.getStatus())) { |
| | | if (!Constants.equalsInteger(Constants.OrderStatus.accepted.getStatus(), order.getStatus())) { |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "当前订单状态不允许取消"); |
| | | } |
| | | if (!driverId.equals(order.getAcceptDriver())) { |
| | |
| | | .set(Orders::getAcceptDriver, null) |
| | | .set(Orders::getAcceptTime, null) |
| | | .set(Orders::getAcceptType, null) |
| | | .set(Orders::getStatus, Constants.OrderStatus.deposited.getStatus()) |
| | | .eq(Orders::getId, orderId)); |
| | | |
| | | // 5. 写入取消日志 |
| | |
| | | |
| | | // 7. 通知会员:司机已抢单 |
| | | sendOrderNotice(order.getMemberId(), Constants.MemberOrderNotify.WAIT_PICKUP_GRABBED, orderId, |
| | | "orderNo", order.getCode(), |
| | | "driverName", driver.getName()); |
| | | |
| | | // 通知存件门店:订单已抢单待取件 |
| | | if (order.getDepositShopId() != null) { |
| | | sendShopNotice(order.getDepositShopId(), Constants.ShopOrderNotify.WAIT_PICKUP, orderId, |
| | | "orderNo", order.getCode()); |
| | | "orderNo", order.getCode(), |
| | | "name", driver.getName()); |
| | | } |
| | | |
| | | // 通知司机:抢单成功 |
| | |
| | | // 4. 更新订单状态为派送中(4) |
| | | ordersMapper.update(new UpdateWrapper<Orders>().lambda() |
| | | .set(Orders::getStatus, Constants.OrderStatus.delivering.getStatus()) |
| | | .set(Orders::getTakeTime, now) |
| | | .set(Orders::getUpdateTime, now) |
| | | .eq(Orders::getId, orderId)); |
| | | |
| | |
| | | vo.setIsUrgent(order.getIsUrgent()); |
| | | vo.setDriverFee(order.getDriverFee()); |
| | | vo.setUrgentAmount(order.getUrgentAmount()); |
| | | vo.setPlatformRewardAmount(order.getPlatformRewardAmount()); |
| | | |
| | | // 存件门店(使用Orders自带坐标) |
| | | vo.setDepositShopName(order.getDepositShopName()); |
| | | vo.setDepositShopAddress(order.getDepositShopAddress()); |
| | | vo.setDepositLng(order.getDepositLgt() != null ? order.getDepositLgt().doubleValue() : null); |
| | | vo.setDepositLat(order.getDepositLat() != null ? order.getDepositLat().doubleValue() : null); |
| | | if (needDepositDist && driverLat != null && driverLng != null |
| | | && order.getDepositLgt() != null && order.getDepositLat() != null) { |
| | | double distKm = haversine(driverLat, driverLng, |
| | | order.getDepositLgt().doubleValue(), order.getDepositLat().doubleValue()); |
| | | double distKm = haversine(driverLat, driverLng, order.getDepositLat().doubleValue(), |
| | | order.getDepositLgt().doubleValue()); |
| | | vo.setDepositDistance(formatDistance(distKm)); |
| | | } |
| | | |
| | | // 取件信息 + 联系电话(使用Orders自带坐标) |
| | | // 取件信息(使用Orders自带坐标) |
| | | boolean hasTakeShop = order.getTakeShopId() != null && StringUtils.isNotBlank(order.getTakeShopName()); |
| | | if (hasTakeShop) { |
| | | vo.setTakeName(order.getTakeShopName()); |
| | | vo.setTakeAddress(order.getTakeShopAddress()); |
| | | vo.setTakeShopId(order.getTakeShopId()); |
| | | vo.setContactPhone(order.getTakeShopLinkPhone()); |
| | | } else { |
| | | vo.setTakeName(order.getTakeLocation()); |
| | | vo.setTakeAddress(order.getTakeLocationRemark()); |
| | | vo.setContactPhone(order.getTakePhone()); |
| | | } |
| | | vo.setTakeLng(order.getTakeLgt() != null ? order.getTakeLgt().doubleValue() : null); |
| | | vo.setTakeLat(order.getTakeLat() != null ? order.getTakeLat().doubleValue() : null); |
| | | if (driverLat != null && driverLng != null |
| | | && order.getTakeLgt() != null && order.getTakeLat() != null) { |
| | | double takeDist = haversine(driverLat, driverLng, |
| | | order.getTakeLgt().doubleValue(), order.getTakeLat().doubleValue()); |
| | | double takeDist = haversine(driverLat, driverLng, order.getTakeLat().doubleValue(), |
| | | order.getTakeLgt().doubleValue()); |
| | | vo.setTakeDistance(formatDistance(takeDist)); |
| | | } |
| | | |
| | |
| | | // 待取货状态(status=3)返回司机取货码 |
| | | if (Constants.equalsInteger(order.getStatus(), Constants.THREE)||Constants.equalsInteger(order.getStatus(), Constants.FOUR)) { |
| | | vo.setDriverVerifyCode(order.getDriverVerifyCode()); |
| | | } |
| | | |
| | | // 订单状态 |
| | | vo.setStatus(order.getStatus()); |
| | | vo.setStatusDesc(getStatusDesc(order.getStatus())); |
| | | vo.setCreateTime(order.getCreateTime()); |
| | | |
| | | // 联系电话(按订单状态) |
| | | if (Constants.equalsInteger(order.getStatus(), Constants.THREE)) { |
| | | vo.setContactPhone(order.getDepositShopLinkPhone()); |
| | | } else if (Constants.equalsInteger(order.getStatus(), Constants.FOUR)) { |
| | | if (hasTakeShop) { |
| | | vo.setContactPhone(order.getTakeShopLinkPhone()); |
| | | } else { |
| | | vo.setContactPhone(order.getTakePhone()); |
| | | } |
| | | } else if (Constants.equalsInteger(order.getStatus(), Constants.FIVE)) { |
| | | vo.setContactPhone(order.getTakePhone()); |
| | | } |
| | | |
| | | // 物品明细 |
| | |
| | | for (int i = 0; i < paramPairs.length - 1; i += 2) { |
| | | templateParam.put(paramPairs[i], paramPairs[i + 1]); |
| | | } |
| | | boolean result = AliSmsService.sendSms(phone, smsNotify.getTemplateCode(), |
| | | String error = AliSmsService.sendSms(phone, smsNotify.getTemplateCode(), |
| | | templateParam.toJSONString()); |
| | | if (result) { |
| | | log.info("短信发送成功: phone={}, template={}", phone, smsNotify.name()); |
| | | } else { |
| | | log.warn("短信发送失败: phone={}, template={}", phone, smsNotify.name()); |
| | | } |
| | | // 存储短信记录 |
| | | Smsrecord record = new Smsrecord(); |
| | | record.setPhone(phone); |
| | | record.setContent(content); |
| | | record.setType(Constants.ONE); // 1=订单通知 |
| | | record.setStatus(result ? Constants.ONE : Constants.ZERO); |
| | | record.setType(Constants.ONE); |
| | | record.setStatus(error == null ? Constants.ONE : Constants.ZERO); |
| | | if (error != null) { |
| | | record.setRemark(error); |
| | | } |
| | | record.setCreateTime(new Date()); |
| | | record.setDeleted(Constants.ZERO); |
| | | smsrecordMapper.insert(record); |
| | |
| | | record.setContent(content); |
| | | record.setType(Constants.ONE); |
| | | record.setStatus(Constants.ZERO); |
| | | record.setRemark(e.getMessage()); |
| | | record.setCreateTime(new Date()); |
| | | record.setDeleted(Constants.ZERO); |
| | | smsrecordMapper.insert(record); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public void changePassword(Integer driverId, String newPassword, String token) { |
| | | if (StringUtils.isBlank(newPassword)) { |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "密码不能为空"); |
| | | public void changePassword(Integer driverId, String oldPassword, String newPassword, String token) { |
| | | if (StringUtils.isBlank(oldPassword)) { |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "旧密码不能为空"); |
| | | } |
| | | // 校验密码必须同时包含字母和数字 |
| | | if (StringUtils.isBlank(newPassword)) { |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "新密码不能为空"); |
| | | } |
| | | // 校验新密码必须同时包含字母和数字 |
| | | boolean hasLetter = newPassword.chars().anyMatch(Character::isLetter); |
| | | boolean hasDigit = newPassword.chars().anyMatch(Character::isDigit); |
| | | if (!hasLetter || !hasDigit) { |
| | |
| | | Member member = memberMapper.selectById(driverInfo.getMemberId()); |
| | | if (member == null) { |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY); |
| | | } |
| | | // 校验旧密码 |
| | | String oldEncryptPwd = secure.encryptPassword(oldPassword, member.getSalt()); |
| | | if (!oldEncryptPwd.equals(member.getPassword())) { |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "旧密码错误"); |
| | | } |
| | | // 加密新密码并更新 |
| | | String salt = RandomStringUtils.randomAlphanumeric(6); |
| | |
| | | List<Integer> validStatuses = Arrays.asList( |
| | | Constants.OrderStatus.accepted.getStatus(), |
| | | Constants.OrderStatus.delivering.getStatus(), |
| | | Constants.OrderStatus.arrived.getStatus(), |
| | | Constants.OrderStatus.finished.getStatus()); |
| | | if (status != null && !validStatuses.contains(status)) { |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "状态只能为3(待取件)、4(配送中)、7(已完成)"); |
| | |
| | | .select("s1.name", Orders::getDepositShopName) |
| | | .select("s1.address", Orders::getDepositShopAddress) |
| | | .select("s2.name", Orders::getTakeShopName) |
| | | .select("s2.address", Orders::getTakeShopAddress) |
| | | .select("s2.address", Orders::getDepositShopAddress) |
| | | .select("s1.link_phone as takeShopLinkPhone") |
| | | .select("s2.link_phone as takeShopLinkPhone") |
| | | .select("c2.other_field as c2OtherField") |
| | | .select("c2.name as goodLevelName") |
| | |
| | | return vo; |
| | | } |
| | | |
| | | @Override |
| | | public boolean checkDriverToken(String token) { |
| | | if (StringUtils.isBlank(token) || !token.startsWith(Constants.ONE + "")) { |
| | | return false; |
| | | } |
| | | String tokenRedis = (String) redisTemplate.opsForValue().get(Constants.REDIS_TOKEN_KEY + token); |
| | | if (StringUtils.isBlank(tokenRedis)) { |
| | | return false; |
| | | } |
| | | try { |
| | | int lastIndex = token.lastIndexOf("_") + 1; |
| | | Integer memberId = Integer.valueOf(token.substring(lastIndex)); |
| | | Member member = memberMapper.selectById(memberId); |
| | | return member != null |
| | | && !Constants.ONE.equals(member.getDeleted()) |
| | | && !Constants.ONE.equals(member.getStatus()) |
| | | && Constants.ONE.equals(member.getUserType()); |
| | | } catch (Exception e) { |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void registerJpushAlias(Integer driverId, String jpushAlias) { |
| | | DriverInfo update = new DriverInfo(); |
| | | update.setId(driverId); |
| | | update.setJpushAlias(jpushAlias); |
| | | driverInfoMapper.updateById(update); |
| | | } |
| | | |
| | | } |