Example #1
0
        public static bool UpdateDebitSMSStatus(DebitRecord debitRecord)
        {
            DataBaseOperator dataBaseOperator = null;

            try
            {
                dataBaseOperator = new DataBaseOperator();
                ParamCollections paramCollections = new ParamCollections();

                string sqlStr = "update IFUserDebitRecord set smsSendTimes = @iSmsSendTimes where debitId = @iDebitId";
                paramCollections.Add("@iSmsSendTimes", debitRecord.smsSendTimes + 1);
                paramCollections.Add("@iDebitId", debitRecord.debitId);
                dataBaseOperator.ExecuteStatement(sqlStr, paramCollections.GetParams());
            }
            catch (Exception ex)
            {
                Log.WriteErrorLog("SMSSendDao::UpdateDebitSMSStatus", ex.Message);
            }
            finally
            {
                if (null != dataBaseOperator)
                {
                    dataBaseOperator.Close();
                    dataBaseOperator = null;
                }
            }
            return(true);
        }
    public static bool UpdateRedoUserPayBackRecordStatus(string orderId)
    {
        DataBaseOperator dbo = null;

        try
        {
            dbo = new DataBaseOperator();
            string           sqlStr = @"update IFUserPayBackDebitRecord set statusTime=now(),retryTimes=ifnull(retryTimes,0)+1 where id=@iOrderId";
            ParamCollections pc     = new ParamCollections();
            pc.Add("@iOrderId", orderId);
            dbo.ExecuteStatement(sqlStr, pc.GetParams());
            return(true);
        }
        catch (Exception ex)
        {
            Log.WriteErrorLog("BusinessDao::UpdateUserPayBackRecordStatus", ex.Message);
        }
        finally
        {
            if (null != dbo)
            {
                dbo.Close();
                dbo = null;
            }
        }
        return(false);
    }
Example #3
0
        public static DataProviderResultModel SetDuitkuCallbackRecordStatus(string guid, int status)
        {
            DataProviderResultModel result = new DataProviderResultModel();
            DataBaseOperator        dbo    = null;

            try
            {
                dbo = new DataBaseOperator();
                ParamCollections pc     = new ParamCollections();
                string           sqlStr = @"update IFDuitkuCallbackLogs set status = @iStatus,statusTime = now() where guid = @sGuid";

                pc.Add("@iStatus", status);
                pc.Add("@sGuid", guid);

                result.data   = dbo.ExecuteStatement(sqlStr, pc.GetParams());
                result.result = Result.SUCCESS;
            }
            catch (Exception ex)
            {
                result.result  = Result.ERROR;
                result.message = ex.Message;
                Log.WriteErrorLog("DuitkuProvider::SetDuitkuCallbackRecordStatus", "{0}", ex.Message);
            }
            finally
            {
                if (null != dbo)
                {
                    dbo.Close();
                    dbo = null;
                }
            }
            return(result);
        }
Example #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="debitMoney"></param>
        /// <param name="debitPeroid"></param>
        /// <param name="bankId"></param>
        /// <param name="description"></param>
        /// <returns></returns>
        public static DataProviderResultModel SubmitDebitReuqestV2(int userId, float debitMoney, int debitPeroid, int bankId, string description, string deviceId)
        {
            DataBaseOperator        dbo    = null;
            DataProviderResultModel result = new DataProviderResultModel();

            try
            {
                dbo = new DataBaseOperator();
                ParamCollections pc = new ParamCollections();
                pc.Add("@iUserId", userId);
                pc.Add("@dDebitMoney", debitMoney);
                pc.Add("@iDebitPeroid", debitPeroid);
                pc.Add("@iBankId", bankId);
                pc.Add("@sDescription", description);
                pc.Add("@sDeviceId", deviceId);

                Hashtable table = new Hashtable();
                DataTable dt    = dbo.ExecProcedure("p_debit_submitrequest_v2", pc.GetParams(), out table);
                if (null != dt && dt.Rows.Count == 1)
                {
                    int.TryParse(Convert.ToString(dt.Rows[0][0]), out result.result);

                    if (result.result < 0)
                    {
                        result.message = Convert.ToString(dt.Rows[0][1]);
                        result.data    = new { debitRecordId = -1 };
                        Log.WriteErrorLog("DebitProvider::SubmitDebitReuqest", "提交申请失败:{0}|{1}|{2}|{3}|{4},结果是:{5}", userId, debitMoney, debitPeroid, bankId, description, dt.Rows[0][1]);
                    }
                    else
                    {
                        result.result = Result.SUCCESS;
                        ///记录ID
                        result.data = new { debitRecordId = Convert.ToString(dt.Rows[0][2]) };
                    }
                }
                else
                {
                    result.result  = MainErrorModels.LOGIC_ERROR;
                    result.message = "error from the submit debit request.";
                }
                return(result);
            }
            catch (Exception ex)
            {
                result.result  = MainErrorModels.DATABASE_REQUEST_ERROR;
                result.message = "The database logic error.The function is SubmitDebitReuqest";
                Log.WriteErrorLog("DebitProvider::GetUserBankInfo", "获取失败:{0},异常:{1}", userId, ex.Message);
            }
            finally
            {
                if (null != dbo)
                {
                    dbo.Close();
                    dbo = null;
                }
            }
            return(result);
        }
Example #5
0
        public static DataProviderResultModel GetUserDebitRecordLogs(int debitId)
        {
            DataBaseOperator        dbo    = null;
            DataProviderResultModel result = new DataProviderResultModel();

            try
            {
                dbo = new DataBaseOperator();
                ParamCollections pc     = new ParamCollections();
                string           sqlStr = @"select changeType, remarks, createTime, afterTime 
                from IFUserDebitPaybackTimeChange where debitId = @iDebitId order by id;";
                pc.Add("@iDebitId", debitId);

                DataTable dt = dbo.GetTable(sqlStr, pc.GetParams());

                List <DebitRecordLogModel> list = new List <DebitRecordLogModel>();
                if (null != dt && dt.Rows.Count > 0)
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        DebitRecordLogModel log = new DebitRecordLogModel();
                        log.description = Convert.ToString(dt.Rows[i]["remarks"]);
                        int iTmp = 0;
                        int.TryParse(Convert.ToString(dt.Rows[i]["changeType"]), out iTmp);
                        log.changeType = iTmp;

                        log.changeTime = Convert.ToString(dt.Rows[i]["createTime"]);
                        log.afterTime  = Convert.ToString(dt.Rows[i]["afterTime"]);

                        list.Add(log);
                    }
                    result.result = Result.SUCCESS;
                    result.data   = list;
                }
                else
                {
                    result.result = Result.SUCCESS;
                    result.data   = list;
                }
                return(result);
            }
            catch (Exception ex)
            {
                result.result  = MainErrorModels.DATABASE_REQUEST_ERROR;
                result.message = "The database logic error.The function is DebitProvider::GetUserDebitRecordLogs";
                Log.WriteErrorLog("v2::DebitProvider::GetUserDebitRecordLogs", "获取失败:{0},异常:{1}", debitId, ex.Message);
            }
            finally
            {
                if (null != dbo)
                {
                    dbo.Close();
                    dbo = null;
                }
            }
            return(result);
        }
Example #6
0
        // GET: Audit
        public ActionResult DebitRecords(string userId, int status, string beginTime, string endTime)
        {
            var package = new ExcelPackage();

            var worksheet = package.Workbook.Worksheets.Add("DebitRecords");

            DataBaseOperator dbo    = null;
            string           result = String.Empty;

            try
            {
                if (String.IsNullOrEmpty(beginTime) || String.IsNullOrEmpty(endTime))
                {
                    beginTime = DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd");
                    endTime   = DateTime.Now.ToString("yyyy-MM-dd");
                }
                dbo = new DataBaseOperator();
                string sqlStr = String.Format(@"select debitId,userId, debitMoney, Status, createTime, description, bankId
, certificate, debitPeroid, payBackMoney,(select b.Description from IFUserAduitDebitRecord b where b.debitId = a.DebitId) 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 a.createTime >='{0}' and a.createTime < '{1}' ", beginTime, endTime);

                ParamCollections pc = new ParamCollections();
                if (!String.IsNullOrEmpty(userId))
                {
                    sqlStr += " and a.userId = @iUserId";
                    pc.Add("@iUserId", userId);
                }

                if (status != -1)
                {
                    sqlStr += " and a.status = @iStatus";
                    pc.Add("@iStatus", status);
                }
                DataTable dt = dbo.GetTable(sqlStr, pc.GetParams());

                ViewData["data"] = dt;

                ViewData["beginTime"] = beginTime;
                ViewData["endTime"]   = endTime;
                ViewData["userId"]    = userId;
            }
            catch (Exception ex)
            {
                Log.WriteErrorLog("AuditController::DebitRecords", ex.Message);
            }
            finally
            {
                if (null != dbo)
                {
                    dbo.Close();
                    dbo = null;
                }
            }

            return(View());
        }
    ///
    /// 获取待自动放款的记录
    ///
    public static List <DebitUserRecord> GetReadyReleaseDebitRecords()
    {
        DataBaseOperator       dbo  = null;
        List <DebitUserRecord> list = new List <DebitUserRecord>();

        try
        {
            dbo = new DataBaseOperator();
            string           sqlStr = @"select debitId,b.BNICode,b.BankCode, b.BankName, b.userId,b.ContactName,a.actualMoney,ifnull(a.target,'A') target
                    from IFUserDebitRecord a,IFUserBankInfo b where a.status = @iStatus and a.audit_step = @iStep and 
                    a.bankId = b.bankId and b.BNICode is not null and b.BNICode != '' limit 10";
            ParamCollections pc     = new ParamCollections();
            pc.Add("@iStatus", 5);
            pc.Add("@iStep", 3);

            DataTable dt = dbo.GetTable(sqlStr, pc.GetParams());
            if (null != dt && dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    DebitUserRecord record = new DebitUserRecord();
                    int             tmp    = 0;
                    int.TryParse(Convert.ToString(dt.Rows[i]["userId"]), out tmp);
                    record.userId = tmp;

                    record.userName = Convert.ToString(dt.Rows[i]["contactName"]);
                    float ftmp = 0f;
                    float.TryParse(Convert.ToString(dt.Rows[i]["actualMoney"]), out ftmp);
                    record.amountTransfer = ftmp;

                    int.TryParse(Convert.ToString(dt.Rows[i]["debitId"]), out tmp);
                    record.debitId = tmp;

                    record.bankCode    = Convert.ToString(dt.Rows[i]["BNICode"]);
                    record.target      = Convert.ToString(dt.Rows[i]["target"]);
                    record.bankAccount = Convert.ToString(dt.Rows[i]["BankCode"]);
                    record.purpose     = "auto release loan.Rp" + record.amountTransfer;
                    list.Add(record);
                }
            }
        }
        catch (Exception ex)
        {
            Log.WriteErrorLog("BusinessDao::GetReadyReleaseDebitRecords", ex.Message);
        }
        finally
        {
            if (null != dbo)
            {
                dbo.Close();
                dbo = null;
            }
        }
        return(list);
    }
Example #8
0
        public static DataProviderResultModel GetUserQuestions(UserInfoRequestBody userInfo)
        {
            DataProviderResultModel result = new DataProviderResultModel();
            DataBaseOperator        dbo    = null;

            try
            {
                dbo = new DataBaseOperator();
                ParamCollections pc     = new ParamCollections();
                string           sqlStr = "select id,userId, content, url, feedback, adminId, createTime, replyTime from IFUserQuestions where userId = @iUserId";

                pc.Add("@iUserId", userInfo.userId);
                DataTable            dt   = dbo.GetTable(sqlStr, pc.GetParams(true));
                List <UserQuestions> list = new List <UserQuestions>();
                if (null != dt)
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        UserQuestions questions = new UserQuestions();
                        questions.userId     = Convert.ToString(dt.Rows[i]["userId"]);
                        questions.id         = Convert.ToString(dt.Rows[i]["id"]);
                        questions.content    = Convert.ToString(dt.Rows[i]["content"]);
                        questions.feedback   = Convert.ToString(dt.Rows[i]["feedback"]);
                        questions.createTime = Convert.ToString(dt.Rows[i]["createTime"]);
                        questions.replyTime  = Convert.ToString(dt.Rows[i]["replyTime"]);
                        questions.url        = Convert.ToString(dt.Rows[i]["url"]);
                        list.Add(questions);
                    }
                    result.data   = list;
                    result.result = Result.SUCCESS;
                }
                else
                {
                    result.result  = Result.ERROR;
                    result.message = "The database logic error.Return data is null";
                }
            }
            catch (Exception ex)
            {
                result.result  = MainErrorModels.DATABASE_REQUEST_ERROR;
                result.message = "The database logic error.";
                Log.WriteErrorLog("v2::MineProvider::GetUserQuestions", "Error:{0}, {1}", JsonConvert.SerializeObject(userInfo), ex.Message);
            }
            finally
            {
                if (null != dbo)
                {
                    dbo.Close();
                    dbo = null;
                }
            }
            return(result);
        }
Example #9
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="debitMoney"></param>
        /// <param name="debitPeroid"></param>
        /// <returns></returns>
        public static DataProviderResultModel GetInterestRateByDebitStyle(float debitMoney, int debitPeriod)
        {
            DataBaseOperator        dbo    = null;
            DataProviderResultModel result = new DataProviderResultModel();

            try
            {
                dbo = new DataBaseOperator();
                ParamCollections pc     = new ParamCollections();
                string           sqlStr = "select interestRate,overdueDayInterest from IFDebitStyle where money = @dDebitMoney and period = @iDebitPeriod;";
                pc.Add("@dDebitMoney", debitMoney);
                pc.Add("@iDebitPeriod", debitPeriod);

                Hashtable table = new Hashtable();
                DataRow   rates = dbo.GetRow(sqlStr, pc.GetParams());
                if (null != rates)
                {
                    result.result = Result.SUCCESS;
                    float rate        = 0f;
                    float overdueRate = 0f;
                    float.TryParse(Convert.ToString(rates[0]), out rate);
                    float.TryParse(Convert.ToString(rates[1]), out overdueRate);
                    result.data = new List <float> {
                        rate, overdueRate
                    };
                }
                else
                {
                    result.result  = MainErrorModels.NO_SUCH_DEBIT_COMBINATION;
                    result.message = "There is no such combination.";
                }

                return(result);
            }
            catch (Exception ex)
            {
                result.result  = MainErrorModels.DATABASE_REQUEST_ERROR;
                result.message = "The database logic error.";
                Log.WriteErrorLog("DebitProvider::GetUserBankInfo", "获取失败:{0},{1},异常:{2}", debitMoney, debitPeriod, ex.Message);
            }
            finally
            {
                if (null != dbo)
                {
                    dbo.Close();
                    dbo = null;
                }
            }
            return(result);
        }
Example #10
0
        public static List <DebitRecord> GetDebitRecords()
        {
            DataBaseOperator   dataBaseOperator = null;
            List <DebitRecord> list             = new List <DebitRecord>();

            try
            {
                dataBaseOperator = new DataBaseOperator();
                ParamCollections paramCollections = new ParamCollections();

                string sqlStr = @"select * from (
select debitId,b.Phone,datediff(date_format(payBackDayTime, '%Y-%m-%d'),date_format(now(), '%Y-%m-%d')) overdueDay,payBackMoney,ifnull(smsSendTimes,0) smsSendTimes 
from IFUserDebitRecord a,IFUsers b where a.userId = b.userId and a.status =@iStatus and ifnull(a.smsSendTimes,0) < @iSmsSendTimes) as tab where overdueDay < @iOverdueDay;";
                paramCollections.Add("@iStatus", 1);
                paramCollections.Add("@iSmsSendTimes", 3);
                paramCollections.Add("@iOverdueDay", 3);
                DataTable dt = dataBaseOperator.GetTable(sqlStr, paramCollections.GetParams());

                if (null != dt)
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        DebitRecord debit = new DebitRecord();
                        int         itmp  = 0;
                        int.TryParse(Convert.ToString(dt.Rows[i]["debitId"]), out itmp);
                        debit.debitId = itmp;

                        int.TryParse(Convert.ToString(dt.Rows[i]["overdueDay"]), out itmp);
                        debit.overdueDay = itmp;

                        int.TryParse(Convert.ToString(dt.Rows[i]["smsSendTimes"]), out itmp);
                        debit.smsSendTimes = itmp;

                        debit.phone = Convert.ToString(dt.Rows[i]["phone"]);

                        debit.money = Convert.ToString(dt.Rows[i]["payBackMoney"]);
                        list.Add(debit);
                    }
                }
            }
            catch (Exception ex)
            {
                Log.WriteErrorLog("SMSSendDao::GetDebitRecords", ex.Message);
            }
            return(list);
        }
        public static DataProviderResultModel GetBankCodes()
        {
            DataBaseOperator        dbo    = null;
            List <BankCode>         infos  = new List <BankCode>();
            DataProviderResultModel result = new DataProviderResultModel();

            try
            {
                dbo = new DataBaseOperator();
                ParamCollections pc     = new ParamCollections();
                string           sqlStr = @"select bankCode,bankName from IFBanksCode where status = 1 order by bankName";
                DataTable        dt     = dbo.GetTable(sqlStr, pc.GetParams());

                if (null != dt && dt.Rows.Count > 0)
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        BankCode info = new BankCode();
                        info.bankCode = Convert.ToString(dt.Rows[i]["bankCode"]);
                        info.bankName = Convert.ToString(dt.Rows[i]["bankName"]);

                        infos.Add(info);
                    }
                }

                result.result = Result.SUCCESS;
                result.data   = infos;
                return(result);
            }
            catch (Exception ex)
            {
                result.result  = Result.ERROR;
                result.message = "The database logic error.The function is MainInfoProvider::GetBankCodes";
                Log.WriteErrorLog("MainInfoProvider::GetBankCodes", "获取失败,异常:{0}", ex.Message);
            }
            finally
            {
                if (null != dbo)
                {
                    dbo.Close();
                    dbo = null;
                }
            }
            return(result);
        }
        public static DataProviderResultModel GetNotices()
        {
            DataBaseOperator        dbo    = null;
            List <NoticeModel>      infos  = new List <NoticeModel>();
            DataProviderResultModel result = new DataProviderResultModel();

            try
            {
                dbo = new DataBaseOperator();
                ParamCollections pc     = new ParamCollections();
                string           sqlStr = @"select title,content from IFNotice where startTime < now() and endTime > now() order by id desc";
                DataTable        dt     = dbo.GetTable(sqlStr, pc.GetParams());

                if (null != dt && dt.Rows.Count > 0)
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        NoticeModel info = new NoticeModel();
                        info.content = Convert.ToString(dt.Rows[i]["content"]);
                        info.title   = Convert.ToString(dt.Rows[i]["title"]);

                        infos.Add(info);
                    }
                }

                result.result = Result.SUCCESS;
                result.data   = infos;
                return(result);
            }
            catch (Exception ex)
            {
                result.result  = Result.ERROR;
                result.message = "The database logic error.The function is MainInfoProvider::GetNotices";
                Log.WriteErrorLog("MainInfoProvider::GetNotices", "获取失败,异常:{0}", ex.Message);
            }
            finally
            {
                if (null != dbo)
                {
                    dbo.Close();
                    dbo = null;
                }
            }
            return(result);
        }
Example #13
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="debitId"></param>
        /// <param name="payBackDebitMoney"></param>
        /// <param name="certificateUrl"></param>
        /// <returns></returns>
        public static DataProviderResultModel PayBackDebitRequest(int userId, int debitId, float payBackDebitMoney, string certificateUrl)
        {
            DataBaseOperator        dbo    = null;
            DataProviderResultModel result = new DataProviderResultModel();
            List <DebitInfoModel>   infos  = new List <DebitInfoModel>();

            try
            {
                dbo = new DataBaseOperator();
                ParamCollections pc = new ParamCollections();
                pc.Add("@iUserId", userId);
                pc.Add("@iDebitId", debitId);
                pc.Add("@dPayBackDebitMoney", payBackDebitMoney);
                pc.Add("@sCertificateUrl", certificateUrl);

                Hashtable table = new Hashtable();
                DataTable dt    = dbo.ExecProcedure("p_debit_paybackrequest", pc.GetParams(), out table);
                if (null != dt && dt.Rows.Count == 1)
                {
                    int.TryParse(Convert.ToString(dt.Rows[0][0]), out result.result);
                    result.message = Convert.ToString(dt.Rows[0][1]);
                }
                else
                {
                    result.result  = MainErrorModels.LOGIC_ERROR;
                    result.message = "error from the submit payback debit request.";
                }
                return(result);
            }
            catch (Exception ex)
            {
                Log.WriteErrorLog("DebitProvider::PayBackDebitRequest", "获取失败:{0}|{1},异常:{2}", userId, ex.Message);
            }
            finally
            {
                if (null != dbo)
                {
                    dbo.Close();
                    dbo = null;
                }
            }
            return(result);
        }
Example #14
0
        public static DataProviderResultModel PostUserQuestions(QuestionsRequestBody requestBody)
        {
            DataProviderResultModel result = new DataProviderResultModel();
            DataBaseOperator        dbo    = null;

            try
            {
                dbo = new DataBaseOperator();
                ParamCollections pc     = new ParamCollections();
                string           sqlStr = @"insert into IFUserQuestions(userId, content, url, feedback, createTime)
                        values(@iUserId, @sContent, @sUrl, '', now());";

                pc.Add("@iUserId", requestBody.userId);
                pc.Add("@sContent", requestBody.content);
                pc.Add("@sUrl", requestBody.url);
                int dbret = dbo.ExecuteStatement(sqlStr, pc.GetParams(true));
                if (dbret > 0)
                {
                    result.result = Result.SUCCESS;
                }
                else
                {
                    result.result  = Result.ERROR;
                    result.message = "The database logic error.Return data is null";
                }
            }
            catch (Exception ex)
            {
                result.result  = MainErrorModels.DATABASE_REQUEST_ERROR;
                result.message = "The database logic error.";
                Log.WriteErrorLog("v2::MineProvider::PostUserQuestions", "Error:{0}, {1}", JsonConvert.SerializeObject(requestBody), ex.Message);
            }
            finally
            {
                if (null != dbo)
                {
                    dbo.Close();
                    dbo = null;
                }
            }
            return(result);
        }
Example #15
0
        public static PayBackDebitModel GetDebitPayBackRecord(int userId, int debitId)
        {
            DataBaseOperator  dbo  = null;
            PayBackDebitModel info = new PayBackDebitModel();

            try
            {
                dbo = new DataBaseOperator();
                ParamCollections pc     = new ParamCollections();
                string           sqlStr = @"select userId,PayBackDebitMoney,status,createtime,statusTime,certificateUrl,debitId 
                        from IFUserPayBackDebitRecord where userId = @iUserId and debitId = @iDebitId;";
                pc.Add("@iUserId", userId);
                pc.Add("@iDebitId", debitId);

                DataTable dt = dbo.GetTable(sqlStr, pc.GetParams());

                if (null != dt && dt.Rows.Count > 0)
                {
                    float.TryParse(Convert.ToString(dt.Rows[0]["payBackDebitMoney"]), out info.payBackDebitMoney);
                    int.TryParse(Convert.ToString(dt.Rows[0]["Status"]), out info.status);
                    info.userId         = userId;
                    info.debitId        = debitId;
                    info.certificateUrl = Convert.ToString(dt.Rows[0]["certificateUrl"]);
                    info.statusTime     = Convert.ToString(dt.Rows[0]["statusTime"]);
                }
                return(info);
            }
            catch (Exception ex)
            {
                Log.WriteErrorLog("DebitProvider::GetDebitPayBackRecord", "获取失败:{0}|{1},异常:{2}", userId, ex.Message);
            }
            finally
            {
                if (null != dbo)
                {
                    dbo.Close();
                    dbo = null;
                }
            }
            return(info);
        }
        public static List <SelectionModel> GetSelection()
        {
            DataBaseOperator      dbo   = null;
            List <SelectionModel> infos = new List <SelectionModel>();

            try
            {
                dbo = new DataBaseOperator();
                ParamCollections pc     = new ParamCollections();
                string           sqlStr = @"select selectName,selectValue,selectType from IFSelection where status = @iStatus order by selectType, orderIndex desc";
                pc.Add("@iStatus", 1);
                DataTable dt = dbo.GetTable(sqlStr, pc.GetParams());

                if (null != dt && dt.Rows.Count > 0)
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        SelectionModel info = new SelectionModel();
                        info.selectText = Convert.ToString(dt.Rows[i]["selectName"]);
                        int.TryParse(Convert.ToString(dt.Rows[i]["selectValue"]), out info.selectValue);
                        info.selectType = Convert.ToString(dt.Rows[i]["selectType"]);
                        infos.Add(info);
                    }
                }
                return(infos);
            }
            catch (Exception ex)
            {
                Log.WriteErrorLog("MainInfoProvider::GetSelection", "获取失败,异常:{0}", ex.Message);
            }
            finally
            {
                if (null != dbo)
                {
                    dbo.Close();
                    dbo = null;
                }
            }
            return(infos);
        }
Example #17
0
        public static DataProviderResultModel GetDailyExtendReport(string dateId)
        {
            DataBaseOperator        dbo    = null;
            DataProviderResultModel result = new DataProviderResultModel();
            List <DebitInfoModel>   infos  = new List <DebitInfoModel>();

            try
            {
                dbo = new DataBaseOperator();
                ParamCollections pc     = new ParamCollections();
                string           sqlStr = @"select a.debitId,b.ContactName,date_format(releaseLoanTime,'%Y-%m-%d'),round(fee,0) fee1, round(actualMoney,0)
                        ,round(fee,0) fee2,alreadyReturnInterest, returnInterest, alreadyReturnMoney,alreadyReturnInterest + returnInterest + alreadyReturnMoney,userPaybackTime
                    from IFUserDebitRecord a,IFUserBankInfo b,IFUserPayBackDebitRecord c
                    where c.statusTime >= @dDate1 and c.statusTime < date_add(@dDate2, interval 1 day) 
                    and a.debitId = c.DebitId and c.Status = 1 and c.type = 2
                    and a.userId = b.userId and a.status in (-2,1,2,3,4,6) and (alreadyReturnInterest + returnInterest + alreadyReturnMoney) > 0";
                pc.Add("@dDate1", dateId);
                pc.Add("@dDate2", dateId);

                DataTable dt = dbo.GetTable(sqlStr, pc.GetParams());

                result.data = dt;
            }
            catch (Exception ex)
            {
                result.result  = MainErrorModels.DATABASE_REQUEST_ERROR;
                result.message = "The database logic error.The function is ReportProvider::GetDailyExtendReport";
                Log.WriteErrorLog("ReportProvider::GetDailyExtendReport", "获取失败:{0},异常:{1}", dateId, ex.Message);
            }
            finally
            {
                if (null != dbo)
                {
                    dbo.Close();
                    dbo = null;
                }
            }
            return(result);
        }
Example #18
0
        public static DataProviderResultModel GetUserBankId(int userId)
        {
            DataBaseOperator        dbo    = null;
            DataProviderResultModel result = new DataProviderResultModel();

            try
            {
                dbo = new DataBaseOperator();
                ParamCollections pc = new ParamCollections();
                pc.Add("@iUserId", userId);
                string    sqlStr = "select bankId from IFUserBankInfo where userId = @iUserId order by updateTime desc limit 1";
                DataTable dt     = dbo.GetTable(sqlStr, pc.GetParams(true));
                if (null != dt && dt.Rows.Count == 1)
                {
                    result.data = dt.Rows[0][0];
                }
                else
                {
                    result.result  = MainErrorModels.LOGIC_ERROR;
                    result.message = "The bankInfo is empty.";
                }
                return(result);
            }
            catch (Exception ex)
            {
                result.result  = MainErrorModels.DATABASE_REQUEST_ERROR;
                result.message = "The database logic error.The function is GetUserBankId";
                Log.WriteErrorLog("DebitProvider::GetUserBankId", "获取失败:{0},异常:{1}", userId, ex.Message);
            }
            finally
            {
                if (null != dbo)
                {
                    dbo.Close();
                    dbo = null;
                }
            }
            return(result);
        }
Example #19
0
    public static SortedList <string, string> GetNeedCheckDebitRecords()
    {
        DataBaseOperator            dbo  = null;
        SortedList <string, string> list = new SortedList <string, string>();

        try
        {
            dbo = new DataBaseOperator();
            string           sqlStr = @"select id,ifnull(b.target,'A') target from IFUserPayBackDebitRecord a,IFUserDebitRecord b
                where a.type in (3,4) and a.status = -2 and ifnull(a.reTryTimes,0) < 3 
				and a.debitId = b.debitId
                and a.createTime < date_add(now(), interval -30 minute) 
                and a.createTime > '2018-09-13 22:00:00' order by a.reTryTimes limit 10";
            ParamCollections pc     = new ParamCollections();

            DataTable dt = dbo.GetTable(sqlStr, pc.GetParams());
            if (null != dt && dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    list.Add(Convert.ToString(dt.Rows[i]["id"]), Convert.ToString(dt.Rows[i]["target"]));
                }
            }
        }
        catch (Exception ex)
        {
            Log.WriteErrorLog("BusinessDao::GetNeedCheckDebitRecords", ex.Message);
        }
        finally
        {
            if (null != dbo)
            {
                dbo.Close();
                dbo = null;
            }
        }
        return(list);
    }
Example #20
0
        public static DataProviderResultModel SetDuitkuPaybackRecordStaus(CallbackRequestModel request)
        {
            DataBaseOperator dbo  = null;
            IDbConnection    conn = null;
            IDbTransaction   tran = null;
            int dbret             = -1;

            DataProviderResultModel result = new DataProviderResultModel();

            try
            {
                dbo = new DataBaseOperator();

                string           sqlStr = "select debitId,type,userId from IFUserPayBackDebitRecord where id = @iId and status = @iStatus";
                ParamCollections pc     = new ParamCollections();
                pc.Add("@iId", request.merchantOrderId);
                pc.Add("@iStatus", -2);

                Log.WriteDebugLog("DuitkuProvider::SetDuitkuPaybackRecordStaus", "[{0}]查询还款记录表的数据,用户、还款类型、贷款记录ID。", request.merchantOrderId);

                DataTable paybackInfo = dbo.GetTable(sqlStr, pc.GetParams(true));
                if (null != paybackInfo && paybackInfo.Rows.Count == 1)
                {
                    string debitId = Convert.ToString(paybackInfo.Rows[0]["debitId"]);
                    string type    = Convert.ToString(paybackInfo.Rows[0]["type"]);
                    string userId  = Convert.ToString(paybackInfo.Rows[0]["userId"]);

                    Log.WriteDebugLog("DuitkuProvider::SetDuitkuPaybackRecordStaus", "[{0}]查询到还款记录,用户:{1}、还款类型:{2}、贷款记录ID:{3}。"
                                      , request.merchantOrderId, userId, type, debitId);

                    Log.WriteDebugLog("DuitkuProvider::SetDuitkuPaybackRecordStaus", "[{0}]开始更新还款记录表的状态", request.merchantOrderId);

                    conn = dbo.GetConnection();
                    tran = dbo.BeginTransaction(conn);

                    sqlStr = @"update IFUserPayBackDebitRecord set status = @iStatus1,statusTime = now(),money=@fMoney 
                    where id = @iId and status = @iStatus2";
                    pc.Add("@iStatus1", 1);
                    pc.Add("@fMoney", request.amount);
                    pc.Add("@iId", request.merchantOrderId);
                    pc.Add("@iStatus2", -2);
                    result.data = dbo.ExecuteStatement(sqlStr, pc.GetParams(true), conn);

                    Log.WriteDebugLog("DuitkuProvider::SetDuitkuPaybackRecordStaus", "[{0}]更新还款记录表的状态,结果为:{1}", request.merchantOrderId, result.data);

                    sqlStr = @"select date_format(now(),'%Y-%m-%d') now,date_format(payBackDayTime,'%Y-%m-%d') payBackDayTime 
                            from IFUserDebitRecord where debitId = @iDebitId";

                    pc.Add("@iDebitId", debitId);
                    DataTable debitInfo = dbo.GetTable(sqlStr, pc.GetParams(true));
                    if (null != debitInfo && debitInfo.Rows.Count == 1)
                    {
                        Log.WriteDebugLog("DuitkuProvider::SetDuitkuPaybackRecordStaus", "[{0}]查询到用户应还时间{1}"
                                          , request.merchantOrderId, debitInfo.Rows[0]["payBackDayTime"]);

                        string extendLogSql = String.Empty;
                        //tran = conn.BeginTransaction();
                        ///3 - 延期;4 - 还款
                        if (type == "3")
                        {
                            //如果还款日期大于当前日期,延期后的时间是从还款时间+7天(相当于提前延期)。
                            //如果还款日期小于当前日期,延期时间是从当天+7天。
                            DateTime now     = DateTime.Now;
                            DateTime payback = DateTime.Now;

                            DateTime.TryParse(Convert.ToString(debitInfo.Rows[0]["payBackDayTime"]), out payback);
                            DateTime.TryParse(Convert.ToString(debitInfo.Rows[0]["now"]), out now);

                            DataProviderResultModel extendResult = DebitProvider.GetUserExtendRecord(Convert.ToInt32(debitId));
                            if (extendResult.result == Result.SUCCESS)
                            {
                                DebitExtendModel extendInfo   = extendResult.data as DebitExtendModel;
                                float            amoutMoney   = 0f;
                                float            needPayMoney = 0f;

                                float.TryParse(request.amount, out amoutMoney);
                                needPayMoney = (float)Math.Round(extendInfo.extendFee + extendInfo.overdueMoney - extendInfo.partMoney, 0);
                                amoutMoney   = (float)Math.Round(amoutMoney, 0);
                                Log.WriteDebugLog("DuitkuProvider::SetDuitkuPaybackRecordStaus", "[{0}]核对应还金额 needPayMoney:{1} - amoutMoney:{2}", request.merchantOrderId, needPayMoney, amoutMoney);
                                if (amoutMoney >= (extendInfo.extendFee - extendInfo.partMoney))
                                {
                                    #region 全额延期逻辑
                                    //如果存在逾期,全额支付后需清算逾期
                                    if (extendInfo.overdueMoney > 0 && amoutMoney >= needPayMoney)
                                    {
                                        Log.WriteDebugLog("DuitkuProvider::SetDuitkuPaybackRecordStaus", "逾期费用:{0},开始清算。", extendInfo.overdueMoney);
                                        sqlStr = @"update IFUserDebitOverdueRecord set clearStatus=@iClearStatus,clearTime=now(),clearSource=@iClearSource 
                                            where debitId=@iDebitId";
                                        pc.Add("@iClearStatus", 1);
                                        pc.Add("@iClearSource", 2);
                                        pc.Add("@iDebitId", debitId);

                                        dbret = dbo.ExecuteStatement(sqlStr, pc.GetParams(true), conn);
                                        Log.WriteDebugLog("DuitkuProvider::SetDuitkuPaybackRecordStaus", "[{0}][{1}]清算逾期费用 成功({2})。", request.merchantOrderId, debitId, dbret);

                                        Log.WriteDebugLog("DuitkuProvider::SetDuitkuPaybackRecordStaus", "[{0}]金额大于最小延期费,系统自动审核。用户[{1}]。", request.merchantOrderId, extendInfo.userId);
                                        Log.WriteDebugLog("DuitkuProvider::SetDuitkuPaybackRecordStaus", "[{0}]更新贷款记录表状态及最后还款时间。", request.merchantOrderId);
                                        TimeSpan ts = payback.Subtract(now);

                                        if (ts.Days >= 0)
                                        {
                                            sqlStr = @"update IFUserDebitRecord set status = @iStatus,paybackdayTime=date_add(paybackdayTime, interval 7 day)
                                            ,statusTime = now(),partMoney=@fPartMoney,overdueMoney = 0,overdueDay = 0
                                        where debitId = @iDebitId";
                                        }
                                        else
                                        {
                                            sqlStr = @"update IFUserDebitRecord set status = @iStatus,paybackdayTime=date_add(now(), interval 7 day)
                                        ,statusTime = now(),partMoney=@fPartMoney,overdueMoney = 0,overdueDay = 0
                                        where debitId = @iDebitId";
                                        }

                                        pc.Add("@iStatus", 1);
                                        //如果多还了,就暂存到部份还款字段。
                                        if (amoutMoney - needPayMoney > 0)
                                        {
                                            pc.Add("@fPartMoney", amoutMoney - needPayMoney);
                                        }
                                        else
                                        {
                                            pc.Add("@fPartMoney", 0);
                                        }
                                        pc.Add("@iDebitId", debitId);
                                        dbret = dbo.ExecuteStatement(sqlStr, pc.GetParams(true), conn);
                                        Log.WriteDebugLog("DuitkuProvider::SetDuitkuPaybackRecordStaus", "[{0}]更新贷款记录表状态及最后还款时间 成功({1})。", request.merchantOrderId, dbret);

                                        //插日志
                                        extendLogSql = @"insert into IFUserDebitPaybackTimeChange(debitId, beforTime, changeDays, afterTime,
                                                                                                     changeType, remarks,createTime,adminId,objectId)
                                                                                    values(@iDebitId, @dBeforTime, @iChangeDays, @dAfterTime, 
                                                                                                    @iChangeType, @sRemarks, now(), @iAdminId, @iObjectId);";
                                        pc.Add("@iDebitId", debitId);
                                        pc.Add("@dBeforTime", payback.ToString("yyyy-MM-dd"));
                                        pc.Add("@iChangeDays", ts.Days >= 0 ? ts.Days + 7 : 7 + (ts.Days * -1));
                                        pc.Add("@dAfterTime", ts.Days >= 0 ? payback.AddDays(7).ToString("yyyy-MM-dd") : now.AddDays(7).ToString("yyyy-MM-dd"));
                                        pc.Add("@iChangeType", 4);
                                        pc.Add("@sRemarks", "Proses perpanjangan disetujui(10001).");
                                        pc.Add("@iAdminId", "-1");
                                        pc.Add("@iObjectId", request.merchantOrderId);

                                        dbret = dbo.ExecuteStatement(extendLogSql, pc.GetParams(true), conn);
                                        Log.WriteDebugLog("DuitkuProvider::SetDuitkuPaybackRecordStaus", "[{0}] 插入贷款的还款时间变更记录 成功({1})。", request.merchantOrderId, dbret);
                                    }
                                    else
                                    {
                                        //如果只还了最小的延期费,则不清算逾期费
                                        Log.WriteDebugLog("DuitkuProvider::SetDuitkuPaybackRecordStaus", "[{0}]金额大于最小延期费,系统自动审核。用户[{1}]。", request.merchantOrderId, extendInfo.userId);
                                        Log.WriteDebugLog("DuitkuProvider::SetDuitkuPaybackRecordStaus", "[{0}]更新贷款记录表状态及最后还款时间,因为没有支付逾期费,所以。", request.merchantOrderId);
                                        sqlStr = @"update IFUserDebitRecord set status = @iStatus,paybackdayTime=date_add(paybackdayTime, interval 7 day)
                                            ,statusTime = now(),partMoney=@fPartMoney
                                        where debitId = @iDebitId";

                                        pc.Add("@iStatus", 1);
                                        //如果多还了,就暂存到部份还款字段。
                                        if (amoutMoney - (extendInfo.extendFee - extendInfo.partMoney) > 0)
                                        {
                                            pc.Add("@fPartMoney", amoutMoney - (extendInfo.extendFee - extendInfo.partMoney));
                                        }
                                        else
                                        {
                                            pc.Add("@fPartMoney", 0);
                                        }
                                        pc.Add("@iDebitId", debitId);
                                        dbret = dbo.ExecuteStatement(sqlStr, pc.GetParams(true), conn);

                                        Log.WriteDebugLog("DuitkuProvider::SetDuitkuPaybackRecordStaus", "[{0}]更新贷款记录表状态及最后还款时间 成功({1})。", request.merchantOrderId, dbret);

                                        extendLogSql = @"insert into IFUserDebitPaybackTimeChange(debitId, beforTime, changeDays, afterTime,
                                                                                                     changeType, remarks,createTime,adminId,objectId)
                                                                                    values(@iDebitId, @dBeforTime, @iChangeDays, @dAfterTime, 
                                                                                                    @iChangeType, @sRemarks, now(), @iAdminId, @iObjectId);";
                                        pc.Add("@iDebitId", debitId);
                                        pc.Add("@dBeforTime", payback.ToString("yyyy-MM-dd"));
                                        pc.Add("@iChangeDays", 7);
                                        pc.Add("@dAfterTime", payback.AddDays(7).ToString("yyyy-MM-dd"));
                                        pc.Add("@iChangeType", 4);
                                        pc.Add("@sRemarks", "Proses perpanjangan disetujui(10002).");
                                        pc.Add("@iAdminId", "-1");
                                        pc.Add("@iObjectId", request.merchantOrderId);

                                        dbret = dbo.ExecuteStatement(extendLogSql, pc.GetParams(true), conn);
                                        Log.WriteDebugLog("DuitkuProvider::SetDuitkuPaybackRecordStaus", "[{0}]插入贷款的还款时间变更记录 成功({1})。", request.merchantOrderId, dbret);
                                    }
                                    Log.WriteDebugLog("DuitkuProvider::SetDuitkuPaybackRecordStaus", "[{0}]开始插入审核记录。", request.merchantOrderId);

                                    sqlStr = @"insert into IFUserAduitDebitRecord(AduitType,debitId,status,description,adminId,auditTime)
	                                    values(@iAuditType, @iDebitId, @iAuditStatus, @sAuditDescription, @iUserId, now());"    ;

                                    pc.Add("@iAuditType", 2);
                                    pc.Add("@iDebitId", debitId);
                                    pc.Add("@iAuditStatus", 1);
                                    pc.Add("@sAuditDescription", "Proses perpanjangan disetujui(10002).");
                                    pc.Add("@iUserId", -1);

                                    dbret = dbo.ExecuteStatement(sqlStr, pc.GetParams(true), conn);
                                    Log.WriteDebugLog("DuitkuProvider::SetDuitkuPaybackRecordStaus", "[{0}]插入审核记录 成功({1})。", request.merchantOrderId, dbret);
                                    #endregion
                                }
                                else
                                {
                                    #region 部份延期逻辑
                                    Log.WriteDebugLog("DuitkuProvider::SetDuitkuPaybackRecordStaus", "[{0}]金额对不上,将已还计入部份还款。", request.merchantOrderId);
                                    Log.WriteDebugLog("DuitkuProvider::SetDuitkuPaybackRecordStaus", "[{0}]应支付:{1},收到用户支付:{2},差额:{3},历史支付:{4}。"
                                                      , request.merchantOrderId, needPayMoney, amoutMoney, needPayMoney - amoutMoney, extendInfo.partMoney);

                                    sqlStr = @"update IFUserPayBackDebitRecord set status = @iStatus1,statusTime = now(),money=@fMoney 
                                        where id = @iId";
                                    pc.Add("@iStatus1", 1);
                                    pc.Add("@fMoney", request.amount);
                                    pc.Add("@iId", request.merchantOrderId);
                                    result.data = dbo.ExecuteStatement(sqlStr, pc.GetParams(true), conn);

                                    sqlStr = @"update IFUserDebitRecord set status = if(date_format(payBackDayTime,'%Y-%m-%d') < date_format(now(),'%Y-%m-%d'), 4, 1)
                                            ,partMoney=ifnull(partMoney,0)+@fMoney,statusTime = now() 
                                        where debitId = @iDebitId";

                                    pc.Add("@fMoney", request.amount);
                                    pc.Add("@iDebitId", debitId);
                                    dbret = dbo.ExecuteStatement(sqlStr, pc.GetParams(true), conn);

                                    //取,如果延期成功,下一次还款时间
                                    sqlStr = @"SELECT if(convert(date_format(payBackDayTime,'%Y%m%d'), signed) >= 
                                        convert(date_format(now(),'%Y%m%d'),signed), date_format(date_add(payBackDayTime, interval 7 day),'%Y-%m-%d')
                                        , date_format(date_add(now(), interval 7 day),'%Y-%m-%d')
                                        ) extendNextPayback FROM IFUserDebitRecord where debitId = @iDebitId;";
                                    pc.Add("@iDebitId", debitId);
                                    object extendNextPayback = dbo.GetScalar(sqlStr, pc.GetParams(true));

                                    sqlStr = @"insert into IFUserAduitDebitRecord(AduitType,debitId,status,description,adminId,auditTime)
	                            values(@iAuditType, @iDebitId, @iAuditStatus, @sAuditDescription, @iUserId, now());"    ;
                                    //还款所需金额 = 贷款金额 + 逾期费 - 本次支付 - 历史支付金额
                                    float needPaybackMoney = extendInfo.debitMoney + extendInfo.overdueMoney - amoutMoney - extendInfo.partMoney;
                                    //已支付Rp100.000,还款还需要支付Rp140.000,延期到2018-09-21还需要支付Rp400.000
                                    //Sudah bayar 100 harus d bayarkan 1.400.000 sepenuhnya dibayar dan untuk diperpanjang sampai 21 -09- 2018 harus bayar 400.000
                                    string desc = String.Format("Sudah bayar {0} harus dibayarkan {1} sepenuhnya dan untuk diperpanjang sampai {2} harus bayar {3}.\r\nJika ada pertanyaan silakan hubungi:\r\n0813 1682 3995\r\n0813 8366 2454."
                                                                , amoutMoney.ToString("N0").Replace(",", "."), needPaybackMoney.ToString("N0").Replace(",", "."), extendNextPayback, (needPayMoney - amoutMoney).ToString("N0").Replace(",", "."));
                                    pc.Add("@iAuditType", 2);
                                    pc.Add("@iDebitId", debitId);
                                    pc.Add("@iAuditStatus", 1);
                                    pc.Add("@sAuditDescription", desc);//延期申请(审核中)
                                    pc.Add("@iUserId", -1);
                                    dbret = dbo.ExecuteStatement(sqlStr, pc.GetParams(true), conn);
                                    Log.WriteDebugLog("DuitkuProvider::SetDuitkuPaybackRecordStaus", "[{0}]插入审核记录 成功({1})。", request.merchantOrderId, dbret);

                                    extendLogSql = @"insert into IFUserDebitPaybackTimeChange(debitId, changeDays,
                                                                                                     changeType, remarks,createTime,adminId,objectId)
                                                                                    values(@iDebitId, @iChangeDays, 
                                                                                                    @iChangeType, @sRemarks, now(), @iAdminId, @iObjectId);";
                                    pc.Add("@iDebitId", debitId);
                                    pc.Add("@iChangeDays", 0);
                                    pc.Add("@iChangeType", -1);
                                    pc.Add("@sRemarks", desc);
                                    pc.Add("@iAdminId", "-1");
                                    pc.Add("@iObjectId", request.merchantOrderId);

                                    dbret = dbo.ExecuteStatement(extendLogSql, pc.GetParams(true), conn);
                                    Log.WriteDebugLog("DuitkuProvider::SetDuitkuPaybackRecordStaus", "[{0}]插入贷款的还款时间变更记录 成功({1})。", request.merchantOrderId, dbret);

                                    #endregion
                                }
                            }
                        }
                        if (type == "4")
                        {
                            DataProviderResultModel debitResult = DebitProvider.GetUserDebitRecord(Convert.ToInt32(debitId));
                            if (debitResult.result == Result.SUCCESS)
                            {
                                DebitInfoModel debitModel   = debitResult.data as DebitInfoModel;
                                float          amoutMoney   = 0f;
                                float          needPayMoney = 0f;

                                float.TryParse(request.amount, out amoutMoney);
                                needPayMoney = (float)Math.Round(debitModel.payBackMoney, 0);
                                amoutMoney   = (float)Math.Round(amoutMoney, 0);
                                Log.WriteDebugLog("DuitkuProvider::SetDuitkuPaybackRecordStaus", "[{0}]核对应还金额 needPayMoney:{1} - amoutMoney:{2}", request.merchantOrderId, needPayMoney, amoutMoney);
                                if (amoutMoney >= needPayMoney)
                                {
                                    #region 全额还款逻辑
                                    Log.WriteDebugLog("DuitkuProvider::SetDuitkuPaybackRecordStaus", "[{0}]金额对上,系统自动审核。用户[{1}]全额还款次数+1。", request.merchantOrderId, debitModel.userId);
                                    sqlStr = @"update IFUsers set fullPaymentTimes = ifnull(fullPaymentTimes,0) + 1 where userId = @iUserId";
                                    pc.Add("@iUserId", debitModel.userId);
                                    dbret = dbo.ExecuteStatement(sqlStr, pc.GetParams(true), conn);
                                    Log.WriteDebugLog("DuitkuProvider::SetDuitkuPaybackRecordStaus", "[{0}]更新用户全额还款次数成功({1})。", request.merchantOrderId, dbret);

                                    sqlStr = @"update IFUserDebitRecord set status = @iStatus,userPaybackTime=now(),statusTime = now(),
                                            partMoney=@fPartMoney,overdueMoney = 0,overdueDay = 0
                                            where debitId = @iDebitId";
                                    pc.Add("@iStatus", 3);
                                    //如果多还了,暂存到该字段。
                                    pc.Add("@fPartMoney", amoutMoney - needPayMoney);
                                    pc.Add("@iDebitId", debitId);
                                    dbret = dbo.ExecuteStatement(sqlStr, pc.GetParams(true), conn);

                                    //如果存在逾期,全额支付后需清算逾期
                                    if (debitModel.overdueMoney > 0)
                                    {
                                        Log.WriteDebugLog("DuitkuProvider::SetDuitkuPaybackRecordStaus", "[{0}]逾期费用:{1},开始清算。", request.merchantOrderId, debitModel.overdueMoney);
                                        sqlStr = @"update IFUserDebitOverdueRecord set clearStatus=@iClearStatus,clearTime=now(),clearSource=@iClearSource 
                                            where debitId=@iDebitId";
                                        pc.Add("@iClearStatus", 1);
                                        pc.Add("@iClearSource", 2);
                                        pc.Add("@iDebitId", debitId);

                                        dbret = dbo.ExecuteStatement(sqlStr, pc.GetParams(true), conn);
                                        Log.WriteDebugLog("DuitkuProvider::SetDuitkuPaybackRecordStaus", "[{0}][{1}]清算逾期费用 成功({2})。", request.merchantOrderId, debitId, dbret);
                                    }

                                    Log.WriteDebugLog("DuitkuProvider::SetDuitkuPaybackRecordStaus", "[{0}]更新贷款记录表状态及还款时间 成功({1})。", request.merchantOrderId, dbret);
                                    Log.WriteDebugLog("DuitkuProvider::SetDuitkuPaybackRecordStaus", "[{0}]开始插入审核记录。", request.merchantOrderId);

                                    sqlStr = @"insert into IFUserAduitDebitRecord(AduitType,debitId,status,description,adminId,auditTime)
	                            values(@iAuditType, @iDebitId, @iAuditStatus, @sAuditDescription, @iUserId, now());"    ;

                                    pc.Add("@iAuditType", 3);
                                    pc.Add("@iDebitId", debitId);
                                    pc.Add("@iAuditStatus", 3);
                                    pc.Add("@sAuditDescription", "Proses pembayaran disetujui(10002).");
                                    pc.Add("@iUserId", -1);

                                    dbret = dbo.ExecuteStatement(sqlStr, pc.GetParams(true), conn);

                                    Log.WriteDebugLog("DuitkuProvider::SetDuitkuPaybackRecordStaus", "[{0}]插入审核记录 成功({1})。", request.merchantOrderId, dbret);

                                    extendLogSql = @"insert into IFUserDebitPaybackTimeChange(debitId, changeDays,
                                                                                                     changeType, remarks,createTime,adminId,objectId)
                                                                                    values(@iDebitId, @iChangeDays, 
                                                                                                    @iChangeType, @sRemarks, now(), @iAdminId, @iObjectId);";
                                    pc.Add("@iDebitId", debitId);
                                    pc.Add("@iChangeDays", 0);
                                    pc.Add("@iChangeType", 6);
                                    pc.Add("@sRemarks", "Proses pembayaran disetujui(10002).");
                                    pc.Add("@iAdminId", "-1");
                                    pc.Add("@iObjectId", request.merchantOrderId);

                                    dbret = dbo.ExecuteStatement(extendLogSql, pc.GetParams(true), conn);
                                    Log.WriteDebugLog("DuitkuProvider::SetDuitkuPaybackRecordStaus", "[{0}]插入贷款的还款时间变更记录 成功({1})。", request.merchantOrderId, dbret);

                                    #endregion
                                }
                                else
                                {
                                    #region 部份还款逻辑
                                    Log.WriteDebugLog("DuitkuProvider::SetDuitkuPaybackRecordStaus", "[{0}]金额对不上,进入人工审核。", request.merchantOrderId);
                                    Log.WriteDebugLog("DuitkuProvider::SetDuitkuPaybackRecordStaus", "[{0}]应支付:{1},收到用户支付:{2},差额:{3},历史支付:{4}。"
                                                      , request.merchantOrderId, needPayMoney, amoutMoney, needPayMoney - amoutMoney, debitModel.partMoney);

                                    sqlStr = @"update IFUserPayBackDebitRecord set status = @iStatus1,statusTime = now(),money=@fMoney 
                                        where id = @iId";
                                    pc.Add("@iStatus1", 1);
                                    pc.Add("@fMoney", request.amount);
                                    pc.Add("@iId", request.merchantOrderId);
                                    result.data = dbo.ExecuteStatement(sqlStr, pc.GetParams(true), conn);

                                    //原来是什么状态,就更新为什么状态,将还款的钱更新到部份还款金额字段。
                                    sqlStr = @"update IFUserDebitRecord set status = if(payBackDayTime < now(), 4, 1)
                                                    ,partMoney=ifnull(partMoney,0)+@fMoney,statusTime = now() 
                                                where debitId = @iDebitId";
                                    //pc.Add("@iStatus", 1);
                                    pc.Add("@fMoney", request.amount);
                                    pc.Add("@iDebitId", debitId);
                                    dbret = dbo.ExecuteStatement(sqlStr, pc.GetParams(true), conn);

                                    Log.WriteDebugLog("DuitkuProvider::SetDuitkuPaybackRecordStaus", "[{0}]更新贷款记录表状态及还款时间 成功({1})。", request.merchantOrderId, dbret);
                                    Log.WriteDebugLog("DuitkuProvider::SetDuitkuPaybackRecordStaus", "[{0}]开始插入审核记录。", request.merchantOrderId);

                                    sqlStr = @"insert into IFUserAduitDebitRecord(AduitType,debitId,status,description,adminId,auditTime)
	                                    values(@iAuditType, @iDebitId, @iAuditStatus, @sAuditDescription, @iUserId, now());"    ;

                                    string desc = String.Format("Sudah membayar Rp {0}.\r\nuntuk pelunasan silakan bayarkan kembali sisanya sebesar Rp {1}.\r\nJika ada pertanyaan silakan hubungi:\r\n0813 1682 3995\r\n0813 8366 2454."
                                                                , amoutMoney.ToString("N0").Replace(",", "."), (debitModel.payBackMoney - amoutMoney).ToString("N0").Replace(",", "."));
                                    pc.Add("@iAuditType", 3);
                                    pc.Add("@iDebitId", debitId);
                                    pc.Add("@iAuditStatus", 1);
                                    pc.Add("@sAuditDescription", desc);
                                    pc.Add("@iUserId", -1);

                                    dbret = dbo.ExecuteStatement(sqlStr, pc.GetParams(true), conn);
                                    Log.WriteDebugLog("DuitkuProvider::SetDuitkuPaybackRecordStaus", "[{0}]插入审核记录 成功({1})。", request.merchantOrderId, dbret);


                                    extendLogSql = @"insert into IFUserDebitPaybackTimeChange(debitId, changeDays,
                                                                                                     changeType, remarks,createTime,adminId,objectId)
                                                                                    values(@iDebitId, @iChangeDays, 
                                                                                                    @iChangeType, @sRemarks, now(), @iAdminId, @iObjectId);";
                                    pc.Add("@iDebitId", debitId);
                                    pc.Add("@iChangeDays", 0);
                                    pc.Add("@iChangeType", 7);
                                    pc.Add("@sRemarks", desc);
                                    pc.Add("@iAdminId", "-1");
                                    pc.Add("@iObjectId", request.merchantOrderId);

                                    dbret = dbo.ExecuteStatement(extendLogSql, pc.GetParams(true), conn);
                                    Log.WriteDebugLog("DuitkuProvider::SetDuitkuPaybackRecordStaus", "[{0}]插入贷款的还款时间变更记录 成功({1})。", request.merchantOrderId, dbret);

                                    #endregion
                                }
                            }
                        }
                        result.result = Result.SUCCESS;
                        tran.Commit();
                    }
                    else
                    {
                        result.result = Result.ERROR;
                        Log.WriteErrorLog("DuitkuProvider::SetDuitkuPaybackRecordStaus", "[{0}]查找贷款ID失败,记录不存在。{1}", request.merchantOrderId, debitId);
                        tran.Rollback();
                    }
                }
                else
                {
                    result.result = Result.ERROR;
                    Log.WriteErrorLog("DuitkuProvider::SetDuitkuPaybackRecordStaus", "根据订单ID查找贷款ID失败,有可能该订单已处理。{0}", request.merchantOrderId);
                }
            }
            catch (Exception ex)
            {
                if (null != tran)
                {
                    tran.Rollback();
                }
                result.result  = Result.ERROR;
                result.message = ex.Message;
                Log.WriteErrorLog("DuitkuProvider::SetDuitkuPaybackRecordStaus", "{0} 订单在执行时发生异常: {1}", request.merchantOrderId, ex.Message);
            }
            finally
            {
                if (null != dbo)
                {
                    if (null != conn)
                    {
                        dbo.ReleaseConnection(conn);
                    }
                    dbo.Close();
                    dbo = null;
                }
            }
            return(result);
        }
Example #21
0
        public static DataProviderResultModel CreatePayBack(int userId, int debitId, string type, string merchantCode)
        {
            DataProviderResultModel result = new DataProviderResultModel();
            DataBaseOperator        dbo    = null;

            try
            {
                dbo = new DataBaseOperator();
                string           sqlStr = "select count(1) from IFUserPayBackDebitRecord where debitId = @iDebitId and status = @iStatus and type = @iType";
                ParamCollections pc     = new ParamCollections();
                pc.Add("@iDebitId", debitId);
                pc.Add("@iStatus", -2);
                pc.Add("@iType", type);

                int count = dbo.GetCount(sqlStr, pc.GetParams(true));
                if (count > 0)
                {
                    //重置状态。
                    sqlStr = @"update IFUserPayBackDebitRecord set createTime=now(),statusTime=now(),reTryTimes=0,merchantCode=@sMerchantCode
                        where debitId = @iDebitId and status = @iStatus and type = @iType";
                    pc.Add("@sMerchantCode", merchantCode);
                    pc.Add("@iDebitId", debitId);
                    pc.Add("@iStatus", -2);
                    pc.Add("@iType", type);
                    dbo.ExecuteStatement(sqlStr, pc.GetParams(true));

                    sqlStr = "select id from IFUserPayBackDebitRecord where debitId = @iDebitId and status = @iStatus and type = @iType";
                    pc.Add("@iDebitId", debitId);
                    pc.Add("@iStatus", -2);
                    pc.Add("@iType", type);

                    object obj = dbo.GetScalar(sqlStr, pc.GetParams(true));
                    result.data   = obj;
                    result.result = Result.SUCCESS;
                }
                else
                {
                    sqlStr = @"insert into IFUserPayBackDebitRecord(userId, status,createTime, type, debitId, merchantCode)
                                values(@iUserId, @iStatus,now(), @iType, @iDebitId,@sMerchantCode);";

                    pc.Add("@iUserId", userId);
                    pc.Add("@iStatus", -2);
                    pc.Add("@iType", type);
                    pc.Add("@iDebitId", debitId);
                    pc.Add("@sMerchantCode", merchantCode);
                    dbo.ExecuteStatement(sqlStr, pc.GetParams(true));

                    sqlStr = "select id from IFUserPayBackDebitRecord where debitId = @iDebitId and status = @iStatus and type = @iType order by id desc limit 1";
                    pc.Add("@iDebitId", debitId);
                    pc.Add("@iStatus", -2);
                    pc.Add("@iType", type);

                    object obj = dbo.GetScalar(sqlStr, pc.GetParams(true));
                    result.data   = obj;
                    result.result = Result.SUCCESS;
                }
            }
            catch (Exception ex)
            {
                result.result = Result.ERROR;
                Log.WriteErrorLog("DuitkuProvider::CreatePayBack", ex.Message);
            }
            finally
            {
                if (null != dbo)
                {
                    dbo.Close();
                    dbo = null;
                }
            }
            return(result);
        }
Example #22
0
        public static DataProviderResultModel SaveDuitkuCallbackRecord(CallbackRequestModel request)
        {
            DataProviderResultModel result = new DataProviderResultModel();
            DataBaseOperator        dbo    = null;
            IDbConnection           conn   = null;
            IDbTransaction          tran   = null;

            try
            {
                dbo  = new DataBaseOperator();
                conn = dbo.GetConnection();
                tran = dbo.BeginTransaction(conn);

                ParamCollections pc     = new ParamCollections();
                string           sqlStr = @"insert into IFDuitkuCallbackLogs(merchantCode,amount,merchantOrderId,productDetail,additionalParam,
                            merchantUserId,reference,signature,issuer_name,issuer_bank,createTime,guid)
                            values(@sMerchantCode,@sAmount,@sMerchantOrderId,@sProductDetail,@sAdditionalParam,
                            @sMerchantUserId,@sReference,@sSignature,@sIssuer_name,@sIssuer_bank,now(),@sGuid);";

                string guid = Guid.NewGuid().ToString();
                pc.Add("@sMerchantCode", request.merchantCode);
                pc.Add("@sAmount", request.amount);
                pc.Add("@sMerchantOrderId", request.merchantOrderId);
                pc.Add("@sProductDetail", request.productDetail);
                pc.Add("@sAdditionalParam", request.additionalParam);
                pc.Add("@sMerchantUserId", request.merchantUserId);
                pc.Add("@sReference", request.reference);
                pc.Add("@sSignature", request.signature);
                pc.Add("@sIssuer_name", request.issuer_name);
                pc.Add("@sIssuer_bank", request.issuer_bank);
                pc.Add("@sGuid", guid);

                dbo.ExecuteStatement(sqlStr, pc.GetParams());

                result.data   = guid;
                result.result = Result.SUCCESS;
            }
            catch (Exception ex)
            {
                if (null != tran)
                {
                    tran.Rollback();
                }
                result.result  = Result.ERROR;
                result.message = ex.Message;
                Log.WriteErrorLog("DuitkuProvider::SaveDuitkuCallbackRecord", "{0}", ex.Message);
            }
            finally
            {
                if (null != tran)
                {
                    tran.Commit();
                }
                if (null != dbo)
                {
                    if (null != conn)
                    {
                        dbo.ReleaseConnection(conn);
                    }
                    dbo.Close();
                    dbo = null;
                }
            }
            return(result);
        }
Example #23
0
    ///设置贷款记录的状态
    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);
    }
Example #24
0
        public static DataProviderResultModel GetUserDebitRecords(DebitRecordsRequestBody request)
        {
            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,
bankCode,bankName,contactName
                    from IFUserDebitRecord a where userId = @iUserId";

                pc.Add("@iUserId", request.userId);
                if (request.index > 0)
                {
                    sqlStr += " and a.debitId < @iDebitId";
                    pc.Add("@iDebitId", request.index);
                }

                // 申请成功的记录:
                if (request.status == 1)
                {
                    sqlStr += " and a.status in (1,2,3,4,6,-2) ";
                }
                // 申请失败的记录
                if (request.status == 2)
                {
                    sqlStr += " and a.status = -1 ";
                }
                // 申请中的记录
                if (request.status == 3)
                {
                    sqlStr += " and a.status in (0,5) ";
                }

                sqlStr += " order by DebitId desc limit 10";

                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 = request.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"]);
                        if (info.status == 3)
                        {
                            info.description = "Proses pembayaran disetujui(10003).";
                            info.auditInfo   = "Proses pembayaran disetujui(10003).";
                        }
                        else
                        {
                            info.auditInfo   = Convert.ToString(dt.Rows[i]["auditInfo"]);
                            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.bankCode        = Convert.ToString(dt.Rows[i]["bankCode"]);
                        info.bankName        = Convert.ToString(dt.Rows[i]["bankName"]);
                        info.bankUserName    = Convert.ToString(dt.Rows[i]["contactName"]);

                        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}", request.userId, ex.Message);
            }
            finally
            {
                if (null != dbo)
                {
                    dbo.Close();
                    dbo = null;
                }
            }
            return(result);
        }
Example #25
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="debitId"></param>
        /// <returns></returns>
        public static DataProviderResultModel GetUserExtendRecord(int debitId)
        {
            DataBaseOperator        dbo    = null;
            DataProviderResultModel result = new DataProviderResultModel();

            try
            {
                dbo = new DataBaseOperator();
                ParamCollections pc     = new ParamCollections();
                string           sqlStr = @"select debitId,userId,ifnull(a.target,'A') target, 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 DebitId = @iDebitId";
                pc.Add("@iDebitId", debitId);
                DebitExtendModel extend = new DebitExtendModel();
                DataTable        dt     = dbo.GetTable(sqlStr, pc.GetParams());

                if (null != dt && dt.Rows.Count > 0)
                {
                    DebitInfoModel info = new DebitInfoModel();
                    int.TryParse(Convert.ToString(dt.Rows[0]["userId"]), out info.userId);
                    int.TryParse(Convert.ToString(dt.Rows[0]["debitId"]), out info.debitId);
                    int.TryParse(Convert.ToString(dt.Rows[0]["overdueDay"]), out info.overdueDay);
                    float.TryParse(Convert.ToString(dt.Rows[0]["dayInterset"]), out info.dayInterset);
                    float.TryParse(Convert.ToString(dt.Rows[0]["overdueMoney"]), out info.overdueMoney);
                    float.TryParse(Convert.ToString(dt.Rows[0]["partMoney"]), out info.partMoney);
                    float.TryParse(Convert.ToString(dt.Rows[0]["debitMoney"]), out info.debitMoney);
                    int.TryParse(Convert.ToString(dt.Rows[0]["Status"]), out info.status);
                    int.TryParse(Convert.ToString(dt.Rows[0]["bankId"]), out info.bankId);
                    int.TryParse(Convert.ToString(dt.Rows[0]["debitPeroid"]), out info.debitPeroid);
                    float.TryParse(Convert.ToString(dt.Rows[0]["payBackMoney"]), out info.payBackMoney);
                    info.createTime      = Convert.ToString(dt.Rows[0]["createTime"]);
                    info.description     = Convert.ToString(dt.Rows[0]["description"]);
                    info.releaseLoanTime = Convert.ToString(dt.Rows[0]["releaseLoanTime"]);
                    info.auditTime       = Convert.ToString(dt.Rows[0]["statusTime"]);
                    info.target          = Convert.ToString(dt.Rows[0]["target"]);
                    info.repaymentTime   = Convert.ToString(dt.Rows[0]["payBackDayTime"]);

                    info.certificate = Convert.ToString(dt.Rows[0]["certificate"]);
                    info.auditInfo   = Convert.ToString(dt.Rows[0]["auditInfo"]);

                    if (info.status != 1 && info.status != 4 && info.status != -2)
                    {
                        result.result  = MainErrorModels.THE_DEBIT_RECORD_STATUS_FAIL;
                        result.message = "Only within loan, overdue, payback failed , can request extend";
                        return(result);
                    }
                    extend.userId       = info.userId;
                    extend.debitId      = info.debitId;
                    extend.status       = info.status;
                    extend.target       = info.target;
                    extend.partMoney    = info.partMoney;
                    extend.debitMoney   = info.debitMoney;
                    extend.debitPeroid  = info.debitPeroid;
                    extend.overdueMoney = info.overdueMoney;

                    DataProviderResultModel rateResult = DebitProvider.GetInterestRateByDebitStyle(info.debitMoney, info.debitPeroid);

                    if (null != rateResult.data)
                    {
                        List <float> rate = rateResult.data as List <float>;

                        if (rate[0] > 1)
                        {
                            extend.extendFee = rate[0];
                        }
                        else
                        {
                            extend.extendFee = rate[0] * info.debitMoney;
                        }
                    }
                }
                else
                {
                    result.result = Result.SUCCESS;
                }

                result.data = extend;

                return(result);
            }
            catch (Exception ex)
            {
                result.result  = MainErrorModels.DATABASE_REQUEST_ERROR;
                result.message = "The database logic error.The function is DebitProvider::GetUserDebitRecord";
                Log.WriteErrorLog("DebitProvider::GetUserDebitRecord", "获取失败:{0},异常:{1}", debitId, ex.Message);
            }
            finally
            {
                if (null != dbo)
                {
                    dbo.Close();
                    dbo = null;
                }
            }
            return(result);
        }
Example #26
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        public static DataProviderResultModel GetUserDebitAttention(int userId)
        {
            DataBaseOperator        dbo    = null;
            DataProviderResultModel result = new DataProviderResultModel();

            try
            {
                dbo = new DataBaseOperator();
                ParamCollections pc     = new ParamCollections();
                string           sqlStr = @"select debitId,userId, debitMoney, 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 and status in (-2,1,2,4) limit 1;";
                pc.Add("@iUserId", userId);

                DataTable dt = dbo.GetTable(sqlStr, pc.GetParams());

                DebitInfoModel info = new DebitInfoModel();
                if (null != dt && dt.Rows.Count > 0)
                {
                    int.TryParse(Convert.ToString(dt.Rows[0]["userId"]), out info.userId);
                    int.TryParse(Convert.ToString(dt.Rows[0]["debitId"]), out info.debitId);
                    float.TryParse(Convert.ToString(dt.Rows[0]["dayInterset"]), out info.dayInterset);
                    float.TryParse(Convert.ToString(dt.Rows[0]["overdueMoney"]), out info.overdueMoney);
                    float.TryParse(Convert.ToString(dt.Rows[0]["debitMoney"]), out info.debitMoney);
                    int.TryParse(Convert.ToString(dt.Rows[0]["Status"]), out info.status);
                    int.TryParse(Convert.ToString(dt.Rows[0]["bankId"]), out info.bankId);
                    int.TryParse(Convert.ToString(dt.Rows[0]["debitPeroid"]), out info.debitPeroid);
                    float.TryParse(Convert.ToString(dt.Rows[0]["payBackMoney"]), out info.payBackMoney);
                    info.createTime      = Convert.ToString(dt.Rows[0]["createTime"]);
                    info.description     = Convert.ToString(dt.Rows[0]["description"]);
                    info.releaseLoanTime = Convert.ToString(dt.Rows[0]["releaseLoanTime"]);
                    info.auditTime       = Convert.ToString(dt.Rows[0]["statusTime"]);
                    info.repaymentTime   = Convert.ToString(dt.Rows[0]["payBackDayTime"]);

                    info.certificate = Convert.ToString(dt.Rows[0]["certificate"]);
                    info.auditInfo   = Convert.ToString(dt.Rows[0]["auditInfo"]);
                }
                else
                {
                    result.result = Result.SUCCESS;
                }
                result.data = info;
                return(result);
            }
            catch (Exception ex)
            {
                result.result  = MainErrorModels.DATABASE_REQUEST_ERROR;
                result.message = "The database logic error.The function is DebitProvider::GetUserDebitAttention";
                Log.WriteErrorLog("DebitProvider::GetUserDebitRecords", "获取失败:{0},异常:{1}", userId, ex.Message);
            }
            finally
            {
                if (null != dbo)
                {
                    dbo.Close();
                    dbo = null;
                }
            }
            return(result);
        }