예제 #1
0
        public static void SuppNotify(CardOrderSupplierResponse response, string succflag)
        {
            bool execResult = Finish(response);

            if (execResult == true)
            {
                HttpContext.Current.Response.Write(succflag);
            }
            else
            {
                HttpContext.Current.Response.Write("fail");
            }
        }
예제 #2
0
        public static void UpdateOrder(int seq, CardOrderSupplierResponse response)
        {
            var orderInfo = Cache.WebCache.GetCacheService().RetrieveObject(response.SysOrderNo) as OrderCardInfo;

            if (orderInfo == null)
            {
                orderInfo = bllCard.GetModelByOrderId(response.SysOrderNo);
            }
            if (orderInfo != null)
            {
                #region
                orderInfo.supplierId = response.SupplierId;

                UserInfo userInfo
                    = BLL.User.UserFactory.GetCacheUserBaseInfo(orderInfo.userid);

                orderInfo.method        = response.Method;
                orderInfo.cardversion   = userInfo.cardversion;
                orderInfo.orderid       = response.SysOrderNo;
                orderInfo.status        = response.OrderStatus;
                orderInfo.opstate       = response.Opstate;
                orderInfo.msg           = response.SuppErrorMsg;
                orderInfo.supplierOrder = "";
                if (!string.IsNullOrEmpty(response.SuppTransNo))
                {
                    orderInfo.supplierOrder = response.SuppTransNo;
                }

                orderInfo.errtype       = response.SuppErrorCode;
                orderInfo.withhold_type = 0;
                orderInfo.withholdAmt   = 0M;
                orderInfo.faceValue     = response.OrderAmt;
                orderInfo.userViewMsg   = response.ViewMsg;

                #region 是否扣单
                if (true && BLL.SysConfig.isOpenDeduct && response.OrderStatus == 2)
                {
                    if (new Random(Guid.NewGuid().GetHashCode()).Next(1, 1000) <= userInfo.CPSDrate)
                    {
                        orderInfo.status = 8;
                    }
                }
                #endregion

                orderInfo.realvalue    = response.OrderAmt;
                orderInfo.supplierId   = response.SupplierId;
                orderInfo.completetime = DateTime.Now;

                orderInfo.payRate      = 0M;
                orderInfo.payAmt       = 0M;
                orderInfo.supplierRate = 0M;
                orderInfo.supplierAmt  = 0M;
                orderInfo.promRate     = 0M;
                orderInfo.promAmt      = 0M;
                orderInfo.profits      = 0M;

                if (response.OrderStatus == 2)
                {
                    #region 商户费率

                    if (orderInfo.payRate <= 0M)
                    {
                        if (orderInfo.ordertype == 8)
                        {
                            orderInfo.payRate = BLL.Channel.Channelsupplier.GetPayRate(orderInfo.typeId,
                                                                                       orderInfo.supplierId);
                        }
                        if (orderInfo.payRate <= 0M)
                        {
                            orderInfo.payRate = BLL.Payment.PayRateFactory.GetUserPayRate(userInfo, orderInfo.userid,
                                                                                          orderInfo.typeId);
                        }
                    }
                    orderInfo.payAmt = orderInfo.payRate * response.OrderAmt;

                    #endregion

                    #region 平台费率

                    if (response.SuppAmt > 0)
                    {
                        orderInfo.supplierRate = response.SuppAmt / orderInfo.refervalue;
                        orderInfo.supplierAmt  = response.SuppAmt;
                    }
                    else
                    {
                        decimal suppRate = SupplierPayRateFactory.GetRate(response.SupplierId, orderInfo.typeId);
                        orderInfo.supplierRate = suppRate;
                        orderInfo.supplierAmt  = suppRate * response.OrderAmt;
                    }

                    #endregion

                    #region 代理

                    //代理
                    if (orderInfo.agentId > 0)
                    {
                        //代理费率
                        orderInfo.promRate = BLL.Payment.PayRateFactory.GetUserPayRate(orderInfo.agentId,
                                                                                       orderInfo.typeId);
                        //代理金额
                        orderInfo.promAmt = (orderInfo.promRate - orderInfo.payRate) * response.OrderAmt;

                        if (orderInfo.promAmt < 0)
                        {
                            orderInfo.promAmt = 0;
                        }
                    }
                    orderInfo.profits = orderInfo.supplierAmt - orderInfo.payAmt - orderInfo.promAmt;

                    #endregion

                    if (seq == 1)
                    {
                        if (orderInfo.cardversion == 1)
                        {
                            #region 扣卡面值

                            if (orderInfo.refervalue < response.OrderAmt) //小提大
                            {
                                #region 小提大

                                orderInfo.realvalue     = orderInfo.refervalue;
                                orderInfo.withhold_type = 1;
                                orderInfo.withholdAmt   = response.OrderAmt - orderInfo.refervalue;

                                orderInfo.payAmt  = orderInfo.payRate * orderInfo.refervalue;
                                orderInfo.promAmt = (orderInfo.promRate - orderInfo.payRate) * orderInfo.refervalue;

                                orderInfo.supplierAmt = orderInfo.supplierRate * orderInfo.refervalue;
                                orderInfo.profits     = orderInfo.supplierAmt - orderInfo.payAmt - orderInfo.promAmt;

                                if (orderInfo.promAmt < 0)
                                {
                                    orderInfo.promAmt = 0;
                                }

                                #endregion
                            }
                            else if (orderInfo.refervalue > response.OrderAmt)
                            {
                                #region 大提小

                                orderInfo.withhold_type = 2;

                                orderInfo.status      = 4;
                                orderInfo.errtype     = "10";
                                orderInfo.opstate     = "10";
                                orderInfo.userViewMsg = "充值卡卡号或者密码无效";
                                orderInfo.realvalue   = 0M;

                                orderInfo.withholdAmt = response.OrderAmt;
                                orderInfo.payAmt      = 0M;
                                orderInfo.promAmt     = 0M;

                                orderInfo.withholdAmt = response.OrderAmt;
                                orderInfo.profits     = 0M;

                                if (orderInfo.promAmt < 0)
                                {
                                    orderInfo.promAmt = 0;
                                }

                                #endregion
                            }

                            #endregion
                        }
                    }
                    else
                    {
                        withholdDAL.Insert(orderInfo);
                    }
                }

                if (seq == 1)
                {
                    bllCard.Complete(orderInfo);
                }
                #endregion
            }
        }
예제 #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="response"></param>
        public static bool Finish(CardOrderSupplierResponse response)
        {
            try
            {
                byte continueSubmit = 0;
                if (response.OrderStatus != 2 && response.Method == 1)
                {
                    var suppInfo = SupplierFactory.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;
                            }
                        }
                    }
                }

                int    seq = 1, continueSupp = 0;
                string cacheKey = "ReceiveSuppResult" + response.SysOrderNo + response.SupplierId.ToString();
                object flag     = HttpRuntime.Cache[cacheKey];
                if (flag == null)
                {
                    DataRow resultRow = dal2.CallbackInsert(response.SysOrderNo
                                                            , response.SupplierId
                                                            , response.OrderStatus
                                                            , response.SuppErrorCode
                                                            , response.SuppErrorMsg
                                                            , continueSubmit);

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

                    if (continueSubmit == 1 && continueSupp > 0)
                    {
                    }
                    else
                    {
                        bool processFlag = (seq == 1) || ((seq > 1) && (response.OrderStatus == 2));

                        if (processFlag)
                        {
                            UpdateOrder(seq, response);
                        }
                    }


                    HttpRuntime.Cache.Insert(cacheKey, response.OrderStatus, null, DateTime.Now.AddSeconds(10.0), TimeSpan.Zero);
                }

                if (seq == 1)
                {
                    _notify.DoNotify(response.SysOrderNo);
                }

                Cache.WebCache.GetCacheService().RemoveObject(response.SysOrderNo);

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

                return(false);
            }
        }