コード例 #1
0
        public ActionResult UserAllInfo()
        {
            if (TAuth.IsLogged() && !TAuth.IsAdmin())
            {
                var user  = repo.GetUser(Guid.Parse((string)Session["UserID"]));
                var sales = repo.GetAllSales();

                UserAllInfoModel model = new UserAllInfoModel
                {
                    User  = user,
                    Sales = sales.Where(s => s.UserID == user.ID && s.State.Name == "Active").ToList()
                };

                return(View(model));
            }
            else
            {
                return(RedirectToAction("Index", "Home"));
            }
        }
コード例 #2
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));
        }
コード例 #3
0
        /// <summary>
        /// 获取贷款种类
        /// </summary>
        /// <returns></returns>
        public ActionResult <string> GetInitDebitStyle()
        {
            HttpResultModel ret = new HttpResultModel();

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

            try
            {
                string userId    = HttpContext.Request.Headers["userId"];
                var    iUserId   = 0;
                var    userLevel = 0;
                int.TryParse(userId, out iUserId);
                if (iUserId > 0)
                {
                    string key  = String.Format("UserAllInfoV5_{0}", userId);
                    string info = redis.StringGet(key);
                    if (!String.IsNullOrEmpty(info))
                    {
                        UserAllInfoModel userInfo = JsonConvert.DeserializeObject <UserAllInfoModel>(info);
                        userLevel = userInfo.userLevel;

                        Log.WriteDebugLog("v2::MainController::GetInitDebitStyle", "用户的等级是:{0}", userLevel);
                    }
                    else
                    {
                        DataProviderResultModel dataProviderResult = UserProvider.GetUserAllInfo(userId);
                        if (dataProviderResult.result == Result.SUCCESS)
                        {
                            UserAllInfoModel userInfo = dataProviderResult.data as UserAllInfoModel;
                            userLevel = userInfo.userLevel;
                            redis.StringSet(key, JsonConvert.SerializeObject(userInfo));
                        }
                        else
                        {
                            Log.WriteDebugLog("v2::MainController::GetInitDebitStyle", "获取缓存与数据库为空:{0}", userId);
                        }
                    }
                }
                else
                {
                    Log.WriteDebugLog("v2::MainController::GetInitDebitStyle", "用户ID没有传入");
                    userLevel = 0;
                }

                var debitStyle = new List <float> {
                    1500000.00f, 2100000.00f, 2700000.00f
                };
                var debitDesc = new SortedList <float, string>();
                debitDesc.Add(1500000.00f, "ISI LENGKAP DATA PRIBADI ANDA DENGAN BENAR MAKA SYSTEM CREDIT KITA AKAN MELAKUKAN PENGECEKAN DAN PINJAMAN AKAN DIBERIKAN SECARA AUTOMATIS BILA LOLOS VERIFIKASI. TERIMA KASIH");
                debitDesc.Add(2100000.00f, "PEMINJAMAN DENGAN NOMINAL INI HANYA BISA DIPINJAMKAN KALAU SUDAH PERNAH MELAKUKAN PEMBAYARAN TEPAT WAKTU ATAU PERPANJANGAN PRODUCT A DENGAN NOMINAL RP 1.500.000 SEBANYAK 2 KALI PEMINJAMAN");
                debitDesc.Add(2700000.00f, "PEMINJAMAN DENGAN NOMINAL INI HANYA BISA DIPINJAMKAN KALAU SUDAH PERNAH MELAKUKAN PEMBAYARAN TEPAT WAKTU ATAU PERPANJANGAN PRODUCT B DENGAN NOMINAL RP 2.100.000 SEBANYAK 2 KALI PEMINJAMAN");

                var debitPeriod = new List <int> {
                    7
                };
                //List<object> retList = new List<object>();
                List <DebitInfo> list = new List <DebitInfo>();
                foreach (var style in debitStyle)
                {
                    foreach (var period in debitPeriod)
                    {
                        DebitInfo info = new DebitInfo();
                        info.debitMoney  = style;
                        info.debitPeriod = period;

                        info.description = "Ketika Anda melakukan pinjam\r\nBiaya admin harus dibayar diawal";
                        DataProviderResultModel result = DebitProvider.GetInterestRateByDebitStyle(style, period);
                        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 = style;
                                //手续费,一次性
                                if (rate >= 1)
                                {
                                    info.debitFee = rate;
                                    //日息
                                    info.dailyInterest = rate / period;
                                }
                                else
                                {
                                    info.debitFee = style * rate;
                                    //日息
                                    info.dailyInterest = style * rate / period;
                                }
                                info.adminFee = String.Format("Biaya Admin Rp {0}", info.debitFee);
                                //实际到帐,减去手续费
                                info.actualMoney = style - info.debitFee;

                                //逾期日息
                                info.overdueDayInterest = info.actualMoney * overdueRate;

                                //描述
                                info.description  = debitDesc[style];
                                info.displayStyle = 1;
                                if (userLevel == 0)
                                {
                                    if (style > 1500000)
                                    {
                                        info.displayStyle = 0;
                                    }
                                }
                                if (userLevel == 1)
                                {
                                    if (style > 2100000)
                                    {
                                        info.displayStyle = 0;
                                    }
                                }
                                list.Add(info);
                            }
                        }
                    }
                }
                ret.data = list;
            }
            catch (Exception ex)
            {
                ret.result    = Result.ERROR;
                ret.errorCode = MainErrorModels.LOGIC_ERROR;
                ret.message   = Convert.ToString(MainErrorModels.LOGIC_ERROR);

                Log.WriteErrorLog("v2::MainController::GetInitDebitStyle", "异常:{0}", ex.Message);
            }
            return(JsonConvert.SerializeObject(ret));
        }