Ejemplo n.º 1
0
        /// <summary>
        /// 会员修改
        /// </summary>
        /// <returns></returns>
        public ActionResult Update()
        {
            MemberAppDto args = RequestArgs <MemberAppDto>();

            if (args == null)
            {
                return(FailedResult("参数无效。"));
            }
            Member member = _memberManager.GetMember(UserContext.UserId);

            if (string.IsNullOrEmpty(args.name) == false)
            {
                member.name = args.name;
            }
            if (string.IsNullOrEmpty(args.wechatNo) == false)
            {
                member.wechat_no = args.wechatNo;
            }
            if (string.IsNullOrEmpty(args.cardHolder) == false)
            {
                member.card_holder = args.cardHolder;
            }
            if (string.IsNullOrEmpty(args.cardNo) == false)
            {
                member.card_no = args.cardNo;
            }
            if (string.IsNullOrEmpty(args.depositBank) == false)
            {
                member.deposit_bank = args.depositBank;
            }
            if (string.IsNullOrEmpty(args.depositBranchBank) == false)
            {
                member.deposit_branch_bank = args.depositBranchBank;
            }

            if (string.IsNullOrEmpty(args.secretStatus) == false)
            {
                member.secret_status = Convert.ToInt32(args.secretStatus);
            }

            if (string.IsNullOrEmpty(args.picPath) == false)
            {
                member.pic_path = args.picPath;
            }
            NormalResult result = _memberManager.UpdateMember(member);

            return(ApiResult(result.Successful, result.Message));
        }
Ejemplo n.º 2
0
        public ActionResult Get(int id)
        {
            if (id == 0)
            {
                return(FailedResult("参数无效"));
            }
            MemberAppDto member    = Mapper.Map <Member, MemberAppDto> (_memberManager.GetMember(id));
            AppApiResult apiResult = new AppApiResult()
            {
                result  = "success",
                message = "查询用户信息成功!",
                token   = this.UserContext.Token,
                data    = member
            };

            return(ApiResult(apiResult));
        }
Ejemplo n.º 3
0
        public ActionResult Login()
        {
            MemberLoginArgs args = RequestArgs <MemberLoginArgs>();

            if (args == null)
            {
                return(FailedResult("参数无效。"));
            }
            args.password = IOHelper.GetMD5HashFromString(args.password);
            Member member = _memberManager.GetMemberByMobilePhoneAndPassword(args.mobilephone, args.password);

            if (member == null == false)
            {
                //TODO:初始化 memberDto
                MemberAppDto memberAppDto = Mapper.Map <Member, MemberAppDto>(member);

                memberAppDto.primaryDistributionCount = _memberManager.GetMemberDistributionCount(memberAppDto.id, null);
                memberAppDto.secondDistributionCount  = _memberManager.GetMemberDistributionCount(null, Convert.ToInt32(memberAppDto.superiorAgentId));
                MemberUserContext userContext = new MemberUserContext()
                {
                    LoginTime = DateTime.Now,
                    Token     = Guid.NewGuid().ToString(),
                    UserId    = member.id,
                    Member    = memberAppDto
                };
                NormalResult <MemberUserContext> result = new NormalResult <MemberUserContext>();
                result.Data = userContext;

                _cachingService.Set(userContext.Token, userContext);

                //一般返回结果不需要自己new AppApiResult,看 return ApiResult 这个方法的几个重载
                AppApiResult apiResult = new AppApiResult()
                {
                    result  = "success",
                    message = "登录成功",
                    token   = result.Data.Token,
                    data    = memberAppDto
                };
                return(ApiResult(apiResult));
            }
            else
            {
                return(FailedResult("手机号或密码无效。"));
            }
        }