Example #1
0
        /// <summary>
        /// 登录
        /// </summary>
        /// <param name="loginName">Name of the login.</param>
        /// <param name="password">The password.</param>
        /// <param name="AppSystem">APP系统</param>
        /// <param name="apiCode">The API code.</param>
        /// <returns>UserModel.</returns>
        public UserModel Login(string loginName, string password, string AppSystem, ref ApiStatusCode apiCode)
        {
            using (var dal = FactoryDispatcher.UserFactory())
            {
                UserModel model = dal.Login(loginName, password);
                if (model != null)
                {
                    if (model.IsActive == 1 && model.ShopActive == 1)
                    {
                        apiCode = ApiStatusCode.OK;
                        if (!string.IsNullOrEmpty(model.UserHeadImg))
                        {
                            model.UserHeadImg = WebConfig.reswebsite() + model.UserHeadImg;
                        }
                        model.myqrcodeUrl      = WebConfig.articleDetailsDomain() + "/app/myqrcode.html?userid=" + model.UserId;
                        model.myShareQrcodeUrl = WebConfig.articleDetailsDomain() + string.Format("/resource/app/qrcode/{0}/index.html", model.UserId);
                        model.MengBeans        = model.MengBeans - model.MengBeansLocked;
                        model.Score            = model.Score - model.ScoreLocked;
                        model.TempMengBeans    = UserLogic.countTempBeansMoney(model.UserId, 0);
                        model.UserGender       = model.UserGender.ToUpper();
                        string token = EncryptHelper.MD5(StringHelper.CreateCheckCode(20));
                        if (dal.IsAuthTokenExist(model.UserId) ? dal.UpdateUserAuthToken(model.UserId, token) : dal.AddUserAuthToken(model.UserId, token))
                        {
                            model.token = token;
                        }

                        if (model.UserIdentity == 1)
                        {
                            UserLogic.masterUpdate(model.UserId);
                        }
                        else
                        {
                            UserLogic.userUpdate(model.UserId);
                        }

                        model.LevelName = UserLogic.GetUserLevelName(model.UserId);

                        //添加登录日志
                        LogLogic.AddLoginLog(new LoginLogModel()
                        {
                            UserId       = model.UserId,
                            UserIdentity = model.UserIdentity,
                            BelongOne    = model.BelongOne,
                            ShopId       = model.ShopId,
                            AppSystem    = AppSystem
                        });

                        //更新最后登录时间
                        dal.UpdateLastLoginTime(model.UserId);
                        return(model);
                    }
                    else
                    {
                        apiCode = ApiStatusCode.账户已禁用;
                        return(null);
                    }
                }
                else
                {
                    apiCode = ApiStatusCode.账户密码不正确;
                    return(null);
                }
            }
        }
Example #2
0
        public static bool Update(int userId, string orderId, int status, ref ApiStatusCode code)
        {
            using (var dal = FactoryDispatcher.OrderFactory())
            {
                OrderModel orderModel = dal.GetModel(orderId);
                if (orderModel == null)
                {
                    code = ApiStatusCode.订单存在问题;
                    return(false);
                }
                if (orderModel.OrderStatus != 0)
                {
                    code = ApiStatusCode.订单目前状态存在异常;
                    return(false);
                }

                if (status == 1 && string.IsNullOrEmpty(orderModel.SuccessImg))
                {
                    code = ApiStatusCode.请先上传成交凭证;
                    return(false);
                }


                //改订单为已处理
                if (status == 1 && orderModel.UserId != orderModel.Ct_BelongId)
                {
                    //更新盟友用户等级
                    UserLogic.userUpdate(orderModel.Ct_BelongId);
                    //更新盟主用户等级
                    UserLogic.masterUpdate(orderModel.UserId);
                    if (orderModel.MengBeans > 0)
                    {
                        //给盟友加盟豆
                        UserLogic.addUserMoney(orderModel.Ct_BelongId, orderModel.MengBeans);

                        using (var dal1 = FactoryDispatcher.UserFactory())
                        {
                            TempBeansRecordsModel model1 = new TempBeansRecordsModel();
                            model1.Amount     = -orderModel.MengBeans;
                            model1.UserId     = orderModel.Ct_BelongId;
                            model1.LogType    = 0;
                            model1.Income     = 0;
                            model1.CreateTime = DateTime.Now;
                            model1.Status     = 0;
                            model1.OrderId    = orderModel.orderId;
                            model1.Remark     = "转正";
                            dal1.AddTempBeansRecords(model1);

                            BeansRecordsModel model2 = new BeansRecordsModel();
                            model2.Amount     = orderModel.MengBeans;
                            model2.UserId     = orderModel.Ct_BelongId;
                            model2.LogType    = 0;
                            model2.Income     = 1;
                            model2.Remark     = "订单奖励";
                            model2.OrderId    = orderModel.orderId;
                            model2.CreateTime = DateTime.Now;
                            dal1.AddBeansRecords(model2);
                        }
                    }
                }
                if (status == 2 && orderModel.UserId != orderModel.Ct_BelongId && orderModel.MengBeans > 0)
                {
                    using (var dal1 = FactoryDispatcher.UserFactory())
                    {
                        TempBeansRecordsModel model1 = new TempBeansRecordsModel();
                        model1.Amount     = -orderModel.MengBeans;
                        model1.UserId     = orderModel.Ct_BelongId;
                        model1.LogType    = 0;
                        model1.Income     = 0;
                        model1.CreateTime = DateTime.Now;
                        model1.Status     = 0;
                        model1.OrderId    = orderModel.orderId;
                        model1.Remark     = "退单";
                        dal1.AddTempBeansRecords(model1);
                    }
                }

                bool flag = dal.Update(orderId, status) == 1;
                if (status == 1)
                {
                    if (orderModel.UserId != orderModel.Ct_BelongId && orderModel.UserId > 0 && orderModel.Ct_BelongId > 0)
                    {
                        //添加用户订单量
                        UserLogic.AddUserOrderSuccessAmount(orderModel.UserId);
                        UserLogic.AddUserOrderSuccessAmount(orderModel.Ct_BelongId);
                    }
                    else
                    {
                        //添加用户订单量
                        UserLogic.AddUserOrderSuccessAmount(orderModel.UserId);
                    }
                }

                return(flag);
            }
        }