public JiaMengShangInfo UpdateSingle(int id, JiaMengShangInfoReq data) { JiaMengShangInfo model = db.JiaMengShangInfo.Find(id); SetJiaMengShangInfo(model, data); db.SaveChanges(); return(model); }
void SetJMSShouKuanRule(JiaMengShangInfo model, int optId, string optName, string shoukuantype) { JMSShouKuanRule souKuanRule = new JMSShouKuanRule(); souKuanRule.JmsId = model.id; souKuanRule.Createtime = DateTime.Now; souKuanRule.JmsName = model.JmsName; souKuanRule.JmsClassName = model.JmsClassName; souKuanRule.OptId = optId; souKuanRule.OptName = optName; souKuanRule.State = "未收"; souKuanRule.ShouKuanType = shoukuantype;//"意向金"; souKuanRule.projectid = model.ProjectID; db.JMSShouKuanRule.Add(souKuanRule); }
/// <summary> /// 设置model,如果不为空就设置,如果为空则和之前一样 /// </summary> /// <param name="target"></param> /// <param name="source"></param> /// <returns></returns> public JiaMengShangInfo SetJiaMengShangInfo(JiaMengShangInfo model, JiaMengShangInfoReq data, int optId = 0, string optName = "") { if (!string.IsNullOrEmpty(data.JmsName)) { model.JmsName = data.JmsName; } if (!string.IsNullOrEmpty(data.JmsPhone)) { model.JmsPhone = data.JmsPhone; } if (data.JmsStateID != null) { model.JmsStateID = data.JmsStateID.Value; } if (data.JieDianTbStateID != null) { model.JieDianTbStateID = data.JieDianTbStateID.Value; } if (!string.IsNullOrEmpty(data.JmsQuDaoLaiYuan)) { model.JmsQuDaoLaiYuan = data.JmsQuDaoLaiYuan; } if (!string.IsNullOrEmpty(data.JmsWeiXinHao)) { model.JmsWeiXinHao = data.JmsWeiXinHao; } if (!string.IsNullOrEmpty(data.JmsMail)) { model.JmsMail = data.JmsMail; } if (!string.IsNullOrEmpty(data.JmsArea)) { model.JmsArea = data.JmsArea; } if (!string.IsNullOrEmpty(data.JmsAddress)) { model.JmsAddress = data.JmsAddress; } if (!string.IsNullOrEmpty(data.JmsConShiHangYe)) { model.JmsConShiHangYe = data.JmsConShiHangYe; } if (!string.IsNullOrEmpty(data.JmsGuDongGouCheng)) { model.JmsGuDongGouCheng = data.JmsGuDongGouCheng; } if (!string.IsNullOrEmpty(data.JmsYiXiang)) { model.JmsYiXiang = data.JmsYiXiang; } if (!string.IsNullOrEmpty(data.JmsHasWuYe)) { model.JmsHasWuYe = data.JmsHasWuYe; } if (!string.IsNullOrEmpty(data.JmsWuYeClass)) { model.JmsWuYeClass = data.JmsWuYeClass; } if (!string.IsNullOrEmpty(data.JmsWuYeQuYu)) { model.JmsWuYeQuYu = data.JmsWuYeQuYu; } if (!string.IsNullOrEmpty(data.JmsZiJinYuSuan)) { model.JmsZiJinYuSuan = data.JmsZiJinYuSuan; } if (!string.IsNullOrEmpty(data.JmsHeZuoModel)) { model.JmsHeZuoModel = data.JmsHeZuoModel; } if (!string.IsNullOrEmpty(data.JmsXiaoFeiLi)) { model.JmsXiaoFeiLi = data.JmsXiaoFeiLi; } if (!string.IsNullOrEmpty(data.JmsYZHSShuLiang)) { model.JmsYZHSShuLiang = data.JmsYZHSShuLiang; } if (!string.IsNullOrEmpty(data.JmsYZHSJunJia)) { model.JmsYZHSJunJia = data.JmsYZHSJunJia; } if (!string.IsNullOrEmpty(data.JmsYongYouZiYuan)) { model.JmsYongYouZiYuan = data.JmsYongYouZiYuan; } if (!string.IsNullOrEmpty(data.JmsVisitedXiXi)) { model.JmsVisitedXiXi = data.JmsVisitedXiXi; } if (!string.IsNullOrEmpty(data.optName)) { model.optName = data.optName; } if (!string.IsNullOrEmpty(data.JmsTelPhone)) { model.JmsTelPhone = data.JmsTelPhone; } if (!string.IsNullOrEmpty(data.JmsClassName)) { if (data.JmsClassName != model.JmsClassName) { //更新加盟商类型时新增 收款规则 //先删除之前的 var toRemove = db.JMSShouKuanRule.Where(rule => rule.JmsId == model.id); db.JMSShouKuanRule.RemoveRange(toRemove); model.JmsClassName = data.JmsClassName; if (data.JmsClassName.IndexOf("品牌加盟") >= 0 || data.JmsClassName.IndexOf("委托管理") >= 0) { //品牌加盟和委托管理类的加盟商自动生成意向金、尾款、保证金和管理费四类收款 SetJMSShouKuanRule(model, optId, optName, "意向金"); SetJMSShouKuanRule(model, optId, optName, "尾款"); SetJMSShouKuanRule(model, optId, optName, "保证金"); SetJMSShouKuanRule(model, optId, optName, "管理费"); } else if (data.JmsClassName.IndexOf("技术加盟") >= 0) { //技术加盟类的加盟商自动生成意向金和尾款两类收款 SetJMSShouKuanRule(model, optId, optName, "意向金"); SetJMSShouKuanRule(model, optId, optName, "尾款"); } } } if (!string.IsNullOrEmpty(data.JmsCity)) { model.JmsCity = data.JmsCity; } if (!string.IsNullOrEmpty(data.JmsProvince)) { model.JmsProvince = data.JmsProvince; } if (!string.IsNullOrEmpty(data.JmsHasVisitOther)) { model.JmsHasVisitOther = data.JmsHasVisitOther; } if (data.SaleId != null) { model.SaleId = data.SaleId; } if (!string.IsNullOrEmpty(data.SaleName)) { model.SaleName = data.SaleName; } if (data.optDateTime != null && data.optDateTime != DateTime.MinValue && data.optDateTime != SqlDateTime.MinValue.Value) { model.optDateTime = data.optDateTime.Value; } return(model); }