Ejemplo n.º 1
0
        /// <summary>
        /// 判断是否登录,及有权限
        /// </summary>
        /// <param name="actionContext"></param>
        /// <returns></returns>
        protected override bool IsAuthorized(HttpActionContext actionContext)
        {
            string ActionName           = actionContext.ActionDescriptor.ActionName;
            string ControllerName       = actionContext.ActionDescriptor.ControllerDescriptor.ControllerName;
            IEnumerable <string> values = null;

            if (actionContext.Request.Headers.TryGetValues("ticket", out values))
            {
                if (values.First().StartsWith("Pay_"))
                {
                    string _Ticket = values.First().Replace("Pay_", "");
                    if (MD51.PwdIsRight(_Ticket, "sz06181102#@!"))
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                //如果获取到
                return(actionContext.IsLogin());
                //判断是否登录
            }
            else
            {
                //如果没有获取到
                return(false);
            }
        }
Ejemplo n.º 2
0
        public AccountBalanceQueryResult accountBalance([FromBody] AccountBalanceQuery query)
        {
            AccountBalanceQueryResult result = new AccountBalanceQueryResult();

            result.balanceFee     = 1000d;
            result.mchCode        = query.mchCode;
            result.mchProductCode = query.mchProductCode;
            result.msg            = "0";
            result.nonceStr       = Guid.NewGuid().ToString().ToLower().Replace("-", "");
            //Md5(mchCode + mchProductCode + nonceStr + status)
            string strSign = query.mchCode + query.mchProductCode + result.nonceStr;

            result.sign = MD51.GetMd5Hash(strSign);
            return(result);
        }
Ejemplo n.º 3
0
        public XiaMengQBiOrderQueryResult orderQuery([FromBody] XiaMengQBiOrderQuery query)
        {
            XiaMengQBiOrderQueryResult result = null;

            if (query == null || string.IsNullOrEmpty(query.transId))
            {
                return(null);
            }

            OrderModel model = DBHelper.GetOrderByID(query.transId);

            if (model != null)
            {
                XiaMengQBiOrder orderEntity = JsonConvert.DeserializeObject <XiaMengQBiOrder>(model.JSON);
                result             = new XiaMengQBiOrderQueryResult();
                result.msg         = model.OrderStatus.ToString();
                result.nonceStr    = Guid.NewGuid().ToString().ToLower().Replace("-", "");
                result.outOrderId  = orderEntity.outOrderId;
                result.rechargeNum = orderEntity.goodsNum;
                //充值结果 0计费失败 1计费成功 2未回报
                if (model.Status == 0)
                {
                    result.rechargeResult = "2";
                }
                else
                {
                    result.rechargeResult = model.OrderStatus.ToString();
                }
                result.userInfo = orderEntity.userName;
                result.result   = "0";
                result.transId  = model.ID.ToString();

                string strSign = orderEntity.mchCode + orderEntity.mchProductCode
                                 + orderEntity.outOrderId + model.ID.ToString() + orderEntity.userName
                                 + result.rechargeNum + result.rechargeResult + result.nonceStr;

                result.sign = MD51.GetMd5Hash(strSign);
            }

            string str = JsonConvert.SerializeObject(result);

            m_Logger.LogInformation($"orderQuery:{str}");

            return(result);
        }
Ejemplo n.º 4
0
        private List <KeyValuePair <string, string> > GetKeyValuePairList(OrderModel model)
        {
            List <KeyValuePair <string, string> > list     = new List <KeyValuePair <string, string> >();
            List <KeyValuePair <string, string> > signList = new List <KeyValuePair <string, string> >();
            XiaMengQBiOrder entity = JsonConvert.DeserializeObject <XiaMengQBiOrder>(model.JSON);

            string value;

            foreach (var key in m_ParamKeyList)
            {
                PropertyInfo p = typeof(XiaMengQBiOrder).GetProperty(key);
                if (p != null)
                {
                    value = p.GetValue(entity)?.ToString();
                    KeyValuePair <string, string> pair = new KeyValuePair <string, string>(key, value);
                    list.Add(pair);
                }
            }
            //sign
            if (!string.IsNullOrEmpty(m_signKeyName))
            {
                string signString = string.Empty;
                foreach (var key in m_SignKeyList)
                {
                    KeyValuePair <string, string> pair = list.Where(m => m.Key == key).FirstOrDefault();

                    if (!String.IsNullOrEmpty(pair.Key))
                    {
                        signString += pair.Value;
                    }
                }
                //Md5(mchCode + mchProductCode + nonceStr + status+key)

                if (!string.IsNullOrEmpty(CurrentOrderTemplateModel.SecretKey))
                {
                    signString += CurrentOrderTemplateModel.SecretKey;
                }
                Console.WriteLine($"prepare post: orderNum:{model.OrderNum} time:{DateTime.Now.ToString()} signRawValue:{signString}");
                string signValue = MD51.GetMd5Hash(signString);
                KeyValuePair <string, string> p1 = new KeyValuePair <string, string>(m_signKeyName, signValue);
                list.Add(p1);
            }
            return(list);
        }