示例#1
0
        /// <summary>
        /// 处理网银支付异步通知返回订单信息,执行扣量等操作,处理完毕会自动输出succflag或failflag给接口供应商平台
        /// </summary>
        /// <param name="supplierId"></param>
        /// <param name="orderId"></param>
        /// <param name="supplierOrderId"></param>
        /// <param name="status"></param>
        /// <param name="opstate"></param>
        /// <param name="msg"></param>
        /// <param name="tranAmt">结算金额</param>
        ///  <param name="suppSettleAmt">供应商给平台的费率</param>
        /// <param name="succflag"></param>
        /// <param name="failflag"></param>
        public static void SuppNotify(int supplierId, string orderId, string supplierOrderId, int status,
                                      string opstate, string msg, decimal tranAmt, decimal suppSettleAmt,
                                      string succflag, string failflag)
        {
            var execResult = new FunExecResult()
            {
                ErrCode = 0,
                ErrMsg  = ""
            };

            var orderInfo = Cache.WebCache.GetCacheService().RetrieveObject(orderId) as OrderBankInfo;

            if (orderInfo == null)
            {
                orderInfo = BLL.Order.Bank.Factory.Instance.GetModelByOrderId(orderId);
            }
            if (orderInfo != null)
            {
                bool insertToDb = orderInfo.status == 1;
                if (insertToDb)
                {
                    #region InsertToDb
                    orderInfo.status    = status;
                    orderInfo.realvalue = tranAmt;
                    orderInfo.msg       = msg;

                    execResult = InsertToDb(supplierId
                                            , orderInfo
                                            , supplierOrderId
                                            , status
                                            , opstate
                                            , msg, tranAmt, suppSettleAmt);

                    //Cache.WebCache.GetCacheService().RemoveObject(orderId);
                    #endregion
                }
                if (orderInfo.status != 1)
                {
                    APINotification.SynchronousNotifyX(orderInfo);
                }
            }

            if (execResult.ErrCode == 0)
            {
                if (!string.IsNullOrEmpty(succflag))
                {
                    System.Web.HttpContext.Current.Response.Write(succflag);
                }
            }
            else
            {
                if (!string.IsNullOrEmpty(failflag))
                {
                    System.Web.HttpContext.Current.Response.Write(failflag);
                }
            }
        }
示例#2
0
        public ActionResult ApproveRequisition(ApproveRequisitionViewModel viewmodel)
        {
            string            token = GetToken();
            UserModel         um    = GetUser();
            RequisitionModel  reqm  = new RequisitionModel();
            NotificationModel nom   = new NotificationModel();


            try
            {
                reqm            = APIRequisition.GetRequisitionByReqid(viewmodel.ReqID, token, out string error);
                reqm.Status     = ConRequisition.Status.APPROVED;
                reqm.Approvedby = um.Userid;
                if (!viewmodel.Approve)
                {
                    reqm.Status  = ConRequisition.Status.REJECTED;
                    nom.Deptid   = reqm.Depid;
                    nom.Role     = ConUser.Role.EMPLOYEE;
                    nom.Title    = "Requisition Rejected";
                    nom.NotiType = ConNotification.NotiType.RejectedRequistion;
                    nom.ResID    = reqm.Reqid;
                    nom.Remark   = "The new requisition has been rejected by the HOD with remark : " + viewmodel.Remark;
                    nom          = APINotification.CreateNoti(token, nom, out error);

                    nom.Deptid   = reqm.Depid;
                    nom.Role     = ConUser.Role.DEPARTMENTREP;
                    nom.Title    = "Requisition Rejected";
                    nom.NotiType = ConNotification.NotiType.RejectedRequistion;
                    nom.ResID    = reqm.Reqid;
                    nom.Remark   = "The new requisition has been rejected by the HOD with remark : " + viewmodel.Remark;
                    nom          = APINotification.CreateNoti(token, nom, out error);
                }

                reqm = APIRequisition.UpdateRequisition(reqm, token, out error);


                Session["noti"]     = true;
                Session["notitype"] = "success";

                if (viewmodel.Approve)
                {
                    Session["notititle"]   = "Requisition Approval";
                    Session["notimessage"] = "Requisiton is now approved!";
                    return(RedirectToAction("TrackRequisition", new { id = reqm.Reqid }));
                }
                Session["notititle"]   = "Requisition Rejection";
                Session["notimessage"] = "Requisiton is rejected!";
                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                return(RedirectToAction("Index", "Error", new { error = ex.Message }));
            }
        }
        // for AJAX reload via shared layout -- once in 10 seconds
        public PartialViewResult GetNotifications()
        {
            string    token = GetToken();
            UserModel um    = GetUser();
            string    error = "";
            List <NotificationModel> notis = new List <NotificationModel>();

            notis                 = APINotification.GetNotiByunread(false, um.Deptid, um.Role, token, out error);
            ViewBag.NotiCount     = notis.Count;
            ViewBag.Notifications = notis;
            return(PartialView());
        }
示例#4
0
        // for notification ajax retrieval
        public PartialViewResult GetNotifications()
        {
            string    token = GetToken();
            UserModel um    = GetUser();
            string    error = "";
            List <NotificationModel> notis = new List <NotificationModel>();

            notis = APINotification.GetNotiByunread(false, um.Deptid, um.Role, token, out error);
            notis = notis.OrderByDescending(x => x.Datetime).ToList();
            foreach (NotificationModel noti in notis)
            {
                noti.RelativeTime = Utilities.Utility.GetRelativeTime(noti.Datetime);
            }
            ViewBag.NotiCount     = notis.Count;
            ViewBag.Notifications = notis;
            return(PartialView());
        }
示例#5
0
        public ActionResult Index(int id)
        {
            string    error = "";
            string    token = GetToken();
            UserModel um    = GetUser();

            NotificationModel notim             = new NotificationModel();
            DepartmentCollectionPointModel dcpm = new DepartmentCollectionPointModel();

            notim = APINotification.UpdateNotificationAsRead(token, id, out error);

            switch (notim.NotiType)
            {
            case ConNotification.NotiType.Adjustment:
                if (notim.Role == ConUser.Role.SUPERVISOR)
                {
                    return(RedirectToAction("Approve", "Supervisor"));
                }
                else if (notim.Role == ConUser.Role.MANAGER)
                {
                    return(RedirectToAction("Approve", "Manager"));
                }
                else
                {
                    return(RedirectToAction("Inventory", "Clerk"));
                }

            case ConNotification.NotiType.ClerkApprovedCollectionPointChange:
                return(RedirectToAction("CollectionPoint", "HOD"));

            case ConNotification.NotiType.ClerkApprovedRequisition:
                return(RedirectToAction("TrackRequisition", "HOD", new { id = notim.ResID }));

            case ConNotification.NotiType.ClerkRejectedCollectionPointChange:
                return(RedirectToAction("CollectionPoint", "HOD"));

            case ConNotification.NotiType.CollectedRequistion:
                return(RedirectToAction("DisbursementDetail", "Clerk", new { id = notim.ResID }));

            case ConNotification.NotiType.CollectionPointChangeRequestApproval:
                return(RedirectToAction("ApproveCollectionPoint", "Clerk", new { id = notim.ResID }));

            case ConNotification.NotiType.DelegationAssigned:
                return(RedirectToAction("Index", "Home"));

            case ConNotification.NotiType.DelegationCancelled:
                return(RedirectToAction("Index", "Home"));

            case ConNotification.NotiType.DeliveredRequisition:
                dcpm = APICollectionPoint.GetActiveDepartmentCollectionPointByDeptID(token, um.Deptid, out error);
                if (dcpm == null)
                {
                    dcpm = new DepartmentCollectionPointModel
                    {
                        CpName = "Department Collection Point"
                    };
                }
                Session["noti"]        = true;
                Session["notitype"]    = "info";
                Session["notititle"]   = "Outstanding Requisiton";
                Session["notimessage"] = "Please go collect the items at " + dcpm.CpName;
                return(RedirectToAction("Index", "Home"));

            case ConNotification.NotiType.DeptRepAssigned:
                return(RedirectToAction("Index", "Home"));

            case ConNotification.NotiType.HODApprovedRequistion:
                if (notim.Role == ConUser.Role.EMPLOYEE)
                {
                    return(RedirectToAction("TrackRequisition", "Employee", new { id = notim.ResID }));
                }
                else if (notim.Role == ConUser.Role.DEPARTMENTREP)
                {
                    return(RedirectToAction("TrackRequisition", "Employee", new { id = notim.ResID }));
                }
                return(RedirectToAction("RequisitionDetail", "Clerk", new { id = notim.ResID }));

            case ConNotification.NotiType.OutstandingItemsCollected:
                return(RedirectToAction("OutstandingDetail", "Clerk", new { id = notim.ResID }));

            case ConNotification.NotiType.OutstandingItemsReadyToCollect:
                dcpm = APICollectionPoint.GetActiveDepartmentCollectionPointByDeptID(token, um.Deptid, out error);
                if (dcpm == null)
                {
                    dcpm = new DepartmentCollectionPointModel
                    {
                        CpName = "Department Collection Point"
                    };
                }
                Session["noti"]        = true;
                Session["notitype"]    = "info";
                Session["notititle"]   = "Outstanding Requisiton";
                Session["notimessage"] = "Please go collect the items at " + dcpm.CpName;
                return(RedirectToAction("Index", "Home"));

            case ConNotification.NotiType.RejectedRequistion:
                return(RedirectToAction("Index", "Home"));

            case ConNotification.NotiType.RequisitionApproval:
                return(RedirectToAction("ApproveRequisition", "HOD", new { id = notim.ResID }));
            }
            return(View());
        }
示例#6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="response"></param>
        public static bool Finish(CardOrderSupplierResponse response)
        {
            string cacheKey = "OrderBankComplete" + response.SysOrderNo + response.SupplierId.ToString(CultureInfo.InvariantCulture);

            object flag = Cache.WebCache.GetCacheService().RetrieveObject(cacheKey);

            if (flag != null)
            {
                return(true);
            }

            var orderInfo = Cache.WebCache.GetCacheService().RetrieveObject(response.SysOrderNo) as OrderCardInfo;

            if (orderInfo == null)
            {
                orderInfo = BLL.Order.Card.Factory.Instance.GetModelByOrderId(response.SysOrderNo);
            }
            if (orderInfo == null)
            {
                return(false);
            }

            try
            {
                byte continueSubmit = 0;

                int seq = 1, continueSupp = 0;

                bool processFlag = true;

                if (response.Method == 1)
                {
                    if (response.OrderStatus != 2)
                    {
                        #region 继续提交
                        var suppInfo = BLL.Supplier.Factory.GetCacheModel(response.SupplierId);
                        if (suppInfo != null)
                        {
                            if (!string.IsNullOrEmpty(suppInfo.AsynsRetCode))
                            {
                                string[] arr = suppInfo.AsynsRetCode.Split(',');
                                if (arr.Any(s => s == response.SuppErrorCode))
                                {
                                    continueSubmit = 1;
                                }
                            }
                        }
                        #endregion
                    }

                    DataRow resultRow = BLL.Order.Card.Factory.Instance.CallbackInsert(response.SysOrderNo
                                                                                       , response.SupplierId
                                                                                       , response.OrderStatus
                                                                                       , response.SuppErrorCode
                                                                                       , response.SuppErrorMsg
                                                                                       , continueSubmit);

                    if (resultRow != null)
                    {
                        seq          = Convert.ToInt32(resultRow["seq"]);
                        continueSupp = Convert.ToInt32(resultRow["suppId"]);
                    }

                    if (continueSubmit == 1 && continueSupp > 0)
                    {
                        #region 再次提交
                        try
                        {
                            if (resultRow != null)
                            {
                                var o = new CardOrderSummitArgs()
                                {
                                    SysOrderNo = response.SysOrderNo,
                                    CardTypeId = Convert.ToInt32(resultRow["typeid"]),
                                    CardNo     = resultRow["cardno"].ToString(),
                                    CardPass   = resultRow["cardpass"].ToString(),
                                    FaceValue  = decimal.ToInt32(Convert.ToDecimal(resultRow["facevalue"])),
                                    Attach     = "",
                                    Source     = 2
                                };
                                var callBack = SendCard((SupplierCode)continueSupp, o);
                                if (callBack.SummitStatus == 1)
                                {
                                    processFlag = false;
                                }
                            }
                        }
                        catch
                        {
                        }
                        #endregion
                    }
                    else
                    {
                        processFlag = (seq == 1) || ((seq > 1) && (response.OrderStatus == 2));
                    }
                }

                if (processFlag)
                {
                    orderInfo = UpdateOrder(seq, orderInfo, response);

                    if (seq == 1 && orderInfo != null)
                    {
                        //APINotification.DoAsynchronousNotify(orderInfo);

                        APINotification.SynchronousNotifyX(orderInfo);
                    }
                }
                Cache.WebCache.GetCacheService().AddObject(cacheKey, response.OrderStatus, 5);

                return(true);
            }
            catch (Exception exception)
            {
                ExceptionHandler.HandleException(exception);

                return(false);
            }
        }
示例#7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            if (this.IsValid)
            {
                string orderId = this.txtOrderId.Text.Trim();
                if (string.IsNullOrEmpty(orderId))
                {
                    ShowMessageBox("请输入订单号");
                    return;
                }

                if (string.IsNullOrEmpty(ddlSupp.SelectedValue))
                {
                    ShowMessageBox("请选择接口商");
                    return;
                }

                string  orderAmt = this.txtOrderAmt.Text.Trim();
                decimal amt      = 0M;
                if (string.IsNullOrEmpty(orderAmt))
                {
                    ShowMessageBox("请输入订单金额");
                    return;
                }

                if (!decimal.TryParse(orderAmt, out amt))
                {
                    ShowMessageBox("订单金额不能为空");
                    return;
                }
                if (amt <= 0M)
                {
                    ShowMessageBox("金额不能为0");
                    return;
                }

                OrderBankInfo orderBank = viviapi.BLL.Order.Bank.Factory.Instance.GetModelByOrderId(orderId);
                if (orderBank == null)
                {
                    ShowMessageBox("不存在此订单");
                    return;
                }

                if (orderBank.status != 1)
                {
                    ShowMessageBox("订单状态不正确");
                    return;
                }

                string supp = this.ddlSupp.SelectedValue;

                if (orderBank.status == 1)
                {
                    FunExecResult result = viviapi.ETAPI.Common.OrderBankUtils.InsertToDb(int.Parse(supp)
                                                                                          , orderBank
                                                                                          , "Sys" + DateTime.Now.Ticks.ToString()
                                                                                          , 2
                                                                                          , "0"
                                                                                          , "手动补单"
                                                                                          , amt, 0M);

                    if (result.ErrCode == 0)
                    {
                        if (orderBank.status != 1)
                        {
                            APINotification.SynchronousNotifyX(orderBank);
                        }

                        ShowMessageBox("操作成功");
                    }
                    else
                    {
                        ShowMessageBox("操作失败");
                    }
                }
                else
                {
                    ShowMessageBox("订单状态不正确");
                }
            }
        }