Example #1
0
        /// <summary>
        /// 添加一条数据
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int Add(FeeHR model, SqlTransaction tran)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into FeeHR(");
            strSql.Append(" MainID,UserID,FeeTime,FeeType,FeeCoin,FeeCoinType,IsDelete )");
            strSql.Append(" values (");
            strSql.Append("@MainID,@UserID,@FeeTime,@FeeType,@FeeCoin,@FeeCoinType,@IsDelete)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@MainID",      model.MainID),
                new SqlParameter("@UserID",      model.UserID),
                new SqlParameter("@FeeTime",     model.FeeTime),
                new SqlParameter("@FeeType",     model.FeeType),
                new SqlParameter("@FeeCoin",     model.FeeCoin),
                new SqlParameter("@FeeCoinType", model.FeeCoinType),
                new SqlParameter("@IsDelete",    model.IsDelete),
            };

            object obj;

            if (tran == null)
            {
                obj = SqlHelper.GetSingle(strSql.ToString(), CommandType.Text, parameters);
            }
            else
            {
                obj = SqlHelper.GetSingle(tran, CommandType.Text, strSql.ToString(), parameters);
            }
            return(obj == null ? 0 : Convert.ToInt32(obj));
        }
Example #2
0
        /// <summary>
        /// 修改 (可能有其他业务逻辑检查)
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public ResultInfo Update(FeeHR model)
        {
            ResultInfo ri = new ResultInfo();

            if (Edit(model))
            {
                ri.Ok  = true;
                ri.Msg = "修改成功";
            }

            return(ri);
        }
Example #3
0
        /// <summary>
        /// 保存 (可能有其他业务逻辑检查)
        /// </summary>
        /// <param name="model">实体</param>
        /// <returns></returns>
        public ResultInfo Create(FeeHR model, SqlTransaction tran)
        {
            ResultInfo ri = new ResultInfo();

            if (model == null)
            {
                return(ri);
            }

            int result = Add(model, tran);

            if (result > 0)
            {
                ri.Ok  = true;
                ri.Msg = "添加成功";
            }

            return(ri);
        }
Example #4
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public bool Update(FeeHR model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update FeeHR set ");
            strSql.Append("MainID=@MainID,UserID=@UserID,FeeTime=@FeeTime,FeeType=@FeeType,FeeCoin=@FeeCoin,FeeCoinType=@FeeCoinType,IsDelete=@IsDelete");

            strSql.Append(" where FeeHRID=@FeeHRID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@MainID",      model.MainID),
                new SqlParameter("@UserID",      model.UserID),
                new SqlParameter("@FeeTime",     model.FeeTime),
                new SqlParameter("@FeeType",     model.FeeType),
                new SqlParameter("@FeeCoin",     model.FeeCoin),
                new SqlParameter("@FeeCoinType", model.FeeCoinType),
                new SqlParameter("@IsDelete",    model.IsDelete),

                new SqlParameter("@FeeHRID",     model.FeeHRID)
            };

            return(SqlHelper.ExecuteSql(strSql.ToString(), CommandType.Text, parameters) > 0);
        }
Example #5
0
 /// <summary>
 /// 修改一条记录
 /// </summary>
 /// <param name="model">实体对象</param>
 /// <returns></returns>
 public bool Edit(FeeHR model)
 {
     return(dal.Update(model));
 }
Example #6
0
 /// <summary>
 /// 添加一条记录,没有任何逻辑
 /// </summary>
 /// <param name="model">实体对象</param>
 /// <returns></returns>
 public int Add(FeeHR model, SqlTransaction tran)
 {
     return(dal.Add(model, tran));
 }
        public ActionResult Fee(int id = 0, int type = 1)
        {
            ResultInfo <string> ri = new ResultInfo <string>();

            if (IsLogin)
            {
                if (id > 0)
                {
                    string contact = string.Empty;
                    string keyType = string.Empty;
                    if (type == 1)
                    {
                        ZhaoPin model = ZhaoPinBLL.Instance.GetModel(id);
                        keyType = "FeeHRZhaoPinValue";
                        contact = model.Contact;
                    }
                    else if (type == 2)
                    {
                        keyType = "FeeHRQiuZhiValue";
                        QiuZhi model = QiuZhiBLL.Instance.GetModel(id);
                        contact = model.Contact;
                        ri.Url  = model.JianLiPic;
                    }
                    else
                    {
                        keyType = "FeeHRProductValue";
                        Product model = ProductBLL.Instance.GetModel(id);
                        contact = model.Contact;
                    }

                    BeginTran();

                    int value    = Convert.ToInt32(ConfigHelper.AppSettings(keyType));
                    int cointype = 2;

                    //判断有无足够vip分
                    if (UserExtBLL.Instance.HasEnoughCoin(cointype, value, UserID))
                    {
                        //扣除相应分数
                        if (UserExtBLL.Instance.SubScore(UserID, value, cointype, Tran))
                        {
                            //记录流水
                            if (ScoreCoinLogBLL.Instance.Log(-value, cointype, CoinSourceEnum.SeeZhaoPinInfo, UserID, UserInfo.UserName, Tran))
                            {
                                //记录答案表
                                FeeHR fee = new FeeHR()
                                {
                                    FeeTime     = DateTime.Now,
                                    FeeType     = type,
                                    IsDelete    = 0,
                                    MainID      = id,
                                    UserID      = UserID,
                                    FeeCoin     = value,
                                    FeeCoinType = cointype
                                };
                                int result = FeeHRBLL.Instance.Add(fee, Tran);
                                if (result > 0)
                                {
                                    ri.Ok   = true;
                                    ri.Data = contact;
                                    Commit();
                                }
                                else
                                {
                                    RollBack();
                                    ri.Msg = "消费失败";
                                }
                            }
                            else
                            {
                                RollBack();
                                ri.Msg = "消费失败";
                            }
                        }
                        else
                        {
                            RollBack();
                            ri.Msg = "消费失败";
                        }
                    }
                    else
                    {
                        ri.Msg = "VIP分不足,请前往个人中心充值";
                    }
                }
                else
                {
                    ri.Msg = "信息不存在";
                }
            }
            else
            {
                ri.Msg = "请先登录";
                ri.Url = "/Account/Login";
            }
            return(Result(ri));
        }