private string pay(HttpContext context)
        {
            try
            {
                string openid   = context.Request["openid"];
                string ids      = context.Request["ids"];
                string quantity = context.Request["quantity"];

                string macNum  = ms.getMacNum(ids);
                int    biaoNum = ms.getMacBiao(macNum);

                if (string.IsNullOrEmpty(ids) || string.IsNullOrEmpty(quantity))
                {
                    return("必要参数为空");
                }

                string json = "{ids:\"" + ids + "\",quantity:\"" + quantity + "\"}";

                int price = 1;

                DataTable dt = ms.getDeposit();
                if (dt != null)
                {
                    price = Convert.ToInt32(dt.Rows[0]["biaoMoney"]) * biaoNum + Convert.ToInt32(dt.Rows[0]["gameMoney"]) * Convert.ToInt32(quantity);
                }

                ms.makeLog("pay()方法:biaoNum," + biaoNum + "macNum," + macNum);

                Random      rand  = new Random();
                int         num   = rand.Next(1000, 9999);
                Parameteres param = new Parameteres();
                param.Total_fee = price.ToString();     //总金额有问题
                string orderno = DateTime.Now.ToString("yyyyMMddHHmmss") + num;
                param.Out_trade_no = orderno;
                param.Attach       = json;
                string canshu    = GetUnifiedOrderParam(openid, param);
                string payResXML = Helper.ordinaryPost("https://api.mch.weixin.qq.com/pay/unifiedorder", canshu);
                var    payRes    = XDocument.Parse(payResXML);
                var    root      = payRes.Element("xml");

                //序列化相应参数返回给小程序
                var    res     = GetPayRequestParam(root, param.Appid, param.Key);
                string strJson = JsonConvert.SerializeObject(res);
                return(strJson);
            }
            catch (Exception ex)
            {
                return(ex.ToString());
            }
        }
        /// <summary>
        /// 返回给微信的押金和游戏金额的接口
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        private string getDeposit(HttpContext context)
        {
            string macNum = context.Request["macNum"];

            if (string.IsNullOrEmpty(macNum))
            {
                Deposit   jsonResult = new Deposit();
                DataTable dt         = ms.getDeposit();
                if (dt != null && dt.Rows.Count > 0)
                {
                    double biaoMoney = Convert.ToDouble(dt.Rows[0]["biaoMoney"]) / 100;
                    double gameMoney = Convert.ToDouble(dt.Rows[0]["gameMoney"]) / 100;
                    jsonResult.Success      = true;
                    jsonResult.GameMoney    = gameMoney.ToString();
                    jsonResult.DepositMoney = biaoMoney.ToString();
                    jsonResult.TotalMoney   = (gameMoney + biaoMoney).ToString();
                }
                else
                {
                    jsonResult.Success = false;
                }
                string strJson = JsonConvert.SerializeObject(jsonResult);
                return(strJson);
            }
            else
            {
                Deposit   jsonResult = new Deposit();
                DataTable dt         = ms.getDeposit();
                int       biaoNum    = ms.getMacBiao(macNum);
                biaoNum = biaoNum > 0 ? biaoNum : 1;
                if (dt != null && dt.Rows.Count > 0)
                {
                    double gameMoney    = Convert.ToDouble(dt.Rows[0]["gameMoney"]) / 100;
                    double depositMoney = Convert.ToDouble(dt.Rows[0]["biaoMoney"]) / 100 * biaoNum;
                    jsonResult.Success      = true;
                    jsonResult.GameMoney    = gameMoney.ToString();         //游戏费用
                    jsonResult.DepositMoney = depositMoney.ToString();      //押金
                    jsonResult.TotalMoney   = (gameMoney + depositMoney).ToString();
                }
                else
                {
                    jsonResult.Success = false;
                }
                string strJson = JsonConvert.SerializeObject(jsonResult);
                return(strJson);
            }
        }