Merge branch 'master' of http://192.168.10.111:8383/SIG
This commit is contained in:
@@ -129,11 +129,12 @@ Public Class E119 : Implements IHttpHandler
|
||||
End If
|
||||
|
||||
If Metodo = "RegistraRemision" Then
|
||||
|
||||
context.Response.ContentType = "application/json"
|
||||
Dim Auth As AuthMessage = ValidarSolicitud(context)
|
||||
|
||||
MsgLog.AppendLine("Validado:" & Auth.IsSuccess)
|
||||
If Auth.IsSuccess Then
|
||||
retorno = RegistraRemision(context)
|
||||
retorno = RegistraRemision(context, MsgLog)
|
||||
Else
|
||||
context.Response.StatusCode = Auth.StatusCode
|
||||
retorno = JsonConvert.SerializeObject(Auth.ErrorMessage)
|
||||
@@ -335,15 +336,14 @@ Public Class E119 : Implements IHttpHandler
|
||||
End If
|
||||
End Function
|
||||
|
||||
Private Function RegistraRemision(ByVal context As HttpContext) As String
|
||||
Private Function RegistraRemision(ByVal context As HttpContext, ByRef MsgLog As StringBuilder) As String
|
||||
|
||||
Dim TieneError As Boolean = False
|
||||
Dim JsonRequest As JObject = Nothing
|
||||
Dim Respuesta As New ResponseMsg
|
||||
Dim RespuestaError As New ResponseMsgError
|
||||
Dim MsgLog As New StringBuilder
|
||||
Try
|
||||
|
||||
Try
|
||||
MsgLog.AppendLine("1.0 Registra")
|
||||
If context.Request.InputStream IsNot Nothing Then
|
||||
Using reader As New StreamReader(context.Request.InputStream)
|
||||
@@ -355,6 +355,7 @@ Public Class E119 : Implements IHttpHandler
|
||||
TieneError = True
|
||||
End If
|
||||
Else
|
||||
MsgLog.AppendLine("json:" & json)
|
||||
TieneError = True
|
||||
End If
|
||||
End Using
|
||||
@@ -362,7 +363,7 @@ Public Class E119 : Implements IHttpHandler
|
||||
|
||||
MsgLog.AppendLine("1.1 accedido")
|
||||
If TieneError Then
|
||||
RespuestaError.message = "No se pudo procesar la solicitud - Formato mal formado"
|
||||
RespuestaError.message = "No se pudo procesar la solicitud - Formato mal formado (1.1)"
|
||||
context.Response.StatusCode = 200
|
||||
Return JsonConvert.SerializeObject(RespuestaError)
|
||||
End If
|
||||
@@ -378,6 +379,7 @@ Public Class E119 : Implements IHttpHandler
|
||||
Dim ObjInventario As New ClsInventarios(ObjClientes.IniciaTransacSQL())
|
||||
Dim CveSubProyecto, CveCliente, CveMoneda, CvePS As Integer
|
||||
Dim Cantidad, PU, Descuento As Decimal
|
||||
Dim CveDireccionEnvio As Integer = 0
|
||||
Dim Obs As String = ""
|
||||
CveSubProyecto = 12659 ' fijo Ecommerce
|
||||
CveCliente = 0
|
||||
@@ -387,8 +389,8 @@ Public Class E119 : Implements IHttpHandler
|
||||
Dim RFC As String = ""
|
||||
Dim NombreCliente As String = ""
|
||||
If JsonRequest("billing") IsNot Nothing Then
|
||||
RFC = JsonRequest("billing").First("first_name").ToString()
|
||||
NombreCliente = JsonRequest("billing").First("first_name").ToString() & " " & JsonRequest("billing").First("last_name").ToString()
|
||||
RFC = JsonRequest("billing")("first_name").ToString()
|
||||
NombreCliente = JsonRequest("billing")("first_name").ToString() & " " & JsonRequest("billing")("last_name").ToString()
|
||||
End If
|
||||
|
||||
'BUSCAR SI ESTÁ REGISTRADO EL CLIENTE
|
||||
@@ -406,16 +408,16 @@ Public Class E119 : Implements IHttpHandler
|
||||
MsgLog.AppendLine("1.5 crear cliente")
|
||||
If JsonRequest("billing") IsNot Nothing Then
|
||||
Dim CveEstado As Integer = -1
|
||||
Dim Direccion As String = If(JsonRequest("billing").First("address_1") Is Nothing, "", JsonRequest("billing").First("address_1").ToString())
|
||||
Dim Direccion As String = If(JsonRequest("billing")("address_1") Is Nothing, "", JsonRequest("billing")("address_1").ToString())
|
||||
Dim NumExt As String = ""
|
||||
Dim NumInt As String = ""
|
||||
Dim Colonia As String = ""
|
||||
Dim Ciudad As String = If(JsonRequest("billing").First("city") Is Nothing, "", JsonRequest("billing").First("city").ToString())
|
||||
Dim Localidad As String = If(JsonRequest("billing").First("city") Is Nothing, "", JsonRequest("billing").First("city").ToString())
|
||||
Dim CP As String = If(JsonRequest("billing").First("postcode") Is Nothing, "", JsonRequest("billing").First("postcode").ToString())
|
||||
Dim Telefono As String = If(JsonRequest("billing").First("phone") Is Nothing, "", JsonRequest("billing").First("phone").ToString())
|
||||
Dim Correo As String = If(JsonRequest("billing").First("email") Is Nothing, "", JsonRequest("billing").First("email").ToString())
|
||||
Dim Estado As String = If(JsonRequest("billing").First("state") Is Nothing, "", JsonRequest("billing").First("state").ToString())
|
||||
Dim Ciudad As String = If(JsonRequest("billing")("city") Is Nothing, "", JsonRequest("billing")("city").ToString())
|
||||
Dim Localidad As String = If(JsonRequest("billing")("city") Is Nothing, "", JsonRequest("billing")("city").ToString())
|
||||
Dim CP As String = If(JsonRequest("billing")("postcode") Is Nothing, "", JsonRequest("billing")("postcode").ToString())
|
||||
Dim Telefono As String = If(JsonRequest("billing")("phone") Is Nothing, "", JsonRequest("billing")("phone").ToString())
|
||||
Dim Correo As String = If(JsonRequest("billing")("email") Is Nothing, "", JsonRequest("billing")("email").ToString())
|
||||
Dim Estado As String = If(JsonRequest("billing")("state") Is Nothing, "", JsonRequest("billing")("state").ToString())
|
||||
If Not String.IsNullOrEmpty(Estado) Then
|
||||
CveEstado = ClsPaginas.GlobalDTGralEstados("MEX").FiltroPrimeroValor("CveEstado", $"NombreEstado = '{Estado.Trim}'").ToEntero()
|
||||
If CveEstado <= 0 Then 'SI NO ENCUENTRA EL ESTADO INGRESA EL DE SONORA
|
||||
@@ -437,13 +439,58 @@ Public Class E119 : Implements IHttpHandler
|
||||
End If
|
||||
|
||||
End If
|
||||
' shiping
|
||||
'shiping_lines/ method_id: free_shipping/local_pickup
|
||||
If JsonRequest("shipping") IsNot Nothing AndAlso Not TieneError Then
|
||||
Dim CveEstado As Integer = -1
|
||||
Dim Direccion As String = If(JsonRequest("shipping")("address_1") Is Nothing, "", JsonRequest("shipping")("address_1").ToString())
|
||||
Dim NumExt As String = ""
|
||||
Dim NumInt As String = ""
|
||||
Dim Colonia As String = ""
|
||||
Dim Ciudad As String = If(JsonRequest("shipping")("city") Is Nothing, "", JsonRequest("shipping")("city").ToString())
|
||||
Dim Localidad As String = If(JsonRequest("shipping")("city") Is Nothing, "", JsonRequest("shipping")("city").ToString())
|
||||
Dim CP As String = If(JsonRequest("shipping")("postcode") Is Nothing, "", JsonRequest("shipping")("postcode").ToString())
|
||||
Dim Telefono As String = If(JsonRequest("shipping")("phone") Is Nothing, "", JsonRequest("shipping")("phone").ToString())
|
||||
Dim Correo As String = If(JsonRequest("shipping")("email") Is Nothing, "", JsonRequest("shipping")("email").ToString())
|
||||
Dim Estado As String = If(JsonRequest("shipping")("state") Is Nothing, "", JsonRequest("shipping")("state").ToString())
|
||||
If Not String.IsNullOrEmpty(Estado) Then
|
||||
CveEstado = ClsPaginas.GlobalDTGralEstados("MEX").FiltroPrimeroValor("CveEstado", $"NombreEstado = '{Estado.Trim}'").ToEntero()
|
||||
If CveEstado <= 0 Then 'SI NO ENCUENTRA EL ESTADO INGRESA EL DE SONORA
|
||||
CveEstado = 26
|
||||
End If
|
||||
Else
|
||||
CveEstado = 26
|
||||
End If
|
||||
|
||||
If ObjClientes.DireccionEnvioGet(-1, CveCliente, -1) Then
|
||||
Dim dtt As DataTable = ObjClientes.DtResultados
|
||||
If dtt IsNot Nothing AndAlso dtt.Rows.Count > 0 Then
|
||||
dtt = dtt.FiltraParametros($"EnvioDireccion = '{Direccion}' and EnvioCP = '{CP}'")
|
||||
If dtt.Rows.Count > 0 Then
|
||||
CveDireccionEnvio = dtt.FiltroPrimeroValor("CveDireccionEnvio").ToEntero
|
||||
End If
|
||||
Else
|
||||
CveDireccionEnvio = ObjClientes.DireccionEnvioAdd(CveCliente, Direccion, NumExt, NumInt, Colonia, Ciudad, Estado, CP, "", 100, 1)
|
||||
End If
|
||||
End If
|
||||
|
||||
Else
|
||||
MsgLog.AppendLine("1.5.9 sin datos cliente")
|
||||
TieneError = True
|
||||
Resp.Mensajes.Add("no existen datos del cliente")
|
||||
End If
|
||||
|
||||
MsgLog.AppendLine("1.6 inicio generar venta")
|
||||
ObjFactura = Modelos.Factura.CrearVentaNueva(Usuario, CveSubProyecto, CveCliente, CveMoneda, "Rem")
|
||||
MsgLog.AppendFormat("1.6.0 objeto creado {0}", If(ObjFactura IsNot Nothing, "si", "no"))
|
||||
|
||||
If JsonRequest("shiping_lines") IsNot Nothing Then
|
||||
' shiping
|
||||
'shiping_lines/ method_id: free_shipping/local_pickup
|
||||
Dim Entrega As String = If(JsonRequest("shiping_lines")("method_id") Is Nothing, "", JsonRequest("shiping_lines")("method_id").ToString())
|
||||
ObjFactura.Alfa1 = Entrega
|
||||
End If
|
||||
|
||||
ObjFactura.CveDireccionEnvio = cvedireccionenvio
|
||||
|
||||
If JsonRequest("line_items") IsNot Nothing Then
|
||||
Dim ListaPS As JArray = JArray.Parse(JsonRequest("line_items").ToString())
|
||||
Dim Consec As Integer = 1
|
||||
@@ -470,6 +517,7 @@ Public Class E119 : Implements IHttpHandler
|
||||
Resp.Mensajes.Add("no existen productos definidos")
|
||||
End If
|
||||
|
||||
|
||||
If ObjFactura IsNot Nothing AndAlso Not TieneError Then
|
||||
MsgLog.AppendLine("1.7 agregar la remision")
|
||||
Resp = ObjFactura.EmitirFactura(False, Transac:=ObjClientes.IniciaTransacSQL())
|
||||
@@ -528,9 +576,10 @@ Public Class E119 : Implements IHttpHandler
|
||||
|
||||
Catch ex As Exception
|
||||
TieneError = True
|
||||
Finally
|
||||
MsgLog.ToString.GuardaLogAD("LogE119")
|
||||
End Try
|
||||
|
||||
MsgLog.ToString.GuardaLogAD("LogE119")
|
||||
If TieneError Then
|
||||
context.Response.StatusCode = 200
|
||||
Return JsonConvert.SerializeObject(RespuestaError)
|
||||
|
||||
Reference in New Issue
Block a user