public object UpdateBindMobile([FromBody] BindMobileViewModel bindModel)
        {
            LogUtil.Info("执行更换绑定手机号请求...");

            SingleInstance <ShopBLL> .Instance.BindMobile(base.AppSign, base.CurrUser, bindModel);

            var currUser = GetCurrUser(OperateType.Dologout, bindModel.NewMobile);

            //执行登出系列操作
            if (currUser != null)
            {
                SingleInstance <ShopBLL> .Instance.DoLogout(currUser);
            }
            return(OK());
        }
Esempio n. 2
0
        /// <summary>
        /// 更新绑定手机号
        /// </summary>
        /// <param name="appSign"></param>
        /// <param name="curUser"></param>
        /// <param name="bindModel"></param>
        public void BindMobile(string appSign, ShopEntity curUser, BindMobileViewModel bindModel)
        {
            var db = new RepositoryFactory().BaseRepository().BeginTrans();

            try
            {
                // 校验参数
                if (bindModel == null)
                {
                    throw new MessageException("更新参数不可为空!");
                }
                if (bindModel.NewMobile == bindModel.Mobile)
                {
                    throw new MessageException("新手机号与原手机号相同!");
                }
                if (bindModel.Mobile != curUser.ShopAccount)
                {
                    throw new MessageException("原手机号不正确请核对!");
                }
                var shop = GetShopByMobile(bindModel.NewMobile, OperateType.GetInfo);
                if (shop != null)
                {
                    //1.校验是否存在订单
                    var isExistsOrder = SingleInstance <OrderBLL> .Instance.CheckShopIsExistsOrder(shop.ShopId);

                    if (isExistsOrder)
                    {
                        throw new MessageException("新手机账号下已有订单,请联系客服!");
                    }
                    //2.校验是否关联打印机
                    var isBindPrinter = SingleInstance <PrinterBLL> .Instance.CheckShopIsBindPrinter(shop.ShopId);

                    if (isBindPrinter)
                    {
                        throw new MessageException("新手机账号下已绑定打印机,请先解除!");
                    }
                    //3.校验是否授权第三方平台
                    var isAuth = SingleInstance <PlatformBLL> .Instance.CheckShopIsAuhtPlatform(shop.ShopId);

                    if (isAuth)
                    {
                        throw new MessageException("新手机账号下已有第三方平台授权,请先取消!");
                    }

                    //throw new MessageException("新手机号已注册!");
                }

                // 更新验证码
                SingleInstance <VerifyCodeBLL> .Instance.UpdateVerifyCode(appSign, bindModel.VerifyCode, bindModel.NewMobile);

                if (shop != null)
                {
                    // 4.删除新手机号对应门店账户信息
                    service.Remove(shop.ShopId);
                }

                // 5.更新手机号
                curUser.ShopAccount = bindModel.NewMobile;
                service.UpdateEntity(curUser);

                db.Commit();
            }
            catch (Exception ex)
            {
                db.Rollback();
                LogUtil.Error(ex.StackTrace);
                throw new MessageException(ex.Message);
            }
        }