Ejemplo n.º 1
0
        public override AbstractResponse OnEvent_ScanRequest(ScanEventRequest scanEventRequest)
        {
            ReplyInfo replyInfo    = ReplyHelper.GetSubscribeReply();
            string    fromUserName = scanEventRequest.FromUserName;

            try
            {
                MemberProcessor.UpdateWXUserIsSubscribeStatus(fromUserName, true);
            }
            catch (Exception ex)
            {
                IDictionary <string, string> dictionary = new Dictionary <string, string>();
                dictionary.Add("openId", fromUserName);
                Globals.WriteExceptionLog(ex, dictionary, "UpdateWXUserIsSubscribeStatus");
            }
            if (replyInfo == null)
            {
                replyInfo = new ReplyInfo();
            }
            replyInfo.Keys = "登录";
            if (scanEventRequest != null && !string.IsNullOrEmpty(scanEventRequest.EventKey) && scanEventRequest.EventKey.Split('_').Length >= 2)
            {
                string text = scanEventRequest.EventKey.Split('_')[1];
                if (text == "referralregister")
                {
                    replyInfo.Keys = "分销注册";
                }
                else if (text.Contains("referraluserid"))
                {
                    if (text.Split(':').Length == 2)
                    {
                        int referralUserId = text.Split(':')[1].ToInt(0);
                        MemberWXReferralInfo wXReferral = VShopHelper.GetWXReferral(scanEventRequest.FromUserName);
                        if (wXReferral != null && wXReferral.Id > 0)
                        {
                            VShopHelper.UpdateWXReferral(scanEventRequest.FromUserName, referralUserId);
                        }
                        else
                        {
                            VShopHelper.AddWXReferral(scanEventRequest.FromUserName, referralUserId);
                        }
                    }
                }
                else if (text.Contains("shoppingguiderid") && text.Split(':').Length == 2)
                {
                    int shoppingGuiderId = text.Split(':')[1].ToInt(0);
                    MemberWXShoppingGuiderInfo memberWXShoppingGuider = MemberHelper.GetMemberWXShoppingGuider(scanEventRequest.FromUserName);
                    if (memberWXShoppingGuider != null && memberWXShoppingGuider.Id > 0)
                    {
                        MemberHelper.UpdateWXShoppingGuider(scanEventRequest.FromUserName, shoppingGuiderId);
                    }
                    else
                    {
                        MemberHelper.AddWXShoppingGuider(scanEventRequest.FromUserName, shoppingGuiderId);
                    }
                }
            }
            AbstractResponse response = this.GetResponse(replyInfo, scanEventRequest.FromUserName, scanEventRequest);

            if (response == null)
            {
                return(this.GotoManyCustomerService(scanEventRequest));
            }
            response.ToUserName   = scanEventRequest.FromUserName;
            response.FromUserName = scanEventRequest.ToUserName;
            return(response);
        }