예제 #1
0
        private void BtnSave_Click(object sender, EventArgs e)
        {
            IList <MenuInfo> initFuwuMenus = VShopHelper.GetInitFuwuMenus();
            FWMenu           menu          = new FWMenu
            {
                button = new List <FWButton>()
            };
            List <FWButton> list2 = menu.button as List <FWButton>;

            foreach (MenuInfo info in initFuwuMenus)
            {
                FWButton item = this.BuildMenu(info);
                if ((info.Chilren != null) && (info.Chilren.Count > 0))
                {
                    item.subButton = new List <FWButton>();
                    foreach (MenuInfo info2 in info.Chilren)
                    {
                        (item.subButton as List <FWButton>).Add(this.BuildMenu(info2));
                    }
                }
                list2.Add(item);
            }
            if (!AlipayFuwuConfig.CommSetConfig(SettingsManager.GetMasterSettings(true).AlipayAppid, base.Server.MapPath("~/"), "GBK"))
            {
                base.Response.Write("<script>alert('您的服务窗配置信息错误,请您先检查配置!');location.href='AliFuwuConfig.aspx'</script>");
            }
            else
            {
                AlipayMobilePublicMenuUpdateResponse response = AliOHHelper.MenuUpdate(menu);
                if (((response != null) && !response.IsError) && (response.Code == "200"))
                {
                    this.ShowMsg("自定义菜单已同步到支付宝服务窗!", true);
                }
                else
                {
                    this.ShowMsg("操作失败!" + response.Msg, false);
                }
            }
        }
        private void ShowQRImage()
        {
            string str = "bind" + DateTime.Now.ToString("yyyyMMddHHmmss");

            try
            {
                QrcodeInfo info2 = new QrcodeInfo
                {
                    codeType     = "TEMP",
                    showLogo     = "Y",
                    expireSecond = 600
                };
                codeInfo info3 = new codeInfo();
                scene    scene = new scene
                {
                    sceneId = str
                };
                info3.scene    = scene;
                info2.codeInfo = info3;
                QrcodeInfo codeInfo = info2;
                this.hiddSceneId.Value = str;
                AlipayMobilePublicQrcodeCreateResponse response = AliOHHelper.QrcodeSend(codeInfo);
                if ((response != null) && (response.Code == 200L))
                {
                    this.imgQRCode.ImageUrl = response.CodeImg;
                }
                else
                {
                    this.imgQRCode.AlternateText = "未成功获取服务窗授权";
                }
            }
            catch (Exception exception)
            {
                AliOHHelper.log(exception.Message);
            }
        }
예제 #3
0
        private void BtnSave_Click(object sender, System.EventArgs e)
        {
            System.Collections.Generic.IList <MenuInfo> initFuwuMenus = VShopHelper.GetInitFuwuMenus();
            FWMenu fWMenu = new FWMenu();

            fWMenu.button = new System.Collections.Generic.List <FWButton>();
            System.Collections.Generic.List <FWButton> list = fWMenu.button as System.Collections.Generic.List <FWButton>;
            foreach (MenuInfo current in initFuwuMenus)
            {
                FWButton fWButton = this.BuildMenu(current);
                if (current.Chilren != null && current.Chilren.Count > 0)
                {
                    fWButton.subButton = new System.Collections.Generic.List <FWButton>();
                    foreach (MenuInfo current2 in current.Chilren)
                    {
                        (fWButton.subButton as System.Collections.Generic.List <FWButton>).Add(this.BuildMenu(current2));
                    }
                }
                list.Add(fWButton);
            }
            SiteSettings masterSettings = SettingsManager.GetMasterSettings(true);
            string       alipayAppid    = masterSettings.AlipayAppid;

            if (!AlipayFuwuConfig.CommSetConfig(alipayAppid, base.Server.MapPath("~/"), "GBK"))
            {
                base.Response.Write("<script>alert('您的服务窗配置信息错误,请您先检查配置!');location.href='AliFuwuConfig.aspx'</script>");
                return;
            }
            AlipayMobilePublicMenuUpdateResponse alipayMobilePublicMenuUpdateResponse = AliOHHelper.MenuUpdate(fWMenu);

            if (alipayMobilePublicMenuUpdateResponse != null && !alipayMobilePublicMenuUpdateResponse.IsError && alipayMobilePublicMenuUpdateResponse.Code == "200")
            {
                this.ShowMsg("自定义菜单已同步到支付宝服务窗!", true);
                return;
            }
            this.ShowMsg("操作失败!" + alipayMobilePublicMenuUpdateResponse.Msg, false);
        }
예제 #4
0
        public void ProcessRequest(System.Web.HttpContext context)
        {
            this.siteSettings = SettingsManager.GetMasterSettings(true);
            this.appid        = this.siteSettings.AlipayAppid;
            AliOHHelper.log(context.Request.Form.ToString());
            if (AlipayFuwuConfig.appId.Length < 15 && !AlipayFuwuConfig.CommSetConfig(this.appid, context.Server.MapPath("~/"), "GBK"))
            {
                context.Response.Write(AlipayFuwuConfig.errstr);
                return;
            }
            if ("alipay.service.check".Equals(AliOHHelper.getRequestString("service", context)))
            {
                AliOHHelper.verifygw(context);
                return;
            }
            if ("alipay.mobile.public.message.notify".Equals(AliOHHelper.getRequestString("service", context)))
            {
                string requestString = AliOHHelper.getRequestString("biz_content", context);
                string xmlNode       = AliOHHelper.getXmlNode(requestString, "EventType");
                string xmlNode2      = AliOHHelper.getXmlNode(requestString, "FromUserId");
                this.UserInfo = AliOHHelper.getXmlNode(requestString, "UserInfo");
                string xmlNode3 = AliOHHelper.getXmlNode(requestString, "ActionParam");
                AliOHHelper.getXmlNode(requestString, "AgreementId");
                AliOHHelper.getXmlNode(requestString, "AccountNo");
                AliOHHelper.getXmlNode(requestString, "AppId");
                AliOHHelper.getXmlNode(requestString, "CreateTime");
                string xmlNode4 = AliOHHelper.getXmlNode(requestString, "MsgType");
                string xmlNode5 = AliOHHelper.getXmlNode(requestString, "Content");
                string a;
                if ((a = xmlNode4) != null)
                {
                    if (!(a == "event"))
                    {
                        if (!(a == "text"))
                        {
                            if (!(a == "image"))
                            {
                                goto IL_22F;
                            }
                            goto IL_1E3;
                        }
                    }
                    else
                    {
                        try
                        {
                            this.replyAction(xmlNode2, xmlNode, xmlNode5, xmlNode3);
                            goto IL_22F;
                        }
                        catch (System.Exception ex)
                        {
                            AliOHHelper.log(ex.Message.ToString());
                            goto IL_22F;
                        }
                    }
                    try
                    {
                        if (!string.IsNullOrEmpty(xmlNode2))
                        {
                            WeiXinHelper.UpdateRencentAliOpenID(xmlNode2);
                        }
                    }
                    catch (System.Exception ex2)
                    {
                        AliOHHelper.log(ex2.Message.ToString());
                    }
                    try
                    {
                        this.replyAction(xmlNode2, "", xmlNode5, xmlNode3);
                        goto IL_22F;
                    }
                    catch (System.Exception ex3)
                    {
                        AliOHHelper.log(ex3.Message.ToString());
                        goto IL_22F;
                    }
IL_1E3:
                    Articles articles = new Articles
                    {
                        toUserId = xmlNode2,
                        msgType  = "text",
                        text     = new MessageText
                        {
                            content = "服务窗暂时不接收图片消息"
                        }
                    };
                    AliOHHelper.log(AliOHHelper.CustomSend(articles).Body);
                }
IL_22F:
                AliOHHelper.verifyRequestFromAliPay(context, xmlNode2, this.appid);
            }
        }
예제 #5
0
        private void replyAction(string FromUserId, string eventType, string textContent, string ActionParam)
        {
            Articles articles = new Articles
            {
                toUserId = FromUserId,
                msgType  = "text",
                text     = new MessageText
                {
                    content = "系统未找到相关信息!"
                }
            };

            if (eventType != "")
            {
                if ("follow".Equals(eventType))
                {
                    if (!string.IsNullOrEmpty(FromUserId))
                    {
                        MemberProcessor.AddFuwuFollowUser(FromUserId);
                    }
                    string aliOHFollowRelayTitle = this.siteSettings.AliOHFollowRelayTitle;
                    Hidistro.Entities.VShop.ReplyInfo subscribeReply = AliFuwuReplyHelper.GetSubscribeReply();
                    if (subscribeReply != null)
                    {
                        if (subscribeReply.MessageType == MessageType.Text)
                        {
                            TextReplyInfo textReplyInfo = subscribeReply as TextReplyInfo;
                            articles.text.content = textReplyInfo.Text;
                        }
                        else if (subscribeReply.ArticleID > 0)
                        {
                            ArticleInfo articleInfo = ArticleHelper.GetArticleInfo(subscribeReply.ArticleID);
                            if (articleInfo != null)
                            {
                                articles = this.GetAlipayArticlesFromArticleInfo(articleInfo, Globals.HostPath(System.Web.HttpContext.Current.Request.Url), FromUserId);
                            }
                            else
                            {
                                articles.text.content = aliOHFollowRelayTitle;
                            }
                        }
                    }
                    else
                    {
                        articles.text.content = aliOHFollowRelayTitle;
                    }
                }
                else if ("unfollow".Equals(eventType))
                {
                    if (!string.IsNullOrEmpty(FromUserId))
                    {
                        MemberProcessor.DelFuwuFollowUser(FromUserId);
                    }
                }
                else if ("click".Equals(eventType))
                {
                    int num = 0;
                    if (ActionParam != "" && int.TryParse(ActionParam, out num) && num > 0)
                    {
                        Hidistro.Entities.VShop.MenuInfo fuwuMenu = VShopHelper.GetFuwuMenu(num);
                        if (fuwuMenu != null)
                        {
                            Hidistro.Entities.VShop.ReplyInfo reply = AliFuwuReplyHelper.GetReply(fuwuMenu.ReplyId);
                            if (reply != null)
                            {
                                ArticleInfo articleInfo2 = ArticleHelper.GetArticleInfo(reply.ArticleID);
                                if (articleInfo2 != null)
                                {
                                    articles = this.GetAlipayArticlesFromArticleInfo(articleInfo2, Globals.HostPath(System.Web.HttpContext.Current.Request.Url), FromUserId);
                                }
                            }
                        }
                    }
                }
                else if ("enter".Equals(eventType))
                {
                    if (!string.IsNullOrEmpty(this.UserInfo))
                    {
                        MemberInfo openIdMember = MemberProcessor.GetOpenIdMember(FromUserId, "fuwu");
                        if (openIdMember != null && openIdMember.AlipayLoginId.StartsWith("FW*"))
                        {
                            JObject jObject       = JsonConvert.DeserializeObject(this.UserInfo) as JObject;
                            string  alipayLoginId = "";
                            string  text          = "";
                            if (jObject["logon_id"] != null)
                            {
                                alipayLoginId = jObject["logon_id"].ToString();
                            }
                            if (jObject["user_name"] != null)
                            {
                                text = jObject["user_name"].ToString();
                            }
                            if (text != "" && text != "")
                            {
                                openIdMember.AlipayLoginId  = alipayLoginId;
                                openIdMember.AlipayUsername = text;
                                MemberProcessor.SetAlipayInfos(openIdMember);
                            }
                        }
                    }
                    if (!ActionParam.Contains("sceneId"))
                    {
                        return;
                    }
                    JObject jObject2 = JsonConvert.DeserializeObject(ActionParam) as JObject;
                    if (jObject2["scene"]["sceneId"] != null)
                    {
                        string text2 = jObject2["scene"]["sceneId"].ToString();
                        if (text2.StartsWith("bind"))
                        {
                            if (AlipayFuwuConfig.BindAdmin.Count > 10)
                            {
                                AlipayFuwuConfig.BindAdmin.Clear();
                            }
                            if (AlipayFuwuConfig.BindAdmin.ContainsKey(text2))
                            {
                                AlipayFuwuConfig.BindAdmin[text2] = FromUserId;
                            }
                            else
                            {
                                AlipayFuwuConfig.BindAdmin.Add(text2, FromUserId);
                            }
                            articles.text.content = "您正在尝试绑定服务窗管理员身份!";
                        }
                    }
                }
            }
            else if (textContent != "")
            {
                articles = null;
                System.Collections.Generic.IList <Hidistro.Entities.VShop.ReplyInfo> replies = AliFuwuReplyHelper.GetReplies(ReplyType.Keys);
                if (replies != null && replies.Count > 0)
                {
                    foreach (Hidistro.Entities.VShop.ReplyInfo current in replies)
                    {
                        if (current != null)
                        {
                            if (current.MatchType == MatchType.Equal && current.Keys == textContent)
                            {
                                if (current.MessageType == MessageType.Text)
                                {
                                    articles = new Articles
                                    {
                                        toUserId = FromUserId,
                                        msgType  = "text",
                                        text     = new MessageText
                                        {
                                            content = ""
                                        }
                                    };
                                    TextReplyInfo textReplyInfo2 = current as TextReplyInfo;
                                    articles.text.content = textReplyInfo2.Text;
                                    break;
                                }
                                if (current.ArticleID > 0)
                                {
                                    ArticleInfo articleInfo3 = ArticleHelper.GetArticleInfo(current.ArticleID);
                                    if (articleInfo3 != null)
                                    {
                                        articles = this.GetAlipayArticlesFromArticleInfo(articleInfo3, Globals.HostPath(System.Web.HttpContext.Current.Request.Url), FromUserId);
                                        if (articles != null)
                                        {
                                            break;
                                        }
                                    }
                                }
                            }
                            if (current.MatchType == MatchType.Like && current.Keys.Contains(textContent))
                            {
                                if (current.MessageType == MessageType.Text)
                                {
                                    articles = new Articles
                                    {
                                        toUserId = FromUserId,
                                        msgType  = "text",
                                        text     = new MessageText
                                        {
                                            content = ""
                                        }
                                    };
                                    TextReplyInfo textReplyInfo3 = current as TextReplyInfo;
                                    articles.text.content = textReplyInfo3.Text;
                                    break;
                                }
                                if (current.ArticleID > 0)
                                {
                                    ArticleInfo articleInfo4 = ArticleHelper.GetArticleInfo(current.ArticleID);
                                    if (articleInfo4 != null)
                                    {
                                        articles = this.GetAlipayArticlesFromArticleInfo(articleInfo4, Globals.HostPath(System.Web.HttpContext.Current.Request.Url), FromUserId);
                                        if (articles != null)
                                        {
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            if (articles == null)
            {
                System.Collections.Generic.IList <Hidistro.Entities.VShop.ReplyInfo> replies2 = AliFuwuReplyHelper.GetReplies(ReplyType.NoMatch);
                if (replies2 != null && replies2.Count > 0)
                {
                    using (System.Collections.Generic.IEnumerator <Hidistro.Entities.VShop.ReplyInfo> enumerator2 = replies2.GetEnumerator())
                    {
                        while (enumerator2.MoveNext())
                        {
                            Hidistro.Entities.VShop.ReplyInfo current2 = enumerator2.Current;
                            if (current2.MessageType == MessageType.Text)
                            {
                                articles = new Articles
                                {
                                    toUserId = FromUserId,
                                    msgType  = "text",
                                    text     = new MessageText
                                    {
                                        content = ""
                                    }
                                };
                                TextReplyInfo textReplyInfo4 = current2 as TextReplyInfo;
                                articles.text.content = textReplyInfo4.Text;
                                break;
                            }
                            if (current2.ArticleID > 0)
                            {
                                ArticleInfo articleInfo5 = ArticleHelper.GetArticleInfo(current2.ArticleID);
                                if (articleInfo5 != null)
                                {
                                    articles = this.GetAlipayArticlesFromArticleInfo(articleInfo5, Globals.HostPath(System.Web.HttpContext.Current.Request.Url), FromUserId);
                                    if (articles != null)
                                    {
                                        break;
                                    }
                                }
                            }
                        }
                        goto IL_674;
                    }
                }
                articles = new Articles
                {
                    toUserId = FromUserId,
                    msgType  = "text",
                    text     = new MessageText
                    {
                        content = "系统未找到相关信息!"
                    }
                };
            }
IL_674:
            AliOHHelper.log(AliOHHelper.CustomSend(articles).Body);
        }
예제 #6
0
파일: SendAllEdit.cs 프로젝트: zwkjgs/XKD
        protected void Page_Load(object sender, System.EventArgs e)
        {
            if (!base.IsPostBack)
            {
                if (this.type == "getarticleinfo")
                {
                    base.Response.ContentType = "application/json";
                    string s   = "{\"type\":\"0\",\"tips\":\"操作失败\"}";
                    int    num = Globals.RequestFormNum("articleid");
                    if (num > 0)
                    {
                        ArticleInfo articleInfo = ArticleHelper.GetArticleInfo(num);
                        if (articleInfo != null)
                        {
                            System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder();
                            switch (articleInfo.ArticleType)
                            {
                            case ArticleType.News:
                                s = string.Concat(new object[]
                                {
                                    "{\"type\":\"1\",\"articletype\":",
                                    (int)articleInfo.ArticleType,
                                    ",\"title\":\"",
                                    this.String2Json(articleInfo.Title),
                                    "\",\"date\":\"",
                                    this.String2Json(articleInfo.PubTime.ToString("M月d日")),
                                    "\",\"imgurl\":\"",
                                    this.String2Json(articleInfo.ImageUrl),
                                    "\",\"memo\":\"",
                                    this.String2Json(articleInfo.Memo),
                                    "\"}"
                                });
                                goto IL_30E;

                            case ArticleType.List:
                            {
                                System.Collections.Generic.IList <ArticleItemsInfo> itemsInfo = articleInfo.ItemsInfo;
                                foreach (ArticleItemsInfo current in itemsInfo)
                                {
                                    stringBuilder.Append(string.Concat(new string[]
                                        {
                                            "{\"title\":\"",
                                            this.String2Json(current.Title),
                                            "\",\"imgurl\":\"",
                                            this.String2Json(current.ImageUrl),
                                            "\"},"
                                        }));
                                }
                                s = string.Concat(new object[]
                                    {
                                        "{\"type\":\"1\",\"articletype\":",
                                        (int)articleInfo.ArticleType,
                                        ",\"title\":\"",
                                        this.String2Json(articleInfo.Title),
                                        "\",\"date\":\"",
                                        this.String2Json(articleInfo.PubTime.ToString("M月d日")),
                                        "\",\"imgurl\":\"",
                                        this.String2Json(articleInfo.ImageUrl),
                                        "\",\"items\":[",
                                        stringBuilder.ToString().Trim(new char[]
                                        {
                                            ','
                                        }),
                                        "]}"
                                    });
                                goto IL_30E;
                            }
                            }
                            s = string.Concat(new object[]
                            {
                                "{\"type\":\"1\",\"articletype\":",
                                (int)articleInfo.ArticleType,
                                ",\"title\":\"",
                                this.String2Json(articleInfo.Title),
                                "\",\"date\":\"",
                                this.String2Json(articleInfo.PubTime.ToString("M月d日")),
                                "\",\"imgurl\":\"",
                                this.String2Json(articleInfo.ImageUrl),
                                "\",\"memo\":\"",
                                this.String2Json(articleInfo.Content),
                                "\"}"
                            });
                        }
                    }
IL_30E:
                    base.Response.Write(s);
                    base.Response.End();
                    return;
                }
                if (this.type == "postdata")
                {
                    base.Response.ContentType = "application/json";
                    this.sendID = Globals.RequestFormNum("sendid");
                    int    num2         = Globals.RequestFormNum("sendtype");
                    int    num3         = Globals.RequestFormNum("msgtype");
                    int    articleid    = Globals.RequestFormNum("articleid");
                    string title        = Globals.RequestFormStr("title");
                    string content      = Globals.RequestFormStr("content");
                    int    isoldarticle = Globals.RequestFormNum("isoldarticle");
                    string text         = this.SavePostData(num3, articleid, title, content, isoldarticle, this.sendID, true);
                    string s2;
                    if (string.IsNullOrEmpty(text))
                    {
                        MessageType messageType = (MessageType)num3;
                        string      arg_3DF_0   = string.Empty;
                        Articles    Articles    = new Articles();
                        Articles.msgType = "text";
                        string storeUrl = Globals.HostPath(System.Web.HttpContext.Current.Request.Url);
                        if (messageType == MessageType.List || messageType == MessageType.News)
                        {
                            this.sendID = Globals.ToNum(this.SavePostData(num3, articleid, title, content, isoldarticle, this.sendID, false));
                            ArticleInfo articleInfo2 = ArticleHelper.GetArticleInfo(articleid);
                            if (articleInfo2 == null)
                            {
                                s2 = "{\"type\":\"0\",\"tips\":\"素材不存在了\"}";
                                base.Response.Write(s2);
                                base.Response.End();
                            }
                            Articles = this.GetAlipayArticlesFromArticleInfo(articleInfo2, storeUrl);
                        }
                        else
                        {
                            this.sendID   = Globals.ToNum(this.SavePostData(num3, articleid, title, content, isoldarticle, this.sendID, false));
                            Articles.text = new MessageText
                            {
                                content = Globals.StripHtmlXmlTags(content)
                            };
                        }
                        SiteSettings masterSettings = SettingsManager.GetMasterSettings(true);
                        if (AlipayFuwuConfig.appId.Length < 15)
                        {
                            AlipayFuwuConfig.CommSetConfig(masterSettings.AlipayAppid, base.Server.MapPath("~/"), "GBK");
                        }
                        if (num2 == 1)
                        {
                            AlipayMobilePublicMessageTotalSendResponse alipayMobilePublicMessageTotalSendResponse = AliOHHelper.TotalSend(Articles);
                            if (!alipayMobilePublicMessageTotalSendResponse.IsError && alipayMobilePublicMessageTotalSendResponse.Code == "200")
                            {
                                s2 = "{\"type\":\"1\",\"tips\":\"服务窗群发成功,请于一天后到服务窗后台查询送达结果!\"}";
                                string msgid = "";
                                if (!string.IsNullOrEmpty(alipayMobilePublicMessageTotalSendResponse.Data) && alipayMobilePublicMessageTotalSendResponse.Data.Length > 50)
                                {
                                    msgid = alipayMobilePublicMessageTotalSendResponse.Data.Substring(0, 49);
                                }
                                int alypayUserNum = WeiXinHelper.getAlypayUserNum();
                                WeiXinHelper.UpdateMsgId(this.sendID, msgid, 1, alypayUserNum, alypayUserNum, "");
                            }
                            else
                            {
                                s2 = "{\"type\":\"0\",\"tips\":\"" + alipayMobilePublicMessageTotalSendResponse.Msg + "\"}";
                                WeiXinHelper.UpdateMsgId(this.sendID, "", 2, 0, 0, alipayMobilePublicMessageTotalSendResponse.Body);
                            }
                        }
                        else
                        {
                            System.Collections.Generic.List <string> sendList = new System.Collections.Generic.List <string>();
                            System.Data.DataTable rencentAliOpenID            = WeiXinHelper.GetRencentAliOpenID();
                            if (rencentAliOpenID != null)
                            {
                                for (int i = 0; i < rencentAliOpenID.Rows.Count; i++)
                                {
                                    sendList.Add(rencentAliOpenID.Rows[i][0].ToString());
                                }
                            }
                            if (sendList.Count > 0)
                            {
                                WeiXinHelper.UpdateMsgId(this.sendID, "", 0, 0, sendList.Count, "");
                                new System.Threading.Thread(() =>
                                {
                                    try
                                    {
                                        bool flag = false;
                                        foreach (string current3 in sendList)
                                        {
                                            if (current3.Length > 16)
                                            {
                                                Articles.toUserId = current3;
                                                AlipayMobilePublicMessageCustomSendResponse alipayMobilePublicMessageCustomSendResponse = AliOHHelper.CustomSend(Articles);
                                                if (alipayMobilePublicMessageCustomSendResponse != null && alipayMobilePublicMessageCustomSendResponse.IsError)
                                                {
                                                    AliOHHelper.log(alipayMobilePublicMessageCustomSendResponse.Body);
                                                }
                                                else
                                                {
                                                    flag = true;
                                                    WeiXinHelper.UpdateAddSendCount(this.sendID, 1, -1);
                                                }
                                                System.Threading.Thread.Sleep(10);
                                            }
                                        }
                                        if (flag)
                                        {
                                            WeiXinHelper.UpdateAddSendCount(this.sendID, 0, 1);
                                        }
                                        else
                                        {
                                            WeiXinHelper.UpdateAddSendCount(this.sendID, 0, 2);
                                        }
                                        System.Threading.Thread.Sleep(10);
                                    }
                                    catch (System.Exception ex)
                                    {
                                        AliOHHelper.log(ex.Message.ToString());
                                    }
                                }).Start();
                                s2 = "{\"type\":\"1\",\"tips\":\"信息正在后台推送中,请稍后刷新群发列表查看结果\"}";
                            }
                            else
                            {
                                s2 = "{\"type\":\"0\",\"tips\":\"暂时没有关注的用户可以发送信息\"}";
                            }
                        }
                    }
                    else
                    {
                        s2 = "{\"type\":\"0\",\"tips\":\"" + text + "\"}";
                    }
                    base.Response.Write(s2);
                    base.Response.End();
                    return;
                }
                if (this.sendID > 0)
                {
                    this.hdfSendID.Value = this.sendID.ToString();
                    SendAllInfo sendAllInfo = WeiXinHelper.GetSendAllInfo(this.sendID);
                    if (sendAllInfo != null)
                    {
                        MessageType messageType2 = sendAllInfo.MessageType;
                        this.hdfMessageType.Value = ((int)sendAllInfo.MessageType).ToString();
                        int articleID = sendAllInfo.ArticleID;
                        this.hdfArticleID.Value = articleID.ToString();
                        this.txtTitle.Text      = sendAllInfo.Title;
                        switch (messageType2)
                        {
                        case MessageType.Text:
                            this.fkContent.Text = sendAllInfo.Content;
                            break;

                        case MessageType.News:
                            if (articleID <= 0)
                            {
                                this.hdfIsOldArticle.Value = "1";
                                NewsReplyInfo newsReplyInfo = ReplyHelper.GetReply(this.sendID) as NewsReplyInfo;
                                if (newsReplyInfo != null && newsReplyInfo.NewsMsg != null && newsReplyInfo.NewsMsg.Count != 0)
                                {
                                    this.htmlInfo = string.Concat(new string[]
                                    {
                                        "<div class=\"mate-inner\"><h3 id=\"singelTitle\">",
                                        newsReplyInfo.NewsMsg[0].Title,
                                        "</h3><span>",
                                        newsReplyInfo.LastEditDate.ToString("M月d日"),
                                        "</span><div class=\"mate-img\"><img id=\"img1\" src=\"",
                                        newsReplyInfo.NewsMsg[0].PicUrl,
                                        "\" class=\"img-responsive\"></div><div class=\"mate-info\" id=\"Lbmsgdesc\">",
                                        newsReplyInfo.NewsMsg[0].Description,
                                        "</div><div class=\"red-all clearfix\"><strong class=\"fl\">查看全文</strong><em class=\"fr\">&gt;</em></div></div>"
                                    });
                                }
                            }
                            break;

                        case MessageType.List:
                            if (articleID <= 0)
                            {
                                this.hdfIsOldArticle.Value = "1";
                                NewsReplyInfo newsReplyInfo2 = ReplyHelper.GetReply(this.sendID) as NewsReplyInfo;
                                if (newsReplyInfo2 != null)
                                {
                                    System.Text.StringBuilder stringBuilder2 = new System.Text.StringBuilder();
                                    if (newsReplyInfo2.NewsMsg != null && newsReplyInfo2.NewsMsg.Count > 0)
                                    {
                                        int num4 = 0;
                                        foreach (NewsMsgInfo current2 in newsReplyInfo2.NewsMsg)
                                        {
                                            num4++;
                                            if (num4 == 1)
                                            {
                                                stringBuilder2.Append(string.Concat(new string[]
                                                {
                                                    "<div class=\"mate-inner top\">                 <div class=\"mate-img\" >                     <img id=\"img1\" src=\"",
                                                    current2.PicUrl,
                                                    "\" class=\"img-responsive\">                     <div class=\"title\" id=\"title1\">",
                                                    current2.Title,
                                                    "</div>                 </div>             </div>"
                                                }));
                                            }
                                            else
                                            {
                                                stringBuilder2.Append(string.Concat(new string[]
                                                {
                                                    "             <div class=\"mate-inner\">                 <div class=\"child-mate\">                     <div class=\"child-mate-title clearfix\">                         <div class=\"title\">",
                                                    current2.Title,
                                                    "</div>                         <div class=\"img\">                             <img src=\"",
                                                    current2.PicUrl,
                                                    "\" class=\"img-responsive\">                         </div>                     </div>                 </div>             </div>"
                                                }));
                                            }
                                        }
                                        this.htmlInfo = stringBuilder2.ToString();
                                    }
                                }
                            }
                            break;
                        }
                    }
                    else
                    {
                        base.Response.Redirect("sendalllist.aspx");
                        base.Response.End();
                    }
                }
                else if (this.LocalArticleID > 0)
                {
                    ArticleInfo articleInfo3 = ArticleHelper.GetArticleInfo(this.LocalArticleID);
                    if (articleInfo3 != null)
                    {
                        this.hdfArticleID.Value   = this.LocalArticleID.ToString();
                        this.hdfMessageType.Value = ((int)articleInfo3.ArticleType).ToString();
                    }
                }
                if (string.IsNullOrEmpty(this.htmlInfo))
                {
                    this.htmlInfo = "<div class=\"exit-shop-info\">内容区</div>";
                }
                this.litInfo.Text = this.htmlInfo;
            }
        }
예제 #7
0
        public void ProcessRequest(HttpContext context)
        {
            Articles articles2;

            this.siteSettings = SettingsManager.GetMasterSettings(true);
            this.appid        = this.siteSettings.AlipayAppid;
            AliOHHelper.log(context.Request.Form.ToString());
            if ((AlipayFuwuConfig.appId.Length < 15) && !AlipayFuwuConfig.CommSetConfig(this.appid, context.Server.MapPath("~/"), "GBK"))
            {
                context.Response.Write(AlipayFuwuConfig.errstr);
                return;
            }
            if ("alipay.service.check".Equals(AliOHHelper.getRequestString("service", context)))
            {
                AliOHHelper.verifygw(context);
                return;
            }
            if (!"alipay.mobile.public.message.notify".Equals(AliOHHelper.getRequestString("service", context)))
            {
                return;
            }
            string xml       = AliOHHelper.getRequestString("biz_content", context);
            string eventType = AliOHHelper.getXmlNode(xml, "EventType");
            string str3      = AliOHHelper.getXmlNode(xml, "FromUserId");

            this.UserInfo = AliOHHelper.getXmlNode(xml, "UserInfo");
            string actionParam = AliOHHelper.getXmlNode(xml, "ActionParam");

            AliOHHelper.getXmlNode(xml, "AgreementId");
            AliOHHelper.getXmlNode(xml, "AccountNo");
            AliOHHelper.getXmlNode(xml, "AppId");
            AliOHHelper.getXmlNode(xml, "CreateTime");
            string str5        = AliOHHelper.getXmlNode(xml, "MsgType");
            string textContent = AliOHHelper.getXmlNode(xml, "Content");
            string str7        = str5;

            if (str7 != null)
            {
                if (!(str7 == "event"))
                {
                    if (str7 == "text")
                    {
                        try
                        {
                            if (!string.IsNullOrEmpty(str3))
                            {
                                WeiXinHelper.UpdateRencentAliOpenID(str3);
                            }
                        }
                        catch (Exception exception2)
                        {
                            AliOHHelper.log(exception2.Message.ToString());
                        }
                        try
                        {
                            this.replyAction(str3, "", textContent, actionParam);
                            goto Label_022F;
                        }
                        catch (Exception exception3)
                        {
                            AliOHHelper.log(exception3.Message.ToString());
                            goto Label_022F;
                        }
                        goto Label_01E3;
                    }
                    if (str7 == "image")
                    {
                        goto Label_01E3;
                    }
                }
                else
                {
                    try
                    {
                        this.replyAction(str3, eventType, textContent, actionParam);
                    }
                    catch (Exception exception)
                    {
                        AliOHHelper.log(exception.Message.ToString());
                    }
                }
            }
            goto Label_022F;
Label_01E3:
            articles2          = new Articles();
            articles2.toUserId = str3;
            articles2.msgType  = "text";
            MessageText text = new MessageText
            {
                content = "服务窗暂时不接收图片消息"
            };

            articles2.text = text;
            Articles articles = articles2;

            AliOHHelper.log(AliOHHelper.CustomSend(articles).Body);
Label_022F:
            AliOHHelper.verifyRequestFromAliPay(context, str3, this.appid);
        }
예제 #8
0
        private void replyAction(string FromUserId, string eventType, string textContent, string ActionParam)
        {
            Articles articles6 = new Articles
            {
                toUserId = FromUserId,
                msgType  = "text"
            };
            MessageText text5 = new MessageText
            {
                content = "系统未找到相关信息!"
            };

            articles6.text = text5;
            Articles articles = articles6;

            if (eventType != "")
            {
                if ("follow".Equals(eventType))
                {
                    if (!string.IsNullOrEmpty(FromUserId))
                    {
                        MemberProcessor.AddFuwuFollowUser(FromUserId);
                    }
                    string aliOHFollowRelayTitle = this.siteSettings.AliOHFollowRelayTitle;
                    Hidistro.Entities.VShop.ReplyInfo subscribeReply = AliFuwuReplyHelper.GetSubscribeReply();
                    if (subscribeReply != null)
                    {
                        if (subscribeReply.MessageType == Hidistro.Entities.VShop.MessageType.Text)
                        {
                            TextReplyInfo info2 = subscribeReply as TextReplyInfo;
                            articles.text.content = info2.Text;
                        }
                        else if (subscribeReply.ArticleID > 0)
                        {
                            ArticleInfo articleInfo = ArticleHelper.GetArticleInfo(subscribeReply.ArticleID);
                            if (articleInfo != null)
                            {
                                articles = this.GetAlipayArticlesFromArticleInfo(articleInfo, Globals.HostPath(HttpContext.Current.Request.Url), FromUserId);
                            }
                            else
                            {
                                articles.text.content = aliOHFollowRelayTitle;
                            }
                        }
                    }
                    else
                    {
                        articles.text.content = aliOHFollowRelayTitle;
                    }
                }
                else if ("unfollow".Equals(eventType))
                {
                    if (!string.IsNullOrEmpty(FromUserId))
                    {
                        MemberProcessor.DelFuwuFollowUser(FromUserId);
                    }
                }
                else if ("click".Equals(eventType))
                {
                    int result = 0;
                    if (((ActionParam != "") && int.TryParse(ActionParam, out result)) && (result > 0))
                    {
                        Hidistro.Entities.VShop.MenuInfo fuwuMenu = VShopHelper.GetFuwuMenu(result);
                        if (fuwuMenu != null)
                        {
                            Hidistro.Entities.VShop.ReplyInfo reply = AliFuwuReplyHelper.GetReply(fuwuMenu.ReplyId);
                            if (reply != null)
                            {
                                ArticleInfo info6 = ArticleHelper.GetArticleInfo(reply.ArticleID);
                                if (info6 != null)
                                {
                                    articles = this.GetAlipayArticlesFromArticleInfo(info6, Globals.HostPath(HttpContext.Current.Request.Url), FromUserId);
                                }
                            }
                        }
                    }
                }
                else if ("enter".Equals(eventType))
                {
                    if (!string.IsNullOrEmpty(this.UserInfo))
                    {
                        MemberInfo openIdMember = MemberProcessor.GetOpenIdMember(FromUserId, "fuwu");
                        if ((openIdMember != null) && openIdMember.AlipayLoginId.StartsWith("FW*"))
                        {
                            JObject obj2 = JsonConvert.DeserializeObject(this.UserInfo) as JObject;
                            string  str2 = "";
                            string  str3 = "";
                            if (obj2["logon_id"] != null)
                            {
                                str2 = obj2["logon_id"].ToString();
                            }
                            if (obj2["user_name"] != null)
                            {
                                str3 = obj2["user_name"].ToString();
                            }
                            if ((str3 != "") && (str3 != ""))
                            {
                                openIdMember.AlipayLoginId  = str2;
                                openIdMember.AlipayUsername = str3;
                                MemberProcessor.SetAlipayInfos(openIdMember);
                            }
                        }
                    }
                    if (!ActionParam.Contains("sceneId"))
                    {
                        return;
                    }
                    JObject obj3 = JsonConvert.DeserializeObject(ActionParam) as JObject;
                    if (obj3["scene"]["sceneId"] != null)
                    {
                        string key = obj3["scene"]["sceneId"].ToString();
                        if (key.StartsWith("bind"))
                        {
                            if (AlipayFuwuConfig.BindAdmin.Count > 10)
                            {
                                AlipayFuwuConfig.BindAdmin.Clear();
                            }
                            if (AlipayFuwuConfig.BindAdmin.ContainsKey(key))
                            {
                                AlipayFuwuConfig.BindAdmin[key] = FromUserId;
                            }
                            else
                            {
                                AlipayFuwuConfig.BindAdmin.Add(key, FromUserId);
                            }
                            articles.text.content = "您正在尝试绑定服务窗管理员身份!";
                        }
                    }
                }
            }
            else if (textContent != "")
            {
                articles = null;
                IList <Hidistro.Entities.VShop.ReplyInfo> replies = AliFuwuReplyHelper.GetReplies(ReplyType.Keys);
                if ((replies != null) && (replies.Count > 0))
                {
                    foreach (Hidistro.Entities.VShop.ReplyInfo info8 in replies)
                    {
                        if (info8 != null)
                        {
                            if ((info8.MatchType == MatchType.Equal) && (info8.Keys == textContent))
                            {
                                if (info8.MessageType == Hidistro.Entities.VShop.MessageType.Text)
                                {
                                    Articles articles2 = new Articles
                                    {
                                        toUserId = FromUserId,
                                        msgType  = "text"
                                    };
                                    MessageText text = new MessageText
                                    {
                                        content = ""
                                    };
                                    articles2.text = text;
                                    articles       = articles2;
                                    TextReplyInfo info9 = info8 as TextReplyInfo;
                                    articles.text.content = info9.Text;
                                    break;
                                }
                                if (info8.ArticleID > 0)
                                {
                                    ArticleInfo info10 = ArticleHelper.GetArticleInfo(info8.ArticleID);
                                    if (info10 != null)
                                    {
                                        articles = this.GetAlipayArticlesFromArticleInfo(info10, Globals.HostPath(HttpContext.Current.Request.Url), FromUserId);
                                        if (articles != null)
                                        {
                                            break;
                                        }
                                    }
                                }
                            }
                            if ((info8.MatchType == MatchType.Like) && info8.Keys.Contains(textContent))
                            {
                                if (info8.MessageType == Hidistro.Entities.VShop.MessageType.Text)
                                {
                                    Articles articles3 = new Articles
                                    {
                                        toUserId = FromUserId,
                                        msgType  = "text"
                                    };
                                    MessageText text2 = new MessageText
                                    {
                                        content = ""
                                    };
                                    articles3.text = text2;
                                    articles       = articles3;
                                    TextReplyInfo info11 = info8 as TextReplyInfo;
                                    articles.text.content = info11.Text;
                                    break;
                                }
                                if (info8.ArticleID > 0)
                                {
                                    ArticleInfo info12 = ArticleHelper.GetArticleInfo(info8.ArticleID);
                                    if (info12 != null)
                                    {
                                        articles = this.GetAlipayArticlesFromArticleInfo(info12, Globals.HostPath(HttpContext.Current.Request.Url), FromUserId);
                                        if (articles != null)
                                        {
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            if (articles == null)
            {
                IList <Hidistro.Entities.VShop.ReplyInfo> list2 = AliFuwuReplyHelper.GetReplies(ReplyType.NoMatch);
                if ((list2 != null) && (list2.Count > 0))
                {
                    foreach (Hidistro.Entities.VShop.ReplyInfo info13 in list2)
                    {
                        if (info13.MessageType == Hidistro.Entities.VShop.MessageType.Text)
                        {
                            Articles articles4 = new Articles
                            {
                                toUserId = FromUserId,
                                msgType  = "text"
                            };
                            MessageText text3 = new MessageText
                            {
                                content = ""
                            };
                            articles4.text = text3;
                            articles       = articles4;
                            TextReplyInfo info14 = info13 as TextReplyInfo;
                            articles.text.content = info14.Text;
                            break;
                        }
                        if (info13.ArticleID > 0)
                        {
                            ArticleInfo info15 = ArticleHelper.GetArticleInfo(info13.ArticleID);
                            if (info15 != null)
                            {
                                articles = this.GetAlipayArticlesFromArticleInfo(info15, Globals.HostPath(HttpContext.Current.Request.Url), FromUserId);
                                if (articles != null)
                                {
                                    break;
                                }
                            }
                        }
                    }
                }
                else
                {
                    Articles articles5 = new Articles
                    {
                        toUserId = FromUserId,
                        msgType  = "text"
                    };
                    MessageText text4 = new MessageText
                    {
                        content = "系统未找到相关信息!"
                    };
                    articles5.text = text4;
                    articles       = articles5;
                }
            }
            AliOHHelper.log(AliOHHelper.CustomSend(articles).Body);
        }
예제 #9
0
        private void ShowQRImage()
        {
            string text = "bind" + System.DateTime.Now.ToString("yyyyMMddHHmmss");

            try
            {
                QrcodeInfo codeInfo = new QrcodeInfo
                {
                    codeType     = "TEMP",
                    showLogo     = "Y",
                    expireSecond = 600,
                    codeInfo     = new codeInfo
                    {
                        scene = new scene
                        {
                            sceneId = text
                        }
                    }
                };
                this.hiddSceneId.Value = text;
                AlipayMobilePublicQrcodeCreateResponse alipayMobilePublicQrcodeCreateResponse = AliOHHelper.QrcodeSend(codeInfo);
                if (alipayMobilePublicQrcodeCreateResponse != null && alipayMobilePublicQrcodeCreateResponse.Code == 200L)
                {
                    this.imgQRCode.ImageUrl = alipayMobilePublicQrcodeCreateResponse.CodeImg;
                }
                else
                {
                    this.imgQRCode.AlternateText = "未成功获取服务窗授权";
                }
            }
            catch (System.Exception ex)
            {
                AliOHHelper.log(ex.Message);
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (this.IsPostBack)
            {
                return;
            }
            if (this.type == "getarticleinfo")
            {
                this.Response.ContentType = "application/json";
                string s         = "{\"type\":\"0\",\"tips\":\"操作失败\"}";
                int    articleid = Globals.RequestFormNum("articleid");
                if (articleid > 0)
                {
                    ArticleInfo articleInfo = ArticleHelper.GetArticleInfo(articleid);
                    if (articleInfo != null)
                    {
                        StringBuilder stringBuilder = new StringBuilder();
                        switch (articleInfo.ArticleType)
                        {
                        case ArticleType.News:
                            s = "{\"type\":\"1\",\"articletype\":" + (object)articleInfo.ArticleType + ",\"title\":\"" + this.String2Json(articleInfo.Title) + "\",\"date\":\"" + this.String2Json(articleInfo.PubTime.ToString("M月d日")) + "\",\"imgurl\":\"" + this.String2Json(articleInfo.ImageUrl) + "\",\"memo\":\"" + this.String2Json(articleInfo.Memo) + "\"}";
                            break;

                        case ArticleType.List:
                            foreach (ArticleItemsInfo articleItemsInfo in (IEnumerable <ArticleItemsInfo>)articleInfo.ItemsInfo)
                            {
                                stringBuilder.Append("{\"title\":\"" + this.String2Json(articleItemsInfo.Title) + "\",\"imgurl\":\"" + this.String2Json(articleItemsInfo.ImageUrl) + "\"},");
                            }
                            s = "{\"type\":\"1\",\"articletype\":" + (object)articleInfo.ArticleType + ",\"title\":\"" + this.String2Json(articleInfo.Title) + "\",\"date\":\"" + this.String2Json(articleInfo.PubTime.ToString("M月d日")) + "\",\"imgurl\":\"" + this.String2Json(articleInfo.ImageUrl) + "\",\"items\":[" + ((object)stringBuilder).ToString().Trim(',') + "]}";
                            break;

                        default:
                            s = "{\"type\":\"1\",\"articletype\":" + (object)articleInfo.ArticleType + ",\"title\":\"" + this.String2Json(articleInfo.Title) + "\",\"date\":\"" + this.String2Json(articleInfo.PubTime.ToString("M月d日")) + "\",\"imgurl\":\"" + this.String2Json(articleInfo.ImageUrl) + "\",\"memo\":\"" + this.String2Json(articleInfo.Content) + "\"}";
                            break;
                        }
                    }
                }
                this.Response.Write(s);
                this.Response.End();
            }
            else if (this.type == "postdata")
            {
                this.Response.ContentType = "application/json";
                this.sendID = Globals.RequestFormNum("sendid");
                int    num          = Globals.RequestFormNum("sendtype");
                int    msgType      = Globals.RequestFormNum("msgtype");
                int    articleid    = Globals.RequestFormNum("articleid");
                string title        = Globals.RequestFormStr("title");
                string content      = Globals.RequestFormStr("content");
                int    isoldarticle = Globals.RequestFormNum("isoldarticle");
                string str1         = this.SavePostData(msgType, articleid, title, content, isoldarticle, this.sendID, true);
                string s;
                if (string.IsNullOrEmpty(str1))
                {
                    MessageType messageType = (MessageType)msgType;
                    string      str2        = string.Empty;
                    Articles    Articles    = new Articles();
                    Articles.msgType = "text";
                    string storeUrl = Globals.HostPath(HttpContext.Current.Request.Url);
                    if (messageType == MessageType.List || messageType == MessageType.News)
                    {
                        this.sendID = Globals.ToNum((object)this.SavePostData(msgType, articleid, title, content, isoldarticle, this.sendID, false));
                        ArticleInfo articleInfo = ArticleHelper.GetArticleInfo(articleid);
                        if (articleInfo == null)
                        {
                            this.Response.Write("{\"type\":\"0\",\"tips\":\"素材不存在了\"}");
                            this.Response.End();
                        }
                        Articles = this.GetAlipayArticlesFromArticleInfo(articleInfo, storeUrl);
                    }
                    else
                    {
                        this.sendID   = Globals.ToNum((object)this.SavePostData(msgType, articleid, title, content, isoldarticle, this.sendID, false));
                        Articles.text = new MessageText()
                        {
                            content = Globals.StripHtmlXmlTags(content)
                        };
                    }
                    SiteSettings masterSettings = SettingsManager.GetMasterSettings(true);
                    if (AlipayFuwuConfig.appId.Length < 15)
                    {
                        AlipayFuwuConfig.CommSetConfig(masterSettings.AlipayAppid, this.Server.MapPath("~/"), "GBK");
                    }
                    if (num == 1)
                    {
                        AlipayMobilePublicMessageTotalSendResponse totalSendResponse = AliOHHelper.TotalSend(Articles);
                        if (!totalSendResponse.IsError && totalSendResponse.Code == "200")
                        {
                            s = "{\"type\":\"1\",\"tips\":\"服务窗群发成功,请于一天后到服务窗后台查询送达结果!\"}";
                            string msgid = "";
                            if (!string.IsNullOrEmpty(totalSendResponse.Data) && totalSendResponse.Data.Length > 50)
                            {
                                msgid = totalSendResponse.Data.Substring(0, 49);
                            }
                            int alypayUserNum = WeiXinHelper.getAlypayUserNum();
                            WeiXinHelper.UpdateMsgId(this.sendID, msgid, 1, alypayUserNum, alypayUserNum, "");
                        }
                        else
                        {
                            s = "{\"type\":\"0\",\"tips\":\"" + totalSendResponse.Msg + "\"}";
                            WeiXinHelper.UpdateMsgId(this.sendID, "", 2, 0, 0, totalSendResponse.Body);
                        }
                    }
                    else
                    {
                        List <string> sendList         = new List <string>();
                        DataTable     rencentAliOpenId = WeiXinHelper.GetRencentAliOpenID();
                        if (rencentAliOpenId != null)
                        {
                            for (int index = 0; index < rencentAliOpenId.Rows.Count; ++index)
                            {
                                sendList.Add(rencentAliOpenId.Rows[index][0].ToString());
                            }
                        }
                        if (sendList.Count > 0)
                        {
                            WeiXinHelper.UpdateMsgId(this.sendID, "", 0, 0, sendList.Count, "");
                            new Thread((ThreadStart)(() =>
                            {
                                try
                                {
                                    bool flag = false;
                                    foreach (string str in sendList)
                                    {
                                        if (str.Length > 16)
                                        {
                                            Articles.toUserId = str;
                                            AlipayMobilePublicMessageCustomSendResponse customSendResponse = AliOHHelper.CustomSend(Articles);
                                            if (customSendResponse != null && customSendResponse.IsError)
                                            {
                                                AliOHHelper.log(customSendResponse.Body);
                                            }
                                            else
                                            {
                                                flag = true;
                                                WeiXinHelper.UpdateAddSendCount(this.sendID, 1, -1);
                                            }
                                            Thread.Sleep(10);
                                        }
                                    }
                                    if (flag)
                                    {
                                        WeiXinHelper.UpdateAddSendCount(this.sendID, 0, 1);
                                    }
                                    else
                                    {
                                        WeiXinHelper.UpdateAddSendCount(this.sendID, 0, 2);
                                    }
                                    Thread.Sleep(10);
                                }
                                catch (Exception ex)
                                {
                                    AliOHHelper.log(((object)ex.Message).ToString());
                                }
                            })).Start();
                            s = "{\"type\":\"1\",\"tips\":\"信息正在后台推送中,请稍后刷新群发列表查看结果\"}";
                        }
                        else
                        {
                            s = "{\"type\":\"0\",\"tips\":\"暂时没有关注的用户可以发送信息\"}";
                        }
                    }
                }
                else
                {
                    s = "{\"type\":\"0\",\"tips\":\"" + str1 + "\"}";
                }
                this.Response.Write(s);
                this.Response.End();
            }
            else
            {
                if (this.sendID > 0)
                {
                    this.hdfSendID.Value = this.sendID.ToString();
                    SendAllInfo sendAllInfo = WeiXinHelper.GetSendAllInfo(this.sendID);
                    if (sendAllInfo != null)
                    {
                        MessageType messageType = sendAllInfo.MessageType;
                        this.hdfMessageType.Value = ((int)sendAllInfo.MessageType).ToString();
                        int articleId = sendAllInfo.ArticleID;
                        this.hdfArticleID.Value = articleId.ToString();
                        this.txtTitle.Text      = sendAllInfo.Title;
                        switch (messageType)
                        {
                        case MessageType.Text:
                            this.fkContent.Text = sendAllInfo.Content;
                            break;

                        case MessageType.News:
                            if (articleId <= 0)
                            {
                                this.hdfIsOldArticle.Value = "1";
                                NewsReplyInfo newsReplyInfo = ReplyHelper.GetReply(this.sendID) as NewsReplyInfo;
                                if (newsReplyInfo != null && newsReplyInfo.NewsMsg != null && newsReplyInfo.NewsMsg.Count != 0)
                                {
                                    this.htmlInfo = "<div class=\"mate-inner\"><h3 id=\"singelTitle\">" + newsReplyInfo.NewsMsg[0].Title + "</h3><span>" + newsReplyInfo.LastEditDate.ToString("M月d日") + "</span><div class=\"mate-img\"><img id=\"img1\" src=\"" + newsReplyInfo.NewsMsg[0].PicUrl + "\" class=\"img-responsive\"></div><div class=\"mate-info\" id=\"Lbmsgdesc\">" + newsReplyInfo.NewsMsg[0].Description + "</div><div class=\"red-all clearfix\"><strong class=\"fl\">查看全文</strong><em class=\"fr\">&gt;</em></div></div>";
                                    break;
                                }
                                else
                                {
                                    break;
                                }
                            }
                            else
                            {
                                break;
                            }

                        case MessageType.List:
                            if (articleId <= 0)
                            {
                                this.hdfIsOldArticle.Value = "1";
                                NewsReplyInfo newsReplyInfo = ReplyHelper.GetReply(this.sendID) as NewsReplyInfo;
                                if (newsReplyInfo != null)
                                {
                                    StringBuilder stringBuilder = new StringBuilder();
                                    if (newsReplyInfo.NewsMsg != null && newsReplyInfo.NewsMsg.Count > 0)
                                    {
                                        int num = 0;
                                        foreach (NewsMsgInfo newsMsgInfo in (IEnumerable <NewsMsgInfo>)newsReplyInfo.NewsMsg)
                                        {
                                            ++num;
                                            if (num == 1)
                                            {
                                                stringBuilder.Append("<div class=\"mate-inner top\">                 <div class=\"mate-img\" >                     <img id=\"img1\" src=\"" + newsMsgInfo.PicUrl + "\" class=\"img-responsive\">                     <div class=\"title\" id=\"title1\">" + newsMsgInfo.Title + "</div>                 </div>             </div>");
                                            }
                                            else
                                            {
                                                stringBuilder.Append("             <div class=\"mate-inner\">                 <div class=\"child-mate\">                     <div class=\"child-mate-title clearfix\">                         <div class=\"title\">" + newsMsgInfo.Title + "</div>                         <div class=\"img\">                             <img src=\"" + newsMsgInfo.PicUrl + "\" class=\"img-responsive\">                         </div>                     </div>                 </div>             </div>");
                                            }
                                        }
                                        this.htmlInfo = ((object)stringBuilder).ToString();
                                        break;
                                    }
                                    else
                                    {
                                        break;
                                    }
                                }
                                else
                                {
                                    break;
                                }
                            }
                            else
                            {
                                break;
                            }
                        }
                    }
                    else
                    {
                        this.Response.Redirect("sendalllist.aspx");
                        this.Response.End();
                    }
                }
                else if (this.LocalArticleID > 0)
                {
                    ArticleInfo articleInfo = ArticleHelper.GetArticleInfo(this.LocalArticleID);
                    if (articleInfo != null)
                    {
                        this.hdfArticleID.Value   = this.LocalArticleID.ToString();
                        this.hdfMessageType.Value = ((int)articleInfo.ArticleType).ToString();
                    }
                }
                if (string.IsNullOrEmpty(this.htmlInfo))
                {
                    this.htmlInfo = "<div class=\"exit-shop-info\">内容区</div>";
                }
                this.litInfo.Text = this.htmlInfo;
            }
        }
예제 #11
0
        public void AlipayLoginAction(SiteSettings site)
        {
            if (string.IsNullOrEmpty(AlipayFuwuConfig.appId) && !AlipayFuwuConfig.CommSetConfig(site.AlipayAppid, this.Page.Server.MapPath("~/"), "GBK"))
            {
                this.WriteFuwuError(this.Page.Request.QueryString.ToString(), "服务窗口参数配置不准确!");
                this.Page.Response.Redirect(Globals.ApplicationPath + "/UserLogin.aspx");
            }
            string text  = this.Page.Request.QueryString["auth_code"];
            string value = this.Page.Request.QueryString["scope"];

            if (!string.IsNullOrEmpty(value) && !string.IsNullOrEmpty(text))
            {
                this.WriteFuwuError(this.Page.Request.QueryString.ToString(), "已授权");
                AlipaySystemOauthTokenResponse oauthTokenResponse = AliOHHelper.GetOauthTokenResponse(text);
                this.WriteFuwuError(AliOHHelper.SerializeObject(oauthTokenResponse, true), "获取AccessToken");
                if (oauthTokenResponse == null || oauthTokenResponse.IsError || oauthTokenResponse.AccessToken == null)
                {
                    this.Page.Response.Redirect(Globals.ApplicationPath + "/UserLogin.aspx?returnUrl=" + Globals.UrlEncode(HttpContext.Current.Request.Url.AbsoluteUri.ToString()));
                    return;
                }
                string  text2   = oauthTokenResponse.AlipayUserId;
                string  text3   = "";
                JObject jObject = JsonConvert.DeserializeObject(oauthTokenResponse.Body) as JObject;
                if (jObject["alipay_system_oauth_token_response"]["user_id"] != null)
                {
                    text3 = jObject["alipay_system_oauth_token_response"]["user_id"].ToString();
                }
                if (this.HasLogin(text3, "fuwu") || this.HasLogin(text2, "fuwu"))
                {
                    MemberInfo openIdMember = MemberProcessor.GetOpenIdMember(text3, "fuwu");
                    if (openIdMember == null || openIdMember.Status == Convert.ToInt32(UserStatus.DEL))
                    {
                        this.Page.Response.Redirect(Globals.ApplicationPath + "/logout.aspx");
                    }
                    string alipayOpenid = openIdMember.AlipayOpenid;
                    if ((text2 != "" && text2 != alipayOpenid) || string.IsNullOrEmpty(alipayOpenid))
                    {
                        openIdMember.AlipayOpenid = text2;
                        MemberProcessor.SetAlipayInfos(openIdMember);
                    }
                    this.setLogin(openIdMember.UserId);
                    this.WriteFuwuError("已存在用户登入!", text3);
                    return;
                }
                string accessToken = oauthTokenResponse.AccessToken;
                AlipayUserUserinfoShareResponse alipayUserUserinfo = AliOHHelper.GetAlipayUserUserinfo(accessToken);
                this.WriteFuwuError(AliOHHelper.SerializeObject(alipayUserUserinfo, true), "获取用户信息");
                string alipayUsername = "";
                string text4          = "";
                if (alipayUserUserinfo != null && !alipayUserUserinfo.IsError)
                {
                    text4 = alipayUserUserinfo.Avatar;
                    if (alipayUserUserinfo.RealName != null)
                    {
                        alipayUsername = alipayUserUserinfo.RealName;
                    }
                    if (string.IsNullOrEmpty(text2))
                    {
                        text2 = alipayUserUserinfo.UserId;
                    }
                    if (string.IsNullOrEmpty(text3))
                    {
                        JObject jObject2 = JsonConvert.DeserializeObject(alipayUserUserinfo.Body) as JObject;
                        if (jObject2["alipay_user_id"] != null)
                        {
                            text3 = jObject2["alipay_user_id"].ToString();
                        }
                    }
                }
                string     text5      = "FW*" + text3.Substring(10);
                string     generateId = Globals.GetGenerateId();
                MemberInfo memberInfo = new MemberInfo();
                memberInfo.GradeId        = MemberProcessor.GetDefaultMemberGrade();
                memberInfo.UserName       = text5;
                memberInfo.CreateDate     = DateTime.Now;
                memberInfo.SessionId      = generateId;
                memberInfo.SessionEndTime = DateTime.Now.AddYears(10);
                memberInfo.UserHead       = text4;
                memberInfo.AlipayAvatar   = text4;
                memberInfo.AlipayLoginId  = text5;
                memberInfo.AlipayOpenid   = text2;
                memberInfo.AlipayUserId   = text3;
                memberInfo.AlipayUsername = alipayUsername;
                HttpCookie httpCookie = HttpContext.Current.Request.Cookies["Vshop-ReferralId"];
                if (httpCookie != null)
                {
                    memberInfo.ReferralUserId = Convert.ToInt32(httpCookie.Value);
                }
                else
                {
                    memberInfo.ReferralUserId = 0;
                }
                memberInfo.Password = HiCryptographer.Md5Encrypt("888888");
                MemberProcessor.CreateMember(memberInfo);
                MemberInfo member = MemberProcessor.GetMember(generateId);
                this.setLogin(member.UserId);
                return;
            }
            else
            {
                if (!string.IsNullOrEmpty(value))
                {
                    this.WriteFuwuError(this.Page.Request.QueryString.ToString(), "拒绝授权");
                    this.Page.Response.Redirect(Globals.ApplicationPath + "/UserLogin.aspx");
                    return;
                }
                string text6 = AliOHHelper.AlipayAuthUrl(HttpContext.Current.Request.Url.ToString().Replace(":" + HttpContext.Current.Request.Url.Port, ""), site.AlipayAppid, "auth_userinfo");
                this.WriteFuwuError(text6, "用户登入授权的路径");
                this.Page.Response.Redirect(text6);
                return;
            }
        }
예제 #12
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            if (!base.IsPostBack)
            {
                if (this.type == "getarticleinfo")
                {
                    base.Response.ContentType = "application/json";
                    string str1 = "{\"type\":\"0\",\"tips\":\"操作失败\"}";
                    int    num  = Globals.RequestFormNum("articleid");
                    if (num > 0)
                    {
                        ArticleInfo articleInfo = ArticleHelper.GetArticleInfo(num);
                        if (articleInfo != null)
                        {
                            StringBuilder stringBuilder = new StringBuilder();
                            switch (articleInfo.ArticleType)
                            {
                            case ArticleType.News:
                            {
                                object[] articleType = new object[] { "{\"type\":\"1\",\"articletype\":", (int)articleInfo.ArticleType, ",\"title\":\"", this.String2Json(articleInfo.Title), "\",\"date\":\"", null, null, null, null, null, null };
                                DateTime pubTime     = articleInfo.PubTime;
                                articleType[5]  = this.String2Json(pubTime.ToString("M月d日"));
                                articleType[6]  = "\",\"imgurl\":\"";
                                articleType[7]  = this.String2Json(articleInfo.ImageUrl);
                                articleType[8]  = "\",\"memo\":\"";
                                articleType[9]  = this.String2Json(articleInfo.Memo);
                                articleType[10] = "\"}";
                                str1            = string.Concat(articleType);
                                break;
                            }

                            case ArticleType.Text | ArticleType.News:
                            {
                                object[] objArray = new object[] { "{\"type\":\"1\",\"articletype\":", (int)articleInfo.ArticleType, ",\"title\":\"", this.String2Json(articleInfo.Title), "\",\"date\":\"", null, null, null, null, null, null };
                                DateTime dateTime = articleInfo.PubTime;
                                objArray[5]  = this.String2Json(dateTime.ToString("M月d日"));
                                objArray[6]  = "\",\"imgurl\":\"";
                                objArray[7]  = this.String2Json(articleInfo.ImageUrl);
                                objArray[8]  = "\",\"memo\":\"";
                                objArray[9]  = this.String2Json(articleInfo.Content);
                                objArray[10] = "\"}";
                                str1         = string.Concat(objArray);
                                break;
                            }

                            case ArticleType.List:
                            {
                                foreach (ArticleItemsInfo itemsInfo in articleInfo.ItemsInfo)
                                {
                                    string[] strArrays = new string[] { "{\"title\":\"", this.String2Json(itemsInfo.Title), "\",\"imgurl\":\"", this.String2Json(itemsInfo.ImageUrl), "\"}," };
                                    stringBuilder.Append(string.Concat(strArrays));
                                }
                                object[] articleType1 = new object[] { "{\"type\":\"1\",\"articletype\":", (int)articleInfo.ArticleType, ",\"title\":\"", this.String2Json(articleInfo.Title), "\",\"date\":\"", null, null, null, null, null, null };
                                DateTime pubTime1     = articleInfo.PubTime;
                                articleType1[5] = this.String2Json(pubTime1.ToString("M月d日"));
                                articleType1[6] = "\",\"imgurl\":\"";
                                articleType1[7] = this.String2Json(articleInfo.ImageUrl);
                                articleType1[8] = "\",\"items\":[";
                                string str2     = stringBuilder.ToString();
                                char[] chrArray = new char[] { ',' };
                                articleType1[9]  = str2.Trim(chrArray);
                                articleType1[10] = "]}";
                                str1             = string.Concat(articleType1);
                                break;
                            }

                            default:
                            {
                                goto case ArticleType.Text | ArticleType.News;
                            }
                            }
                        }
                    }
                    base.Response.Write(str1);
                    base.Response.End();
                    return;
                }
                if (this.type == "postdata")
                {
                    base.Response.ContentType = "application/json";
                    string str3 = "{\"type\":\"1\",\"tips\":\"操作成功\"}";
                    this.sendID = Globals.RequestFormNum("sendid");
                    int    num1 = Globals.RequestFormNum("sendtype");
                    int    num2 = Globals.RequestFormNum("msgtype");
                    int    num3 = Globals.RequestFormNum("articleid");
                    string str4 = Globals.RequestFormStr("title");
                    string str5 = Globals.RequestFormStr("content");
                    int    num4 = Globals.RequestFormNum("isoldarticle");
                    string str6 = this.SavePostData(num2, num3, str4, str5, num4, this.sendID, true);
                    if (!string.IsNullOrEmpty(str6))
                    {
                        str3 = string.Concat("{\"type\":\"0\",\"tips\":\"", str6, "\"}");
                    }
                    else
                    {
                        MessageType messageType = (MessageType)num2;
                        string      empty       = string.Empty;
                        Articles    article     = new Articles()
                        {
                            msgType = "text"
                        };
                        string str7 = Globals.HostPath(HttpContext.Current.Request.Url);
                        if (messageType == MessageType.List || messageType == MessageType.News)
                        {
                            this.sendID = Globals.ToNum(this.SavePostData(num2, num3, str4, str5, num4, this.sendID, false));
                            ArticleInfo articleInfo1 = ArticleHelper.GetArticleInfo(num3);
                            if (articleInfo1 == null)
                            {
                                str3 = "{\"type\":\"0\",\"tips\":\"素材不存在了\"}";
                                base.Response.Write(str3);
                                base.Response.End();
                            }
                            article = this.GetAlipayArticlesFromArticleInfo(articleInfo1, str7);
                        }
                        else
                        {
                            this.sendID = Globals.ToNum(this.SavePostData(num2, num3, str4, str5, num4, this.sendID, false));
                            Articles    article1    = article;
                            MessageText messageText = new MessageText()
                            {
                                content = Globals.StripHtmlXmlTags(str5)
                            };
                            article1.text = messageText;
                        }
                        SiteSettings masterSettings = SettingsManager.GetMasterSettings(true);
                        if (AlipayFuwuConfig.appId.Length < 15)
                        {
                            AlipayFuwuConfig.CommSetConfig(masterSettings.AlipayAppid, base.Server.MapPath("~/"), "GBK");
                        }
                        if (num1 != 1)
                        {
                            List <string> strs             = new List <string>();
                            DataTable     rencentAliOpenID = WeiXinHelper.GetRencentAliOpenID();
                            if (rencentAliOpenID != null)
                            {
                                for (int i = 0; i < rencentAliOpenID.Rows.Count; i++)
                                {
                                    strs.Add(rencentAliOpenID.Rows[i][0].ToString());
                                }
                            }
                            if (strs.Count <= 0)
                            {
                                str3 = "{\"type\":\"0\",\"tips\":\"暂时没有关注的用户可以发送信息\"}";
                            }
                            else
                            {
                                WeiXinHelper.UpdateMsgId(this.sendID, "", 0, 0, strs.Count, "");
                                (new Thread(() =>
                                {
                                    try
                                    {
                                        bool flag = false;
                                        foreach (string str in strs)
                                        {
                                            if (str.Length <= 16)
                                            {
                                                continue;
                                            }
                                            article.toUserId = str;
                                            AlipayMobilePublicMessageCustomSendResponse alipayMobilePublicMessageCustomSendResponse = AliOHHelper.CustomSend(article);
                                            if (alipayMobilePublicMessageCustomSendResponse == null || !alipayMobilePublicMessageCustomSendResponse.IsError)
                                            {
                                                flag = true;
                                                WeiXinHelper.UpdateAddSendCount(this.sendID, 1, -1);
                                            }
                                            else
                                            {
                                                AliOHHelper.log(alipayMobilePublicMessageCustomSendResponse.Body);
                                            }
                                            Thread.Sleep(10);
                                        }
                                        if (!flag)
                                        {
                                            WeiXinHelper.UpdateAddSendCount(this.sendID, 0, 2);
                                        }
                                        else
                                        {
                                            WeiXinHelper.UpdateAddSendCount(this.sendID, 0, 1);
                                        }
                                        Thread.Sleep(10);
                                    }
                                    catch (Exception exception)
                                    {
                                        AliOHHelper.log(exception.Message.ToString());
                                    }
                                })).Start();
                                str3 = "{\"type\":\"1\",\"tips\":\"信息正在后台推送中,请稍后刷新群发列表查看结果\"}";
                            }
                        }
                        else
                        {
                            AlipayMobilePublicMessageTotalSendResponse alipayMobilePublicMessageTotalSendResponse = AliOHHelper.TotalSend(article);
                            if (alipayMobilePublicMessageTotalSendResponse.IsError || !(alipayMobilePublicMessageTotalSendResponse.Code == "200"))
                            {
                                str3 = string.Concat("{\"type\":\"0\",\"tips\":\"", alipayMobilePublicMessageTotalSendResponse.Msg, "\"}");
                                WeiXinHelper.UpdateMsgId(this.sendID, "", 2, 0, 0, alipayMobilePublicMessageTotalSendResponse.Body);
                            }
                            else
                            {
                                str3 = "{\"type\":\"1\",\"tips\":\"服务窗群发成功,请于一天后到服务窗后台查询送达结果!\"}";
                                string str8 = "";
                                if (!string.IsNullOrEmpty(alipayMobilePublicMessageTotalSendResponse.Data) && alipayMobilePublicMessageTotalSendResponse.Data.Length > 50)
                                {
                                    str8 = alipayMobilePublicMessageTotalSendResponse.Data.Substring(0, 49);
                                }
                                int alypayUserNum = WeiXinHelper.getAlypayUserNum();
                                WeiXinHelper.UpdateMsgId(this.sendID, str8, 1, alypayUserNum, alypayUserNum, "");
                            }
                        }
                    }
                    base.Response.Write(str3);
                    base.Response.End();
                    return;
                }
                if (this.sendID > 0)
                {
                    this.hdfSendID.Value = this.sendID.ToString();
                    SendAllInfo sendAllInfo = WeiXinHelper.GetSendAllInfo(this.sendID);
                    if (sendAllInfo == null)
                    {
                        base.Response.Redirect("sendalllist.aspx");
                        base.Response.End();
                    }
                    else
                    {
                        MessageType messageType1 = sendAllInfo.MessageType;
                        this.hdfMessageType.Value = sendAllInfo.MessageType.ToString();
                        int articleID = sendAllInfo.ArticleID;
                        this.hdfArticleID.Value = articleID.ToString();
                        this.txtTitle.Text      = sendAllInfo.Title;
                        switch (messageType1)
                        {
                        case MessageType.Text:
                        {
                            this.fkContent.Text = sendAllInfo.Content;
                            break;
                        }

                        case MessageType.News:
                        {
                            if (articleID > 0)
                            {
                                break;
                            }
                            this.hdfIsOldArticle.Value = "1";
                            NewsReplyInfo reply = ReplyHelper.GetReply(this.sendID) as NewsReplyInfo;
                            if (reply == null || reply.NewsMsg == null || reply.NewsMsg.Count == 0)
                            {
                                break;
                            }
                            string[] title = new string[] { "<div class=\"mate-inner\"><h3 id=\"singelTitle\">", reply.NewsMsg[0].Title, "</h3><span>", null, null, null, null, null, null };
                            title[3]      = reply.LastEditDate.ToString("M月d日");
                            title[4]      = "</span><div class=\"mate-img\"><img id=\"img1\" src=\"";
                            title[5]      = reply.NewsMsg[0].PicUrl;
                            title[6]      = "\" class=\"img-responsive\"></div><div class=\"mate-info\" id=\"Lbmsgdesc\">";
                            title[7]      = reply.NewsMsg[0].Description;
                            title[8]      = "</div><div class=\"red-all clearfix\"><strong class=\"fl\">查看全文</strong><em class=\"fr\">&gt;</em></div></div>";
                            this.htmlInfo = string.Concat(title);
                            break;
                        }

                        case MessageType.List:
                        {
                            if (articleID > 0)
                            {
                                break;
                            }
                            this.hdfIsOldArticle.Value = "1";
                            NewsReplyInfo newsReplyInfo = ReplyHelper.GetReply(this.sendID) as NewsReplyInfo;
                            if (newsReplyInfo == null)
                            {
                                break;
                            }
                            StringBuilder stringBuilder1 = new StringBuilder();
                            if (newsReplyInfo.NewsMsg == null || newsReplyInfo.NewsMsg.Count <= 0)
                            {
                                break;
                            }
                            int num5 = 0;
                            foreach (NewsMsgInfo newsMsg in newsReplyInfo.NewsMsg)
                            {
                                num5++;
                                if (num5 != 1)
                                {
                                    string[] title1 = new string[] { "             <div class=\"mate-inner\">                 <div class=\"child-mate\">                     <div class=\"child-mate-title clearfix\">                         <div class=\"title\">", newsMsg.Title, "</div>                         <div class=\"img\">                             <img src=\"", newsMsg.PicUrl, "\" class=\"img-responsive\">                         </div>                     </div>                 </div>             </div>" };
                                    stringBuilder1.Append(string.Concat(title1));
                                }
                                else
                                {
                                    string[] picUrl = new string[] { "<div class=\"mate-inner top\">                 <div class=\"mate-img\" >                     <img id=\"img1\" src=\"", newsMsg.PicUrl, "\" class=\"img-responsive\">                     <div class=\"title\" id=\"title1\">", newsMsg.Title, "</div>                 </div>             </div>" };
                                    stringBuilder1.Append(string.Concat(picUrl));
                                }
                            }
                            this.htmlInfo = stringBuilder1.ToString();
                            break;
                        }
                        }
                    }
                }
                else if (this.LocalArticleID > 0)
                {
                    ArticleInfo articleInfo2 = ArticleHelper.GetArticleInfo(this.LocalArticleID);
                    if (articleInfo2 != null)
                    {
                        this.hdfArticleID.Value   = this.LocalArticleID.ToString();
                        this.hdfMessageType.Value = articleInfo2.ArticleType.ToString();
                    }
                }
                if (string.IsNullOrEmpty(this.htmlInfo))
                {
                    this.htmlInfo = "<div class=\"exit-shop-info\">内容区</div>";
                }
                this.litInfo.Text = this.htmlInfo;
            }
        }
        public void AlipayLoginAction(SiteSettings site)
        {
            if (string.IsNullOrEmpty(AlipayFuwuConfig.appId) && !AlipayFuwuConfig.CommSetConfig(site.AlipayAppid, this.Page.Server.MapPath("~/"), "GBK"))
            {
                this.WriteFuwuError(this.Page.Request.QueryString.ToString(), "服务窗口参数配置不准确!");
                this.Page.Response.Redirect(Globals.ApplicationPath + "/UserLogin.aspx");
            }
            string str  = this.Page.Request.QueryString["auth_code"];
            string str2 = this.Page.Request.QueryString["scope"];

            if (!string.IsNullOrEmpty(str2) && !string.IsNullOrEmpty(str))
            {
                this.WriteFuwuError(this.Page.Request.QueryString.ToString(), "已授权");
                AlipaySystemOauthTokenResponse oauthTokenResponse = AliOHHelper.GetOauthTokenResponse(str);
                this.WriteFuwuError(AliOHHelper.SerializeObject(oauthTokenResponse, true), "获取AccessToken");
                if (((oauthTokenResponse != null) && !oauthTokenResponse.IsError) && (oauthTokenResponse.AccessToken != null))
                {
                    string  alipayUserId = oauthTokenResponse.AlipayUserId;
                    string  openId       = "";
                    JObject obj2         = JsonConvert.DeserializeObject(oauthTokenResponse.Body) as JObject;
                    if (obj2["alipay_system_oauth_token_response"]["user_id"] != null)
                    {
                        openId = obj2["alipay_system_oauth_token_response"]["user_id"].ToString();
                    }
                    if (this.HasLogin(openId, "fuwu") || this.HasLogin(alipayUserId, "fuwu"))
                    {
                        MemberInfo openIdMember = MemberProcessor.GetOpenIdMember(openId, "fuwu");
                        if ((openIdMember == null) || (openIdMember.Status == Convert.ToInt32(UserStatus.DEL)))
                        {
                            this.Page.Response.Redirect(Globals.ApplicationPath + "/logout.aspx");
                        }
                        string alipayOpenid = openIdMember.AlipayOpenid;
                        if (((alipayUserId != "") && (alipayUserId != alipayOpenid)) || string.IsNullOrEmpty(alipayOpenid))
                        {
                            openIdMember.AlipayOpenid = alipayUserId;
                            MemberProcessor.SetAlipayInfos(openIdMember);
                        }
                        this.setLogin(openIdMember.UserId);
                        this.WriteFuwuError("已存在用户登入!", openId);
                    }
                    else
                    {
                        AlipayUserUserinfoShareResponse alipayUserUserinfo = AliOHHelper.GetAlipayUserUserinfo(oauthTokenResponse.AccessToken);
                        this.WriteFuwuError(AliOHHelper.SerializeObject(alipayUserUserinfo, true), "获取用户信息");
                        string str7     = "";
                        string realName = "";
                        string avatar   = "";
                        if ((alipayUserUserinfo != null) && !alipayUserUserinfo.IsError)
                        {
                            avatar = alipayUserUserinfo.Avatar;
                            if (alipayUserUserinfo.RealName != null)
                            {
                                realName = alipayUserUserinfo.RealName;
                            }
                            if (string.IsNullOrEmpty(alipayUserId))
                            {
                                alipayUserId = alipayUserUserinfo.UserId;
                            }
                            if (string.IsNullOrEmpty(openId))
                            {
                                JObject obj3 = JsonConvert.DeserializeObject(alipayUserUserinfo.Body) as JObject;
                                if (obj3["alipay_user_id"] != null)
                                {
                                    openId = obj3["alipay_user_id"].ToString();
                                }
                            }
                        }
                        str7 = "FW*" + openId.Substring(10);
                        string     generateId = Globals.GetGenerateId();
                        MemberInfo member     = new MemberInfo {
                            GradeId        = MemberProcessor.GetDefaultMemberGrade(),
                            UserName       = str7,
                            CreateDate     = DateTime.Now,
                            SessionId      = generateId,
                            SessionEndTime = DateTime.Now.AddYears(10),
                            UserHead       = avatar,
                            AlipayAvatar   = avatar,
                            AlipayLoginId  = str7,
                            AlipayOpenid   = alipayUserId,
                            AlipayUserId   = openId,
                            AlipayUsername = realName
                        };
                        HttpCookie cookie = HttpContext.Current.Request.Cookies["Vshop-ReferralId"];
                        if (cookie != null)
                        {
                            member.ReferralUserId = Convert.ToInt32(cookie.Value);
                        }
                        else
                        {
                            member.ReferralUserId = 0;
                        }
                        member.Password = HiCryptographer.Md5Encrypt("888888");
                        MemberProcessor.CreateMember(member);
                        MemberInfo info3 = MemberProcessor.GetMember(generateId);
                        this.setLogin(info3.UserId);
                    }
                }
                else
                {
                    this.Page.Response.Redirect(Globals.ApplicationPath + "/UserLogin.aspx?returnUrl=" + Globals.UrlEncode(HttpContext.Current.Request.Url.AbsoluteUri.ToString()));
                }
            }
            else if (!string.IsNullOrEmpty(str2))
            {
                this.WriteFuwuError(this.Page.Request.QueryString.ToString(), "拒绝授权");
                this.Page.Response.Redirect(Globals.ApplicationPath + "/UserLogin.aspx");
            }
            else
            {
                string msg = AliOHHelper.AlipayAuthUrl(HttpContext.Current.Request.Url.ToString().Replace(":" + HttpContext.Current.Request.Url.Port, ""), site.AlipayAppid, "auth_userinfo");
                this.WriteFuwuError(msg, "用户登入授权的路径");
                this.Page.Response.Redirect(msg);
            }
        }