Advertisement
Guest User

Untitled

a guest
Jun 19th, 2018
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 76.46 KB | None | 0 0
  1. package br.hering.fulfilmentprocess.services.impl;
  2.  
  3. import java.io.PrintWriter;
  4. import java.io.StringWriter;
  5. import java.math.BigDecimal;
  6. import java.math.RoundingMode;
  7. import java.text.ParseException;
  8. import java.text.SimpleDateFormat;
  9. import java.util.ArrayList;
  10. import java.util.Collection;
  11. import java.util.Date;
  12. import java.util.HashMap;
  13. import java.util.List;
  14. import java.util.Map;
  15.  
  16. import javax.annotation.Resource;
  17. import javax.xml.bind.JAXBContext;
  18. import javax.xml.bind.JAXBElement;
  19. import javax.xml.bind.JAXBException;
  20. import javax.xml.bind.Marshaller;
  21.  
  22. import org.apache.commons.collections.CollectionUtils;
  23. import org.apache.commons.lang.StringUtils;
  24. import org.apache.log4j.Logger;
  25. import org.springframework.beans.factory.annotation.Autowired;
  26. import org.springframework.ws.client.core.WebServiceTemplate;
  27.  
  28. import com.flieger.adyen.service.AdyenPaymentTransactionEntryService;
  29. import com.flieger.carrier.services.CarrierDeliveryService;
  30. import com.flieger.carrier.services.CarrierZoneDeliveryModeService;
  31. import com.flieger.data.NewsletterSubscriberData;
  32. import com.flieger.facades.NewsletterSubscriberFacade;
  33. import com.flieger.payment.model.AbstractPaymentInfoModel;
  34. import com.flieger.payment.model.AdyenCreditCardPaymentInfoModel;
  35. import com.flieger.payment.model.AdyenDebitPaymentInfoModel;
  36. import com.flieger.payment.model.BoletoPaymentInfoModel;
  37. import com.flieger.payment.model.MultiplePaymentInfoModel;
  38.  
  39. import br.com.hering.oms.enums.OMSRefundType;
  40. import br.com.hering.oms.model.ReservePaymentInfoModel;
  41. import br.hering.core.enums.BankAccountType;
  42. import br.hering.core.enums.TipoDeEndereco;
  43. import br.hering.core.model.BankInformationsModel;
  44. import br.hering.core.model.ExchangeAndReturnProcessModel;
  45. import br.hering.core.model.ExchangeAndReturnProductsModel;
  46. import br.hering.core.model.HeringSizeVariantProductModel;
  47. import br.hering.core.model.order.payment.VoucherPaymentInfoModel;
  48. import br.hering.fulfilmentprocess.dao.OMSOrderDao;
  49. import br.hering.fulfilmentprocess.exceptions.AddressMethodException;
  50. import br.hering.fulfilmentprocess.exceptions.DeliveryModeException;
  51. import br.hering.fulfilmentprocess.message.order.oms.CancelFulfillment;
  52. import br.hering.fulfilmentprocess.message.order.oms.Categorias;
  53. import br.hering.fulfilmentprocess.message.order.oms.Cliente;
  54. import br.hering.fulfilmentprocess.message.order.oms.CustosDeFrete;
  55. import br.hering.fulfilmentprocess.message.order.oms.DadosPedido;
  56. import br.hering.fulfilmentprocess.message.order.oms.Endereco;
  57. import br.hering.fulfilmentprocess.message.order.oms.ExtensionAttributes;
  58. import br.hering.fulfilmentprocess.message.order.oms.Fornecimento;
  59. import br.hering.fulfilmentprocess.message.order.oms.Fornecimentos;
  60. import br.hering.fulfilmentprocess.message.order.oms.ImportarPedidoRequest;
  61. import br.hering.fulfilmentprocess.message.order.oms.Item;
  62. import br.hering.fulfilmentprocess.message.order.oms.Items;
  63. import br.hering.fulfilmentprocess.message.order.oms.Itens;
  64. import br.hering.fulfilmentprocess.message.order.oms.Pagamento;
  65. import br.hering.fulfilmentprocess.message.order.oms.Pedido;
  66. import br.hering.fulfilmentprocess.message.order.oms.Refund;
  67. import br.hering.fulfilmentprocess.message.order.oms.RefundAttributes;
  68. import br.hering.fulfilmentprocess.message.order.oms.Remessa;
  69. import br.hering.fulfilmentprocess.message.order.oms.Resultado;
  70. import br.hering.fulfilmentprocess.message.order.oms.ReturnFulfillment;
  71. import br.hering.fulfilmentprocess.message.order.oms.SendFulfillmentCancellationResponse;
  72. import br.hering.fulfilmentprocess.message.order.oms.SendFulfillmentReturnResponse;
  73. import br.hering.fulfilmentprocess.message.order.oms.SendOrderResponse;
  74. import br.hering.fulfilmentprocess.message.order.oms.Vendedor;
  75. import br.hering.fulfilmentprocess.services.ExportOMSOrderService;
  76. import br.hering.fulfilmentprocess.services.impl.DefaultExportOrderService.TipoDePagamento;
  77. import de.hybris.platform.basecommerce.enums.ConsignmentStatus;
  78. import de.hybris.platform.category.model.CategoryModel;
  79. import de.hybris.platform.commerceservices.constants.GeneratedCommerceServicesConstants.Enumerations.CustomerType;
  80. import de.hybris.platform.commerceservices.product.CommerceProductService;
  81. import de.hybris.platform.commerceservices.url.UrlResolver;
  82. import de.hybris.platform.core.enums.Gender;
  83. import de.hybris.platform.core.model.order.AbstractOrderEntryModel;
  84. import de.hybris.platform.core.model.order.OrderModel;
  85. import de.hybris.platform.core.model.order.payment.CreditCardPaymentInfoModel;
  86. import de.hybris.platform.core.model.order.price.DiscountModel;
  87. import de.hybris.platform.core.model.product.ProductModel;
  88. import de.hybris.platform.core.model.user.AddressModel;
  89. import de.hybris.platform.core.model.user.CustomerModel;
  90. import de.hybris.platform.ordersplitting.model.ConsignmentEntryModel;
  91. import de.hybris.platform.ordersplitting.model.ConsignmentModel;
  92. import de.hybris.platform.payment.enums.PaymentTransactionType;
  93. import de.hybris.platform.payment.model.PaymentTransactionEntryModel;
  94. import de.hybris.platform.util.Config;
  95. import de.hybris.platform.util.DiscountValue;
  96. import de.hybris.platform.voucher.VoucherService;
  97. import de.hybris.platform.voucher.model.PromotionVoucherModel;
  98. import de.hybris.platform.voucher.model.VoucherModel;
  99.  
  100. public class DefaultExportOMSOrderService implements ExportOMSOrderService {
  101.  
  102. public static enum TipoDePagamento{
  103. VALE_PRESENTE("VALE PRESENTE", "&", "Vale presente liberado pelo Sac"),
  104. GIFT_CARD("GIFT CARD", "@", "Recebimento com o Gift Card"),
  105. CARTAO_DE_CREDITO("CARTAO DE CREDITO", "CREDIT_CARD", "Pagamento com Cartão de Crédito"),
  106. CARTAO_DE_DEBITO("CARTAO DE DEBITO", "E", "Pagamento com Cartão de Débito"),
  107. BOLETO("BOLETO", "BOLETO", "Pagamento com Boleto"),
  108. DEBITO_ONLINE("DEBITO ONLINE", "U", "Pagamento com Debito Online"),
  109. VALE_CREDITO("VALE CREDITO", "CUSTOMER_CREDIT", "Utilizado em casos de Créditos por devolução"),
  110. ESTORNO_CARTO_CREDITO("ESTORNO CARTAO DE CREDITO", "X", "Estorno da Compra do Cartão de Crédito"),
  111. RESERVA("RESERVA", "RESERVE", "Reservar para retirada em loja");
  112.  
  113. private final String name;
  114. private final String code;
  115. private final String description;
  116.  
  117. TipoDePagamento(final String name, final String code, final String description){
  118. this.name = name;
  119. this.code = code;
  120. this.description = description;
  121. }
  122.  
  123. /**
  124. * @return the name
  125. */
  126. public String getName() {
  127. return name;
  128. }
  129.  
  130. /**
  131. * @return the code
  132. */
  133. public String getCode() {
  134. return code;
  135. }
  136.  
  137. /**
  138. * @return the description
  139. */
  140. public String getDescription() {
  141. return description;
  142. }
  143. }
  144.  
  145. protected final Logger LOG = Logger.getLogger(this.getClass());
  146.  
  147. private static final String CLEARSALE = "ClearSale";
  148.  
  149. private static final int APROVADO_CLEARSALE = 1;
  150.  
  151. private static final String VOUCHER_VALIDATE = "vc_";
  152.  
  153. private static final String VOUCHER_DEVOLUTION = "return_";
  154.  
  155. private static final String VOUCHER_EXCHANGE = "exchange_";
  156.  
  157. private static final String VOUCHER_OLD_EXCHAGE = "old_exchange_";
  158.  
  159. private static final String VALE_PRESENTE = "gf";
  160.  
  161. private static final String CIELO = "cielo";
  162.  
  163. private static final String PENDING = "PENDING";
  164.  
  165. private static final String WAITING = "WAITING";
  166.  
  167. private static final Map<String, String> STORE_CODE_MAPPING;
  168. static {
  169. STORE_CODE_MAPPING = new HashMap<String,String>();
  170. STORE_CODE_MAPPING.put("hering", "001");
  171. STORE_CODE_MAPPING.put("dzarm", "002");
  172. STORE_CODE_MAPPING.put("puc", "003");
  173. STORE_CODE_MAPPING.put("kids", "004");
  174. STORE_CODE_MAPPING.put("foryou", "005");
  175. STORE_CODE_MAPPING.put("outlet", "006");
  176. }
  177.  
  178. @Autowired
  179. private WebServiceTemplate enviarPedidosWSTemplate;
  180.  
  181. @Resource(name = "newsletterSubscriptionFacade")
  182. private NewsletterSubscriberFacade newsletterSubscriptionFacade;
  183.  
  184. @Resource
  185. CarrierDeliveryService deliveryService;
  186.  
  187. @Resource
  188. private CarrierZoneDeliveryModeService zoneDeliveryModeService;
  189.  
  190. @Resource
  191. private VoucherService voucherService;
  192.  
  193. @Resource
  194. private AdyenPaymentTransactionEntryService paymentTransactionEntryService;
  195.  
  196. @Resource
  197. private CommerceProductService commerceProductService;
  198.  
  199. @Resource
  200. private UrlResolver<ProductModel> productModelUrlResolver;
  201.  
  202. private OMSOrderDao omsOrderDao;
  203.  
  204. @Override
  205. public boolean exportOrder(final OrderModel order)
  206. {
  207. LOG.info("Iniciando envio do pedido numero:" + order.getCode() + " para o OMS via PI.");
  208.  
  209. final DadosPedido omsDadosPedido = new DadosPedido();
  210. boolean success = this.populateDadosPedido(order, omsDadosPedido);
  211.  
  212. final ImportarPedidoRequest request = new ImportarPedidoRequest();
  213. request.setDadosPedido(omsDadosPedido);
  214.  
  215. try
  216. {
  217. exportToString(request);
  218.  
  219. enviarPedidosWSTemplate.setDefaultUri(Config.getParameter("enviar.pedidos.oms.ws.template"));
  220.  
  221. JAXBElement<SendOrderResponse> response = (JAXBElement<SendOrderResponse>) enviarPedidosWSTemplate.marshalSendAndReceive(request);
  222.  
  223. LOG.info("RESPOSTA PI");
  224. LOG.info("RespondeCode: " + response.getValue().getReturn().getResponseCode());
  225. LOG.info("ResponseMessage: " + response.getValue().getReturn().getResponseMessage());
  226. LOG.info("ResponseJsonRequest: " + response.getValue().getReturn().getResponseJsonRequest());
  227. }
  228. catch(Exception e)
  229. {
  230. StringWriter sw = new StringWriter();
  231. e.printStackTrace(new PrintWriter(sw));
  232. LOG.error(e.getMessage());
  233. LOG.error(sw.toString());
  234. }
  235.  
  236. LOG.info("Envio do pedido numero:" + order.getCode() + " Finalizado"
  237. + (success ? " sem" : " com") + " erros.");
  238.  
  239. return success;
  240.  
  241. }
  242.  
  243. /**
  244. * @param order
  245. */
  246. @Override
  247. public void exportStatus(OrderModel order) {
  248. // do nothing
  249. }
  250.  
  251. @Override
  252. public boolean exportExchangeAndReturn(OrderModel order)
  253. {
  254. boolean success = false;
  255.  
  256. if (checkIfOrderOldExchange(order))
  257. {
  258. return true;
  259. }
  260.  
  261. if (checkIfOrderReturn(order))
  262. {
  263. ReturnFulfillment returnFulfilment = new ReturnFulfillment();
  264. success = populateReturnFulfilmentReturn(order, returnFulfilment);
  265. sendRequestExchangeReturn(returnFulfilment);
  266. }
  267. else if (checkIfOrderExchange(order))
  268. {
  269. ReturnFulfillment returnFulfilment = new ReturnFulfillment();
  270. success = populateReturnFulfilmentExchange(order, returnFulfilment);
  271. sendRequestExchangeReturn(returnFulfilment);
  272. } else {
  273. return true;
  274. }
  275.  
  276. LOG.info("Envio do pedido numero:" + order.getCode() + " Finalizado" );
  277.  
  278. return success;
  279.  
  280.  
  281. }
  282.  
  283. /**
  284. * @param returnFulfilment
  285. */
  286. private void sendRequestExchangeReturn(ReturnFulfillment returnFulfilment) {
  287. try
  288. {
  289. exportToString(returnFulfilment);
  290.  
  291. enviarPedidosWSTemplate.setDefaultUri(Config.getParameter("enviar.troca.devolucao.oms.ws.template"));
  292.  
  293. JAXBElement<SendFulfillmentReturnResponse> response = (JAXBElement<SendFulfillmentReturnResponse>) enviarPedidosWSTemplate.marshalSendAndReceive(returnFulfilment);
  294.  
  295. LOG.info("RESPOSTA PI");
  296. LOG.info("RespondeCode: " + response.getValue().getReturn().getResponseCode());
  297. LOG.info("ResponseMessage: " + response.getValue().getReturn().getResponseMessage());
  298. LOG.info("ResponseJsonRequest: " + response.getValue().getReturn().getResponseJsonRequest());
  299. }
  300. catch(Exception e)
  301. {
  302. StringWriter sw = new StringWriter();
  303. e.printStackTrace(new PrintWriter(sw));
  304. LOG.error(e.getMessage());
  305. LOG.error(sw.toString());
  306. }
  307. }
  308.  
  309. /**
  310. * @param order
  311. * @param returnFulfilment
  312. * @return
  313. */
  314. private boolean populateReturnFulfilmentExchange(OrderModel order,
  315. ReturnFulfillment returnFulfilment) {
  316. ExchangeAndReturnProcessModel exchangeAndReturnProcess = order.getExchangeAndReturnProcess();
  317. OrderModel originalOrder = getOmsOrderDao().getOrderByCode(exchangeAndReturnProcess.getOriginalOrderCode());
  318. String consignmentCode = originalOrder.getConsignments().iterator().next().getOmsFulfillmentId();
  319.  
  320. if (consignmentCode == null || StringUtils.isBlank(consignmentCode))
  321. {
  322. consignmentCode = "F1";
  323. }
  324.  
  325. returnFulfilment.setClientId(Config.getParameter("hering.omni.oms.clientid"));
  326. returnFulfilment.setChannelId(order.getStore().getOmsChannel().getCode());
  327. returnFulfilment.setCancelationReason("OTHER");
  328. returnFulfilment.setFulfillmentId(consignmentCode);
  329. returnFulfilment.setOrderId(originalOrder.getCode());
  330. returnFulfilment.setExceptionId(exchangeAndReturnProcess.getChangedOldProductsOrderCode());
  331. returnFulfilment.setPlacedAt(convertDate(order.getDate()));
  332.  
  333. //ADD OLD_EXCHANGE ORDER CODE (DV01)
  334.  
  335. //POPULATE EXTENSION ATTRIBUTES
  336. ExtensionAttributes extensionAttributes = new ExtensionAttributes();
  337. extensionAttributes.setHybrisExchangeOrderId(exchangeAndReturnProcess.getChangedOldProductsOrderCode());
  338. /*extensionAttributes.setHybrisRefundOrderId("null");*/
  339. extensionAttributes.setReturnText(exchangeAndReturnProcess.getDescription());
  340. extensionAttributes.setReverseLogisticTrackingCode(exchangeAndReturnProcess.getCodigoAutPostagem());
  341.  
  342. Items items = new Items();
  343. List<Item> itemList = new ArrayList<Item>();
  344.  
  345. List<ExtensionAttributes> extensionAttributesList = new ArrayList<ExtensionAttributes>();
  346. extensionAttributesList.add(extensionAttributes);
  347.  
  348. returnFulfilment.getExtensionAttributes().addAll(extensionAttributesList);
  349.  
  350. int i = 1;
  351.  
  352. for (ExchangeAndReturnProductsModel exchangeReturnProduct : exchangeAndReturnProcess.getChangedProducts())
  353. {
  354. Item item = new Item();
  355. item.setSku(exchangeReturnProduct.getOriginalProduct().getCode());
  356. item.setQuantity(exchangeReturnProduct.getQuantity().toString());
  357. item.setStockType("PHYSICAL");
  358.  
  359. br.hering.fulfilmentprocess.message.order.oms.Item.ExtensionAttributes itemExtAttributes = new br.hering.fulfilmentprocess.message.order.oms.Item.ExtensionAttributes();
  360.  
  361. itemExtAttributes.setHybrisItemSequenceId(String.valueOf(i++));
  362. itemExtAttributes.setHybrisReferenceOrderId(exchangeAndReturnProcess.getChangedOldProductsOrderCode());
  363.  
  364. HeringSizeVariantProductModel heringProduto = (HeringSizeVariantProductModel) exchangeReturnProduct.getOriginalProduct();
  365.  
  366. itemExtAttributes.setProductColorId(heringProduto.getBaseProduct().getCode().split("_")[1]);
  367. itemExtAttributes.setProductId(heringProduto.getBaseProduct().getCode().split("_")[0]);
  368. itemExtAttributes.setReason(String.valueOf(exchangeReturnProduct.getReason()));
  369.  
  370. item.setExtensionAttributes(itemExtAttributes);
  371.  
  372. itemList.add(item);
  373.  
  374. }
  375.  
  376. returnFulfilment.setItems(items);
  377. returnFulfilment.getItems().getItem().addAll(itemList);
  378.  
  379. final DadosPedido omsDadosPedido = new DadosPedido();
  380.  
  381. boolean success = this.populateDadosPedido(order, omsDadosPedido);
  382.  
  383. final ImportarPedidoRequest request = new ImportarPedidoRequest();
  384. request.setDadosPedido(omsDadosPedido);
  385. br.hering.fulfilmentprocess.message.order.oms.Order newOrder = new br.hering.fulfilmentprocess.message.order.oms.Order();
  386. newOrder.setImportarPedidoRequest(request);
  387. returnFulfilment.setOrder(newOrder);
  388.  
  389. return true;
  390. }
  391.  
  392. private boolean populateReturnFulfilmentReturn(OrderModel order,
  393. ReturnFulfillment returnFulfilment) {
  394. ExchangeAndReturnProcessModel exchangeAndReturnProcess = order.getExchangeAndReturnProcess();
  395. OrderModel originalOrder = getOmsOrderDao().getOrderByCode(exchangeAndReturnProcess.getOriginalOrderCode());
  396. String fulfillmentCode = originalOrder.getConsignments().iterator().next().getOmsFulfillmentId();
  397.  
  398. if (fulfillmentCode == null || StringUtils.isBlank(fulfillmentCode))
  399. {
  400. fulfillmentCode = "F1";
  401. }
  402.  
  403. returnFulfilment.setClientId(Config.getParameter("hering.omni.oms.clientid"));
  404. returnFulfilment.setChannelId(order.getStore().getOmsChannel().getCode());
  405. returnFulfilment.setCancelationReason("OTHER");
  406. returnFulfilment.setFulfillmentId(fulfillmentCode);
  407. returnFulfilment.setOrderId(originalOrder.getCode());
  408. returnFulfilment.setExceptionId(order.getCode());
  409.  
  410. returnFulfilment.setPlacedAt(convertDate(order.getDate()));
  411. //ADD RETURN ORDER CODE (DV01)
  412.  
  413. //POPULATE EXTENSION ATTRIBUTES
  414. ExtensionAttributes extensionAttributes = new ExtensionAttributes();
  415. /*extensionAttributes.setHybrisExchangeOrderId("null");*/
  416. extensionAttributes.setHybrisRefundOrderId(order.getCode());
  417. extensionAttributes.setReturnText(exchangeAndReturnProcess.getDescription());
  418. extensionAttributes.setReverseLogisticTrackingCode(exchangeAndReturnProcess.getCodigoAutPostagem());
  419.  
  420. List<ExtensionAttributes> extensionAttributesList = new ArrayList<ExtensionAttributes>();
  421. extensionAttributesList.add(extensionAttributes);
  422.  
  423. returnFulfilment.getExtensionAttributes().addAll(extensionAttributesList);
  424.  
  425. Items items = new Items();
  426. List<Item> itemList = new ArrayList<Item>();
  427.  
  428. int i = 1;
  429.  
  430. for (ExchangeAndReturnProductsModel exchangeReturnProduct : exchangeAndReturnProcess.getReturnProducts())
  431. {
  432. Item item = new Item();
  433. item.setSku(exchangeReturnProduct.getOriginalProduct().getCode());
  434. item.setQuantity(exchangeReturnProduct.getQuantity().toString());
  435. item.setStockType("PHYSICAL");
  436.  
  437. br.hering.fulfilmentprocess.message.order.oms.Item.ExtensionAttributes itemExtAttributes = new br.hering.fulfilmentprocess.message.order.oms.Item.ExtensionAttributes();
  438.  
  439. itemExtAttributes.setHybrisItemSequenceId(String.valueOf(i++));
  440. itemExtAttributes.setHybrisReferenceOrderId(order.getCode());
  441.  
  442. HeringSizeVariantProductModel heringProduto = (HeringSizeVariantProductModel) exchangeReturnProduct.getOriginalProduct();
  443.  
  444. itemExtAttributes.setProductColorId(heringProduto.getBaseProduct().getCode().split("_")[1]);
  445. itemExtAttributes.setProductId(heringProduto.getBaseProduct().getCode().split("_")[0]);
  446. itemExtAttributes.setReason(String.valueOf(exchangeReturnProduct.getReason()));
  447.  
  448. item.setExtensionAttributes(itemExtAttributes);
  449.  
  450. itemList.add(item);
  451.  
  452. }
  453.  
  454. returnFulfilment.setItems(items);
  455. returnFulfilment.getItems().getItem().addAll(itemList);
  456.  
  457. Refund refund = new Refund();
  458. refund.setRefundValue(String.valueOf(exchangeAndReturnProcess.getTotalValueReturned()));
  459.  
  460. RefundAttributes atts = new RefundAttributes();
  461.  
  462. if (exchangeAndReturnProcess.getBankInformation() != null)
  463. {
  464. BankInformationsModel bankInfo = exchangeAndReturnProcess.getBankInformation();
  465.  
  466. refund.setRefundType(OMSRefundType.OFFLINE_REFUND.getCode());
  467.  
  468. if (exchangeAndReturnProcess.getBankInformation().getOperation().equals("Corrente"))
  469. {
  470. atts.setBankAccountType("conta-corrente");
  471. }
  472. else
  473. {
  474. atts.setBankAccountType("conta-poupança");
  475. }
  476.  
  477. atts.setBankCode(bankInfo.getBank());
  478. atts.setBankBranch(bankInfo.getAgency());
  479.  
  480. if(bankInfo.getAgency().contains("-"))
  481. {
  482. atts.setBankBranch(bankInfo.getAgency().split("-")[0]);
  483. atts.setBankBranchCheckDigit(bankInfo.getAgency().split("-")[1]);
  484. } else {
  485.  
  486. atts.setBankBranch(bankInfo.getAgency());
  487.  
  488. }
  489.  
  490. if(bankInfo.getAccount().contains("-"))
  491. {
  492. atts.setBankAccount(bankInfo.getAccount().split("-")[0]);
  493. atts.setBankAccountCheckDigit(bankInfo.getAccount().split("-")[1]);
  494. } else {
  495.  
  496. atts.setBankAccount(bankInfo.getAccount());
  497.  
  498. }
  499.  
  500. atts.setCustomerDocumentNumber(bankInfo.getDocument());
  501. atts.setCustomerName(bankInfo.getAccountHolder());
  502. }
  503. else if (exchangeAndReturnProcess.getIsCreditNote() != null && exchangeAndReturnProcess.getIsCreditNote())
  504. {
  505. refund.setRefundType(OMSRefundType.GIFTCARD.getCode());
  506.  
  507. } else {
  508.  
  509. refund.setRefundType(OMSRefundType.PAYMENT_VOID.getCode());
  510. }
  511.  
  512. refund.setRefundAttributes(atts);
  513.  
  514. returnFulfilment.setRefund(refund);
  515.  
  516. return true;
  517. }
  518.  
  519. private String getOriginalExchangedProductSku(OrderModel order, String newProductSku) {
  520.  
  521. ExchangeAndReturnProcessModel exchangeAndReturnProcess = order.getExchangeAndReturnProcess();
  522.  
  523. for (ExchangeAndReturnProductsModel exchangeReturnProduct : exchangeAndReturnProcess.getChangedProducts())
  524. {
  525.  
  526. if (exchangeReturnProduct.getChangedProduct() != null && newProductSku.equals(exchangeReturnProduct.getChangedProduct().getCode())) {
  527.  
  528. return exchangeReturnProduct.getOriginalProduct().getCode();
  529.  
  530. }
  531.  
  532. }
  533.  
  534. return StringUtils.EMPTY;
  535. }
  536.  
  537. private boolean checkIfOrderOldExchange(OrderModel order)
  538. {
  539. for (DiscountModel discount : order.getDiscounts())
  540. {
  541. if (discount.getCode().contains("OLD_EXCHANGE"))
  542. {
  543. return true;
  544. }
  545. }
  546.  
  547. return false;
  548. }
  549.  
  550. private boolean checkIfOrderExchange(OrderModel order)
  551. {
  552. for (DiscountModel discount : order.getDiscounts())
  553. {
  554. if (discount.getCode().contains("EXCHANGE"))
  555. {
  556. return true;
  557. }
  558. }
  559.  
  560. return false;
  561. }
  562.  
  563. private boolean checkIfOrderReturn(OrderModel order)
  564. {
  565. for (DiscountModel discount : order.getDiscounts())
  566. {
  567. if (discount.getCode().contains("RETURN"))
  568. {
  569. return true;
  570. }
  571. }
  572.  
  573. return false;
  574. }
  575.  
  576. @Override
  577. public boolean exportCancelOrRefund(OrderModel order)
  578. {
  579. boolean success = true;
  580.  
  581. for (ConsignmentModel consignment : order.getConsignments())
  582. {
  583. if (consignment.getStatus().equals(ConsignmentStatus.CANCELLING))
  584. {
  585. success = exportCancelOrRefund(order, consignment);
  586. }
  587. }
  588.  
  589. return success;
  590. }
  591.  
  592. private boolean exportCancelOrRefund(OrderModel order, ConsignmentModel consignment)
  593. {
  594. LOG.info("Iniciando envio do pedido numero:" + order.getCode() + " para o OMS via PI.");
  595.  
  596. CancelFulfillment cancelFulfilment = new CancelFulfillment();
  597. populateCancelFulfilment(order, consignment, cancelFulfilment);
  598.  
  599. try
  600. {
  601. exportToString(cancelFulfilment);
  602.  
  603. enviarPedidosWSTemplate.setDefaultUri(Config.getParameter("enviar.pedidos.pendentes"));
  604.  
  605. JAXBContext context = JAXBContext.newInstance(CancelFulfillment.class);
  606. Marshaller m = context.createMarshaller();
  607. m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
  608. m.marshal(cancelFulfilment, System.out);
  609.  
  610. JAXBElement<SendFulfillmentCancellationResponse> response = (JAXBElement<SendFulfillmentCancellationResponse>) enviarPedidosWSTemplate.marshalSendAndReceive(cancelFulfilment);
  611.  
  612. LOG.info("RESPOSTA PI");
  613. LOG.info("RespondeCode: " + response.getValue().getReturn().getResponseCode());
  614. LOG.info("ResponseMessage: " + response.getValue().getReturn().getResponseMessage());
  615. LOG.info("ResponseJsonRequest: " + response.getValue().getReturn().getResponseJsonRequest());
  616. }
  617. catch(Exception e)
  618. {
  619. StringWriter sw = new StringWriter();
  620. e.printStackTrace(new PrintWriter(sw));
  621. LOG.error(e.getMessage());
  622. LOG.error(sw.toString());
  623. }
  624.  
  625. LOG.info("Envio do pedido numero:" + order.getCode() + " Finalizado" );
  626.  
  627. return true;
  628.  
  629. }
  630.  
  631. /**
  632. * @param order
  633. * @param consignment
  634. * @param cancelFulfilment
  635. */
  636. private void populateCancelFulfilment(OrderModel order,
  637. ConsignmentModel consignment, CancelFulfillment cancelFulfilment) {
  638. Items items = new Items();
  639. List<Item> itemList = new ArrayList<Item>();
  640. cancelFulfilment.setClientId(Config.getParameter("hering.omni.oms.clientid"));
  641. cancelFulfilment.setChannelId(order.getStore().getOmsChannel().getCode());
  642. cancelFulfilment.setCancelationReason("OTHER");
  643. cancelFulfilment.setFulfillmentId(consignment.getOmsFulfillmentId());
  644. cancelFulfilment.setOrderId(consignment.getOrder().getCode());
  645. cancelFulfilment.setExceptionId(consignment.getOrder().getCode());
  646.  
  647. for (ConsignmentEntryModel entry : consignment.getConsignmentEntries())
  648. {
  649. Item item = new Item();
  650. item.setSku(entry.getOrderEntry().getProduct().getCode());
  651. item.setQuantity(entry.getQuantity().toString());
  652. item.setStockType("PHYSICAL");
  653. itemList.add(item);
  654. }
  655.  
  656. cancelFulfilment.setItems(items);
  657.  
  658. cancelFulfilment.getItems().getItem().addAll(itemList);
  659.  
  660. if (consignment.getOrderFromCancellation() != null)
  661. {
  662. final DadosPedido omsDadosPedido = new DadosPedido();
  663.  
  664. OrderModel orderModel = (OrderModel) consignment.getOrderFromCancellation();
  665.  
  666. cancelFulfilment.setPlacedAt(convertDate(orderModel.getDate()));
  667.  
  668. boolean success = this.populateDadosPedido(orderModel, omsDadosPedido);
  669.  
  670. final ImportarPedidoRequest request = new ImportarPedidoRequest();
  671. request.setDadosPedido(omsDadosPedido);
  672. br.hering.fulfilmentprocess.message.order.oms.Order newOrder = new br.hering.fulfilmentprocess.message.order.oms.Order();
  673. newOrder.setImportarPedidoRequest(request);
  674. cancelFulfilment.setOrder(newOrder);
  675.  
  676. } else if (consignment.getRefund() != null) {
  677.  
  678. Refund refund = new Refund();
  679. refund.setRefundValue(String.valueOf(consignment.getRefund().getValue()));
  680. refund.setRefundType(consignment.getRefund().getType().getCode());
  681. RefundAttributes atts = new RefundAttributes();
  682.  
  683. cancelFulfilment.setPlacedAt(convertDate(consignment.getRefund().getCreationtime()));
  684.  
  685. if (consignment.getRefund().getType().equals(OMSRefundType.OFFLINE_REFUND))
  686. {
  687. if (consignment.getRefund().getBankAccountType().equals(BankAccountType.CHECKING_ACCOUNT)) {
  688.  
  689. atts.setBankAccountType("conta-corrente");
  690.  
  691. } else {
  692.  
  693. atts.setBankAccountType("conta-poupança");
  694.  
  695. }
  696.  
  697. atts.setBankCode(consignment.getRefund().getBankCode());
  698. atts.setBankBranch(consignment.getRefund().getBankAgency());
  699.  
  700. if (StringUtils.isNotEmpty(consignment.getRefund().getBankAgencyDigit())) {
  701.  
  702. atts.setBankBranchCheckDigit(consignment.getRefund().getBankAgencyDigit());
  703. }
  704.  
  705. atts.setBankAccount(consignment.getRefund().getBankAccount());
  706.  
  707. if (StringUtils.isNotEmpty(consignment.getRefund().getBankAccountDigit())) {
  708.  
  709. atts.setBankAccountCheckDigit(consignment.getRefund().getBankAccountDigit());
  710.  
  711. }
  712.  
  713. atts.setCustomerName(consignment.getRefund().getName());
  714.  
  715. atts.setCustomerDocumentNumber(consignment.getRefund().getDocumentNumber());
  716. }
  717.  
  718. refund.setRefundAttributes(atts);
  719. cancelFulfilment.setRefund(refund);
  720. }
  721. }
  722.  
  723. protected String exportToString(final ImportarPedidoRequest integrationDTO) throws JAXBException
  724. {
  725. final JAXBContext jaxbContext = JAXBContext.newInstance(ImportarPedidoRequest.class);
  726. final Marshaller marshaller = jaxbContext.createMarshaller();
  727. marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
  728. marshaller.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.TRUE);
  729.  
  730. final StringWriter stringWriter = new StringWriter();
  731.  
  732. marshaller.marshal(integrationDTO, stringWriter);
  733.  
  734. LOG.info("XML Generated: " + stringWriter.toString());
  735.  
  736. return stringWriter.toString();
  737. }
  738.  
  739. protected String exportToString(final CancelFulfillment integrationDTO) throws JAXBException
  740. {
  741. final JAXBContext jaxbContext = JAXBContext.newInstance(CancelFulfillment.class);
  742. final Marshaller marshaller = jaxbContext.createMarshaller();
  743. marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
  744. marshaller.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.TRUE);
  745.  
  746. final StringWriter stringWriter = new StringWriter();
  747.  
  748. marshaller.marshal(integrationDTO, stringWriter);
  749.  
  750. LOG.info("XML Generated: " + stringWriter.toString());
  751.  
  752. return stringWriter.toString();
  753. }
  754.  
  755. protected String exportToString(final ReturnFulfillment integrationDTO) throws JAXBException
  756. {
  757. final JAXBContext jaxbContext = JAXBContext.newInstance(ReturnFulfillment.class);
  758. final Marshaller marshaller = jaxbContext.createMarshaller();
  759. marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
  760. marshaller.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.TRUE);
  761.  
  762. final StringWriter stringWriter = new StringWriter();
  763.  
  764. marshaller.marshal(integrationDTO, stringWriter);
  765.  
  766. LOG.info("XML Generated: " + stringWriter.toString());
  767.  
  768. return stringWriter.toString();
  769. }
  770.  
  771. private boolean populateDadosPedido(final OrderModel order, final DadosPedido dadosPedido)
  772. {
  773. final String siteId = getSiteId(order.getSite().getUid());
  774.  
  775. boolean success = buildCustomerData(order, dadosPedido, siteId);
  776.  
  777. success &= buildOrderData(order, dadosPedido, siteId);
  778.  
  779. buildCarrierData(order, dadosPedido);
  780.  
  781. success &= buildPaymentData(order, dadosPedido, siteId);
  782.  
  783. buildOrderEntriesData(order, dadosPedido, siteId);
  784.  
  785. buildPaymentVoucher(order, dadosPedido, siteId);
  786.  
  787. success &= validateDadosPedido(dadosPedido);
  788.  
  789. //buildPaymentExchangeAndReturn(order, dadosPedido, siteId);
  790.  
  791. buildFulfillments(order, dadosPedido, siteId);
  792.  
  793. buildVendedor(order, dadosPedido, siteId);
  794.  
  795. adjustPaymentsNumber(dadosPedido);
  796.  
  797. if(isDevolutionOrder(order))
  798. {
  799. dadosPedido.setResultado(setUpResultado(order, dadosPedido.getPedido(), siteId));
  800. }
  801. return success;
  802. }
  803.  
  804.  
  805. private void buildVendedor(OrderModel order, DadosPedido dadosPedido, String siteId) {
  806.  
  807. Vendedor vendedor = new Vendedor();
  808.  
  809. vendedor.setCodigoVendedor("NET");
  810. vendedor.setIdVendedor("1");
  811. vendedor.setTipoVendedor("1");
  812.  
  813. dadosPedido.setVendedor(vendedor);
  814. }
  815.  
  816. private boolean isDevolutionOrder(final OrderModel orderModel)
  817. {
  818. try
  819. {
  820. Collection<String> vouchersApplied = voucherService
  821. .getAppliedVoucherCodes(orderModel);
  822.  
  823. if(CollectionUtils.isNotEmpty(vouchersApplied))
  824. {
  825. String voucherCode =vouchersApplied.iterator().next();
  826.  
  827. if(voucherCode.contains(VOUCHER_DEVOLUTION.toUpperCase())
  828. && orderModel.getExchangeAndReturnProcess() != null
  829. && orderModel.getExchangeAndReturnProcess().getBankInformation() != null)
  830. {
  831. return true;
  832. }
  833. }
  834.  
  835. return false;
  836. }
  837.  
  838. catch(Exception e)
  839. {
  840. LOG.error("Fail on get exchange and return "
  841. + "type order number:" + orderModel.getCode());
  842. }
  843.  
  844. return false;
  845. }
  846.  
  847. private boolean validateDadosPedido(final DadosPedido dadosPedido)
  848. {
  849. return !dadosPedido.getPagamento().isEmpty();
  850. }
  851.  
  852. private String getSiteId(String site)
  853. {
  854. if (STORE_CODE_MAPPING.containsKey(site))
  855. {
  856. return STORE_CODE_MAPPING.get(site);
  857. }
  858. return "";
  859. }
  860.  
  861. private String convertDate(Date date) {
  862.  
  863. SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
  864.  
  865. return dateFormat.format(date);
  866. }
  867.  
  868. private String convertDateInUSFormat(String dateInString) {
  869.  
  870. String formattedDate = null;
  871.  
  872. SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
  873.  
  874. try {
  875.  
  876. Date date = formatter.parse(dateInString);
  877.  
  878. formattedDate = convertDate(date);
  879.  
  880. } catch (ParseException e) {
  881. //e.printStackTrace();
  882. }
  883.  
  884. return formattedDate;
  885. }
  886.  
  887. /**
  888. * @param order
  889. * @param dadosPedido
  890. */
  891. private boolean buildCustomerData(
  892. final OrderModel order,
  893. final DadosPedido dadosPedido,
  894. final String siteId)
  895. {
  896. boolean success = true;
  897. try
  898. {
  899. final CustomerModel customer = (CustomerModel) order.getUser();
  900. final Cliente cliente = new Cliente();
  901. cliente.setCodigoSite(siteId);
  902. cliente.setCodigoCliente(customer.getPk().toString());
  903.  
  904. if (customer.getType() != null && customer.getType().equals(CustomerType.GUEST))
  905. {
  906. String name = "";
  907. if (order.getDeliveryAddress() != null && order.getDeliveryAddress().getOriginal() != null)
  908. {
  909. name += StringUtils.isBlank(order.getDeliveryAddress().getOriginal().getFirstname()) ? "" : order
  910. .getDeliveryAddress().getOriginal().getFirstname();
  911. name += " "
  912. + (StringUtils.isBlank(order.getDeliveryAddress().getOriginal().getLastname()) ? "" : order
  913. .getDeliveryAddress().getOriginal().getLastname());
  914. }
  915. cliente.setNome(name.trim());
  916. }
  917. else
  918. {
  919. cliente.setNome(customer.getName());
  920. }
  921.  
  922. cliente.setPfPj(customer.getCpfcnpj().length() == 11 ? true : false);
  923. cliente.setRgIe(customer.getRgIe());
  924. cliente.setCpfCgc(customer.getCpfcnpj());
  925.  
  926. if (customer.getBirthday() != null)
  927. {
  928. cliente.setAniversario(convertDate(customer.getBirthday()));
  929. }
  930.  
  931. cliente.setDataCadastramento(convertDate(customer.getCreationtime()));
  932.  
  933. if (customer.getGender() != null)
  934. {
  935. cliente.setSexo(customer.getGender().getCode().charAt(0) + "");
  936. }
  937. else
  938. {
  939. cliente.setSexo(Gender.UNDEFINED.getCode().charAt(0) + "");
  940. }
  941.  
  942. if (customer.getDefaultShipmentAddress() != null)
  943. {
  944. if (customer.getDefaultShipmentAddress().getDddPhone() != null)
  945. {
  946. cliente.setDdd(customer.getDefaultShipmentAddress().getDddPhone());
  947. }
  948. if (customer.getDefaultShipmentAddress().getPhone1() != null)
  949. {
  950. cliente.setTelefone(customer.getDefaultShipmentAddress().getPhone1());
  951. }
  952. }
  953.  
  954. cliente.setEmail(customer.getUid().replaceAll("[a-z0-9\\-]*\\|", ""));
  955.  
  956. try
  957. {
  958. final NewsletterSubscriberData newsLetter = newsletterSubscriptionFacade.findByEmail(customer.getUid().replaceAll(
  959. "[a-z0-9\\-]*\\|", ""));
  960. cliente.setNewsletter(newsLetter != null && Boolean.TRUE.equals(newsLetter.getReceive()));
  961. }
  962. catch (final Exception e)
  963. {
  964. LOG.error("Not FATAL error", e);
  965. }
  966.  
  967. dadosPedido.setCliente(cliente);
  968.  
  969. success = buildCustomerAddressData(dadosPedido, customer, order);
  970.  
  971. }
  972. catch (final Exception e)
  973. {
  974. success = false;
  975. LOG.info("Error creating customerData for Order: " + order.getCode() + "; Exception: " + e);
  976. }
  977. return success;
  978. }
  979.  
  980. /**
  981. * @param dadosPedido
  982. * @param customer
  983. */
  984. private boolean buildCustomerAddressData(final DadosPedido dadosPedido,
  985. final CustomerModel customer, final OrderModel order) {
  986.  
  987. boolean success = true;
  988.  
  989. if (!isPickup(order)) {
  990.  
  991. final Endereco deliveryAddress =
  992. buildAddress(order.getDeliveryAddress(), customer.getPk().toString());
  993.  
  994. if(deliveryAddress == null)
  995. {
  996. success = false;
  997. LOG.info("Error creating deliveryAddress for order: " + order.getCode());
  998. }
  999. else if(!dadosPedido.getEndereco().contains(deliveryAddress))
  1000. {
  1001. dadosPedido.getEndereco().add(deliveryAddress);
  1002. }
  1003.  
  1004. }
  1005.  
  1006. Endereco billingAddress = null;
  1007.  
  1008. if (!isReserve(order)) {
  1009. billingAddress =
  1010. buildAddress(order.getPaymentInfo().getBillingAddress(), customer.getPk().toString());
  1011.  
  1012. billingAddress.setEnderecoCobranca(true);
  1013. }
  1014.  
  1015. if(billingAddress == null) {
  1016.  
  1017. if (isReserve(order)) {
  1018.  
  1019. // mesmo quando é reserva, o erp precisa de um endereço de cobrança
  1020. // tentamos de todas sa formas setar esse endereço
  1021.  
  1022. AddressModel userAddress = null;
  1023.  
  1024. if (customer.getDefaultPaymentAddress() != null) {
  1025.  
  1026. userAddress = customer.getDefaultPaymentAddress();
  1027.  
  1028. } else if (customer.getDefaultShipmentAddress() != null){
  1029.  
  1030. userAddress = customer.getDefaultPaymentAddress();
  1031.  
  1032. } else if (customer.getAddresses() != null && customer.getAddresses().size() > 0){
  1033.  
  1034. userAddress = customer.getAddresses().iterator().next();
  1035. }
  1036.  
  1037. if (userAddress == null) {
  1038.  
  1039. success = false;
  1040. LOG.info("Error creating billingAddress for order: " + order.getCode());
  1041.  
  1042. } else {
  1043.  
  1044. billingAddress =
  1045. buildAddress(userAddress, customer.getPk().toString());
  1046.  
  1047. billingAddress.setEnderecoCobranca(true);
  1048.  
  1049. if (!dadosPedido.getEndereco().contains(billingAddress)) {
  1050.  
  1051. dadosPedido.getEndereco().add(billingAddress);
  1052.  
  1053. } else {
  1054.  
  1055. dadosPedido.getEndereco().get(0).setEnderecoCobranca(true);
  1056.  
  1057. }
  1058.  
  1059. }
  1060. }
  1061.  
  1062. } else {
  1063.  
  1064. int indexOf = dadosPedido.getEndereco().indexOf(billingAddress);
  1065.  
  1066. if (indexOf < 0) {
  1067.  
  1068. dadosPedido.getEndereco().add(billingAddress);
  1069.  
  1070. } else {
  1071.  
  1072. dadosPedido.getEndereco().get(indexOf).setEnderecoCobranca(true);
  1073.  
  1074. }
  1075.  
  1076. }
  1077.  
  1078. return success;
  1079. }
  1080.  
  1081. private Endereco buildAddress(final AddressModel add, String codigoCliente)
  1082. {
  1083. try
  1084. {
  1085. final Endereco endereco = new Endereco();
  1086.  
  1087. if(add.getOriginal() != null)
  1088. {
  1089. endereco.setCodigoEndereco(add.getOriginal().getPk().getLongValueAsString());
  1090. }
  1091. else
  1092. {
  1093. endereco.setCodigoEndereco(add.getPk().getLongValueAsString());
  1094. }
  1095.  
  1096. endereco.setDescricaoEndereco(add.getFirstname() + " " + add.getLastname());
  1097. endereco.setPais(add.getCountry().getIsocode());
  1098. endereco.setCep(add.getPostalcode());
  1099. endereco.setBairro(add.getDistrict());
  1100. endereco.setCidade(add.getTown());
  1101. endereco.setComplemento(add.getComplemento());
  1102. endereco.setNumero(add.getStreetnumber());
  1103. endereco.setLogradouro(add.getStreetname());
  1104. endereco.setUf(add.getRegion().getIsocode().substring(3));
  1105. endereco.setEnderecoPrincipal(true);
  1106. endereco.setTipoEndereco(getAddressType(add));
  1107. endereco.setDdd(add.getDddPhone());
  1108. endereco.setTelefone(add.getPhone1());
  1109. endereco.setDddCelular(StringUtils.isEmpty(add.getDddCellPhone()) ? add.getDddPhone() : add.getDddCellPhone());
  1110. endereco.setCelular(StringUtils.isEmpty(add.getCellphone()) ? add.getPhone1() : add.getCellphone());
  1111. endereco.setCodigoCliente(codigoCliente);
  1112. endereco.setEnderecoCobranca(add.getBillingAddress());
  1113. endereco.setEnderecoEntrega(add.getShippingAddress());
  1114. endereco.setCodigoMunicipioIBGE("9999999");
  1115.  
  1116. return endereco;
  1117. }
  1118. catch (Exception e)
  1119. {
  1120. LOG.info("Error creating Address for order export. Customer: "
  1121. + codigoCliente + "; address: " + add.getPk().toString() + "; Exception: " + e);
  1122. }
  1123. return null;
  1124. }
  1125.  
  1126. /**
  1127. * @param order
  1128. * @param DATE_FORMAT
  1129. * @param dadosPedido
  1130. */
  1131. private boolean buildOrderData(final OrderModel order,
  1132. final DadosPedido dadosPedido, String siteId)
  1133. {
  1134. boolean success = true;
  1135.  
  1136. try
  1137. {
  1138. final Pedido pedido = new Pedido();
  1139.  
  1140. pedido.setCodigoSite(siteId);
  1141. // TODO:
  1142. pedido.setClienteId(Config.getParameter("hering.omni.oms.clientid"));
  1143. pedido.setCanalId(order.getStore().getOmsChannel().getCode());
  1144.  
  1145. pedido.setStatus(getOrderStatus(order));
  1146.  
  1147. /*
  1148. *
  1149. * 1: PEDIDO NORMAL
  1150. * 2: PEDIRO RESERVA
  1151. * 3: CARTAO PRESENTE
  1152. * 4: PEDIDO DE TROCA
  1153. * 5: EMBRULHAR PRE PRESENTE
  1154. * */
  1155. if(order.isExchangeOrReturnOrder())
  1156. {
  1157. DiscountModel voucher = voucherService.getAppliedVouchers(order).iterator().next();
  1158. //order.setTotalPrice(voucher.getValue());
  1159.  
  1160. if(voucher.getCode().toLowerCase().contains(VOUCHER_DEVOLUTION) || voucher.getCode().toLowerCase().contains(VOUCHER_OLD_EXCHAGE))
  1161. {
  1162. order.setCode("DV01_"+order.getCode());
  1163. if(order != null && order.getExchangeAndReturnProcess() != null
  1164. && order.getExchangeAndReturnProcess().getDescription() != null){
  1165. pedido.setMensagemCartao(order.getExchangeAndReturnProcess().getDescription());
  1166. }
  1167. pedido.setTipo("4");
  1168. }
  1169. else
  1170. {
  1171. pedido.setTipo("1");
  1172. }
  1173. }
  1174. else if(order != null && order.getEntries() != null && !order.getEntries().isEmpty()
  1175. && order.getEntries().get(0).getProduct().getCode().startsWith("GIF")){
  1176. pedido.setTipo("3");
  1177. }
  1178. else if(order.isPackageProduct()){
  1179. pedido.setTipo("5");
  1180. }
  1181. else{
  1182. pedido.setTipo("1");
  1183. }
  1184.  
  1185. // vazio por enquanto para não dar problema no OMS
  1186. if (pedido.getMensagemCartao() == null) {
  1187.  
  1188. pedido.setMensagemCartao(" ");
  1189.  
  1190. }
  1191.  
  1192. pedido.setCodigoPedido(order.getCode());
  1193. pedido.setData(convertDate(order.getCreationtime()));
  1194. pedido.setDataHoraFinalizacaoPedido(convertDate(order.getDate()));
  1195.  
  1196. pedido.setValorTotal(BigDecimal.valueOf(order.getTotalPrice()
  1197. .doubleValue()).add(BigDecimal.valueOf(order.getTotalDiscounts())));
  1198. /*
  1199. * Quando ha um voucher de vale cr�dito o valor do desconto � zerado
  1200. * e recalculado o valor total
  1201. */
  1202. pedido.setDesconto(BigDecimal.valueOf(order.getTotalDiscounts()));
  1203.  
  1204. if(order.isExchangeOrReturnOrder())
  1205. {
  1206. DiscountModel voucher = voucherService.getAppliedVouchers(order).iterator().next();
  1207. //O valor tem que ser o da ordem que já foi ajustado
  1208. //order.setTotalPrice(voucher.getValue());
  1209.  
  1210. if(voucher.getCode().contains("RETURN_") || voucher.getCode().contains("OLD_EXCHANGE_"))
  1211. {
  1212. pedido.setCodigoDesconto(order.getCodPostagem());
  1213. }
  1214. }
  1215. else if (CollectionUtils.isNotEmpty(order.getDiscounts())) {
  1216. for(String voucherCode: voucherService.getAppliedVoucherCodes(order)){
  1217. if(StringUtils.isNotBlank(voucherCode) && !voucherCode.startsWith(VOUCHER_VALIDATE) && !voucherCode.startsWith(VALE_PRESENTE) ){
  1218. pedido.setCodigoDesconto(voucherCode);
  1219. break;
  1220. }
  1221. }
  1222. }
  1223.  
  1224. if (pedido.getCodigoDesconto() == null) {
  1225.  
  1226. pedido.setCodigoDesconto(" ");
  1227.  
  1228. }
  1229.  
  1230. pedido.setCodigoCliente(order.getUser().getPk().toString());
  1231.  
  1232. //setting deliveryAddress
  1233. AddressModel deliveryAddress = order.getDeliveryAddress();
  1234.  
  1235. if (order.getDeliveryAddress() == null){
  1236. success = false;
  1237. throw new AddressMethodException("Delivery Address does not exist for order: " + order.getCode());
  1238. }
  1239.  
  1240. if(deliveryAddress.getOriginal() != null){
  1241. deliveryAddress = deliveryAddress.getOriginal();
  1242. }
  1243. Endereco aux = new Endereco();
  1244. aux.setCodigoEndereco(deliveryAddress.getPk().getLongValueAsString());
  1245. if(!dadosPedido.getEndereco().contains(aux)){
  1246. success = false;
  1247. LOG.info("FATAL ERROR. Building OrderData for Order: " + order.getCode()
  1248. + " failed. Customer does not contain the DeliveryAddress assingned for this order. "
  1249. + "The order will be sent to PI, but it will fail to integrate to Linx due to this mismatch");
  1250. }
  1251. pedido.setCodigoEnderecoEntrega(aux.getCodigoEndereco());
  1252. pedido.setCodigoEnderecoCobranca(aux.getCodigoEndereco());
  1253.  
  1254. // vazio por enquanto
  1255. pedido.setIdCampanha(" ");
  1256.  
  1257. dadosPedido.setPedido(pedido);
  1258. } catch (Exception e){
  1259. success = false;
  1260. LOG.error("Error building OrderData for order: " + order.getCode(), e);
  1261. }
  1262. return success;
  1263. }
  1264.  
  1265. //Calcula o valor de desconto quando o valor do frete em porcentagem
  1266. private BigDecimal calculateVoucherAbsoluteValue(final BigDecimal desconto, final BigDecimal total){
  1267.  
  1268. if(desconto != BigDecimal.ZERO){
  1269. final BigDecimal percent = desconto.divide(BigDecimal.valueOf(100));
  1270. final BigDecimal absoluteValue = percent.multiply(total);
  1271. return BigDecimal.valueOf(absoluteValue.floatValue()).setScale(2, BigDecimal.ROUND_HALF_UP);
  1272. }
  1273. return BigDecimal.ZERO;
  1274. }
  1275.  
  1276. /**
  1277. * @param order
  1278. * @param dadosPedido
  1279. * @param pedido
  1280. */
  1281. private void buildOrderEntriesData(final OrderModel order,
  1282. final DadosPedido dadosPedido, String siteId) {
  1283. int count = 0;
  1284. int idx = 1;
  1285.  
  1286. for (final AbstractOrderEntryModel entry : order.getEntries()) {
  1287. count = count + entry.getQuantity().intValue();
  1288.  
  1289. HeringSizeVariantProductModel heringProduto = (HeringSizeVariantProductModel) entry.getProduct();
  1290.  
  1291. final Itens item = new Itens();
  1292. item.setCodigoSite(siteId);
  1293. item.setCodigoPedido(order.getCode());
  1294. item.setCodigoProduto(heringProduto.getBaseProduct().getCode()
  1295. .split("_")[0]);
  1296. item.setCorProduto(heringProduto.getBaseProduct().getCode()
  1297. .split("_")[1]);
  1298. item.setTextoPersonalizado(entry.getCustomText());
  1299. item.setNome(heringProduto.getBaseProduct().getName());
  1300. item.setItem(String.valueOf(idx));
  1301. item.setSku(entry.getProduct().getCode());
  1302. item.setQuantidade(entry.getQuantity().intValue());
  1303. item.setPrecoLiquido(BigDecimal.valueOf(entry.getBasePrice() - calculateDiscount(entry.getDiscountValues()).doubleValue() ));
  1304.  
  1305. item.setDesconto(this.calculateDiscount(entry.getDiscountValues()));
  1306. item.setIndicaBrinde(entry.getGiveAway() ? "1" : "0");
  1307.  
  1308. Double weight = heringProduto.getWeight() * 1000;
  1309. item.setPeso(String.valueOf(weight.intValue()));
  1310.  
  1311. final Collection<CategoryModel> categories = commerceProductService.getSuperCategoriesExceptClassificationClassesForProduct(heringProduto);
  1312.  
  1313. if (!categories.isEmpty()) {
  1314.  
  1315. Categorias categorias = new Categorias();
  1316.  
  1317. List<String> strCategories = new ArrayList<String>();
  1318.  
  1319. for (CategoryModel category : categories) {
  1320.  
  1321. if (category.getName() != null) {
  1322.  
  1323. strCategories.add(category.getName());
  1324.  
  1325. }
  1326.  
  1327. }
  1328.  
  1329. if (!strCategories.isEmpty()) {
  1330.  
  1331. categorias.getCategoria().addAll(strCategories);
  1332.  
  1333. item.setCategorias(categorias);
  1334.  
  1335. }
  1336. }
  1337.  
  1338. // marca, talvez tenha um atributo
  1339.  
  1340. String site = order.getSite().getUid();
  1341.  
  1342. String productUrl = Config.getParameter("website." + site + ".https") + productModelUrlResolver.resolve(heringProduto);
  1343.  
  1344. item.setUrl(productUrl);
  1345.  
  1346. item.setTamanho(heringProduto.getSize());
  1347. item.setCodigoDeBarras(heringProduto.getEan());
  1348.  
  1349. if (heringProduto.getBaseProduct().getPicture() != null) {
  1350.  
  1351. String productImageUrl = heringProduto.getBaseProduct().getPicture().getURL();
  1352.  
  1353. if (StringUtils.isNotEmpty(productImageUrl)) {
  1354.  
  1355. item.setImage(productImageUrl);
  1356.  
  1357. }
  1358. }
  1359.  
  1360. item.setCorDescricao(heringProduto.getColorFullDescription());
  1361.  
  1362. item.setMarca(site);
  1363.  
  1364. if (checkIfOrderExchange(order)) {
  1365.  
  1366. item.setReferenceSkuId(heringProduto.getCode());
  1367.  
  1368. item.setHybrisItemSequenceId(String.valueOf(entry.getEntryNumber()));
  1369.  
  1370. }
  1371.  
  1372. if(order.isExchangeOrReturnOrder())
  1373. {
  1374. Collection<DiscountModel> vouchers = voucherService.getAppliedVouchers(order);
  1375. if( CollectionUtils.isNotEmpty(vouchers) )
  1376. {
  1377. DiscountModel voucher = vouchers.iterator().next();
  1378. if(order.isExchangeOrReturnOrder())
  1379. {
  1380. if(voucher.getCode().startsWith("CODE_EXCHANGE"))
  1381. {
  1382. item.setStatus(0);
  1383. }
  1384. else
  1385. {
  1386. item.setStatus(getProductReasonCode(order, heringProduto.getCode()));
  1387. }
  1388. }
  1389. }
  1390. }
  1391. else
  1392. {
  1393. item.setStatus(0);
  1394. }
  1395.  
  1396. dadosPedido.getItens().add(item);
  1397. idx += 1;
  1398. }
  1399.  
  1400. dadosPedido.getPedido().setQuantidadeTotal(count);
  1401. }
  1402.  
  1403.  
  1404. private int getProductReasonCode(final OrderModel orderModel, final String productCode)
  1405. {
  1406. Collection<ExchangeAndReturnProductsModel> exchangeProducts = checkChangedProductListExchange(orderModel);
  1407.  
  1408. if(CollectionUtils.isNotEmpty(exchangeProducts)){
  1409. for(ExchangeAndReturnProductsModel product:exchangeProducts){
  1410. if(product.getOriginalProduct().getCode().equals(productCode)){
  1411. return product.getReason();
  1412. }
  1413. }
  1414. }
  1415.  
  1416. Collection<ExchangeAndReturnProductsModel> returnProducts = checkExchangeProductList(orderModel);
  1417.  
  1418. if(CollectionUtils.isNotEmpty(returnProducts)){
  1419. for(ExchangeAndReturnProductsModel product:returnProducts){
  1420. if(product.getOriginalProduct().getCode().equals(productCode)){
  1421. return product.getReason();
  1422. }
  1423. }
  1424. }
  1425.  
  1426. LOG.warn("Product " + productCode + " without exchange and return reason.");
  1427. return -1;
  1428. }
  1429.  
  1430. /**
  1431. * @param orderModel
  1432. * @return
  1433. */
  1434. private Collection<ExchangeAndReturnProductsModel> checkExchangeProductList(OrderModel orderModel){
  1435. if(orderModel != null && orderModel.getExchangeAndReturnProcess() != null
  1436. && orderModel.getExchangeAndReturnProcess().getReturnProducts() != null){
  1437. return orderModel.getExchangeAndReturnProcess().getReturnProducts();
  1438. }else{
  1439. return null;
  1440. }
  1441.  
  1442. }
  1443.  
  1444. private Collection<ExchangeAndReturnProductsModel> checkChangedProductListExchange(OrderModel orderModel){
  1445. if(orderModel != null && orderModel.getExchangeAndReturnProcess() != null
  1446. && orderModel.getExchangeAndReturnProcess().getChangedProducts() != null){
  1447. return orderModel.getExchangeAndReturnProcess().getChangedProducts();
  1448. }else{
  1449. return null;
  1450. }
  1451. }
  1452.  
  1453. /**
  1454. * @param order
  1455. * @param pedido
  1456. * @throws DeliveryModeException
  1457. */
  1458. private void buildCarrierData(final OrderModel order,
  1459. final DadosPedido dadosPedido) {
  1460. Pedido pedido = dadosPedido.getPedido();
  1461.  
  1462. try{
  1463.  
  1464. pedido.setPeso(BigDecimal.valueOf(deliveryService.calculateTotalWeight(order)));
  1465. pedido.setValorFrete(BigDecimal.valueOf(order.getDeliveryCost().doubleValue()));
  1466. pedido.setPrazoMaximoEntrega(order.getEstimatedDeliveryDays());
  1467.  
  1468. }catch (Exception e) {
  1469. LOG.error("Error building buildCarrierData for order: " + order.getCode(), e);
  1470. }
  1471. }
  1472.  
  1473. private boolean isPickup(final OrderModel order) {
  1474.  
  1475. for (ConsignmentModel consignment : order.getConsignments())
  1476. {
  1477. if (consignment.getOmsFulfillmentType().equals("SHIPMENT")) {
  1478. return false;
  1479. }
  1480. }
  1481.  
  1482. return true;
  1483. }
  1484.  
  1485. private boolean isReserve(final OrderModel order) {
  1486.  
  1487. if (order.getPaymentInfo() instanceof MultiplePaymentInfoModel) {
  1488.  
  1489. final List<AbstractPaymentInfoModel> paymentInfoList =
  1490. ((MultiplePaymentInfoModel) order.getPaymentInfo()).getPaymentInfoList();
  1491.  
  1492. for (int i = 0; i < paymentInfoList.size(); i++)
  1493. {
  1494. final AbstractPaymentInfoModel paymentInfo = paymentInfoList.get(i);
  1495.  
  1496. if(paymentInfo instanceof ReservePaymentInfoModel){
  1497. return true;
  1498. }
  1499. }
  1500.  
  1501. } else if (order.getPaymentInfo() instanceof ReservePaymentInfoModel) {
  1502.  
  1503. return true;
  1504.  
  1505. }
  1506.  
  1507. return false;
  1508. }
  1509.  
  1510. /**
  1511. * @param order
  1512. * @param dadosPedido
  1513. * @param siteId
  1514. * @param success
  1515. */
  1516. private boolean buildPaymentData(
  1517. final OrderModel order,
  1518. final DadosPedido dadosPedido,
  1519. final String siteId)
  1520. {
  1521. if( order.isExchangeOrReturnOrder() )
  1522. {
  1523. return true;
  1524. }
  1525.  
  1526. boolean success = true;
  1527.  
  1528. final List<Pagamento> pagamentoList = new ArrayList<Pagamento>();
  1529.  
  1530. if(!(order.getPaymentInfo() instanceof MultiplePaymentInfoModel))
  1531. {
  1532. buildLegacyPaymentData(order, dadosPedido, siteId);
  1533. return true;
  1534. }
  1535. /**One order can be payed by several methods. The */
  1536. final List<AbstractPaymentInfoModel> paymentInfoList =
  1537. ((MultiplePaymentInfoModel) order.getPaymentInfo()).getPaymentInfoList();
  1538.  
  1539. for ( int i = 0; i < paymentInfoList.size(); i++)
  1540. {
  1541. try
  1542. {
  1543. final AbstractPaymentInfoModel paymentInfo = paymentInfoList.get(i);
  1544.  
  1545. if(paymentInfo instanceof ReservePaymentInfoModel){
  1546. return true;
  1547. }
  1548.  
  1549. final Pagamento pagamento = new Pagamento();
  1550. pagamento.setParcela(i+1);
  1551. pagamento.setCodigoSite(siteId);
  1552. pagamento.setCodigoPedido(order.getCode());
  1553. pagamento.setMoeda(order.getCurrency().getIsocode());
  1554. pagamento.setCapturado(APROVADO_CLEARSALE);
  1555. pagamento.setCodigoAntifraude("APPROVED");
  1556. pagamento.setCotacao(BigDecimal.valueOf(1));
  1557. pagamento.setStatusVerificacaoFraude("APPROVED");
  1558.  
  1559. /**todo o processo de voucher foi unificado no metodo buildVoucherPayment
  1560. * porque o novissimo tipo VoucherPaymentInfo nao tem todas as informacoes necessarias
  1561. * */
  1562.  
  1563. if (paymentInfo instanceof VoucherPaymentInfoModel)
  1564. {
  1565. LOG.info(
  1566. String.format(
  1567. "Found paymentInfo:{code:%s} for order:{code:%s}. This will be handled by the buildPaymentVoucher.",
  1568. paymentInfo.getCode(),
  1569. order.getCode()));
  1570. continue;
  1571. }
  1572. else if (paymentInfo instanceof AdyenDebitPaymentInfoModel )
  1573. {
  1574. final PaymentTransactionEntryModel authorization =
  1575. paymentTransactionEntryService.getForPaymentInfoAndType(
  1576. paymentInfo,
  1577. PaymentTransactionType.AUTHORIZATION3D);
  1578.  
  1579. success &=
  1580. checkIfTransactionIsNull(
  1581. order, paymentInfo, authorization);
  1582.  
  1583. final AdyenDebitPaymentInfoModel debitInfo =
  1584. (AdyenDebitPaymentInfoModel) paymentInfo;
  1585.  
  1586. pagamento.setTipoPagamento(TipoDePagamento.CARTAO_DE_DEBITO.getCode());
  1587. pagamento.setNumeroTitulo(debitInfo.getNumber());
  1588. pagamento.setParcelasCartao(1);
  1589.  
  1590. pagamento.setCodigoAdministradora(
  1591. getCodigoAdminstradoraCartao(
  1592. debitInfo.getSelectedBrand()));
  1593.  
  1594. pagamento.setVencimento(convertDate(order.getDate()));
  1595.  
  1596. // Numero de referencia do adyen
  1597. pagamento.setNumeroAprovacaoCartao(
  1598. authorization.getAdyenAuthorizationCode());
  1599.  
  1600. pagamento.setValor(BigDecimal.valueOf(debitInfo.getValuePaid().doubleValue()));
  1601. pagamento.setValorMoeda(BigDecimal.valueOf(debitInfo.getValuePaid().doubleValue()));
  1602. pagamento.setMetodo(CIELO);
  1603. }
  1604. else
  1605. {
  1606. final PaymentTransactionEntryModel authorization =
  1607. paymentTransactionEntryService.getForPaymentInfoAndType(
  1608. paymentInfo,
  1609. PaymentTransactionType.AUTHORIZATION);
  1610.  
  1611. if (paymentInfo instanceof AdyenCreditCardPaymentInfoModel )
  1612. {
  1613. success &=
  1614. checkIfTransactionIsNull(
  1615. order, paymentInfo, authorization);
  1616.  
  1617. final AdyenCreditCardPaymentInfoModel cc =
  1618. (AdyenCreditCardPaymentInfoModel) paymentInfo;
  1619.  
  1620. pagamento.setTipoPagamento(
  1621. TipoDePagamento.CARTAO_DE_CREDITO.getCode());
  1622.  
  1623. pagamento.setNumeroTitulo(cc.getNumber());
  1624. pagamento.setParcelasCartao((cc.getInstallment() != null
  1625. ? cc.getInstallment() : 0));
  1626.  
  1627. pagamento.setCodigoAdministradora(
  1628. cc.getType().getCode() != null
  1629. ? getCodigoAdminstradoraCartao(cc.getType().getCode())
  1630. : 0);
  1631.  
  1632. pagamento.setVencimento(
  1633. convertDate(order.getDate()));
  1634.  
  1635. if (authorization != null && authorization.getAdyenAuthorizationCode() != null) {
  1636. // Numero de referencia do adyen
  1637. pagamento.setNumeroAprovacaoCartao(authorization.getAdyenAuthorizationCode());
  1638. }
  1639.  
  1640. pagamento.setMetodo(CIELO);
  1641. // this is done in order to send only 2 decimal cases to linx oms
  1642. pagamento.setValor(BigDecimal.valueOf(cc.getValuePaid().doubleValue()));
  1643. pagamento.setValorMoeda(BigDecimal.valueOf(cc.getValuePaid().doubleValue()));
  1644. pagamento.setBandeira(cc.getType().getCode() != null ? cc.getType().getCode() : "");
  1645. }
  1646. else if (paymentInfo instanceof BoletoPaymentInfoModel)
  1647. {
  1648. success &=
  1649. checkIfTransactionIsNull(order, paymentInfo, authorization);
  1650.  
  1651. final BoletoPaymentInfoModel boleto =
  1652. (BoletoPaymentInfoModel) paymentInfo;
  1653.  
  1654. pagamento.setTipoPagamento(TipoDePagamento.BOLETO.getCode());
  1655.  
  1656. pagamento.setNumeroTitulo(
  1657. authorization.getAdyenBoletoNossoNumero());
  1658.  
  1659. pagamento.setParcelasCartao(1);
  1660. // Para boleto o codigo eh ZERO
  1661. pagamento.setCodigoAdministradora(0);
  1662.  
  1663. pagamento.setVencimento(
  1664. convertDateInUSFormat(authorization.getAdyenBoletoExpirationDate()));
  1665.  
  1666. // Campo obrigatorio, fixo numero unico do boleto
  1667. pagamento.setNumeroAprovacaoCartao(
  1668. authorization.getAdyenBoletoNossoNumero());
  1669.  
  1670. final BigDecimal totalPago = BigDecimal.valueOf(order.getTotalPrice());
  1671. pagamento.setValor(totalPago);
  1672. pagamento.setValorMoeda(totalPago);
  1673. //TODO
  1674. pagamento.setCodigoBanco(Config.getParameter("hering.boleto.bank.code"));
  1675. }
  1676. }
  1677. pagamentoList.add(pagamento);
  1678. }
  1679. catch (Exception e)
  1680. {
  1681. success = false;
  1682. LOG.error(
  1683. String.format("Unexpected error for order:{code:%s}",
  1684. order.getCode()), e);
  1685. }
  1686. }
  1687. dadosPedido.getPagamento().addAll(pagamentoList);
  1688. return success;
  1689. }
  1690.  
  1691. private void adjustPaymentsNumber(final DadosPedido pedido) {
  1692.  
  1693. for (int i = 0; i < pedido.getPagamento().size(); i++) {
  1694.  
  1695. Pagamento pagamento = pedido.getPagamento().get(i);
  1696.  
  1697. pagamento.setParcela(i+1);
  1698.  
  1699. }
  1700.  
  1701. }
  1702.  
  1703. private boolean checkIfTransactionIsNull(final OrderModel order,
  1704. final AbstractPaymentInfoModel paymentInfo,
  1705. final PaymentTransactionEntryModel authorization)
  1706. {
  1707. boolean success = true;
  1708. if (authorization == null)
  1709. {
  1710. LOG.error(
  1711. String.format(
  1712. "Authorization for order:{code:%s}; paymentInfo:{code:%s} does not exists",
  1713. order.getCode(), paymentInfo.getCode()));
  1714. success = false;
  1715. }
  1716. return success;
  1717. }
  1718.  
  1719. private String getOrderStatus(final OrderModel order) {
  1720.  
  1721. if (isReserve(order)) {
  1722.  
  1723. return "PROCESSING";
  1724.  
  1725. } else if (hasBoleto(order)) {
  1726.  
  1727. return "PENDING";
  1728.  
  1729. } else {
  1730.  
  1731. return "PROCESSING";
  1732.  
  1733. }
  1734.  
  1735. }
  1736.  
  1737. private String getConsignmentStatus(final OrderModel order) {
  1738.  
  1739. if (isReserve(order)) {
  1740.  
  1741. return "WAITING";
  1742.  
  1743. } else if (hasBoleto(order)) {
  1744.  
  1745. return "PENDING";
  1746.  
  1747. } else {
  1748.  
  1749. return "WAITING";
  1750.  
  1751. }
  1752.  
  1753. }
  1754.  
  1755. private boolean hasBoleto(final OrderModel order) {
  1756.  
  1757. if (order.getPaymentInfo() instanceof MultiplePaymentInfoModel) {
  1758.  
  1759. /**One order can be payed by several methods. The */
  1760. final List<AbstractPaymentInfoModel> paymentInfoList =
  1761. ((MultiplePaymentInfoModel) order.getPaymentInfo()).getPaymentInfoList();
  1762.  
  1763. for ( int i = 0; i < paymentInfoList.size(); i++)
  1764. {
  1765. try
  1766. {
  1767. final AbstractPaymentInfoModel paymentInfo = paymentInfoList.get(i);
  1768.  
  1769. if(paymentInfo instanceof BoletoPaymentInfoModel){
  1770. return true;
  1771. }
  1772.  
  1773. } catch (Exception e) {
  1774.  
  1775. // nothing
  1776.  
  1777. }
  1778. }
  1779.  
  1780. } else if (order.getPaymentInfo() instanceof BoletoPaymentInfoModel) {
  1781.  
  1782. return true;
  1783.  
  1784. }
  1785.  
  1786. return false;
  1787.  
  1788. }
  1789.  
  1790. private Object buildLegacyPaymentData(final OrderModel order,
  1791. final DadosPedido dadosPedido, final String siteId)
  1792. {
  1793. boolean success = true;
  1794.  
  1795. final Pagamento pagamento = new Pagamento();
  1796. pagamento.setCodigoSite(siteId);
  1797. pagamento.setCodigoPedido(order.getCode());
  1798. pagamento.setMoeda(order.getCurrency().getIsocode());
  1799. pagamento.setCapturado(APROVADO_CLEARSALE);
  1800. // pagamento.setCodigoAntifraude(CLEARSALE);
  1801. pagamento.setCodigoAntifraude("APPROVED");
  1802.  
  1803. pagamento.setValor( BigDecimal.valueOf(order.getTotalPrice()) );
  1804. pagamento.setValorMoeda( BigDecimal.valueOf(order.getTotalPrice()) );
  1805. pagamento.setCotacao(BigDecimal.valueOf(1));
  1806.  
  1807. PaymentTransactionEntryModel auth = null;
  1808. if( !CollectionUtils.isEmpty(order.getPaymentTransactions()) ) {
  1809. for (PaymentTransactionEntryModel model : order.getPaymentTransactions().get(0).getEntries())
  1810. {
  1811. if (model.getType().equals(PaymentTransactionType.AUTHORIZATION))
  1812. {
  1813. auth = model;
  1814. break;
  1815. }
  1816. }
  1817. }
  1818.  
  1819. if(order.getPaymentInfo() instanceof ReservePaymentInfoModel){
  1820. return true;
  1821. }
  1822.  
  1823. if ( order.getPaymentInfo() instanceof CreditCardPaymentInfoModel
  1824. && auth != null)
  1825. {
  1826. CreditCardPaymentInfoModel cc =
  1827. (CreditCardPaymentInfoModel) order.getPaymentInfo();
  1828.  
  1829. pagamento.setTipoPagamento(TipoDePagamento.CARTAO_DE_CREDITO.getCode());
  1830. pagamento.setNumeroTitulo(cc.getNumber());
  1831. pagamento.setParcelasCartao(cc.getInstallment());
  1832.  
  1833. pagamento.setCodigoAdministradora(
  1834. getCodigoAdminstradoraCartao(cc.getType().getCode()));
  1835. if(pagamento.getCodigoAdministradora() == 0){
  1836. success = false;
  1837. }
  1838.  
  1839. pagamento.setMetodo(CIELO);
  1840. pagamento.setVencimento(convertDate(order.getDate()));
  1841. // Numero de referencia do adyen
  1842. pagamento.setNumeroAprovacaoCartao(auth.getAdyenAuthorizationCode());
  1843. }
  1844. else if( order.getPaymentInfo() instanceof BoletoPaymentInfoModel
  1845. && auth != null)
  1846. {
  1847. pagamento.setTipoPagamento(TipoDePagamento.BOLETO.getCode());
  1848. pagamento.setNumeroTitulo(auth.getAdyenBoletoNossoNumero());
  1849. pagamento.setParcelasCartao(1);
  1850. // Para boleto o codigo eh ZERO
  1851. pagamento.setCodigoAdministradora(0);
  1852. pagamento.setVencimento(auth.getAdyenBoletoExpirationDate());
  1853. // Campo obrigatorio, fixo numero unico do boleto
  1854. pagamento.setNumeroAprovacaoCartao(auth.getAdyenBoletoNossoNumero());
  1855. //TODO
  1856. pagamento.setCodigoBanco("BANCO");
  1857. }
  1858. else if( order.getPaymentInfo() instanceof VoucherPaymentInfoModel)
  1859. {
  1860. pagamento.setTipoPagamento(TipoDePagamento.VALE_CREDITO.getCode());
  1861. pagamento.setParcelasCartao(1);
  1862. pagamento.setCodigoAdministradora(0);
  1863. pagamento.setVencimento(convertDate(order.getDate()));
  1864. //caso o voucher for igual ao valor da mercadoria n adicionado o metodo de pagamento aqui e sim na buildPaymentVoucher
  1865. if((new Double(0)).equals(order.getTotalPrice())){
  1866. LOG.info("Payment is Voucher and the order totalPrice is equal to 0. "
  1867. + "The payments will be constructed based on the vouchers used by this order");
  1868. return (success && true);
  1869. }
  1870. }
  1871. /*
  1872. * FIXO - utilizado somente quando for utilizado dois tipos de
  1873. * pagamentos diferente para a mesma compra
  1874. */
  1875. pagamento.setParcela(1);
  1876. dadosPedido.getPagamento().add(pagamento);
  1877. return success;
  1878. }
  1879.  
  1880. /*private void buildPaymentExchangeAndReturn( final OrderModel order,
  1881. final DadosPedido dadosPedido, final String siteId)
  1882. {
  1883.  
  1884. final Pagamento pagamento = new Pagamento();
  1885.  
  1886. for(final String voucherCode: voucherService.getAppliedVoucherCodes(order))
  1887. {
  1888. LOG.info("VOUCHER encontrado para ordem "+order.getCode()+"/"+voucherCode);
  1889. if( StringUtils.isNotBlank(voucherCode)
  1890. && ( voucherCode.toLowerCase().contains(VOUCHER_DEVOLUTION)
  1891. || voucherCode.toLowerCase().contains(VOUCHER_EXCHANGE)
  1892. || voucherCode.toLowerCase().contains(VOUCHER_OLD_EXCHAGE)))
  1893. {
  1894. final VoucherModel voucher = voucherService.getVoucher(voucherCode);
  1895.  
  1896. BigDecimal valorDoVoucher = BigDecimal.valueOf(voucher.getValue());
  1897.  
  1898. if(!voucher.getAbsolute()){
  1899. valorDoVoucher = calculateVoucherAbsoluteValue(valorDoVoucher, BigDecimal.valueOf(order.getSubtotal() ));
  1900. }
  1901.  
  1902. BigDecimal total = new BigDecimal(order.getTotalPrice()).setScale(2, RoundingMode.HALF_EVEN);
  1903.  
  1904. if(!voucherCode.toLowerCase().contains(VOUCHER_DEVOLUTION))
  1905. {
  1906. total = new BigDecimal(order.getSubtotal()).setScale(2, RoundingMode.HALF_EVEN);
  1907. }
  1908.  
  1909.  
  1910. //TODO: Ignorar valor retornado acima e utilizar o valor da ordem
  1911.  
  1912. LOG.info(total + " Valor da ordem "+order.getCode());
  1913. LOG.info(dadosPedido.getPagamento().size() + " pagamentos");
  1914. pagamento.setCodigoSite(siteId);
  1915. pagamento.setCodigoPedido(order.getCode());
  1916. pagamento.setMoeda(order.getCurrency().getSymbol());
  1917. pagamento.setCapturado(APROVADO_CLEARSALE);
  1918. pagamento.setCodigoAntifraude(CLEARSALE);
  1919. pagamento.setValor(total);
  1920. pagamento.setValorMoeda(total);
  1921.  
  1922. pagamento.setCotacao(BigDecimal.valueOf(1));
  1923. pagamento.setTipoPagamento(TipoDePagamento.VALE_PRESENTE.getCode());
  1924. pagamento.setParcelasCartao(1);
  1925. pagamento.setCodigoAdministradora(0);
  1926. pagamento.setVencimento(convertDate(order.getDate()));
  1927. pagamento.setParcela(0);
  1928. pagamento.setNumeroTitulo(voucherCode);
  1929.  
  1930. pagamento.setNumeroTitulo(order.getExchangeAndReturnProcess().getOriginalOrderCode());
  1931.  
  1932. pagamento.setTipoPagamento(TipoDePagamento.VALE_CREDITO.getCode());
  1933.  
  1934. if( voucherCode.contains("OLD_EXCHANGE_") || voucherCode.contains("EXCHANGE_") )
  1935. {
  1936. pagamento.setTipoPagamento("V");
  1937. }
  1938. else if( voucherCode.contains("RETURN_") )
  1939. {
  1940. //caso tenha escolhido extorno do cartao
  1941. if( order.getExchangeAndReturnProcess() != null
  1942. && order.getExchangeAndReturnProcess().getVoucher() == null
  1943. && order.getExchangeAndReturnProcess().getBankInformation() == null )
  1944. {
  1945. pagamento.setTipoPagamento("X");
  1946. }
  1947. else if( order.getExchangeAndReturnProcess() != null
  1948. && order.getExchangeAndReturnProcess().getBankInformation() != null )
  1949. {
  1950. pagamento.setTipoPagamento("D");
  1951. }
  1952. else
  1953. {
  1954. pagamento.setTipoPagamento("V");
  1955. pagamento.setNumeroAprovacaoCartao(getValeCredito(order));
  1956. }
  1957. }
  1958.  
  1959. BigDecimal outrosDescontos = BigDecimal.valueOf(order.getSubtotal().doubleValue() - order.getTotalPrice().doubleValue()).setScale(2, RoundingMode.HALF_EVEN);;
  1960.  
  1961. dadosPedido.getPedido().setValorTotal(total);
  1962. dadosPedido.getPedido().setDesconto( outrosDescontos.doubleValue() > 0 ? outrosDescontos : new BigDecimal("0").setScale(2, RoundingMode.HALF_EVEN));
  1963. dadosPedido.getPagamento().add(pagamento);
  1964. }
  1965. }
  1966.  
  1967. LOG.info("Nenhum dado de Pagamento de Troca/Devolução Informado");
  1968. }*/
  1969.  
  1970. private String getValeCredito(OrderModel order) {
  1971.  
  1972. if(order != null && order.getExchangeAndReturnProcess() != null && order.getExchangeAndReturnProcess().getVoucher() != null)
  1973. {
  1974. return ((PromotionVoucherModel) order.getExchangeAndReturnProcess().getVoucher()).getVoucherCode();
  1975. }
  1976.  
  1977. return null;
  1978. }
  1979.  
  1980. private void buildFulfillments(OrderModel order, DadosPedido dadosPedido, String siteId) {
  1981. //TODO: implentar populando com Consignments
  1982.  
  1983. for(ConsignmentModel consignmentModel : order.getConsignments()){
  1984.  
  1985. Fornecimento fornecimento = new Fornecimento();
  1986. fornecimento.setCodigoLocalidade(consignmentModel.getOmsLocationId());
  1987. fornecimento.setCodigoPedido(consignmentModel.getCode().substring(0, consignmentModel.getCode().lastIndexOf("-")));
  1988. fornecimento.setCodigoSite(siteId);
  1989. fornecimento.setId(consignmentModel.getOmsFulfillmentId());
  1990. fornecimento.setStatus(getConsignmentStatus(order));
  1991. fornecimento.setTipo(consignmentModel.getOmsFulfillmentType());
  1992. fornecimento.setShippingAmount(String.valueOf(consignmentModel.getShippingAmount()));
  1993. fornecimento.setReservaId(consignmentModel.getOmsFulfillmentId());
  1994.  
  1995. if (fornecimento.getTipo().equals("PICKUP")) {
  1996.  
  1997. fornecimento.setRetirarEmLojaPrePago(!isReserve(order));
  1998. fornecimento.setBackOfficePagamentoId(!isReserve(order) ? "ADCR" + order.getCode() + consignmentModel.getOmsFulfillmentId() : null);
  1999.  
  2000. }
  2001.  
  2002. for(ConsignmentEntryModel consignmentEntryModel : consignmentModel.getConsignmentEntries()){
  2003. Itens itens = new Itens();
  2004.  
  2005. if(consignmentEntryModel.getOrderEntry() != null){
  2006. itens.setQuantidade(consignmentEntryModel.getOrderEntry().getQuantity().intValue());
  2007. itens.setSku(consignmentEntryModel.getOrderEntry().getProduct().getCode());
  2008.  
  2009. if (consignmentEntryModel.getOrderEntry().getCustomText() == null) {
  2010. itens.setTextoPersonalizado(" ");
  2011. } else {
  2012. itens.setTextoPersonalizado(consignmentEntryModel.getOrderEntry().getCustomText());
  2013. }
  2014.  
  2015. itens.setIndicaBrinde(consignmentEntryModel.getOrderEntry().getGiveAway() ? "1" : "0");
  2016.  
  2017. if (order.getExchangeAndReturnProcess() != null && checkIfOrderExchange(order)) {
  2018.  
  2019. /* TODO */
  2020. itens.setReferenceSkuId(getOriginalExchangedProductSku(order, consignmentEntryModel.getOrderEntry().getProduct().getCode()));
  2021.  
  2022. itens.setHybrisItemSequenceId(String.valueOf(consignmentEntryModel.getOrderEntry().getEntryNumber() + 1));
  2023.  
  2024. }
  2025. }
  2026. fornecimento.getItens().add(itens);
  2027. }
  2028.  
  2029.  
  2030. if(consignmentModel.getShipment() != null){
  2031. Remessa remessa = new Remessa();
  2032.  
  2033. remessa.setCodigoContrato(consignmentModel.getShipment().getContractId());
  2034. remessa.setCodigoTransportadora(consignmentModel.getShipment().getCarrierId());
  2035. remessa.setMetodo(consignmentModel.getShipment().getMethod());
  2036. remessa.setPrecoRemessa(BigDecimal.valueOf(consignmentModel.getShipment().getShippingPrice()));
  2037. remessa.setTempoRemessa(String.valueOf(consignmentModel.getShipment().getShippingTime()));
  2038.  
  2039.  
  2040. if(consignmentModel.getShippingAddress() != null){
  2041.  
  2042. Endereco endereco = new Endereco();
  2043.  
  2044. endereco = buildAddress(consignmentModel.getShippingAddress(), order.getUser().getPk().toString());
  2045.  
  2046. /*endereco.setBairro(consignmentModel.getShippingAddress().getDistrict());
  2047. endereco.setCelular(consignmentModel.getShippingAddress().getCellphone());
  2048. endereco.setCep(consignmentModel.getShippingAddress().getPostalcode());
  2049. endereco.setCidade(consignmentModel.getShippingAddress().getTown());
  2050. endereco.setCodigoCliente(order.getPk().toString());
  2051. endereco.setCodigoEndereco(consignmentModel.getShippingAddress().getPk().toString());
  2052. endereco.setComplemento(consignmentModel.getShippingAddress().getComplemento());
  2053. endereco.setDdd(consignmentModel.getShippingAddress().getDddPhone());
  2054. endereco.setDddCelular(consignmentModel.getShippingAddress().getDddCellPhone());
  2055. endereco.setDescricaoEndereco(consignmentModel.getShippingAddress().getFirstname() + " " + consignmentModel.getShippingAddress().getLastname());
  2056. endereco.setEnderecoCobranca(consignmentModel.getShippingAddress().getBillingAddress());
  2057. endereco.setEnderecoEntrega(consignmentModel.getShippingAddress().getShippingAddress());
  2058. endereco.setEnderecoPrincipal(consignmentModel.getShippingAddress().getContactAddress());
  2059. endereco.setLogradouro(consignmentModel.getShippingAddress().getStreetname());
  2060. endereco.setNumero(consignmentModel.getShippingAddress().getStreetnumber());
  2061. endereco.setPais(consignmentModel.getShippingAddress().getCountry();
  2062. endereco.setTelefone(consignmentModel.getShippingAddress().getPhone1());
  2063. endereco.setTipoEndereco(getAddressType(consignmentModel.getShippingAddress()));
  2064. endereco.setUf(consignmentModel.getShippingAddress().getRegion() != null ?
  2065. consignmentModel.getShippingAddress().getRegion().getIsocode().substring(3) : null);
  2066. endereco.setCodigoMunicipioIBGE("9999999");*/
  2067.  
  2068. remessa.setEndereco(endereco);
  2069. }
  2070.  
  2071. fornecimento.setRemessa(remessa);
  2072. }
  2073.  
  2074.  
  2075. if (consignmentModel.getFreightCosts() != null) {
  2076.  
  2077. CustosDeFrete shippingCost = new CustosDeFrete();
  2078.  
  2079. shippingCost.setEsperandoTempoTransferencia(String.valueOf(consignmentModel.getFreightCosts().getWaitingTransferTime()));
  2080. shippingCost.setPrecoSeparacao(BigDecimal.valueOf(consignmentModel.getFreightCosts().getHandlingPrice()));
  2081. shippingCost.setPrecoTotal(BigDecimal.valueOf(consignmentModel.getFreightCosts().getTotalPrice()));
  2082. shippingCost.setPrecoTransferencia(BigDecimal.valueOf(consignmentModel.getFreightCosts().getTransferPrice()));
  2083. shippingCost.setTempoChegadaEstoque(String.valueOf(consignmentModel.getFreightCosts().getStockArrivalTime()));
  2084. shippingCost.setTempoSeparacao(String.valueOf(consignmentModel.getFreightCosts().getHandlingTime()));
  2085. shippingCost.setTempoTotal(String.valueOf(consignmentModel.getFreightCosts().getTotalTime()));
  2086. shippingCost.setTempoTransferencia(String.valueOf(consignmentModel.getFreightCosts().getTransferTime()));
  2087.  
  2088. fornecimento.setCustosDeFrete(shippingCost);
  2089. }
  2090.  
  2091.  
  2092.  
  2093. dadosPedido.setFornecimentos(new Fornecimentos());
  2094. dadosPedido.getFornecimentos().getFornecimento().add(fornecimento);
  2095.  
  2096. }
  2097.  
  2098. }
  2099.  
  2100. private void buildPaymentVoucher(
  2101. final OrderModel order,
  2102. final DadosPedido dadosPedido, final String siteId)
  2103. {
  2104. final Pagamento pagamento = new Pagamento();
  2105.  
  2106. //apenas um voucher promocional por pedido, mais um voucher tratado pelo buildPayment
  2107. for(final String voucherCode: voucherService.getAppliedVoucherCodes(order))
  2108. {
  2109. LOG.info("Encontrado voucher: " + voucherCode);
  2110.  
  2111. if( StringUtils.isNotBlank(voucherCode)
  2112. && ( voucherCode.toLowerCase().startsWith(VOUCHER_VALIDATE)
  2113. || voucherCode.toLowerCase().startsWith(VALE_PRESENTE)))
  2114. {
  2115. final VoucherModel voucher = voucherService.getVoucher(voucherCode);
  2116.  
  2117. if(voucher == null){
  2118. LOG.info("Voucher eh invalido. Skipping...");
  2119. continue;
  2120. } else {
  2121. LOG.info("Voucher eh valido. Criando pagamento...");
  2122. }
  2123.  
  2124. BigDecimal valorDoVoucher = BigDecimal.valueOf(voucher.getValue());
  2125.  
  2126. if(!voucher.getAbsolute()){
  2127. valorDoVoucher = calculateVoucherAbsoluteValue(valorDoVoucher, BigDecimal.valueOf(order.getSubtotal() ));
  2128. }
  2129.  
  2130. LOG.info("Valor do voucher: " + valorDoVoucher);
  2131.  
  2132. pagamento.setCodigoSite(siteId);
  2133. pagamento.setCodigoPedido(order.getCode());
  2134. pagamento.setMoeda(order.getCurrency().getIsocode());
  2135. pagamento.setCapturado(APROVADO_CLEARSALE);
  2136. // pagamento.setCodigoAntifraude(CLEARSALE);
  2137. pagamento.setCodigoAntifraude("APPROVED");
  2138. pagamento.setValor(valorDoVoucher);
  2139. pagamento.setValorMoeda(valorDoVoucher);
  2140.  
  2141. pagamento.setStatusVerificacaoFraude("APPROVED");
  2142.  
  2143. pagamento.setCotacao(BigDecimal.valueOf(1));
  2144. pagamento.setTipoPagamento(TipoDePagamento.VALE_CREDITO.getCode());
  2145. pagamento.setParcelasCartao(1);
  2146. pagamento.setCodigoAdministradora(0);
  2147. pagamento.setVencimento(convertDate(order.getDate()));
  2148. pagamento.setParcela(0);
  2149. pagamento.setNumeroTitulo(voucherCode);
  2150.  
  2151. //como o vale cr���������dito n���������o ��������� desconto ��������� realculado o valor de desconto
  2152. BigDecimal outrosDescontos =
  2153. BigDecimal.valueOf(order.getTotalDiscounts());
  2154.  
  2155. outrosDescontos =
  2156. outrosDescontos.subtract(
  2157. BigDecimal.valueOf(
  2158. Math.min(outrosDescontos.doubleValue(),
  2159. valorDoVoucher.doubleValue())));
  2160.  
  2161. LOG.info("Outros descontos: " + outrosDescontos);
  2162.  
  2163. //totaldiscounts: 59,9 - voucher: 54,99 = 4,91 no caso do voucher, o totaldiscounts est������ englobando o valor do voucher. Se eu tirar o valor
  2164. // do voucher, tenho o valor que efetivamente foi dado como desconto
  2165. if( voucher.getFreeShipping() ){
  2166. dadosPedido.getPedido().setValorFrete(BigDecimal.ZERO);
  2167. outrosDescontos =
  2168. outrosDescontos.subtract(
  2169. BigDecimal.valueOf(
  2170. Math.min(outrosDescontos.doubleValue(), order.getDeliveryCost())) );
  2171. LOG.info("Voucher eh freeShipping. Outros descontos ajustados: " + outrosDescontos);
  2172. }
  2173.  
  2174. dadosPedido.getPedido().setDesconto( outrosDescontos );
  2175. dadosPedido.getPagamento().add(pagamento);
  2176. break;
  2177. }
  2178. }
  2179. }
  2180.  
  2181. private String getAddressType(final AddressModel add)
  2182. {
  2183. String home = "2";
  2184. String company = "3";
  2185.  
  2186. if (add.getTipoDeEndereco() == null)
  2187. {
  2188. return home;
  2189. }
  2190.  
  2191. if (add.getTipoDeEndereco().getCode().equals(
  2192. TipoDeEndereco.RESIDENCIAL))
  2193. {
  2194. return home;
  2195. }
  2196. //TODO:
  2197. //return "billing";
  2198. return company;
  2199. }
  2200.  
  2201. private int getCodigoAdminstradoraCartao(final String brand)
  2202. {
  2203. if(brand == null)
  2204. {
  2205. return 0;
  2206. }
  2207. if (brand.equalsIgnoreCase("VISA"))
  2208. {
  2209. return 1;
  2210. }
  2211. if (brand.equalsIgnoreCase("MASTER"))
  2212. {
  2213. return 2;
  2214. }
  2215. if (brand.equalsIgnoreCase("DINERS"))
  2216. {
  2217. return 3;
  2218. }
  2219. if (brand.equalsIgnoreCase("AMEX"))
  2220. {
  2221. return 4;
  2222. }
  2223. if (brand.equalsIgnoreCase("HIPERCARD"))
  2224. {
  2225. return 5;
  2226. }
  2227. if (brand.equalsIgnoreCase("ELO"))
  2228. {
  2229. return 6;
  2230. }
  2231. if (brand.equalsIgnoreCase("HERING"))
  2232. {
  2233. return 7;
  2234. }
  2235. if (brand.equalsIgnoreCase("ELECTRON"))
  2236. {
  2237. return 8;
  2238. }
  2239. if (brand.equalsIgnoreCase("MAESTRO"))
  2240. {
  2241. return 9;
  2242. }
  2243. return 0;
  2244. }
  2245.  
  2246. private BigDecimal calculateDiscount(final List<DiscountValue> list) {
  2247. BigDecimal total = new BigDecimal(0);
  2248. for (final DiscountValue discount : list) {
  2249. total = total.add(BigDecimal.valueOf(discount.getValue())) ;
  2250. }
  2251. return total;
  2252. }
  2253.  
  2254. private Resultado setUpResultado( final OrderModel orderModel, final Pedido pedido, final String siteId )
  2255. {
  2256. BankInformationsModel bankInformations =
  2257. orderModel.getExchangeAndReturnProcess().getBankInformation();
  2258.  
  2259. StringBuilder chave = new StringBuilder();
  2260. chave.append("#" + bankInformations.getBank());
  2261. chave.append("#" + bankInformations.getAccountHolder());
  2262. chave.append("#" + bankInformations.getDocument());
  2263. chave.append("#" + bankInformations.getAgency());
  2264. chave.append("#" + bankInformations.getAccount());
  2265.  
  2266. Resultado resultado = new Resultado();
  2267. resultado.setTransacao("DEVOLUCAO_HYBRIS");
  2268. resultado.setMensagem(chave.toString());
  2269. resultado.setChave("CODIGO_SITE="+ siteId +"#PEDIDO=" + pedido.getCodigoPedido());
  2270.  
  2271. return resultado;
  2272. }
  2273.  
  2274. /**
  2275. * @return the omsOrderDao
  2276. */
  2277. public OMSOrderDao getOmsOrderDao() {
  2278. return omsOrderDao;
  2279. }
  2280.  
  2281. /**
  2282. * @param omsOrderDao the omsOrderDao to set
  2283. */
  2284. public void setOmsOrderDao(OMSOrderDao omsOrderDao) {
  2285. this.omsOrderDao = omsOrderDao;
  2286. }
  2287. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement