Ejemplo n.º 1
0
        public ActionResult <string> PostQuestions()
        {
            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:MineController::PostQuestions", "请求参数为空。{0}", HelperProvider.GetHeader(HttpContext));
                return(JsonConvert.SerializeObject(ret));
            }

            var requestBody = JsonConvert.DeserializeObject <QuestionsRequestBody>(content);

            try
            {
                DataProviderResultModel result = MineProvider.PostUserQuestions(requestBody);
                if (result.result == Result.SUCCESS)
                {
                    ret.data   = result.data;
                    ret.result = Result.SUCCESS;
                }
                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 MineController::PostQuestions function.";

                Log.WriteErrorLog("v2::MineController::PostQuestions", "UserInfo:{0},异常:{1}", content, ex.Message);
            }
            return(JsonConvert.SerializeObject(ret));
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 3
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));
        }
Ejemplo n.º 4
0
        public ActionResult <string> GetSTSToken()
        {
            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::GetSTSToken", "请求参数为空。{0}", HelperProvider.GetHeader(HttpContext));
                    return(JsonConvert.SerializeObject(ret));
                }
                var requestBody = JsonConvert.DeserializeObject <STSTokenRequestBody>(content);

                ret.data = HelperProvider.GetToken(requestBody.userId, requestBody.region);
            }
            catch (Exception ex)
            {
                ret.result    = Result.ERROR;
                ret.errorCode = MainErrorModels.LOGIC_ERROR;
                ret.message   = Convert.ToString(MainErrorModels.LOGIC_ERROR);

                Log.WriteErrorLog("v2::MainController::GetSTSToken", "异常:{0}", ex.Message);
            }
            return(JsonConvert.SerializeObject(ret));
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 启动时获取全局的配置信息
        /// </summary>
        /// <returns></returns>
        public ActionResult <string> GetInitAppConfig()
        {
            HttpResultModel ret = new HttpResultModel();

            ret.result = Result.SUCCESS;
            try
            {
                string version  = HttpContext.Request.Headers["version"];
                string pkgName  = HttpContext.Request.Headers["pkgName"];
                int    iVersion = 0;
                int.TryParse(version, out iVersion);

                Redis redis = HelperProvider.GetRedis();
                version = redis.StringGet("appVersion");
                int newVersion = 0;
                int.TryParse(version, out newVersion);

                int updateIsMust = 0;
                int.TryParse(redis.StringGet("updateIsMust"), out updateIsMust);
                SortedList <string, string> list = new SortedList <string, string>();
                if (String.IsNullOrEmpty(pkgName))
                {
                    list.Add("isUpdate", "1");
                    list.Add("version", Convert.ToString(newVersion));
                    list.Add("isMust", "0");

                    Log.WriteDebugLog("MainController::GetInitAppConfig", "老版本:提示升级,{0}", HelperProvider.GetHeader(HttpContext));
                }
                else
                {
                    list.Add("isUpdate", Convert.ToString(newVersion > iVersion ? 1 : 0));
                    list.Add("version", Convert.ToString(newVersion));
                    list.Add("isMust", Convert.ToString(updateIsMust));
                }
                //Anda masih menggunakan aplikasi versi lama, silahkan klik https://play.google.com/store/apps/details?id=com.danapinjam.vip untuk mengunduh versi terbaru.
                list.Add("downloadUrl", "https://play.google.com/store/apps/details?id=com.danapinjam.vip");
                list.Add("aboutUrl", "http://api.danapinjam.com/api/Home/about");
                list.Add("helpUrl", "http://api.danapinjam.com/api/Home/Help");
                list.Add("contactusUrl", "http://api.danapinjam.com/api/Home/contactus");
                list.Add("agreementUrl2", "http://api.danapinjam.com/api/Home/agreement2");
                list.Add("agreementUrl", "http://api.danapinjam.com/api/Home/agreement");

                ///下面是第三方支付的说明页面
                list.Add("atmh5url", ConfigSettings.atmh5url);
                list.Add("paymethod", String.IsNullOrEmpty(ConfigSettings.PayMethod) ? "1" : ConfigSettings.PayMethod);

                ///以下是OSS的相关配置
                list.Add("ossRegion", "ap-southeast-5");
                list.Add("bucketName", "yjddebit");
                list.Add("ossEndPoint", "http://oss-ap-southeast-5.aliyuncs.com");
                list.Add("ossUrl", "http://yjddebit.oss-ap-southeast-5.aliyuncs.com");

                list.Add("privacyPolicy", "http://api.smalldebit.club/static/html/privacy.html");
                list.Add("indexIntro", "Lakukan Pembayaran Tepat Waktu\r\n&\r\nNikmati Pinjaman Yang Lebih Besar");

                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::GetInitAppConfig", "异常:{0}", ex.Message);
            }
            return(JsonConvert.SerializeObject(ret));
        }
Ejemplo n.º 6
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()
        {
            HttpResultModel ret = new HttpResultModel();

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

            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:DebitController::SubmitDebitRequest", "请求参数为空。{0}", HelperProvider.GetHeader(HttpContext));
                    return(JsonConvert.SerializeObject(ret));
                }

                var requestBody = JsonConvert.DeserializeObject <SubmitDebitRequestBody>(content);

                string pkgName = HttpContext.Request.Headers["pkgName"];
                string lockKey = "submitdebit";
                if (redis.LockTake(lockKey, requestBody.userId))
                {
                    if (String.IsNullOrEmpty(requestBody.deviceId))
                    {
                        requestBody.deviceId = HttpContext.Request.Headers["deviceNo"];
                    }

                    if (requestBody.bankId < 1)
                    {
                        ret.result    = Result.ERROR;
                        ret.errorCode = MainErrorModels.PARAMETER_ERROR;
                        ret.message   = "The bankId is empty.";
                        redis.LockRelease(lockKey, requestBody.userId);

                        Log.WriteWarning("v2::DebitController::SubmitDebitRequest", "警告:用户【{0}】提交时BankId为空。", requestBody.userId);
                        return(JsonConvert.SerializeObject(ret));
                    }

                    ///逻辑
                    DataProviderResultModel result = DebitProvider.SubmitDebitReuqestV2(requestBody.userId, requestBody.debitMoney, requestBody.debitPeriod, requestBody.bankId, requestBody.description, requestBody.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, requestBody.userId);
                }
                else
                {
                    ret.result    = Result.ERROR;
                    ret.errorCode = MainErrorModels.ALREADY_SUBMIT_REQUEST;
                    ret.message   = "already submit request.";

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

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