Exemplo n.º 1
0
        internal virtual void Update(ClientState state, Model model)
        {
            if (model.Timestamp.IsSpecified)
            {
                _timestampTicks = model.Timestamp.Value.UtcTicks;
            }

            if (model.Content.IsSpecified)
            {
                Content = model.Content.Value;
            }

            if (model.Application.IsSpecified)
            {
                // create a new Application from the API model
                Application = new MessageApplication()
                {
                    Id          = model.Application.Value.Id,
                    CoverImage  = model.Application.Value.CoverImage,
                    Description = model.Application.Value.Description,
                    Icon        = model.Application.Value.Icon,
                    Name        = model.Application.Value.Name
                };
            }

            if (model.Activity.IsSpecified)
            {
                // create a new Activity from the API model
                Activity = new MessageActivity()
                {
                    Type    = model.Activity.Value.Type.Value,
                    PartyId = model.Activity.Value.PartyId.Value
                };
            }
        }
Exemplo n.º 2
0
        internal virtual void Update(Model model)
        {
            if (model.Timestamp.IsSpecified)
            {
                _timestampTicks = model.Timestamp.Value.UtcTicks;
            }

            if (model.Content.IsSpecified)
            {
                Content = model.Content.Value;
            }

            if (model.Application.IsSpecified)
            {
                // create a new Application from the API model
                Application = new MessageApplication()
                {
                    Id          = model.Application.Value.Id,
                    CoverImage  = model.Application.Value.CoverImage,
                    Description = model.Application.Value.Description,
                    Icon        = model.Application.Value.Icon,
                    Name        = model.Application.Value.Name
                };
            }

            if (model.Activity.IsSpecified)
            {
                // create a new Activity from the API model
                Activity = new MessageActivity()
                {
                    Type    = model.Activity.Value.Type.Value,
                    PartyId = model.Activity.Value.PartyId.GetValueOrDefault()
                };
            }

            if (model.Reactions.IsSpecified)
            {
                var value = model.Reactions.Value;
                if (value.Length > 0)
                {
                    var reactions = ImmutableArray.CreateBuilder <RestReaction>(value.Length);
                    for (int i = 0; i < value.Length; i++)
                    {
                        reactions.Add(RestReaction.Create(value[i]));
                    }
                    _reactions = reactions.ToImmutable();
                }
                else
                {
                    _reactions = ImmutableArray.Create <RestReaction>();
                }
            }
            else
            {
                _reactions = ImmutableArray.Create <RestReaction>();
            }
        }
Exemplo n.º 3
0
        public NotifyController(MessageApplication messageApp)
        {
            if (messageApp == null)
            {
                throw new ArgumentNullException(nameof(messageApp));
            }

            _messageApp = messageApp;
        }
Exemplo n.º 4
0
        /// <summary>
        /// 是否强制绑定手机号
        /// </summary>
        /// <returns></returns>
        public JsonResult <Result <string> > IsConBindSms()
        {
            if (CurrentUser == null)
            {
                return(Json(ErrorResult <string>("未登录")));
            }

            var isBind = MessageApplication.IsOpenBindSms(CurrentUserId);

            return(Json(ApiResult(isBind, "", "")));
        }
Exemplo n.º 5
0
        internal virtual void Update(ClientState state, Model model)
        {
            Type = model.Type;

            if (model.Timestamp.IsSpecified)
            {
                _timestampTicks = model.Timestamp.Value.UtcTicks;
            }

            if (model.Content.IsSpecified)
            {
                Content = model.Content.Value;
            }

            if (model.Application.IsSpecified)
            {
                // create a new Application from the API model
                Application = new MessageApplication()
                {
                    Id          = model.Application.Value.Id,
                    CoverImage  = model.Application.Value.CoverImage,
                    Description = model.Application.Value.Description,
                    Icon        = model.Application.Value.Icon,
                    Name        = model.Application.Value.Name
                };
            }

            if (model.Activity.IsSpecified)
            {
                // create a new Activity from the API model
                Activity = new MessageActivity()
                {
                    Type    = model.Activity.Value.Type.Value,
                    PartyId = model.Activity.Value.PartyId.GetValueOrDefault()
                };
            }

            if (model.Reference.IsSpecified)
            {
                // Creates a new Reference from the API model
                Reference = new MessageReference
                {
                    GuildId           = model.Reference.Value.GuildId,
                    InternalChannelId = model.Reference.Value.ChannelId,
                    MessageId         = model.Reference.Value.MessageId
                };
            }

            if (model.Flags.IsSpecified)
            {
                Flags = model.Flags.Value;
            }
        }
Exemplo n.º 6
0
        protected override JsonResult <Result <string> > OnCheckCheckCodeSuccess(string contact)
        {
            CheckUserLogin();

            string pluginId = PluginsManagement.GetInstalledPluginInfos(Core.Plugins.PluginType.SMS).First().PluginId;

            var _iMemberIntegralConversionFactoryService = ServiceProvider.Instance <IMemberIntegralConversionFactoryService> .Create;
            var _iMemberIntegralService = ServiceProvider.Instance <IMemberIntegralService> .Create;
            var _iMemberInviteService   = ServiceProvider.Instance <IMemberInviteService> .Create;

            var member = CurrentUser;

            if (Application.MessageApplication.GetMemberContactsInfo(pluginId, contact, MemberContactInfo.UserTypes.General) != null)
            {
                return(Json(ErrorResult <string>(contact + "已经绑定过了!")));
            }
            member.CellPhone = contact;
            MemberApplication.UpdateMember(member.Map <DTO.Members>());
            MessageApplication.UpdateMemberContacts(new MemberContactInfo()
            {
                Contact         = contact,
                ServiceProvider = pluginId,
                UserId          = CurrentUser.Id,
                UserType        = MemberContactInfo.UserTypes.General
            });
            Cache.Remove(CacheKeyCollection.MemberPluginCheck(CurrentUser.UserName, pluginId));
            Cache.Remove(CacheKeyCollection.Member(CurrentUser.Id));//移除用户缓存
            Cache.Remove("Rebind" + CurrentUser.Id);

            MemberInfo inviteMember = MemberApplication.GetMember(member.InviteUserId);


            var info = new MemberIntegralRecordInfo();

            info.UserName   = member.UserName;
            info.MemberId   = member.Id;
            info.RecordDate = DateTime.Now;
            info.TypeId     = MemberIntegralInfo.IntegralType.Reg;
            info.ReMark     = "绑定手机";
            var memberIntegral = _iMemberIntegralConversionFactoryService.Create(Himall.Entities.MemberIntegralInfo.IntegralType.Reg);

            _iMemberIntegralService.AddMemberIntegral(info, memberIntegral);
            if (inviteMember != null)
            {
                _iMemberInviteService.AddInviteIntegel(member, inviteMember, true);
            }

            return(base.OnCheckCheckCodeSuccess(contact));
        }
Exemplo n.º 7
0
        public JsonResult Skip(string serviceProvider, string openId, string nickName, string realName, string headimgurl, Entities.MemberOpenIdInfo.AppIdTypeEnum appidtype = Entities.MemberOpenIdInfo.AppIdTypeEnum.Normal, string unionid = null, string sex = null, string city = null, string province = null)
        {
            int    num      = 0;
            string username = DateTime.Now.ToString("yyMMddHHmmssffffff");   //TODO:DZY[150916]未使用,在方法内会重新生成

            nickName   = System.Web.HttpUtility.UrlDecode(nickName);
            realName   = System.Web.HttpUtility.UrlDecode(realName);
            headimgurl = System.Web.HttpUtility.UrlDecode(headimgurl);
            province   = System.Web.HttpUtility.UrlDecode(province);
            city       = System.Web.HttpUtility.UrlDecode(city);
            Entities.MemberInfo memberInfo = _iMemberService.GetMemberByUnionIdOpenId(unionid, openId);
            if (memberInfo == null)
            {
                memberInfo = _iMemberService.QuickRegister(username, realName, nickName, serviceProvider, openId, PlatformType.GetHashCode(),
                                                           unionid, sex, headimgurl, appidtype, null, city, province, spreadId: CurrentSpreadId);
                //TODO:ZJT  在用户注册的时候,检查此用户是否存在OpenId是否存在红包,存在则添加到用户预存款里
                _iBonusService.DepositToRegister(memberInfo.Id);
                //用户注册的时候,检查是否开启注册领取优惠券活动,存在自动添加到用户预存款里
                if (memberInfo.IsNewAccount)
                {
                    num = CouponApplication.RegisterSendCoupon(memberInfo.Id, memberInfo.UserName);
                }
                ClearDistributionSpreadCookie();
                _iMemberService.AddIntegel(memberInfo); //给用户加积分//执行登录后初始化相关操作
            }

            base.SetUserLoginCookie(memberInfo.Id);
            Application.MemberApplication.UpdateLastLoginDate(memberInfo.Id);
            WebHelper.SetCookie(CookieKeysCollection.HIMALL_ACTIVELOGOUT, "0", DateTime.MaxValue);

            #region 判断是否强制绑定手机号
            MemberApplication.UpdateLastLoginDate(memberInfo.Id);
            var isBind = MessageApplication.IsOpenBindSms(memberInfo.Id);
            if (!isBind)
            {
                return(Json <dynamic>(success: false, data: new { num = num }, code: 99));
            }
            #endregion

            return(Json <dynamic>(success: true, data: new { num = num }));
        }
        /// <summary>
        /// 处理普通页面请求的情况
        /// </summary>
        /// <param name="filterContext"></param>
        /// <returns>是否中断当前action提前结束</returns>
        bool ProcessInvalidUser_NormalRequest(ActionExecutingContext filterContext)
        {
            bool end = true;
            //处理手动退出后不自动登录
            string actlogout = WebHelper.GetCookie(CookieKeysCollection.Mall_ACTIVELOGOUT);

            //分析当前平台类型,并创建对应的登录接口
            IMobileOAuth imobileOauth = null;

            switch (PlatformType)
            {
            case Core.PlatformType.WeiXin:
                imobileOauth = new WeixinOAuth();
                break;
            }
            string normalLoginUrl = string.Format("/m-{0}/Login/Entrance?returnUrl={1}", PlatformType.ToString(), WebUtility.UrlEncode(filterContext.HttpContext.Request.GetDisplayUrl().ToString()));

            if (imobileOauth != null && GetRequestType(filterContext.HttpContext.Request) == Core.PlatformType.WeiXin)//找到了支持的登录接口
            {
                //可能的待跳转用户授权地址

                var    settings = new Entities.WXshopInfo();
                string redirectUrl;
                //string strShopid = WebHelper.GetCookie(CookieKeysCollection.Mall_SHOP);
                //long shopid = string.IsNullOrEmpty(strShopid) ? 0 : UserCookieEncryptHelper.Decrypt(strShopid, "Mobile");

                string strShopid = filterContext.HttpContext.Request.Query["shop"].ToString();
                var    AppidType = MemberOpenIdInfo.AppIdTypeEnum.Normal;
                if (!string.IsNullOrEmpty(strShopid))
                {
                    long shopid = 0;
                    bool isLong = long.TryParse(strShopid, out shopid);
                    if (shopid > 0)
                    {
                        settings = VshopApplication.GetVShopSetting(shopid);
                    }
                }

                if (string.IsNullOrEmpty(settings.AppId) || string.IsNullOrEmpty(settings.AppSecret))
                {
                    settings = new Entities.WXshopInfo()
                    {
                        AppId     = SiteSettings.WeixinAppId,
                        AppSecret = SiteSettings.WeixinAppSecret,
                        Token     = SiteSettings.WeixinToken
                    };
                    AppidType = MemberOpenIdInfo.AppIdTypeEnum.Payment;//是平台Appid,可以作为付款(微信支付)
                }

                //获取当前用户信息
                var userInfo = imobileOauth.GetUserInfo(filterContext, out redirectUrl, settings);
                if (string.IsNullOrWhiteSpace(redirectUrl))                              //待跳转地址为空,说明已经经过了用户授权页面
                {
                    if (userInfo != null && !string.IsNullOrWhiteSpace(userInfo.OpenId)) //用户信息不为空并且OpenId不为空,说明用户已经授权
                    {
                        if (AppidType == MemberOpenIdInfo.AppIdTypeEnum.Payment)
                        {
                            var curMenberOpenId = Core.Helper.SecureHelper.AESEncrypt(userInfo.OpenId, "Mobile");
                            WebHelper.SetCookie(CookieKeysCollection.Mall_USER_OpenID, curMenberOpenId);
                        }
                        //检查是否已经有用户绑定过该OpenId
                        //Mall.Core.Log.Debug("InvalidUser LoginProvider=" + userInfo.LoginProvider);
                        //Mall.Core.Log.Debug("InvalidUser OpenId=" + userInfo.OpenId);
                        //Mall.Core.Log.Debug("InvalidUser UnionId=" + userInfo.UnionId);
                        Entities.MemberInfo existUser = null;
                        //existUser = ServiceHelper.Create<IMemberService>().GetMemberByUnionId(userInfo.LoginProvider, userInfo.UnionId);
                        if (existUser == null)
                        {
                            if (actlogout != "1")
                            {
                                //existUser = ServiceHelper.Create<IMemberService>().GetMemberByOpenId(userInfo.LoginProvider, userInfo.OpenId);
                                existUser = MemberApplication.GetMemberByUnionId(userInfo.UnionId);
                            }
                        }

                        if (existUser != null)//已经有用户绑定过,直接标识为该用户
                        {
                            #region 如它已冻结了则直接跳到登录页
                            if (existUser.Disabled)
                            {
                                var result = Redirect(normalLoginUrl);
                                end = false;
                                return(end);
                            }
                            #endregion
                            base.SetUserLoginCookie(existUser.Id);
                            Application.MemberApplication.UpdateLastLoginDate(existUser.Id);
                            var isBind = MessageApplication.IsOpenBindSms(existUser.Id);
                            if (!isBind)
                            {
                                var result = Redirect(string.Format("/m-{0}/Member/BindPhone", PlatformType.ToString()));
                                filterContext.Result = result;
                            }
                        }
                        else//未绑定过,则跳转至登录绑定页面
                        {
                            normalLoginUrl = string.Format("/m-{0}/Login/Entrance?openId={1}&serviceProvider={2}&nickName={3}&realName={4}&headimgurl={5}&returnUrl={6}&AppidType={7}&unionid={8}&sex={9}&city={10}&province={11}&country={12}",
                                                           PlatformType.ToString(),
                                                           userInfo.OpenId,
                                                           "Mall.Plugin.OAuth.WeiXin",//使用同微信登录插件一致的名称, 以此保证微信信任与微信商城登录用户信息统一
                                                           WebUtility.UrlEncode(userInfo.NickName),
                                                           WebUtility.UrlEncode(userInfo.RealName),
                                                           WebUtility.UrlEncode(userInfo.Headimgurl),
                                                           WebUtility.UrlEncode(filterContext.HttpContext.Request.Headers["Referer"].ToString()),
                                                           AppidType,
                                                           userInfo.UnionId,
                                                           userInfo.Sex,
                                                           userInfo.City,
                                                           userInfo.Province,
                                                           userInfo.Country
                                                           );
                            //跳转至登录绑定页面
                            var result = Redirect(normalLoginUrl);
                            filterContext.Result = result;
                        }
                    }
                    else//用户未授权,或者无法获取用户授权
                    {
                        //用户未授权,则跳转至普通登录页面
                        var result = Redirect(normalLoginUrl);
                        filterContext.Result = result;
                    }
                }
                else
                {//立即跳转到用户授权页面
                    var result = Redirect(redirectUrl);
                    filterContext.Result = result;
                }
            }
            else
            {//未找到对应的用户授权实现机制,则跳转至普通登录页面
                var result = Redirect(normalLoginUrl);
                filterContext.Result = result;
            }
            return(end);
        }
 /// <summary>
 /// Üzenet küldésének eseménykiváltása.
 /// </summary>
 /// <param name="message">Az üzenet.</param>
 protected void OnMessageApplication(String message)
 {
     MessageApplication?.Invoke(this, new MessageEventArgs(message));
 }
Exemplo n.º 10
0
 public JsonResult IsConBindSms()
 {
     return(Json <dynamic>(success: MessageApplication.IsOpenBindSms(CurrentUser.Id)));
 }
Exemplo n.º 11
0
        internal virtual void Update(ClientState state, Model model)
        {
            Type = model.Type;

            if (model.Timestamp.IsSpecified)
            {
                _timestampTicks = model.Timestamp.Value.UtcTicks;
            }

            if (model.Content.IsSpecified)
            {
                Content = model.Content.Value;
            }

            if (model.Application.IsSpecified)
            {
                // create a new Application from the API model
                Application = new MessageApplication()
                {
                    Id          = model.Application.Value.Id,
                    CoverImage  = model.Application.Value.CoverImage,
                    Description = model.Application.Value.Description,
                    Icon        = model.Application.Value.Icon,
                    Name        = model.Application.Value.Name
                };
            }

            if (model.Activity.IsSpecified)
            {
                // create a new Activity from the API model
                Activity = new MessageActivity()
                {
                    Type    = model.Activity.Value.Type.Value,
                    PartyId = model.Activity.Value.PartyId.GetValueOrDefault()
                };
            }

            if (model.Reference.IsSpecified)
            {
                // Creates a new Reference from the API model
                Reference = new MessageReference
                {
                    GuildId           = model.Reference.Value.GuildId,
                    InternalChannelId = model.Reference.Value.ChannelId,
                    MessageId         = model.Reference.Value.MessageId,
                    FailIfNotExists   = model.Reference.Value.FailIfNotExists
                };
            }

            if (model.Components.IsSpecified)
            {
                Components = model.Components.Value.Select(x => new ActionRowComponent(x.Components.Select <IMessageComponent, IMessageComponent>(y =>
                {
                    switch (y.Type)
                    {
                    case ComponentType.Button:
                        {
                            var parsed = (API.ButtonComponent)y;
                            return(new Discord.ButtonComponent(
                                       parsed.Style,
                                       parsed.Label.GetValueOrDefault(),
                                       parsed.Emote.IsSpecified
                                        ? parsed.Emote.Value.Id.HasValue
                                            ? new Emote(parsed.Emote.Value.Id.Value, parsed.Emote.Value.Name, parsed.Emote.Value.Animated.GetValueOrDefault())
                                            : new Emoji(parsed.Emote.Value.Name)
                                        : null,
                                       parsed.CustomId.GetValueOrDefault(),
                                       parsed.Url.GetValueOrDefault(),
                                       parsed.Disabled.GetValueOrDefault()));
                        }

                    case ComponentType.SelectMenu:
                        {
                            var parsed = (API.SelectMenuComponent)y;
                            return(new SelectMenuComponent(
                                       parsed.CustomId,
                                       parsed.Options.Select(z => new SelectMenuOption(
                                                                 z.Label,
                                                                 z.Value,
                                                                 z.Description.GetValueOrDefault(),
                                                                 z.Emoji.IsSpecified
                                        ? z.Emoji.Value.Id.HasValue
                                            ? new Emote(z.Emoji.Value.Id.Value, z.Emoji.Value.Name, z.Emoji.Value.Animated.GetValueOrDefault())
                                            : new Emoji(z.Emoji.Value.Name)
                                        : null,
                                                                 z.Default.ToNullable())).ToList(),
                                       parsed.Placeholder.GetValueOrDefault(),
                                       parsed.MinValues,
                                       parsed.MaxValues,
                                       parsed.Disabled
                                       ));
                        }

                    default:
                        return(null);
                    }
                }).ToList())).ToImmutableArray();
            }
            else
            {
                Components = new List <ActionRowComponent>();
            }

            if (model.UserMentions.IsSpecified)
            {
                var value = model.UserMentions.Value;
                if (value.Length > 0)
                {
                    var newMentions = ImmutableArray.CreateBuilder <SocketUser>(value.Length);
                    for (int i = 0; i < value.Length; i++)
                    {
                        var val = value[i];
                        if (val != null)
                        {
                            var user = Channel.GetUserAsync(val.Id, CacheMode.CacheOnly).GetAwaiter().GetResult() as SocketUser;
                            if (user != null)
                            {
                                newMentions.Add(user);
                            }
                            else
                            {
                                newMentions.Add(SocketUnknownUser.Create(Discord, state, val));
                            }
                        }
                    }
                    _userMentions = newMentions.ToImmutable();
                }
            }

            if (model.Interaction.IsSpecified)
            {
                Interaction = new MessageInteraction <SocketUser>(model.Interaction.Value.Id,
                                                                  model.Interaction.Value.Type,
                                                                  model.Interaction.Value.Name,
                                                                  SocketGlobalUser.Create(Discord, state, model.Interaction.Value.User));
            }

            if (model.Flags.IsSpecified)
            {
                Flags = model.Flags.Value;
            }
        }
Exemplo n.º 12
0
 protected void OnMessageApplication(object obj, String message)
 {
     MessageApplication?.Invoke(obj, new MessageEventArgs(message));
 }
Exemplo n.º 13
0
 /// <summary>
 /// 是否强制绑定手机号
 /// </summary>
 /// <returns></returns>
 public object IsConBindSms()
 {
     CheckUserLogin();
     return(Json(new { success = MessageApplication.IsOpenBindSms(CurrentUser.Id) }));
 }
Exemplo n.º 14
0
 public object SendMessageOnRefundApply(RefundApply args)
 {
     MessageApplication.SendMessageOnRefundApply(args.UserId, args.Info, args.RefundMode, args.RefundId);
     return(new { success = true });
 }
Exemplo n.º 15
0
 public object SendMessageOnRefundDeliver(RefundDeliverArgs args)
 {
     MessageApplication.SendMessageOnRefundDeliver(args.UserId, args.Info, args.RefundId);
     return(new { success = true });
 }
Exemplo n.º 16
0
 public object SendMessageOnDistributorCommissionSettled(DistributorCommissionSettledArgs args)
 {
     MessageApplication.SendMessageOnDistributorCommissionSettled(args.UserId, args.Amount, args.SettlementDate);
     return(new { success = true });
 }