/// <summary>
        /// 增加一条数据
        /// </summary>
        public void Add(Wuyiju.Model.DepositRecharge obj)
        {
            if (obj == null)
            {
                throw new ApplicationException("参数不能为空");
            }

            using (var db = new DataContext())
            {
                var _dao = this.GetDao(db);
                _dao.Insert(obj);
            }
        }
        public void Recharge(Wuyiju.Model.DepositRecharge obj)
        {
            if (obj == null)
            {
                throw new ApplicationException("参数不能为空");
            }

            if (obj.Huimoney <= 0)
            {
                throw new ApplicationException("充值金额有误");
            }


            if (obj.Pay_Type == RechargeType.BankHui)
            {
            }

            using (var db = new DataContext())
            {
                var userSvr     = unity.GetInstance <IUserDAL>(db);
                var rechargeSvr = unity.GetInstance <IDepositRechargeDAL>(db);

                var user = userSvr.Get(obj.User_Id);

                var now = DateTime.Now;
                obj.Sn        = string.Format("{0:yyMMdd}{1:d10}", now, rechargeSvr.GetMaxId() + 1);
                obj.Add_Time  = now.ToUnixTimestamp();
                obj.Total_Fee = obj.Huimoney;
                obj.Status    = 0;

                db.BeginTransaction();
                try
                {
                    rechargeSvr.Insert(obj);
                    user.Frozen_Money += obj.Huimoney;
                    userSvr.Update(user);
                    db.Commit();
                }
                catch (Exception ex)
                {
                    db.Rollback();
                    throw new ApplicationException("充值出现异常:" + ex.Message);
                }
            }
        }
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Modify(Wuyiju.Model.DepositRecharge obj)
        {
            if (obj == null)
            {
                throw new ApplicationException("参数不能为空");
            }

            var old = dao.Get(obj.Id);

            if (old == null)
            {
                throw new ApplicationException("非法操作记录不存在");
            }

            using (var db = new DataContext())
            {
                var _dao = this.GetDao(db);
                _dao.Update(obj);
            }
        }
Example #4
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(Wuyiju.Model.DepositRecharge model)
        {
            StringBuilder sql = new StringBuilder();

            sql.Append("update ec_deposit_recharge set ");

            sql.Append(" sn = @sn , ");
            sql.Append(" pay_type = @pay_type , ");
            sql.Append(" status = @status , ");
            sql.Append(" user_id = @user_id , ");
            sql.Append(" add_time = @add_time , ");
            sql.Append(" pay_time = @pay_time , ");
            sql.Append(" total_fee = @total_fee , ");
            sql.Append(" pay_fee = @pay_fee , ");
            sql.Append(" trade_no = @trade_no , ");
            sql.Append(" txt = @txt , ");
            sql.Append(" shoukCard = @shoukCard , ");
            sql.Append(" huiBank = @huiBank , ");
            sql.Append(" huiMoney = @huiMoney , ");
            sql.Append(" huiTime = @huiTime , ");
            sql.Append(" huiUser = @huiUser , ");
            sql.Append(" huiFile = @huiFile , ");
            sql.Append(" huiRemark = @huiRemark , ");
            sql.Append(" user_name = @user_name  ");
            sql.Append(" where id=@id ");

            DynamicParameters param = new DynamicParameters();

            if (model != null)
            {
                param.AddDynamicParams(model);
            }

            var rows = db.Execute(sql, param);

            if (rows < 1)
            {
                throw new ApplicationException("更新数据无效");
            }
        }
Example #5
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public void Insert(Wuyiju.Model.DepositRecharge model)
        {
            StringBuilder sql = new StringBuilder();

            sql.Append("insert into ec_deposit_recharge(");
            sql.Append("sn,pay_type,status,user_id,add_time,pay_time,total_fee,pay_fee,trade_no,txt,shoukCard,huiBank,huiMoney,huiTime,huiUser,huiFile,huiRemark,user_name");
            sql.Append(") values (");
            sql.Append("@sn,@pay_type,@status,@user_id,@add_time,@pay_time,@total_fee,@pay_fee,@trade_no,@txt,@shoukCard,@huiBank,@huiMoney,@huiTime,@huiUser,@huiFile,@huiRemark,@user_name");
            sql.Append(") ");

            DynamicParameters param = new DynamicParameters();

            if (model != null)
            {
                param.AddDynamicParams(model);
            }

            var rows = db.Execute(sql, param);

            if (rows < 1)
            {
                throw new ApplicationException("插入数据无效");
            }
        }