Esempio n. 1
0
        public ActionResult ROrderDetail(string orderid)
        {
            //-----
            noncestr = CommonMethod.GetCode(16);
            string jsapi_ticket = Js_sdk_Signature.IsExistjsapi_ticket(WeChatConfig.IsExistAccess_Token2());

            timestamp = DateTime.Now.Ticks.ToString().Substring(0, 10);;
            string url = Request.Url.ToString().Replace("#", "");

            JssdkSignature = Js_sdk_Signature.GetjsSDK_Signature(noncestr, jsapi_ticket, timestamp, url);

            ViewBag.Appid        = WeChatConfig.GetKeyValue("appid");
            ViewBag.Uri          = WeChatConfig.GetKeyValue("shareurl");
            ViewBag.noncestr     = noncestr;
            ViewBag.jsapi_ticket = jsapi_ticket;
            ViewBag.timestamp    = timestamp;
            ViewBag.PageFlag     = "PayOrder";
            if (string.IsNullOrEmpty(CommonMethod.getCookie("userid")) || string.IsNullOrEmpty(CommonMethod.getCookie("openid")))
            {
                return(Content("对不起,请登陆系统!"));
            }
            var order = orderB.Get(o => o.orderNum == orderid);

            if (order == null)
            {
                return(Content("对不起,这个订单是错误的!"));
            }
            return(View(VIEW_TG_order.ToViewModel(order)));
        }
Esempio n. 2
0
        public ActionResult Category(string id)
        {
            ViewBag.isok  = "OK";
            ViewBag.Appid = WeChatConfig.GetKeyValue("appid");
            ViewBag.Uri   = WeChatConfig.GetKeyValue("shareurl");

            noncestr = CommonMethod.GetCode(16);

            string jsapi_ticket = Js_sdk_Signature.IsExistjsapi_ticket(token.IsExistAccess_Token());

            timestamp = DateTime.Now.Ticks.ToString().Substring(0, 10);;
            string url = Request.Url.ToString().Replace("#", "");

            JssdkSignature         = Js_sdk_Signature.GetjsSDK_Signature(noncestr, jsapi_ticket, timestamp, url);
            ViewBag.noncestr       = noncestr;
            ViewBag.jsapi_ticket   = jsapi_ticket;
            ViewBag.timestamp      = timestamp;
            ViewBag.JssdkSignature = JssdkSignature;
            ViewBag.PageFlag       = id;

            var sid = TypeParser.ToInt32(Request["sid"]);

            if (sid <= 0)
            {
                sid = 2;
            }
            ViewBag.SupplierID   = sid;
            ViewBag.SupplierName = supplierB.Get(s => s.SUPPLIER_ID == sid).SUPPLIER_NAME;
            ViewBag.ProductList  = VIEW_MST_PRD.ToListViewModel(prdB.GetListBy(p => p.CATE_ID == id && p.STATUS == true && p.ISCHECK == true, p => p.SEQ_NO));
            var model = VIEW_MST_CATEGORY.ToViewModel(categoryB.Get(c => c.CATE_CD == id));

            return(View(model));
        }
Esempio n. 3
0
        public ActionResult ProductDetail(string id)
        {
            ViewBag.Appid = WeChatConfig.GetKeyValue("appid");
            ViewBag.Uri   = WeChatConfig.GetKeyValue("shareurl");

            noncestr = CommonMethod.GetCode(16);

            string jsapi_ticket = Js_sdk_Signature.IsExistjsapi_ticket(token.IsExistAccess_Token());

            timestamp = DateTime.Now.Ticks.ToString().Substring(0, 10);;
            string url = Request.Url.ToString().Replace("#", "");

            JssdkSignature         = Js_sdk_Signature.GetjsSDK_Signature(noncestr, jsapi_ticket, timestamp, url);
            ViewBag.noncestr       = noncestr;
            ViewBag.jsapi_ticket   = jsapi_ticket;
            ViewBag.timestamp      = timestamp;
            ViewBag.JssdkSignature = JssdkSignature;
            var userid = CommonMethod.getCookie("userid");
            var openid = CommonMethod.getCookie("openid");

            ViewBag.userName = "";
            ViewBag.userTel  = "";
            if (!string.IsNullOrEmpty(userid) && !string.IsNullOrEmpty(openid))
            {
                var user = VIEW_YX_weiUser.ToViewModel(weiUserM.GetModelWithOutTrace(u => u.openid == openid));
                if (user != null)
                {
                    ViewBag.userName = user.userRelname;
                    ViewBag.userTel  = user.userTel;
                }
            }
            var sid = TypeParser.ToInt32(Request["sid"]);

            if (sid <= 0)
            {
                sid = 2;
            }
            ViewBag.SupplierID = sid;
            var supplier = supplierB.Get(s => s.SUPPLIER_ID == sid);

            ViewBag.SupplierName = supplier.SUPPLIER_NAME;
            ViewBag.Address      = supplier.ADDRESS;
            ViewBag.Tel          = supplier.TEL;
            var model = VIEW_MST_PRD.ToViewModel(prdB.Get(p => p.PRD_CD == id));

            ViewBag.ImgList  = VIEW_MST_PRD_IMG.ToListViewModel(prdimgB.GetListBy(pm => pm.PRD_CD == id));
            ViewBag.AM       = sysrefB.GetListBy(s => s.REF_TYPE == model.CATE_ID && s.REF_PARAM.Contains("AM_"), s => s.REF_SEQ);
            ViewBag.PM       = sysrefB.GetListBy(s => s.REF_TYPE == model.CATE_ID && s.REF_PARAM.Contains("PM_"), s => s.REF_SEQ);
            ViewBag.PageFlag = model.CATE_ID;


            return(View(model));
        }
Esempio n. 4
0
        public static string certPwd  = "";                                     //GetKeyValue("mchid");//证书密码  及   商户平台商户号  初始密码  可以修改
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            Appsecret = WeChatConfig.GetKeyValue("appsecret");
            AppId     = WeChatConfig.GetKeyValue("appid");
            apisecret = WeChatConfig.GetKeyValue("apisecret");
            URLToken  = WeChatConfig.GetKeyValue("token");
            try
            {
                if (HttpContext.Current.Request.HttpMethod.ToUpper() == "GET")
                {
                    if (!AccessTokenContainer.CheckRegistered(AppId))
                    {
                        AccessTokenContainer.Register(AppId, Appsecret);
                    }

                    Auth(); //微信接入的测试  成为开发者第一步
                }
                if (HttpContext.Current.Request.HttpMethod.ToUpper() == "POST")
                {
                    if (!AccessTokenContainer.CheckRegistered(AppId))
                    {
                        AccessTokenContainer.Register(AppId, Appsecret);
                    }



                    responseMsg();
                }
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog("一般处理程序入口错误:", ex);
            }
            // context.Response.Write("Hello World");
        }
Esempio n. 5
0
        public ActionResult PayOrder(string orderid)
        {
            ViewBag.PageFlag = "PayOrder";
            var openid = CommonMethod.getCookie("openid");
            var userid = CommonMethod.getCookie("userid");
            var user   = weiUserM.GetModelWithOutTrace(u => u.userNum == userid && u.openid == openid);

            if (user == null)
            {
                return(Content("对不起,请登陆系统!"));
            }
            ViewBag.UserType    = user.isfenxiao;
            ViewBag.userYongJin = user.userYongJin;
            ViewBag.Userid      = userid;
            ViewBag.Openid      = openid;
            var order = orderB.Get(o => o.orderNum == orderid);

            if (order == null)
            {
                return(Content("对不起,这个订单是错误的!"));
            }

            //-----
            noncestr = CommonMethod.GetCode(16);
            string jsapi_ticket = Js_sdk_Signature.IsExistjsapi_ticket(WeChatConfig.IsExistAccess_Token2());

            timestamp = DateTime.Now.Ticks.ToString().Substring(0, 10);;
            string url = Request.Url.ToString().Replace("#", "");

            JssdkSignature = Js_sdk_Signature.GetjsSDK_Signature(noncestr, jsapi_ticket, timestamp, url);

            ViewBag.Appid        = WeChatConfig.GetKeyValue("appid");
            ViewBag.Uri          = WeChatConfig.GetKeyValue("shareurl");
            ViewBag.noncestr     = noncestr;
            ViewBag.jsapi_ticket = jsapi_ticket;
            ViewBag.timestamp    = timestamp;

            //微信支付代码
            //
            //httpContext

            var packageReqHandler = new RequestHandler(HttpContext);

            packageReqHandler.Init();

            //时间戳
            payTimeSamp = Senparc.Weixin.MP.TenPayLibV3.TenPayV3Util.GetTimestamp();
            //随机字符串
            sj = CommonMethod.GetCode(16) + "_" + userid;
            //设置参数
            packageReqHandler.SetParameter("body", "商城-购买支付"); //商品信息 127字符
            packageReqHandler.SetParameter("appid", PayConfig.AppId);
            packageReqHandler.SetParameter("mch_id", PayConfig.MchId);
            packageReqHandler.SetParameter("nonce_str", sj);
            packageReqHandler.SetParameter("notify_url", PayConfig.NotifyUrl);
            packageReqHandler.SetParameter("openid", openid);
            packageReqHandler.SetParameter("out_trade_no", orderid + "_" + CommonMethod.GetCode(4));          //商家订单号
            packageReqHandler.SetParameter("spbill_create_ip", Request.UserHostAddress);                      //用户的公网ip,不是商户服务器IP
            packageReqHandler.SetParameter("total_fee", (Convert.ToDouble(order.yunPrice) * 100).ToString()); //商品金额,以分为单位(money * 100).ToString()
            packageReqHandler.SetParameter("trade_type", "JSAPI");
            packageReqHandler.SetParameter("attach", CommonMethod.GetCode(28));                               //自定义参数 127字符
            string sign = packageReqHandler.CreateMd5Sign("key", PayConfig.AppKey);                           //第一次签名结果

            #region 获取package包======================
            packageReqHandler.SetParameter("sign", sign);

            string data = packageReqHandler.ParseXML();//支付发送的数据 XML格式


            string prepayXml = Senparc.Weixin.MP.AdvancedAPIs.TenPayV3.Unifiedorder(data);
            //string prepayXml = WeiXin.GetPage("https://api.mch.weixin.qq.com/pay/unifiedorder", data);
            var xdoc = new XmlDocument();
            xdoc.LoadXml(prepayXml);
            XmlNode xn = xdoc.SelectSingleNode("xml");
            LogHelper.WriteLog(prepayXml);
            try
            {
                string PrepayId = WeChatConfig.GetXMLstrByKey("prepay_id", xdoc);
                Package = string.Format("prepay_id={0}", PrepayId);
                LogHelper.WriteLog(Package);
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog(ex.ToString());
                Package = string.Format("prepay_id={0}", "");
            }
            #endregion


            #region 设置支付参数 输出页面  该部分参数请勿随意修改 ==============
            var paySignReqHandler = new RequestHandler(HttpContext);
            paySignReqHandler.SetParameter("appId", PayConfig.AppId);
            paySignReqHandler.SetParameter("timeStamp", payTimeSamp);
            paySignReqHandler.SetParameter("nonceStr", sj);
            paySignReqHandler.SetParameter("package", Package);
            paySignReqHandler.SetParameter("signType", "MD5");
            PaySign = paySignReqHandler.CreateMd5Sign("key", PayConfig.AppKey);
            #endregion

            //--------END

            ViewBag.payTimeSamp = payTimeSamp;
            ViewBag.sj          = sj;
            ViewBag.Package     = Package;
            ViewBag.PaySign     = PaySign;
            return(View(VIEW_TG_order.ToViewModel(order)));
        }
Esempio n. 6
0
        public ActionResult UserMain()
        {
            ViewBag.PageFlag = "UserMain";
            ViewBag.isok     = "OK";
            ViewBag.Appid    = WeChatConfig.GetKeyValue("appid");
            ViewBag.Uri      = WeChatConfig.GetKeyValue("shareurl");

            noncestr = CommonMethod.GetCode(16);

            string jsapi_ticket = Js_sdk_Signature.IsExistjsapi_ticket(token.IsExistAccess_Token());

            timestamp = DateTime.Now.Ticks.ToString().Substring(0, 10);;
            string url = Request.Url.ToString().Replace("#", "");

            JssdkSignature       = Js_sdk_Signature.GetjsSDK_Signature(noncestr, jsapi_ticket, timestamp, url);
            ViewBag.noncestr     = noncestr;
            ViewBag.jsapi_ticket = jsapi_ticket;
            ViewBag.timestamp    = timestamp;
            openid = CommonMethod.getCookie("openid");
            userid = CommonMethod.getCookie("userid");
            if (string.IsNullOrEmpty(openid))
            {
                //根据授权 获取openid //根据授权  获取用户的openid
                string code = Request.QueryString["code"];//获取授权code
                LogHelper.WriteLog("//////////////////////////////////////////////////////////////////////////////////");
                LogHelper.WriteLog("code:" + code);
                if (string.IsNullOrEmpty(code))
                {
                    string codeurl = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx242aa47391c159f6&redirect_uri=http://www.aoshacar.com/AoShaCar/userMain&response_type=code&scope=snsapi_userinfo&state=STATE&connect_redirect=1#wechat_redirect";
                    Response.Redirect(codeurl);
                }
                else
                {
                    string openIdUrl = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=" + WeChatConfig.GetKeyValue("appid") + "&secret=" + WeChatConfig.GetKeyValue("appsecret") + "&code=" + code + "&grant_type=authorization_code";
                    string content   = Tools.GetPage(openIdUrl, "");
                    openid = Tools.GetJsonValue(content, "openid");//根据授权  获取当前人的openid
                }
            }
            var model = VIEW_YX_weiUser.ToViewModel(weiUserM.GetModelWithOutTrace(u => u.openid == openid));

            if (model != null)
            {
                CommonMethod.delCookie("openid");
                CommonMethod.delCookie("userid");
                CommonMethod.setCookie("openid", openid, 1);
                CommonMethod.setCookie("userid", model.userNum, 1);
                ViewBag.nickname   = model.nickname;
                ViewBag.headimgurl = model.headimgurl;
            }
            else
            {
                Senparc.Weixin.MP.AdvancedAPIs.User.UserInfoJson dic = Senparc.Weixin.MP.AdvancedAPIs.UserApi.Info(token.IsExistAccess_Token(), openid);
                //LogHelper.WriteLog("XXXXXXXXXXX:" + openid);
                if (dic != null)
                {
                    ViewBag.nickname   = dic.nickname;
                    ViewBag.headimgurl = dic.headimgurl;
                }
                model                = new MODEL.ViewModel.VIEW_YX_weiUser();
                model.subscribe      = dic.subscribe;
                model.openid         = dic.openid;
                model.nickname       = dic.nickname;
                model.sex            = dic.sex;
                model.U_language     = dic.language;
                model.city           = dic.city;
                model.province       = dic.province;
                model.country        = dic.country;
                model.headimgurl     = dic.headimgurl;
                model.subscribe_time = DateTime.Now;
                model.userSex        = dic.sex == 2 ? "女" : "男";
                model.userNum        = Common.Tools.Get8Digits();
                model.F_id           = 0;
                model.isfenxiao      = 0;
                model.userMoney      = 0;
                model.userYongJin    = 0;
                weiUserM.Add(VIEW_YX_weiUser.ToEntity(model));
            }
            ViewBag.UserType = ConfigSettings.GetSysConfigValue("USERTYPE", model.isfenxiao.ToString());
            return(View(model));
        }
Esempio n. 7
0
        public ActionResult Index()
        {
            ViewBag.PageFlag = "Index";
            if (string.IsNullOrEmpty(CommonMethod.getCookie("userid")) || string.IsNullOrEmpty(CommonMethod.getCookie("openid")))
            {
                //CommonMethod.delCookie("userid");
                //登陆
                string code = Request.QueryString["code"];//获取授权code
                if (!string.IsNullOrEmpty(code))
                {
                    string openIdUrl = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=" + WeChatConfig.GetKeyValue("appid") + "&secret=" + WeChatConfig.GetKeyValue("appsecret") + "&code=" + code + "&grant_type=authorization_code";
                    string content   = Tools.GetPage(openIdUrl, "");
                    openid = Tools.GetJsonValue(content, "openid");//根据授权  获取当前人的openid
                    var model = weiUserM.GetModelWithOutTrace(u => u.openid == openid);
                    if (model != null)
                    {
                        CommonMethod.delCookie("openid");
                        CommonMethod.delCookie("userid");
                        CommonMethod.setCookie("openid", openid, 1);
                        CommonMethod.setCookie("userid", model.userNum, 1);
                    }
                }
                else
                {
                    string codeurl = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx242aa47391c159f6&redirect_uri=http://www.aoshacar.com/AoShaCar/Index&response_type=code&scope=snsapi_userinfo&state=STATE&connect_redirect=1#wechat_redirect";
                    Response.Redirect(codeurl);
                }
                //end
            }
            ViewBag.PageFlag = "Index";
            var sid = TypeParser.ToInt32(Request["sid"]);

            if (sid <= 0)
            {
                sid = 2;
            }
            ViewBag.SupplierID   = sid;
            ViewBag.SupplierName = supplierB.Get(s => s.SUPPLIER_ID == sid).SUPPLIER_NAME;
            ViewBag.CategoryList = VIEW_MST_CATEGORY.ToListViewModel(categoryB.GetListBy(c => c.ACTIVE == true));
            ViewBag.ProductList  = VIEW_MST_PRD.ToListViewModel(prdB.GetListBy(p => p.ISCHECK == true && p.STATUS == true && p.ISHOT == true, p => p.SEQ_NO));

            return(View());
        }