Exemplo n.º 1
0
        /// <summary>
        /// 获取某条贷款记录
        /// </summary>
        /// <param name="debitId"></param>
        /// <returns></returns>
        public ActionResult <string> GetUserExtendInfo(int debitId)
        {
            HttpResultModel ret = new HttpResultModel();

            ret.result = Result.SUCCESS;
            try
            {
                ///逻辑
                DataProviderResultModel result = DebitProvider.GetUserExtendRecord(debitId);
                if (result.result == Result.SUCCESS)
                {
                    ret.data = result.data;
                }
                else
                {
                    ret.result  = result.result;
                    ret.message = result.message;
                }
            }
            catch (Exception ex)
            {
                ret.result    = Result.ERROR;
                ret.errorCode = MainErrorModels.LOGIC_ERROR;
                ret.message   = "The program logic error from the DebitController::GetUserDebitRecord function.";

                Log.WriteErrorLog("DebitController::GetUserDebitRecord", "异常:{0}", ex.Message);
            }

            return(JsonConvert.SerializeObject(ret));
        }
Exemplo n.º 2
0
        public ActionResult <string> GetUserDebitAttention(int userId)
        {
            HttpResultModel ret = new HttpResultModel();

            ret.result = Result.SUCCESS;
            try
            {
                ///逻辑
                DataProviderResultModel result = DebitProvider.GetUserDebitAttention(userId);
                if (result.result == Result.SUCCESS)
                {
                    ret.data = result.data;
                }
                else
                {
                    ret.result  = result.result;
                    ret.message = result.message;
                }
            }
            catch (Exception ex)
            {
                ret.result    = Result.ERROR;
                ret.errorCode = MainErrorModels.LOGIC_ERROR;
                ret.message   = Convert.ToString(MainErrorModels.LOGIC_ERROR);

                Log.WriteErrorLog("MainController::GetUserDebitAttention", "异常:{0}", ex.Message);
            }
            return(JsonConvert.SerializeObject(ret));
        }
Exemplo n.º 3
0
        public ActionResult <string> GetNotices()
        {
            HttpResultModel ret = new HttpResultModel();

            ret.result = Result.SUCCESS;
            try
            {
                DataProviderResultModel result = MainInfoProvider.GetNotices();
                if (result.result == Result.SUCCESS)
                {
                    ret.data = result.data;
                }
                else
                {
                    ret.result  = result.result;
                    ret.message = result.message;
                }
            }
            catch (Exception ex)
            {
                ret.result    = Result.ERROR;
                ret.errorCode = MainErrorModels.LOGIC_ERROR;
                ret.message   = Convert.ToString(MainErrorModels.LOGIC_ERROR);

                Log.WriteErrorLog("v2::MainController::GetNotice", "异常:{0}", ex.Message);
            }
            return(JsonConvert.SerializeObject(ret));
        }
Exemplo n.º 4
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);
        }
Exemplo n.º 5
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);
        }
Exemplo n.º 6
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);
        }
Exemplo n.º 7
0
        public ActionResult <string> GetUserDebitRecordDetail()
        {
            HttpResultModel ret = new HttpResultModel();

            ret.result = Result.SUCCESS;

            string content = HelperProvider.GetRequestContent(HttpContext);

            if (String.IsNullOrEmpty(content))
            {
                ret.result    = Result.ERROR;
                ret.errorCode = MainErrorModels.PARAMETER_ERROR;
                ret.message   = "The request body is empty.";

                Log.WriteErrorLog("v2:DebitController::SubmitDebitRequest", "请求参数为空。{0}", HelperProvider.GetHeader(HttpContext));
                return(JsonConvert.SerializeObject(ret));
            }

            try
            {
                var requestBody = JsonConvert.DeserializeObject <DebitInfoRequestBody>(content);
                DebitRecordLogResponse  response = new DebitRecordLogResponse();
                DataProviderResultModel result   = DebitProvider.GetUserDebitRecord(requestBody.debitId);
                if (result.result == Result.SUCCESS)
                {
                    response.debitInfo = result.data as DebitInfoModel;
                    result             = DebitProvider.GetUserDebitRecordLogs(requestBody.debitId);
                    if (result.result == Result.SUCCESS)
                    {
                        response.logs = result.data as List <DebitRecordLogModel>;
                        ret.data      = response;
                        ret.result    = Result.SUCCESS;
                    }
                    else
                    {
                        ret.result  = result.result;
                        ret.message = result.message;
                    }
                }
                else
                {
                    ret.result  = result.result;
                    ret.message = result.message;
                }
            }
            catch (Exception ex)
            {
                ret.result    = Result.ERROR;
                ret.errorCode = MainErrorModels.LOGIC_ERROR;
                ret.message   = "The program logic error from the DebitController::GetUserDebitRecordDetail function.";

                Log.WriteErrorLog("v2::DebitController::GetUserDebitRecordDetail", "异常:{0}", ex.Message);
            }

            return(JsonConvert.SerializeObject(ret));
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 10
0
        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);
        }
Exemplo n.º 11
0
        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);
        }
Exemplo n.º 12
0
        /// <summary>
        /// 获取用户的贷款记录
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        public ActionResult <string> GetUserDebitRecords()
        {
            HttpResultModel ret = new HttpResultModel();

            ret.result = Result.SUCCESS;

            string content = HelperProvider.GetRequestContent(HttpContext);

            if (String.IsNullOrEmpty(content))
            {
                ret.result    = Result.ERROR;
                ret.errorCode = MainErrorModels.PARAMETER_ERROR;
                ret.message   = "The request body is empty.";

                Log.WriteErrorLog("v2:DebitController::SubmitDebitRequest", "请求参数为空。{0}", HelperProvider.GetHeader(HttpContext));
                return(JsonConvert.SerializeObject(ret));
            }
            try
            {
                var requestBody = JsonConvert.DeserializeObject <DebitRecordsRequestBody>(content);

                ///逻辑
                DataProviderResultModel result = DebitProvider.GetUserDebitRecords(requestBody);
                if (result.result == Result.SUCCESS)
                {
                    ret.data = result.data;
                }
                else
                {
                    ret.result  = result.result;
                    ret.message = result.message;
                }
            }
            catch (Exception ex)
            {
                ret.result    = Result.ERROR;
                ret.errorCode = MainErrorModels.LOGIC_ERROR;
                ret.message   = "The program logic error from the DebitController::GetUserDebitRecords function.";

                Log.WriteErrorLog("v2::DebitController::GetUserDebitRecords", "UserId:{0},异常:{1}", content, ex.Message);
            }

            return(JsonConvert.SerializeObject(ret));
        }
Exemplo n.º 13
0
        public ActionResult <string> GetUserDebitAttention()
        {
            HttpResultModel ret = new HttpResultModel();

            ret.result = Result.SUCCESS;
            try
            {
                string content = HelperProvider.GetRequestContent(HttpContext);
                if (String.IsNullOrEmpty(content))
                {
                    ret.result    = Result.ERROR;
                    ret.errorCode = MainErrorModels.PARAMETER_ERROR;
                    ret.message   = "The request body is empty.";

                    Log.WriteErrorLog("v2:MainController::GetUserDebitAttention", "请求参数为空。{0}", HelperProvider.GetHeader(HttpContext));
                    return(JsonConvert.SerializeObject(ret));
                }

                var requestBody = JsonConvert.DeserializeObject <UserInfoRequestBody>(content);
                int iUserId     = 0;
                int.TryParse(requestBody.userId, out iUserId);
                ///逻辑
                DataProviderResultModel result = DebitProvider.GetUserDebitAttention(iUserId);
                if (result.result == Result.SUCCESS)
                {
                    ret.data = result.data;
                }
                else
                {
                    ret.result  = result.result;
                    ret.message = result.message;
                }
            }
            catch (Exception ex)
            {
                ret.result    = Result.ERROR;
                ret.errorCode = MainErrorModels.LOGIC_ERROR;
                ret.message   = Convert.ToString(MainErrorModels.LOGIC_ERROR);

                Log.WriteErrorLog("v2::MainController::GetUserDebitAttention", "异常:{0}", ex.Message);
            }
            return(JsonConvert.SerializeObject(ret));
        }
Exemplo n.º 14
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);
        }
Exemplo n.º 15
0
        public ActionResult <string> GetNotices()
        {
            HttpResultModel ret = new HttpResultModel();

            ret.result = Result.SUCCESS;
            try
            {
                string pkgName = HttpContext.Request.Headers["pkgName"];
                if (String.IsNullOrEmpty(pkgName))
                {
                    List <NoticeModel> infos = new List <NoticeModel>();
                    NoticeModel        info  = new NoticeModel();
                    info.title   = "Warning";
                    info.content = "Anda masih menggunakan aplikasi versi lama, silahkan klik  https://play.google.com/store/apps/details?id=com.danapinjam.vip untuk mengunduh versi terbaru.";
                    infos.Add(info);
                    ret.data = infos;
                }
                else
                {
                    ///逻辑
                    DataProviderResultModel result = MainInfoProvider.GetNotices();
                    if (result.result == Result.SUCCESS)
                    {
                        ret.data = result.data;
                    }
                    else
                    {
                        ret.result  = result.result;
                        ret.message = result.message;
                    }
                }
            }
            catch (Exception ex)
            {
                ret.result    = Result.ERROR;
                ret.errorCode = MainErrorModels.LOGIC_ERROR;
                ret.message   = Convert.ToString(MainErrorModels.LOGIC_ERROR);

                Log.WriteErrorLog("MainController::GetNotice", "异常:{0}", ex.Message);
            }
            return(JsonConvert.SerializeObject(ret));
        }
Exemplo n.º 16
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);
        }
Exemplo n.º 17
0
        /// <summary>
        /// 获取贷款种类
        /// </summary>
        /// <returns></returns>
        public ActionResult <string> GetBankCodes()
        {
            HttpResultModel ret = new HttpResultModel();

            ret.result = Result.SUCCESS;
            try
            {
                Redis  redis   = HelperProvider.GetRedis();
                string key     = "BankCodes";
                string retJson = redis.StringGet(key);

                if (String.IsNullOrEmpty(retJson))
                {
                    DataProviderResultModel result = MainInfoProvider.GetBankCodes();
                    if (result.result == Result.SUCCESS)
                    {
                        ret.data = result.data;
                    }
                    else
                    {
                        ret.result    = Result.ERROR;
                        ret.errorCode = result.result;
                        ret.message   = result.message;
                    }
                    redis.StringSet(key, JsonConvert.SerializeObject(ret), 300);
                }
                else
                {
                    return(retJson);
                }
            }
            catch (Exception ex)
            {
                ret.result    = Result.ERROR;
                ret.errorCode = MainErrorModels.LOGIC_ERROR;
                ret.message   = Convert.ToString(MainErrorModels.LOGIC_ERROR);

                Log.WriteErrorLog("MainController::GetBankCodes", "异常:{0}", ex.Message);
            }

            return(JsonConvert.SerializeObject(ret));
        }
Exemplo n.º 18
0
    private void threadProc()
    {
        while (!_isbreak)
        {
            SortedList <string, string> list = BusinessDao.GetNeedCheckDebitRecords();
            Log.WriteDebugLog("StatusCheckThread::threadProc", "存在{0}个需要确认的订单。", list.Count);
            foreach (string orderId in list.Keys)
            {
                string target = list[orderId];
                Log.WriteDebugLog("StatusCheckThread::threadProc", "{0} 准备开始确认订单的状态,渠道{1}。", orderId, target);
                LoanBank bank         = new LoanBank();
                string   merchantCode = String.Empty;

                InquriyTransferResponse response = bank.DuitkuOrderStatusInquiryRequest(orderId, target);
                if (response.statusCode == "00")
                {
                    CallbackRequestModel callback = new CallbackRequestModel();
                    callback.amount          = response.amount;
                    callback.merchantOrderId = response.merchantOrderId;

                    DataProviderResultModel resultModel = DuitkuProvider.SetDuitkuPaybackRecordStaus(callback);
                    if (resultModel.result == Result.SUCCESS)
                    {
                        Log.WriteDebugLog("StatusCheckThread::threadProc", "[{0}]重做成功了。", orderId);
                    }
                    else
                    {
                        Log.WriteDebugLog("StatusCheckThread::threadProc", "[{0}]接口调用成功,但是数据库操作失败了。", orderId);
                    }
                }
                else
                {
                    Log.WriteDebugLog("StatusCheckThread::threadProc", "[{0}]重做失败了。", orderId);
                }

                ///重做次数+1
                BusinessDao.UpdateRedoUserPayBackRecordStatus(orderId);
            }
            Thread.Sleep(10 * 60 * 1000);
        }
    }
Exemplo n.º 19
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="debitId"></param>
        /// <param name="payBackDebitMoney"></param>
        /// <param name="certificateUrl"></param>
        /// <returns></returns>
        public ActionResult <string> SubmitExtendDebitRequest(int userId, int debitId, float payBackDebitMoney, string certificateUrl = "")
        {
            HttpResultModel ret = new HttpResultModel();

            ret.result = Result.SUCCESS;
            Redis redis = HelperProvider.GetRedis();

            try
            {
                string lockKey = "submitExtend";
                if (redis.LockTake(lockKey, userId))
                {
                    ///逻辑
                    DataProviderResultModel result = DebitProvider.ExtendDebitRequest(userId, debitId, payBackDebitMoney, certificateUrl);
                    ret.result = result.result;
                    if (result.result != Result.SUCCESS)
                    {
                        ret.result    = Result.ERROR;
                        ret.errorCode = result.result;
                        ret.message   = result.message;
                    }
                    redis.LockRelease(lockKey, userId);
                }
                else
                {
                    ret.result    = Result.ERROR;
                    ret.errorCode = MainErrorModels.ALREADY_SUBMIT_REQUEST;
                    ret.message   = "already submit request.";
                }
            }
            catch (Exception ex)
            {
                ret.result    = Result.ERROR;
                ret.errorCode = MainErrorModels.LOGIC_ERROR;
                ret.message   = Convert.ToString(MainErrorModels.LOGIC_ERROR);

                Log.WriteErrorLog("DebitController::SubmitExtendDebitRequest", "异常:{0}", ex.Message);
            }

            return(JsonConvert.SerializeObject(ret));
        }
Exemplo n.º 20
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);
        }
Exemplo n.º 21
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);
        }
Exemplo n.º 22
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);
        }
Exemplo n.º 23
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);
        }
Exemplo n.º 24
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);
        }
Exemplo n.º 25
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);
        }
Exemplo n.º 26
0
        /// <summary>
        /// 计算利率 2
        /// </summary>
        /// <param name="debitMoney"></param>
        /// <param name="debitPeroid"></param>
        /// <returns></returns>
        public ActionResult <string> CalcInterestRate(float debitMoney, int debitPeriod)
        {
            HttpResultModel ret = new HttpResultModel();

            ret.result = Result.SUCCESS;
            try
            {
                ///逻辑
                DebitInfo info = new DebitInfo();
                info.debitMoney  = debitMoney;
                info.debitPeriod = debitPeriod;
                info.description = String.Format("no interest rate fees\r\nonly pay back {0} after {1} days", debitMoney.ToString("#,##0.00 "), debitPeriod);
                DataProviderResultModel result = DebitProvider.GetInterestRateByDebitStyle(debitMoney, debitPeriod);
                if (result.result == Result.SUCCESS)
                {
                    float rate        = 0f;
                    float overdueRate = 0f;

                    if (null != result.data)
                    {
                        List <float> rates = result.data as List <float>;

                        rate        = rates[0];
                        overdueRate = rates[1];
                        //贷多少,还多少
                        info.payBackMoney = debitMoney;

                        //手续费,一次性
                        if (rate >= 1)
                        {
                            info.debitFee = rate;
                            //日息
                            info.dailyInterest = rate / debitPeriod;
                        }
                        else
                        {
                            info.debitFee = debitMoney * rate;
                            //日息
                            info.dailyInterest = debitMoney * rate / debitPeriod;
                        }
                        //实际到帐,减去手续费
                        info.actualMoney = debitMoney - info.debitFee;
                        //日息
                        info.dailyInterest = debitMoney * rate / debitPeriod;
                        //逾期日息
                        info.overdueDayInterest = debitMoney * overdueRate;
                        ret.data = info;
                    }
                    else
                    {
                        ret.result  = MainErrorModels.LOGIC_ERROR;
                        ret.message = "logic error,The rate calc result is 0.";
                    }
                }
                else
                {
                    ret.result    = Result.ERROR;
                    ret.errorCode = result.result;
                    ret.message   = result.message;
                }
            }
            catch (Exception ex)
            {
                ret.result    = Result.ERROR;
                ret.errorCode = MainErrorModels.LOGIC_ERROR;
                ret.message   = Convert.ToString(MainErrorModels.LOGIC_ERROR);

                Log.WriteErrorLog("DebitController::CalcInterestRate", "异常:{0}", ex.Message);
            }

            return(JsonConvert.SerializeObject(ret));
        }
Exemplo n.º 27
0
        public IActionResult DailyReport(string date)
        {
            try
            {
                string XlsxContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";

                DataProviderResultModel model = ReportProvider.GetDailyReport(date);

                using (var package = new ExcelPackage())
                {
                    var worksheet = package.Workbook.Worksheets.Add("DAILY REPORT");

                    setReleaseLoanHeader(worksheet, date);

                    //Fill release loan data
                    DataTable releaseLoan = model.data as DataTable;
                    int       row         = 11;
                    if (null != releaseLoan || releaseLoan.Rows.Count > 0)
                    {
                        worksheet.Cells["A11"].LoadFromDataTable(releaseLoan, PrintHeaders: false);
                    }
                    row += releaseLoan.Rows.Count;
                    setCellBodyStyle(worksheet.Cells[String.Format("A11:E{0}", row)], 11, ExcelHorizontalAlignment.Center, ExcelVerticalAlignment.Center);

                    setPaybackLoanHeader("Daily Collection", worksheet, ref row);

                    row  += 2;
                    model = ReportProvider.GetDailyPaybackReport(date);
                    DataTable paybackLoan = model.data as DataTable;

                    int bodyRow = row;
                    if (null != paybackLoan && paybackLoan.Rows.Count > 0)
                    {
                        worksheet.Cells[String.Format("A{0}", row)].LoadFromDataTable(paybackLoan, PrintHeaders: false);
                    }
                    row += paybackLoan.Rows.Count;
                    setCellBodyStyle(worksheet.Cells[String.Format("A{0}:K{1}", bodyRow, row)], 11, ExcelHorizontalAlignment.Center, ExcelVerticalAlignment.Center);

                    setPaybackLoanHeader("Extend Collection", worksheet, ref row);

                    row  += 2;
                    model = ReportProvider.GetDailyExtendReport(date);
                    DataTable extendLoan = model.data as DataTable;

                    bodyRow = row;
                    if (null != extendLoan && extendLoan.Rows.Count > 0)
                    {
                        worksheet.Cells[String.Format("A{0}", row)].LoadFromDataTable(extendLoan, PrintHeaders: false);
                    }
                    row += extendLoan.Rows.Count;
                    setCellBodyStyle(worksheet.Cells[String.Format("A{0}:K{1}", bodyRow, row)], 11, ExcelHorizontalAlignment.Center, ExcelVerticalAlignment.Center);

                    setBadLoanHeader("Bad Debt Confirmed", worksheet, ref row);
                    row += 2;

                    model = ReportProvider.GetDailyBadReport(date);
                    DataTable badLoan = model.data as DataTable;
                    bodyRow = row;
                    if (null != badLoan && badLoan.Rows.Count > 0)
                    {
                        worksheet.Cells[String.Format("A{0}", row)].LoadFromDataTable(badLoan, PrintHeaders: false);
                    }
                    row += badLoan.Rows.Count;
                    setCellBodyStyle(worksheet.Cells[String.Format("A{0}:F{1}", bodyRow, row)], 11, ExcelHorizontalAlignment.Center, ExcelVerticalAlignment.Center);

                    row += 2;
                    worksheet.Cells[String.Format("A{0}", row)].Value = "Prepared by,";
                    worksheet.Cells[String.Format("C{0}", row)].Value = "Checked by,";
                    worksheet.Cells[String.Format("F{0}", row)].Value = "Approved by,";
                    worksheet.Cells.AutoFitColumns();

                    return(File(package.GetAsByteArray(), XlsxContentType, String.Format("{0}_report.xlsx", date.Replace("-", ""))));
                }
            }
            catch (Exception ex)
            {
                Log.WriteErrorLog("ReportController::DailyReport", ex.Message);
                return(Content(String.Format("An error occurred. Please try again.{0}", ex.Message)));
            }
        }
Exemplo n.º 28
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);
        }
Exemplo n.º 29
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 ActionResult <string> SubmitDebitRequest(int userId, float debitMoney, string description, int bankId = 0, int debitPeriod = 0, int debitPeroid = 0, string deviceId = "")
        {
            HttpResultModel ret = new HttpResultModel();

            ret.result = Result.SUCCESS;
            Redis redis = HelperProvider.GetRedis();

            try
            {
                string pkgName = HttpContext.Request.Headers["pkgName"];
                if (String.IsNullOrEmpty(pkgName) && String.IsNullOrEmpty(redis.StringGet(String.Format("attention_{0}", userId))))
                {
                    Log.WriteDebugLog("DebitController::SubmitDebitRequest", "[{0}] 用的是老版本,发短信通知他去下载最新版", userId);
                    WaveCellSMSSingleSender.Authorization  = ConfigSettings.WaveCellSMSAuthorization;
                    WaveCellSMSSingleSender.SubAccountName = ConfigSettings.WaveCellSMSAccountName;
                    WaveCellSMSSingleSender waveCellSMSSender = new WaveCellSMSSingleSender();

                    string key  = String.Format("UserAllInfoV5_{0}", userId);
                    string info = redis.StringGet(key);
                    if (!String.IsNullOrEmpty(info))
                    {
                        UserAllInfoModel          userInfo = JsonConvert.DeserializeObject <UserAllInfoModel>(info);
                        string                    phone    = "+62" + userInfo.userPersonalInfo.userName;
                        string                    msg      = "Anda masih menggunakan aplikasi versi lama, silahkan klik  https://play.google.com/store/apps/details?id=com.danapinjam.vip untuk mengunduh versi terbaru.";
                        WaveCellSMSResponseModels sendRet  = waveCellSMSSender.Send(phone, msg);
                    }
                    redis.StringSet(String.Format("attention_{0}", userId), "1");
                }

                if (userId > 146724 && String.IsNullOrEmpty(pkgName))
                {
                    ret.result    = Result.ERROR;
                    ret.errorCode = MainErrorModels.PARAMETER_ERROR;
                    ret.message   = "Anda masih menggunakan aplikasi versi lama, silahkan klik  https://play.google.com/store/apps/details?id=com.danapinjam.vip untuk mengunduh versi terbaru.";

                    Log.WriteWarning("DebitController::SubmitDebitRequest", "新用户,老版本将不允许借款。{0}", HelperProvider.GetHeader(HttpContext));
                    return(JsonConvert.SerializeObject(ret));
                }
                string lockKey = "submitdebit";
                if (redis.LockTake(lockKey, userId))
                {
                    debitPeriod = debitPeriod == 0 ? debitPeroid : debitPeriod;
                    if (String.IsNullOrEmpty(deviceId))
                    {
                        deviceId = HttpContext.Request.Headers["deviceNo"];
                    }

                    if (bankId == 0)
                    {
                        DataProviderResultModel bankInfoResult = DebitProvider.GetUserBankId(userId);
                        if (bankInfoResult.result == Result.SUCCESS)
                        {
                            int.TryParse(Convert.ToString(bankInfoResult.data), out bankId);
                        }
                        else
                        {
                            ret.result    = Result.ERROR;
                            ret.errorCode = MainErrorModels.PARAMETER_ERROR;
                            ret.message   = bankInfoResult.message;
                            redis.LockRelease(lockKey, userId);
                            return(JsonConvert.SerializeObject(ret));
                        }
                        Log.WriteWarning("DebitController::SubmitDebitRequest", "警告:用户【{0}】提交时BankId为空,可能是老版本。", userId);
                    }

                    ///逻辑
                    DataProviderResultModel result = DebitProvider.SubmitDebitReuqest(userId, debitMoney, debitPeriod, bankId, description, deviceId);
                    ret.result = result.result;
                    if (result.result == Result.SUCCESS)
                    {
                        ret.data = result.data;
                    }
                    else
                    {
                        ret.result    = Result.ERROR;
                        ret.errorCode = result.result;
                        ret.message   = result.message;
                    }
                    redis.LockRelease(lockKey, userId);
                }
                else
                {
                    ret.result    = Result.ERROR;
                    ret.errorCode = MainErrorModels.ALREADY_SUBMIT_REQUEST;
                    ret.message   = "already submit request.";

                    Log.WriteDebugLog("DebitController::SubmitDebitRequest", "[{0}] 重复请求。", userId);
                }
            }
            catch (Exception ex)
            {
                ret.result    = Result.ERROR;
                ret.errorCode = MainErrorModels.LOGIC_ERROR;
                ret.message   = Convert.ToString(MainErrorModels.LOGIC_ERROR);

                Log.WriteErrorLog("DebitController::SubmitDebitRequest", "异常:{0}", ex.Message);
            }
            finally
            {
                Log.WriteDebugLog("UserController::SubmitDebitRequest", "{0}", HelperProvider.GetHeader(HttpContext));
            }
            return(JsonConvert.SerializeObject(ret));
        }
Exemplo n.º 30
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);
        }