public ReturnResult AddPolicy() { try { //var json = "{\"agentId\":\"56\",\"city\": \"苏州\", \"cityCode\": \"320500\", \"codeType\": \"geren\", \"codeTypeValue\": \"320723199601292415\", \"customerName\": \"袁连杰\",\"customerPhone\": \"18051803995\",\"insureListSelectedString\": \",交强险,不计免赔(责任免除) ,车船税,第三者责任险: 800万,盗抢险,车上人员(司机)责任保险,划痕险,玻璃单独破碎险,自燃险,车辆损失险,车上人员(乘客)责任保险,\", \"notifications\": \"000001\", \"textarea\": \"就这里吧\", \"timeEnd\": \"2019-09-11\", \"timeStarts\": \"2018-09-12\", \"_1_image_path\": \"http://localhost:52453/upload/20170912/105217105.jpg \", \"_2_image_path\": \"http://localhost:52453/upload/20170912/105217104.jpg \"}"; Models.PostAddPolicy model = Request.CZBParam <Models.PostAddPolicy>(); if (new Accounts().AddPolicy(model)) { return(new ReturnResult { code = ReturnCode.Success, data = "", desc = "请求成功" }); } else { return(new ReturnResult { code = ReturnCode.Error, data = "", desc = "请求失败" }); } } catch (Exception err) { return(new ReturnResult { code = ReturnCode.Error, data = "", desc = err.Message }); } }
/// <summary> /// 添加保单 /// </summary> /// <param name="postModel"></param> /// <returns></returns> public bool AddPolicy(Models.PostAddPolicy postModel) { Model.FX_Policy model = new Model.FX_Policy { AgentId = postModel.agentId.ToInt32(), CustomerName = postModel.customerName.Trim(), CustomerMoblie = postModel.customerPhone.Trim(), FX_PolicyNo = "FX" + Utils.GetOrderNumber(), StartTime = postModel.timeStarts.ToDateTime(), EndTime = postModel.timeEnd.ToDateTime(), DrivingLicensePic = postModel._1_image_path, CustomerIdPic = postModel._2_image_path, InsureCode = postModel.notifications, CityCode = postModel.cityCode, Remark = postModel.textarea, PolicyAmount = 0, CarRegisterDate = DateTime.Now, ComeFrom = 1, ////保单来源 UserId = 1, DrivingLicense = "", //数据库不允许null CreateTime = DateTime.Now, PolicyState = 1, OfferNum = 0, RejectNum = 0, PayState = 0, }; if (postModel.codeType == "geren") { model.CarType = 1; //身份证号 model.CustomerIdNo = postModel.codeTypeValue; } else { model.CarType = 2; //组织机构代码 model.OrganizationCode = postModel.codeTypeValue; } List <InsuranceDetail> insuranceList = ToInsuranceList(postModel.insureListSelectedString.Replace("万", "0000")); List <Model.FX_InsuranceType> insuranceTypeList = new BLL.FX_InsuranceType().GetAllList().Tables[0].ToEntityList <Model.FX_InsuranceType>(); List <Model.FX_PolicyDetail> policyDetailList = new List <Model.FX_PolicyDetail>(); foreach (InsuranceDetail insuranceDetail in insuranceList) { Model.FX_InsuranceType insuranceTypeInfo = insuranceTypeList.FirstOrDefault(exp => exp.InsuranceName == insuranceDetail.name); if (insuranceTypeInfo != null) { Model.FX_PolicyDetail fxdetial = new Model.FX_PolicyDetail(); fxdetial.InsuranceTypeId = insuranceTypeInfo.InsuranceTypeId; fxdetial.InsuranceTypeDetail = insuranceDetail.price > 0 ? insuranceDetail.price.ToStringEx() : ""; fxdetial.TotalAmount = 0; fxdetial.CreateTime = DateTime.Now; fxdetial.UpdateTime = DateTime.Now; fxdetial.IsUse = 1; policyDetailList.Add(fxdetial); } } #region 保险提成参数 try { model.PolicyInsurePara = GetPolicyInsurePara(model.InsureCode, model.CityCode); } catch { } #endregion if (new BLL.FX_Policy().AddPolicyList(model, policyDetailList)) { return(true); } return(false); }