public ActionResult SendCode()
        {
            MemberSendCodeArgs args = RequestArgs <MemberSendCodeArgs>();

            if (args == null)
            {
                return(FailedResult("参数无效。"));
            }
            string code = new Random().Next(1000, 9999).ToString();

            Yuntongxun.SendTemplateSMS(args.mobilephone, "192218", new string[] { code });

            _cachingService.Set(args.mobilephone + "ValidationCode", code, TimeSpan.FromMinutes(VALIDATIONCODE_EXPRESSTIME));

            return(ApiResult(true, "验证码已发送,15分钟内有效。"));
        }
        public NormalResult ChangeStatus(ChangeMemberStatusArgs args)
        {
            using (Entities db = new Entities())
            {
                IQueryable <Member> queryable = db.Member;

                Member dbMember = queryable.FirstOrDefault(e => e.id == args.MemberId);
                if (dbMember == null)
                {
                    return(new NormalResult("指定的数据不存在。"));
                }

                if (dbMember.status == args.Status)
                {
                    return(new NormalResult());
                }

                dbMember.status = args.Status;


                switch (dbMember.status)
                {
                case 2:     //审核通过
                            //发短信
                    Yuntongxun.SendTemplateSMS(dbMember.phone_num, "202414", new string[] { });
                    break;

                case 3:     //审核不通过
                    //发短信
                    break;

                default:
                    break;
                }

                dbMember.update_time = DateTime.Now;

                db.SaveChanges();
            }

            return(new NormalResult());
        }
        /// <summary>
        /// 会员开户
        /// </summary>
        /// <returns></returns>
        public ActionResult Register()
        {
            MemberRegisterArgs args = RequestArgs <MemberRegisterArgs>();

            if (args == null)
            {
                return(FailedResult("参数无效。"));
            }

            Member member = new Member();

            member.name              = args.userName;
            member.wechat_no         = args.wechatNo;
            member.phone_num         = args.mobilephone;
            member.superior_agent_id = this.UserContext.UserId;
            member.status            = 1;
            member.type              = 3;

            NormalResult result = _memberManager.CreateMember(member);

            if (result.Successful)
            {
                //发短信
                Yuntongxun.SendTemplateSMS(args.mobilephone, "197936", new string[] { "18994422279" });

                //新用户注册等待审核
                Yuntongxun.SendTemplateSMS("18994422239", "241364",
                                           new string[] { member.phone_num, _memberManager.GetMemberCount(1).ToString() });


                return(ApiResult(true, "申请开户成功"));
            }
            else
            {
                return(FailedResult(result.Message));
            }
        }
        public ActionResult RegisterNoSuper()
        {
            MemberRegisterArgs args = RequestArgs <MemberRegisterArgs>();

            if (args == null)
            {
                return(FailedResult("参数无效。"));
            }

            Member member = new Member();

            member.phone_num = args.mobilephone;
            member.wechat_no = args.wechatNo;
            member.password  = IOHelper.GetMD5HashFromString(args.password);
            member.status    = 1;
            member.type      = 3;

            NormalResult result = _memberManager.CreateMember(member);

            if (result.Successful)
            {
                //注册使用模版
                Yuntongxun.SendTemplateSMS(args.mobilephone, "197936", new string[] { "18994422279" });

                //新用户注册等待审核
                Yuntongxun.SendTemplateSMS("18994422239", "241364",
                                           new string[] { member.phone_num, _memberManager.GetMemberCount(1).ToString() });


                return(ApiResult(true, "申请开户成功", Mapper.Map <MemberAppDto>(member)));
            }
            else
            {
                return(FailedResult(result.Message));
            }
        }