/// <summary> /// 删除服务包相关,不能删除时,返回所有不能删除相关对象数量 /// </summary> public bool DeleteServiceBundle(long serviceId, long userId, ref string faileReason) { try { var isbDal = new ivt_service_bundle_dal(); var thisSerBundle = isbDal.FindNoDeleteById(serviceId); if (thisSerBundle == null) { return(true); } var conSerList = new ctt_contract_service_dal().getContractByServiceId(thisSerBundle.id); if (conSerList != null && conSerList.Count > 0) { faileReason += $"{conSerList.Count} 合同\n"; } var quoteItemList = new crm_quote_item_dal().GetItemByObjId(thisSerBundle.id); if (quoteItemList != null && quoteItemList.Count > 0) { faileReason += $"{quoteItemList.Count} 报价项\n"; } var labourList = new sdk_work_entry_dal().GetListByService(thisSerBundle.id); if (labourList != null && labourList.Count > 0) { faileReason += $"{labourList.Count} 工时\n"; } var insProList = new crm_installed_product_dal().GetInsListBySerBunId(thisSerBundle.id); if (insProList != null && insProList.Count > 0) { faileReason += $"{insProList.Count} 配置项\n"; } if (!string.IsNullOrEmpty(faileReason)) { return(false); } else { var isbsDal = new ivt_service_bundle_service_dal(); var serList = GetServiceListByServiceBundleId(thisSerBundle.id); if (serList != null && serList.Count > 0) { serList.ForEach(_ => { isbsDal.Delete(_); }); } isbDal.SoftDelete(thisSerBundle, userId); OperLogBLL.OperLogDelete <ivt_service_bundle>(thisSerBundle, thisSerBundle.id, userId, DTO.DicEnum.OPER_LOG_OBJ_CATE.IVT_SERVICE_BUNDLE, "删除服务包"); } } catch (Exception) { return(false); } return(true); }
void GetQuoteItem(HttpContext context) { var quoteItemId = context.Request.QueryString["quoteItemId"]; if (!string.IsNullOrEmpty(quoteItemId)) { var item = new crm_quote_item_dal().FindNoDeleteById(long.Parse(quoteItemId)); if (item != null) { WriteResponseJson(item); } } }
/// <summary> /// 批量新增产品相关报价项 /// </summary> public void AddQuoteItemByProduct(HttpContext context, string ids, int quote_id) { if (!string.IsNullOrEmpty(ids)) { var itemDal = new crm_quote_item_dal(); var productIds = ids.Split(new Char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); foreach (var productId in productIds) { var product = new ProductBLL().GetProduct(long.Parse(productId)); if (product != null) { crm_quote_item thisQuoteItem = new crm_quote_item() { id = itemDal.GetNextIdCom(), name = product.name, type_id = (int)DTO.DicEnum.QUOTE_ITEM_TYPE.PRODUCT, object_id = product.id, description = product.description, unit_price = product.unit_price, unit_cost = product.unit_cost, unit_discount = 0, quantity = 1, quote_id = quote_id, period_type_id = product.period_type_id, create_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now), create_user_id = LoginUserId, update_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now), update_user_id = LoginUserId, optional = 0, }; itemDal.Insert(thisQuoteItem); new sys_oper_log_dal().Insert(new sys_oper_log() { user_cate = "用户", user_id = (int)LoginUserId, name = LoginUser.name, phone = LoginUser.mobile, oper_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now), oper_object_cate_id = (int)OPER_LOG_OBJ_CATE.QUOTE_ITEM, oper_object_id = thisQuoteItem.id,// 操作对象id oper_type_id = (int)OPER_LOG_TYPE.ADD, oper_description = itemDal.AddValue(thisQuoteItem), remark = "添加报价项", }); } } context.Response.Write("true"); } else { context.Response.Write("false"); } }
/// <summary> /// 判断报价是否含有初始费用报价项,有返回,没有返回空 /// </summary> public void ReturnStart(HttpContext context, long quote_id) { var thisQuoteItem = new crm_quote_item_dal().GetStartItem(quote_id); if (thisQuoteItem != null) { context.Response.Write(new EMT.Tools.Serialize().SerializeJson(thisQuoteItem)); } else { } }
/// <summary> /// 删除报价 /// </summary> /// <param name="quote_id"></param> /// <param name="user_id"></param> /// <returns></returns> public bool DeleteQuote(long quote_id, long user_id) { // todo 报价如果关联了销售订单,则不可删除 var quote = _dal.GetQuote(quote_id); if (quote != null) { var user = UserInfoBLL.GetUserInfo(user_id); if (user != null) { quote.delete_user_id = user_id; quote.delete_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now); _dal.Update(quote); new sys_oper_log_dal().Insert(new sys_oper_log() { user_cate = "用户", user_id = (int)user.id, name = user.name, phone = user.mobile == null ? "" : user.mobile, oper_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now), oper_object_cate_id = (int)OPER_LOG_OBJ_CATE.QUOTE, oper_object_id = quote.id,// 操作对象id oper_type_id = (int)OPER_LOG_TYPE.DELETE, oper_description = _dal.AddValue(quote), remark = "删除报价" }); var quoteItemList = new crm_quote_item_dal().GetQuoteItems(" and quote_id = " + quote.id); // 删除报价的同时,删除报价下的所有报价项 if (quoteItemList != null && quoteItemList.Count > 0) { var quoteItemBLL = new QuoteItemBLL(); quoteItemList.ForEach(_ => { //_.delete_user_id = user_id; //_.delete_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now); quoteItemBLL.DeleteQuoteItem(_.id, user.id); }); } return(true); } } return(false); }
protected Dictionary <long, string> serviceList = new Dictionary <long, string>(); // 所有的相同的服务 protected void Page_Load(object sender, EventArgs e) { try { var quote_id = Request.QueryString["quote_id"]; var contract_id = Request.QueryString["contract_id"]; if ((!string.IsNullOrEmpty(quote_id)) && (!string.IsNullOrEmpty(contract_id))) { var itemList = new crm_quote_item_dal().GetQuoteItems($" and quote_id={quote_id}"); var conSerList = new ctt_contract_service_dal().GetConSerList(long.Parse(contract_id)); if (itemList != null && itemList.Count > 0 && conSerList != null && conSerList.Count > 0) { conSerList.ForEach(conser => { if (itemList.Any(_ => _.object_id == conser.object_id)) { if (serviceList.Count > 0) { if (!serviceList.Any(ser => ser.Key == conser.object_id)) // { serviceList.Add(conser.object_id, isServiceOrBag(conser.object_id)); } } else { serviceList.Add(conser.object_id, isServiceOrBag(conser.object_id)); } } }); } else { Response.End(); } } else { Response.End(); } } catch (Exception msg) { Response.End(); } }
/// <summary> /// 判断报价是否包含初始费 并且 合同中是否也有初始费用 /// </summary> /// <param name="context"></param> /// <param name="quote_id"></param> /// <param name="contract_id"></param> public void CompareSetupFee(HttpContext context, long quote_id, long contract_id) { var quote = new QuoteBLL().GetQuote(quote_id); var contract = new ctt_contract_dal().GetSingleContract(contract_id); bool isHasSetupFee = false; if (quote != null && contract != null) { var quoteItemList = new crm_quote_item_dal().GetQuoteItems($" and quote_id = {quote.id}"); if (quoteItemList != null && quoteItemList.Count > 0) { var setupFeeItem = quoteItemList.Where(_ => _.type_id == (int)QUOTE_ITEM_TYPE.START_COST).ToList(); if (setupFeeItem != null && setupFeeItem.Count > 0 && contract.setup_fee != null) { isHasSetupFee = true; } } } context.Response.Write(isHasSetupFee); }
/// <summary> /// 报价是否可以进行关闭报价操作 /// </summary> public bool CanCloseQuote(long quote_id, out string reason) { reason = ""; bool result = true; try { var thisQuote = _dal.FindNoDeleteById(quote_id); if (thisQuote != null) { if (thisQuote.is_primary_quote != 1) { reason = "该报价不是主报价"; return(false); } var thisQuoItemList = new crm_quote_item_dal().GetQuoteItems($"and quote_id = {quote_id}"); if (thisQuoItemList != null && thisQuoItemList.Count > 0) { var serItemList = thisQuoItemList.Where(_ => _.type_id == (int)EMT.DoneNOW.DTO.DicEnum.QUOTE_ITEM_TYPE.SERVICE || _.type_id == (int)EMT.DoneNOW.DTO.DicEnum.QUOTE_ITEM_TYPE.START_COST).ToList(); if (serItemList != null && serItemList.Count > 0) { reason = "报价中包含服务/包、初始费用等"; return(false); } } else { result = true; } } else { reason = "没有找到该报价"; } } catch (Exception msg) { return(false); } return(result); }
/// <summary> /// 判断报价和合同是否有重复的服务 /// </summary> /// <param name="context"></param> /// <param name="quote_id"></param> /// <param name="contract_id"></param> public void CompareService(HttpContext context, long quote_id, long contract_id) { var quote = new QuoteBLL().GetQuote(quote_id); var conSerList = new ctt_contract_service_dal().GetConSerList(contract_id); bool isHasService = false; if (quote != null && conSerList != null && conSerList.Count>0) { var quoteItemList = new crm_quote_item_dal().GetQuoteItems($" and quote_id = {quote.id}"); if (quoteItemList != null && quoteItemList.Count > 0) { var serviceItem = quoteItemList.Where(_ => _.type_id == (int)QUOTE_ITEM_TYPE.SERVICE).ToList(); if(conSerList.Any(_=> serviceItem.Any(item => item.object_id == _.object_id))) { isHasService = true; } } } context.Response.Write(isHasService); }
/// <summary> /// 商机计算 /// </summary> private void GetQuoteItemMoney(HttpContext context, long oid) { var oppo = new crm_opportunity_dal().FindNoDeleteById(oid); if (oppo != null) { // 将一次性,按月,季度,赋值之后 , 需要将配送的金额和折扣的金额 存储之后计算 var priQuote = new crm_quote_dal().GetPriQuote(oid); if (priQuote != null) { decimal oneTimeRevenue = 0; decimal oneTimeCost = 0; decimal monthRevenue = 0; decimal monthCost = 0; decimal quarterRevenue = 0; decimal quarterCost = 0; decimal halfRevenue = 0; decimal halfCost = 0; decimal yearRevenue = 0; decimal yearCost = 0; decimal shipRevenue = 0; decimal shipCost = 0; decimal discount = 0; var itemList = new crm_quote_item_dal().GetAllQuoteItem(priQuote.id); if (itemList != null && itemList.Count > 0) { var thisItem = itemList.Where(_ => _.type_id != (int)EMT.DoneNOW.DTO.DicEnum.QUOTE_ITEM_TYPE.DISTRIBUTION_EXPENSES && _.optional != 1 && _.type_id != (int)DTO.DicEnum.QUOTE_ITEM_TYPE.DISCOUNT).ToList(); var shipList = itemList.Where(_ => _.type_id == (int)DTO.DicEnum.QUOTE_ITEM_TYPE.DISTRIBUTION_EXPENSES && _.optional == 0).ToList(); // 配送类型的报价项 var thisOneTimeList = itemList.Where(_ => _.period_type_id == (int)DTO.DicEnum.QUOTE_ITEM_PERIOD_TYPE.ONE_TIME && _.optional == 0 && _.type_id != (int)DTO.DicEnum.QUOTE_ITEM_TYPE.DISCOUNT && _.type_id != (int)DTO.DicEnum.QUOTE_ITEM_TYPE.DISTRIBUTION_EXPENSES).ToList(); var discountQIList = itemList.Where(_ => _.type_id == (int)DTO.DicEnum.QUOTE_ITEM_TYPE.DISCOUNT && _.optional == 0).ToList(); if (shipList != null && shipList.Count > 0) { var totalPrice = shipList.Sum(_ => (_.unit_discount != null && _.unit_price != null && _.quantity != null) ? (_.unit_price - _.unit_discount) * _.quantity : 0); shipRevenue = (decimal)totalPrice; var totalCost = shipList.Sum(_ => (_.unit_cost != null && _.quantity != null) ? _.unit_cost * _.quantity : 0); shipCost = (decimal)totalCost; } if (discountQIList != null && discountQIList.Count > 0) { var totalPrice = (discountQIList.Where(_ => _.discount_percent == null).ToList().Sum(_ => (_.unit_discount != null && _.quantity != null) ? _.unit_discount * _.quantity : 0) + (thisOneTimeList != null && thisOneTimeList.Count > 0 ? discountQIList.Where(_ => _.discount_percent != null).ToList().Sum(_ => thisOneTimeList.Sum(one => (one.unit_discount != null && one.unit_price != null && one.quantity != null) ? (one.unit_price - one.unit_discount) * one.quantity : 0) * _.discount_percent * 100 / 100) : 0)); discount = (decimal)totalPrice; } if (thisItem != null && thisItem.Count > 0) { var oneTimeList = thisItem.Where(_ => _.period_type_id == (int)DTO.DicEnum.QUOTE_ITEM_PERIOD_TYPE.ONE_TIME).ToList(); var monthList = thisItem.Where(_ => _.period_type_id == (int)DTO.DicEnum.QUOTE_ITEM_PERIOD_TYPE.MONTH).ToList(); var quarterList = thisItem.Where(_ => _.period_type_id == (int)DTO.DicEnum.QUOTE_ITEM_PERIOD_TYPE.QUARTER).ToList(); var halfList = thisItem.Where(_ => _.period_type_id == (int)DTO.DicEnum.QUOTE_ITEM_PERIOD_TYPE.HALFYEAR).ToList(); var yearList = thisItem.Where(_ => _.period_type_id == (int)DTO.DicEnum.QUOTE_ITEM_PERIOD_TYPE.YEAR).ToList(); if (oneTimeList != null && oneTimeList.Count > 0) { oneTimeRevenue = (decimal)oneTimeList.Sum(_ => (_.unit_price != null && _.quantity != null) ? (((_.unit_price ?? 0) - (_.unit_discount ?? 0)) * _.quantity) : 0); oneTimeCost = (decimal)oneTimeList.Sum(_ => (_.unit_cost != null && _.quantity != null) ? (_.unit_cost * _.quantity) : 0); } if (monthList != null && monthList.Count > 0) { monthRevenue = (decimal)monthList.Sum(_ => (_.unit_price != null && _.quantity != null) ? (((_.unit_price ?? 0) - (_.unit_discount ?? 0)) * _.quantity) : 0); monthCost = (decimal)monthList.Sum(_ => (_.unit_cost != null && _.quantity != null) ? (_.unit_cost * _.quantity) : 0); } if (quarterList != null && quarterList.Count > 0) { quarterRevenue = (decimal)quarterList.Sum(_ => (_.unit_price != null && _.quantity != null) ? (((_.unit_price ?? 0) - (_.unit_discount ?? 0)) * _.quantity) : 0); quarterCost = (decimal)quarterList.Sum(_ => (_.unit_cost != null && _.quantity != null) ? (_.unit_cost * _.quantity) : 0); } if (halfList != null && halfList.Count > 0) { halfRevenue = (decimal)halfList.Sum(_ => (_.unit_price != null && _.quantity != null) ? (((_.unit_price ?? 0) - (_.unit_discount ?? 0)) * _.quantity) : 0); halfCost = (decimal)halfList.Sum(_ => (_.unit_cost != null && _.quantity != null) ? (_.unit_cost * _.quantity) : 0); } if (yearList != null && yearList.Count > 0) { yearRevenue = (decimal)yearList.Sum(_ => (_.unit_price != null && _.quantity != null) ? (((_.unit_price ?? 0) - (_.unit_discount ?? 0)) * _.quantity) : 0); yearCost = (decimal)yearList.Sum(_ => (_.unit_cost != null && _.quantity != null) ? (_.unit_cost * _.quantity) : 0); } } } context.Response.Write(new EMT.Tools.Serialize().SerializeJson(new { oneTimeRevenue = oneTimeRevenue, oneTimeCost = oneTimeCost, monthRevenue = monthRevenue, monthCost = monthCost, quarterRevenue = quarterRevenue, quarterCost = quarterCost, halfRevenue = halfRevenue, halfCost = halfCost, yearRevenue = yearRevenue, yearCost = yearCost, shipRevenue = shipRevenue, shipCost = shipCost, discount = discount })); } } // quoteItemList.Where(_ => _.type_id != (int)EMT.DoneNOW.DTO.DicEnum.QUOTE_ITEM_TYPE.DISTRIBUTION_EXPENSES && _.optional != 1&&_.type_id != (int)DTO.DicEnum.QUOTE_ITEM_TYPE.DISCOUNT).ToList(); }
protected void Page_Load(object sender, EventArgs e) { var quote_id = Request.QueryString["quote_id"]; if (!string.IsNullOrEmpty(quote_id)) { quote = new crm_quote_dal().FindNoDeleteById(long.Parse(quote_id)); } if (quote != null) { // 如何获取到已经生成配置项 的报价项和为生成配置项的报价项 // 1 获取产品相关报价项 // 2 根据产品报价项的数量,去获取相应的配置项数量,数量不足时,将剩余的报价项放入展示的报价项中 // 3 成本同理 var cqiDal = new crm_quote_item_dal(); var cipDal = new crm_installed_product_dal(); #region 获取相应的产品报价项 var productList = cqiDal.GetItemByType(quote.id, (int)DTO.DicEnum.QUOTE_ITEM_TYPE.PRODUCT); if (productList != null && productList.Count > 0) { isShowProduct = true; foreach (var item in productList) { if (item.quantity != null && item.quote_id != null) { var insProList = cipDal.GetInsProByQuoteId((long)item.id, (long)item.quantity); int num = (int)item.quantity; // 获取多少次 这个报价项 if (insProList != null && insProList.Count > 0) { num = (int)item.quantity - insProList.Count; var itemList = cqiDal.GetItemByNum(item.id, insProList.Count); if (itemList != null && itemList.Count > 0) { ExistProductItemList.AddRange(itemList); } } if (num > 0) { var itemList = cqiDal.GetItemByNum(item.id, num); if (itemList != null && itemList.Count > 0) { productItemList.AddRange(itemList); } } } } } #endregion #region 获取相应的成本报价项 var chargeList = cqiDal.GetItemByType(quote.id, (int)DTO.DicEnum.QUOTE_ITEM_TYPE.DEGRESSION); if (chargeList != null && chargeList.Count > 0) { isShowCharge = true; foreach (var item in chargeList) { if (item.quantity != null && item.quote_id != null) { var insProList = cipDal.GetInsProByQuoteId((long)item.id, (long)item.quantity); int num = (int)item.quantity; // 获取多少次 这个报价项 if (insProList != null && insProList.Count > 0) { num = (int)item.quantity - insProList.Count; var itemList = cqiDal.GetItemByNum(item.id, insProList.Count); if (itemList != null && itemList.Count > 0) { ExistChargeItemList.AddRange(itemList); } } if (num > 0) { var itemList = cqiDal.GetItemByNum(item.id, num); if (itemList != null && itemList.Count > 0) { chargeItemList.AddRange(itemList); } } } } } #endregion if (!IsPostBack) { rbBuyDate.Enabled = false; } } }
protected void Page_Load(object sender, EventArgs e) { try { thisBookMark = new IndexBLL().GetSingBook(Request.RawUrl, LoginUserId); // quote_group_by groupBy.DataTextField = "show"; groupBy.DataValueField = "val"; groupBy.DataSource = dic.FirstOrDefault(_ => _.Key == "quote_group_by").Value; groupBy.DataBind(); isShow = Request.QueryString["isShow"]; IssaleOrder = !string.IsNullOrEmpty(Request.QueryString["isSaleOrder"]); var sid = Request.QueryString["sale_order_id"]; if (!string.IsNullOrEmpty(sid)) { sale_order_id = long.Parse(sid); } var quote_id = Request.QueryString["quote_id"]; if (!string.IsNullOrEmpty(quote_id)) { quote = new QuoteBLL().GetQuote(Convert.ToInt64(quote_id)); if (quote.quote_tmpl_id != null) { var sys_quote_temp = new QuoteTemplateBLL().GetQuoteTemplate((long)quote.quote_tmpl_id); if (sys_quote_temp != null) { // 获取到该报价的报价模板用于设置税的显示方式和汇总名称 show_each_tax_in_tax_group.Value = sys_quote_temp.show_each_tax_in_tax_group.ToString(); show_each_tax_in_tax_period.Value = sys_quote_temp.show_each_tax_in_tax_period.ToString(); // 选中第一个:按照周期分组时起作用,每个周期后显示税 最后的汇总也有税) // var a3 =sys_quote_temp.show_labels_when_grouped; // 预留字段 show_tax_cate.Value = sys_quote_temp.show_tax_cate.ToString(); show_tax_cate_superscript.Value = sys_quote_temp.show_tax_cate_superscript.ToString(); } } } var opportunity_id = Request.QueryString["opportunity_id"]; // 这里是通过商机查看报价项的情况 if (!string.IsNullOrEmpty(opportunity_id)) { var oppoQuoteList = new crm_quote_dal().GetQuoteByWhere($" and opportunity_id = {opportunity_id} "); if (oppoQuoteList != null && oppoQuoteList.Count > 0) { quote = oppoQuoteList.FirstOrDefault(_ => _.is_primary_quote == 1); // 如果该商机下有报价则一定会有主报价 } } if (quote != null) { quoteItemList = new crm_quote_item_dal().GetQuoteItems($" and quote_id={quote.id} "); // quoteItemList.Sort(SortCycle); // 自定义排序测试 quoteItemList = quoteItemList.OrderBy(_ => SortQuoteItem(_.period_type_id)).ToList(); quoteList = new crm_quote_dal().GetQuoteByWhere($" and opportunity_id = {quote.opportunity_id} "); var primaryQuote = quoteList.FirstOrDefault(_ => _.is_primary_quote == 1); if (primaryQuote != null) { var thisQuoteItemList = new crm_quote_item_dal().GetQuoteItems($" and quote_id={primaryQuote.id} "); var thisDiscountQIList = thisQuoteItemList.Where(_ => _.type_id == (int)DTO.DicEnum.QUOTE_ITEM_TYPE.DISCOUNT && _.optional == 0).ToList(); var thisOneTimeQTList = thisQuoteItemList.Where(_ => _.period_type_id == (int)DTO.DicEnum.QUOTE_ITEM_PERIOD_TYPE.ONE_TIME && _.optional == 0).ToList(); var thisOptionalItemList = thisQuoteItemList.Where(_ => _.optional == 1).ToList(); var totalPrice = ((decimal)((thisQuoteItemList.Sum(_ => (_.unit_discount != null && _.unit_price != null && _.quantity != null) ? (_.unit_price - _.unit_discount) * _.quantity : 0) - thisDiscountQIList.Where(_ => _.discount_percent != null).ToList().Sum(_ => (_.unit_discount != null && _.quantity != null) ? _.unit_discount * _.quantity : 0) - (thisOneTimeQTList != null && thisOneTimeQTList.Count > 0 ? thisDiscountQIList.Where(_ => _.discount_percent != null).ToList().Sum(_ => thisOneTimeQTList.Sum(one => (one.unit_discount != null && one.unit_price != null && one.quantity != null) ? (one.unit_price - one.unit_discount) * one.quantity : 0) * _.discount_percent) : 0)))).ToString("#0.00"); quoteList.Remove(primaryQuote); primaryQuote.name = "PRIMARY:" + primaryQuote.name + "(" + totalPrice + ")"; quoteList.Add(primaryQuote); } #region // 为报价下拉框赋值 quoteDropList.DataValueField = "id"; quoteDropList.DataTextField = "name"; quoteDropList.DataSource = quoteList; quoteDropList.DataBind(); quoteDropList.SelectedValue = quote.id.ToString(); #endregion if (quoteItemList != null && quoteItemList.Count > 0) { // 用户需要添加折扣类型的报价项,然后可以针对付费周期类型为一次性的报价项进行折扣 // 折扣只针对一次性周期的报价项折扣 oneTimeList = quoteItemList.Where(_ => _.period_type_id == (int)DTO.DicEnum.QUOTE_ITEM_PERIOD_TYPE.ONE_TIME && _.optional == 0 && _.type_id != (int)DTO.DicEnum.QUOTE_ITEM_TYPE.DISCOUNT && _.type_id != (int)DTO.DicEnum.QUOTE_ITEM_TYPE.DISTRIBUTION_EXPENSES).ToList(); discountQIList = quoteItemList.Where(_ => _.type_id == (int)DTO.DicEnum.QUOTE_ITEM_TYPE.DISCOUNT && _.optional == 0).ToList(); // 获取到可选的报价项, optionalItemList = quoteItemList.Where(_ => _.optional == 1).ToList(); // 获取到可选的报价项 // optionalItemList.Sort(); // &&optionalItemList.Any(op=>op.id!=_.id)&&oneTimeList.Any(one=>one.id!=_.id) 满足多个报价项过滤条件的,选择其中的一个 distributionList = quoteItemList.Where(_ => _.type_id == (int)DTO.DicEnum.QUOTE_ITEM_TYPE.DISTRIBUTION_EXPENSES && _.optional == 0).ToList(); // 配送类型的报价项 // 配送,一次性,可选的配置项独立显示,所以在这里分离出来,传到前台后单独处理 // 获取到筛选后报价项列表方便分组管理 筛选后的列表不包括可选,一次性的折扣和配送 var screenList = quoteItemList.Where(_ => _.type_id != (int)EMT.DoneNOW.DTO.DicEnum.QUOTE_ITEM_TYPE.DISTRIBUTION_EXPENSES && _.optional != 1 && _.type_id != (int)DTO.DicEnum.QUOTE_ITEM_TYPE.DISCOUNT).ToList(); if (!string.IsNullOrEmpty(Request.QueryString["group_by"])) { groupByType = Request.QueryString["group_by"]; } else { if (quote.group_by_id != null) { groupByType = ((long)quote.group_by_id).ToString(); } } // groupByType = ?((long)quote.group_by_id).ToString():Request.QueryString["group_by"]; if (groupByType == ((int)EMT.DoneNOW.DTO.DicEnum.QUOTE_GROUP_BY.CYCLE).ToString()) // 按周期分组 { groupList = screenList.GroupBy(_ => _.period_type_id == null ? "" : _.period_type_id.ToString()).ToDictionary(_ => (object)_.Key, _ => _.ToList()); // as Dictionary<long?, new QuoteBLL().UpdateGroup(quote.id, (int)QUOTE_GROUP_BY.CYCLE, GetLoginUserId()); groupBy.SelectedValue = ((int)QUOTE_GROUP_BY.CYCLE).ToString(); } else if (groupByType == ((int)QUOTE_GROUP_BY.PRODUCT).ToString()) // 按产品分组 { groupList = screenList.GroupBy(_ => _.object_id == null ? "" : ReturnProductID((long)_.object_id)).ToDictionary(_ => (object)_.Key, _ => _.ToList()); new QuoteBLL().UpdateGroup(quote.id, (int)QUOTE_GROUP_BY.PRODUCT, GetLoginUserId()); groupBy.SelectedValue = ((int)QUOTE_GROUP_BY.PRODUCT).ToString(); } else if (groupByType == ((int)QUOTE_GROUP_BY.CYCLE_PRODUCT).ToString()) // 按周期产品分组 { new QuoteBLL().UpdateGroup(quote.id, (int)QUOTE_GROUP_BY.CYCLE_PRODUCT, GetLoginUserId()); groupBy.SelectedValue = ((int)QUOTE_GROUP_BY.CYCLE_PRODUCT).ToString(); doubleGroupList = screenList.GroupBy(d => d.period_type_id == null ? "" : d.period_type_id.ToString()).ToDictionary(_ => (object)_.Key, _ => _.ToList().GroupBy(d => d.object_id == null ? "" : ReturnProductID((long)d.object_id)).ToDictionary(d => (object)d.Key, d => d.ToList())); } else if (groupByType == ((int)QUOTE_GROUP_BY.PRODUCT_CYCLE).ToString()) // 按产品周期分组 { new QuoteBLL().UpdateGroup(quote.id, (int)QUOTE_GROUP_BY.PRODUCT_CYCLE, GetLoginUserId()); groupBy.SelectedValue = ((int)QUOTE_GROUP_BY.PRODUCT_CYCLE).ToString(); doubleGroupList = screenList.GroupBy(_ => _.object_id == null ? "" : ReturnProductID((long)_.object_id)).ToDictionary(_ => (object)_.Key, _ => _.ToList().GroupBy(d => d.period_type_id == null ? "" : d.period_type_id.ToString()).ToDictionary(d => (object)d.Key, d => d.ToList())); } else // 不分组 { new QuoteBLL().UpdateGroup(quote.id, (int)QUOTE_GROUP_BY.NO, GetLoginUserId()); groupBy.SelectedValue = ((int)QUOTE_GROUP_BY.NO).ToString(); } //switch (groupByType) //{ // case "cycle": // // 按照周期分组 // break; // case "product": // break; // default: // groupByType = "no"; // break; //} // ClientScript.RegisterStartupScript(this.GetType(), "提示信息", "<script> $(\"#groupBy\").val('"+groupBy+"')</script>"); if (discountQIList != null && discountQIList.Count > 0) { discountQIList.ForEach(_ => { if (_.discount_percent != null) { _.discount_percent = _.discount_percent / 100; } }); } } } else { Response.End(); } } catch (Exception) { throw; } }