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")
            });
        }
Exemplo n.º 2
0
        /// <summary>
        /// 功能描述:支付线程
        /// </summary>
        /// <param name="MerchantId">商户ID</param>
        /// <param name="order_no">订单号</param>
        /// <param name="order_amount">金额</param>
        /// <param name="order_time">订单创建时间</param>
        /// <param name="pay_type">支付方式</param>
        /// <param name="product_name">商品描述</param>
        /// <param name="fldNotice">异步通知地址</param>
        /// <param name="key">商户key值</param>

        public static void myThread(string MerchantId, string order_no, string order_amount, string order_time, string pay_type, string product_name, string fldNotice, string key)
        {
            TimerExampleState s = new TimerExampleState();

            s.fldNotice = fldNotice;

            AsynParameterPay asyn = new AsynParameterPay();

            asyn.MerchantId  = MerchantId;
            asyn.OrderID     = order_no;
            asyn.Amount      = order_amount;
            asyn.OrderTime   = order_time;
            asyn.Paytype     = pay_type;
            asyn.ProductName = product_name;
            asyn.Paystate    = "支付成功";

            string getpram = JsonHelper.SerializeObject(asyn);
            //json 转换成Dictionary
            Dictionary <string, string> valuePairs = JsonHelper.DeserializeStringToDictionary <string, string>(getpram);
            //排序
            RulePayBehavior behavior = new RulePayBehavior();
            string          sign     = behavior.AsciiDesc(valuePairs);

            //添加key值
            sign += "key=" + key;
            //md5加密
            string signkey = behavior.EncryptionMd5(sign);

            asyn.Sign = signkey;

            //装换成json
            s.pram = JsonHelper.SerializeObject(asyn);

            //创建代理对象TimerCallback,该代理将被定时调用
            TimerCallback timerDelegate = new TimerCallback(Request);
            //创建一个时间间隔为5m的定时器
            Timer timer = new Timer(timerDelegate, s, 5 * 60 * 1000, 5 * 60 * 1000);

            s.tmr = timer;
            //主线程停下来等待Timer对象的终止
            while (s.tmr != null)
            {
                Thread.Sleep(1000);
            }
        }