/// <summary>
        /// 新增余额
        /// </summary>
        /// <param name="balance"></param>
        /// <param name="message"></param>
        /// <returns></returns>
        public static bool AddBalance(decimal balance, int accountId, out string message)
        {
            message = "";
            bool retFlag= false;  //返回结果
            Base_t_AccountInfo bai= new Base_t_AccountInfo();

            AccountDataSourceDataContext adsdc = new AccountDataSourceDataContext();

            bai = adsdc.Base_t_AccountInfo.FirstOrDefault(p=>p.id == accountId);

            if(bai == null)
            {
                retFlag = false;
                message = "不存在该账户信息; accountId:"+accountId.ToString();
            }
            else
            {
                try
                {
                    bai.balance = bai.balance + balance;
                    adsdc.SubmitChanges();
                    retFlag = true;
                    message = "新增余额成功";
                }
                catch(Exception ex)
                {
                    message = ex.Message;
                    retFlag = false;
                }
            }

            return retFlag;
        }
        /// <summary>
        /// 审核待审核记录
        /// </summary>
        /// <param name="auditId"></param>
        /// <returns></returns>
        public static bool AuditOperBalanceInfo(int auditId, string operUserId,bool status, out string message)
        {
            message = "";
            bool retFlag = false;
            using (AccountDataSourceDataContext adsdc = new AccountDataSourceDataContext())
            {
                DbTransaction tran = adsdc.Connection.BeginTransaction();
                Base_t_AccountAuditInfo baai = new Base_t_AccountAuditInfo();
                Base_t_AccountInfo bai = new Base_t_AccountInfo();

                baai = adsdc.Base_t_AccountAuditInfo.FirstOrDefault(p => p.id == auditId);
                try
                {
                    //审核待审核记录
                    if (baai != null)
                    {
                        //如果流水记如存在,则根据流水记录中的账户ID取账户信息
                        bai = adsdc.Base_t_AccountInfo.FirstOrDefault(p => p.id == baai.accountId);

                        baai.status = true;
                        baai.opUser = operUserId;
                        baai.opTime = DateTime.Now;
                        adsdc.SubmitChanges();
                        retFlag = true;
                    }

                    //审核成功,插入操作记录到流水记录表
                    if (retFlag)
                    {
                        string mess = "";
                        Base_t_AccountDetailEntity bade = new Base_t_AccountDetailEntity();
                        PublicFunction.ObjectCopyTo(baai, bade);

                        //自动赋值后,处理各别不同的属性值
                        bade.Id = 0;
                        bade.Orderid = baai.refId;
                        bade.Resume = baai.direction;
                        bade.UseBalance = (decimal)baai.opBalance;
                        if (baai.type == 0)
                            bade.EndBalance = (decimal)bai.balance + (decimal)baai.opBalance;
                        else
                            bade.EndBalance = (decimal)bai.balance - (decimal)baai.opBalance;

                        InsertOperBalanceInfo(bade, out mess);
                        message = mess;
                    }
                    tran.Commit();
                }
                catch(Exception ex)
                {
                    tran.Rollback();
                    message = ex.Message;
                    retFlag = false;
                }
            }
            return retFlag;
        }
 partial void DeleteBase_t_AccountInfo(Base_t_AccountInfo instance);
 partial void UpdateBase_t_AccountInfo(Base_t_AccountInfo instance);
 partial void InsertBase_t_AccountInfo(Base_t_AccountInfo instance);
        /// <summary>
        /// 更新账户信息
        /// </summary>
        /// <param name="baie"></param>
        /// <param name="message"></param>
        /// <returns></returns>
        public static bool UpdateAccountInfo(Base_t_AccountInfoEntity baie, out string message)
        {
            message = "";
            bool retFlag = false;
            Base_t_AccountInfo bai = new Base_t_AccountInfo();

            //转换实体
            if(baie != null)
                PublicFunction.ObjectCopyTo(baie, bai);

            AccountDataSourceDataContext adsdc = new AccountDataSourceDataContext();

            try
            {
                adsdc.SubmitChanges();
                message = "更新成功";
                retFlag = true;
            }
            catch(Exception ex)
            {
                message = ex.Message;
                retFlag = false;
            }

            return retFlag;
        }
        /// <summary>
        /// 解锁账户信息
        /// </summary>
        /// <param name="accountId">账户ID</param>
        /// <param name="mark">操作描述说明</param>
        /// <param name="operId">操作ID</param>
        /// <param name="subjecId">操作子系统编码</param>
        /// <param name="message">返回信息</param>
        /// <returns></returns>
        public static bool UnBlockAccountInfo(int accountId, string userCode, string userName, string operId, string mark, string subjecCode, out string message)
        {
            message = "";
            bool retFlag = false;
            using (AccountDataSourceDataContext adsdc = new AccountDataSourceDataContext())
            {
                Base_t_AccountInfo bai = new Base_t_AccountInfo();
                bai = adsdc.Base_t_AccountInfo.FirstOrDefault(p => p.id == accountId);
                if (bai != null)
                {
                    try
                    {
                        bai.status = 1;
                        adsdc.SubmitChanges();
                        retFlag = true;
                    }
                    catch (Exception ex)
                    {
                        message = ex.Message;
                        retFlag = false;
                    }
                }
                else
                {
                    message = "该账户不存在!";
                    retFlag = false;
                }

                //如果锁定成功,插入流水记录
                if (retFlag)
                {
                    Base_t_AccountDetailEntity bade = new Base_t_AccountDetailEntity();
                    bade.Type = 3;
                    bade.AccountId = accountId;
                    bade.OpTime = DateTime.Now;
                    bade.CustmerCode = userCode;
                    bade.CustmerName = userName;
                    bade.OpUser = operId;
                    bade.Resume = mark;
                    bade.SubjectCode = subjecCode;

                    //插入流水信息记录
                    InsertOperBalanceInfo(bade, out message);
                    retFlag = true;
                }

                return retFlag;
            }
        }
        /// <summary>
        ///  锁定账户余额
        /// </summary>
        /// <param name="accountId">账户ID</param>
        /// <param name="mark">操作描述说明</param>
        /// <param name="operId">操作ID</param>
        /// <param name="subjecId">操作子系统编码</param>
        /// <param name="balance">余额</param>
        /// <param name="message">反回信息</param>
        /// <returns></returns>
        public static bool UnBlockAccountBalance(int accountId, string operId, string mark, string subjecCode, decimal balance, out string message)
        {
            message = "";
            bool retFlag = false;
            using (AccountDataSourceDataContext adsdc = new AccountDataSourceDataContext())
            {
                DbTransaction tran = adsdc.Connection.BeginTransaction();
                Base_t_AccountInfo bai = new Base_t_AccountInfo();
                bai = adsdc.Base_t_AccountInfo.FirstOrDefault(p => p.id == accountId);
                if (bai != null)
                {
                    try
                    {
                        if (bai.blockBalance < balance)
                        {
                            message = "账户可解锁余额不足,请确定解锁金额是否超限";
                            retFlag = false;
                        }
                        else
                        {
                            bai.blockBalance = bai.blockBalance - balance;
                            adsdc.SubmitChanges();
                            retFlag = true;
                        }
                    }
                    catch (Exception ex)
                    {
                        message = ex.Message;
                        retFlag = false;
                    }
                }
                else
                {
                    message = "该账户不存在!";
                    retFlag = false;
                }

                //如果锁定成功,插入流水记录
                if (retFlag)
                {
                    try
                    {
                        Base_t_AccountAuditInfoEntity baaie = new Base_t_AccountAuditInfoEntity();

                        baaie.CreateTime = DateTime.Now;
                        baaie.CreateUser = operId;

                        baaie.Type = 1;
                        baaie.AccountId = accountId;
                        baaie.OpTime = DateTime.Now;
                        baaie.OpUser = operId;
                        baaie.Remark = mark;
                        baaie.SubjectCode = subjecCode;

                        //插入流水信息记录
                        InsertAuditOperBalanceInfo(baaie, out message);
                        retFlag = true;

                        tran.Commit();
                    }
                    catch (Exception ex)
                    {
                        tran.Rollback();
                        message = ex.Message;
                        retFlag = true;
                    }
                }

                return retFlag;
            }
        }
 /// <summary>
 /// 根据用户ID查询账户信息
 /// </summary>
 /// <param name="userId">用户ID</param>
 /// <returns></returns>
 public static Base_t_AccountInfoEntity SelectAccountInfoByUserId(string userId)
 {
     using (AccountDataSourceDataContext adsdc = new AccountDataSourceDataContext())
     {
         Base_t_AccountInfoEntity baie = new Base_t_AccountInfoEntity();
         Base_t_AccountInfo bai = new Base_t_AccountInfo();
         bai = adsdc.Base_t_AccountInfo.FirstOrDefault(p => p.userId == userId.Trim());
         if (bai != null)
         {
             PublicFunction.ObjectCopyTo(bai, baie);
         }
         else
             return null;
         return baie;
     }
 }
Beispiel #10
0
        /// <summary>
        /// 查询账户信息
        /// </summary>
        /// <param name="accountId"></param>
        /// <returns></returns>
        public static Base_t_AccountInfoEntity SelectAccountInfo(int accountId)
        {
            Base_t_AccountInfo bai = new Base_t_AccountInfo();
            Base_t_AccountInfoEntity baie = new Base_t_AccountInfoEntity();

            AccountDataSourceDataContext adsdc = new AccountDataSourceDataContext();

            bai = adsdc.Base_t_AccountInfo.FirstOrDefault(p => p.id == accountId);
            if (bai != null)
                PublicFunction.ObjectCopyTo(bai, baie);
            if (baie != null)
            {
                return baie;
            }

            return null;
        }
Beispiel #11
0
        /// <summary>
        /// 新增账户信息
        /// </summary>
        /// <param name="baie"></param>
        /// <param name="message"></param>
        /// <returns></returns>
        public static bool InsertAccountInfo(Base_t_AccountInfoEntity baie, out string accountId, out string message)
        {
            accountId = "";
            bool retFlag = false;

            Base_t_AccountInfo adbai = new Base_t_AccountInfo();

            if (baie == null)
            {
                message = "传入参数有误";
                return false;
            }
            //进行实体转换
            PublicFunction.ObjectCopyTo(baie, adbai);

            AccountDataSourceDataContext adsdc = new AccountDataSourceDataContext();
            try
            {
                if (adbai != null)
                {
                    adsdc.Base_t_AccountInfo.InsertOnSubmit(adbai);
                    adsdc.SubmitChanges();

                }
                retFlag = true;
                message = "新增账户信息成功";
                //返回账户ID
                accountId = adbai.id.ToString();
            }
            catch(Exception ex)
            {
                retFlag = false;
                message = ex.Message;
            }
            return retFlag;
        }