| | |
| | | import com.doumee.dao.business.DriverInfoMapper; |
| | | import com.doumee.dao.business.MemberMapper; |
| | | import com.doumee.dao.business.MultifileMapper; |
| | | import com.doumee.dao.business.OrderCommentMapper; |
| | | import com.doumee.dao.business.SmsrecordMapper; |
| | | import com.doumee.dao.business.CategoryMapper; |
| | | import com.doumee.dao.business.OrdersMapper; |
| | | import com.doumee.dao.business.ShopInfoMapper; |
| | | import com.doumee.dao.business.OrdersDetailMapper; |
| | | import com.doumee.dao.business.RevenueMapper; |
| | | import com.doumee.biz.system.SystemDictDataBiz; |
| | |
| | | import com.doumee.dao.business.model.Category; |
| | | import com.doumee.dao.business.model.DriverInfo; |
| | | import com.doumee.dao.business.model.OrderLog; |
| | | import com.doumee.dao.business.model.OrderComment; |
| | | import com.doumee.dao.business.model.ShopInfo; |
| | | import com.doumee.dao.business.model.Member; |
| | | import com.doumee.dao.business.model.Multifile; |
| | | import com.doumee.dao.business.model.Smsrecord; |
| | |
| | | import com.doumee.service.business.NoticeService; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.github.yulichang.wrapper.MPJLambdaWrapper; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.RandomStringUtils; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | * @author rk |
| | | * @date 2026/04/08 |
| | | */ |
| | | @Slf4j |
| | | @Service |
| | | public class DriverInfoServiceImpl implements DriverInfoService { |
| | | |
| | |
| | | |
| | | @Autowired |
| | | private OrdersMapper ordersMapper; |
| | | |
| | | @Autowired |
| | | private ShopInfoMapper shopInfoMapper; |
| | | |
| | | @Autowired |
| | | private OrderCommentMapper orderCommentMapper; |
| | | |
| | | @Autowired |
| | | private RevenueMapper revenueMapper; |
| | |
| | | } |
| | | } |
| | | |
| | | // 异地寄存实时经纬度(按状态返回) |
| | | 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()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 下单附件图片 |
| | | String imgPrefix = systemDictDataBiz.queryByCode(Constants.OSS, Constants.RESOURCE_PATH).getCode() |
| | | + systemDictDataBiz.queryByCode(Constants.OSS, Constants.MEMBER_FILES).getCode(); |
| | | vo.setOrderImages(getFileUrls(orderId, Constants.FileType.ORDER_FILE.getKey(), imgPrefix)); |
| | | |
| | | // 评价信息 |
| | | vo.setCommentStatus(order.getCommentStatus()); |
| | | if (Constants.equalsInteger(order.getCommentStatus(), Constants.ONE)) { |
| | | vo.setCommentTime(order.getCommentTime()); |
| | | // 查询司机评价记录 |
| | | OrderComment driverComment = orderCommentMapper.selectOne(new QueryWrapper<OrderComment>().lambda() |
| | | .eq(OrderComment::getOrderId, orderId) |
| | | .eq(OrderComment::getTargetType, Constants.THREE) |
| | | .eq(OrderComment::getDeleted, Constants.ZERO) |
| | | .last("limit 1")); |
| | | if (driverComment != null) { |
| | | vo.setDriverScore(driverComment.getScore()); |
| | | vo.setCommentContent(driverComment.getContent()); |
| | | } |
| | | // 评价附件图片 |
| | | vo.setCommentImages(getFileUrls(orderId, Constants.FileType.COMMENT_ATTACH.getKey(), imgPrefix)); |
| | | } |
| | | |
| | | return vo; |
| | | } |
| | |
| | | sendDriverNotice(driverId, Constants.DriverOrderNotify.WAIT_DELIVER, orderId, |
| | | "orderNo", order.getCode(), |
| | | "shopName", shopName != null ? shopName : ""); |
| | | |
| | | // 短信通知司机:抢单成功,待取件 |
| | | String pickupAddress = order.getDepositShopAddress() != null ? order.getDepositShopAddress() : order.getDepositLocation(); |
| | | sendSmsNotify(driver.getTelephone(), Constants.SmsNotify.DRIVER_WAIT_PICKUP, |
| | | "orderNo", order.getCode(), |
| | | "address", pickupAddress != null ? pickupAddress : ""); |
| | | } |
| | | |
| | | @Override |
| | |
| | | // 通知司机:已取件配送中 |
| | | sendDriverNotice(driverId, Constants.DriverOrderNotify.DELIVERING, orderId, |
| | | "orderNo", order.getCode()); |
| | | |
| | | // 短信通知会员:司机已取件,配送中 |
| | | Member deliveringMember = memberMapper.selectById(order.getMemberId()); |
| | | if (deliveringMember != null) { |
| | | sendSmsNotify(deliveringMember.getTelephone(), Constants.SmsNotify.MEMBER_DELIVERING, |
| | | "orderNo", order.getCode(), |
| | | "name", driver.getName()); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | |
| | | return vo; |
| | | } |
| | | |
| | | /** |
| | | * 发送短信通知(失败不影响主业务) |
| | | */ |
| | | private void sendSmsNotify(String phone, Constants.SmsNotify smsNotify, String... paramPairs) { |
| | | if (StringUtils.isBlank(phone)) { |
| | | return; |
| | | } |
| | | String content = smsNotify.format(paramPairs); |
| | | try { |
| | | JSONObject templateParam = new JSONObject(); |
| | | for (int i = 0; i < paramPairs.length - 1; i += 2) { |
| | | templateParam.put(paramPairs[i], paramPairs[i + 1]); |
| | | } |
| | | boolean result = 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.setCreateTime(new Date()); |
| | | record.setDeleted(Constants.ZERO); |
| | | smsrecordMapper.insert(record); |
| | | } catch (Exception e) { |
| | | log.error("短信发送异常: phone={}, template={}, error={}", phone, smsNotify.name(), e.getMessage()); |
| | | try { |
| | | Smsrecord record = new Smsrecord(); |
| | | record.setPhone(phone); |
| | | record.setContent(content); |
| | | record.setType(Constants.ONE); |
| | | record.setStatus(Constants.ZERO); |
| | | record.setCreateTime(new Date()); |
| | | record.setDeleted(Constants.ZERO); |
| | | smsrecordMapper.insert(record); |
| | | } catch (Exception ignored) {} |
| | | } |
| | | } |
| | | |
| | | } |