Пример #1
0
 public int Delete(RecommendLog item)
 {
     return(_databaseInstance.Delete(item, TableName));
 }
Пример #2
0
        /// <summary>
        /// 订阅(关注)事件
        /// </summary>
        /// <returns></returns>
        public override IResponseMessageBase OnEvent_SubscribeRequest(RequestMessageEvent_Subscribe requestMessage)
        {
            var responseMessage     = ResponseMessageBase.CreateFromRequestMessage <ResponseMessageText>(requestMessage);
            var AccountService      = _container.Resolve <IAccountService>();
            var MembershipService   = _container.Resolve <IMembershipService>();
            var TransactionHelper   = _container.Resolve <TransactionHelper>();
            var RecommendLogService = _container.Resolve <IRecommendLogService>();
            var item = AccountService.GetByopenID(requestMessage.FromUserName);

            WxPayAPI.Log.Info(this.GetType().ToString(), "进入订阅(关注) openId: " + requestMessage.FromUserName);
            string salerOpenId = "";
            var    userWX      = Senparc.Weixin.MP.AdvancedAPIs.UserApi.Info(WxPayConfig.APPID, requestMessage.FromUserName);

            if (item == null)
            {
                string orangeKey = requestMessage.EventKey.Replace("qrscene_", "");
                WxPayAPI.Log.Info(this.GetType().ToString(), "进入订阅(关注) orangeKey: " + orangeKey);
                int     salerId    = 0;
                Account saleAccont = null;
                if (!string.IsNullOrWhiteSpace(orangeKey))
                {
                    saleAccont = AccountService.GetByorangeKey(orangeKey);
                    if (saleAccont == null)
                    {
                    }
                    else
                    {
                        salerId     = saleAccont.accountId;
                        salerOpenId = saleAccont.openID;
                        WxPayAPI.Log.Info(this.GetType().ToString(), "进入订阅(关注) salerOpenId: " + saleAccont.openID);
                    }
                }
                TransactionHelper.BeginTransaction();
                AccountUser modelUser = new AccountUser();
                modelUser.Address     = "";
                modelUser.DisplayName = userWX.nickname;
                modelUser.Email       = "";
                modelUser.Gender      = userWX.sex;
                modelUser.Mobile      = "";
                modelUser.Name        = requestMessage.FromUserName;
                modelUser.Photo       = userWX.headimgurl.Replace("/0", "/132");
                //modelUser.SetPassword(Password);
                modelUser.State = UserStates.Normal;
                MembershipService.CreateUser(modelUser);
                Account modelAccount = new Account();
                //var QrCodeResult = CreateQrCode();
                //modelAccount.ticket = QrCodeResult.ticket;
                modelAccount.activatePoint = 0; string myOrangeKey = (modelUser.UserId + 10000).ToString();
                modelAccount.orangeKey     = myOrangeKey.PadLeft(modelUser.UserId.ToString().Length + 2, '0');
                //modelAccount.notActivatePoint = 0;
                // modelAccount.orangeKey = modelUser.UserId.ToString().PadLeft(modelUser.UserId.ToString().Length + 2, '0');
                //modelAccount.payPoint = 0;
                modelAccount.openID = requestMessage.FromUserName;
                //modelAccount.presentExp = site.givePoint;
                modelAccount.salerId    = salerId;
                modelAccount.state      = AccountStates.Normal;
                modelAccount.submitTime = DateTime.Now;
                modelAccount.userId     = modelUser.UserId;
                modelAccount.grade      = AccountGrade.not;
                AccountService.Insert(modelAccount);
                if (salerId > 0)
                {
                    RecommendLog recommendlog = new RecommendLog();
                    recommendlog.remark     = string.Format("推荐了{0}", userWX.nickname);
                    recommendlog.salerId    = saleAccont.userId;
                    recommendlog.submitTime = DateTime.Now;
                    recommendlog.userId     = modelUser.UserId;
                    recommendlog.userName   = requestMessage.FromUserName;
                    RecommendLogService.Insert(recommendlog);
                    if (!string.IsNullOrWhiteSpace(salerOpenId))
                    {
                        string msg = string.Format("恭喜您,您成功推荐了【{0}】成为了您的直属粉丝,时间:{1}", userWX.nickname, DateTime.Now);
                        Senparc.Weixin.MP.AdvancedAPIs.CustomApi.SendText(WxPayConfig.APPID, salerOpenId, msg);
                    }
                }
                responseMessage.Content = "快去成为会员吧";
                TransactionHelper.Commit();
                //responseMessage.Articles.Add(new Article()
                //{
                //    Title = "速度,加入雷鹏汽车吧!",
                //    Description = "注册,成为会员即赠送积分!",
                //    PicUrl = "http://shop.leipengcar.com/MsgImages/one.jpg",//requestMessage.PicUrl,
                //    Url = "http://shop.leipengcar.com/Regists/Regist?openId=" + requestMessage.FromUserName
                //});
            }
            else
            {
            }


            //responseMessage.Content = msg();// "欢迎关注雷鹏汽车用品!​";//GetWelcomeInfo();
            return(responseMessage);
        }
Пример #3
0
 public int Insert(RecommendLog item)
 {
     return(_databaseInstance.Insert(item, TableName));
 }
Пример #4
0
        //public CreateQrCodeResult CreateQrCode()
        //{
        //    var set = SetWeChatService.GetById(1);
        //    var access_token = AccessTokenContainer.GetToken(set.appID);
        //    return Senparc.Weixin.MP.AdvancedAPIs.QrCodeApi.Create(access_token, 0, 001);

        //}

        public ResultMessage Save()
        {
            try
            {
                //if (string.IsNullOrWhiteSpace(openID))
                //    return new ResultMessage() { Code = -1, Msg = "请重新进入页面!" };
                //var account = AccountService.GetByopenID(openID);
                //if (account != null)
                //    return new ResultMessage() { Code = -1, Msg = "你已注册!" };
                var user = MembershipService.GetByMobile(Mobile);
                if (user != null)
                {
                    return new ResultMessage()
                           {
                               Code = -1, Msg = "手机号码已注册,请更换!"
                           }
                }
                ;
                if (string.IsNullOrWhiteSpace(Password))
                {
                    return new ResultMessage()
                           {
                               Code = -1, Msg = "请输入密码!"
                           }
                }
                ;
                if (Password != PasswordConfirm)
                {
                    return new ResultMessage()
                           {
                               Code = -1, Msg = "两次输入密码不一致!"
                           }
                }
                ;
                var     site       = SiteService.Query(new SiteRequest()).FirstOrDefault();
                int     salerId    = 0;
                Account saleAccont = null;
                if (!string.IsNullOrWhiteSpace(orangeKey))
                {
                    saleAccont = AccountService.GetByorangeKey(orangeKey);

                    if (saleAccont == null)
                    {
                        return new ResultMessage()
                               {
                                   Code = -2, Msg = "推荐码不存在!"
                               }
                    }
                    ;
                    salerId = saleAccont.accountId;
                }
                TransactionHelper.BeginTransaction();
                AccountUser modelUser = new AccountUser();
                modelUser.Address     = Address;
                modelUser.DisplayName = Name;
                modelUser.Email       = Email;
                modelUser.Gender      = Sex;
                modelUser.Mobile      = Mobile;
                modelUser.Name        = Mobile;
                modelUser.SetPassword(Password);
                modelUser.State = UserStates.Normal;
                MembershipService.CreateUser(modelUser);
                Account modelAccount = new Account();
                //var QrCodeResult = CreateQrCode();
                //modelAccount.ticket = QrCodeResult.ticket;
                modelAccount.activatePoint = 0;
                //modelAccount.notActivatePoint = 0;
                modelAccount.orangeKey = modelUser.UserId.ToString().PadLeft(modelUser.UserId.ToString().Length + 2, '0');
                //modelAccount.payPoint = 0;
                modelAccount.openID = openID;
                //modelAccount.presentExp = site.givePoint;
                modelAccount.salerId    = salerId;
                modelAccount.state      = AccountStates.Normal;
                modelAccount.submitTime = DateTime.Now;
                modelAccount.userId     = modelUser.UserId;
                modelAccount.grade      = AccountGrade.not;
                AccountService.Insert(modelAccount);
                if (salerId > 0)
                {
                    RecommendLog recommendlog = new RecommendLog();
                    recommendlog.remark     = string.Format("推荐了{0}", Mobile);
                    recommendlog.salerId    = saleAccont.userId;
                    recommendlog.submitTime = DateTime.Now;
                    recommendlog.userId     = modelUser.UserId;
                    recommendlog.userName   = Mobile;
                    RecommendLogService.Insert(recommendlog);
                }
                TransactionHelper.Commit();
                return(new ResultMessage()
                {
                    Code = 0
                });
            }
            catch (Exception ex)
            {
                Log4netService.Insert(ex);
                return(new ResultMessage()
                {
                    Code = -1, Msg = "系统错误!"
                });
            }
        }