Example #1
0
 public void GerarPlanilhas(string strPath, string emailEnvioRede, string emailEnvioCielo, string emailEnvioValeCultura,
                            string emailEnvioEloCultura, string emailEnvioAmex, string emailEnvioPlanilhasManuais)
 {
     //PlanilhasEstornosManuais.GeraPlanilhaEstornosManuais(strPath, emailEnvioPlanilhasManuais);
     Rede.GeraPlanilhaRede(strPath, emailEnvioRede);
     Cielo.GeraPlanilhaCielo(strPath, emailEnvioCielo);
     ValeCultura.GeraPlanilhaValeCultura(strPath, emailEnvioValeCultura, "Vale Cultura");
     ValeCultura.GeraPlanilhaValeCultura(strPath, emailEnvioEloCultura, "Elo Cultura");
     Amex.GeraPlanilhaAmexAVista(strPath, emailEnvioAmex);
     AmexParcelado.GeraPlanilhaAmexParcelado(strPath, emailEnvioAmex);
 }
Example #2
0
        public static List <AmexParcelado> getEstornosAmexParcelado()
        {
            DateTime dt = System.DateTime.Now;
            BD       bd = new BD();

            StringBuilder str = new StringBuilder();

            str.Append("SELECT est.ID, est.Cartao, b.Nome, vbfp.NSUHost, vbfp.NSUSitef, vbfp.NumeroAutorizacao, vb.DataVenda, ");
            str.Append("vb.Senha AS SenhaVenda, SUBSTRING(vbfp.CodigoIR, 2, 10) AS CodigoIR, c.CanalTipoID, ");
            str.Append("vbfp.Valor, fp.Parcelas, fp.Nome ,fp.Tipo, fpt.Nome, c.NroEstabelecimentoAmex, vb.id as VendaBilheteriaID ");
            str.Append("FROM EstornoDadosCartaoCredito est (NOLOCK) ");
            str.Append("inner join tVendaBilheteria vb (nolock) on vb.ID = est.VendaBilheteriaIDvenda ");
            str.Append("inner join tVendaBilheteriaFormaPagamento vbfp (nolock) on vbfp.VendaBilheteriaID = vb.ID ");
            str.Append("inner join tFormaPagamento fp (nolock) on fp.ID = vbfp.FormaPagamentoID ");
            str.Append("inner join tFormaPagamentoTipo fpt (nolock) on fp.FormaPagamentoTipoID = fpt.ID ");
            str.Append("inner join tBandeira b (nolock) on fp.BandeiraID = b.ID ");
            str.Append("inner join tCancelDevolucaoPendente cdp (NOLOCK) on cdp.VendaBilheteriaIDCancel = est.VendaBilheteriaIDcancel ");
            str.Append("inner join tCanal c (nolock) on c.ID = cdp.CanalID ");
            //str.Append("WHERE est.PlanilhaGerada IN (0,1) AND est.Status IN ('O', 'P', 'W') ");
            str.Append("WHERE est.PlanilhaGerada = 0  AND est.Status IN('P', 'W') ");
            str.Append("AND b.Nome IN ('American Express') AND fp.Parcelas > 1 ");
            //str.Append("AND (vbfp.NSUHost <> 0 OR vbfp.NSUSitef <> 0) ");

            List <AmexParcelado> lstAmexParcelado = new List <AmexParcelado>();

            bd.Consulta(str.ToString());

            VendaBilheteriaItem vbi = new VendaBilheteriaItem();

            while (bd.Consulta().Read())
            {
                AmexParcelado amexParc = new AmexParcelado();
                //amexParc.ID = bd.LerInt("ID");
                //amexParc.Estabelecimento = bd.LerString("NroEstabelecimentoAmex"); //"9061745055";//Valor default por enquanto

                string NSU       = "";
                int    CanalTipo = bd.LerInt("CanalTipoID");
                int    VendaID   = bd.LerInt("VendaBilheteriaID");

                //Amex amex = new Amex();

                if (CanalTipo == 1 || CanalTipo == 2)
                {
                    IRLib.ClientObjects.EstruturaPagamento.enumTipoPagamento TipoPagamento;

                    TipoPagamento = vbi.TipoPagamentoBilheteria(VendaID);

                    amexParc.ID = bd.LerInt("ID");

                    switch (TipoPagamento)
                    {
                    case IRLib.ClientObjects.EstruturaPagamento.enumTipoPagamento.TEF:
                        amexParc.Estabelecimento = "9061745048";    //Valor default para compras via TEF
                        break;

                    case IRLib.ClientObjects.EstruturaPagamento.enumTipoPagamento.Adyen:
                        amexParc.Estabelecimento = "9061745055";    //Valor default para compras via Adyen
                        break;

                    default:
                        amexParc.Estabelecimento = "";    //Valor default
                        break;
                    }
                }
                else
                {
                    amexParc.Estabelecimento = GetCodigoIR(bd.LerString("CodigoIR")); //bd.LerString("NroEstabelecimentoAmex");//"1037983464";//Valor default por enquanto
                }
                amexParc.NumeroCartao = bd.LerString("Cartao");
                amexParc.DataVenda    = bd.LerStringFormatoData("DataVenda");
                //amex.NSU = bd.LerString("NSUSitef");

                NSU = bd.LerString("NSUSitef");// == "" ? getNSUConciliacao(VendaID) : bd.LerString("NSUHost");

                NSU = NSU == "" ? getNSUConciliacao(VendaID) : NSU;

                if (NSU == "" || NSU == "0")
                {
                    amexParc.Status = 'W';//Wait, aguardar inserir manualmente NSU e Autorização
                }
                else
                {
                    amexParc.NSU    = NSU;
                    amexParc.Status = 'R';//Ready, pronta para processar
                }

                //amexParc.NumeroCartao = bd.LerString("Cartao");
                //amexParc.DataVenda = bd.LerStringFormatoData("DataVenda");
                //amexParc.NSU = bd.LerString("NSUSitef");
                amexParc.Autorizacao   = bd.LerStringFormatoData("NumeroAutorizacao");
                amexParc.ValorVenda    = bd.LerString("Valor");;
                amexParc.ValorCancelar = bd.LerString("Valor");
                amexParc.SenhaVenda    = bd.LerString("SenhaVenda");

                lstAmexParcelado.Add(amexParc);
            }

            return(lstAmexParcelado);
        }
Example #3
0
        public static void GeraPlanilhaAmexParcelado(string strPath, string emailEnvio)
        {
            if (!Directory.Exists(strPath))
            {
                Directory.CreateDirectory(strPath);
            }

            string data        = System.DateTime.Now.ToString("yyyyMMddHHmmss");
            string arquivCopia = strPath + "Amex - Parcelado_" + data + ".xlsx";
            string nomeArquivo = "Amex - Parcelado_" + data + ".xlsx";

            ExcelPackage   package = new ExcelPackage();
            ExcelWorksheet ws      = package.Workbook.Worksheets.Add("Cancelamento");

            ws.Cells["A1"].Value = "ESTABELECIMENTO";
            ws.Cells["B1"].Value = "NÚMERO DO CARTÂO";
            ws.Cells["C1"].Value = "DT VENDA";
            ws.Cells["D1"].Value = "NSU";
            ws.Cells["E1"].Value = "AUTORIZAÇÃO";
            ws.Cells["F1"].Value = "VLR VENDA";
            ws.Cells["G1"].Value = "VLR CANCELAR";
            ws.Cells["H1"].Value = "SENHA VENDA";
            ////////////////////////////////////////////////////////////////////////////////////////////////////
            //int linha = 2;

            List <AmexParcelado> lstAmexParcelado = AmexParcelado.getEstornosAmexParcelado();

            if (lstAmexParcelado.Count > 0)
            {
                int linha = 2;
                foreach (AmexParcelado item in lstAmexParcelado)
                {
                    if (item.Status == 'R')
                    {
                        ws.Cells[linha, 1].Value = item.Estabelecimento;
                        ws.Cells[linha, 2].Value = item.NumeroCartao;
                        ws.Cells[linha, 3].Value = item.DataVenda;
                        ws.Cells[linha, 4].Value = item.NSU;
                        ws.Cells[linha, 5].Value = item.Autorizacao;
                        ws.Cells[linha, 6].Value = item.ValorVenda;
                        ws.Cells[linha, 7].Value = item.ValorCancelar;
                        ws.Cells[linha, 8].Value = item.SenhaVenda;
                        linha++;
                    }
                }
                ////////////////////////////////////////////////////////////////////////////////////////////////////
                ws.Cells.AutoFitColumns();

                FileInfo fi = new FileInfo(arquivCopia);
                package.SaveAs(fi);

                BinaryReader br = new BinaryReader(fi.OpenRead());

                foreach (AmexParcelado item in lstAmexParcelado)
                {
                    if (item.Status == 'R')
                    {
                        item.setPlanilhaGerada();
                    }

                    else if (item.Status == 'W')
                    {
                        item.setItemWait();
                    }
                }

                bool RegGerados = lstAmexParcelado.ToList().Count(t => t.Status.Equals('R')) > 0;

                if (RegGerados)
                {
                    string[] lstEmails = emailEnvio.Split(';');

                    byte[] arrAnexo = br.ReadBytes((int)fi.Length);

                    foreach (string email in lstEmails)
                    {
                        IRLib.Emails.Retorno retorno = GetInstance().
                                                       EnviarEmailCancelamentoEstornoOperadora(email, "Estorno Planilhas", arrAnexo, nomeArquivo);
                    }

                    InsertHistorico("Amex - Parcelado", arquivCopia, nomeArquivo, emailEnvio);
                }
            }
        }