示例#1
0
 protected void GetHeadImg(M_UserInfo mu)
 {
     if (mu == null || mu.IsNull || mu.UserID < 1)
     {
     }
     else
     {
         uappMod = uappBll.SelModelByUid(mu.UserID, "wechat");
         M_WX_User wuserMod = new M_WX_User();
         if (uappMod != null)
         {
             try
             {
                 wuserMod = wxapi.GetWxUserModel(uappMod.OpenID);
             }
             catch (Exception ex)
             {
                 wxapi.GetToken();
                 wuserMod = wxapi.GetWxUserModel(uappMod.OpenID);
                 throw ex;
             }
             if (wuserMod != null)
             {
                 Response.Write("{\"nickname\":\"" + wuserMod.Name + "\",\"headimgurl\":\"" + wuserMod.HeadImgUrl + "\"}");
             }
         }
     }
 }
示例#2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //string appid = "wx64dcf57278caa037";
            //string redirect_uri = "http://www.zljdsc.com/test/WxLogin.aspx";
            //string secret = "71c21ab790c34c05e1290a26ff025c70";
            M_Third_Info wxInfo = thirdBll.SelModelByName("wechat");
            string       state  = "";

            if (string.IsNullOrEmpty(Request.QueryString["code"]))//微信登录操作
            {
                state = function.GetRandomString(8).ToLower();
                Session.Add("wx_state", state);
                string url = "https://open.weixin.qq.com/connect/qrconnect?appid=" + wxInfo.ID + "&redirect_uri=" + HttpUtility.UrlEncode(wxInfo.CallBackUrl) + "&response_type=code&scope=snsapi_login&state=" + state + "#wechat_redirect";
                Response.Redirect(url);
            }
            else//登录返回操作
            {
                //检测state参数是否匹配
                if (Session["wx_state"] == null || !Session["wx_state"].Equals(Request.QueryString["state"]))
                {
                    function.WriteErrMsg("参数错误!");
                }
                Session["wx_state"] = null;
                string  url     = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=" + wxInfo.ID + "&secret=" + wxInfo.Secret + "&code=" + Request.QueryString["code"] + "&grant_type=authorization_code";
                JObject wxinfo  = GetWxInfo(url);
                Appinfo infomod = AppBll.SelModelByOpenID(wxinfo["openid"].ToString(), "wechat");
                if (infomod == null)//新用户注册
                {
                    infomod = GetNewUser(wxinfo);
                }
                M_UserInfo mu = buser.SelReturnModel(infomod.UserID);
                buser.SetLoginState(mu);
                Response.Redirect("/User");
            }
        }
示例#3
0
        //自动注册新用户并登录
        private void AutoUser(string plat, string openid)
        {
            Appinfo    appMod = new Appinfo();
            M_UserInfo mu     = new M_UserInfo();

            mu.UserName = plat + function.GetRandomString(6).ToLower();
            mu.UserPwd  = StringHelper.MD5("123123aa");
            mu.Email    = mu.UserName + "@random.com";
            if (string.IsNullOrEmpty(openid))
            {
                function.WriteErrMsg("openid不存在");
            }
            appMod = appBll.SelModelByOpenID(openid, plat);
            if (appMod != null && appMod.UserID > 0)
            {
                mu = buser.SelReturnModel(appMod.UserID);
            }
            else
            {
                appMod            = new Appinfo();
                mu.UserID         = buser.AddModel(mu);
                appMod.OpenID     = openid;
                appMod.SourcePlat = plat;
                appMod.UserID     = mu.UserID;
                appBll.Insert(appMod);
            }
            buser.SetLoginState(mu);
            Response.Redirect(targetUrl);
        }
示例#4
0
 public bool UpdateByID(Appinfo model)
 {
     if (string.IsNullOrEmpty(model.SourcePlat))
     {
         throw new Exception("未指定平台");
     }
     return(Sql.UpdateByIDs(TbName, PK, model.ID.ToString(), BLLCommon.GetFieldAndPara(model), model.GetParameters()));
 }
示例#5
0
        public ActionResult RedPacket()
        {
            //用户必须关注公众号之后才可访问
            WxAPI.AutoSync(Request.RawUrl);
            Appinfo uaMod = uaBll.SelModelByUid(mu.UserID, "wechat");

            ViewBag.state = uaMod == null ? "0" : "1";
            return(View());
        }
示例#6
0
    protected void Page_Init(object sender, EventArgs e)
    {
        M_UserInfo mu1 = buser.GetLogin();

        if (mu1 == null || mu1.IsNull || mu1.UserID < 1)
        {
            Response.Redirect("/wxpromo.aspx?appid=2&r=/User/Default2.aspx");
        }
        else if (mu1.Status != 0)
        {
            function.WriteErrMsg("你的帐户未通过验证或被锁定,请与网站管理员联系", "/wxpromo.aspx?appid=2&r=/User/Default2.aspx");
        }

        if (buser.CheckLogin())
        {
            uappMod = uappBll.SelModelByUid(mu1.UserID, "wechat");
            if (uappMod != null)
            {
                M_WX_User wxuserMod = wxuserBll.SelForOpenid(2, uappMod.OpenID);
                if (wxuserMod == null)
                {
                    WxAPI   wxapi  = WxAPI.Code_Get(2);
                    string  apiurl = "https://api.weixin.qq.com/cgi-bin/";
                    string  result = APIHelper.GetWebResult(apiurl + "user/info?access_token=" + wxapi.AccessToken + "&openid=" + uappMod.OpenID);
                    JObject obj    = JsonConvert.DeserializeObject <JObject>(result);
                    if (obj["errcode"].ToString() == "40003")
                    {
                        buser.ClearCookie();
                        Response.Redirect("/wxpromo.aspx?appid=2&r=/User/Default2.aspx");
                    }
                }
            }
        }
        else if (badmin.CheckLogin())
        {
            M_AdminInfo adminMod = badmin.GetAdminLogin();
            M_UserInfo  mu       = buser.GetUserByName(adminMod.AdminName, adminMod.AdminPassword);
            if (mu == null || mu.IsNull || mu.UserID < 1)
            {
                Response.Redirect("/User/Login.aspx");
            }
            else if (mu.Status != 0)
            {
                function.WriteErrMsg("你的帐户未通过验证或被锁定,请与网站管理员联系", "/wxpromo.aspx?appid=2&r=/User/Default2.aspx");
            }
            else
            {
                buser.SetLoginState(mu);
            }
        }
        else
        {
            B_User.CheckIsLogged(Request.RawUrl);
        }
    }
示例#7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                WxAPI  wxapi = WxAPI.Code_Get();
                string code  = Request.QueryString["code"] ?? "";
                if (string.IsNullOrEmpty(code))
                {
                    return;
                }
                string     result = APIHelper.GetWebResult("https://api.weixin.qq.com/sns/oauth2/access_token?appid=" + wxapi.AppId.APPID + "&secret=" + wxapi.AppId.Secret + "&code=" + code + "&grant_type=authorization_code");
                JObject    obj    = (JObject)JsonConvert.DeserializeObject(result);
                string     openid = obj["openid"].ToString();
                Appinfo    umod   = appBll.SelModelByOpenID(openid, "wechat");
                M_UserInfo mu     = new M_UserInfo();
                if (umod == null)
                {
                    umod = new Appinfo();
                    M_WX_User wuMod = wxuserBll.SelForOpenid(wxapi.AppId.ID, openid);
                    if (wuMod == null)
                    {
                        wuMod = wxapi.GetWxUserModel(openid);
                        wxuserBll.Insert(wuMod);
                    }
                    mu.UserName  = "******" + DateTime.Now.ToString("yyyyMMddHHmmss") + function.GetRandomString(2).ToLower();
                    mu.UserPwd   = StringHelper.MD5(function.GetRandomString(6));
                    mu.Email     = function.GetRandomString(10) + "@random.com";
                    mu.HoneyName = wuMod.Name;
                    mu.TrueName  = wuMod.Name;
                    mu.UserID    = buser.Add(mu);

                    umod.UserID     = mu.UserID;
                    umod.SourcePlat = "wechat";
                    umod.OpenID     = wuMod.OpenID;
                    appBll.Insert(umod);
                    M_Uinfo mubase = new M_Uinfo();
                    mubase.UserId = mu.UserID;
                    buser.AddBase(mubase);
                }
                else
                {
                    mu = buser.SelReturnModel(umod.UserID);
                }
                //设置为登录状态
                buser.SetLoginState(mu);
                Response.Redirect(RUrl);
            }
        }
示例#8
0
        //创建新用户
        private Appinfo GetNewUser(JObject wxinfo)
        {
            Appinfo    infomod = new Appinfo();
            M_UserInfo mu      = new M_UserInfo();

            mu.UserName = "******" + function.GetRandomString(8).ToLower();
            mu.UserPwd  = StringHelper.MD5(function.GetRandomString(8));
            mu.Email    = mu.UserName + "@random.com";
            mu.UserID   = buser.Add(mu);

            infomod.UserID     = mu.UserID;
            infomod.OpenID     = wxinfo["openid"].ToString();
            infomod.SourcePlat = "wechat";
            infomod.Token      = wxinfo["access_token"].ToString();
            AppBll.Insert(infomod);
            return(infomod);
        }
示例#9
0
    protected void GetHeadImg(M_UserInfo mu)
    {
        int appid = 1;

        if (AppID > 0)
        {
            appid = AppID;
        }
        WxAPI wxapi = WxAPI.Code_Get(appid);

        if (mu == null || mu.IsNull || mu.UserID < 1)
        {
        }
        else
        {
            uappMod = uappBll.SelModelByUid(mu.UserID, "wechat");
            M_WX_User wuserMod = new M_WX_User();
            if (uappMod != null)
            {
                try
                {
                    wuserMod = wxapi.GetWxUserModel(uappMod.OpenID);
                    if (string.IsNullOrEmpty(wuserMod.Name))
                    {
                        wxapi.GetToken();
                        wuserMod = wxapi.GetWxUserModel(uappMod.OpenID);
                    }
                }
                catch (Exception ex)
                {
                    wxapi.GetToken();
                    wuserMod = wxapi.GetWxUserModel(uappMod.OpenID);
                    throw ex;
                }
                if (wuserMod != null)
                {
                    Response.Write("{\"nickname\":\"" + wuserMod.Name + "\",\"headimgurl\":\"" + wuserMod.HeadImgUrl + "\"}");
                }
            }
        }
    }
示例#10
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         M_Design_Album albumMod = albumBll.SelReturnModel(Mid);
         M_UserInfo     mu       = buser.GetSelect(albumMod.UserID);
         string         username = mu.UserName;
         appMod = appBll.SelModelByUid(mu.UserID, "wechat");
         if (appMod != null)
         {
             wxMod = wxBll.SelForOpenid(1, appMod.OpenID);
             if (wxMod != null)
             {
                 username = wxMod.Name;
             }
         }
         albumMod.AlbumName += "-来自[" + username + "]的动力逐浪微相册";
         string html = SafeSC.ReadFileStr("/design/album/tlps/" + albumMod.UseTlp + "/photo.html");
         html = html.Replace("\"{album}\"", JsonConvert.SerializeObject(albumMod));
         Response.Clear(); Response.Write(html); Response.End();
     }
 }
示例#11
0
 protected void Page_Init(object sender, EventArgs e)
 {
     if (buser.CheckLogin())
     {
         M_UserInfo mu = buser.GetLogin();
         if (mu == null || mu.IsNull || mu.UserID < 1)
         {
             Response.Redirect("/wxpromo.aspx?r=" + Request.RawUrl);
             //Response.Redirect("/User/Login.aspx");
         }
         else if (mu.Status != 0)
         {
             function.WriteErrMsg("你的帐户未通过验证或被锁定,请与网站管理员联系", "/User/Login.aspx");
         }
         uappMod = uappBll.SelModelByUid(mu.UserID, "wechat");
         if (uappMod != null)
         {
             M_WX_User wxuserMod1 = wxuserBll.SelForOpenid(1, uappMod.OpenID);
             M_WX_User wxuserMod2 = wxuserBll.SelForOpenid(2, uappMod.OpenID);
             if (wxuserMod1 != null)
             {
                 footer_div1.Visible = true;
             }
             if (wxuserMod2 != null)
             {
                 footer_div2.Visible = true;
             }
             if (wxuserMod1 == null && wxuserMod2 == null)
             {
                 footer_div1.Visible = true;
             }
         }
     }
     else
     {
         B_User.CheckIsLogged(Request.RawUrl);
     }
 }
示例#12
0
        //如果存在,则直接登录
        private bool HasExist(string openid, string source)
        {
            bool    result = true;
            Appinfo appMod = appBll.SelModelByOpenID(openid, source);

            if (appMod != null)
            {
                M_UserInfo mu = buser.GetSelect(appMod.UserID);
                if (mu.IsNull)
                {
                    result = false;
                }
                else
                {
                    buser.SetLoginState(mu);
                }
            }
            else
            {
                result = false;
            }
            return(result);
        }
示例#13
0
    //支付成功时执行的操作
    private void PayOrder_Success(WxPayData result)
    {
        ZLLog.L(ZLEnum.Log.pay, "微信:微信支付 支付单:" + result.GetValue("out_trade_no") + " 金额:" + result.GetValue("total_fee"));
        try
        {
            M_Order_PayLog paylogMod = new M_Order_PayLog();
            M_Payment      pinfo     = payBll.SelModelByPayNo(result.GetValue("out_trade_no").ToString());
            if (pinfo == null)
            {
                throw new Exception("支付单不存在");
            }                                                    //支付单检测合为一个方法
            if (pinfo.Status != (int)M_Payment.PayStatus.NoPay)
            {
                throw new Exception("支付单状态不为未支付");
            }
            pinfo.Status       = (int)M_Payment.PayStatus.HasPayed;
            pinfo.PlatformInfo = "微信扫码|公众号支付";
            pinfo.SuccessTime  = DateTime.Now;
            pinfo.PayTime      = DateTime.Now;
            pinfo.CStatus      = true;
            //1=100,
            double tradeAmt = Convert.ToDouble(result.GetValue("total_fee")) / 100;
            pinfo.MoneyTrue = tradeAmt;
            payBll.Update(pinfo);
            DataTable orderDT = orderBll.GetOrderbyOrderNo(pinfo.PaymentNum);
            foreach (DataRow dr in orderDT.Rows)
            {
                M_OrderList orderMod = orderBll.SelModelByOrderNo(dr["OrderNo"].ToString());
                OrderHelper.FinalStep(pinfo, orderMod, paylogMod);
                if (orderMod.Ordertype == (int)M_OrderList.OrderEnum.Purse)
                {
                    M_UserInfo mu = buser.SelReturnModel(orderMod.Userid);
                    new B_Shop_MoneyRegular().AddMoneyByMin(mu, orderMod.Ordersamount, ",订单号[" + orderMod.OrderNo + "]");
                }
                orderCom.SendMessage(orderMod, paylogMod, "payed");
                //orderCom.SaveSnapShot(orderMod);

                if (orderMod.Ordertype != 6)
                {
                    buser.ChangeVirtualMoney(orderMod.Userid, new M_UserExpHis()
                    {
                        score     = orderMod.Ordersamount,
                        ScoreType = 3,
                        detail    = "在线消费赠送积分:" + orderMod.Ordersamount
                    });
                }
                //订单返利
                OrderRebates(orderMod.Userid, orderMod.Ordersamount);
                //订单打印
                int orderID  = DataConvert.CLng(dr["ID"].ToString());
                int StoreID  = DataConvert.CLng(dr["StoreID"].ToString());
                int devID    = GetPrintDevice(StoreID);  //设备ID
                int tlpID    = GetPrintModelID(StoreID); //模板ID
                int printnum = GetPrintNum(StoreID);
                //------------------------------
                DataTable          orderDT1 = DBCenter.Sel("ZL_OrderInfo", "ID=" + orderID);
                M_Shop_PrintTlp    tlpMod   = tlpBll.SelReturnModel(tlpID);
                M_Shop_PrintDevice devMod   = devBll.SelReturnModel(devID);
                string             msg      = orderCOM.TlpDeal(tlpMod.Content, orderDT1);
                ZLLog.L(ZLEnum.Log.pay, msg);
                msgBll.Insert(msg, tlpMod.ID, devMod, printnum);
                //function.WriteSuccessMsg("信息已发送", "MessageList.aspx");

                //发送微信通知
                try
                {
                    userappMod = userappBll.SelModelByUid(DataConvert.CLng(dr["UserID"]), "wechat");
                    if (userappMod != null)
                    {
                        WxAPI wxapi = WxAPI.Code_Get(1);
                        if (dr["Ordertype"].ToString() == "6")
                        {
                            M_UserInfo userMod = buser.GetUserByUserID(DataConvert.CLng(dr["UserID"]));
                            wxapi.Tlp_SendTlpMsg(userappMod.OpenID, "vRUiDj-k6EGjwQC2GO4oU1G37CJjiu2fZ-ePBj1jJ60", "http://v.wodian8.com/User/Order/OrderList1.aspx", "{\"first\": {\"value\":\"您好,您已经充值成功。\",\"color\":\"#173177\"},\"keyword1\":{\"value\":\"" + DataConvert.CDouble(dr["Ordersamount"]).ToString("0.00") + "\",\"color\":\"#173177\"},\"keyword2\": {\"value\":\"" + DateTime.Now.ToString("yyyy年MM月dd日 HH:mm:ss") + "\",\"color\":\"#173177\"},\"keyword3\": {\"value\":\"" + userMod.Purse.ToString("0.00") + "\",\"color\":\"#173177\"},\"remark\":{\"value\":\"感谢您对我们的信任,我们将为您提供更优质的服务。\",\"color\":\"#173177\"}}");
                        }
                        else
                        {
                            wxapi.Tlp_SendTlpMsg(userappMod.OpenID, "E-yWv8GVKeJHymtTB0zOGKnEv6LXodjr-M6tj1sLzfM", "http://v.wodian8.com/User/Order/OrderList1.aspx", "{\"first\": {\"value\":\"您的订单支付成功!\",\"color\":\"#173177\"},\"keyword1\":{\"value\":\"" + dr["OrderNo"].ToString() + "\",\"color\":\"#173177\"},\"keyword2\": {\"value\":\"" + GetProname(DataConvert.CLng(dr["ID"])) + "\",\"color\":\"#173177\"},\"keyword3\": {\"value\":\"" + DataConvert.CDouble(dr["Ordersamount"]).ToString("0.00") + "\",\"color\":\"#173177\"},\"keyword4\": {\"value\":\"" + DateTime.Now.ToString("yyyy年MM月dd日 HH:mm:ss") + "\",\"color\":\"#173177\"},\"remark\":{\"value\":\"点击查看订单详情!\",\"color\":\"#173177\"}}");
                        }
                    }
                }
                catch (Exception ex)
                {
                    ZLLog.L(ZLEnum.Log.pay, new M_Log()
                    {
                        Action  = "发送微信通知报错",
                        Message = "原因:" + ex.Message
                    });
                    throw;
                }
            }
            ZLLog.L(ZLEnum.Log.pay, "微信支付成功!支付单:" + result.GetValue("out_trade_no").ToString());
        }
        catch (Exception ex)
        {
            ZLLog.L(ZLEnum.Log.pay, new M_Log()
            {
                Action  = "支付回调报错",
                Message = "平台:微信,支付单:" + result.GetValue("out_trade_no").ToString() + ",原因:" + ex.Message
            });
        }
    }
示例#14
0
    private void SendMsg(Object info)
    {
        try
        {
            M_WxTextMsg reqMod = (M_WxTextMsg)info;
            System.Threading.Thread.Sleep(1000);//延迟1秒,避免先于欢迎消息
            M_WX_APPID appmod = new B_WX_APPID().GetAppByWxNo(reqMod.ToUserName);
            if (appmod == null)
            {
                throw new Exception("目标公众号[" + reqMod.ToUserName + "]不存在");
            }
            string     msgStr  = "";
            Appinfo    uappMod = new Appinfo();
            B_UserAPP  uappBll = new B_UserAPP();
            M_UserInfo mu      = new M_UserInfo();
            uappMod = uappBll.SelModelByOpenID(reqMod.FromUserName, "wechat");
            if (uappMod != null)
            {
                mu = buser.GetUserByUserID(uappMod.UserID);
                M_UserInfo pmu = buser.GetUserByUserID(DataConvert.CLng(reqMod.EventKey.Replace("qrscene_", "")));
                if (mu != null && mu.UserID > 0)
                {
                    if (DataConvert.CLng(mu.ParentUserID) > 0)
                    {
                        msgStr = "您已绑定了推荐人不能重复绑定!";
                    }
                    else
                    {
                        if (mu.UserID == DataConvert.CLng(reqMod.EventKey.Replace("qrscene_", "")))
                        {
                            msgStr = "您扫描的是您自己的二维码!";
                        }
                        else
                        {
                            if (pmu != null && pmu.UserID > 0)
                            {
                                string err = "";
                                if (CheckParentUser(pmu.UserID, mu.UserID, ref err))
                                {
                                    mu.ParentUserID = pmu.UserID.ToString();
                                    if (buser.UpdateByID(mu))
                                    {
                                        msgStr = "您成功绑定了推荐人:" + pmu.TrueName + "!";
                                    }

                                    else
                                    {
                                        msgStr = "绑定推荐人失败!";
                                    }
                                }
                                else
                                {
                                    msgStr = "绑定推荐失败,错误信息:" + err;
                                }
                            }
                            else
                            {
                                msgStr = "绑定推荐失败,推荐人不存在!";
                            }
                        }
                    }
                }
                WxAPI.Code_Get(appmod).SendMsg(reqMod.FromUserName, msgStr);
            }
        }
        catch (Exception ex) { ZLLog.L("微信多信息出错,原因:" + ex.Message); }
    }
示例#15
0
    /// <summary>
    /// 系统事件,如订阅等处理
    /// </summary>
    public void WxEventHandler(M_WxTextMsg reqMod)
    {
        M_WX_User userMod = null;

        switch (reqMod.Event.ToLower())
        {
        case "subscribe":
            userMod       = api.GetWxUserModel(reqMod.FromUserName);
            userMod.CDate = DateTime.Now;
            userMod.AppId = api.AppId.ID;
            wxuserBll.Insert(userMod);
            M_WxImgMsg msgmod = JsonConvert.DeserializeObject <M_WxImgMsg>(api.AppId.WelStr);
            msgmod.ToUserName   = reqMod.FromUserName;
            msgmod.FromUserName = reqMod.ToUserName;

            int        pid      = DataConvert.CLng(reqMod.EventKey.Replace("qrscene_", ""));
            Appinfo    uappMod1 = new Appinfo();
            B_UserAPP  uappBll1 = new B_UserAPP();
            M_UserInfo mu1      = new M_UserInfo();
            M_WX_User  wuserMod = new M_WX_User();
            M_Uinfo    mubase   = new M_Uinfo();
            uappMod1 = uappBll1.SelModelByOpenID(reqMod.FromUserName, "wechat");
            wuserMod = api.GetWxUserModel(reqMod.FromUserName);
            if (uappMod1 != null)
            {
                mu1 = buser.GetUserByUserID(uappMod1.UserID);
                if (mu1 != null && mu1.UserID > 0)
                {
                    mu1.TrueName = wuserMod.Name;
                    mu1.GroupID  = 1;
                    buser.UpdateByID(mu1);
                }
                else
                {
                    mu1.UserName = "******" + DateTime.Now.ToString("yyyyMMddHHmmss") + function.GetRandomString(2).ToLower();
                    mu1.UserPwd  = StringHelper.MD5(function.GetRandomString(6));
                    mu1.Email    = function.GetRandomString(10) + "@wx.com";
                    mu1.Question = function.GetRandomString(5);
                    mu1.Answer   = function.GetRandomString(5);
                    mu1.TrueName = wuserMod.Name;
                    mu1.GroupID  = 1;
                    mu1.UserID   = buser.Add(mu1);

                    uappMod1.UserID     = mu1.UserID;
                    uappMod1.SourcePlat = "wechat";
                    uappMod1.OpenID     = reqMod.FromUserName;
                    uappBll1.UpdateByID(uappMod1);
                    mubase.UserId = mu1.UserID;
                    buser.AddBase(mubase);
                }
            }
            else
            {
                uappMod1     = new Appinfo();
                mu1.UserName = "******" + DateTime.Now.ToString("yyyyMMddHHmmss") + function.GetRandomString(2).ToLower();
                mu1.UserPwd  = StringHelper.MD5(function.GetRandomString(6));
                mu1.Email    = function.GetRandomString(10) + "@wx.com";
                mu1.Question = function.GetRandomString(5);
                mu1.Answer   = function.GetRandomString(5);
                mu1.TrueName = wuserMod.Name;
                mu1.GroupID  = 1;
                mu1.UserID   = buser.Add(mu1);

                uappMod1.UserID     = mu1.UserID;
                uappMod1.SourcePlat = "wechat";
                uappMod1.OpenID     = reqMod.FromUserName;
                uappBll1.Insert(uappMod1);
                mubase.UserId = mu1.UserID;
                buser.AddBase(mubase);
            }

            if (string.IsNullOrEmpty(msgmod.Articles[0].PicUrl))     //如未设置图片则以纯文本格式发送,纯文本支持内置超链接
            {
                M_WxTextMsg textMod = ImageToText(msgmod);
                RepToClient(textMod.ToXML());
            }
            else
            {
                RepToClient(msgmod.ToXML());
            }
            //关注时发送多条信息
            if (pid > 0)
            {
                System.Threading.ThreadPool.QueueUserWorkItem(new System.Threading.WaitCallback(SendMsg), reqMod);
            }
            //关注时发送多条信息
            //System.Threading.ThreadPool.QueueUserWorkItem(new System.Threading.WaitCallback(SendMsg), reqMod);
            break;

        case "unsubscribe":
            wxuserBll.DelByOpenid(api.AppId.ID, reqMod.FromUserName);
            break;

        case "location":    //用户进入公众号(包含定位信息)
            M_WxImgMsg msgmod1 = new M_WxImgMsg();
            msgmod1.ToUserName   = reqMod.FromUserName;
            msgmod1.FromUserName = reqMod.ToUserName;
            M_WX_ReplyMsg rpMod = new M_WX_ReplyMsg();
            rpMod = rpBll.SelByFileAndDef(appBll.GetAppByWxNo(reqMod.ToUserName).ID, "头图");
            if (rpMod != null)
            {
                M_WXImgItem item = JsonConvert.DeserializeObject <M_WXImgItem>(rpMod.Content);
                msgmod1.Articles.Add(new M_WXImgItem()
                {
                    Title = item.Title, Url = item.Url, Description = item.Description, PicUrl = item.PicUrl
                });
            }
//                rpMod = rpBll.SelByFileAndDef(appBll.GetAppByWxNo(reqMod.ToUserName).ID, "推送1");
//                {
//                    M_WXImgItem item = JsonConvert.DeserializeObject<M_WXImgItem>(rpMod.Content);
//                    msgmod1.Articles.Add(new M_WXImgItem() { Title = item.Title, Url = item.Url, Description = item.Description, PicUrl = item.PicUrl });
//                }
//                rpMod = rpBll.SelByFileAndDef(appBll.GetAppByWxNo(reqMod.ToUserName).ID, "推送2");
//                {
//                    M_WXImgItem item = JsonConvert.DeserializeObject<M_WXImgItem>(rpMod.Content);
//                    msgmod1.Articles.Add(new M_WXImgItem() { Title = item.Title, Url = item.Url, Description = item.Description, PicUrl = item.PicUrl });
//                }
//                rpMod = rpBll.SelByFileAndDef(appBll.GetAppByWxNo(reqMod.ToUserName).ID, "推送3");
//                {
//                    M_WXImgItem item = JsonConvert.DeserializeObject<M_WXImgItem>(rpMod.Content);
//                    msgmod1.Articles.Add(new M_WXImgItem() { Title = item.Title, Url = item.Url, Description = item.Description, PicUrl = item.PicUrl });
//                }
//                rpMod = rpBll.SelByFileAndDef(appBll.GetAppByWxNo(reqMod.ToUserName).ID, "推送4");
//                {
//                    M_WXImgItem item = JsonConvert.DeserializeObject<M_WXImgItem>(rpMod.Content);
//                    msgmod1.Articles.Add(new M_WXImgItem() { Title = item.Title, Url = item.Url, Description = item.Description, PicUrl = item.PicUrl });
//                }
            RepToClient(msgmod1.ToXML());
            break;

        case "scan":
            Appinfo     uappMod  = new Appinfo();
            B_UserAPP   uappBll  = new B_UserAPP();
            M_UserInfo  mu       = new M_UserInfo();
            M_WxTextMsg textMod2 = new M_WxTextMsg();
            textMod2.FromUserName = reqMod.ToUserName;
            textMod2.ToUserName   = reqMod.FromUserName;
            textMod2.MsgType      = "text";
            textMod2.Content      = "";
            uappMod = uappBll.SelModelByOpenID(reqMod.FromUserName, "wechat");
            if (uappMod != null)
            {
                mu = buser.GetUserByUserID(uappMod.UserID);
                M_UserInfo pmu = buser.GetUserByUserID(DataConvert.CLng(reqMod.EventKey));
                if (mu != null && mu.UserID > 0)
                {
                    if (DataConvert.CLng(mu.ParentUserID) > 0)
                    {
                        textMod2.Content = "您已绑定了推荐人不能重复绑定!";
                        RepToClient(textMod2.ToXML());
                    }
                    else
                    {
                        if (mu.UserID == DataConvert.CLng(reqMod.EventKey))
                        {
                            textMod2.Content = "您扫描的是您自己的二维码!";
                        }
                        else
                        {
                            mu.ParentUserID = DataConvert.CLng(reqMod.EventKey).ToString();
                            if (pmu != null && pmu.UserID > 0)
                            {
                                string err = "";
                                if (CheckParentUser(pmu.UserID, mu.UserID, ref err))
                                {
                                    mu.ParentUserID = pmu.UserID.ToString();
                                    if (buser.UpdateByID(mu))
                                    {
                                        textMod2.Content = "您成功绑定了推荐人:" + pmu.TrueName + "!";
                                    }

                                    else
                                    {
                                        textMod2.Content = "绑定推荐人失败!";
                                    }
                                }
                                else
                                {
                                    textMod2.Content = "绑定推荐失败,错误信息:" + err;
                                }
                            }
                            else
                            {
                                textMod2.Content = "绑定推荐失败,推荐人不存在!";
                            }
                        }
                        RepToClient(textMod2.ToXML());
                    }
                }
            }
            break;

        default:
            break;
        }
    }
示例#16
0
    //提交订单
    protected void AddOrder_Btn_Click(object sender, EventArgs e)
    {
        if (Address_Div.Visible && DataConvert.CLng(Request.Form["address_rad"]) < 1)
        {
            function.WriteErrMsg("尚未选定收货地址");
        }
        //1,生成订单,2,关联购物车中商品为已绑定订单
        M_UserInfo  mu      = buser.GetLogin(false);
        M_UserRecei receMod = receBll.GetSelect(Convert.ToInt32(Request.Form["address_rad"]), mu.UserID);
        DataTable   cartDT  = cartBll.SelByCookID(CartCookID, ProClass, ids);//需要购买的商品

        if (cartDT.Rows.Count < 1)
        {
            function.WriteErrMsg("你尚未选择商品,<a href='/User/Order/OrderList.aspx'>查看我的订单</a>");
        }
        //------生成订单前检测区
        foreach (DataRow dr in cartDT.Rows)
        {
            if (!HasStock(dr["Allowed"], DataConvert.CLng(dr["stock"]), Convert.ToInt32(dr["Pronum"])))
            {
                function.WriteErrMsg("购买失败," + dr["proname"] + "的库存数量不足");
            }
        }
        //------检测End
        //按店铺生成订单,统一存ZL_Orderinfo
        DataTable storeDT = cartDT.DefaultView.ToTable(true, "StoreID");
        M_Payment payMod  = new M_Payment();

        payMod.PayNo = payBll.CreatePayNo();
        List <M_OrderList> orderList = new List <M_OrderList>();//用于生成临时订单,统计计算(Disuse)

        foreach (DataRow dr in storeDT.Rows)
        {
            #region 暂不使用字段
            //Odata.province = this.DropDownList1.SelectedValue;
            //Odata.city = this.DropDownList2.SelectedValue;//将地址省份与市ID存入,XML数据源
            //Odata.Guojia = "";//国家
            //Odata.Chengshi = DropDownList2.SelectedItem.Text;//城市
            //Odata.Diqu = DropDownList3.SelectedItem.Text;//地区
            //Odata.Delivery = DataConverter.CLng(Request.Form["Delivery"]);
            //Odata.Deliverytime = DataConverter.CLng(this.Deliverytime.Text);
            //Odata.Mobile = receMod.MobileNum;
            #endregion
            M_OrderList Odata = new M_OrderList();
            Odata.Ordertype = OrderHelper.GetOrderType(ProClass);
            Odata.OrderNo   = B_OrderList.CreateOrderNo((M_OrderList.OrderEnum)Odata.Ordertype);
            Odata.StoreID   = Convert.ToInt32(dr["StoreID"]);
            cartDT.DefaultView.RowFilter = "StoreID=" + Odata.StoreID;
            DataTable storeCartDT = cartDT.DefaultView.ToTable();
            switch (ProClass)//旅游机票等,以联系人信息为地址
            {
            case 7:
            case 8:
                M_Cart_Travel   model = JsonConvert.DeserializeObject <M_Cart_Travel>(storeCartDT.Rows[0]["Additional"].ToString());
                M_Cart_Contract user  = model.Contract[0];
                Odata.Receiver  = user.Name;
                Odata.Reuser    = user.Name;
                Odata.Phone     = user.Mobile;
                Odata.MobileNum = user.Mobile;
                Odata.Email     = user.Email;
                break;

            default:    //普通订单
                Odata.Receiver  = receMod.ReceivName;
                Odata.Reuser    = receMod.ReceivName;
                Odata.Phone     = receMod.phone;
                Odata.MobileNum = receMod.MobileNum;
                Odata.Email     = receMod.Email;
                Odata.Shengfen  = receMod.Provinces;
                Odata.Jiedao    = receMod.Street;
                Odata.ZipCode   = receMod.Zipcode;
                break;
            }
            Odata.Invoiceneeds    = DataConverter.CLng(Request.Form["invoice_rad"]);//是否需开发票
            Odata.Invoice         = Odata.Invoiceneeds == 0 ? "" : InvoTitle_T.Text + "||" + Invoice_T.Text;
            Odata.Rename          = mu.UserName;
            Odata.Outstock        = 0;              //缺货处理
            Odata.Ordermessage    = ORemind_T.Text; //订货留言
            Odata.Merchandiser    = "";             //跟单员
            Odata.Internalrecords = "";             //内部记录
            Odata.IsCount         = false;
            //-----金额计算
            Odata.Balance_price     = GetTotalMoney(storeCartDT);
            Odata.Freight           = GetFarePrice(storeCartDT, Odata.StoreID); //运费计算
            Odata.Ordersamount      = Odata.Balance_price + Odata.Freight;      //订单金额
            Odata.AllMoney_Json     = orderCom.GetTotalJson(storeCartDT);       //附加需要的虚拟币
            Odata.Specifiedprice    = Odata.Ordersamount;                       //订单金额;
            Odata.Receivablesamount = 0;                                        //收款金额
            Odata.Developedvotes    = 0;
            Odata.OrderStatus       = (int)M_OrderList.StatusEnum.Normal;       //订单状态
            Odata.Paymentstatus     = (int)M_OrderList.PayEnum.NoPay;           //付款状态
            Odata.StateLogistics    = 0;                                        //物流状态
            Odata.Signed            = 0;                                        //签收
            Odata.Settle            = 0;                                        //结清
            Odata.Aside             = 0;                                        //作废
            Odata.Suspended         = 0;                                        //暂停
            Odata.AddTime           = DateTime.Now;
            Odata.AddUser           = mu.UserName;;
            Odata.Userid            = mu.UserID;
            Odata.Integral          = DataConverter.CLng(Request.QueryString["jifen"]);
            Odata.Freight_remark    = " ";
            Odata.Balance_remark    = "";
            Odata.Promoter          = 0;
            Odata.id = orderBll.Adds(Odata);
            cartProBll.CopyToCartPro(mu, storeCartDT, Odata.id);
            orderList.Add(Odata);
            orderCom.SendMessage(Odata, null, "ordered");
            userappMod = userappBll.SelModelByUid(buser.GetLogin().UserID, "wechat");
            if (userappMod != null)
            {
                //function.WriteErrMsg(Odata.AddTime.ToString("yyyy年MM月dd日 HH:mm:ss"));
                WxAPI  wxapi = WxAPI.Code_Get(1);
                string json  = "{ \"touser\":\"" + userappMod.OpenID + "\",\"template_id\":\"6kw4rUCX3IpE7k8_kn3ocmaaQBZF4blWq25ualnz1qw\",\"url\":\"http://www.wodian8.com/User/Order/OrderList1.aspx\",\"data\":{\"first\": {\"value\":\"订单提交成功!\",\"color\":\"#173177\"},\"keyword1\":{\"value\":\"" + Odata.AddTime.ToString("yyyy年MM月dd日 HH:mm:ss") + "\",\"color\":\"#173177\"},\"keyword2\": {\"value\":\"" + Odata.Ordersamount.ToString("0.00") + "元\",\"color\":\"#173177\"},\"keyword3\": {\"value\":\"" + GetProname(Odata.id) + "\",\"color\":\"#173177\"},\"keyword4\": {\"value\":\"" + Odata.Shengfen + Odata.Jiedao + "\",\"color\":\"#173177\"},\"remark\":{\"value\":\"您好,订单提交成功,请尽快付款!\",\"color\":\"#173177\"}}}";
                wxapi.SendTlpMsg(json);
                //wxapi.SendMsg(userappMod.OpenID, "你已下订单,订单号为:" + Odata.OrderNo);
            }
        }
        cartBll.DelByids(ids);
        //-----------------订单生成后处理
        //进行减库存等操作
        foreach (DataRow dr in cartDT.Rows)
        {
            M_Product model = proBll.GetproductByid(Convert.ToInt32(dr["Proid"]));
            model.Stock = model.Stock - DataConvert.CLng(dr["Pronum"]);
            SqlHelper.ExecuteSql("Update ZL_Commodities Set Stock=" + model.Stock + " Where ID=" + model.ID);
        }
        //生成支付单,处理优惠券,并进入付款步骤
        foreach (M_OrderList model in orderList)
        {
            payMod.PaymentNum += model.OrderNo + ",";
            payMod.MoneyPay   += model.Ordersamount;
        }
        //优惠券
        if (!string.IsNullOrEmpty(Arrive_T.Text))
        {
            double arriveAmount = arriveBll.UserArrive(Arrive_T.Text, Arrive_Pwd.Text);
            payMod.MoneyPay     = payMod.MoneyPay - arriveAmount;
            payMod.ArriveMoney  = arriveAmount;
            payMod.ArriveDetail = Arrive_T.Text + "|" + Arrive_Pwd.Text;
        }
        //积分处理
        if (point_body.Visible && DataConvert.CLng(Point_T.Text) > 0)
        {
            int point    = DataConvert.CLng(Point_T.Text);
            int maxPoint = (int)((SiteConfig.ShopConfig.PointRatiot * 0.01) * (double)payMod.MoneyPay / SiteConfig.ShopConfig.PointRate);
            //if (point <= 0) { function.WriteErrMsg("积分数值不正确"); }
            if (point > mu.UserExp)
            {
                function.WriteErrMsg("您的积分不足!");
            }
            if (point > maxPoint)
            {
                function.WriteErrMsg("积分不能大于可兑换金额!");
            }
            //生成支付单时扣除用户积分
            buser.ChangeVirtualMoney(mu.UserID, new M_UserExpHis()
            {
                ScoreType = (int)M_UserExpHis.SType.Point, score = -point, detail = "积分抵扣,支付单号:" + payMod.PayNo
            });
            payMod.MoneyPay = payMod.MoneyPay - (point * SiteConfig.ShopConfig.PointRate);
            payMod.UsePoint = point;
        }
        if (payMod.MoneyPay <= 0)
        {
            payMod.MoneyPay = 0.01;
        }
        payMod.PaymentNum = payMod.PaymentNum.TrimEnd(',');
        payMod.Remark     = cartDT.Rows.Count > 1 ? "[" + cartDT.Rows[0]["ProName"] as string + "]等" : cartDT.Rows[0]["ProName"] as string;
        payMod.UserID     = mu.UserID;
        payMod.Status     = 1;
        payMod.PaymentID  = payBll.Add(payMod);

        string redirect_uri = HttpUtility.UrlEncode("http://www.wodian8.com/Payonline/wxpayonline.aspx?PayNo=" + payMod.PayNo);
        string url          = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx8c5c2dc7b10a36f3&redirect_uri=" + redirect_uri + "&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect";
        //Response.Redirect(url);
        Response.Redirect("/PayOnline/Orderpay.aspx?PayNo=" + payMod.PayNo);
    }
示例#17
0
    //进入该页即开始推广,自动创建用户,关联APPID
    protected void Page_Load(object sender, EventArgs e)
    {
        B_User    buser  = new B_User();
        B_UserAPP appBll = new B_UserAPP();
        int       puid   = DataConverter.CLng(Session["WX_PUserID"]);
        string    rurl   = DataConvert.CStr(Session["WX_R"]);

        if (string.IsNullOrEmpty(rurl))
        {
            rurl = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx215c3a129d4f8fcc&redirect_uri=http%3a%2f%2fx014.2013.hx008.com&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect";
        }
        //if (puid < 1) { function.WriteErrMsg("推荐用户不存在"); }
        M_WX_APPID appMod = new M_WX_APPID();  //自行置入缓存,使用时取出

        appMod.APPID  = WxPayConfig.APPID;     //"wx674f7f7116d71f52";
        appMod.Secret = WxPayConfig.APPSECRET; //1ea6ecc8a53028019f604097379d3b21
        WxAPI wxapi = WxAPI.Code_Get(1);
        //wxapi.AppId = appMod;
        string     code         = Request["code"];
        string     access_token = APIHelper.GetWebResult("https://api.weixin.qq.com/sns/oauth2/access_token?appid=" + appMod.APPID + "&secret=" + appMod.Secret + "&code=" + code + "&grant_type=authorization_code");
        JObject    obj          = (JObject)JsonConvert.DeserializeObject(access_token);
        JObject    userobj      = (JObject)JsonConvert.DeserializeObject(APIHelper.GetWebResult("https://api.weixin.qq.com/sns/userinfo?access_token=" + obj["access_token"] + "&openid=" + obj["openid"] + "&lang=zh_CN"));
        string     openID       = obj["openid"].ToString();
        Appinfo    umod         = appBll.SelModelByOpenID(openID, "wechat");
        M_UserInfo mu           = new M_UserInfo();

        if (umod != null)
        {
            mu = buser.SelReturnModel(umod.UserID);
            buser.SetLoginState(mu);
            Response.Redirect(rurl);
        }
        else //新用户则注册
        {
            umod            = new Appinfo();
            mu.UserName     = "******" + DateTime.Now.ToString("yyyyMMddHHmmss") + function.GetRandomString(2).ToLower();
            mu.UserPwd      = StringHelper.MD5(function.GetRandomString(6));
            mu.Email        = function.GetRandomString(10) + "@wx.com";
            mu.Question     = function.GetRandomString(5);
            mu.Answer       = function.GetRandomString(5);
            mu.ParentUserID = puid.ToString();
            mu.TrueName     = userobj["nickname"].ToString();
            mu.GroupID      = 1;
            mu.UserID       = buser.Add(mu);

            umod.UserID     = mu.UserID;
            umod.SourcePlat = "wechat";
            umod.OpenID     = openID;
            appBll.Insert(umod);
            M_Uinfo mubase = new M_Uinfo();
            mubase.UserId = mu.UserID;
            buser.AddBase(mubase);
            //推广人得积分
            //if (puid > 0)
            //{
            //    M_UserInfo pmu = buser.SelReturnModel(puid);
            //    if (!pmu.IsNull)
            //    {
            //        buser.ChangeVirtualMoney(pmu.UserID, new M_UserExpHis()
            //        {
            //            score = 20,
            //            ScoreType = (int)M_UserExpHis.SType.Point,
            //            detail = "新用户[" + mu.UserName + "]注册,获得推广积分:"+20
            //        });
            //    }
            //}

            buser.SetLoginState(mu);
            Response.Redirect(rurl);
        }
    }
示例#18
0
        public ActionResult GetRedPacket()
        {
            ViewBag.state = "2";
            ViewBag.err   = "";
            string flow    = Request["flow"];
            string redcode = Request["redcode"];
            string rurl    = Request["rurl"];//成功后的返回页
            //红包相关检测
            M_WX_RedDetail detMod = new M_WX_RedDetail();

            try
            {
                detMod = detBll.SelModelByCode(redcode);
                Appinfo uaMod = uaBll.SelModelByUid(mu.UserID, "wechat");
                if (detMod == null)
                {
                    ViewBag.err = "红包不存在";
                }
                else if (detMod.ZStatus != 1)
                {
                    ViewBag.err = "该红包已经被使用";
                }
                else if (detMod.Amount < 1 || detMod.Amount > 200)
                {
                    ViewBag.err = "红包金额不正确";
                }
                if (!string.IsNullOrEmpty(ViewBag.err))
                {
                    return(View("RedPacket"));
                }
                M_WX_RedPacket redMod = redBll.SelReturnModel(detMod.MainID);
                if (!redMod.Flow.Equals(flow))
                {
                    ViewBag.err = "匹配码不正确";
                }
                else if (redMod.SDate > DateTime.Now)
                {
                    ViewBag.err = "活动尚未开始";
                }
                else if (redMod.EDate < DateTime.Now)
                {
                    ViewBag.err = "活动已经结束";
                }
                if (!string.IsNullOrEmpty(ViewBag.err))
                {
                    return(View("RedPacket"));
                }
                WxAPI api = WxAPI.Code_Get(redMod.AppID);
                WxAPI.AutoSync(Request.RawUrl, api.AppId);
                if (mu.IsNull)
                {
                    ViewBag.err = "用户不存在";
                }
                if (uaMod == null)
                {
                    ViewBag.err = "用户信息不存在";
                }
                if (!string.IsNullOrEmpty(ViewBag.err))
                {
                    return(View("RedPacket"));
                }
                //-------------------
                string apiUrl = "https://api.mch.weixin.qq.com/mmpaymkttransfers/sendredpack";
                //生成提交参数
                WxPayData wxdata = new WxPayData();
                wxdata.SetValue("nonce_str", WxAPI.nonce);
                wxdata.SetValue("mch_billno", api.AppId.Pay_AccountID + DateTime.Now.ToString("yyyyMMdd") + function.GetRandomString(10, 2));
                wxdata.SetValue("mch_id", api.AppId.Pay_AccountID);
                wxdata.SetValue("wxappid", api.AppId.APPID);
                wxdata.SetValue("send_name", SiteConfig.SiteInfo.SiteName);
                //接受红包的用户用户在wxappid下的openid
                wxdata.SetValue("re_openid", uaMod.OpenID);//oDTTbwLa7WuySP0WcJJzYJmErCQ4
                wxdata.SetValue("total_amount", (int)(detMod.Amount * 100));
                wxdata.SetValue("total_num", 1);
                wxdata.SetValue("wishing", redMod.Wishing);   //红包祝福语
                wxdata.SetValue("client_ip", "58.215.75.11"); //调用接口的机器IP地址
                wxdata.SetValue("act_name", redMod.Name);     //活动名称
                wxdata.SetValue("remark", redMod.Remind);
                wxdata.SetValue("sign", wxdata.MakeSign());
                //随机码,签名
                string xml      = wxdata.ToXml();
                string response = HttpService.Post(xml, apiUrl, true, 60, api.AppId);
                //------------------------发放完成(不论成功失败均算已领取,记录好返回)
                detMod.UserID   = mu.UserID;
                detMod.UserName = mu.UserName;
                detMod.UseTime  = DateTime.Now.ToString();
                //WxPayData result = new WxPayData(api.AppId.Pay_Key);
                //result.FromXml(response);
                //if (result.GetValue("return_code").ToString().Equals("SUCCESS"))//return_msg
                //{
                //    detMod.ZStatus = 99;
                //}
                //else
                //{
                //    detMod.ZStatus = -1;
                //    detMod.Remind = response;
                //}
                detMod.ZStatus = 99; detMod.Remind = response;
                detBll.UpdateByID(detMod);
                ViewBag.state  = "3";
                ViewBag.amount = detMod.Amount.ToString("f2");
                return(View("RedPacket"));
            }
            catch (Exception ex)
            {
                ZLLog.L(ZLEnum.Log.pay, "微信红包异常,领取码:" + redcode + ",原因:" + ex.Message);
                ViewBag.state = "3";
                ViewBag.err   = ex.Message;
                //如异常,该红包禁用,等待管理员审核
                detMod.ZStatus = -1;
                detMod.Remind  = ex.Message;
                detBll.UpdateByID(detMod);
                return(View("RedPacket"));
            }
        }
示例#19
0
 public int Insert(Appinfo model)
 {
     return(Sql.insertID(TbName, model.GetParameters(), BLLCommon.GetParas(model), BLLCommon.GetFields(model)));
 }
示例#20
0
        protected void Register_Click(object sender, EventArgs e)
        {
            UserName_T.Text   = UserName_T.Text.Replace(" ", "");
            UserPwd_T.Text    = UserPwd_T.Text.Replace(" ", "");
            ConfirmPwd_T.Text = ConfirmPwd_T.Text.Replace(" ", "");
            if (string.IsNullOrEmpty(UserName_T.Text))
            {
                function.WriteErrMsg("用户名不能为空");
            }
            if (string.IsNullOrEmpty(UserPwd_T.Text))
            {
                function.WriteErrMsg("密码不能为空");
            }
            if (ConfirmPwd_T.Text != UserPwd_T.Text)
            {
                function.WriteErrMsg("密码不一致");
            }
            if (buser.IsExistUName(UserName_T.Text))
            {
                function.WriteErrMsg("用户名已存在,请更换用户名注册");
            }
            //if (buser.IsExist("ume", UserName_T.Text)) { function.WriteErrMsg("用户名已存在,请更换用户名注册"); }
            M_UserInfo mu = new M_UserInfo();

            mu.UserName = UserName_T.Text;
            mu.UserPwd  = StringHelper.MD5(UserPwd_T.Text);
            mu.Email    = Email_T.Text;
            mu.Question = function.GetRandomString(10);
            mu.Answer   = function.GetRandomString(10);
            Appinfo appMod = new Appinfo();

            appMod.SourcePlat = ZType;
            switch (appMod.SourcePlat)
            {
            case "qq":
            {
                if (string.IsNullOrEmpty(QQ_OpenID_Hid.Value))
                {
                    function.WriteErrMsg("绑定信息错误");
                }
                if (appBll.SelModelByOpenID(QQ_OpenID_Hid.Value, "qq") != null)
                {
                    function.WriteErrMsg("该OpenID已存在,不可重复绑定");
                }
                appMod.OpenID = QQ_OpenID_Hid.Value;
                //JObject obj = new QQHelper(QQ_Token_Hid.Value, QQ_OpenID_Hid.Value).GetUserInfo();
                //mu.HoneyName = obj["data"]["nick"].ToString();||obj["nickname"]
            }
            break;

            case "sina":
            {
                if (string.IsNullOrEmpty(Sina_OpenID_Hid.Value))
                {
                    function.WriteErrMsg("未指定openid");
                }
                if (appBll.SelModelByOpenID(Sina_OpenID_Hid.Value, "sina") != null)
                {
                    function.WriteErrMsg("该OpenID已存在,不可重复绑定");
                }
                appMod.OpenID = Sina_OpenID_Hid.Value;
            }
            break;

            case "wechat":
            default:
                throw new Exception("暂未开启该[" + ZType + "]平台注册");
            }
            mu.UserID = buser.AddModel(mu);
            if (mu.UserID < 1)
            {
                function.WriteErrMsg("用户添加失败!!!");
            }
            appMod.UserID = mu.UserID;
            appBll.Insert(appMod);
            buser.SetLoginState(mu);
            Response.Redirect(targetUrl);
        }
示例#21
0
    public void MyBind()
    {
        DataTable  dt = new DataTable();
        M_UserInfo mu = buser.GetLogin();

        switch (SType)
        {
        case 0:    //订单
            orderMod = orderBll.SelModelByOrderNo(OrderNo);

            //Total_L.Text = orderMod.Balance_price.ToString("f2") + "+" + orderMod.Freight.ToString("f2") + "=" + orderMod.Ordersamount.ToString("f2") + "元 (金额+运费)";

            labelmoney01.Text      = orderMod.Receivablesamount.ToString("f2");
            ExpressNum_T.Text      = orderMod.ExpressNum;
            ExpressDelivery_T.Text = orderMod.ExpressDelivery;
            if (orderMod == null || orderMod.id == 0)
            {
                function.WriteErrMsg("订单不存在");
            }
            if (orderMod.Userid != mu.UserID)
            {
                function.WriteErrMsg("该订单不属于你,无法查看");
            }
            dt        = SelByOrderID(orderMod.id);
            price     = orderMod.Balance_price;
            fare      = orderMod.Freight;
            allamount = orderMod.Ordersamount;
            DataTable dt1 = SqlHelper.ExecuteTable("select * from ZL_Payment where PaymentNum='" + orderMod.OrderNo + "' order by PayTime DESC");
            if (dt1.Rows.Count > 0)
            {
                payMod    = payBll.SelModelByPayNo(dt1.Rows[0]["PayNo"].ToString());
                allamount = (double)payMod.MoneyPay;
                arrive    = payMod.ArriveMoney;
                point     = payMod.UsePoint;
            }
            Total_L.Text = price.ToString("f2") + " + " + fare.ToString("f2") + " - " + arrive.ToString("f2") + "-" + (point * 0.01).ToString("f2") + "(" + point + ")" + " = " + allamount.ToString("f2");
            Total_L.Text = Total_L.Text + " (商品总价+运费-优惠券-积分兑换=总额)";
            break;

        case 1:    //购物车
            dt = cartBll.GetCarProList(OrderNo);
            break;
        }
        if (orderMod.Paymentstatus != (int)M_OrderList.PayEnum.HasPayed)
        {
            PayUrl_A.Visible = true;
            DataTable dt1    = SqlHelper.ExecuteTable("select * from ZL_Payment where PaymentNum='" + orderMod.OrderNo + "' order by PayTime DESC");
            string    payurl = "&OrderCode=" + orderMod.OrderNo;
            if (dt1.Rows.Count > 0)
            {
                payurl = "&PayNo=" + dt1.Rows[0]["PayNo"];
            }
            uappMod = uappBll.SelModelByUid(buser.GetLogin().UserID, "wechat");
            if (uappMod != null)
            {
                M_WX_User wxuserMod1 = wxuserBll.SelForOpenid(1, uappMod.OpenID);
                M_WX_User wxuserMod2 = wxuserBll.SelForOpenid(2, uappMod.OpenID);
                if (wxuserMod1 != null && wxuserMod2 == null)
                {
                    PayUrl_A.HRef = "/PayOnline/OrderPay.aspx?appid=1" + payurl;
                }
                else if (wxuserMod2 != null && wxuserMod1 == null)
                {
                    PayUrl_A.HRef = "/PayOnline/OrderPay.aspx?appid=2" + payurl;
                }
                else if (wxuserMod1 == null && wxuserMod2 == null)
                {
                    PayUrl_A.HRef = "/PayOnline/OrderPay.aspx?" + payurl;
                }
            }
            else
            {
                PayUrl_A.HRef = "/PayOnline/OrderPay.aspx?" + payurl;
            }
        }
        if (dt.Rows.Count > 0 && !string.IsNullOrEmpty(dt.Rows[0]["Additional"].ToString()))
        {
            User_Div.Visible = true;
            M_Cart_Travel          model     = JsonConvert.DeserializeObject <M_Cart_Travel>(dt.Rows[0]["Additional"].ToString());
            List <M_Cart_Contract> modelList = new List <M_Cart_Contract>();
            modelList.AddRange(model.Guest);
            modelList.AddRange(model.Contract);
            UserRPT.DataSource = modelList;
            UserRPT.DataBind();
        }
        pronum         = dt.Rows.Count;
        RPT.DataSource = dt;
        RPT.DataBind();
    }
示例#22
0
    //进入该页即开始推广,自动创建用户,关联APPID
    protected void Page_Load(object sender, EventArgs e)
    {
        int       AppID  = DataConverter.CLng(Request.QueryString["appid"]);
        B_User    buser  = new B_User();
        B_UserAPP appBll = new B_UserAPP();
        int       puid   = DataConverter.CLng(Session["WX_PUserID"]);
        string    rurl   = DataConvert.CStr(Session["WX_R"]);

        if (string.IsNullOrEmpty(rurl))
        {
            rurl = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx8c5c2dc7b10a36f3&redirect_uri=http%3a%2f%2fv.wodian8.com%2fUser%2fDefault1.aspx&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect";
        }
        //if (puid < 1) { function.WriteErrMsg("推荐用户不存在"); }
        M_WX_APPID appMod = new M_WX_APPID();//自行置入缓存,使用时取出

        appMod = WxPayApi.Pay_GetByID(AppID);

        string     code         = Request["code"];
        string     access_token = APIHelper.GetWebResult("https://api.weixin.qq.com/sns/oauth2/access_token?appid=" + appMod.APPID + "&secret=" + appMod.Secret + "&code=" + code + "&grant_type=authorization_code");
        JObject    obj          = (JObject)JsonConvert.DeserializeObject(access_token);
        JObject    userobj      = (JObject)JsonConvert.DeserializeObject(APIHelper.GetWebResult("https://api.weixin.qq.com/sns/userinfo?access_token=" + obj["access_token"] + "&openid=" + obj["openid"] + "&lang=zh_CN"));
        string     openID       = obj["openid"].ToString();
        Appinfo    umod         = appBll.SelModelByOpenID(openID, "wechat");
        M_UserInfo mu           = new M_UserInfo();

        if (umod != null)
        {
            mu = buser.SelReturnModel(umod.UserID);
            buser.SetLoginState(mu);
            Response.Redirect(rurl);
        }
        else //新用户则注册
        {
            umod            = new Appinfo();
            mu.UserName     = "******" + DateTime.Now.ToString("yyyyMMddHHmmss") + function.GetRandomString(2).ToLower();
            mu.UserPwd      = StringHelper.MD5(function.GetRandomString(6));
            mu.Email        = function.GetRandomString(10) + "@wx.com";
            mu.Question     = function.GetRandomString(5);
            mu.Answer       = function.GetRandomString(5);
            mu.ParentUserID = puid.ToString();
            mu.TrueName     = userobj["nickname"].ToString();
            mu.GroupID      = 1;
            mu.UserID       = buser.Add(mu);

            umod.UserID     = mu.UserID;
            umod.SourcePlat = "wechat";
            umod.OpenID     = openID;
            appBll.Insert(umod);
            M_Uinfo mubase = new M_Uinfo();
            mubase.UserId = mu.UserID;
            buser.AddBase(mubase);
            //推广人得积分
            if (puid > 0)
            {
                M_UserInfo pmu = buser.SelReturnModel(puid);
                if (!pmu.IsNull)
                {
                    buser.ChangeVirtualMoney(pmu.UserID, new M_UserExpHis()
                    {
                        score     = 20,
                        ScoreType = (int)M_UserExpHis.SType.Point,
                        detail    = "新用户[" + mu.UserName + "]注册,获得推广积分:" + 20
                    });
                }
            }
            buser.SetLoginState(mu);
            Response.Redirect(rurl);
        }
    }
示例#23
0
    //获取订单操作按钮,分为已下单(未付款),已下单(已付款),已完结(显示)
    public string Getoperator(DataRowView dr)
    {
        M_OrderList orderMod    = new M_OrderList();
        string      result      = "";
        int         orderStatus = DataConverter.CLng(dr["OrderStatus"]);
        int         payStatus   = DataConverter.CLng(dr["Paymentstatus"]);
        int         oid         = Convert.ToInt32(dr["ID"]);
        int         aside       = Convert.ToInt32(dr["Aside"]);
        string      orderNo     = dr["OrderNo"].ToString();

        //----------如果已经删除,则不执行其余的判断
        if (aside != 0)//如果已删除,则不进行其余的判断
        {
            result += "<div><a href='javascript:;' data-oid='" + oid + "' onclick='ConfirmAction(this,\"reconver\");'>还原订单</a></div>";
            result += "<div><a href='javascript:;' data-oid='" + oid + "' onclick='ConfirmAction(this,\"realdel\");'>彻底删除</a></div>";
            return(result);
        }
        if (payStatus == (int)M_OrderList.PayEnum.NoPay)//未付款,显示倒计时和付款链接
        {
            bool isnormal = true;
            //订单过期判断
            if (SiteConfig.ShopConfig.OrderExpired > 0)
            {
                int seconds = GetOrderUnix(dr);
                if (seconds <= 0)
                {
                    result += "<span class='gray9'>订单关闭</span>"; isnormal = false;
                }
                else
                {
                    result += "<span class='ordertime' data-time='" + seconds + "'></span>";
                }
            }
            DataTable dt     = SqlHelper.ExecuteTable("select * from ZL_Payment where PaymentNum='" + orderNo + "' order by PayTime DESC");
            string    payurl = "&OrderCode=" + orderNo;
            if (dt.Rows.Count > 0)
            {
                payurl = "&PayNo=" + dt.Rows[0]["PayNo"];
            }
            //订单未完成,且为正常状态,显示付款
            if (isnormal && OrderHelper.IsCanPay(dr.Row))
            {
                uappMod = uappBll.SelModelByUid(buser.GetLogin().UserID, "wechat");
                if (uappMod != null)
                {
                    M_WX_User wxuserMod1 = wxuserBll.SelForOpenid(1, uappMod.OpenID);
                    M_WX_User wxuserMod2 = wxuserBll.SelForOpenid(2, uappMod.OpenID);
                    if (wxuserMod1 != null && wxuserMod2 == null)
                    {
                        result += "<br/><a href='/Payonline/OrderPay.aspx?appid=1" + payurl + "' class='btn btn-danger btn-sm'> 前往付款</a> ";
                    }
                    else if (wxuserMod2 != null && wxuserMod1 == null)
                    {
                        result += "<br/><a href='/Payonline/OrderPay.aspx?appid=2" + payurl + "' class='btn btn-danger btn-sm'> 前往付款</a> ";
                    }
                    else if (wxuserMod1 == null && wxuserMod2 == null)
                    {
                        result += "<br/><a href='/Payonline/OrderPay.aspx?" + payurl + "' class='btn btn-danger btn-sm'> 前往付款</a> ";
                    }
                }
                else
                {
                    result += "<br/><a href='/Payonline/OrderPay.aspx?" + payurl + "' class='btn btn-danger btn-sm'> 前往付款</a> ";
                }
                //DataTable dt = SqlHelper.ExecuteTable(CommandType.Text, "select * from ZL_Payment where PaymentNum='" + orderNo + "'", null);
                //if (dt.Rows.Count > 0)
                //{
                //    string redirect_uri = HttpUtility.UrlEncode("http://www.wodian8.com/Payonline/wxpayonline.aspx?PayNo=" + dt.Rows[0]["PayNo"].ToString());
                //    string url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx8c5c2dc7b10a36f3&redirect_uri=" + redirect_uri + "&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect";
                //    result += "<br/><a href='" + url + "' class='btn btn-danger btn-sm'> 前往付款</a> ";
                //}
                //else
                //    result += "<br/><a href='/Payonline/OrderPay.aspx?OrderCode=" + orderNo + "' class='btn btn-danger btn-sm'> 前往付款</a> ";
            }
            result += "<span><a href='javascript:;' data-oid='" + oid + "' class='btn btn-warning btn-sm' onclick='ConfirmAction(this,\"del\");'><i class='fa fa-close'></i> 取消订单</a></span>";
        }
        else
        {
            //---物流
            switch (Convert.ToInt32(dr["StateLogistics"]))
            {
            case 1:
                result += "<div><a href='javascript:;' class='btn btn-primary' data-oid='" + oid + "' onclick='ConfirmAction(this,\"receive\");'>确认收货</a></div>";
                break;
            }
            //已付款,但处理申请退款等状态
            if (orderStatus < (int)M_OrderList.StatusEnum.Normal)
            {
                //result += "<a href='AddShare.aspx?CartID=" + dr["CartID"] + "'>取消退款</a><br />";
            }
            //已付款未完结,可申请退款
            if (orderStatus >= (int)M_OrderList.StatusEnum.Normal && orderStatus < (int)M_OrderList.StatusEnum.OrderFinish)
            {
                result += "<a href='javascript:;' onclick='ShowDrawback(" + oid + ");'>取消订单</a>";
            }
            //已付款已完结,可评价晒单
            if (orderStatus >= (int)M_OrderList.StatusEnum.OrderFinish)//已完结
            {
                if (!(dr["AddStatus"].ToString().Contains("comment")))
                {
                    result += "<a href='AddShare.aspx?OrderID=" + dr["ID"] + "'><i class='fa fa-edit'></i> 评价晒单</a>";
                }
                //result += "<a href='/Shop/" + dr["ProID"] + ".aspx' target='_blank' class='btn btn-primary'>立即购买</a>";
            }
        }
        return(result);
    }