Exemple #1
0
    // Start is called before the first frame update
    void Start()
    {
        GameObject infoLogObject = GameObject.Find("InfoLog");

        infoLogObject.GetComponent <Canvas>().enabled = false;
        infoLogAnimator = infoLogObject.GetComponent <Animator>();


        GameObject loginWindow = GameObject.Find("LoginWindow");

        loginLogic = loginWindow.GetComponent <LoginLogic>();
        GameObject informationWindow = GameObject.Find("InformationWindow");

        informationLogic = informationWindow.GetComponent <InformationLogic>();
        GameObject registerWindow = GameObject.Find("RegisterWindow");

        registerLogin = registerWindow.GetComponent <RegisterLogin>();
        GameObject mainMenuWindow = GameObject.Find("MainMenuWindow");

        mainMenuLogic = mainMenuWindow.GetComponent <MainMenuLogic>();
        GameObject gameCreationWindow = GameObject.Find("GameCreationWindow");

        gameCreationLogic = gameCreationWindow.GetComponent <GameCreationLogic>();
        GameObject invitationWindow = GameObject.Find("InvitationWindow");

        invitationLogic = invitationWindow.GetComponent <InvitationLogic>();
        GameObject joinAGameWindow = GameObject.Find("JoinAGameWindow");

        joinAGameLogic = joinAGameWindow.GetComponent <JoinAGameLogic>();
        connectToServer();
    }
Exemple #2
0
        // Start is called before the first frame update
        //It gets all the unity objects needed on this script, makes the menu invisible
        //Get an instance of the server connection
        //set the button events
        void Start()
        {
            GameObject informationWindow = GameObject.Find("InformationWindow");

            informationLogic = informationWindow.GetComponent <InformationLogic>();
            GameObject loginWindow = GameObject.Find("LoginWindow");

            loginLogic = loginWindow.GetComponent <LoginLogic>();
            GameObject gameCreationWindow = GameObject.Find("GameCreationWindow");

            gameCreationLogic = gameCreationWindow.GetComponent <GameCreationLogic>();

            GameObject invitationWindow = GameObject.Find("InvitationWindow");

            invitationLogic = invitationWindow.GetComponent <InvitationLogic>();
            GameObject joinAGameWindow = GameObject.Find("JoinAGameWindow");

            joinAGameLogic = joinAGameWindow.GetComponent <JoinAGameLogic>();
            GameObject scoreBoardWindow = GameObject.Find("ScoreboardWindow");

            scoreBoardLogic = scoreBoardWindow.GetComponent <ScoreBoardLogic>();

            serverConnection = ServerConnection.getInstance();
            createGameBtn.onClick.AddListener(CreateGameClick);
            joinGameBtn.onClick.AddListener(JoinGameClick);
            userInfoBtn.onClick.AddListener(UserInfoClick);
            scoreBoardBtn.onClick.AddListener(ScoreBoardClick);


            gameCreationLogic.playButtonCanvas.enabled = false;
            joinAGameLogic.mainCanvas.enabled          = false;
        }
    //Start is called before the first frame update
    //It gets all the unity objects needed on this script, makes the infoLog invisible
    //Get an instance of the server connection
    //set the button events
    //Executes the function to connect to the server for the first time
    void OnSceneLoaded(Scene scene, LoadSceneMode mode)
    {
        Debug.Log("Loading Message_Parser");

        GameObject infoLogObject = GameObject.Find("InfoLog");

        infoLogObject.GetComponent <Canvas>().enabled = false;
        infoLogAnimator = infoLogObject.GetComponent <Animator>();


        GameObject loginWindow = GameObject.Find("LoginWindow");

        loginLogic = loginWindow.GetComponent <LoginLogic>();
        GameObject informationWindow = GameObject.Find("InformationWindow");

        informationLogic = informationWindow.GetComponent <InformationLogic>();
        GameObject registerWindow = GameObject.Find("RegisterWindow");

        registerLogin = registerWindow.GetComponent <RegisterLogin>();
        GameObject mainMenuWindow = GameObject.Find("MainMenuWindow");

        mainMenuLogic = mainMenuWindow.GetComponent <MainMenuLogic>();
        GameObject gameCreationWindow = GameObject.Find("GameCreationWindow");

        gameCreationLogic = gameCreationWindow.GetComponent <GameCreationLogic>();
        GameObject invitationWindow = GameObject.Find("InvitationWindow");

        invitationLogic = invitationWindow.GetComponent <InvitationLogic>();
        GameObject joinAGameWindow = GameObject.Find("JoinAGameWindow");

        joinAGameLogic = joinAGameWindow.GetComponent <JoinAGameLogic>();
        GameObject scoreboardWindow = GameObject.Find("ScoreboardWindow");

        scoreBoardLogic = scoreboardWindow.GetComponent <ScoreBoardLogic>();
        GameObject personalBoardWindow = GameObject.Find("PersonalBoardWindow");

        personalBoardLogic = personalBoardWindow.GetComponent <LoginUI.PersonalBoardLogic>();
        connectToServer();
    }
 public InvitationController(IAccountContext accountContext, IUserContext userContext, IInvitationContext invitationContext)
 {
     _accountLogic    = new AccountLogic(accountContext);
     _userLogic       = new UserLogic(userContext);
     _invitationLogic = new InvitationLogic(invitationContext);
 }
Exemple #5
0
 public UserController(IUserContext userContext, IInvitationContext invitationContext)
 {
     _userContext     = userContext;
     _invitationLogic = new InvitationLogic(invitationContext);
 }
Exemple #6
0
        public ActionResult Index(RequestParam <RequestTender> reqst)
        {
            LoggerHelper.Info(JsonHelper.Entity2Json(reqst));
            ResultInfo <string> res = new ResultInfo <string>("99999");
            var usrId    = ConvertHelper.ParseValue(reqst.body.userId, 0);
            var targetId = ConvertHelper.ParseValue(reqst.body.targetId, 0);
            var bds      = string.Empty;

            B_borrowing_target b_borrowing_target = new B_borrowing_target();
            var            m_borrowing_target     = b_borrowing_target.GetModel(targetId);
            B_member_table b_member_table         = new B_member_table();
            var            m_member_table         = b_member_table.GetModel(usrId);


            if (m_borrowing_target == null || m_member_table == null)
            {
                res.code    = "1000000010";
                res.message = Settings.Instance.GetErrorMsg(res.code);
                return(View(res));
            }
            if (!string.IsNullOrWhiteSpace(reqst.body.bonusIds))
            {
                bds = reqst.body.bonusIds;
            }
            if (!string.IsNullOrWhiteSpace(reqst.body.addRateIds))
            {
                if (!string.IsNullOrWhiteSpace(bds))
                {
                    bds += ",";
                }
                bds = reqst.body.addRateIds;
            }
            var         investAmount = ConvertHelper.ParseValue(reqst.body.investAmount, 0M);
            BorrowLogic _logic       = new BorrowLogic();
            var         ent          = _logic.SelectBorrowDetail(targetId);

            if (usrId <= 0)
            {
                res.code    = "1000000015";
                res.message = Settings.Instance.GetErrorMsg(res.code);
                return(View(res));
            }
            if (targetId <= 0)
            {
                res.code    = "1000000014";
                res.message = Settings.Instance.GetErrorMsg(res.code);
                return(View(res));
            }
            if (investAmount < 100)
            {
                res.code    = "2000000000";
                res.message = Settings.Instance.GetErrorMsg(res.code);
                return(View(res));
            }
            if (m_borrowing_target.minimum > 0 && investAmount < m_borrowing_target.minimum)
            {
                res.code    = "2000000008";
                res.message = Settings.Instance.GetErrorMsg(res.code);
                return(View(res));
            }
            if (m_borrowing_target.maxmum > 0 && investAmount > m_borrowing_target.maxmum)
            {
                res.code    = "2000000009";
                res.message = Settings.Instance.GetErrorMsg(res.code);
                return(View(res));
            }

            if (reqst.body.typeId == 6)//新手标判定
            {
                if (!string.IsNullOrWhiteSpace(bds))
                {
                    res.code    = "2000000010";
                    res.message = Settings.Instance.GetErrorMsg(res.code);
                    return(View(res));
                }
                if (m_member_table.useridentity != 5)
                {
                    if (Convert.ToDateTime(m_member_table.Registration_time.ToString("yyyy-MM-dd")).AddDays(30) < Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd")))
                    {
                        res.code    = "2000000011";
                        res.message = Settings.Instance.GetErrorMsg(res.code);
                        return(View(res));
                    }
                    B_Bid_records b_Bid_records = new B_Bid_records();
                    int           investedCount = b_Bid_records.GetInvestCount(reqst.body.userId, reqst.body.targetId);
                    if (investedCount >= 3)
                    {
                        res.code    = "2000000012";
                        res.message = Settings.Instance.GetErrorMsg(res.code);
                        return(View(res));
                    }
                    if (ent.start_time != null && ent.start_time.Value < Convert.ToDateTime("2016-12-01 00:00:00"))
                    {
                        res.code    = "2999999999";
                        res.message = Settings.Instance.GetErrorMsg(res.code);
                        return(View(res));
                    }
                    if (ent.project_type_id != null && ent.project_type_id.Value != 6)
                    {
                        res.code    = "2999999999";
                        res.message = Settings.Instance.GetErrorMsg(res.code);
                        return(View(res));
                    }
                }
            }
            try
            {
                decimal        vocheramttemp = GetUseRewards(bds, usrId);
                B_member_table b             = new B_member_table();
                M_member_table user          = new M_member_table();
                user = b.GetModel(reqst.body.userId);
                InvestmentParameters mp = new InvestmentParameters
                {
                    Amount            = investAmount,
                    Circle            = ConvertHelper.ParseValue(ent.life_of_loan, 0),
                    CircleType        = ConvertHelper.ParseValue(ent.unit_day, 0),
                    NominalYearRate   = ConvertHelper.ParseValue(ent.annual_interest_rate, 0D),
                    OverheadsRate     = 0f,
                    RepaymentMode     = ConvertHelper.ParseValue(ent.payment_options, 0),
                    RewardRate        = 0f,
                    IsThirtyDayMonth  = false,
                    InvestDate        = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd")),
                    ReleaseDate       = DateTime.Parse(ent.release_date.ToString()).ToString("yyyy-MM-dd"),
                    Investmentenddate = DateTime.Parse(DateTime.Parse(ent.repayment_date.ToString()).ToString("yyyy-MM-dd")),
                    Payinterest       = ConvertHelper.ParseValue(ent.month_payment_date, 0),
                    InvestObject      = 1
                };
                //追加  加息券
                if (!string.IsNullOrWhiteSpace(bds))
                {
                    B_UserAct bUserAct     = new B_UserAct();
                    var       addRateModel = bUserAct.GetAddRateModel(bds);
                    if (addRateModel != null)// add rate of year
                    {
                        mp.NominalYearRate = mp.NominalYearRate + Convert.ToDouble(addRateModel.Amt.Value);
                    }
                }
                List <InvestmentReceiveRecordInfo> records = InvestCalculator.CalculateReceiveRecord(mp);
                StringBuilder sb = new StringBuilder("");
                if (records != null && records.Any())
                {
                    int i = 1;
                    foreach (var item in records)
                    {
                        sb.AppendFormat("{0},{1},{2},{3},{4},{5},{6},{7}|", i, item.interestvalue_date, item.NominalReceiveDate, item.Balance, item.Interest, item.Principal, item.TotalInstallments, item.TotalDays);
                        i = i + 1;
                    }
                }
                var     orderId      = Settings.Instance.OrderCode;
                var     frozenidNo   = Settings.Instance.OrderCode;
                decimal frozenAmount = 0.00M;

                var xf = ((records != null && records.Any()) ? records.Sum(t => t.Interest) : 0M);
                //LoggerHelper.Error("利息:" + xf + " ------- " + JsonHelper.Entity2Json(records));
                string invitationCode = string.Empty;
                using (InvitationLogic invitationLogic = new InvitationLogic())
                {
                    var invitationModel = invitationLogic.GetUserInvited(usrId);
                    if (invitationModel != null)
                    {
                        invitationCode = invitationModel.invcode;
                    }
                }
                var resVal = _logic.SubmitTender(usrId, targetId, investAmount, bds, invitationCode, orderId
                                                 , xf, frozenidNo
                                                 , investAmount - frozenAmount
                                                 , ((records != null && records.Any()) ? records.Count : 0), sb.ToString());
                if (resVal < 200)
                {
                    switch (resVal)
                    {
                    case -100:
                    {
                        res.code = "2000000001";
                    }
                    break;

                    case -101:
                    {
                        res.code = "2000000008";
                    }
                    break;

                    case -200:
                    {
                        res.code = "2000000002";
                    }
                    break;

                    case -300:
                    {
                        res.code = "2000000003";
                    }
                    break;

                    case -400:
                    {
                        res.code = "2000000004";
                    }
                    break;

                    case -500:
                    {
                        res.code = "2000000007";
                    }
                    break;

                    case -600:
                    {
                        res.code = "2000000006";
                    }
                    break;
                    }
                }
                else
                {
                    LoggerHelper.Error("SubmitTender!!!!!!!!!!!!!!!投资开始");
                    LoggerHelper.Info("投资开始");
                    #region 投资成功
                    M_InitiativeTender Mt = new M_InitiativeTender();
                    Mt.Version       = "20";
                    Mt.CmdId         = "InitiativeTender";
                    Mt.MerCustId     = Settings.Instance.MerCustId;
                    Mt.OrdId         = orderId;
                    Mt.OrdDate       = mp.InvestDate.ToString("yyyyMMdd");
                    Mt.TransAmt      = investAmount.ToString("0.00");
                    Mt.UsrCustId     = user.UsrCustId;
                    Mt.MaxTenderRate = "0.20";

                    TenderJosnPro mtp = new TenderJosnPro();
                    mtp.BorrowerCustId = b.GetModel(ConvertHelper.ParseValue(ent.borrower_registerid, 0)).UsrCustId;
                    mtp.BorrowerAmt    = investAmount.ToString("0.00");

                    // mtp.BorrowerRate = decimal.Parse( dt.Rows[0]["loan_management_fee"].ToString()).ToString("0.00");

                    mtp.BorrowerRate = "1.00"; //风控范围

                    mtp.ProId = targetId.ToString();

                    Mt.BorrowerDetails = "[" + FastJSON.toJOSN(mtp) + "]";

                    #region 此处判断优惠类型

                    #endregion
                    Mt.IsFreeze = "Y";

                    Mt.FreezeOrdId = frozenidNo;

                    Mt.RetUrl = Settings.Instance.GetCallbackUrl("/MemberCenter/InvestSubmit/CallbackRetUrl");

                    Mt.BgRetUrl = Settings.Instance.GetCallbackUrl("/MemberCenter/InvestSubmit/CallbackBgRetUrl");

                    if (!string.IsNullOrWhiteSpace(reqst.body.bonusIds))
                    {
                        Mt.MerPriv = bds;
                        TenderAccPro ret = new TenderAccPro();
                        ret.AcctId    = ChuanglitouP2P.Common.Utils.GetMERDT();
                        ret.VocherAmt = vocheramttemp.ToString("0.00");
                        Mt.ReqExt     = "{" + "\"Vocher\":" + FastJSON.toJOSN(ret) + "}";
                    }
                    else
                    {
                        Mt.MerPriv = reqst.body.addRateIds;
                    }

                    //append device code to comment fields for make sure it be transfered back
                    string temp = Mt.MerPriv;
                    AppendDeviceFlag(reqst.header.appId.ToString(), ref temp);
                    Mt.MerPriv = temp;

                    LoggerHelper.Info("优惠券使用的id:" + bds);
                    StringBuilder chkVal = new StringBuilder();
                    chkVal.Append(Mt.Version);
                    chkVal.Append(Mt.CmdId);
                    chkVal.Append(Mt.MerCustId);
                    chkVal.Append(Mt.OrdId);
                    chkVal.Append(Mt.OrdDate);
                    chkVal.Append(Mt.TransAmt);
                    chkVal.Append(Mt.UsrCustId);
                    chkVal.Append(Mt.MaxTenderRate);
                    chkVal.Append(Mt.BorrowerDetails);
                    chkVal.Append(Mt.IsFreeze);
                    chkVal.Append(Mt.FreezeOrdId);
                    chkVal.Append(Mt.RetUrl);
                    chkVal.Append(Mt.BgRetUrl);
                    chkVal.Append(Mt.MerPriv);
                    chkVal.Append(Mt.ReqExt);

                    string chkv = chkVal.ToString();
                    LoggerHelper.Info("投资:" + chkv);
                    //私钥文件的位置(这里是放在了站点的根目录下)
                    string merKeyFile = AppDomain.CurrentDomain.BaseDirectory + Settings.Instance.MerPr;
                    //需要指定提交字符串的长度
                    int           len        = Encoding.UTF8.GetBytes(chkv).Length;
                    StringBuilder sbChkValue = new StringBuilder(256);
                    //加签
                    int str = DllInterop.SignMsg(Settings.Instance.MerId, merKeyFile, chkv, len, sbChkValue);

                    LoggerHelper.Info(str);

                    Mt.ChkValue = sbChkValue.ToString();
                    if (str == 0)
                    {
                        var strz = new StringBuilder();

                        strz.Append(" <form id=\"formauto\" name=\"formauto\"  action=\"" + Settings.Instance.ChinapnrUrl + "\" method=\"post\">");

                        strz.Append("<input id=\"Version\"  name=\"Version\"  type=\"hidden\"  value=\"" + Mt.Version + "\" />");

                        strz.Append("<input id=\"CmdId\"  name=\"CmdId\"    type=\"hidden\"  value=\"" + Mt.CmdId + "\" />");

                        strz.Append("<input id=\"MerCustId\" name=\"MerCustId\"   type=\"hidden\"  value=\"" + Mt.MerCustId + "\" />");

                        strz.Append("<input id=\"OrdId\" name=\"OrdId\" type=\"hidden\"  value=\"" + Mt.OrdId + "\" />");

                        strz.Append("<input id=\"OrdDate\" name=\"OrdDate\" type=\"hidden\"  value=\"" + Mt.OrdDate + "\" />");

                        strz.Append("<input id=\"TransAmt\" name=\"TransAmt\" type=\"hidden\"  value=\"" + Mt.TransAmt + "\" />");

                        strz.Append("<input id=\"UsrCustId\"  name=\"UsrCustId\" type=\"hidden\"  value=\"" + Mt.UsrCustId + "\" />");

                        strz.Append("<input id=\"MaxTenderRate\"   name=\"MaxTenderRate\" type=\"hidden\"  value=\"" + Mt.MaxTenderRate + "\" />");

                        strz.Append("<input id=\"BorrowerDetails\" name=\"BorrowerDetails\" type=\"hidden\"  value=" + Mt.BorrowerDetails + " />");

                        strz.Append("<input id=\"IsFreeze\" name=\"IsFreeze\" type=\"hidden\"  value=\"" + Mt.IsFreeze + "\" />");
                        strz.Append("<input id=\"FreezeOrdId\" name=\"FreezeOrdId\" type=\"hidden\"  value=\"" + Mt.FreezeOrdId + "\" />");
                        strz.Append("<input id=\"RetUrl\" name=\"RetUrl\" type=\"hidden\"  value=\"" + Mt.RetUrl + "\" />");
                        strz.Append("<input id=\"BgRetUrl\" name=\"BgRetUrl\" type=\"hidden\"  value=\"" + Mt.BgRetUrl + "\" />");
                        strz.Append("<input id=\"MerPriv\" name=\"MerPriv\" type=\"hidden\"  value=\"" + Mt.MerPriv + "\" />");
                        strz.Append("<input id=\"ReqExt\" name=\"ReqExt\" type=\"hidden\"  value=" + Mt.ReqExt + " >");
                        strz.Append("<input id=\"ChkValue\" name=\"ChkValue\" type=\"hidden\"  value=\"" + Mt.ChkValue + "\" />");
                        strz.Append(" </form>");
                        strz.Append("<script type=\"text/javascript\">document.getElementById('formauto').submit();</script>");

                        LoggerHelper.Info("投资表单:" + strz.ToString());
                        res.code = "1";
                        res.body = strz.ToString();
                    }
                    else
                    {
                        res.code = "5000000000";
                    }
                    #endregion
                }
                res.message = Settings.Instance.GetErrorMsg(res.code);
                return(View(res));
            }
            catch (Exception ex)
            {
                LoggerHelper.Error(ex.ToString());
                LoggerHelper.Error(JsonHelper.Entity2Json(reqst));
                res.code    = "500";
                res.message = Settings.Instance.GetErrorMsg(res.code);
                return(View(res));
            }
        }