Пример #1
0
        public IHttpActionResult UserLogin()
        {
            string strUsername = requestHelper.GetRequsetForm("Username", "");
            string strPassword = requestHelper.GetRequsetForm("Password", "");

            WebApi_Model.T_User user = bll.Login(strUsername, strPassword);
            if (user == null)
            {
                return(Ok(ReturnJsonResult.GetJsonResult(-1, "找不到用户", JsonConvert.SerializeObject(user))));
            }

            if (user.IsOnLine != 1)
            {
                user.IsOnLine      = 1;
                user.LastLoginDate = DateTime.Now;
                bll.Update(user);
                return(Ok(ReturnJsonResult.GetJsonResult(1, "OK", JsonConvert.SerializeObject(user))));
            }
            else
            {
                return(Ok(ReturnJsonResult.GetJsonResult(1, "该用户正在被使用", JsonConvert.SerializeObject(user))));
            }
        }
Пример #2
0
 public WebApi_Model.T_User UserRecharge(WebApi_Model.T_User user, WebApi_Model.T_RechargeType rechargetype)
 {
     return(dal.UserRecharge(user, rechargetype));
 }
Пример #3
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool ResetPassword(WebApi_Model.T_User model)
 {
     return(dal.ResetPassword(model));
 }
Пример #4
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(WebApi_Model.T_User model)
 {
     return(dal.Update(model));
 }
Пример #5
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(WebApi_Model.T_User model)
 {
     return(dal.Add(model));
 }
Пример #6
0
        public IHttpActionResult PayPhotoCollection()
        {
            try
            {
                int PhotoCollectionID = int.Parse(requestHelper.GetRequsetForm("PhotoCollectionID", ""));
                int UID    = int.Parse(requestHelper.GetRequsetForm("UID", ""));
                int PayWay = int.Parse(requestHelper.GetRequsetForm("PayWay", ""));

                WebApi_Model.T_Photo_Collection photomodel = bll.GetModel(PhotoCollectionID);
                WebApi_BLL.T_User   tubll     = new WebApi_BLL.T_User();
                WebApi_Model.T_User usermodel = tubll.GetModel(UID);
                if (photomodel == null || photomodel.IsActive != 1)
                {
                    return(Ok(ReturnJsonResult.GetJsonResult(-1, "Faild", "找不到该图集")));
                }

                if (usermodel == null)
                {
                    return(Ok(ReturnJsonResult.GetJsonResult(-1, "Faild", "找不到该用户信息")));
                }

                WebApi_BLL.T_Photo_Pay          tppbll = new WebApi_BLL.T_Photo_Pay();
                List <WebApi_Model.T_Photo_Pay> list   = tppbll.GetModelList(" PhotoCollectionID =" + PhotoCollectionID + " and UID = " + UID);

                if (list.Count > 0)
                {
                    return(Ok(ReturnJsonResult.GetJsonResult(1, "OK", list)));
                }
                else
                {
                    if (PayWay == 1)
                    {
                        //瞟资查看
                        if (usermodel.PiaoZi >= photomodel.PiaoZi)
                        {
                            Hashtable newSqlList = new Hashtable();
                            newSqlList.Add("update T_User Set PiaoZi = (PiaoZi - " + photomodel.PiaoZi + ") where uid = @uid", new SqlParameter[] { new SqlParameter("@uid", UID) });
                            newSqlList.Add("INSERT INTO T_Photo_Pay (photoCollectionID,UID,BuyDate,PayWay,PayValue) values (@photoCollectionID,@UID,GETDATE(),@PayWay,@PayValue)", new SqlParameter[] {
                                new SqlParameter("@photoCollectionID", PhotoCollectionID), new SqlParameter("@UID", UID), new SqlParameter("@PayWay", PayWay), new SqlParameter("@PayValue", photomodel.PiaoZi),
                            });
                            DBHelper.ExecuteSqlTranWithIndentity(newSqlList);
                            return(Ok(ReturnJsonResult.GetJsonResult(1, "OK", true)));
                        }
                        else
                        {
                            return(Ok(ReturnJsonResult.GetJsonResult(-1, "Faild", "瞟资不足")));
                        }
                    }

                    else if (PayWay == 2)
                    {
                        //腿毛
                        if (usermodel.TuiMao >= photomodel.TuiMao)
                        {
                            Hashtable newSqlList = new Hashtable();
                            newSqlList.Add("update T_User Set TuiMao = (TuiMao - " + photomodel.TuiMao + ") where uid = @uid", new SqlParameter[] { new SqlParameter("@uid", UID) });
                            newSqlList.Add("INSERT INTO T_Photo_Pay (photoCollectionID,UID,BuyDate,PayWay,PayValue) values (@photoCollectionID,@UID,GETDATE(),@PayWay,@PayValue)", new SqlParameter[] {
                                new SqlParameter("@photoCollectionID", PhotoCollectionID), new SqlParameter("@UID", UID), new SqlParameter("@PayWay", PayWay), new SqlParameter("@PayValue", photomodel.TuiMao),
                            });
                            DBHelper.ExecuteSqlTranWithIndentity(newSqlList);
                            return(Ok(ReturnJsonResult.GetJsonResult(1, "OK", true)));
                        }
                        else
                        {
                            return(Ok(ReturnJsonResult.GetJsonResult(-1, "Faild", "腿毛不足")));
                        }
                    }
                    else
                    {
                        return(null);
                    }
                }
            }
            catch (Exception ex)
            {
                return(Ok(ReturnJsonResult.GetJsonResult(-1, "Error", ex.Message)));
            }
        }