Exemplo n.º 1
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);
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
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);
        }