/// <summary> /// 添加商品SKU项集 /// </summary> /// <param name="packSkus">商品SKU项集</param> public void AddPackSkus(IEnumerable <DecorationPackSku> packSkus) { #region # 验证 packSkus = packSkus == null ? new DecorationPackSku[0] : packSkus.ToArray(); if (!packSkus.Any()) { throw new ArgumentNullException("packSkus", "套餐模板商品SKU项集不可为空!"); } if (packSkus.Count() != packSkus.DistinctBy(x => x.SkuId).Count()) { throw new InvalidOperationException("同一选区内,商品SKU不可重复!"); } #endregion //先清空 foreach (DecorationPackSku skuItem in this.PackSkus.ToArray()) { this.PackSkus.Remove(skuItem); } //再添加 this.PackSkus.AddRange(packSkus); foreach (DecorationPackSku packSku in packSkus) { packSku.PackItem = this; } //挂起领域事件 处理套餐上是否包含下架|变价商品|工艺属性 EventMediator.Suspend(new PackShelvedChangedEvent(this.PackId)); }
/// <summary> /// 整体定价 /// </summary> /// <param name="square">标准面积(使用面积)</param> /// <param name="totalPrice">总价</param> /// <param name="buildingSquare">标准面积(建筑面积)</param> /// <param name="buildingTotalPrice">建筑面积总价</param> /// <param name="isBuilding">是否整体建筑面积定价</param> /// <param name="isActual">是否整体使用面积定价</param> /// <param name="isManageFee">设置管理费参考价</param> /// <param name="manageFee">管理费参考价</param> /// <param name="isWaterElectricityFee">设置水电预收参考价</param> /// <param name="waterElectricityFee">水电预收参考价</param> public void SetPriceTotally(float square, decimal totalPrice, float buildingSquare, decimal buildingTotalPrice, bool isBuilding, bool isActual, bool isManageFee, decimal manageFee, bool isWaterElectricityFee, decimal waterElectricityFee) { //验证 if (isActual) { Assert.IsTrue(totalPrice >= 0, "总价不可小于0!"); } if (isBuilding) { Assert.IsTrue(buildingTotalPrice >= 0, "建筑面积总价不可小于0!"); } Assert.IsFalse(isManageFee && manageFee <= 0, "管理费参考价请填写大于0的数!"); Assert.IsFalse(isWaterElectricityFee && waterElectricityFee <= 0, "水电预收参考价请填写大于0的数!"); this.Square = square; this.TotalPrice = totalPrice; this.BuildingSquare = buildingSquare; this.BuildingTotalPrice = buildingTotalPrice; this.Priced = true; this.PricingType = DecorationPackPricingType.Total; this.IsBuilding = isBuilding; this.IsActual = isActual; this.IsManageFee = isManageFee; this.ManageFee = manageFee; this.IsWaterElectricityFee = isWaterElectricityFee; this.WaterElectricityFee = waterElectricityFee; //清空平米定价 this.ClearUnitPrice(); //TODO 领域事件处理套餐商品|工艺成本价 更新 this.HasChangedSku = false; EventMediator.Suspend(new PackPricedEvent(this.Id)); }
/// <summary> /// 审核 /// </summary> public void Check() { this.Checked = true; //挂起领域事件 EventMediator.Suspend(new OrderCheckedEvent(base.Number)); }
/// <summary> /// 添加工艺项集 /// </summary> /// <param name="packCrafts">工艺项集</param> public void AddPackCrafts(IEnumerable <DecorationPackCraft> packCrafts) { #region # 验证 packCrafts = packCrafts == null ? new DecorationPackCraft[0] : packCrafts.ToArray(); if (!packCrafts.Any()) { throw new ArgumentNullException("packCrafts", "套餐模板商品工艺项集不可为空!"); } if (packCrafts.Count() != packCrafts.DistinctBy(x => x.CraftEntityId).Count()) { throw new InvalidOperationException("同一选区内,工艺实体不可重复!"); } #endregion //先清空 foreach (DecorationPackCraft craftItem in this.PackCraftEntities.ToArray()) { this.PackCraftEntities.Remove(craftItem); } //再添加 this.PackCraftEntities.AddRange(packCrafts); foreach (DecorationPackCraft packCraft in packCrafts) { packCraft.PackItem = this; } //挂起领域事件 处理套餐上是否包含下架|变价商品|工艺属性 EventMediator.Suspend(new PackShelvedChangedEvent(this.PackId)); }
/// <summary> /// 设置套餐上架 /// </summary> public void SetPackShelfed() { Assert.IsTrue(this.DiscountRatio.IsPercentage(), "折扣比例必须大于0"); this.PackShelfStatus = ShelfStatus.Shelfed; //TODO 克隆套餐副本 EventMediator.Suspend(new OnShelfBalePackEvent(this.Id)); }
/// <summary> /// 领域事件处理方法 /// </summary> /// <param name="eventSource">领域事件源</param> public void Handle(ProductCreatedEvent eventSource) { lock (_Sync) { ProductName = eventSource.ProductName; EventMediator.Suspend(new ProductCreatedEvent2(eventSource.ProductNo, eventSource.ProductName, eventSource.Price)); } }
/// <summary> /// 创建商品构造器 /// </summary> /// <param name="productNo">商品编号</param> /// <param name="productName">商品名称</param> /// <param name="price">价格</param> public Product(string productNo, string productName, decimal price) : this() { base.Number = productNo; base.Name = productName; this.Price = price; //挂起领域事件 EventMediator.Suspend(new ProductCreatedEvent(this.Number, this.Name, this.Price)); }
/// <summary> /// 删除品类下已配置的所有商品集 /// </summary> public void DeleteBalePackAllProduct() { foreach (BalePackProduct product in this.BalePackProducts.ToList()) { this.BalePackProducts.Remove(product); } //挂起领域事件(类似上架商品)——修改套餐是否存在下架商品 EventMediator.Suspend(new BalePackProductShelvedEvent(this.BalePackGroup.ChoiceAreaId, true)); }
/// <summary> /// 商品下架 /// </summary> public void ProductShelfOff() { if (!this.Shelved) { return; } this.Shelved = false; //挂起领域事件 EventMediator.Suspend(new BalePackProductShelvedEvent(this.BalePackCategory.BalePackGroup.ChoiceAreaId, this.Shelved)); }
/// <summary> /// 创建服务构造器 /// </summary> /// <param name="serviceNo">服务编号</param> /// <param name="serviceName">服务名称</param> /// <param name="price">价格</param> public Service(string serviceNo, string serviceName, decimal price) : this() { base.Number = serviceNo; base.Name = serviceName; this.Price = price; //挂起领域事件 EventMediator.Suspend(new ServiceCreatedEvent(this.Number, this.Name, this.Price)); }
/// <summary> /// 下架 /// </summary> public void OffShelf() { if (!this.Shelved) { return; } this.Shelved = false; //挂起领域事件 EventMediator.Suspend(new PackSkuShelvedEvent(this.PackItem.PackId, this.Shelved)); }
/// <summary> /// 重新上架 /// </summary> public void ReOnShelf() { if (this.Shelved) { return; } this.Shelved = true; //挂起领域事件 EventMediator.Suspend(new PackSkuShelvedEvent(this.PackItem.PackId, this.Shelved)); }
/// <summary> /// 删除套餐模板空间 /// </summary> /// <param name="space">套餐模板空间</param> public void RemoveSpace(DecorationPackSpace space) { this.Spaces.Remove(space); //设置总面积 //this.Square = this.Spaces.Any() ? this.Spaces.Sum(x => x.Square) : 0; //空间类型处理 if (this.Spaces.All(x => x.SpaceType != space.SpaceType)) { this.SpaceTypes.Remove(space.SpaceType.GetEnumMember()); this.SpaceTypesStr = this.SpaceTypes.ToJson(); } //挂起领域事件 EventMediator.Suspend(new PackSpaceDeletedEvent(this.Id, space.Id)); }
/// <summary> /// 上架( 4、套餐必须定价) /// </summary> public void OnShelf() { //验证 if (!this.Priced) { throw new InvalidOperationException("套餐模板未定价,不可上架!"); } ////验证 //if (!Spaces.Any()) //{ // throw new InvalidOperationException("套餐模板不存在空间,不可上架!"); //} this.Status = ShelfStatus.Shelfed; //TODO 克隆套餐副本 EventMediator.Suspend(new OnShelfDecorationPackEvent(this.Id)); }
/// <summary> /// 添加商品SKU项集 /// </summary> /// <param name="packRecommendedSkus">商品SKU项集</param> public void AddPackSkus(IEnumerable <DecorationPackRecommendedSku> packRecommendedSkus) { //先清空 foreach (DecorationPackRecommendedSku skuItem in this.PackRecommendedSkus.ToArray()) { this.PackRecommendedSkus.Remove(skuItem); } //再添加 this.PackRecommendedSkus.AddRange(packRecommendedSkus); foreach (DecorationPackRecommendedSku packSku in packRecommendedSkus) { packSku.PackRecommendedItem = this; } //挂起领域事件 处理套餐上是否包含下架|变价商品|工艺属性 EventMediator.Suspend(new PackShelvedChangedEvent(this.PackId)); }
/// <summary> /// 创建权限构造器 /// </summary> /// <param name="systemNo">信息系统编号</param> /// <param name="authorityName">权限名称</param> /// <param name="englishName">英文名称</param> /// <param name="description">描述</param> /// <param name="assemblyName">程序集名称</param> /// <param name="namespace">命名空间</param> /// <param name="className">类名</param> /// <param name="methodName">方法名</param> public Authority(string systemNo, string authorityName, string englishName, string description, string assemblyName, string @namespace, string className, string methodName) : this() { //验证参数 this.CheckBasicInfo(assemblyName, @namespace, className, methodName); base.Name = authorityName; this.SystemNo = systemNo; this.EnglishName = englishName; this.Description = description; this.AssemblyName = assemblyName; this.Namespace = @namespace; this.ClassName = className; this.MethodName = methodName; //初始化权限路径与关键字 this.InitPath(); this.InitKeywords(); //挂起领域事件 EventMediator.Suspend(new AuthorityCreatedEvent(this.SystemNo, this.Id)); }
/// <summary> /// 创建信息系统 /// </summary> /// <param name="systemName">系统名称</param> /// <param name="systemNo">系统编号</param> /// <param name="adminLoginId">管理员登录名</param> /// <param name="applicationType">应用程序类型</param> public InfoSystem(string systemNo, string systemName, string adminLoginId, ApplicationType applicationType) : this() { #region # 验证参数 if (string.IsNullOrWhiteSpace(systemNo)) { throw new ArgumentNullException("systemNo", @"系统编号不可为空!"); } #endregion base.Number = systemNo; base.Name = systemName; this.AdminLoginId = adminLoginId; this.ApplicationType = applicationType; //挂起领域事件 EventMediator.Suspend(new InfoSystemCreatedEvent(this.Number, this.Name, this.AdminLoginId)); //初始化关键字 base.SetKeywords(base.Name); }
/// <summary> /// 按平方米定价 /// </summary> /// <param name="unitPrice">使用面积单价</param> /// <param name="buildingUnitPrice">建筑面积定价</param> /// <param name="isUnitBuilding">平米建筑</param> /// <param name="isUnitActual">平米使用</param> /// <param name="unitSquare">平米定价最低购买使用面积</param> /// <param name="unitBuildingSquare">平米定价最低购买建筑面积</param> /// <param name="isManageFee">设置管理费参考价</param> /// <param name="manageFee">管理费参考价</param> /// <param name="isWaterElectricityFee">设置水电预收参考价</param> /// <param name="waterElectricityFee">水电预收参考价</param> public void SetPriceByUnit(decimal unitPrice, decimal buildingUnitPrice, bool isUnitBuilding, bool isUnitActual, float unitSquare, float unitBuildingSquare, bool isManageFee, decimal manageFee, bool isWaterElectricityFee, decimal waterElectricityFee) { //验证 //Assert.IsTrue(unitPrice >= 0, "定价不可小于0!"); //Assert.IsTrue(buildingUnitPrice >= 0, "定价不可小于0!"); Assert.IsTrue(buildingUnitPrice >= 0 || unitPrice >= 0, "定价不可小于0!使用面积定价与建筑面积定价二者至少选择一个填写!"); Assert.IsFalse(isManageFee && manageFee <= 0, "管理费参考价请填写大于0的数!"); Assert.IsFalse(isWaterElectricityFee && waterElectricityFee <= 0, "水电预收参考价请填写大于0的数!"); this.UnitPrice = unitPrice; this.BuildingUnitPrice = buildingUnitPrice; //TODO 暂定 套餐整体面积和公式里标准面积一致 //this.TotalPrice = Convert.ToDecimal(this.Square) * unitPrice; this.Priced = true; this.PricingType = DecorationPackPricingType.Unit; this.IsUnitBuilding = isUnitBuilding; this.IsUnitActual = isUnitActual; this.UnitSquare = unitSquare; this.UnitBuildingSquare = unitBuildingSquare; //平米定价方式 总价=最低购买面积*单价 this.UnitBuildingTotalPrice = Decimal.Round((this.BuildingUnitPrice * Convert.ToDecimal(this.UnitBuildingSquare)), 2); this.UnitTotalPrice = Decimal.Round((this.UnitPrice * Convert.ToDecimal(this.UnitSquare)), 2); this.IsManageFee = isManageFee; this.ManageFee = manageFee; this.IsWaterElectricityFee = isWaterElectricityFee; this.WaterElectricityFee = waterElectricityFee; //清空整体定价 this.ClearTotalPrice(); //TODO 领域事件处理套餐商品|工艺成本价 更新 this.HasChangedSku = false; EventMediator.Suspend(new PackPricedEvent(this.Id)); }