示例#1
0
        private void WithdrawOperate(Withdraw_Operate operate)
        {
            int id      = RequestHelper.GetQueryString <int>("ID");
            var _entity = WithdrawBLL.Read(id);

            if (_entity.Id <= 0)
            {
                ScriptHelper.Alert("记录不存在", RequestHelper.RawUrl);
            }
            if (_entity.Status != (int)Withdraw_Status.Apply)
            {
                ScriptHelper.Alert("当前状态不能执行此操作", RequestHelper.RawUrl);
            }
            #region 提现完成操作  判断分销商状态是否正常,剩余可提现额度是否满足本次提现
            if (operate == Withdraw_Operate.Pass)
            {
                distributor = UserBLL.Read(_entity.Distributor_Id);
                if (distributor.Distributor_Status != (int)Distributor_Status.Normal)
                {
                    ScriptHelper.Alert("当前分销商已冻结或待审核,不能执行此操作", RequestHelper.RawUrl);
                }
                if (distributor.Total_Commission - distributor.Total_Withdraw < 0)
                {
                    ScriptHelper.Alert("当前提现金额已超出分销商剩余提现额度,不能执行此操作", RequestHelper.RawUrl);
                }
            }
            #endregion
            if (WithdrawBLL.Operate(id, operate, Cookies.Admin.GetAdminID(false), Note.Text))
            {
                ScriptHelper.Alert("操作成功", RequestHelper.RawUrl);
            }
            else
            {
                ScriptHelper.Alert("操作失败", RequestHelper.RawUrl);
            }
        }
示例#2
0
        /// <summary>
        /// 操作:拒绝、完成(已返现)
        /// 拒绝操作:减少用户总提现
        /// 增加操作记录
        /// </summary>
        /// <param name="id"></param>
        /// <param name="operate"></param>
        public bool Operate(int id, Withdraw_Operate operate, int operator_Id, string note)
        {
            bool result = true;

            using (SqlConnection conn = new SqlConnection(connectString))
            {
                conn.Open();
                using (var transaction = conn.BeginTransaction())
                {
                    try
                    {
                        //改变【Withdraw】 申请状态
                        int    status = operate == Withdraw_Operate.Reject ? -1 : 2;
                        string sql    = @"UPDATE [Withdraw] SET [Status]=@Status WHERE [Id]=@Id AND [Status]=1";
                        int    row    = conn.Execute(sql, new { @Id = id, @Status = status }, transaction);
                        if (row > 0)
                        {
                            //记录此次操作
                            sql = @"INSERT INTO [Withdraw_Operate]([Withdraw_Id],[Operator_Id],[Operate],[Note],[Time]) VALUES(@Withdraw_Id,@Operator_Id,@Operate,@Note,@Time)";
                            row = conn.Execute(sql, new { @Withdraw_Id = id, @Operator_Id = operator_Id, @Operate = (int)operate, @Note = note, @Time = DateTime.Now }, transaction);
                            if (row > 0)
                            {
                                //如果是提现完成,则提交事务
                                if (status == 2)
                                {
                                    transaction.Commit();
                                }
                                else
                                {//如果拒绝提现,则减少用户总提现
                                 //获得提现记录 withdraw

                                    sql = @"SELECT * FROM [Withdraw] WHERE [Id]=@Id";
                                    var withdraw = conn.Query <WithdrawInfo>(sql, new { @Id = id }, transaction).SingleOrDefault();
                                    if (withdraw.Id > 0)
                                    {
                                        //计算分销商总提现
                                        sql = @"UPDATE [Usr] SET [Total_Withdraw]=[Total_Withdraw]-@Withdraw WHERE [Id]=@Distributor_Id";
                                        row = conn.Execute(sql, new { @Withdraw = withdraw.Amount, Distributor_Id = withdraw.Distributor_Id }, transaction);
                                        if (row > 0)
                                        {
                                            transaction.Commit();
                                        }
                                        else
                                        {
                                            result = false;
                                            transaction.Rollback();
                                        }
                                    }
                                    else
                                    {
                                        result = false;
                                        transaction.Rollback();
                                    }
                                }
                            }
                            else
                            {
                                result = false;
                                transaction.Rollback();
                            }
                        }
                        else
                        {
                            result = false;
                            transaction.Rollback();
                        }
                    }
                    catch (Exception ex)
                    {
                        result = false;
                        transaction.Rollback();
                    }
                }
            }
            return(result);
        }
示例#3
0
 //void Delete(int id);
 /// <summary>
 /// 管理员审核提现申请
 /// </summary>
 /// <param name="id"></param>
 /// <param name="operate">审核操作</param>
 /// <param name="operator_Id">管理员Id</param>
 public static bool Operate(int id, Withdraw_Operate operate, int operator_Id, string note)
 {
     return(dal.Operate(id, operate, operator_Id, note));
 }