diff --git a/pom.xml b/pom.xml
index a37095d56..b4a4e11c3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,11 +4,11 @@
4.0.0
br.com.rjconsultores
ventaboletosadm
- 1.0.59
+ 1.0.60
war
- 1.0.34
+ 1.0.35
1.0.23
diff --git a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/catalogos/EditarEmpresaController.java b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/catalogos/EditarEmpresaController.java
index d0431d871..491a3d162 100644
--- a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/catalogos/EditarEmpresaController.java
+++ b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/catalogos/EditarEmpresaController.java
@@ -33,8 +33,6 @@ import java.util.regex.Pattern;
import org.apache.commons.lang.BooleanUtils;
import org.apache.commons.lang.StringUtils;
-import org.apache.http.HttpStatus;
-import org.apache.http.entity.ContentType;
import org.apache.log4j.Logger;
import org.brazilutils.br.cpfcnpj.Cnpj;
import org.brazilutils.br.cpfcnpj.Cpf;
@@ -68,7 +66,6 @@ import org.zkoss.zul.Tab;
import org.zkoss.zul.Tabbox;
import org.zkoss.zul.Textbox;
-import com.google.gson.Gson;
import com.rjconsultores.ventaboletos.constantes.ConstantesFuncionSistema;
import com.rjconsultores.ventaboletos.entidad.Categoria;
import com.rjconsultores.ventaboletos.entidad.Ciudad;
@@ -95,11 +92,9 @@ import com.rjconsultores.ventaboletos.entidad.Parada;
import com.rjconsultores.ventaboletos.entidad.TipoEventoExtra;
import com.rjconsultores.ventaboletos.enums.TipoCstGratuidade;
import com.rjconsultores.ventaboletos.enums.TipoEmail;
-import com.rjconsultores.ventaboletos.enums.TipoEnvioRest;
import com.rjconsultores.ventaboletos.enums.TipoOperacaoECommerce;
import com.rjconsultores.ventaboletos.exception.BusinessException;
-import com.rjconsultores.ventaboletos.rest.generic.GenericRest;
-import com.rjconsultores.ventaboletos.rest.generic.RetornoGenericRest;
+import com.rjconsultores.ventaboletos.rest.MercadoPagoService;
import com.rjconsultores.ventaboletos.service.CategoriaService;
import com.rjconsultores.ventaboletos.service.CiudadService;
import com.rjconsultores.ventaboletos.service.EmpresaAdyenConfigService;
@@ -122,11 +117,9 @@ import com.rjconsultores.ventaboletos.utilerias.RegistroConDependenciaException;
import com.rjconsultores.ventaboletos.utilerias.SendMail.AuthType;
import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado;
import com.rjconsultores.ventaboletos.vo.mercadopago.PosVO;
-import com.rjconsultores.ventaboletos.vo.mercadopago.RetornoErro;
import com.rjconsultores.ventaboletos.vo.mercadopago.RetornoPosVO;
import com.rjconsultores.ventaboletos.vo.mercadopago.RetornoStoreVO;
import com.rjconsultores.ventaboletos.vo.mercadopago.StoreVO;
-import com.rjconsultores.ventaboletos.vo.mercadopago.StoreVO.Location;
import com.rjconsultores.ventaboletos.web.utilerias.MyComboboxEstandar;
import com.rjconsultores.ventaboletos.web.utilerias.MyComboboxParada;
import com.rjconsultores.ventaboletos.web.utilerias.MyGenericForwardComposer;
@@ -1834,10 +1827,26 @@ public void onClick$btnTestEmailFlexBus(Event ev) throws InterruptedException {
}
public void onClick$btnCadastrarStoreMercadoPago(Event ev) throws InterruptedException {
- Object storeVO = cadastrarStoreMercadoPago();
-
- if (storeVO != null && storeVO instanceof StoreVO ) {
- RetornoStoreVO retornoStoreVO = retornarStoreMercadoPago();
+ Object storeVO = MercadoPagoService.getInstance().cadastrarStoreMercadoPago(empresa, txtNomeStore.getValue(),
+ txtIdStoreMercadoPago.getValue(), txtUserIdMercadoPago.getValue(), txtUrlApiMercadoPago.getValue(),
+ txtTokenMercadoPago.getValue());
+
+ if (storeVO != null && storeVO instanceof StoreVO) {
+ RetornoStoreVO retornoStoreVO = MercadoPagoService.getInstance().retornarStoreMercadoPago(
+ txtUserIdMercadoPago.getValue(), txtUrlApiMercadoPago.getValue(), txtTokenMercadoPago.getValue());
+
+ boolean processing = true;
+ while (processing) {
+ for (StoreVO vo : retornoStoreVO.getResults()) {
+ if (storeVO.toString().equals(vo.toString())) {
+ processing = false;
+ break;
+ }
+ }
+ retornoStoreVO = MercadoPagoService.getInstance().retornarStoreMercadoPago(
+ txtUserIdMercadoPago.getValue(), txtUrlApiMercadoPago.getValue(),
+ txtTokenMercadoPago.getValue());
+ }
lsStoreMercadoPago.clear();
for (StoreVO vo : retornoStoreVO.getResults()) {
lsStoreMercadoPago.add(vo);
@@ -1845,8 +1854,12 @@ public void onClick$btnTestEmailFlexBus(Event ev) throws InterruptedException {
BindingListModel listModel = new BindingListModelList(lsStoreMercadoPago, true);
cmbStoreMercadoPago.setModel(listModel);
cmbStoreCadastroMercadoPago.setModel(listModel);
-
- Messagebox.show("Store cadastrada com sucesso", Labels.getLabel("editarEmpresaController.window.title"),
+ if (this.storeVO != null) {
+ cmbStoreMercadoPago.setSelectedIndex(lsStoreMercadoPago.indexOf(this.storeVO));
+ }
+
+ Messagebox.show(Labels.getLabel("editarEmpresaController.lblMsgCadastrarStoreMercadoPago.value"),
+ Labels.getLabel("editarEmpresaController.window.title"),
Messagebox.OK, Messagebox.INFORMATION);
} else {
Messagebox.show(storeVO.toString(), Labels.getLabel("editarEmpresaController.window.title"),
@@ -1856,17 +1869,42 @@ public void onClick$btnTestEmailFlexBus(Event ev) throws InterruptedException {
}
public void onClick$btnCadastrarPOSMercadoPago(Event ev) throws InterruptedException {
- Object posVO = cadastrarPOSMercadoPago();
+
+ Object posVO = MercadoPagoService.getInstance().cadastrarPOSMercadoPago(txtNomePOS.getValue(),
+ cmbStoreCadastroMercadoPago.getSelectedItem() != null
+ ? (StoreVO) cmbStoreCadastroMercadoPago.getSelectedItem().getValue()
+ : null,
+ txtIdPOSMercadoPago.getValue(), txtUrlApiMercadoPago.getValue(), txtTokenMercadoPago.getValue());
if (posVO != null && posVO instanceof PosVO) {
- RetornoPosVO retornoPosVO = retornarPosMercadoPago();
+ RetornoPosVO retornoPosVO = MercadoPagoService.getInstance()
+ .retornarPosMercadoPago(txtUrlApiMercadoPago.getValue(), txtTokenMercadoPago.getValue());
+
+ boolean processing = true;
+ while (processing) {
+ for (PosVO vo : retornoPosVO.getResults()) {
+ if (posVO.toString().equals(vo.toString())) {
+ processing = false;
+ break;
+ }
+
+ }
+ retornoPosVO = MercadoPagoService.getInstance().retornarPosMercadoPago(txtUrlApiMercadoPago.getValue(),
+ txtTokenMercadoPago.getValue());
+ }
+
lsPosMercadoPago.clear();
for (PosVO vo : retornoPosVO.getResults()) {
lsPosMercadoPago.add(vo);
}
BindingListModel listModel = new BindingListModelList(lsPosMercadoPago, true);
cmbPOSMercadoPago.setModel(listModel);
- Messagebox.show("POS cadastrado com sucesso", Labels.getLabel("editarEmpresaController.window.title"),
+ if (this.posVO != null) {
+ cmbPOSMercadoPago.setSelectedIndex(lsPosMercadoPago.indexOf(this.posVO));
+ }
+
+ Messagebox.show(Labels.getLabel("editarEmpresaController.lblMsgCadastrarPOSMercadoPago.value"),
+ Labels.getLabel("editarEmpresaController.window.title"),
Messagebox.OK, Messagebox.INFORMATION);
} else {
Messagebox.show(storeVO.toString(), Labels.getLabel("editarEmpresaController.window.title"),
@@ -1881,16 +1919,18 @@ public void onClick$btnTestEmailFlexBus(Event ev) throws InterruptedException {
lsStoreMercadoPago = new ArrayList();
lsPosMercadoPago = new ArrayList();
-
- RetornoStoreVO retornoStoreVO = retornarStoreMercadoPago();
+
+ RetornoStoreVO retornoStoreVO = MercadoPagoService.getInstance().retornarStoreMercadoPago(
+ txtUserIdMercadoPago.getValue(), txtUrlApiMercadoPago.getValue(), txtTokenMercadoPago.getValue());
for (StoreVO vo : retornoStoreVO.getResults()) {
- if ( store != null && vo.toString().equals(store)) {
+ if (store != null && vo.toString().equals(store)) {
this.storeVO = vo;
}
lsStoreMercadoPago.add(vo);
}
- RetornoPosVO retornoPosVO = retornarPosMercadoPago();
+ RetornoPosVO retornoPosVO = MercadoPagoService.getInstance()
+ .retornarPosMercadoPago(txtUrlApiMercadoPago.getValue(), txtTokenMercadoPago.getValue());
for (PosVO vo : retornoPosVO.getResults()) {
if (pos != null && vo.toString().equals(pos)) {
this.posVO = vo;
@@ -1899,150 +1939,6 @@ public void onClick$btnTestEmailFlexBus(Event ev) throws InterruptedException {
}
}
- private Object cadastrarStoreMercadoPago() {
-
- try {
- StoreVO consulta = new StoreVO();
-
- consulta.setName(txtNomeStore.getValue());
- consulta.setExternal_id(txtIdStoreMercadoPago.getValue());
-
- Location item = new Location();
- item.setStreet_number(empresa.getNumero());
- item.setStreet_name(empresa.getLogradouro());
- item.setCity_name(StringUtils.capitalize(empresa.getCidade().getNombciudad().toLowerCase()));
- item.setState_name(StringUtils.capitalize(empresa.getCidade().getEstado().getNombestado().toLowerCase()) );
- item.setLatitude(empresa.getLatitude());
- item.setLongitude(empresa.getLongitude());
- item.setReference(empresa.getComplemento());
-
- consulta.setLocation(item);
-
- HashMap headers = new HashMap();
- headers.put("Authorization",
- "Bearer " + txtTokenMercadoPago.getValue());
- headers.put("Accept", "application/json");
- headers.put("Content-type", "application/json");
-
- String userId = txtUserIdMercadoPago.getValue();
-
- RetornoGenericRest> resposta = GenericRest.getInstance().fazerChamada(
- txtUrlApiMercadoPago.getValue() + "/users/" + userId + "/stores",
- TipoEnvioRest.POST, new Gson().toJson(consulta).toString(), ContentType.APPLICATION_JSON,
- headers, StoreVO.class, Object.class);
-
- if (resposta != null && (resposta.getStatusResposta().equals(HttpStatus.SC_OK)
- || resposta.getStatusResposta().equals(HttpStatus.SC_CREATED))) {
- return (StoreVO) resposta.getConteudo();
- } else {
- return resposta.getConteudoErro();
- }
-
- } catch (Exception e) {
- log.error("erro ao enviar requisicao ", e);
- }
-
- return null;
- }
-
- private Object cadastrarPOSMercadoPago() {
-
- try {
- PosVO consulta = new PosVO();
-
- consulta.setName(txtNomePOS.getValue());
- consulta.setFixed_amount(false);
-
- if (cmbStoreCadastroMercadoPago.getSelectedItem() != null) {
- StoreVO storeVO = (StoreVO) cmbStoreCadastroMercadoPago.getSelectedItem().getValue();
- consulta.setStore_id(storeVO.getId());
- consulta.setExternal_store_id(storeVO.getExternal_id());
- }
-
- consulta.setExternal_id(txtIdPOSMercadoPago.getValue());
- consulta.setCategory(5611203);
-
- HashMap headers = new HashMap();
- headers.put("Authorization",
- "Bearer " + txtTokenMercadoPago.getValue());
- headers.put("Accept", "application/json");
- headers.put("Content-type", "application/json");
-
- RetornoGenericRest> resposta = GenericRest.getInstance().fazerChamada(
- txtUrlApiMercadoPago.getValue() + "/pos",
- TipoEnvioRest.POST, new Gson().toJson(consulta).toString(), ContentType.APPLICATION_JSON,
- headers, PosVO.class, RetornoErro.class);
-
- if (resposta != null && (resposta.getStatusResposta().equals(HttpStatus.SC_OK)
- || resposta.getStatusResposta().equals(HttpStatus.SC_CREATED))) {
- return (PosVO) resposta.getConteudo();
- } else {
- return resposta.getConteudoErro();
- }
-
- } catch (Exception e) {
- log.error("erro ao enviar requisicao ", e);
- }
-
- return null;
- }
-
- private RetornoStoreVO retornarStoreMercadoPago() {
-
- try {
-
- HashMap headers = new HashMap();
- headers.put("Authorization",
- "Bearer " + txtTokenMercadoPago.getValue());
- headers.put("Accept", "application/json");
- headers.put("Content-type", "application/json");
-
- String userId = txtUserIdMercadoPago.getValue();
-
- RetornoGenericRest> resposta = GenericRest.getInstance().fazerChamada(
- txtUrlApiMercadoPago.getValue() + "/users/" + userId + "/stores/search",
- TipoEnvioRest.GET, null, ContentType.APPLICATION_JSON,
- headers, RetornoStoreVO.class, RetornoErro.class);
-
- if (resposta != null && (resposta.getStatusResposta().equals(HttpStatus.SC_OK)
- || resposta.getStatusResposta().equals(HttpStatus.SC_CREATED))) {
- return (RetornoStoreVO) resposta.getConteudo();
- }
-
- } catch (Exception e) {
- log.error("erro ao enviar requisicao ", e);
- }
-
- return null;
- }
-
- private RetornoPosVO retornarPosMercadoPago() {
-
- try {
-
- HashMap headers = new HashMap();
- headers.put("Authorization",
- "Bearer " + txtTokenMercadoPago.getValue());
- headers.put("Accept", "application/json");
- headers.put("Content-type", "application/json");
-
- RetornoGenericRest> resposta = GenericRest.getInstance().fazerChamada(
- txtUrlApiMercadoPago.getValue() + "/pos",
- TipoEnvioRest.GET, null, ContentType.APPLICATION_JSON,
- headers, RetornoPosVO.class, RetornoErro.class);
-
- if (resposta != null && (resposta.getStatusResposta().equals(HttpStatus.SC_OK)
- || resposta.getStatusResposta().equals(HttpStatus.SC_CREATED))) {
- return (RetornoPosVO) resposta.getConteudo();
- }
-
- } catch (Exception e) {
- log.error("erro ao enviar requisicao ", e);
- }
-
- return null;
- }
-
public Combobox getCmbEstadoInscEstadual() {
return cmbEstadoInscEstadual;
}
diff --git a/web/WEB-INF/i3-label_en.label b/web/WEB-INF/i3-label_en.label
index e905228e4..c1a6564cf 100644
--- a/web/WEB-INF/i3-label_en.label
+++ b/web/WEB-INF/i3-label_en.label
@@ -1949,6 +1949,22 @@ editarEmpresaController.lblCodigoContratoSafer.value = Código do contrato
editarEmpresaController.lblInfoSafer.value = Informações Certificado
editarEmpresaController.lblCarregarCertificadoSafer.value = Carregar Certificado
+editarEmpresaController.lblMercadoPago.value = Mercado Pago
+editarEmpresaController.lblTabGeralMercadoPago.value = General
+editarEmpresaController.lblTabCadastroMercadoPago.value = Register
+editarEmpresaController.lblUserIdMercadoPago.value = User ID
+editarEmpresaController.lblTokenMercadoPago.value = Token
+editarEmpresaController.lblUrlApiMercadoPago.value = Url API
+editarEmpresaController.lblStoreMercadoPago.value = Store
+editarEmpresaController.lblPOSMercadoPago.value = POS
+editarEmpresaController.lblStoreNomeMercadoPago.value = Name
+editarEmpresaController.lblIdExternoMercadoPago.value = External ID
+editarEmpresaController.lblPOSNomeMercadoPago.value = Name
+editarEmpresaController.lblBtnCadastrarStoreMercadoPago.value = Register Store
+editarEmpresaController.lblBtnCadastrarPOSMercadoPago.value = Register POS
+editarEmpresaController.lblMsgCadastrarStoreMercadoPago.value = Store registered with success
+editarEmpresaController.lblMsgCadastrarPOSMercadoPago.value = POS registered with success
+
# Muestra o ponto de Pesquisa de Venda
busquedaPuntoVentaController.window.title = Ponto de Venda ( Agência )
busquedaPuntoVentaController.btnRefresh.tooltiptext = Atualizar
diff --git a/web/WEB-INF/i3-label_es_MX.label b/web/WEB-INF/i3-label_es_MX.label
index 52f679d82..fd71ced3b 100644
--- a/web/WEB-INF/i3-label_es_MX.label
+++ b/web/WEB-INF/i3-label_es_MX.label
@@ -1730,6 +1730,22 @@ editarEmpresaController.lblCodigoContratoSafer.value = Código do contrato
editarEmpresaController.lblInfoSafer.value = Informações Certificado
editarEmpresaController.lblCarregarCertificadoSafer.value = Carregar Certificado
+editarEmpresaController.lblMercadoPago.value = Mercado Pago
+editarEmpresaController.lblTabGeralMercadoPago.value = General
+editarEmpresaController.lblTabCadastroMercadoPago.value = Registro
+editarEmpresaController.lblUserIdMercadoPago.value = User ID
+editarEmpresaController.lblTokenMercadoPago.value = Token
+editarEmpresaController.lblUrlApiMercadoPago.value = Url API
+editarEmpresaController.lblStoreMercadoPago.value = Store
+editarEmpresaController.lblPOSMercadoPago.value = POS
+editarEmpresaController.lblStoreNomeMercadoPago.value = Nombre
+editarEmpresaController.lblIdExternoMercadoPago.value = ID Externo
+editarEmpresaController.lblPOSNomeMercadoPago.value = Nombre
+editarEmpresaController.lblBtnCadastrarStoreMercadoPago.value = Registrar Store
+editarEmpresaController.lblBtnCadastrarPOSMercadoPago.value = Registrar POS
+editarEmpresaController.lblMsgCadastrarStoreMercadoPago.value = Store registrada com exito
+editarEmpresaController.lblMsgCadastrarPOSMercadoPago.value = POS registrada com exito
+
# Muestra o ponto de Búsqueda de venta
busquedaPuntoVentaController.window.title = Punto de venta ( Agencia )
busquedaPuntoVentaController.btnRefresh.tooltiptext = Actualizar
diff --git a/web/WEB-INF/i3-label_pt_BR.label b/web/WEB-INF/i3-label_pt_BR.label
index 8db6dc047..fed26cf57 100644
--- a/web/WEB-INF/i3-label_pt_BR.label
+++ b/web/WEB-INF/i3-label_pt_BR.label
@@ -1947,6 +1947,22 @@ editarEmpresaController.lblCodigoContratoSafer.value = Código do contrato
editarEmpresaController.lblInfoSafer.value = Informações Certificado
editarEmpresaController.lblCarregarCertificadoSafer.value = Carregar Certificado
+editarEmpresaController.lblMercadoPago.value = Mercado Pago
+editarEmpresaController.lblTabGeralMercadoPago.value = Geral
+editarEmpresaController.lblTabCadastroMercadoPago.value = Cadastro
+editarEmpresaController.lblUserIdMercadoPago.value = User ID
+editarEmpresaController.lblTokenMercadoPago.value = Token
+editarEmpresaController.lblUrlApiMercadoPago.value = Url API
+editarEmpresaController.lblStoreMercadoPago.value = Store
+editarEmpresaController.lblPOSMercadoPago.value = POS
+editarEmpresaController.lblStoreNomeMercadoPago.value = Nome
+editarEmpresaController.lblIdExternoMercadoPago.value = ID Externo
+editarEmpresaController.lblPOSNomeMercadoPago.value = Nome
+editarEmpresaController.lblBtnCadastrarStoreMercadoPago.value = Cadastrar Store
+editarEmpresaController.lblBtnCadastrarPOSMercadoPago.value = Cadastrar POS
+editarEmpresaController.lblMsgCadastrarStoreMercadoPago.value = Store cadastrada com sucesso
+editarEmpresaController.lblMsgCadastrarPOSMercadoPago.value = POS cadastrada com sucesso
+
# Muestra o ponto de Pesquisa de Venda
busquedaPuntoVentaController.window.title = Ponto de Venda ( Agência )
busquedaPuntoVentaController.btnRefresh.tooltiptext = Atualizar
diff --git a/web/gui/catalogos/editarEmpresa.zul b/web/gui/catalogos/editarEmpresa.zul
index fcef2e9f7..1f77fa3ef 100644
--- a/web/gui/catalogos/editarEmpresa.zul
+++ b/web/gui/catalogos/editarEmpresa.zul
@@ -63,7 +63,7 @@
+ label="${c:l('editarEmpresaController.lblMercadoPago.value')}" />
@@ -2270,8 +2270,8 @@
-
-
+
+
@@ -2286,28 +2286,28 @@
+ value="${c:l('editarEmpresaController.lblUserIdMercadoPago.value')}" />
+ value="${c:l('editarEmpresaController.lblTokenMercadoPago.value')}" />
+ value="${c:l('editarEmpresaController.lblUrlApiMercadoPago.value')}" />
+ value="${c:l('editarEmpresaController.lblStoreMercadoPago.value')}" />
+ value="${c:l('editarEmpresaController.lblPOSMercadoPago.value')}" />
+ value="${c:l('editarEmpresaController.lblStoreNomeMercadoPago.value')}" />
+ value="${c:l('editarEmpresaController.lblIdExternoMercadoPago.value')}" />
-
+
POS
@@ -2375,27 +2376,29 @@
+ value="${c:l('editarEmpresaController.lblPOSNomeMercadoPago.value')}" />
+ value="${c:l('editarEmpresaController.lblIdExternoMercadoPago.value')}" />
+ value="${c:l('editarEmpresaController.lblStoreMercadoPago.value')}" />
+ use="com.rjconsultores.ventaboletos.web.utilerias.MyComboboxEstandar"
+ model="@{winEditarEmpresa$composer.lsStoreMercadoPago}"/>
-
+