Search in sources :

Example 1 with Logistics

use of cn.lili.modules.system.entity.dos.Logistics in project lilishop by lilishop.

the class LogisticsServiceImpl method getOrderTracesByJson.

/**
 * 获取物流信息
 *
 * @param logisticsId 物流公司ID
 * @param expNo       物流单号
 * @param customerName 手机号后四位
 * @return 物流信息
 * @throws Exception
 */
private Traces getOrderTracesByJson(String logisticsId, String expNo, String customerName) throws Exception {
    Setting setting = settingService.get(SettingEnum.KUAIDI_SETTING.name());
    if (CharSequenceUtil.isBlank(setting.getSettingValue())) {
        throw new ServiceException(ResultCode.LOGISTICS_NOT_SETTING);
    }
    KuaidiSetting kuaidiSetting = new Gson().fromJson(setting.getSettingValue(), KuaidiSetting.class);
    // ID
    String EBusinessID = kuaidiSetting.getEbusinessID();
    // KEY
    String AppKey = kuaidiSetting.getAppKey();
    // 请求url
    String ReqURL = kuaidiSetting.getReqURL();
    Logistics logistics = this.getById(logisticsId);
    if (logistics != null) {
        String requestData = "{'OrderCode':'','ShipperCode':'" + logistics.getCode() + "','LogisticCode':'" + expNo + "'" + ",'CustomerName':'" + customerName + "'" + "}";
        Map<String, String> params = new HashMap<>(8);
        params.put("RequestData", urlEncoder(requestData, "UTF-8"));
        params.put("EBusinessID", EBusinessID);
        params.put("RequestType", "1002");
        String dataSign = encrypt(requestData, AppKey, "UTF-8");
        params.put("DataSign", urlEncoder(dataSign, "UTF-8"));
        params.put("DataType", "2");
        String result = sendPost(ReqURL, params);
        Map map = (Map) JSON.parse(result);
        return new Traces(logistics.getName(), expNo, (List<Map>) map.get("Traces"));
    }
    return null;
}
Also used : KuaidiSetting(cn.lili.modules.system.entity.dto.KuaidiSetting) ServiceException(cn.lili.common.exception.ServiceException) HashMap(java.util.HashMap) Traces(cn.lili.modules.system.entity.vo.Traces) KuaidiSetting(cn.lili.modules.system.entity.dto.KuaidiSetting) Setting(cn.lili.modules.system.entity.dos.Setting) Gson(com.google.gson.Gson) HashMap(java.util.HashMap) Map(java.util.Map) Logistics(cn.lili.modules.system.entity.dos.Logistics)

Example 2 with Logistics

use of cn.lili.modules.system.entity.dos.Logistics in project lilishop by lilishop.

the class OrderServiceImpl method checkBatchDeliver.

/**
 * 循环检查批量发货订单列表
 *
 * @param list 待发货订单列表
 */
private void checkBatchDeliver(List<OrderBatchDeliverDTO> list) {
    List<Logistics> logistics = logisticsService.list();
    for (OrderBatchDeliverDTO orderBatchDeliverDTO : list) {
        // 查看订单号是否存在-是否是当前店铺的订单
        Order order = this.getOne(new LambdaQueryWrapper<Order>().eq(Order::getStoreId, UserContext.getCurrentUser().getStoreId()).eq(Order::getSn, orderBatchDeliverDTO.getOrderSn()));
        if (order == null) {
            throw new ServiceException("订单编号:'" + orderBatchDeliverDTO.getOrderSn() + " '不存在");
        } else if (!order.getOrderStatus().equals(OrderStatusEnum.UNDELIVERED.name())) {
            throw new ServiceException("订单编号:'" + orderBatchDeliverDTO.getOrderSn() + " '不能发货");
        }
        // 获取物流公司
        logistics.forEach(item -> {
            if (item.getName().equals(orderBatchDeliverDTO.getLogisticsName())) {
                orderBatchDeliverDTO.setLogisticsId(item.getId());
            }
        });
        if (CharSequenceUtil.isEmpty(orderBatchDeliverDTO.getLogisticsId())) {
            throw new ServiceException("物流公司:'" + orderBatchDeliverDTO.getLogisticsName() + " '不存在");
        }
    }
}
Also used : Order(cn.lili.modules.order.order.entity.dos.Order) ServiceException(cn.lili.common.exception.ServiceException) OrderBatchDeliverDTO(cn.lili.modules.order.order.entity.dto.OrderBatchDeliverDTO) Logistics(cn.lili.modules.system.entity.dos.Logistics)

Example 3 with Logistics

use of cn.lili.modules.system.entity.dos.Logistics in project lilishop by lilishop.

the class OrderServiceImpl method delivery.

@Override
@OrderLogPoint(description = "'订单['+#orderSn+']发货,发货单号['+#logisticsNo+']'", orderSn = "#orderSn")
@Transactional(rollbackFor = Exception.class)
public Order delivery(String orderSn, String logisticsNo, String logisticsId) {
    Order order = OperationalJudgment.judgment(this.getBySn(orderSn));
    // 如果订单未发货,并且订单状态值等于待发货
    if (order.getDeliverStatus().equals(DeliverStatusEnum.UNDELIVERED.name()) && order.getOrderStatus().equals(OrderStatusEnum.UNDELIVERED.name())) {
        // 获取对应物流
        Logistics logistics = logisticsService.getById(logisticsId);
        if (logistics == null) {
            throw new ServiceException(ResultCode.ORDER_LOGISTICS_ERROR);
        }
        // 写入物流信息
        order.setLogisticsCode(logistics.getId());
        order.setLogisticsName(logistics.getName());
        order.setLogisticsNo(logisticsNo);
        order.setLogisticsTime(new Date());
        order.setDeliverStatus(DeliverStatusEnum.DELIVERED.name());
        this.updateById(order);
        // 修改订单状态为已发送
        this.updateStatus(orderSn, OrderStatusEnum.DELIVERED);
        // 修改订单货物可以进行售后、投诉
        orderItemService.update(new UpdateWrapper<OrderItem>().eq(ORDER_SN_COLUMN, orderSn).set("after_sale_status", OrderItemAfterSaleStatusEnum.NOT_APPLIED).set("complain_status", OrderComplaintStatusEnum.NO_APPLY));
        // 发送订单状态改变消息
        OrderMessage orderMessage = new OrderMessage();
        orderMessage.setNewStatus(OrderStatusEnum.DELIVERED);
        orderMessage.setOrderSn(order.getSn());
        this.sendUpdateStatusMessage(orderMessage);
    } else {
        throw new ServiceException(ResultCode.ORDER_DELIVER_ERROR);
    }
    return order;
}
Also used : Order(cn.lili.modules.order.order.entity.dos.Order) ServiceException(cn.lili.common.exception.ServiceException) UpdateWrapper(com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper) LambdaUpdateWrapper(com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper) PintuanOrderMessage(cn.lili.trigger.message.PintuanOrderMessage) OrderMessage(cn.lili.modules.order.order.entity.dto.OrderMessage) Logistics(cn.lili.modules.system.entity.dos.Logistics) OrderLogPoint(cn.lili.modules.order.order.aop.OrderLogPoint) Transactional(org.springframework.transaction.annotation.Transactional)

Example 4 with Logistics

use of cn.lili.modules.system.entity.dos.Logistics in project lilishop by lilishop.

the class AfterSaleServiceImpl method buyerDelivery.

@AfterSaleLogPoint(sn = "#afterSaleSn", description = "'买家退货,物流填写:单号['+#afterSaleSn+'],物流单号为['+#logisticsNo+']'")
@SystemLogPoint(description = "售后-买家退货,物流填写", customerLog = "'买家退货,物流填写:单号['+#afterSaleSn+'],物流单号为['+#logisticsNo+']'")
@Override
public AfterSale buyerDelivery(String afterSaleSn, String logisticsNo, String logisticsId, Date mDeliverTime) {
    // 根据售后单号获取售后单
    AfterSale afterSale = OperationalJudgment.judgment(this.getBySn(afterSaleSn));
    // 判断为已审核通过,待邮寄的售后服务
    if (!afterSale.getServiceStatus().equals(AfterSaleStatusEnum.PASS.name())) {
        throw new ServiceException(ResultCode.AFTER_STATUS_ERROR);
    }
    // 查询会员回寄的物流公司信息
    Logistics logistics = logisticsService.getById(logisticsId);
    // 判断物流公司是否为空
    if (logistics == null) {
        throw new ServiceException(ResultCode.AFTER_STATUS_ERROR);
    }
    afterSale.setMLogisticsCode(logistics.getId());
    afterSale.setMLogisticsName(logistics.getName());
    afterSale.setMLogisticsNo(logisticsNo);
    afterSale.setMDeliverTime(mDeliverTime);
    // 修改售后单状态
    afterSale.setServiceStatus(AfterSaleStatusEnum.BUYER_RETURN.name());
    // 根据售后编号修改售后单
    this.updateAfterSale(afterSaleSn, afterSale);
    return afterSale;
}
Also used : AfterSale(cn.lili.modules.order.aftersale.entity.dos.AfterSale) ServiceException(cn.lili.common.exception.ServiceException) Logistics(cn.lili.modules.system.entity.dos.Logistics) AfterSaleLogPoint(cn.lili.modules.order.aftersale.aop.AfterSaleLogPoint) SystemLogPoint(cn.lili.modules.system.aspect.annotation.SystemLogPoint)

Aggregations

ServiceException (cn.lili.common.exception.ServiceException)4 Logistics (cn.lili.modules.system.entity.dos.Logistics)4 Order (cn.lili.modules.order.order.entity.dos.Order)2 AfterSaleLogPoint (cn.lili.modules.order.aftersale.aop.AfterSaleLogPoint)1 AfterSale (cn.lili.modules.order.aftersale.entity.dos.AfterSale)1 OrderLogPoint (cn.lili.modules.order.order.aop.OrderLogPoint)1 OrderBatchDeliverDTO (cn.lili.modules.order.order.entity.dto.OrderBatchDeliverDTO)1 OrderMessage (cn.lili.modules.order.order.entity.dto.OrderMessage)1 SystemLogPoint (cn.lili.modules.system.aspect.annotation.SystemLogPoint)1 Setting (cn.lili.modules.system.entity.dos.Setting)1 KuaidiSetting (cn.lili.modules.system.entity.dto.KuaidiSetting)1 Traces (cn.lili.modules.system.entity.vo.Traces)1 PintuanOrderMessage (cn.lili.trigger.message.PintuanOrderMessage)1 LambdaUpdateWrapper (com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper)1 UpdateWrapper (com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper)1 Gson (com.google.gson.Gson)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Transactional (org.springframework.transaction.annotation.Transactional)1