Пример #1
0
        public IActionResult CreateAll(InputAllDataModel model)
        {
            if (!model.AgreeToInformationAuthorization || !model.AgreeToServiceAuthorization)
            {
                return(View("CreateErr", new ErrorViewModel()
                {
                    RequestId = "您没有同意服务和信息授权,请退出。"
                }));
            }
            //if (!ModelState.IsValid)
            //{
            //    // work with the model
            //    return View("CreateErr", new ErrorViewModel() { RequestId = "数据缺失请回退。" });
            //}
            if (model.ExpectedLoanTime == null)
            {
                return(View("CreateErr", new ErrorViewModel()
                {
                    RequestId = "期望放款时间缺失请回退。"
                }));
            }
            DateTime dateTime = DateTime.Now;
            Customer customer = _customerService.GetCustomerByIDNumber(model.IDNumber);

            if (customer == null)
            {
                customer = new Customer()
                {
                    Avatar       = "",
                    CreatedOn    = dateTime,
                    CustomerName = model.CustomerName,
                    Fever        = 0,
                    IDNumber     = model.IDNumber,
                    IsDeleted    = false,
                    LoginName    = model.PhoneNumber,
                    CPassword    = "******",
                    PhoneNumber  = model.PhoneNumber,
                    Salt         = "0000"
                };
                _customerService.InsertCustomer(customer);
            }
            CustomerExpectation customerExpectation = new CustomerExpectation()
            {
                CreatedOn               = dateTime,
                CustomerId              = customer.Id,
                CustomerTypeId          = (int)model.customerType,
                ExpectedLoanAmount      = model.ExpectedLoanAmount,
                ExpectedLoanTime        = model.ExpectedLoanTime,
                WorkingAddress          = model.WorkingAddress,
                HavingCreditCardCarLoan = model.HavingCreditCardCarLoan,
                HavingLifeInsurance     = model.HavingLifeInsurance,
                HavingRealEstate        = model.HavingRealEstate
            };

            _customerExpectationService.InsertCustomerExpectation(customerExpectation);
            if (model.HavingCreditCardCarLoan)
            {
                CCreditCardCarLoan cCreditCardCarLoan = new CCreditCardCarLoan()
                {
                    CustomerExpectationId = customerExpectation.Id,
                    CreatedOn             = dateTime,
                    MonthlyAmount         = model.CCLMonthlyAmount,
                    NumberOfRepaymentsCC  = model.NumberOfRepaymentsCC
                };
                _customerExpectationService.InsertCCreditCardCarLoan(cCreditCardCarLoan);
            }


            if (model.HavingLifeInsurance)
            {
                List <CLifeInsurance> cLives          = new List <CLifeInsurance>();
                CLifeInsurance        cLifeInsurance0 = new CLifeInsurance()
                {
                    CustomerExpectationId = customerExpectation.Id,
                    CreatedOn             = dateTime,
                    AnnualPremium         = model.AnnualPremium0,
                    EarliestEffectiveTime = model.EarliestEffectiveTime0,
                    LifeInsuranceCompany  = model.LifeInsuranceCompany0
                };
                cLives.Add(cLifeInsurance0);
                if (model.AnnualPremium1 > 0.0M)
                {
                    CLifeInsurance cLifeInsurance1 = new CLifeInsurance()
                    {
                        CustomerExpectationId = customerExpectation.Id,
                        CreatedOn             = dateTime,
                        AnnualPremium         = model.AnnualPremium1,
                        EarliestEffectiveTime = model.EarliestEffectiveTime1,
                        LifeInsuranceCompany  = model.LifeInsuranceCompany1
                    };
                    cLives.Add(cLifeInsurance1);
                }
                if (model.AnnualPremium2 > 0.0M)
                {
                    CLifeInsurance cLifeInsurance2 = new CLifeInsurance()
                    {
                        CustomerExpectationId = customerExpectation.Id,
                        CreatedOn             = dateTime,
                        AnnualPremium         = model.AnnualPremium2,
                        EarliestEffectiveTime = model.EarliestEffectiveTime2,
                        LifeInsuranceCompany  = model.LifeInsuranceCompany2
                    };
                    cLives.Add(cLifeInsurance2);
                }
                _customerExpectationService.InsertCLifeInsurances(cLives);
            }
            if (model.HavingRealEstate)
            {
                bool needRepay = true;
                if (model.realEstateLoanType == Models.Enum.RealEstateLoanType.全款)
                {
                    needRepay = false;
                }
                CRealEstate cRealEstate = new CRealEstate()
                {
                    CustomerExpectationId = customerExpectation.Id,
                    BankName           = model.BankName,
                    ConstructionArea   = model.ConstructionArea,
                    CreatedOn          = dateTime,
                    LoanTypeId         = (int)model.realEstateLoanType,
                    MonthlyPayment     = needRepay?model.MonthlyPayment:0,
                    NumberOfRepayments = needRepay?model.NumberOfRepayments:0,
                    PropertyNatureId   = (int)model.realEstatePropertyNature,
                    RealEstateAddress  = model.RealEstateAddress,
                    RealEstateValue    = model.RealEstateValue
                };
                if (model.realEstateLoanType == Models.Enum.RealEstateLoanType.全款)
                {
                    cRealEstate.BankName           = "";
                    cRealEstate.MonthlyPayment     = 0;
                    cRealEstate.NumberOfRepayments = 0;
                }
                _customerExpectationService.InsertCRealEstate(cRealEstate);
            }

            if (model.customerType == Models.Enum.CustomerType.班)
            {
                CustomerHired customerHired = new CustomerHired()
                {
                    CustomerExpectationId = customerExpectation.Id,
                    CompanyName           = model.CompanyName,
                    CreatedOn             = dateTime,
                    HavingSIHF            = model.HavingSIHF,
                    HousingFundBase       = model.HousingFundBase,
                    SalaryAfterTax        = model.SalaryAfterTax,
                    SocialInsuranceBase   = model.SocialInsuranceBase
                };
                _customerExpectationService.InsertCustomerHired(customerHired);
            }
            else if (model.customerType == Models.Enum.CustomerType.自雇)
            {
                CustomerSelfEmployed customerSelfEmployed = new CustomerSelfEmployed()
                {
                    CustomerExpectationId  = customerExpectation.Id,
                    CreatedOn              = dateTime,
                    CompanyName            = model.CompanyName,
                    AnnualTaxAmount        = model.AnnualTaxAmount,
                    AnnualTurnover         = model.AnnualTurnover,
                    AnnualVATInvoiceAmount = model.AnnualVATInvoiceAmount
                };
                _customerExpectationService.InsertCustomerSelfEmployed(customerSelfEmployed);
            }

            return(Redirect("http://u.vivatech.cn/h/6601"));
        }
Пример #2
0
 public void InsertCRealEstate(CRealEstate cRealEstate)
 {
     _cRealEstateRepository.Insert(cRealEstate);
     _mysqlContext.SaveChanges();
 }