Exemplo n.º 1
0
        public HttpResponseMessage Reissuenotice(List <tblOrdertable> ordertables)
        {
            string result = string.Empty;
            string orid   = "";

            try
            {
                //循环多条订单
                for (int i = 0; i < ordertables.Count; i++)
                {
                    //获得商户的Key
                    RuleCommon rule     = new RuleCommon();
                    DataTable  Merchant = rule.getdt("select *  from tbleMerchant where fldMerchID='" + ordertables[i].fldMerchID + "'");

                    //获得异步通知地址
                    AsynParameterPay asynParameter = new AsynParameterPay();
                    asynParameter.Amount      = ordertables[i].fldOrderAmount.ToString();
                    asynParameter.MerchantId  = ordertables[i].fldMerchID;
                    asynParameter.OrderID     = ordertables[i].fldOrdernum;
                    asynParameter.OrderTime   = ordertables[i].fldchangstautetime.ToString();
                    asynParameter.Paystate    = ordertables[i].fldStaute;
                    asynParameter.Paytype     = ordertables[i].fldRateName.ToString();
                    asynParameter.ProductName = ordertables[i].fldOrederdetailed.ToString();

                    string getpram = JsonHelper.SerializeObject(asynParameter);
                    //json 转换成Dictionary
                    Dictionary <string, string> valuePairs = JsonHelper.DeserializeStringToDictionary <string, string>(getpram);
                    //排序
                    RulePayBehavior behavior = new RulePayBehavior();
                    string          pxrams   = behavior.AsciiDesc(valuePairs);
                    //添加key值
                    pxrams += "key=" + Merchant.Rows[0]["fldSecretKey"].ToString();
                    //md5加密
                    string signkey = behavior.EncryptionMd5(pxrams);

                    asynParameter.Sign = signkey;

                    //转换成json 格式
                    string prams = JsonHelper.SerializeObject(asynParameter);

                    //请求  通知
                    RulePayRequest rulePayRequest = new RulePayRequest();
                    string         rest           = rulePayRequest.PostUrl(ordertables[i].fldNotice.ToString(), prams);
                    if (rest == "ok")
                    {
                        result = "成功" + i + 1;
                    }
                }
                result = rule.JsonStr("ok", "成功", result);
            }
            catch (Exception e)
            {
                //错误保存日志
                throw new InsertException(e.Message, " Ordertable", "Reissuenotice", "补发通知失败,失败订单号:" + orid);
            }
            return(new HttpResponseMessage {
                Content = new StringContent(result, System.Text.Encoding.UTF8, "application/json")
            });
        }
        public HttpResponseMessage testpay(string Amount, string PayType, string key, string MerchantId)
        {
            string result = string.Empty;

            RulePayMethod rulePay = new RulePayMethod();

            payparameter payparameter = new payparameter();

            RulePayBehavior behavior = new RulePayBehavior();



            Dictionary <string, string> keys = new Dictionary <string, string>();

            keys.Add("Amount", Amount);
            keys.Add("MerchantId", "100001");
            keys.Add("Notifyurl", "http://120.78.210.41:8066/actionapi/AcceptInterface/testreq");
            keys.Add("OrderID", "tx" + behavior.ram(1000000));
            keys.Add("OrderTime", DateTime.Now.ToString());
            keys.Add("PayType", PayType);
            keys.Add("ProductName", "小商品");
            string sign = behavior.AsciiDesc(keys);

            sign = sign + "key=" + key;

            sign = behavior.EncryptionMd5(sign);

            payparameter.Amount      = Amount;
            payparameter.MerchantId  = MerchantId;
            payparameter.Notifyurl   = "http://120.78.210.41:8066/actionapi/AcceptInterface/testreq";
            payparameter.OrderID     = keys["OrderID"];
            payparameter.OrderTime   = keys["OrderTime"];
            payparameter.PayType     = PayType;
            payparameter.ProductName = "小商品";
            payparameter.Sign        = sign;
            rerurnpram rerurnpram = rulePay.Islegitimate(payparameter);

            result = rule.JsonStrCode(rerurnpram.statecode, rerurnpram.message, rerurnpram.data, rerurnpram.urlcode);
            return(new HttpResponseMessage {
                Content = new StringContent(result, System.Text.Encoding.UTF8, "application/json")
            });
        }
Exemplo n.º 3
0
        public HttpResponseMessage QueryOrdertable(selectparm reparm)
        {
            try
            {
                string result = "";


                using (YYPlayContext context = new YYPlayContext())
                {
                    DataTable dt = rule.GetQueryDate("", "tbleMerchant", "fldMerchID='" + reparm.MerchID + "'");


                    if (dt.Rows.Count > 0)
                    {
                        //验证签名
                        notsign notsign = new notsign();
                        notsign.MerchID = reparm.MerchID;
                        notsign.OrderID = reparm.OrderID;
                        RulePayBehavior behavior = new RulePayBehavior();


                        //转换成JSON
                        string json = JsonHelper.SerializeObject(notsign);

                        //实体转字典类型
                        Dictionary <string, string> pairs = behavior.ObjectToMap(notsign, false);
                        //排序后的字段
                        string sign = behavior.AsciiDesc(pairs);
                        //加上key值 然后对比
                        sign += "key=" + dt.Rows[0]["fldSecretKey"].ToString();

                        string newsign = behavior.EncryptionMd5(sign);
                        if (newsign != reparm.Sign)
                        {
                            result = rule.JsonStr("error", "验签失败", "");
                            new InsertException(newsign, "Transaction", "GetOrdertableExcelDate", sign);
                        }
                        else
                        {
                            //查询订单表
                            DataTable table = rule.GetQueryDate("", "vwDownOrdertable", " 1=1 and MerchID='" + reparm.MerchID + "' and OrderID='" + reparm.OrderID + "'", "*");
                            if (table.Rows.Count > 0)
                            {
                                result = rule.JsonStr("ok", "查询成功", table);
                            }
                            else
                            {
                                result = rule.JsonStr("error", "查询不到这条订单,请核对订单号和商户号!", "");
                            }
                        }
                    }
                    else
                    {
                        result = rule.JsonStr("error", "商户ID不存在", "");
                    }
                }

                return(new HttpResponseMessage {
                    Content = new StringContent(result, System.Text.Encoding.UTF8, "application/json")
                });
            }
            catch (Exception e)
            {
                throw new InsertException(e.Message, "Transaction", "GetOrdertableExcelDate", "");
            }
        }