public static DataProviderResultModel GetUserDebitRecords(int userId) { DataBaseOperator dbo = null; DataProviderResultModel result = new DataProviderResultModel(); List <DebitInfoModel> infos = new List <DebitInfoModel>(); try { //限制返回记录条数。 dbo = new DataBaseOperator(); ParamCollections pc = new ParamCollections(); string sqlStr = @"select debitId,userId, debitMoney,ifnull(partMoney,0) partMoney, Status, date_format(createTime, '%Y-%m-%d') createTime, description,ifnull(overdueMoney, 0) overdueMoney,ifnull(overdueDay,0) overdueDay, bankId,date_format(releaseLoanTime, '%Y-%m-%d') releaseLoanTime,date_format(payBackDayTime, '%Y-%m-%d') payBackDayTime, certificate, date_format(statusTime, '%Y-%m-%d') statusTime, debitPeroid, payBackMoney,(select b.Description from IFUserAduitDebitRecord b where b.debitId = a.DebitId order by id desc limit 1) auditInfo, (select if(a.Status = 4, overdueDayInterest,b.interestRate)*a.DebitMoney from IFDebitStyle b where b.money = a.DebitMoney and b.period = a.DebitPeroid) dayInterset from IFUserDebitRecord a where userId = @iUserId order by DebitId desc limit 10;"; pc.Add("@iUserId", userId); DataTable dt = dbo.GetTable(sqlStr, pc.GetParams()); if (null != dt && dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { DebitInfoModel info = new DebitInfoModel(); info.userId = userId; int.TryParse(Convert.ToString(dt.Rows[i]["debitId"]), out info.debitId); int.TryParse(Convert.ToString(dt.Rows[i]["overdueDay"]), out info.overdueDay); float.TryParse(Convert.ToString(dt.Rows[i]["dayInterset"]), out info.dayInterset); float.TryParse(Convert.ToString(dt.Rows[i]["debitMoney"]), out info.debitMoney); float.TryParse(Convert.ToString(dt.Rows[i]["partMoney"]), out info.partMoney); float.TryParse(Convert.ToString(dt.Rows[i]["overdueMoney"]), out info.overdueMoney); int.TryParse(Convert.ToString(dt.Rows[i]["Status"]), out info.status); int.TryParse(Convert.ToString(dt.Rows[i]["bankId"]), out info.bankId); int.TryParse(Convert.ToString(dt.Rows[i]["debitPeroid"]), out info.debitPeroid); float.TryParse(Convert.ToString(dt.Rows[i]["payBackMoney"]), out info.payBackMoney); info.createTime = Convert.ToString(dt.Rows[i]["createTime"]); info.description = Convert.ToString(dt.Rows[i]["description"]); info.certificate = Convert.ToString(dt.Rows[i]["certificate"]); info.payBackMoney = info.payBackMoney + info.overdueMoney - info.partMoney; info.releaseLoanTime = Convert.ToString(dt.Rows[i]["releaseLoanTime"]); info.auditTime = Convert.ToString(dt.Rows[i]["statusTime"]); info.repaymentTime = Convert.ToString(dt.Rows[i]["payBackDayTime"]); info.auditInfo = Convert.ToString(dt.Rows[i]["auditInfo"]); infos.Add(info); } result.data = infos; } else { result.result = Result.SUCCESS; result.data = infos; } return(result); } catch (Exception ex) { result.result = MainErrorModels.DATABASE_REQUEST_ERROR; result.message = "The database logic error.The function is DebitProvider::GetUserDebitRecords"; Log.WriteErrorLog("DebitProvider::GetUserDebitRecords", "获取失败:{0},异常:{1}", userId, ex.Message); } finally { if (null != dbo) { dbo.Close(); dbo = null; } } return(result); }
///设置贷款记录的状态 public static bool SetDebitRecordStatus(int debitId, int status, string auditMsg) { DataBaseOperator dbo = null; IDbTransaction tran = null; IDbConnection conn = null; try { dbo = new DataBaseOperator(); conn = dbo.GetConnection(); string sqlStr = String.Empty; ParamCollections pc = new ParamCollections(); if (status == 1) { sqlStr = "update IFUserDebitRecord set status = @iStatus,StatusTime = now(),releaseLoanTime=now(),payBackDayTime=date_add(now(),interval 7 day) where debitId = @iDebitId"; pc.Add("@iStatus", status); pc.Add("@iDebitId", debitId); Log.WriteDebugLog("BusinesssDao::SetDebitRecordStatus", "放款成功,{0} - {1}", debitId, status); } else { sqlStr = "update IFUserDebitRecord set status = @iStatus,StatusTime = now() where debitId = @iDebitId"; pc.Add("@iStatus", status); pc.Add("@iDebitId", debitId); Log.WriteDebugLog("BusinesssDao::SetDebitRecordStatus", "设置状态,{0} - {1}", debitId, status); } tran = dbo.BeginTransaction(conn); int ret = dbo.ExecuteStatement(sqlStr, pc.GetParams(true), conn); Log.WriteDebugLog("BusinesssDao::SetDebitRecordStatus", "执行成功({0}){1} - {2}", ret, debitId, status); Log.WriteDebugLog("BusinesssDao::SetDebitRecordStatus", "准备插入描述 {0} - {1} {2}", debitId, status, auditMsg); sqlStr = @"insert into IFUserAduitDebitRecord(AduitType,debitId,status,description,adminId,auditTime) values(@iAuditType, @iDebitId, @iAuditStatus, @sMsg, -1, now());" ; pc.Add("@iAuditType", "5"); pc.Add("@iDebitId", debitId); pc.Add("@iAuditStatus", status); pc.Add("@sMsg", auditMsg); ret = dbo.ExecuteStatement(sqlStr, pc.GetParams(true), conn); Log.WriteDebugLog("BusinesssDao::SetDebitRecordStatus", "执行成功({0}){1} - {2}", ret, debitId, status); if (status == 1) { string releaseLogSql = @"insert into IFUserDebitPaybackTimeChange(debitId, changeDays, afterTime, changeType, remarks,createTime,adminId,objectId) values(@iDebitId, @iChangeDays, date_add(now(),interval 7 day), @iChangeType, @sRemarks, now(), @iAdminId, @iObjectId);"; pc.Add("@iDebitId", debitId); pc.Add("@iChangeDays", 7); pc.Add("@iChangeType", 3); pc.Add("@sRemarks", auditMsg); pc.Add("@iAdminId", "-1"); pc.Add("@iObjectId", debitId); int dbret = dbo.ExecuteStatement(releaseLogSql, pc.GetParams(true), conn); Log.WriteDebugLog("BusinesssDao::SetDebitRecordStatus", "[{0}]插入贷款的还款时间变更记录 成功({1})。", debitId, dbret); } tran.Commit(); return(true); } catch (Exception ex) { Log.WriteErrorLog("BusinessDao::SetDebitRecordStatus", "出现异常{0}", ex.Message); } finally { if (null != dbo) { if (null != conn) { dbo.ReleaseConnection(conn); } dbo.Close(); dbo = null; } } if (null != tran) { tran.Rollback(); tran = null; } return(false); }