Пример #1
0
        /// <summary>
        /// 微信公众号支付
        /// </summary>
        /// <param name="pi"></param>
        /// <param name="ma"></param>
        private void Weixinpubpay(Song.Entities.PayInterface pi, Song.Entities.MoneyAccount ma)
        {
            string host = System.Web.HttpContext.Current.Request.Url.Host + ":" + WeiSha.Common.Server.Port + "/";

            if (!string.IsNullOrWhiteSpace(pi.Pai_Returl))
            {
                host = pi.Pai_Returl;
            }
            if (!host.EndsWith("/"))
            {
                host += "/";
            }
            //构造网页授权获取code的URL
            string path = "Pay/Weixin/PublicPay.aspx";
            //System.Web.HttpContext.Current.Response.Write(host + path);
            string redirect_uri = HttpUtility.UrlEncode(host + path.ToLower());

            WxPayAPI.WxPayData data = new WxPayAPI.WxPayData();
            data.SetValue("appid", pi.Pai_ParterID);
            data.SetValue("redirect_uri", redirect_uri);
            data.SetValue("response_type", "code");
            data.SetValue("scope", "snsapi_base");
            //返回的状态值,接口id、流水号
            string state = "pi:{0},serial:{1}";

            state = string.Format(state, pi.Pai_ID, ma.Ma_Serial);
            data.SetValue("state", state + "#wechat_redirect");
            string url = "https://open.weixin.qq.com/connect/oauth2/authorize?" + data.ToUrl();

            System.Web.HttpContext.Current.Response.Redirect(url);
        }
Пример #2
0
 private void ResponseWrite(bool isSuccess, string msg)
 {
     WxPayAPI.WxPayData res = new WxPayAPI.WxPayData();
     res.SetValue("return_code", isSuccess ? "SUCCESS" : "FAIL");
     res.SetValue("return_msg", msg);
     base.Response.Write(res.ToXml());
     base.Response.End();
 }
Пример #3
0
        /**
         * 调用统一下单,获得下单结果
         * @return 统一下单结果
         * @失败时抛异常WxPayException
         */
        public WxPayAPI.WxPayData GetUnifiedOrderResult(decimal total_fee, string openid, string out_trade_no)
        {
            //统一下单
            WxPayAPI.WxPayData data = new WxPayAPI.WxPayData();
            data.SetValue("body", "四川红领巾少儿艺术团-报名活动");
            data.SetValue("attach", "test");
            data.SetValue("out_trade_no", out_trade_no);
            data.SetValue("total_fee", Convert.ToInt32(total_fee * 100));
            data.SetValue("time_start", DateTime.Now.ToString("yyyyMMddHHmmss"));
            data.SetValue("time_expire", DateTime.Now.AddMinutes(10).ToString("yyyyMMddHHmmss"));
            data.SetValue("goods_tag", "test");
            data.SetValue("trade_type", "JSAPI");
            data.SetValue("openid", openid);

            Log.WriteLog("GetUnifiedOrderResult!" + total_fee);

            WxPayAPI.WxPayData result = WxPayAPI.WxPayApi.UnifiedOrder(data);
            if (!result.IsSet("appid") || !result.IsSet("prepay_id") || result.GetValue("prepay_id").ToString() == "")
            {
                Log.WriteLog("UnifiedOrder response error!");
                throw new WxPayException("UnifiedOrder response error!");
            }

            Log.WriteLog("GetUnified77777");
            unifiedOrderResult = result;
            return(result);
        }
Пример #4
0
        /// <summary>
        /// 接收从微信支付后台发送过来的数据并验证签名
        /// </summary>
        /// <returns>微信支付后台返回的数据</returns>
        public WxPayAPI.WxPayData GetNotifyData()
        {
            string builder = Common.ReadStream2String(Request.Body);

            Log.WriteLog("weixin:" + builder);

            /*
             * //接收从微信后台POST过来的数据
             * System.IO.Stream s = Request.Body;
             *
             * int count = 0;
             * byte[] buffer = new byte[1024];
             * StringBuilder builder = new StringBuilder();
             * while ((count = s.Read(buffer, 0, 1024)) > 0)
             * {
             *  builder.Append(Encoding.UTF8.GetString(buffer, 0, count));
             * }
             * s.Flush();
             * s.Close();
             * s.Dispose();*/

            Log.WriteLog("GetNotifyData:" + builder.ToString());

            //转换数据格式并验证签名
            WxPayAPI.WxPayData data = new WxPayAPI.WxPayData();
            try
            {
                Log.WriteLog(builder.ToString());
                data.FromXml(builder.ToString());
            }
            catch (WxPayAPI.WxPayException ex)
            {
                //若签名错误,则立即返回结果给微信支付后台
                WxPayAPI.WxPayData res = new WxPayAPI.WxPayData();
                res.SetValue("return_code", "FAIL");
                res.SetValue("return_msg", ex.Message);
                Response.WriteAsync(res.ToXml());

                Log.WriteLog("GetNotifyData:" + ex.Message);
            }

            return(data);
        }
Пример #5
0
        //修改订单信息
        public void SuccOrder()
        {
            WxPayAPI.WxPayData res = new WxPayAPI.WxPayData();
            try
            {
                Log.WriteLog("SuccOrder:开始了");
                WxPayAPI.WxPayData notifyData   = GetNotifyData();
                string             out_trade_no = notifyData.GetValue("out_trade_no").ToString();

                Log.WriteLog("SuccOrder:" + out_trade_no);
                //查询订单,判断订单真实性
                if (!string.IsNullOrEmpty(out_trade_no))
                {
                    Order order = db.Orders.FirstOrDefault(c => c.Payno == out_trade_no);
                    if (order != null)
                    {
                        order.Status  = 1;
                        order.PayTime = DateTime.Now;
                        db.Orders.Update(order);
                        if (db.SaveChanges() > 0)
                        {
                            Log.WriteLog("SuccOrder:Status");

                            var active = db.Actives.Find(order.ActiveId);
                            active.Count++;
                            db.Actives.Update(active);
                            db.SaveChanges();

                            res.SetValue("return_code", "SUCCESS");
                            res.SetValue("return_msg", "OK");
                            Response.WriteAsync(res.ToXml());
                            Log.WriteLog("SuccOrder:SUCCESS");
                        }
                    }
                    else
                    {
                        Log.WriteLog("SuccOrder:订单查询失败");
                        res.SetValue("return_code", "FAIL");
                        res.SetValue("return_msg", "订单查询失败");
                        Response.WriteAsync(res.ToXml());
                    }
                }
            }
            catch (Exception e)
            {
                //打印日志
                Log.WriteLog("SuccOrder:Message=" + e.Message);
                res.SetValue("return_code", "FAIL");
                res.SetValue("return_msg", e.Message);
                Response.WriteAsync(res.ToXml());
            }
        }
Пример #6
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         OrderNo = HotelCloud.Common.HCRequest.GetString("OrderNo").ToUpper().Trim();
         if (!string.IsNullOrEmpty(OrderNo))
         {
             if (OrderNo.Contains("C"))
             {
                 var dt = HotelCloud.SqlServer.SQLHelper.Get_DataTable(@"select top 1 * from WeiXin..RechargeUser where OrderNo=@OrderNo", HotelCloud.SqlServer.SQLHelper.GetCon(), new Dictionary <string, HotelCloud.SqlServer.DBParam> {
                     { "OrderNo", new HotelCloud.SqlServer.DBParam {
                           ParamValue = OrderNo
                       } }
                 });
                 if (dt.Rows.Count > 0)
                 {
                     foreach (System.Data.DataRow dr in dt.Rows)
                     {
                         int OrderAmount = Convert.ToInt32(Convert.ToDecimal(dr["SPrice"].ToString()) * 1);
                         OrderRoom = "充值扣款";
                         total_fee = OrderAmount.ToString();
                     }
                 }
             }
             else if (OrderNo.Contains("K"))
             {
                 var dt = HotelCloud.SqlServer.SQLHelper.Get_DataTable(@"select top 1 * from WeiXin..MemberCardBuyRecord where OrderNo=@OrderNo", HotelCloud.SqlServer.SQLHelper.GetCon(), new Dictionary <string, HotelCloud.SqlServer.DBParam> {
                     { "OrderNo", new HotelCloud.SqlServer.DBParam {
                           ParamValue = OrderNo
                       } }
                 });
                 if (dt.Rows.Count > 0)
                 {
                     foreach (System.Data.DataRow dr in dt.Rows)
                     {
                         int OrderAmount = Convert.ToInt32(Convert.ToDecimal(dr["BuyMoney"].ToString()) * 1);
                         OrderRoom = "会员卡购买";
                         total_fee = OrderAmount.ToString();
                     }
                 }
             }
             else if (OrderNo.Contains("D"))
             {
                 var dt = HotelCloud.SqlServer.SQLHelper.Get_DataTable(@"select top 1 *  from WeiXin..SupermarketOrder_Levi where OrderId=@OrderId", HotelCloud.SqlServer.SQLHelper.GetCon(), new Dictionary <string, HotelCloud.SqlServer.DBParam> {
                     { "OrderId", new HotelCloud.SqlServer.DBParam {
                           ParamValue = OrderNo.Trim()
                       } }
                 });
                 if (dt.Rows.Count > 0)
                 {
                     foreach (System.Data.DataRow dr in dt.Rows)
                     {
                         int OrderAmount = Convert.ToInt32(Convert.ToDecimal(dr["Money"].ToString()) * 1);
                         OrderRoom = "酒店周边超市消费";
                         total_fee = OrderAmount.ToString();
                     }
                 }
             }
             else if (OrderNo.Contains("P"))
             {
                 var dt = HotelCloud.SqlServer.SQLHelper.Get_DataTable(@"select top 1 * from WeiXin..SaleProducts_Orders where OrderNo=@OrderNo", HotelCloud.SqlServer.SQLHelper.GetCon(), new Dictionary <string, HotelCloud.SqlServer.DBParam> {
                     { "OrderNo", new HotelCloud.SqlServer.DBParam {
                           ParamValue = OrderNo
                       } }
                 });
                 if (dt.Rows.Count > 0)
                 {
                     foreach (System.Data.DataRow dr in dt.Rows)
                     {
                         int OrderAmount = Convert.ToInt32(Convert.ToDecimal(dr["OrderMoney"].ToString()) * 1);
                         OrderRoom = dr["ProductName"].ToString().Trim() + "[" + dr["TcName"].ToString().Trim() + "]";
                         total_fee = OrderAmount.ToString();
                     }
                 }
             }
             else if (OrderNo.Contains("L"))
             {
                 var dt = HotelCloud.SqlServer.SQLHelper.Get_DataTable(@"select top 1 bagging,amount,youhuiamount,hotelid,userweixinid,hotelWeixinId,orderCode,(select sum(AliPayAmount) from  WeiXin..wkn_payrecords where OrderNO=orderCode and Channel='微信支付回调') as zhifu  from WeiXin..T_OrderInfo where orderCode=@orderCode", HotelCloud.SqlServer.SQLHelper.GetCon(), new Dictionary <string, HotelCloud.SqlServer.DBParam> {
                     { "orderCode", new HotelCloud.SqlServer.DBParam {
                           ParamValue = OrderNo.Trim()
                       } }
                 });
                 if (dt.Rows.Count > 0)
                 {
                     foreach (System.Data.DataRow dr in dt.Rows)
                     {
                         string bagging      = dr["bagging"].ToString();
                         string youhuiamount = dr["youhuiamount"].ToString();
                         if (string.IsNullOrEmpty(bagging))
                         {
                             bagging = "0";
                         }
                         if (string.IsNullOrEmpty(youhuiamount))
                         {
                             youhuiamount = "0";
                         }
                         int OrderAmount = Convert.ToInt32((Convert.ToDecimal(dr["amount"].ToString()) - Convert.ToDecimal(youhuiamount) + Convert.ToDecimal(bagging)) * 1);
                         OrderRoom = "酒店周边餐饮消费";
                         total_fee = OrderAmount.ToString();
                     }
                 }
             }
             else
             {
                 hotel3g.Repository.Order order = hotel3g.Repository.OrderRepository.GetOrderInfo(OrderNo.Trim());
                 OrderRoom = order.RoomName + "[" + order.RatePlanName + "]";
                 total_fee = order.OrderAmount.ToString();
                 url       = string.Format("http://hotel.weikeniu.com/Hotel/Index/{0}?key={1}@{2}", order.HotelID.ToString(), order.WeiXinID.ToString(), order.UserWeiXinID.ToString());
             }
         }
         if (HotelCloud.Common.HCRequest.GetString("action") == "code")
         {
             WxPayAPI.NativePay np = new WxPayAPI.NativePay();
             /** ================得到长连接========= */
             string             long_url = np.GetPrePayUrl(HotelCloud.Common.HCRequest.GetString("OrderNo"));
             WxPayAPI.WxPayData data     = new WxPayAPI.WxPayData();
             data.SetValue("long_url", long_url);
             /** ================减小二维码数据量,提升扫描速度和精确度========= */
             WxPayAPI.WxPayData Result = WxPayAPI.WxPayApi.ShortUrl(data, 6);
             if (Result != null)
             {
                 if (Result.GetValue("return_code").ToString() == "SUCCESS")
                 {
                     string ShortUrl = Result.GetValue("short_url").ToString();
                     WxPayAPI.Log.Debug("WxPayApi", "ShortUrl  : " + long_url);
                     Response.Write(CreateCode_Choose(ShortUrl, "Byte", "M", 8, 4));
                 }
             }
             Response.End();
         }
     }
 }
Пример #7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (!string.IsNullOrEmpty(HotelCloud.Common.HCRequest.GetString("state").Trim()))
                {
                    state = HotelCloud.Common.HCRequest.GetString("state").Trim();
                    code  = HotelCloud.Common.HCRequest.GetString("code").Trim();
                    type  = state.Split('|')[1].ToString();                              //对应类型
                    hid   = Regex.Replace(state.Split('|')[0].ToUpper(), @"[^\d]*", ""); //对应酒店id
                    var dt = HotelCloud.SqlServer.SQLHelper.Get_DataTable(@"select top 1 hotel.WeiXinID,SubName,hotelLog,hotel.address,hotel.id,appkey,appid,MCHID,iszhifu  from WeiXin..hotel with(nolock)  inner join WeiXin..WeiXinNO with(nolock)  on WeiXinNO.WeiXinID=hotel.WeiXinID  where hotel.id=@id and hotel.enabled=1", HotelCloud.SqlServer.SQLHelper.GetCon(), new Dictionary <string, HotelCloud.SqlServer.DBParam> {
                        { "id", new HotelCloud.SqlServer.DBParam {
                              ParamValue = hid.Trim()
                          } }
                    });
                    if (dt.Rows.Count > 0)
                    {
                        foreach (System.Data.DataRow dr in dt.Rows)
                        {
                            subname  = dr["SubName"].ToString().Trim();
                            WeiXinID = dr["WeiXinID"].ToString().Trim();
                        }
                    }
                }
                /** ================客人实时付款微信下单操作========= */
                if (HotelCloud.Common.HCRequest.GetString("state") != "" && !string.IsNullOrEmpty(HotelCloud.Common.HCRequest.GetString("price")))
                {
                    System.Web.Script.Serialization.JavaScriptSerializer js = new System.Web.Script.Serialization.JavaScriptSerializer();
                    string result = js.Serialize(new { status = false, msg = "非法操作" });
                    try
                    {
                        WeiXinID = HotelCloud.Common.HCRequest.GetString("weixinid");
                        hid      = HotelCloud.Common.HCRequest.GetString("hid");
                        if (HotelCloud.Common.HCRequest.GetString("type").Trim().ToString() == "0") //表示客房消费操作
                        {
                            var dty = HotelCloud.SqlServer.SQLHelper.Get_DataTable(@"select top 1 appkey,appid,MCHID from WeiXin..WeiXinNO with(nolock)  where WeiXinID=@WeiXinID and iszhifu=1", HotelCloud.SqlServer.SQLHelper.GetCon(), new Dictionary <string, HotelCloud.SqlServer.DBParam> {
                                { "WeiXinID", new HotelCloud.SqlServer.DBParam {
                                      ParamValue = WeiXinID.Trim()
                                  } }
                            });
                            if (dty.Rows.Count > 0)
                            {
                                foreach (System.Data.DataRow dry in dty.Rows)
                                {
                                    appid  = dry["appid"].ToString().Trim();
                                    secret = dry["appkey"].ToString().Trim();
                                    mchid  = dry["MCHID"].ToString().Trim();
                                }
                            }
                        }
                        hotel3g.Models.Cookies.SetCookies("tb1", WxPayAPI.WxPayConfig.Encrypt(appid), 1, "wx");
                        hotel3g.Models.Cookies.SetCookies("tb2", WxPayAPI.WxPayConfig.Encrypt(secret), 1, "wx");
                        hotel3g.Models.Cookies.SetCookies("tb3", WxPayAPI.WxPayConfig.Encrypt(mchid), 1, "wx");
                        openid = "";

                        /** ================二次付款的相关问题==== */
                        if (string.IsNullOrEmpty(openid) && Session["openid"] != null)
                        {
                            openid = Session["openid"].ToString();
                        }

                        /** ================获取公众号对应的用户openid=====这里会存在多次获去openid的情况 但是实际上这个是不被允许的==== */
                        if (string.IsNullOrEmpty(openid))
                        {
                            var    checkTokenUrl = string.Format("https://api.weixin.qq.com/sns/oauth2/access_token?appid={0}&secret={1}&code={2}&grant_type=authorization_code", appid, secret, HotelCloud.Common.HCRequest.GetString("code"));
                            string CReturnJson   = HotelHotel.Utility.HttpWebResponseUtility.Get(checkTokenUrl);
                            WxPayAPI.Log.Debug("获取openid".ToString(), CReturnJson);
                            wxcheckTokenUrl m = Newtonsoft.Json.JsonConvert.DeserializeObject <wxcheckTokenUrl>(CReturnJson);
                            if (m != null)
                            {
                                openid = m.openid;
                            }
                            Session["openid"] = openid.Trim();
                        }
                        if (!string.IsNullOrEmpty(openid))
                        {
                            try
                            {
                                System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls;
                                WebClient    Client = new WebClient();
                                string       json   = Client.DownloadString(string.Format("http://www.weikeniu.com/WeixinFeatures/getGetTokenResult.ashx?appid={0}", appid)).Replace("\\", "").Replace("\"{", "{").Replace("}\"", "}");
                                tAccessToken token  = Newtonsoft.Json.JsonConvert.DeserializeObject <tAccessToken>(json);
                                if (token.error == 1)
                                {
                                    string url     = string.Format("https://api.weixin.qq.com/cgi-bin/user/info?access_token={0}&openid={1}&lang=zh_CN", token.message.ToString(), openid);
                                    string result1 = HotelHotel.Utility.HttpWebResponseUtility.Get(url);
                                    WxPayAPI.Log.Debug("获取用户基本信息", result1.ToString());
                                    Newtonsoft.Json.Linq.JObject outputObj1 = Newtonsoft.Json.Linq.JObject.Parse(result1);
                                    if (outputObj1 != null)
                                    {
                                        /** ================微信收银台 记录对应的客人信息 便于收银台展示对应的客人信息========= */
                                        Nickname = outputObj1["nickname"].ToString();
                                        var dw = HotelCloud.SqlServer.SQLHelper.Get_DataTable(string.Format("select  * from  WeiXin..wkn_unionmember with(nolock) where openid='{0}'", outputObj1["openid"].ToString().Trim('"')), HotelCloud.SqlServer.SQLHelper.Open_Conn(System.Configuration.ConfigurationManager.ConnectionStrings["sqlserver"].ConnectionString.ToString()), null);
                                        if (dw.Rows.Count < 1)
                                        {
                                            HotelCloud.SqlServer.SQLHelper.Run_SQL("insert into WeiXin..wkn_unionmember(openid,nickname,city,province,headimgurl,subscribe_time) values (@openid,@nickname,@city,@province,@headimgurl,@subscribe_time)", HotelCloud.SqlServer.SQLHelper.Open_Conn(System.Configuration.ConfigurationManager.ConnectionStrings["sqlserver"].ConnectionString.ToString()), new Dictionary <string, HotelCloud.SqlServer.DBParam> {
                                                { "openid", new HotelCloud.SqlServer.DBParam {
                                                      ParamValue = outputObj1["openid"].ToString().Trim('"')
                                                  } },
                                                { "nickname", new HotelCloud.SqlServer.DBParam {
                                                      ParamValue = outputObj1["nickname"].ToString().Trim('"')
                                                  } },
                                                { "city", new HotelCloud.SqlServer.DBParam {
                                                      ParamValue = outputObj1["city"].ToString().Trim('"')
                                                  } },
                                                { "province", new HotelCloud.SqlServer.DBParam {
                                                      ParamValue = outputObj1["province"].ToString().Trim('"')
                                                  } },
                                                { "headimgurl", new HotelCloud.SqlServer.DBParam {
                                                      ParamValue = outputObj1["headimgurl"].ToString().Trim('"')
                                                  } },
                                                { "subscribe_time", new HotelCloud.SqlServer.DBParam {
                                                      ParamValue = outputObj1["subscribe_time"].ToString()
                                                  } }
                                            });
                                        }
                                    }
                                }
                            }
                            catch (Exception ex)
                            {
                                WxPayAPI.Log.Debug("获取用户基本信息", ex.Message.ToString());
                            }
                            finally
                            {
                            }
                        }
                        string pay_type = HotelCloud.Common.HCRequest.GetString("type");
                        if (string.IsNullOrEmpty(pay_type))
                        {
                            pay_type = "0";
                        }
                        int total_fee = Convert.ToInt32((Convert.ToDecimal(HotelCloud.Common.HCRequest.GetString("price")) * 100));

                        //主要是下单时需要openid>>静默获去到》》但是这样是需要code>>但是就是存在跳转的问题

                        string             OrderNo = "wx" + DateTime.Now.ToString("yyMMddHHmmss") + new Random().Next(100, 0x3e7);
                        WxPayAPI.WxPayData data    = new WxPayAPI.WxPayData();
                        data.SetValue("body", HotelCloud.Common.HCRequest.GetString("hname"));
                        data.SetValue("attach", hid + "|" + WeiXinID + "|" + pay_type);
                        data.SetValue("out_trade_no", OrderNo);
                        data.SetValue("total_fee", total_fee);
                        data.SetValue("time_start", DateTime.Now.ToString("yyyyMMddHHmmss"));
                        data.SetValue("time_expire", DateTime.Now.AddMinutes(10).ToString("yyyyMMddHHmmss"));
                        data.SetValue("goods_tag", "门店销售");
                        data.SetValue("trade_type", "JSAPI");
                        data.SetValue("openid", openid);
                        WxPayAPI.JsApiPay jsApiPay = new WxPayAPI.JsApiPay();
                        jsApiPay.openid    = openid;
                        jsApiPay.total_fee = total_fee;
                        WxPayAPI.WxPayData unifiedOrderResult = jsApiPay.GetUnifiedOrderResult(data);
                        result = js.Serialize(new { status = true, msg = "统一下单成功", signature = jsApiPay.GetJsApiParameters(), TradeNo = OrderNo });

                        //需要保留对应的表数据wkn_quickpayment相关数据
                        string sql = "insert into WeiXin..wkn_quickpayment (WeiXinID,OrderNo,ConsumptionType,ConsumptionContent,OtherRemarks,PaymentStatus,AliPayAmount) values(@WeiXinID,@OrderNo,@ConsumptionType,@ConsumptionContent,@OtherRemarks,'未支付',@AliPayAmount)";
                        int    drt = HotelCloud.SqlServer.SQLHelper.Run_SQL(sql, HotelCloud.SqlServer.SQLHelper.GetCon(), new Dictionary <string, HotelCloud.SqlServer.DBParam> {
                            { "ConsumptionType", new HotelCloud.SqlServer.DBParam {
                                  ParamValue = pay_type.ToString()
                              } },
                            { "ConsumptionContent", new HotelCloud.SqlServer.DBParam {
                                  ParamValue = HotelCloud.Common.HCRequest.GetString("subContent")
                              } },
                            { "OtherRemarks", new HotelCloud.SqlServer.DBParam {
                                  ParamValue = ""
                              } },
                            { "WeiXinID", new HotelCloud.SqlServer.DBParam {
                                  ParamValue = WeiXinID.ToString()
                              } },
                            { "AliPayAmount", new HotelCloud.SqlServer.DBParam {
                                  ParamValue = total_fee.ToString()
                              } },
                            { "OrderNo", new HotelCloud.SqlServer.DBParam {
                                  ParamValue = OrderNo.ToString()
                              } }
                        });
                        WxPayAPI.Log.Debug("Fastcollection", result.ToString());
                    }
                    catch (Exception ex)
                    {
                        result = js.Serialize(new { status = false, msg = "支付失败" });
                        WxPayAPI.Log.Debug("Fastcollection", ex.Message.ToString());
                    }
                    finally
                    {
                        Response.Write(Newtonsoft.Json.JsonConvert.SerializeObject(result));
                        Response.End();
                    }
                }
            }
        }
Пример #8
0
        /// <summary>
        /// DEMO
        /// </summary>
        public string DemoSubmit()
        {
            //WxPayAPI.dll是用提官方dll 可自行下载c#编译源码
            //如果遇到技术问题进群沟通
            //QQ群:771207642
            //https://pay.weixin.qq.com/wiki/doc/api/micropay_sl.php?chapter=11_1

            Lib.Config.MchId     = "商户号";
            Lib.Config.CertPath  = "";
            Lib.Config.CertPwd   = "";
            Lib.Config.Serial_no = "";



            //使用前先配置上面的参数
            WxPayAPI.WxPayData inputObj = new WxPayAPI.WxPayData();

            inputObj.SetValue("business_code", ""); // //业务申请编号
            inputObj.SetValue("bank_name", "");     // //开户银行全称(含支行)
            inputObj.SetValue("account_bank", "");  // //开户银行

            //https://pay.weixin.qq.com/wiki/doc/api/xiaowei.php?chapter=19_5
            inputObj.SetValue("bank_address_code", "");  // //开户银行省市编码,
            inputObj.SetValue("id_card_valid_time", ""); // //身份证有效期限
            inputObj.SetValue("merchant_shortname", ""); // //商户简称
            inputObj.SetValue("service_phone", "");      // //客服电话
            inputObj.SetValue("store_name", "");         // //门店名称

            //https://pay.weixin.qq.com/wiki/doc/api/xiaowei.php?chapter=19_5
            inputObj.SetValue("store_address_code", ""); // //门店省市编码,
            inputObj.SetValue("store_street", "");       // //门店街道名称

            //https://pay.weixin.qq.com/wiki/doc/api/xiaowei.php?chapter=19_5
            inputObj.SetValue("business", ""); // //经营类目ID,
            inputObj.SetValue("rate", "");     // //商户费率

            // MediaID图片字符串
            //先使用上传图片函数获取结果
            inputObj.SetValue("id_card_copy", "");       // //身份证人像面照片
            inputObj.SetValue("id_card_national", "");   // //身份证国徽面照片
            inputObj.SetValue("store_entrance_pic", ""); // //门店门口照片
            inputObj.SetValue("indoor_pic", "");         // //店内环境照片

            // 敏感信息加密
            inputObj.SetValue("id_card_name", (""));   // //身份证姓名
            inputObj.SetValue("id_card_number", ("")); // //身份证
            inputObj.SetValue("account_name", (""));   // //开户名称
            inputObj.SetValue("account_number", ("")); // //银行账号
            inputObj.SetValue("contact", (""));        // //联系人姓名
            inputObj.SetValue("contact_phone", (""));  // //手机号码

            string result = API.XiaoWei.Submit(inputObj);

            return(result);
        }
Пример #9
0
        public void postweixin(string code, string state)
        {
            if (!string.IsNullOrEmpty(code) && !string.IsNullOrEmpty(state))
            {
                string openid = "", weixinstr = "";
                bool   boocuy = true;

                /** ================会员卡销售支付========= */
                if (state.Contains("K"))
                {
                    var dt = HotelCloud.SqlServer.SQLHelper.Get_DataTable(@"select top 1 * from WeiXin..MemberCardBuyRecord where OrderNo=@OrderId", HotelCloud.SqlServer.SQLHelper.GetCon(), new Dictionary <string, HotelCloud.SqlServer.DBParam> {
                        { "OrderId", new HotelCloud.SqlServer.DBParam {
                              ParamValue = state
                          } }
                    });
                    if (dt.Rows.Count > 0)
                    {
                        foreach (System.Data.DataRow dr in dt.Rows)
                        {
                            openid = getopenid(dr["weixinId"].ToString().Trim(), code);
                            var weixinstrtable = HotelCloud.SqlServer.SQLHelper.Get_DataTable(@"select top 1 weixintype,edition from  WeiXin..WeiXinNO where WeiXinID=@WeiXinID", HotelCloud.SqlServer.SQLHelper.GetCon(), new Dictionary <string, HotelCloud.SqlServer.DBParam> {
                                { "WeiXinID", new HotelCloud.SqlServer.DBParam {
                                      ParamValue = dr["weixinId"].ToString().Trim()
                                  } }
                            });
                            if (weixinstrtable != null)
                            {
                                if (weixinstrtable.Rows.Count > 0)
                                {
                                    foreach (System.Data.DataRow rd in weixinstrtable.Rows)
                                    {
                                        /** ================判断公众号认证情况========= */
                                        weixinstr = rd["weixintype"].ToString();
                                        edition   = rd["edition"].ToString();
                                    }
                                }
                            }
                            if ((string.IsNullOrEmpty(weixinstr) || (weixinstr != "2" && weixinstr != "4")) && dr["weixinId"].ToString().Trim() == "gh_def2f166ed9e")
                            {
                                /** ================未认证情况 进行调整到二维码扫描支付========= */
                                Response.Redirect("http://hotel.weikeniu.com/WeiXinZhiFu/qrcode.aspx?OrderNo=" + dr["OrderNo"].ToString().Trim(), false);
                            }
                            else
                            {
                                int total_fee = Convert.ToInt32(Convert.ToDecimal(dr["BuyMoney"].ToString()) * 100);

                                /** ================Ashbur微信号对应支付金额 0.01元========= */
                                if (openid == "oPfrcjmqyO33T8a8Dn21Kq-QMAcg")
                                {
                                    total_fee = 1;
                                }
                                if (openid == "oUM4bwdTr3DXhUkGf43lGiipmxMA")
                                {
                                    total_fee = 1;
                                }
                                if (openid == "oZLQzv-cg1KvGmrTnq0xdxhK-4kc")
                                {
                                    total_fee = 1;
                                }

                                if (string.IsNullOrEmpty(openid))
                                {
                                    WxPayAPI.Log.Error(this.GetType().ToString(), "wxOAuthRedirect|This page have not get params, cannot be inited, exit...");
                                }
                                else
                                {
                                    HotelID      = dr["HotelId"].ToString().Trim();
                                    UserWeiXinID = dr["userWeixinId"].ToString().Trim();
                                    WeiXinID     = dr["weixinId"].ToString().Trim();

                                    WxPayAPI.WxPayData data = new WxPayAPI.WxPayData();
                                    data.SetValue("body", "会员卡购买");
                                    data.SetValue("attach", "presale");
                                    data.SetValue("out_trade_no", dr["OrderNo"].ToString().Trim());
                                    data.SetValue("total_fee", total_fee);
                                    data.SetValue("time_start", DateTime.Now.ToString("yyyyMMddHHmmss"));
                                    data.SetValue("time_expire", DateTime.Now.AddMinutes(30).ToString("yyyyMMddHHmmss"));
                                    data.SetValue("goods_tag", "会员卡消费");
                                    data.SetValue("trade_type", "JSAPI");
                                    data.SetValue("openid", openid);
                                    WxPayAPI.JsApiPay jsApiPay = new WxPayAPI.JsApiPay();
                                    jsApiPay.openid    = openid;
                                    jsApiPay.total_fee = total_fee;
                                    WxPayAPI.WxPayData unifiedOrderResult = jsApiPay.GetUnifiedOrderResult(data);
                                    wxJsApiParam = jsApiPay.GetJsApiParameters();
                                    WxPayAPI.Log.Debug(this.GetType().ToString(), "wxJsApiParam : " + wxJsApiParam);
                                }
                            }
                        }
                    }
                    else
                    {
                        WxPayAPI.Log.Debug(this.GetType().ToString(), "无效订单或者非预订订单");
                    }
                    boocuy = false;
                    return;
                }

                /** ================酒店周边购物消费========= */
                if (state.Contains("D"))
                {
                    var dt = HotelCloud.SqlServer.SQLHelper.Get_DataTable(@"select top 1 * from WeiXin..SupermarketOrder_Levi where OrderId=@OrderId", HotelCloud.SqlServer.SQLHelper.GetCon(), new Dictionary <string, HotelCloud.SqlServer.DBParam> {
                        { "OrderId", new HotelCloud.SqlServer.DBParam {
                              ParamValue = state
                          } }
                    });
                    if (dt.Rows.Count > 0)
                    {
                        foreach (System.Data.DataRow dr in dt.Rows)
                        {
                            openid = getopenid(dr["weixinID"].ToString().Trim(), code);
                            var weixinstrtable = HotelCloud.SqlServer.SQLHelper.Get_DataTable(@"select top 1 weixintype,edition from  WeiXin..WeiXinNO where WeiXinID=@WeiXinID", HotelCloud.SqlServer.SQLHelper.GetCon(), new Dictionary <string, HotelCloud.SqlServer.DBParam> {
                                { "WeiXinID", new HotelCloud.SqlServer.DBParam {
                                      ParamValue = dr["weixinID"].ToString().Trim()
                                  } }
                            });
                            if (weixinstrtable != null)
                            {
                                if (weixinstrtable.Rows.Count > 0)
                                {
                                    foreach (System.Data.DataRow rd in weixinstrtable.Rows)
                                    {
                                        /** ================判断公众号认证情况========= */
                                        weixinstr = rd["weixintype"].ToString();
                                        edition   = rd["edition"].ToString();
                                    }
                                }
                            }
                            if ((string.IsNullOrEmpty(weixinstr) || (weixinstr != "2" && weixinstr != "4")) && dr["weixinID"].ToString().Trim() == "gh_def2f166ed9e")
                            {
                                Response.Redirect("http://hotel.weikeniu.com/WeiXinZhiFu/qrcode.aspx?OrderNo=" + dr["OrderId"].ToString().Trim(), false);
                            }
                            else
                            {
                                int total_fee = Convert.ToInt32(Convert.ToDecimal(dr["Money"].ToString()) * 100);

                                /** ================Ashbur微信号对应支付金额 0.01元========= */
                                if (openid == "oPfrcjmqyO33T8a8Dn21Kq-QMAcg")
                                {
                                    total_fee = 1;
                                }
                                if (openid == "oUM4bwdTr3DXhUkGf43lGiipmxMA")
                                {
                                    total_fee = 1;
                                }
                                if (openid == "oZLQzv-cg1KvGmrTnq0xdxhK-4kc")
                                {
                                    total_fee = 1;
                                }

                                if (string.IsNullOrEmpty(openid))
                                {
                                    WxPayAPI.Log.Error(this.GetType().ToString(), "wxOAuthRedirect|This page have not get params, cannot be inited, exit...");
                                }
                                else
                                {
                                    HotelID      = dr["HotelId"].ToString().Trim();
                                    UserWeiXinID = dr["userweixinID"].ToString().Trim();
                                    WeiXinID     = dr["weixinID"].ToString().Trim();

                                    WxPayAPI.WxPayData data = new WxPayAPI.WxPayData();
                                    data.SetValue("body", "酒店周边购物消费");
                                    data.SetValue("attach", "presale");
                                    data.SetValue("out_trade_no", dr["OrderId"].ToString().Trim());
                                    data.SetValue("total_fee", total_fee);
                                    data.SetValue("time_start", DateTime.Now.ToString("yyyyMMddHHmmss"));
                                    data.SetValue("time_expire", DateTime.Now.AddMinutes(30).ToString("yyyyMMddHHmmss"));
                                    data.SetValue("goods_tag", "酒店周边购物消费");
                                    data.SetValue("trade_type", "JSAPI");
                                    data.SetValue("openid", openid);
                                    WxPayAPI.JsApiPay jsApiPay = new WxPayAPI.JsApiPay();
                                    jsApiPay.openid    = openid;
                                    jsApiPay.total_fee = total_fee;
                                    WxPayAPI.WxPayData unifiedOrderResult = jsApiPay.GetUnifiedOrderResult(data);
                                    wxJsApiParam = jsApiPay.GetJsApiParameters();
                                    WxPayAPI.Log.Debug(this.GetType().ToString(), "wxJsApiParam : " + wxJsApiParam);
                                }
                            }
                        }
                    }
                    else
                    {
                        WxPayAPI.Log.Debug(this.GetType().ToString(), "无效订单或者非预订订单");
                    }
                    boocuy = false;
                    return;
                }

                /** ================充值卡消费========= */
                if (state.Contains("C"))
                {
                    var dt = HotelCloud.SqlServer.SQLHelper.Get_DataTable(@"select top 1 * from WeiXin..RechargeUser where OrderNo=@OrderNo", HotelCloud.SqlServer.SQLHelper.GetCon(), new Dictionary <string, HotelCloud.SqlServer.DBParam> {
                        { "OrderNo", new HotelCloud.SqlServer.DBParam {
                              ParamValue = state
                          } }
                    });
                    if (dt.Rows.Count > 0)
                    {
                        foreach (System.Data.DataRow dr in dt.Rows)
                        {
                            openid = getopenid(dr["HotelWeiXinId"].ToString().Trim(), code);
                            var weixinstrtable = HotelCloud.SqlServer.SQLHelper.Get_DataTable(@"select top 1 weixintype,edition from  WeiXin..WeiXinNO where WeiXinID=@WeiXinID", HotelCloud.SqlServer.SQLHelper.GetCon(), new Dictionary <string, HotelCloud.SqlServer.DBParam> {
                                { "WeiXinID", new HotelCloud.SqlServer.DBParam {
                                      ParamValue = dr["HotelWeiXinId"].ToString().Trim()
                                  } }
                            });
                            if (weixinstrtable != null)
                            {
                                if (weixinstrtable.Rows.Count > 0)
                                {
                                    foreach (System.Data.DataRow rd in weixinstrtable.Rows)
                                    {
                                        /** ================判断公众号认证情况========= */
                                        weixinstr = rd["weixintype"].ToString();
                                        edition   = rd["edition"].ToString();
                                    }
                                }
                            }
                            if ((string.IsNullOrEmpty(weixinstr) || (weixinstr != "2" && weixinstr != "4")) && dr["HotelWeiXinId"].ToString().Trim() == "gh_def2f166ed9e")
                            {
                                Response.Redirect("http://hotel.weikeniu.com/WeiXinZhiFu/qrcode.aspx?OrderNo=" + dr["OrderNo"].ToString().Trim(), false);
                            }
                            else
                            {
                                int total_fee = Convert.ToInt32(Convert.ToDecimal(dr["SPrice"].ToString()) * 100);

                                /** ================Ashbur微信号对应支付金额 0.01元========= */
                                if (openid == "oPfrcjmqyO33T8a8Dn21Kq-QMAcg")
                                {
                                    total_fee = 1;
                                }
                                if (openid == "oUM4bwdTr3DXhUkGf43lGiipmxMA")
                                {
                                    total_fee = 1;
                                }
                                if (openid == "oZLQzv-cg1KvGmrTnq0xdxhK-4kc")
                                {
                                    total_fee = 1;
                                }

                                if (string.IsNullOrEmpty(openid))
                                {
                                    WxPayAPI.Log.Error(this.GetType().ToString(), "wxOAuthRedirect|This page have not get params, cannot be inited, exit...");
                                }
                                else
                                {
                                    HotelID      = dr["HotelId"].ToString().Trim();
                                    UserWeiXinID = dr["UserWeiXinId"].ToString().Trim();
                                    WeiXinID     = dr["HotelWeiXinId"].ToString().Trim();

                                    WxPayAPI.WxPayData data = new WxPayAPI.WxPayData();
                                    data.SetValue("body", "充值卡消费");
                                    data.SetValue("attach", "presale");
                                    data.SetValue("out_trade_no", dr["OrderNo"].ToString().Trim());
                                    data.SetValue("total_fee", total_fee);
                                    data.SetValue("time_start", DateTime.Now.ToString("yyyyMMddHHmmss"));
                                    data.SetValue("time_expire", DateTime.Now.AddMinutes(30).ToString("yyyyMMddHHmmss"));
                                    data.SetValue("goods_tag", "充值卡消费");
                                    data.SetValue("trade_type", "JSAPI");
                                    data.SetValue("openid", openid);
                                    WxPayAPI.JsApiPay jsApiPay = new WxPayAPI.JsApiPay();
                                    jsApiPay.openid    = openid;
                                    jsApiPay.total_fee = total_fee;
                                    WxPayAPI.WxPayData unifiedOrderResult = jsApiPay.GetUnifiedOrderResult(data);
                                    wxJsApiParam = jsApiPay.GetJsApiParameters();
                                    WxPayAPI.Log.Debug(this.GetType().ToString(), "wxJsApiParam : " + wxJsApiParam);
                                }
                            }
                        }
                    }
                    else
                    {
                        WxPayAPI.Log.Debug(this.GetType().ToString(), "无效订单或者非预订订单");
                    }
                    boocuy = false;
                    return;
                }


                /** ================度假产品消费========= */
                if (state.Contains("P"))
                {
                    var dt = HotelCloud.SqlServer.SQLHelper.Get_DataTable(@"select top 1 * from WeiXin..SaleProducts_Orders where OrderNo=@OrderNo", HotelCloud.SqlServer.SQLHelper.GetCon(), new Dictionary <string, HotelCloud.SqlServer.DBParam> {
                        { "OrderNo", new HotelCloud.SqlServer.DBParam {
                              ParamValue = state
                          } }
                    });
                    if (dt.Rows.Count > 0)
                    {
                        foreach (System.Data.DataRow dr in dt.Rows)
                        {
                            openid = getopenid(dr["HotelWeiXinId"].ToString().Trim(), code);
                            var weixinstrtable = HotelCloud.SqlServer.SQLHelper.Get_DataTable(@"select top 1 weixintype,edition from  WeiXin..WeiXinNO where WeiXinID=@WeiXinID", HotelCloud.SqlServer.SQLHelper.GetCon(), new Dictionary <string, HotelCloud.SqlServer.DBParam> {
                                { "WeiXinID", new HotelCloud.SqlServer.DBParam {
                                      ParamValue = dr["HotelWeiXinId"].ToString().Trim()
                                  } }
                            });
                            if (weixinstrtable != null)
                            {
                                if (weixinstrtable.Rows.Count > 0)
                                {
                                    foreach (System.Data.DataRow rd in weixinstrtable.Rows)
                                    {
                                        /** ================判断公众号认证情况========= */
                                        weixinstr = rd["weixintype"].ToString();
                                        edition   = rd["edition"].ToString();
                                    }
                                }
                            }
                            if ((string.IsNullOrEmpty(weixinstr) || (weixinstr != "2" && weixinstr != "4")) && dr["HotelWeiXinId"].ToString().Trim() == "gh_def2f166ed9e")
                            {
                                /** ================未认证情况 进行调整到二维码扫描支付  目前这个方式也不OK========= */
                                Response.Redirect("http://hotel.weikeniu.com/WeiXinZhiFu/qrcode.aspx?OrderNo=" + dr["OrderNo"].ToString().Trim(), false);
                            }
                            else
                            {
                                int total_fee = Convert.ToInt32(Convert.ToDecimal(dr["OrderMoney"].ToString()) * 100);

                                /** ================Ashbur微信号对应支付金额 0.01元========= */
                                if (openid == "oPfrcjmqyO33T8a8Dn21Kq-QMAcg")
                                {
                                    total_fee = 1;
                                }
                                if (openid == "oUM4bwdTr3DXhUkGf43lGiipmxMA")
                                {
                                    total_fee = 1;
                                }
                                if (openid == "oZLQzv-cg1KvGmrTnq0xdxhK-4kc")
                                {
                                    total_fee = 1;
                                }

                                if (string.IsNullOrEmpty(openid))
                                {
                                    WxPayAPI.Log.Error(this.GetType().ToString(), "wxOAuthRedirect|This page have not get params, cannot be inited, exit...");
                                }
                                else
                                {
                                    HotelID      = dr["HotelId"].ToString().Trim();
                                    UserWeiXinID = dr["UserWeiXinId"].ToString().Trim();
                                    WeiXinID     = dr["HotelWeiXinId"].ToString().Trim();

                                    WxPayAPI.WxPayData data = new WxPayAPI.WxPayData();
                                    data.SetValue("body", dr["ProductName"].ToString().Trim());
                                    data.SetValue("attach", "presale");
                                    data.SetValue("out_trade_no", dr["OrderNo"].ToString().Trim());
                                    data.SetValue("total_fee", total_fee);
                                    data.SetValue("time_start", DateTime.Now.ToString("yyyyMMddHHmmss"));
                                    data.SetValue("time_expire", DateTime.Now.AddMinutes(30).ToString("yyyyMMddHHmmss"));
                                    data.SetValue("goods_tag", dr["ProductName"].ToString().Trim() + "[" + dr["TcName"].ToString().Trim() + "]");
                                    data.SetValue("trade_type", "JSAPI");
                                    data.SetValue("openid", openid);
                                    WxPayAPI.JsApiPay jsApiPay = new WxPayAPI.JsApiPay();
                                    jsApiPay.openid    = openid;
                                    jsApiPay.total_fee = total_fee;
                                    WxPayAPI.WxPayData unifiedOrderResult = jsApiPay.GetUnifiedOrderResult(data);
                                    wxJsApiParam = jsApiPay.GetJsApiParameters();
                                    WxPayAPI.Log.Debug(this.GetType().ToString(), "wxJsApiParam : " + wxJsApiParam);
                                }
                            }
                        }
                    }
                    else
                    {
                        WxPayAPI.Log.Debug(this.GetType().ToString(), "无效订单或者非预订订单");
                    }
                    boocuy = false;
                    return;
                }

                /** ================ 酒店周边餐饮消费========= */
                if (state.Contains("L"))
                {
                    var dt = HotelCloud.SqlServer.SQLHelper.Get_DataTable(@"select top 1 bagging,amount,youhuiamount,ISNULL(CouponMoney,0) as CouponMoney,hotelid,userweixinid,hotelWeixinId,orderCode,(select sum(AliPayAmount) from  WeiXin..wkn_payrecords where OrderNO=orderCode and Channel='微信支付回调') as zhifu,storeID  from WeiXin..T_OrderInfo where orderCode=@orderCode", HotelCloud.SqlServer.SQLHelper.GetCon(), new Dictionary <string, HotelCloud.SqlServer.DBParam> {
                        { "orderCode", new HotelCloud.SqlServer.DBParam {
                              ParamValue = state
                          } }
                    });
                    if (dt.Rows.Count > 0)
                    {
                        foreach (System.Data.DataRow dr in dt.Rows)
                        {
                            openid = getopenid(dr["hotelWeixinId"].ToString().Trim(), code);
                            var weixinstrtable = HotelCloud.SqlServer.SQLHelper.Get_DataTable(@"select top 1 weixintype,edition from  WeiXin..WeiXinNO where WeiXinID=@WeiXinID", HotelCloud.SqlServer.SQLHelper.GetCon(), new Dictionary <string, HotelCloud.SqlServer.DBParam> {
                                { "WeiXinID", new HotelCloud.SqlServer.DBParam {
                                      ParamValue = dr["hotelWeixinId"].ToString().Trim()
                                  } }
                            });
                            if (weixinstrtable != null)
                            {
                                if (weixinstrtable.Rows.Count > 0)
                                {
                                    foreach (System.Data.DataRow rd in weixinstrtable.Rows)
                                    {
                                        /** ================判断公众号认证情况========= */
                                        weixinstr = rd["weixintype"].ToString();
                                        edition   = rd["edition"].ToString();
                                    }
                                }
                            }
                            if ((string.IsNullOrEmpty(weixinstr) || (weixinstr != "2" && weixinstr != "4")) && dr["hotelWeixinId"].ToString() == "gh_def2f166ed9e")
                            {
                                /** ================未认证情况 进行调整到二维码扫描支付========= */
                                Response.Redirect("http://hotel.weikeniu.com/WeiXinZhiFu/qrcode.aspx?OrderNo=" + dr["orderCode"].ToString().Trim(), false);
                            }
                            else
                            {
                                string bagging      = dr["bagging"].ToString();
                                string youhuiamount = dr["youhuiamount"].ToString();
                                if (string.IsNullOrEmpty(bagging))
                                {
                                    bagging = "0";
                                }
                                if (string.IsNullOrEmpty(youhuiamount))
                                {
                                    youhuiamount = "0";
                                }
                                Zhifu = dr["zhifu"].ToString();;
                                if (string.IsNullOrEmpty(Zhifu))
                                {
                                    Zhifu = "0";
                                }
                                int total_fee = Convert.ToInt32((Convert.ToDecimal(dr["amount"].ToString()) - Convert.ToDecimal(youhuiamount) + Convert.ToDecimal(bagging) - Convert.ToDecimal(dr["CouponMoney"].ToString())) * 100);

                                /** ================Ashbur微信号对应支付金额 0.01元========= */
                                if (openid == "oPfrcjmqyO33T8a8Dn21Kq-QMAcg")
                                {
                                    total_fee = 1;
                                }
                                if (openid == "oUM4bwdTr3DXhUkGf43lGiipmxMA")
                                {
                                    total_fee = 1;
                                }
                                if (openid == "oZLQzv-cg1KvGmrTnq0xdxhK-4kc")
                                {
                                    total_fee = 1;
                                }

                                if (string.IsNullOrEmpty(openid))
                                {
                                    WxPayAPI.Log.Error(this.GetType().ToString(), "wxOAuthRedirect|This page have not get params, cannot be inited, exit...");
                                }
                                else
                                {
                                    HotelID      = dr["hotelid"].ToString().Trim();
                                    UserWeiXinID = dr["userweixinid"].ToString().Trim();
                                    WeiXinID     = dr["hotelWeixinId"].ToString().Trim();
                                    storeId      = dr["storeId"].ToString().Trim();

                                    WxPayAPI.WxPayData data = new WxPayAPI.WxPayData();
                                    data.SetValue("body", "酒店周边餐饮消费");
                                    data.SetValue("attach", "consumption");
                                    data.SetValue("out_trade_no", dr["orderCode"].ToString().Trim());
                                    data.SetValue("total_fee", total_fee);
                                    data.SetValue("time_start", DateTime.Now.ToString("yyyyMMddHHmmss"));
                                    data.SetValue("time_expire", DateTime.Now.AddMinutes(30).ToString("yyyyMMddHHmmss"));
                                    data.SetValue("goods_tag", "酒店周边餐饮消费");
                                    data.SetValue("trade_type", "JSAPI");
                                    data.SetValue("openid", openid);
                                    WxPayAPI.JsApiPay jsApiPay = new WxPayAPI.JsApiPay();
                                    jsApiPay.openid    = openid;
                                    jsApiPay.total_fee = total_fee;
                                    WxPayAPI.WxPayData unifiedOrderResult = jsApiPay.GetUnifiedOrderResult(data);
                                    wxJsApiParam = jsApiPay.GetJsApiParameters();
                                    WxPayAPI.Log.Debug(this.GetType().ToString(), "wxJsApiParam : " + wxJsApiParam);
                                }
                            }
                        }
                    }
                    else
                    {
                        WxPayAPI.Log.Debug(this.GetType().ToString(), "无效订单或者非预订订单");
                    }
                    boocuy = false;
                    return;
                }
                /** ================ 酒店客房销售========= */
                if (boocuy)
                {
                    hotel3g.Repository.Order order = hotel3g.Repository.OrderRepository.GetOrderInfo(state);
                    var weixinstrtable             = HotelCloud.SqlServer.SQLHelper.Get_DataTable(@"select top 1 weixintype,edition from  WeiXin..WeiXinNO where WeiXinID=@WeiXinID", HotelCloud.SqlServer.SQLHelper.GetCon(), new Dictionary <string, HotelCloud.SqlServer.DBParam> {
                        { "WeiXinID", new HotelCloud.SqlServer.DBParam {
                              ParamValue = order.WeiXinID.Trim()
                          } }
                    });
                    if (weixinstrtable != null)
                    {
                        if (weixinstrtable.Rows.Count > 0)
                        {
                            foreach (System.Data.DataRow rd in weixinstrtable.Rows)
                            {
                                /** ================判断公众号认证情况========= */
                                weixinstr = rd["weixintype"].ToString();
                                edition   = rd["edition"].ToString();
                            }
                        }
                    }
                    if ((string.IsNullOrEmpty(weixinstr) || (weixinstr != "2" && weixinstr != "4")) && order.WeiXinID.Trim() == "gh_def2f166ed9e")
                    {
                        /** ================未认证情况 进行调整到二维码扫描支付========= */
                        Response.Redirect("http://hotel.weikeniu.com/WeiXinZhiFu/qrcode.aspx?OrderNo=" + order.OrderNo.ToString(), false);
                    }
                    else
                    {
                        if (order == null || order.PayType != "0")
                        {
                            WxPayAPI.Log.Debug(this.GetType().ToString(), "无效订单或者非预订订单");
                        }
                        else
                        {
                            openid = getopenid(order.WeiXinID.Trim(), code);
                            int total_fee = order.OrderAmount * 100;

                            /** ================Ashbur微信号对应支付金额 0.01元========= */
                            if (openid == "oPfrcjmqyO33T8a8Dn21Kq-QMAcg")
                            {
                                total_fee = 1;
                            }
                            if (openid == "oUM4bwdTr3DXhUkGf43lGiipmxMA")
                            {
                                total_fee = 1;
                            }
                            if (openid == "oZLQzv-cg1KvGmrTnq0xdxhK-4kc")
                            {
                                total_fee = 1;
                            }

                            if (string.IsNullOrEmpty(openid))
                            {
                                WxPayAPI.Log.Error(this.GetType().ToString(), "wxOAuthRedirect|This page have not get params, cannot be inited, exit...");
                            }
                            else
                            {
                                HotelID      = order.HotelID.ToString().Trim();
                                UserWeiXinID = order.UserWeiXinID.Trim();
                                WeiXinID     = order.WeiXinID.Trim();
                                if (edition == "1")
                                {
                                    orderid = order.Id.ToString();
                                }
                                orderid = order.Id.ToString();

                                WxPayAPI.WxPayData data = new WxPayAPI.WxPayData();
                                data.SetValue("body", order.HotelName.Trim());
                                data.SetValue("attach", "weikeniuwx");
                                data.SetValue("out_trade_no", order.OrderNo);
                                data.SetValue("total_fee", total_fee);
                                data.SetValue("time_start", DateTime.Now.ToString("yyyyMMddHHmmss"));
                                data.SetValue("time_expire", DateTime.Now.AddMinutes(30).ToString("yyyyMMddHHmmss"));
                                data.SetValue("goods_tag", order.RoomName + "[" + order.RatePlanName + "]");
                                data.SetValue("trade_type", "JSAPI");
                                data.SetValue("openid", openid);
                                WxPayAPI.JsApiPay jsApiPay = new WxPayAPI.JsApiPay();
                                jsApiPay.openid    = openid;
                                jsApiPay.total_fee = total_fee;
                                WxPayAPI.WxPayData unifiedOrderResult = jsApiPay.GetUnifiedOrderResult(data);
                                wxJsApiParam = jsApiPay.GetJsApiParameters();
                                WxPayAPI.Log.Debug(this.GetType().ToString(), "wxJsApiParam : " + wxJsApiParam);
                            }
                        }
                    }
                }
            }
        }