Exemplo n.º 1
0
        public HttpResponseMessage Resetpaypassword(string marehid)
        {
            string result = string.Empty;

            try
            {
                using (YYPlayContext db = new YYPlayContext())
                {
                    RulePayBehavior rulePay = new RulePayBehavior();
                    tbleMerchant    info    = (from c in db.tbleMerchant
                                               where c.fldMerchID == marehid
                                               select c).Single();
                    info.fldPayPass = rulePay.EncryptionMd5(DateTime.Now.Year + info.fldIdCare.Substring(info.fldIdCare.Length - 6, 6), "x2"); //身份证后6位,为初始密码
                    int ret = db.SaveChanges();
                    if (ret < 0)
                    {
                        result = rule.JsonStr("error", "重置失败!", ret);
                    }
                    else
                    {
                        result = rule.JsonStr("ok", "", ret);
                    }
                }
            }
            catch (Exception e)
            {
                result = rule.JsonStr("error", e.Message, "");
            }
            return(new HttpResponseMessage {
                Content = new StringContent(result, System.Text.Encoding.UTF8, "application/json")
            });
        }
Exemplo n.º 2
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.º 4
0
        public HttpResponseMessage AddDMerchantList(pram tbleMerchantpram)
        {
            string result = string.Empty;

            try
            {
                using (YYPlayContext db = new YYPlayContext())
                {
                    RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();

                    Random random = new Random();
                    string nowid  = "100" + random.Next(100, 1000);;

                    tbleMerchant maxid = (from x in db.tbleMerchant
                                          orderby x.fldMerchID descending
                                          select x).FirstOrDefault();

                    RulePayBehavior rulePay      = new RulePayBehavior();
                    string          fldSecretKey = Guid.NewGuid().ToString("N").ToUpper();
                    tbleMerchant    info         = new tbleMerchant();
                    info.fldMerchID    = nowid.ToString();//当前时间加上身份证后四位组成商户ID
                    info.fldMerchName  = tbleMerchantpram.fldMerchName;
                    info.fldCreateTime = DateTime.Now;
                    info.fldIdCare     = tbleMerchantpram.fldIdCare;
                    info.fldIPaddress  = tbleMerchantpram.fldIPaddress;
                    info.fldMaPass     = rulePay.EncryptionMd5(tbleMerchantpram.fldIdCare.Substring(tbleMerchantpram.fldIdCare.Length - 6, 6), "x2");//身份证后6位,为初始密码
                    info.fldPhone      = tbleMerchantpram.fldPhone;
                    info.fldRemark     = "";
                    info.fldPayPass    = rulePay.EncryptionMd5(DateTime.Now.Year + tbleMerchantpram.fldIdCare.Substring(tbleMerchantpram.fldIdCare.Length - 6, 6), "x2");
                    info.fldContacts   = tbleMerchantpram.fldContacts;
                    info.fldAgent      = tbleMerchantpram.fldAgent;
                    info.fldSecretKey  = fldSecretKey;

                    db.tbleMerchant.Add(info);
                    int ret = db.SaveChanges();
                    if (ret <= 0)
                    {
                        result = rule.JsonStr("error", "添加失败!", ret);
                    }
                    else
                    {
                        int       count = 0;
                        DataTable dt    = rule.getpaging("tbleMerchant", "[fldAutoID],[fldMerchID],[fldMerchName],[fldContacts],[fldPhone],[fldCreateTime],[fldIPaddress],[fldIdCare],[fldAgent],[fldRemark],fldisstand", "1=1" + tbleMerchantpram.where, tbleMerchantpram.page, tbleMerchantpram.limit, tbleMerchantpram.sort, out count);

                        getdata getdatas = new getdata();
                        getdatas.total = count;
                        getdatas.Table = dt;
                        //查询所有的数据  用于前端筛选
                        List <tbleMerchant> tbleMerchants = (from x in db.tbleMerchant select x).ToList();
                        getdatas.tbleMerchants = tbleMerchants;
                        result = rule.JsonStr("ok", "", getdatas);
                    }
                }
            }
            catch (Exception e)
            {
                result = rule.JsonStr("error", e.Message, "");
            }
            return(new HttpResponseMessage {
                Content = new StringContent(result, System.Text.Encoding.UTF8, "application/json")
            });
        }
Exemplo n.º 5
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", "");
            }
        }