Exemplo n.º 1
0
  @Override
  public void populate(final TaslyOrderData source, final ExportOrder target)
      throws ConversionException, IllegalArgumentException {
    target.setOrderId(source.getOrderId());
    target.setBuyerMessage(source.getBuyer_message());
    target.setChannelSource(ChannelSource.valueOf(source.getChannel_source().toString()));
    target.setConfirmReceivedTime(source.getConfirm_received_time());
    target.setDeliveryService(DeliveryServiceType.valueOf(source.getDelivery_service().toString()));
    target.setDiscountFee(source.getDiscount_fee());
    target.setEccBankName(source.getEcc_bank_name());
    target.setEccBankNumber(source.getEcc_bank_number());
    target.setEccCustomerAddress(source.getEcc_customer_address());
    target.setEccCustomerPhone(source.getEcc_customer_phone());
    target.setEccTaxpayerNumber(source.getEcc_taxpayer_number());
    target.setInnerSource(InnerSource.valueOf(source.getInner_source().toString()));
    target.setInvoiceContent(source.getInvoice_content());
    target.setInvoiceName(source.getInvoice_name());
    target.setInvoiceType(source.getInvoice_type());
    target.setIssueDate(source.getIssueDate());
    target.setNickName(source.getNick_name());
    target.setOriginalOrderId(source.getOriginal_order_id());
    target.setPaymentNo(source.getPayment_no());
    target.setPaymentPointAmount(source.getPayment_point_amount());
    final List<PaymentInfoData> paymentInfos = source.getPaymentInfos();
    final StringBuffer sb1 = new StringBuffer();
    final StringBuffer sb2 = new StringBuffer();
    for (final PaymentInfoData paymentInfoData : paymentInfos) {
      if (paymentInfoData instanceof TaslyPaymentInfoData) {
        sb1.append(paymentInfoData.getPaymentInfoType());
        sb1.append(';');
        sb2.append(((TaslyPaymentInfoData) paymentInfoData).getIssuedate());
        sb2.append(';');
      }
    }
    target.setPaymentInfoTypes(sb1.toString());
    target.setPaymentIssueDates(sb2.toString());
    target.setSellerMessage(source.getSeller_message());
    target.setShadCity(source.getShad_city());
    target.setShadCitydistrict(source.getShad_citydistrict());
    target.setShadCountrySubentity(source.getShippingAddress().getCountrySubentity());
    target.setShadMobile(source.getShad_mobile());
    target.setShadPhoneNumber(source.getShippingAddress().getPhoneNumber());
    target.setShadPostalZone(source.getShippingAddress().getPostalZone());
    target.setShippingFirstName(source.getShippingFirstName());
    target.setShprInsurance(
        ((TaslyShippingAndHandlingData) source.getShippingAndHandling()).getShpr_insurance());
    target.setShprSubTotalValue(
        source.getShippingAndHandling().getShippingPrice().getSubTotalValue());
    target.setTotalPrice(source.getTotal_price());
    target.setApproveStatus(ApproveStatus.valueOf(source.getApprove_status().toString()));
    target.setShippingLockStatus(
        ShippingLockStatus.valueOf(source.getShipping_lock_status().toString()));
    target.setShadAddressLine1(source.getShippingAddress().getAddressLine1());

    populateOrderLines(source, target);
  }
Exemplo n.º 2
0
  @Override
  public TaslyOrderData modifyLogisticsCompany(final TaslyOrderData orderData) {
    final String innerSource = orderData.getInner_source().name();
    final String channel = orderData.getChannel_source().name();
    final String receiverState = orderData.getShippingAddress().getCountrySubentity();

    // *************** 拆分邮寄方式 ***************
    String realLogisticsCompany = null;
    final List<OrderLineData> orderLineDatas = orderData.getOrderLines();

    final int num = orderLineDatas.size();
    String expressCode = null;
    // 根据sku判断商品物流
    for (int i = 0; i < num; i++) {
      final List<OrderLineQuantityData> orderLineQuantityDatas =
          orderLineDatas.get(i).getOrderLineQuantities();

      for (final OrderLineQuantityData orderLineQuantityData : orderLineQuantityDatas) {
        if (orderLineQuantityData.getClass().isInstance(TaslyOrderLineQuantityData.class)) {
          final TaslyOrderLineQuantityData taslyOrderLineQuantityData =
              (TaslyOrderLineQuantityData) orderLineQuantityData;
          expressCode = taslyOrderLineQuantityData.getExpress_code();
        }
      }

      if (StringUtils.isEmpty(expressCode)) {
        String logisticsCompanyForLocal = null;
        final String skuId = orderLineDatas.get(i).getSkuId();
        logisticsCompanyForLocal = omsQueryDao.getExpressBySku(skuId, channel, innerSource);

        if (!StringUtils.isEmpty(logisticsCompanyForLocal)) {
          realLogisticsCompany = logisticsCompanyForLocal;
          break;
        }
      }
    }
    // 根据送货地点判断商品物流
    if (realLogisticsCompany == null) {
      realLogisticsCompany = omsQueryDao.getExpressByLocation(receiverState, channel, innerSource);
    }

    // 所有order更改物流公司
    for (int j = 0; j < num; j++) {
      final List<OrderLineQuantityData> orderLineQuantityDatas =
          orderLineDatas.get(j).getOrderLineQuantities();

      for (final OrderLineQuantityData orderLineQuantityData : orderLineQuantityDatas) {
        if (orderLineQuantityData instanceof TaslyOrderLineQuantityData) {
          final TaslyOrderLineQuantityData taslyOrderLineQuantityData =
              (TaslyOrderLineQuantityData) orderLineQuantityData;
          taslyOrderLineQuantityData.setExpress_code(realLogisticsCompany);
        }
      }
    }

    return orderData;
  }