예제 #1
0
        public IHttpActionResult CheckPhotoIsBuy(int UID, int PhotoCollectionID)
        {
            WebApi_BLL.T_Photo_Pay          tppbll = new WebApi_BLL.T_Photo_Pay();
            List <WebApi_Model.T_Photo_Pay> list   = tppbll.GetModelList("UID=" + UID + " and PhotoCollectionID=" + PhotoCollectionID);

            if (list.Count > 0)
            {
                return(Ok(ReturnJsonResult.GetJsonResult(1, "OK", true)));
            }
            else
            {
                return(Ok(ReturnJsonResult.GetJsonResult(1, "OK", false)));
            }
        }
예제 #2
0
        public IHttpActionResult CheckStatus(int UID, int PhotoCollectionID)
        {
            WebApi_BLL.T_Photo_Likes tpl_bll = new WebApi_BLL.T_Photo_Likes();
            WebApi_BLL.T_Photo_Store tps_bll = new WebApi_BLL.T_Photo_Store();
            WebApi_BLL.T_Photo_Pay   tpp_bll = new WebApi_BLL.T_Photo_Pay();
            bool      IsLike  = tpl_bll.Exists(UID, PhotoCollectionID);
            bool      IsStore = tps_bll.Exists(UID, PhotoCollectionID);
            bool      IsBuy   = tpp_bll.Exists(UID, PhotoCollectionID);
            ArrayList list    = new ArrayList();
            Hashtable ht      = new Hashtable();

            ht.Add("IsLike", IsLike);
            ht.Add("IsStore", IsStore);
            ht.Add("IsBuy", IsBuy);
            list.Add(ht);
            return(Ok(ReturnJsonResult.GetJsonResult(1, "OK", JsonConvert.SerializeObject(list))));
        }
예제 #3
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)));
            }
        }