Beispiel #1
0
        public void CreateWithSameType()
        {
            var type = new ChannelTypeInfo(TypeInfo.Int);

            Assert.AreSame(TypeInfo.Int, type.ReceiveTypeInfo);
            Assert.AreSame(TypeInfo.Int, type.SendTypeInfo);
        }
Beispiel #2
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        string SendToSupp()
        {
            string msg = string.Empty;

            try
            {
                ChannelTypeInfo chanelTypeInfo = ChannelType.GetCacheModel(TypeId);
                if (chanelTypeInfo == null)
                {
                    msg = "找不到通道,请联系商务或系统管理员处理。";
                }
                else
                {
                    int card_type = 0;

                    if (int.TryParse(chanelTypeInfo.code, out card_type))
                    {
                        string callBackurl = WebUtility.GetCurrentHost() + "/merchant/receiveResult/cardsell.aspx";

                        string postData =
                            string.Format(
                                "type={0}&parter={1}&cardno={2}&cardpwd={3}&value={4}&restrict={5}&orderid={6}&callbackurl={7}",
                                card_type, UserId, CardNo, CardPwd, FaceValue, 0, DateTime.Now.Ticks.ToString(), callBackurl);

                        string sign = viviLib.Security.Cryptography.MD5(postData + CurrentUser.APIKey);

                        postData += "&sign=" + sign + "&attach=cardsell";

                        string postUrl = WebUtility.GetGatewayUrl() + "/CardReceive.ashx";

                        string callback = WebClientHelper.GetString(postUrl, postData, "GET",
                                                                    System.Text.Encoding.GetEncoding("GB2312"), 10000);

                        if (callback == "opstate=0")
                        {
                            msg = "true";
                        }
                        else
                        {
                            msg = callback;
                        }
                    }
                    else
                    {
                        msg = "系统故障";
                    }
                }
            }
            catch (Exception ex)
            {
                msg = ex.Message;
            }

            return(msg);
        }
Beispiel #3
0
        /// <summary>
        ///  更新一条数据
        /// </summary>
        public static bool Update(ChannelTypeInfo model)
        {
            try
            {
                int            rowsAffected;
                SqlParameter[] parameters =
                {
                    new SqlParameter("@id",                    SqlDbType.Int,          4),
                    new SqlParameter("@classid",               SqlDbType.TinyInt,      1),
                    new SqlParameter("@typeId",                SqlDbType.Int,          4),
                    new SqlParameter("@modetypename",          SqlDbType.VarChar,     50),
                    new SqlParameter("@isOpen",                SqlDbType.TinyInt,      1),
                    new SqlParameter("@supplier",              SqlDbType.Int,          4),
                    new SqlParameter("@addtime",               SqlDbType.DateTime),
                    new SqlParameter("@sort",                  SqlDbType.Int,          4),
                    new SqlParameter("@release",               SqlDbType.Bit,          1),
                    new SqlParameter("@runmode",               SqlDbType.TinyInt,      4),
                    new SqlParameter("@runset",                SqlDbType.VarChar,   1000),
                    new SqlParameter("@supplier2",             SqlDbType.Int,          4),
                    new SqlParameter("@suppsWhenExceOccurred", SqlDbType.VarChar,    100),
                    new SqlParameter("@timeout",               SqlDbType.Int, 4)
                };
                parameters[0].Value = model.id;
                parameters[1].Value = model.Class;
                parameters[2].Value = model.typeId;
                parameters[3].Value = model.modetypename;
                parameters[4].Value = (int)model.isOpen;
                parameters[5].Value = model.supplier;
                parameters[6].Value = DateTime.Now;
                parameters[7].Value = model.sort;
                parameters[8].Value = model.release;

                parameters[9].Value  = model.runmode;
                parameters[10].Value = model.runset;
                parameters[11].Value = model.supplier2;
                parameters[12].Value = model.SuppsWhenExceOccurred;
                parameters[13].Value = model.timeout;

                rowsAffected = DataBase.ExecuteNonQuery(CommandType.StoredProcedure, "proc_channeltype_Update", parameters);
                bool success = rowsAffected > 0;
                if (success)
                {
                    ClearCache();
                }
                return(success);
            }
            catch (Exception ex)
            {
                ExceptionHandler.HandleException(ex);
                return(false);
            }
        }
Beispiel #4
0
        /// <summary>
        ///  增加一条数据
        /// </summary>
        public static int Add(ChannelTypeInfo model)
        {
            try
            {
                SqlParameter[] parameters =
                {
                    new SqlParameter("@id",                    SqlDbType.Int,          4),
                    new SqlParameter("@classid",               SqlDbType.TinyInt,      1),
                    new SqlParameter("@typeId",                SqlDbType.Int,          4),
                    new SqlParameter("@modetypename",          SqlDbType.VarChar,     50),
                    new SqlParameter("@isOpen",                SqlDbType.TinyInt,      1),
                    new SqlParameter("@supplier",              SqlDbType.Int,          4),
                    new SqlParameter("@addtime",               SqlDbType.DateTime),
                    new SqlParameter("@sort",                  SqlDbType.Int,          4),
                    new SqlParameter("@release",               SqlDbType.Bit,          1),
                    new SqlParameter("@runmode",               SqlDbType.TinyInt,      4),
                    new SqlParameter("@runset",                SqlDbType.VarChar,   1000),
                    new SqlParameter("@supplier2",             SqlDbType.Int,          4),
                    new SqlParameter("@suppsWhenExceOccurred", SqlDbType.VarChar, 100)
                };
                parameters[0].Direction = ParameterDirection.Output;
                parameters[1].Value     = model.Class;
                parameters[2].Value     = model.typeId;
                parameters[3].Value     = model.modetypename;
                parameters[4].Value     = (int)model.isOpen;
                parameters[5].Value     = model.supplier;
                parameters[6].Value     = model.addtime;
                parameters[7].Value     = model.sort;
                parameters[8].Value     = model.release;

                parameters[9].Value  = model.runmode;
                parameters[10].Value = model.runset;

                parameters[11].Value = model.supplier2;
                parameters[12].Value = model.SuppsWhenExceOccurred;


                DataBase.ExecuteNonQuery(CommandType.StoredProcedure, "proc_channeltype_add", parameters);
                int id = (int)parameters[0].Value;
                if (id > 0)
                {
                    ClearCache();
                }
                return(id);
            }
            catch (Exception ex)
            {
                ExceptionHandler.HandleException(ex);
                return(0);
            }
        }
Beispiel #5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="typeId"></param>
        /// <param name="userId"></param>
        /// <returns></returns>
        public static bool IsOpen(int typeId, int userId)
        {
            bool open = false;

            ChannelTypeInfo typeinfo = GetCacheModel(typeId);

            if (typeinfo == null)
            {
                return(open);
            }

            /*系统通道状态*/
            switch (typeinfo.isOpen)
            {
            case OpenEnum.AllClose:    //全部关闭
                open = false;
                break;

            case OpenEnum.AllOpen:    //全部开启
                open = true;
                break;

            case OpenEnum.Close:    //
                open = GetSysOpenStatus(userId, typeId, false);
                break;

            case OpenEnum.Open:    //
                open = GetSysOpenStatus(userId, typeId, true);
                break;
            }

            /*用户通道状态 只有系统通道状态为开启时用户的设置才有效*/
            if (open == true)
            {
                open = GetUserOpenStatus(userId, typeId, true);
            }

            return(open);
        }
Beispiel #6
0
        /// <summary>
        /// 取类型开通状态
        /// </summary>
        /// <param name="typeId"></param>
        /// <param name="userId"></param>
        /// <returns></returns>
        public static int GetChannelTypeStatus(int typeId, int userId)
        {
            int open = 0;

            ChannelTypeInfo typeinfo = ChannelType.GetCacheModel(typeId);

            if (typeinfo == null)
            {
                return(open);
            }
            int usersuppid = 0;

            /*系统通道状态*/
            switch (typeinfo.isOpen)
            {
            case OpenEnum.AllClose:    //全部关闭
                open = 0;
                break;

            case OpenEnum.AllOpen:    //全部开启
                open = 1;
                break;

            case OpenEnum.Close:                                                                                //根据设置 默认为关闭算法,如果后台对用户单独设置了就计算单独的开启状态。 如果没有看通道本身的状态 默认为关闭。如果后台都未设置为默认状态
                open = BLL.Channel.Channel.GetChanelSysStatus(4, userId, string.Empty, typeId, ref usersuppid); // GetSysOpenStatus(userId, chanelNo, info.typeId, 0);
                break;

            case OpenEnum.Open:                                                                                 //
                open = BLL.Channel.Channel.GetChanelSysStatus(8, userId, string.Empty, typeId, ref usersuppid); //GetSysOpenStatus(userId, chanelNo, info.typeId, 1);
                break;
            }

            /*用户通道状态 只有系统通道状态为开启时用户的设置才有效*/
            if (open == 1)
            {
                open = BLL.Channel.Channel.GetUserOpenStatus(userId, string.Empty, typeId, 1);
            }
            return(open);
        }
Beispiel #7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="typeId"></param>
        /// <param name="userId"></param>
        /// <returns></returns>
        public static ChannelTypeInfo GetModel(int typeId, int userId, out bool enable)
        {
            enable = false;
            int open = 0;

            ChannelTypeInfo typeinfo = ChannelType.GetCacheModel(typeId);

            if (typeinfo == null)
            {
                return(null);
            }
            /*系统通道状态*/
            switch (typeinfo.isOpen)
            {
            case OpenEnum.AllClose:    //全部关闭
                open = 0;
                break;

            case OpenEnum.AllOpen:    //全部开启
                open = 1;
                break;

            case OpenEnum.Close:    //
                open = GetSysOpenStatus(userId, typeId, 0);
                break;

            case OpenEnum.Open:    //
                open = GetSysOpenStatus(userId, typeId, 1);
                break;
            }
            /*用户通道状态 只有系统通道状态为开启时用户的设置才有效*/
            if (open == 1)
            {
                open = GetUserOpenStatus(userId, typeId, 1);
            }
            enable = open == 1;
            return(typeinfo);
        }
Beispiel #8
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="ds"></param>
        /// <returns></returns>
        internal static ChannelTypeInfo GetInfoFromRow(DataRow dr)
        {
            ChannelTypeInfo model = new ChannelTypeInfo();

            if (dr["id"].ToString() != "")
            {
                model.id = int.Parse(dr["id"].ToString());
            }
            if (dr["classid"].ToString() != "")
            {
                model.Class = (ChannelClassEnum)int.Parse(dr["classid"].ToString());
            }
            if (dr["typeId"].ToString() != "")
            {
                model.typeId = int.Parse(dr["typeId"].ToString());
            }
            model.modetypename = dr["modetypename"].ToString();
            model.code         = dr["code"].ToString();
            if (dr["isOpen"].ToString() != "")
            {
                model.isOpen = (OpenEnum)int.Parse(dr["isOpen"].ToString());
            }
            if (dr["supplier"].ToString() != "")
            {
                model.supplier = int.Parse(dr["supplier"].ToString());
            }
            if (dr["suppRate"].ToString() != "")
            {
                model.supprate = Convert.ToDecimal(dr["suppRate"]);
            }
            //if (dr["addtime"].ToString() != "")
            //{
            //    model.addtime = DateTime.Parse(dr["addtime"].ToString());
            //}
            if (dr["sort"].ToString() != "")
            {
                model.sort = int.Parse(dr["sort"].ToString());
            }
            if (dr["release"].ToString() != "")
            {
                if ((dr["release"].ToString() == "1") || (dr["release"].ToString().ToLower() == "true"))
                {
                    model.release = true;
                }
                else
                {
                    model.release = false;
                }
            }
            if (dr["runmode"].ToString() != "")
            {
                model.runmode = int.Parse(dr["runmode"].ToString());
            }
            model.runset = dr["runset"].ToString();
            if (dr["supplier2"].ToString() != "")
            {
                model.supplier2 = int.Parse(dr["supplier2"].ToString());
            }
            if (dr["suppsWhenExceOccurred"].ToString() != "")
            {
                model.SuppsWhenExceOccurred = dr["suppsWhenExceOccurred"].ToString();
            }
            if (dr["timeout"].ToString() != "")
            {
                model.timeout = int.Parse(dr["timeout"].ToString());
            }
            return(model);
        }
Beispiel #9
0
        public void ProcessRequest(HttpContext context)
        {
            string result = string.Empty;

            try
            {
                string orderid   = viviLib.Web.WebBase.GetFormString("orderid", "");
                string cardNo    = viviLib.Web.WebBase.GetFormString("cardNo", "");
                string cardPwd   = viviLib.Web.WebBase.GetFormString("cardPwd", "");
                string faceValue = viviLib.Web.WebBase.GetFormString("faceValue", "");
                string typeId    = viviLib.Web.WebBase.GetFormString("typeId", "");
                string userId    = viviLib.Web.WebBase.GetFormString("userId", "");
                string sign      = viviLib.Web.WebBase.GetFormString("sign", "");
                string apikey    = string.Empty;
                int    typeid    = 0;
                int.TryParse(typeId, out typeid);

                int?_manageId  = 0;
                int _faceValue = 0;
                try
                {
                    _faceValue = Convert.ToInt32(decimal.Round(Convert.ToDecimal(faceValue), 0).ToString());
                }
                catch
                {
                }

                int _userid = 0;
                if (
                    string.IsNullOrEmpty(orderid) ||
                    string.IsNullOrEmpty(cardNo) ||
                    string.IsNullOrEmpty(cardPwd) ||
                    string.IsNullOrEmpty(faceValue) ||
                    string.IsNullOrEmpty(typeId) ||
                    string.IsNullOrEmpty(userId) ||
                    string.IsNullOrEmpty(sign))
                {
                    result = "参数不正确";
                }
                else
                {
                    if (!string.IsNullOrEmpty(userId))
                    {
                        if (int.TryParse(userId, out _userid))
                        {
                        }
                    }

                    if (_userid == 0)
                    {
                        result = "用户不存在";
                    }
                    else
                    {
                        UserInfo userInfo = viviapi.BLL.User.Factory.GetCacheUserBaseInfo(_userid);

                        if (userInfo == null || userInfo.Status != 2)
                        {
                            result = "用户不存在";
                        }
                        else
                        {
                            apikey    = userInfo.APIKey;
                            _manageId = userInfo.manageId;
                        }
                    }
                }
                if (string.IsNullOrEmpty(result))
                {
                    string plain = orderid + cardNo + cardPwd + faceValue + typeId + userId + apikey;
                    //viviLib.Logging.LogHelper.Write(plain);
                    string localsign = viviLib.Security.Cryptography.MD5(plain);
                    //viviLib.Logging.LogHelper.Write(localsign);
                    //viviLib.Logging.LogHelper.Write(sign);
                    if (localsign != sign)
                    {
                        result = "签名不正确";
                    }
                }

                if (string.IsNullOrEmpty(result))
                {
                    ChannelTypeInfo chanelTypeInfo = ChannelType.GetCacheModel(typeid);
                    if (chanelTypeInfo == null)
                    {
                        result = "找不到通道,请联系商务或系统管理员处理。";
                    }
                    else
                    {
                        #region 提交到网关

                        int card_type = 0;

                        if (int.TryParse(chanelTypeInfo.code, out card_type))
                        {
                            string callBackurl = WebUtility.GetCurrentHost() + "/merchant/receiveResult/cardsell.aspx";

                            string postData =
                                string.Format(
                                    "type={0}&parter={1}&cardno={2}&cardpwd={3}&value={4}&restrict={5}&orderid={6}&callbackurl={7}",
                                    card_type, userId, cardNo, cardPwd, faceValue, 0, DateTime.Now.Ticks.ToString(),
                                    callBackurl);

                            sign = viviLib.Security.Cryptography.MD5(postData + apikey);

                            postData += "&sign=" + sign + "&attach=clientCardsell";

                            string postUrl = WebUtility.GetGatewayUrl() + "/CardReceive.ashx";

                            string callback = WebClientHelper.GetString(postUrl, postData, "GET",
                                                                        System.Text.Encoding.GetEncoding("GB2312"), 10000);

                            if (callback == "opstate=0")
                            {
                                result = "success";
                            }
                            else
                            {
                                result = "提卡失败";
                            }
                        }
                        else
                        {
                            result = "系统故障";
                        }

                        #endregion
                    }
                }
            }
            catch (Exception ex)
            {
                result = "系统故障";
            }


            context.Response.ContentType = "text/plain";
            context.Response.Write(result);
        }
Beispiel #10
0
        private void LoadData()
        {
            DataTable data = viviapi.BLL.Channel.ChannelType.GetList(true).Tables[0];

            //通道类别状态
            if (!data.Columns.Contains("type_status"))
            {
                data.Columns.Add("type_status", typeof(string));
            }

            //系统设置
            if (!data.Columns.Contains("sys_setting"))
            {
                data.Columns.Add("sys_setting", typeof(string));
            }

            //用户前台设置
            if (!data.Columns.Contains("user_setting"))
            {
                data.Columns.Add("user_setting", typeof(string));
            }

            if (!data.Columns.Contains("payrate"))
            {
                data.Columns.Add("payrate", typeof(double));
            }

            if (!data.Columns.Contains("suppid"))
            {
                data.Columns.Add("suppid", typeof(int));
            }



            foreach (DataRow dr in data.Rows)
            {
                int typeId = int.Parse(dr["typeId"].ToString());

                bool type_stutas  = false;
                bool?sys_setting  = null;
                bool?user_setting = null;

                ChannelTypeUserInfo setting  = ChannelTypeUsers.GetModel(CurrentUser.ID, typeId);
                ChannelTypeInfo     typeInfo = ChannelType.GetModelByTypeId(typeId);
                switch (typeInfo.isOpen)
                {
                case OpenEnum.Close:
                case OpenEnum.AllClose:

                    type_stutas = false;
                    break;

                case OpenEnum.Open:
                case OpenEnum.AllOpen:
                    type_stutas = true;
                    break;
                }

                dr["type_status"]  = type_stutas ? "right" : "wrong";
                dr["sys_setting"]  = "Unknown";
                dr["user_setting"] = "Unknown";

                dr["suppid"] = 0;
                if (setting != null)
                {
                    if (setting.sysIsOpen.HasValue)
                    {
                        dr["sys_setting"] = setting.sysIsOpen.Value ? "right" : "wrong";
                        if (!setting.sysIsOpen.Value) //如果端口未开放
                        {
                            if (typeId == 101)        //支付宝
                            {
                                class992 = hid;
                            }
                            else if (typeId == 100)//财付通
                            {
                                class993 = hid;
                            }
                            else if (typeId == 207)//微信支付
                            {
                                class1004 = hid;
                            }
                            else if (typeId == 300)//wap微信支付
                            {
                                class1007 = hid;
                            }
                            else if (typeId == 213)//qq支付
                            {
                                class51 = hid;
                            }
                            else if (typeId == 200)//Wap支付宝
                            {
                                class1008 = hid;
                            }
                            lit1.Text += "sysIsOpen" + typeId + ",";
                        }
                    }
                    if (setting.userIsOpen.HasValue)
                    {
                        dr["user_setting"] = setting.userIsOpen.Value ? "right" : "wrong";
                        if (!setting.userIsOpen.Value) //如果端口未开放
                        {
                            if (typeId == 101)         //支付宝
                            {
                                class992 = hid;
                            }
                            else if (typeId == 100)//财付通
                            {
                                class993 = hid;
                            }
                            else if (typeId == 207)//微信支付
                            {
                                class1004 = hid;
                            }
                            else if (typeId == 300)//wap微信支付
                            {
                                class1007 = hid;
                            }
                            else if (typeId == 213)//qq支付
                            {
                                class51 = hid;
                            }
                            else if (typeId == 200)//Wap支付宝
                            {
                                class1008 = hid;
                            }
                            lit2.Text += "userIsOpen" + typeId + ",";
                        }
                    }
                    lit3.Text += "userIsOpenuserIsOpen" + typeId + ",";

                    if (setting.suppid.HasValue)
                    {
                        dr["suppid"] = setting.suppid.Value;
                    }
                }
                //dr["payrate"] = 100 * viviapi.BLL.Finance.PayRate.Instance.GetUserPayRate(this.UserID, Convert.ToInt32(dr["typeId"]));
            }
            //rpt_paymode.DataSource = data;
            //rpt_paymode.DataBind();
        }
Beispiel #11
0
        void LoadData()
        {
            DataTable data = viviapi.BLL.Channel.ChannelType.GetCacheList();

            if (!data.Columns.Contains("payrate"))
            {
                data.Columns.Add("payrate", typeof(double));
            }
            if (!data.Columns.Contains("plmodestatus"))
            {
                data.Columns.Add("plmodestatus", typeof(string));
            }
            if (!data.Columns.Contains("usermodestatus"))
            {
                data.Columns.Add("usermodestatus", typeof(string));
            }

            foreach (DataRow dr in data.Rows)
            {
                //if (dr["release"] != DBNull.Value && Convert.ToBoolean(dr["release"]) == false)
                //{
                //    //data.Rows.Remove(dr);
                //    continue;
                //}

                int typeId = int.Parse(dr["typeId"].ToString());

                bool isuserOpen             = true;
                bool issysOpen              = false;
                ChannelTypeUserInfo setting = ChannelTypeUsers.GetCacheModel(UserId, typeId);
                if (setting != null)
                {
                    if (setting.userIsOpen.HasValue)
                    {
                        isuserOpen = setting.userIsOpen.Value;
                    }
                }

                ChannelTypeInfo typeInfo = ChannelType.GetCacheModel(typeId);
                switch (typeInfo.isOpen)
                {
                case OpenEnum.AllClose:
                    issysOpen = false;
                    break;

                case OpenEnum.AllOpen:
                    issysOpen = true;
                    break;

                case OpenEnum.Close:
                    issysOpen = false;
                    if (setting != null)
                    {
                        if (setting.sysIsOpen.HasValue)
                        {
                            issysOpen = setting.sysIsOpen.Value;
                        }
                    }
                    break;

                case OpenEnum.Open:
                    issysOpen = true;
                    if (setting != null && setting.sysIsOpen.HasValue)
                    {
                        issysOpen = setting.sysIsOpen.Value;
                    }
                    break;
                }

                dr["payrate"] = 100 * viviapi.BLL.Finance.PayRate.Instance.GetUserPayRate(this.UserId, Convert.ToInt32(dr["typeId"]));
                if (isuserOpen)
                {
                    dr["usermodestatus"] = "right";
                }
                else
                {
                    dr["usermodestatus"] = "wrong";
                }
                if (issysOpen)
                {
                    dr["plmodestatus"] = "right";
                }
                else
                {
                    dr["plmodestatus"] = "wrong";
                }
            }

            rpt_paymode.DataSource = data;
            rpt_paymode.DataBind();
        }
Beispiel #12
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        string SendToSupp()
        {
            string msg = string.Empty;

            try
            {
                ChannelTypeInfo chanelTypeInfo = ChannelType.GetCacheModel(CardInfoID);
                if (chanelTypeInfo == null)
                {
                    msg = "找不到通道,请联系商务或系统管理员处理。";
                }
                else
                {
                    int card_type = 0;

                    if (int.TryParse(chanelTypeInfo.code, out card_type))
                    {
                        string        callBackurl  = WebUtility.GetCurrentHost() + "/merchant/receiveResult/cardsell.aspx";
                        StringBuilder cardno       = new StringBuilder();
                        StringBuilder cardpwd      = new StringBuilder();
                        int           totalValue   = CardPairsList.Count * Convert.ToInt32(ParValue);
                        int           currentIndex = 1;
                        foreach (KeyValuePair <string, string> pair in CardPairsList)
                        {
                            cardno.Append(pair.Key);
                            cardpwd.Append(pair.Value);
                            if (currentIndex < CardPairsList.Count)
                            {
                                cardno.Append(";");
                                cardpwd.Append(";");
                            }
                            currentIndex++;
                        }
                        string postData =
                            //
                            string.Format(
                                "type={0}&parter={1}&cardno={2}&cardpwd={3}&value={4}&restrict={5}&orderid={6}&callbackurl={7}",
                                card_type, UserId, cardno.ToString(), cardpwd.ToString(), ParValue, 0, DateTime.Now.Ticks.ToString(), callBackurl);

                        string sign = viviLib.Security.Cryptography.MD5(postData + CurrentUser.APIKey);

                        postData += "&sign=" + sign + "&attach=cardsell" + "&totalvalue=" + totalValue.ToString();

                        string postUrl = WebUtility.GetGatewayUrl() + "/CardReceive.aspx";

                        string callback = WebClientHelper.GetString(postUrl, postData, "GET",
                                                                    System.Text.Encoding.GetEncoding("GB2312"), 10000);

                        if (callback == "opstate=1" || callback == "opstate=0")//提交成功,返回状态码true
                        {
                            msg = "true";
                        }
                        else
                        {
                            msg = callback;
                        }
                    }
                    else
                    {
                        msg = "系统故障";
                    }
                }
            }
            catch (Exception ex)
            {
                msg = ex.Message;
            }

            return(msg);
        }
Beispiel #13
0
        public void ProcessRequest(HttpContext context)
        {
            string msg = string.Empty;

            try
            {
                string userid = viviLib.Web.WebBase.GetFormString("userid", string.Empty);
                if (!string.IsNullOrEmpty(userid))
                {
                    int UserId = 0;

                    if (int.TryParse(userid, out UserId))
                    {
                        DataTable dtcardtypes = new DataTable();
                        dtcardtypes.Columns.Add("typeid", typeof(int));
                        dtcardtypes.Columns.Add("typename", typeof(string));
                        dtcardtypes.Columns.Add("facevalues", typeof(string));


                        DataTable data      = viviapi.BLL.Channel.ChannelType.GetCacheList();
                        DataTable facevalue = viviapi.BLL.Channel.Channel.GetCardChanels(UserId, 0, 0, 1);

                        foreach (DataRow dr in data.Rows)
                        {
                            int typeId = int.Parse(dr["typeId"].ToString());
                            if (typeId < 103 || typeId == 300 || typeId == 114)
                            {
                                continue;
                            }

                            bool isuserOpen = true;
                            bool issysOpen  = false;

                            //用户关闭
                            ChannelTypeUserInfo setting = viviapi.BLL.Channel.ChannelTypeUsers.GetCacheModel(UserId, typeId);
                            if (setting != null)
                            {
                                if (setting.userIsOpen.HasValue)
                                {
                                    isuserOpen = setting.userIsOpen.Value;
                                    if (!isuserOpen)
                                    {
                                        continue;
                                    }
                                }
                            }

                            ChannelTypeInfo typeInfo = ChannelType.GetCacheModel(typeId);
                            switch (typeInfo.isOpen)
                            {
                            case OpenEnum.AllClose:
                                issysOpen = false;
                                break;

                            case OpenEnum.AllOpen:
                                issysOpen = true;
                                break;

                            case OpenEnum.Close:
                                issysOpen = false;
                                if (setting != null)
                                {
                                    if (setting.sysIsOpen.HasValue)
                                    {
                                        issysOpen = setting.sysIsOpen.Value;
                                    }
                                }
                                break;

                            case OpenEnum.Open:
                                issysOpen = true;
                                if (setting != null && setting.sysIsOpen.HasValue)
                                {
                                    if (setting.sysIsOpen.HasValue)
                                    {
                                        issysOpen = setting.sysIsOpen.Value;
                                    }
                                }
                                break;
                            }

                            if (!isuserOpen)
                            {
                                continue;
                            }
                            if (!issysOpen)
                            {
                                continue;
                            }

                            DataRow _dr = dtcardtypes.NewRow();
                            _dr["typeid"]     = typeId;
                            _dr["typename"]   = dr["modetypename"];
                            _dr["facevalues"] = GetFaceValues(facevalue, typeId);
                            dtcardtypes.Rows.Add(_dr);
                        }

                        msg = "success" + Newtonsoft.Json.JsonConvert.SerializeObject(dtcardtypes, Newtonsoft.Json.Formatting.Indented);
                    }
                }
            }
            catch
            {
            }
            context.Response.ContentType = "text/plain";
            context.Response.Write(msg);
        }
Beispiel #14
0
        void ChargeCard()
        {
            string error = string.Empty;

            #region Step1 必要的参数不能为空
            if (string.IsNullOrEmpty(this.parter))
            {
                error = "101";//商户ID为空
            }
            else if (string.IsNullOrEmpty(orderid))
            {
                error = "118";//商户订单号为空
            }
            else if (string.IsNullOrEmpty(money))
            {
                error = "120";//充值金额不合法
            }
            else if (string.IsNullOrEmpty(type))
            {
                error = "107";//充值类型错误
            }
            else if (string.IsNullOrEmpty(P_Price))
            {
                error = "123";//产品单价不是数字
            }
            #endregion
            #region Step2 检查参数长度
            else if (orderid.Length > 32)
            {
                error = "119";//商户订单号太长
            }
            else if (money.Length > 8)
            {
                error = "120";//充值金额不合法
            }
            else if (this.notifyurl.Length > 255)
            {
                error = "126";//result_url太长
            }
            else if (this.returnurl.Length > 255)
            {
                error = "125";//notify_url太长
            }
            else if (this.attach.Length > 255)
            {
                error = "124";//用户自定义信息文字太多
            }
            else if (this.P_Description.Length > 255)
            {
                error = "122";//产品描述文字太多
            }
            else if (this.P_Subject.Length > 50)
            {
                error = "121";//产品名称太长
            }
            else if (this.sign.Length != 32)
            {
                error = "110";//加密串postKey错误
            }
            #endregion
            #region Step3 格式验证
            else if (!viviLib.Text.Validate.IsNumeric(parter))
            {
                error = "109";//用户不存在
            }
            else if (!viviLib.Text.Validate.IsNumeric(type))
            {
                error = "112";//卡号类型不存在
            }
            else if (!checkOrderMoney())
            {
                error = "120";//充值金额不合法
            }

            /* else if (!checkPrice())
             * {
             *   error = "error:1045 产品价格(P_Price)格式不正确!";
             * }
             * else if (!checkPQuantity())
             * {
             *   error = "error:1046 产品数量(P_Quantity)格式不正确!";
             * }
             * else if (!isNotifyUrlOk())
             * {
             *   error = "error:1043 充值状态通知地址(P_Result_URL)格式不正确!";
             * }
             * else if (!isReturnUrlOk())
             * {
             *   error = "error:1044 充值后网页跳转地址(P_Notify_URL)格式不正确!";
             * }*/
            #endregion
            #region Step4 数据验证
            else if (SysChannelId <= 0)
            {
                error = "112";
            }
            else if (TranAmt <= 0M)
            {
                error = "120";
            }
            else if (UserInfo == null)
            {
                error = "109";
            }
            else if (UserInfo.Status != 2)
            {
                error = "109";
            }
            else if (!viviapi.SysInterface.Bank.HuaQi.ReceiveVerify(version, sign, new object[] { this.parter, this.orderid, this.cardno, this.cardpass, this.money, this.type, UserInfo.APIKey }))
            {
                error = "110";
            }
            #endregion

            int suppid = 0;
            if (string.IsNullOrEmpty(error))
            {
                ChannelTypeInfo _chanTypeInfo = viviapi.BLL.Channel.ChannelType.GetCacheModel(this.SysChannelId);
                if (_chanTypeInfo == null)
                {
                    error = "112";
                }
                else if (_chanTypeInfo.isOpen == OpenEnum.Close)
                {
                    error = "112";
                }
                else
                {
                    suppid = _chanTypeInfo.supplier;
                }
            }

            if (!string.IsNullOrEmpty(error))
            {
                #region 处理日志
                if (DebuglogOpen)
                {
                    if (UserInfo.isdebug == 1)
                    {
                        viviapi.Model.Sys.debuginfo _debugInfo = new viviapi.Model.Sys.debuginfo();
                        _debugInfo.addtime   = DateTime.Now;
                        _debugInfo.bugtype   = viviapi.Model.Sys.debugtypeenum.网银订单;
                        _debugInfo.detail    = string.Empty;
                        _debugInfo.errorcode = error;
                        _debugInfo.errorinfo = error;
                        _debugInfo.userid    = UserInfo.ID;
                        if (Request.RawUrl != null)
                        {
                            _debugInfo.url = Request.RawUrl.ToString();
                        }
                        else
                        {
                            _debugInfo.url = string.Empty;
                        }

                        viviapi.BLL.Sys.Debuglog.Insert(_debugInfo);
                    }
                }

                WebUtility.ShowErrorMsg(error);
                return;

                #endregion
            }
            else
            {
                string _supporderid = string.Empty;
                string supperrinfo  = string.Empty;

                string sysOrderId = viviapi.BLL.Order.Card.Factory.Instance.GenerateOrderId(OrderPrefix);

                string cardStatus = Sell(suppid
                                         , sysOrderId
                                         , 0
                                         , cardno
                                         , cardpass
                                         , this.SysChannelId
                                         , this.money
                                         , out _supporderid
                                         , out supperrinfo);



                InitOrder(sysOrderId
                          , cardStatus == "0" ? 1 : 4
                          , string.Empty
                          , string.Empty
                          , suppid
                          , string.Empty);

                if (cardStatus == "0")
                {
                    error = "0";
                }
                else
                {
                    error = "117";
                }
            }

            Response.Write("errCode=" + error);
            Response.End();
        }
Beispiel #15
0
        /// <summary>
        ///
        /// </summary>
        void ChargeBank()
        {
            string error = string.Empty;

            #region Step1 必要的参数不能为空
            if (string.IsNullOrEmpty(this.parter))
            {
                error = "error:1001 商户ID(P_UserId)不能空!";
            }
            else if (string.IsNullOrEmpty(orderid))
            {
                error = "error:1004 商户订单号(P_OrderId)不能空!";
            }
            else if (string.IsNullOrEmpty(money))
            {
                error = "error:1003 充值金额(P_FaceValue)不能空!";
            }
            else if (string.IsNullOrEmpty(type))
            {
                error = "error:1002 充值类型(P_ChannelId)不能空!";
            }
            else if (string.IsNullOrEmpty(P_Price))
            {
                error = "error:1007 产品价格(P_Price)不能空!";
            }
            else if (string.IsNullOrEmpty(P_Quantity))
            {
                error = "error:1008 产品数量(P_Quantity)不能空!";
            }
            else if (string.IsNullOrEmpty(notifyurl))
            {
                error = "error:1005 充值状态通知地址(P_Result_URL)不能空!";
            }
            else if (string.IsNullOrEmpty(sign))
            {
                error = "error:1006 MD5签名(sign)不能空!";
            }
            #endregion
            #region Step2 检查参数长度
            else if (this.parter.Length > 10)
            {
                error = "error:1020 商户ID(P_UserId)长度超过10位!";
            }
            else if (orderid.Length > 32)
            {
                error = "error:1022 商户订单号(P_OrderId)长度超过32位!";
            }
            else if (money.Length > 8)
            {
                error = "error:1023 订单金额(P_FaceValue)长度超过最长限制!";
            }
            else if (this.notifyurl.Length > 255)
            {
                error = "error:1024 充值状态通知地址(P_Result_URL)长度超过255位!";
            }
            else if (this.returnurl.Length > 255)
            {
                error = "error:1025 充值后网页跳转地址(P_Notify_URL)长度超过255位!";
            }
            else if (this.attach.Length > 255)
            {
                error = "error:1027 用户附加信息(P_Notic)长度超过255位!";
            }
            else if (this.P_Description.Length > 255)
            {
                error = "error:1029 产品描述(P_Description)长度超过255位!";
            }
            else if (this.P_Subject.Length > 50)
            {
                error = "error:1029 产品描述(P_Subject)长度超过50位!";
            }
            else if (this.sign.Length != 32)
            {
                error = "error:1028 签名认证串(sign)长度不正确!";
            }
            #endregion
            #region Step3 格式验证
            else if (!viviLib.Text.Validate.IsNumeric(parter))
            {
                error = "error:1040 商户ID(P_UserId)格式不正确!";
            }
            else if (!viviLib.Text.Validate.IsNumeric(type))
            {
                error = "error:1041 充值类型(P_ChannelId)格式不正确!";
            }
            else if (!checkOrderMoney())
            {
                error = "error:1042 订单金额(P_FaceValue)格式不正确!";
            }
            else if (!checkPrice())
            {
                error = "error:1045 产品价格(P_Price)格式不正确!";
            }
            else if (!checkPQuantity())
            {
                error = "error:1046 产品数量(P_Quantity)格式不正确!";
            }
            else if (!isNotifyUrlOk())
            {
                error = "error:1043 充值状态通知地址(P_Result_URL)格式不正确!";
            }
            else if (!isReturnUrlOk())
            {
                error = "error:1044 充值后网页跳转地址(P_Notify_URL)格式不正确!";
            }
            #endregion
            #region Step4 数据验证
            else if (SysChannelId <= 0)
            {
                error = "error:1067 不存在此支付通道(P_ChannelId)!";
            }
            else if (TranAmt <= 0M)
            {
                error = "error:1060 订单金额(P_FaceValue)有误!";
            }
            else if (TranAmt < this.MinTranAMT)
            {
                error = "error:1061 订单金额(P_FaceValue)小于最小允许交易额!";
            }
            else if (TranAmt > this.MaxChargeAMT)
            {
                error = string.Format("error:1062 订单金额(P_FaceValue){0:f2}大于最大允许交易额{1:f2}!", TranAmt, this.MaxChargeAMT);
            }
            else if (UserInfo == null)
            {
                error = "error:1064 商户(P_UserId)不存在";
            }
            else if (UserInfo.Status != 2)
            {
                error = "error:1065 商户(P_UserId)状态不正常";
            }
            else if (!viviapi.SysInterface.Bank.HuaQi.ReceiveVerify(version, sign, new object[] { this.parter, this.orderid, this.cardno, this.cardpass, this.money, this.type, UserInfo.APIKey }))
            {
                error = "error:1066 签名认证串(P_PostKey)错误!";
            }
            #endregion

            if (string.IsNullOrEmpty(error))
            {
                ChannelTypeInfo chanTypeInfo = viviapi.BLL.Channel.ChannelType.GetCacheModel(this.SysChannelId);
                if (chanTypeInfo == null)
                {
                    error = "error:1068:不存在此支付通道(P_ChannelId)!";
                }
                else if (chanTypeInfo.isOpen == OpenEnum.Close)
                {
                    error = "error:1069:通道(P_ChannelId)维护中!";
                }
            }

            if (!string.IsNullOrEmpty(error))
            {
                #region 处理日志
                if (DebuglogOpen)
                {
                    if (UserInfo != null && UserInfo.isdebug == 1)
                    {
                        var debugInfo = new viviapi.Model.Sys.debuginfo
                        {
                            addtime   = DateTime.Now,
                            bugtype   = viviapi.Model.Sys.debugtypeenum.网银订单,
                            detail    = string.Empty,
                            errorcode = error,
                            errorinfo = error,
                            userid    = UserInfo.ID
                        };
                        debugInfo.url = Request.RawUrl.ToString(CultureInfo.InvariantCulture);

                        viviapi.BLL.Sys.Debuglog.Insert(debugInfo);
                    }
                }

                WebUtility.ShowErrorMsg(error);
                return;

                #endregion
            }
            else
            {
                #region 初始化订单
                var order = new OrderBankInfo
                {
                    orderid       = Factory.Instance.GenerateOrderId(OrderPrefix),
                    addtime       = DateTime.Now,
                    attach        = attach,
                    notifycontext = string.Empty,
                    notifycount   = 0,
                    notifystat    = 0,
                    notifyurl     = this.notifyurl,
                    clientip      = viviLib.Web.ServerVariables.TrueIP,
                    completetime  = DateTime.Now,
                    returnurl     = returnurl,
                    ordertype     = 1,
                    typeId        = SysChannelId,
                    paymodeId     = string.Empty,
                    supplierId    = 0,
                    supplierOrder = string.Empty,
                    userid        = Userid,
                    userorder     = orderid,
                    refervalue    = TranAmt
                };
                //order.payRate = 0M;
                //order.supplierRate = chanelInfo.supprate;
                if (Request.UrlReferrer != null)
                {
                    order.referUrl = Request.UrlReferrer.ToString();
                }
                else
                {
                    order.referUrl = string.Empty;
                }
                order.server   = RuntimeSetting.ServerId;
                order.manageId = UserInfo.manageId;

                order.version         = version;
                order.cus_subject     = this.P_Subject;
                order.cus_price       = this.P_Price;
                order.cus_quantity    = this.P_Quantity;
                order.cus_description = this.P_Description;
                order.cus_field2      = type;

                viviapi.Cache.WebCache.GetCacheService().AddObject(order.orderid, order, ExpiresTime);
                //
                orderBankBLL.Insert(order);
                #endregion

                string redirectUrl = "/SelectBank.aspx?sysorderid=" + order.orderid;
                Response.Redirect(redirectUrl, true);
            }
        }
Beispiel #16
0
        /// <summary>
        ///
        /// </summary>
        private void LoadData()
        {
            DataTable data = viviapi.BLL.Channel.ChannelType.GetList(true).Tables[0];

            //通道类别状态
            if (!data.Columns.Contains("type_status"))
            {
                data.Columns.Add("type_status", typeof(string));
            }

            //系统设置
            if (!data.Columns.Contains("sys_setting"))
            {
                data.Columns.Add("sys_setting", typeof(string));
            }

            //用户前台设置
            if (!data.Columns.Contains("user_setting"))
            {
                data.Columns.Add("user_setting", typeof(string));
            }

            if (!data.Columns.Contains("payrate"))
            {
                data.Columns.Add("payrate", typeof(double));
            }

            if (!data.Columns.Contains("suppid"))
            {
                data.Columns.Add("suppid", typeof(int));
            }



            foreach (DataRow dr in data.Rows)
            {
                int typeId = int.Parse(dr["typeId"].ToString());

                bool type_stutas  = false;
                bool?sys_setting  = null;
                bool?user_setting = null;

                ChannelTypeUserInfo setting  = ChannelTypeUsers.GetModel(UserID, typeId);
                ChannelTypeInfo     typeInfo = ChannelType.GetModelByTypeId(typeId);
                switch (typeInfo.isOpen)
                {
                case OpenEnum.Close:
                case OpenEnum.AllClose:
                    type_stutas = false;
                    break;

                case OpenEnum.Open:
                case OpenEnum.AllOpen:
                    type_stutas = true;
                    break;
                }

                dr["type_status"]  = type_stutas ? "right" : "wrong";
                dr["sys_setting"]  = "Unknown";
                dr["user_setting"] = "Unknown";

                dr["suppid"] = 0;
                if (setting != null)
                {
                    if (setting.sysIsOpen.HasValue)
                    {
                        dr["sys_setting"] = setting.sysIsOpen.Value ? "right" : "wrong";
                    }
                    if (setting.userIsOpen.HasValue)
                    {
                        dr["user_setting"] = setting.userIsOpen.Value ? "right" : "wrong";
                    }
                    if (setting.suppid.HasValue)
                    {
                        dr["suppid"] = setting.suppid.Value;
                    }
                }
                dr["payrate"] = 100 * viviapi.BLL.Finance.PayRate.Instance.GetUserPayRate(this.UserID, Convert.ToInt32(dr["typeId"]));
            }
            rpt_paymode.DataSource = data;
            rpt_paymode.DataBind();
        }