コード例 #1
0
        /// <summary>
        /// 执行回调
        /// </summary>
        /// <param name="backModel">回调参数</param>
        /// <param name="url">回调地址</param>
        /// <param name="tryNum">尝试次数</param>
        /// <returns>回调结果</returns>
        private int ExceCallBack(CallBackViewModel backModel, string url, int tryNum)
        {
            var           status  = 0;
            StringBuilder sbQuest = new StringBuilder();
            Type          t       = backModel.GetType();

            foreach (PropertyInfo pi in t.GetProperties())
            {
                var fieldName = pi.Name;
                if (!fieldName.ToLower().Equals("sign") && !fieldName.ToLower().Equals("key"))
                {
                    var fieldValue = pi.GetValue(backModel, null);
                    if (fieldValue != null)
                    {
                        sbQuest.AppendFormat("{0}={1}&", fieldName, fieldValue);
                    }
                }
            }
            var parms = sbQuest.ToString().TrimEnd('&');
            var sign  = CommonUtil.GetMD5Sign(backModel.key, parms);

            LogUtil.Info(string.Format("第{0}次尝试回调,请求地址:{1},sign={2}。", tryNum, (url + "?" + parms), sign));
            var result = NetUtil.ResponseByPost(url, string.Format("{0}&sign={1}", parms, sign));

            if (!string.IsNullOrWhiteSpace(result))
            {
                //将回调结果存储到数据库
                SingleInstance <PrintOrderService> .Instance.RecordCallBack(backModel.bill_no, backModel.order_id, backModel.printer_code, int.Parse(backModel.result_code));

                var apiModel = JsonConvert.DeserializeObject <ApiResultInfo>(result);
                status = apiModel.status;
            }
            return(status);
        }
コード例 #2
0
        public ActionResult Reschedule()
        {
            CallBackViewModel cvm   = new CallBackViewModel();
            IList <Lead>      leads = new List <Lead>();

            //To display the username on top right
            var username = HttpContext.User.Identity.Name;

            cvm.user = _UserRepository.GetUserByUsername(username);


            //Get  reschedule results
            var rescheduleresults = GetRescheduleAppointments();


            // From all these leads find ones which were assigned to this guy
            //if (cvm.user.AssignedRoleId == 4)
            //{

            foreach (var res in rescheduleresults)
            {
                if (res.CreatorId == cvm.user.UserId)
                {
                    var lead = _leadRepos.LeadByLeadID(res.ParentLeadId);
                    lead.CardType     = "Reschedule";
                    lead.CallbackDate = res.CreatedAt;
                    leads.Add(lead);
                }
                else
                {
                    //do nothing
                }
            }

            //}
            //else if (cvm.user.AssignedRoleId == 3)
            //{

            //    foreach (var res in rescheduleresults)
            //    {
            //        if (res.CreatorId == cvm.user.UserId)
            //        {
            //            var lead = _leadRepos.LeadByLeadID(res.ParentLeadId);
            //            lead.CardType = "Reschedule";
            //            lead.CallbackDate = res.CreatedAt;
            //            leads.Add(lead);
            //        }
            //        else
            //        {
            //            //do nothing
            //        }
            //    }
            //}

            cvm.Leads = leads;

            return(View(cvm));
        }
コード例 #3
0
        /// <summary>
        /// 设备回调
        /// </summary>
        /// <param name="statusCode">状态码</param>
        /// <param name="printerCode">打印设备编码</param>
        /// <param name="faultTime">异常时间</param>
        public void DeviceCallBack(int statusCode, string printerCode, DateTime faultTime)
        {
            LogUtil.Info(string.Format("打印设备回调:发送设备状态通知,设备号:{0},状态码: {1},故障时间:{2}", printerCode, statusCode, faultTime));

            //获取设备所属应用信息
            McpApplicationInfo app = null;
            var cc = new ConditionCollection();

            cc.Add(new Condition("printer_code", printerCode));
            var deviceApps = this.GetRepository <McpMerchantPrinterInfo>().ListModel(cc);
            var apps       = GetApplicationList();

            if (deviceApps != null && deviceApps.Count > 0)
            {
                foreach (var devApp in deviceApps)
                {
                    //执行回调更新第三方应用数据状态
                    app = apps.Find(d => d.AppId.Equals(devApp.AppId, StringComparison.CurrentCultureIgnoreCase));
                    if (app != null && !string.IsNullOrWhiteSpace(app.AuthCallbackUrl))
                    {
                        var callbackModel = new CallBackViewModel()
                        {
                            printer_code = printerCode,
                            result_code  = statusCode.ToString(),
                            fault_time   = faultTime.ToString(RegexConsts.DATETIME_FORMAT),
                            key          = app.SignKey
                        };
                        int status = 0, tryNum = 1;
                        try
                        {
                            status = ExceCallBack(callbackModel, app.AuthCallbackUrl, tryNum);
                            if (status != 1)
                            {
                                System.Threading.Thread.Sleep(delayTryInterval);
                                if (tryNum <= tryMax)
                                {
                                    status = ExceCallBack(callbackModel, app.AuthCallbackUrl, ++tryNum);
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            LogUtil.Error(ex.Message);
                            System.Threading.Thread.Sleep(delayTryInterval);
                            if (tryNum <= tryMax)
                            {
                                status = ExceCallBack(callbackModel, app.AuthCallbackUrl, ++tryNum);
                            }
                            else
                            {
                                throw new MessageException(ex.Message);
                            }
                        }
                    }
                }
            }
        }
コード例 #4
0
        public async Task <IActionResult> Contacts(CallBackViewModel model)
        {
            if (ModelState.IsValid)
            {
                await _unitOfWork.CallBack.Add(model.CallBack);

                _unitOfWork.Save();
            }
            return(RedirectToAction("CallBackCompleted"));
        }
コード例 #5
0
        public async Task <IActionResult> GetModel([FromBody] CallBackViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            logger.LogInformation("Получена форма на запрос Перезвонить {@Model}", model);

            var res = await logic.CreateRecallTask(model.Adapt <CallBackDTO>());

            if (!res)
            {
                return(StatusCode(500));
            }

            return(Ok());
        }
コード例 #6
0
        public ActionResult CallBackFree(string code)
        {
            CallBackViewModel callBack = new CallBackViewModel();



            try
            {
                callBack.IsSuccess = true;
                callBack.OrderCode = code;
            }
            catch (Exception e)
            {
                callBack.IsSuccess  = false;
                callBack.RefrenceId = "خطا سیستمی. لطفا با پشتیبانی سایت تماس بگیرید";
            }

            return(View(callBack));
        }
コード例 #7
0
        public ActionResult CallBack()
        {
            CallBackViewModel cvm      = new CallBackViewModel();
            IList <Lead>      leads    = new List <Lead>();
            IList <Lead>      newleads = new List <Lead>();

            IList <Lead> reassignedLeads    = new List <Lead>();
            IList <Lead> newreassignedLeads = new List <Lead>();


            //To display the username on top right
            var username = HttpContext.User.Identity.Name;

            cvm.user = _UserRepository.GetUserByUsername(username);


            //Get the callback results
            var callbackresults = GetCallBackLeads();

            //Get all other Leads who had a last card type as either DNC, Wrong# LeftVm, No Interest, Not Lead
            var wrongresult    = GetWrongNumberLeads();
            var dncresults     = GetDNCLeads();
            var leftvmresults  = GetLeftVMResults();
            var nointresults   = GetNoInterestLeads();
            var notleadresults = GetNotLeadLeads();

            /////////////////////////////////////////////////////////////////////
            foreach (var res in wrongresult)
            {
                reassignedLeads.Add(res);
            }
            foreach (var res in dncresults)
            {
                reassignedLeads.Add(res);
            }
            foreach (var res in leftvmresults)
            {
                reassignedLeads.Add(res);
            }
            foreach (var res in nointresults)
            {
                reassignedLeads.Add(res);
            }
            foreach (var res in notleadresults)
            {
                reassignedLeads.Add(res);
            }
            //////////////////////////////////////////////////////////////////////


            // From all these leads find ones which were assigned to this guy
            //if (cvm.user.AssignedRoleId == 4)
            //{
            foreach (var result in reassignedLeads)
            {
                if (result.AssignedAAUserId == cvm.user.UserId)
                {
                    result.CardType = "Reassigned";
                    newreassignedLeads.Add(result);
                }
                else
                {
                    //do nothing
                }
            }
            leads = newreassignedLeads;

            foreach (var result in callbackresults)
            {
                if (result.AssignedAAUserId == cvm.user.UserId)
                {
                    result.CardType = "Call Back";
                    leads.Add(result);
                }
                else
                {
                    //do nothing
                }
            }


            //}
            //else if (cvm.user.AssignedRoleId == 3)
            //{
            //    foreach (var result in reassignedLeads)
            //    {
            //        if (result.AssignedSAUserId == cvm.user.UserId)
            //        {
            //            result.CardType = "Reassigned";
            //            newreassignedLeads.Add(result);
            //        }
            //        else
            //        {
            //            //do nothing
            //        }
            //    }
            //    leads = newreassignedLeads;

            //    foreach (var result in callbackresults)
            //    {
            //        if (result.AssignedSAUserId == cvm.user.UserId)
            //        {
            //            result.CardType = "Call Back";
            //            leads.Add(result);
            //        }
            //        else
            //        {
            //            //do nothing
            //        }
            //    }

            //}

            cvm.Leads = leads;

            return(View(cvm));
        }
コード例 #8
0
        public ActionResult CallBack(string authority, string status)
        {
            String            Status   = status;
            CallBackViewModel callBack = new CallBackViewModel()
            {
            };

            if (Status != "OK")
            {
                callBack.IsSuccess = false;
            }

            else
            {
                try
                {
                    string merchantId = db.ShopConfigurations.FirstOrDefault(c => c.Name == "zarinpal").Value;

                    var zarinpal = ZarinPal.ZarinPal.Get();
                    zarinpal.EnableSandboxMode();
                    String Authority = authority;
                    long   Amount    = GetAmountByAuthority(Authority);

                    var verificationRequest  = new ZarinPal.PaymentVerification(merchantId, Amount, Authority);
                    var verificationResponse = zarinpal.InvokePaymentVerification(verificationRequest);
                    if (verificationResponse.Status == 100)
                    {
                        Order order = GetOrderByAuthority(authority);
                        if (order != null)
                        {
                            order.IsPaid           = true;
                            order.PaymentDate      = DateTime.Now;
                            order.RefId            = verificationResponse.RefID;
                            order.LastModifiedDate = DateTime.Now;

                            db.SaveChanges();

                            callBack.IsSuccess   = true;
                            callBack.OrderCode   = order.Code.ToString();
                            callBack.RefrenceId  = verificationResponse.RefID;
                            callBack.TotalAmount = order.TotalAmount.ToString("N0") + " تومان";
                            // UpdateUserPoint(order);
                        }
                        else
                        {
                            callBack.IsSuccess  = false;
                            callBack.RefrenceId = "سفارش پیدا نشد";
                        }
                    }
                    else
                    {
                        callBack.IsSuccess  = false;
                        callBack.RefrenceId = verificationResponse.Status.ToString();
                    }
                }
                catch (Exception e)
                {
                    callBack.IsSuccess  = false;
                    callBack.RefrenceId = "خطا سیستمی. لطفا با پشتیبانی سایت تماس بگیرید";
                }
            }
            return(View(callBack));
        }
コード例 #9
0
        public ActionResult CallBack(string authority, string status)
        {
            String            Status   = status;
            CallBackViewModel callBack = new CallBackViewModel();

            if (Status != "OK")
            {
                callBack.IsSuccess  = false;
                callBack.RefrenceId = "414";
                Order order = GetOrderByAuthority(authority);
                if (order != null)
                {
                    callBack.Order        = order;
                    callBack.OrderDetails = db.OrderDetails
                                            .Where(c => c.OrderId == order.Id && c.IsDeleted == false).Include(c => c.Product).ToList();
                }
            }

            else
            {
                try
                {
                    var zarinpal = ZarinPal.ZarinPal.Get();
                    zarinpal.EnableSandboxMode();
                    String Authority = authority;
                    long   Amount    = GetAmountByAuthority(Authority);

                    var verificationRequest  = new ZarinPal.PaymentVerification(MerchantId, Amount, Authority);
                    var verificationResponse = zarinpal.InvokePaymentVerification(verificationRequest);
                    if (verificationResponse.Status == 100 || verificationResponse.Status == 101)
                    {
                        Order order = GetOrderByAuthority(authority);
                        if (order != null)
                        {
                            order.IsPaid      = true;
                            order.PaymentDate = DateTime.Now;
                            order.RefId       = verificationResponse.RefID;

                            db.SaveChanges();
                            callBack.Order      = order;
                            callBack.IsSuccess  = true;
                            callBack.OrderCode  = order.Code.ToString();
                            callBack.RefrenceId = verificationResponse.RefID;

                            callBack.OrderDetails = db.OrderDetails
                                                    .Where(c => c.OrderId == order.Id && c.IsDeleted == false).Include(c => c.Product).ToList();
                            foreach (OrderDetail orderDetail in callBack.OrderDetails)
                            {
                                Product product = orderDetail.Product;
                                product.Quantity = orderDetail.Product.Quantity - 1;

                                if (product.Quantity == 0)
                                {
                                    product.IsAvailable = false;
                                }
                                db.SaveChanges();
                            }
                        }
                        else
                        {
                            callBack.IsSuccess  = false;
                            callBack.RefrenceId = "سفارش پیدا نشد";
                        }
                    }
                    else
                    {
                        callBack.IsSuccess  = false;
                        callBack.RefrenceId = verificationResponse.Status.ToString();
                    }
                }
                catch (Exception e)
                {
                    callBack.IsSuccess  = false;
                    callBack.RefrenceId = "خطا سیستمی. لطفا با پشتیبانی سایت تماس بگیرید";
                }
            }
            ViewBag.HeaderImage = db.Texts.Where(x => x.TextType.Name == "returnfrombank").FirstOrDefault().ImageUrl;

            return(View(callBack));
        }
コード例 #10
0
        /// <summary>
        /// 打印任务状态回调
        /// </summary>
        /// <param name="resultCode">状态码</param>
        /// <param name="orderId">订单编号</param>
        /// <param name="printerCodes">打印设备编码</param>
        public void AppCallBack(int resultCode, string orderId, string printerCodes = "")
        {
            //判断,有些状态不用回调,例如断网
            int[] printStatueCode = { 1, 3, 4, 6, 7 };
            if (!printStatueCode.Contains(resultCode))
            {
                LogUtil.Info($"跳过回调:该状态不回调-{resultCode},订单-{orderId}");
                return;
            }
            LogUtil.Info(string.Format("开始执行打印任务回调,设备号:{0},订单号:{1},状态: {2}", printerCodes, orderId, resultCode));
            //获取打印订单信息
            var cc = new ConditionCollection();

            cc.Add(new Condition("order_id", orderId));
            var order = this.GetRepository <McpOrderInfo>().GetModel(cc);

            if (order != null)
            {
                //获取订单所属应用信息
                var c1 = new ConditionCollection();
                c1.Add(new Condition("app_id", order.AppId));
                var app = this.GetRepository <McpApplicationInfo>().GetModel(c1);
                if (app != null)
                {
                    //执行回调更新第三方应用数据状态
                    if (!string.IsNullOrWhiteSpace(app.UpdateCallbackUrl))
                    {
                        if (string.IsNullOrWhiteSpace(printerCodes))
                        {
                            var c2 = new ConditionCollection();
                            c2.Add(new Condition("order_id", order.OrderId));
                            var           printers  = this.GetRepository <McpOrderPrinterInfo>().ListModel(c2);
                            StringBuilder sbPrinter = new StringBuilder();
                            if (printers != null)
                            {
                                printers.ForEach(d => sbPrinter.AppendFormat("{0},", d.PrinterCode));
                                printerCodes = sbPrinter.ToString().TrimEnd(',');
                            }
                        }
                        var callbackModel = new CallBackViewModel()
                        {
                            bill_no      = order.BillNo,
                            printer_code = printerCodes,
                            result_code  = resultCode.ToString(),
                            key          = app.SignKey,
                            order_id     = orderId
                        };
                        int status = 0, tryNum = 1;
                        try
                        {
                            status = ExceCallBack(callbackModel, app.UpdateCallbackUrl, tryNum);
                            if (status != 1)
                            {
                                System.Threading.Thread.Sleep(delayTryInterval);
                                if (tryNum <= tryMax)
                                {
                                    status = ExceCallBack(callbackModel, app.UpdateCallbackUrl, ++tryNum);
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            LogUtil.Error(ex.Message);
                            System.Threading.Thread.Sleep(delayTryInterval);
                            if (tryNum <= tryMax)
                            {
                                status = ExceCallBack(callbackModel, app.UpdateCallbackUrl, ++tryNum);
                            }
                            else
                            {
                                throw new MessageException(ex.Message);
                            }
                        }

                        //更新回调标识
                        if (status > 0)
                        {
                            order.CallbackStatus = status;
                            order.ModifiedOn     = CommonUtil.GetDBDateTime();
                            this.GetRepository <McpOrderInfo>().Update(order, "callback_status,modified_on");
                        }
                    }
                }
            }
        }
コード例 #11
0
        public ActionResult CallBack(string authority, string status)
        {
            String            Status   = status;
            CallBackViewModel callBack = new CallBackViewModel()
            {
                Menu       = menuHelper.ReturnMenu(),
                FooterLink = menuHelper.GetFooterLink()
            };

            if (Status != "OK")
            {
                callBack.IsSuccess = false;
            }

            else
            {
                try
                {
                    var zarinpal = ZarinPal.ZarinPal.Get();
                    zarinpal.DisableSandboxMode();
                    String Authority = authority;
                    long   Amount    = GetAmountByAuthority(Authority);

                    var verificationRequest  = new ZarinPal.PaymentVerification(MerchantId, Amount, Authority);
                    var verificationResponse = zarinpal.InvokePaymentVerification(verificationRequest);
                    if (verificationResponse.Status == 100 || verificationResponse.Status == 101)
                    {
                        Order order = GetOrderByAuthority(authority);
                        if (order != null)
                        {
                            order.IsPaid      = true;
                            order.PaymentDate = DateTime.Now;
                            order.RefId       = verificationResponse.RefID;

                            db.SaveChanges();

                            callBack.IsSuccess  = true;
                            callBack.OrderCode  = order.Code.ToString();
                            callBack.RefrenceId = verificationResponse.RefID;

                            // UpdateUserPoint(order);

                            OrderDetail orderDetail = db.OrderDetails.FirstOrDefault(current => current.OrderId == order.Id);

                            if (orderDetail != null)
                            {
                                Product product = db.Products.Find(orderDetail.ProductId);

                                if (product != null)
                                {
                                    User   user    = db.Users.Find(order.UserId);
                                    string message = "سفارش شما با شماره پیگیری " + callBack.RefrenceId + " در وب سایت راش وب ثبت گردید ";
                                    SendSms.SendCommonSms(user.CellNum, message);
                                    List <User> admins = db.Users.Where(current => current.IsActive && !current.IsDeleted && current.Role.Name == "Administrator").ToList();
                                    foreach (User admin in admins)
                                    {
                                        message = "یک سفارش با کد " + order.Code + " در وب سایت راش وب ثبت شده است.";
                                        SendSms.SendCommonSms(admin.CellNum, message);
                                    }
                                    //ViewBag.Email = order.DeliverEmail;

                                    //CreateEmail(order.Email, fileLink, orderType);
                                }
                            }
                        }
                        else
                        {
                            callBack.IsSuccess  = false;
                            callBack.RefrenceId = "سفارش پیدا نشد";
                        }
                    }
                    else
                    {
                        callBack.IsSuccess  = false;
                        callBack.RefrenceId = verificationResponse.Status.ToString();
                    }
                }
                catch (Exception e)
                {
                    callBack.IsSuccess  = false;
                    callBack.RefrenceId = "خطا سیستمی. لطفا با پشتیبانی سایت تماس بگیرید";
                }
            }
            return(View(callBack));
        }
コード例 #12
0
        public ActionResult CallBack(string authority, string status)
        {
            String            Status   = status;
            CallBackViewModel callBack = new CallBackViewModel();

            callBack.MenuProductGroups = baseViewModel.GetMenu();
            callBack.MenuServiceGroups = baseViewModel.GetMenuServices();
            callBack.FooterRecentBlog  = baseViewModel.GetFooterRecentBlog();
            Deletecookie();

            if (Status != "OK")
            {
                callBack.IsSuccess = false;
            }

            else
            {
                try
                {
                    var zarinpal = ZarinPal.ZarinPal.Get();
                    // zarinpal.DisableSandboxMode();
                    zarinpal.DisableSandboxMode();
                    String Authority = authority;
                    long   Amount    = GetAmountByAuthority(Authority);

                    var verificationRequest  = new ZarinPal.PaymentVerification(MerchantId, Amount, Authority);
                    var verificationResponse = zarinpal.InvokePaymentVerification(verificationRequest);
                    if (verificationResponse.Status == 100)
                    {
                        Order order = GetOrderByAuthority(authority);
                        if (order != null)
                        {
                            order.IsPaid          = true;
                            order.PaymentDate     = DateTime.Now;
                            order.SaleReferenceId = verificationResponse.RefID;
                            order.OrderStatusId   = db.OrderStatuses.FirstOrDefault(current => current.Code == 1).Id;

                            db.SaveChanges();
                            List <Product> products = RetrunProducts(order.Id);
                            callBack.IsSuccess    = true;
                            callBack.OrderCode    = order.Code.ToString();
                            callBack.RefrenceId   = verificationResponse.RefID;
                            callBack.Products     = products;
                            callBack.CreationDate = order.CreationDateStr;

                            String onlineConsult = WebConfigurationManager.AppSettings["online-consult"];
                            string productType   = products.FirstOrDefault()?.ProductGroup.UrlParam;
                            callBack.ProductType = productType;


                            if (productType == onlineConsult)
                            {
                                UpdateQuestionOrderId(order.Id);
                            }
                            CreateSucessMessage("", order.User.CellNum, order.User.FullName);
                        }
                        else
                        {
                            callBack.IsSuccess  = false;
                            callBack.RefrenceId = "سفارش پیدا نشد";
                            callBack.Products   = null;
                        }
                    }
                    else
                    {
                        callBack.IsSuccess  = false;
                        callBack.RefrenceId = verificationResponse.Status.ToString();
                        callBack.Products   = null;
                    }
                }
                catch (Exception e)
                {
                    callBack.IsSuccess  = false;
                    callBack.RefrenceId = "خطا سیستمی. لطفا با پشتیبانی سایت تماس بگیرید";
                    callBack.Products   = null;
                }
            }
            return(View(callBack));
        }