public ActionResult GetMsGoodsInfo(string id) { try { var result = _mdmGoodsMstrRepository.GetAllList(m => m.GL_ID == id && m.CREATE_ORG_NO == AbpSession.ORG_NO); return(Success("获取成功", result)); } catch (Exception ex) { return(Fail("获取失败:" + ex.Message)); } }
/// <summary> /// 删除商品分类 /// </summary> /// <param name="id"></param> public void DeleteGoodsClass(long id) { var classList = _mdmGoodsClassRepository.GetAllList(m => m.PARENT_ID == id); var mstrList = _mdmGoodsMstrRepository.GetAllList(m => m.GOODS_LARGECLASS == id || m.GOODS_INCLASS == id || m.GOODS_SMALLCLASS == id); if (classList?.Count > 0 || mstrList?.Count > 0) { throw new Exception("该分类下存在正常的子级分类或商品!请先删除子类或商品"); } var entity = _mdmGoodsClassRepository.Get(id); _mdmGoodsClassRepository.Delete(entity); }
/// <summary> /// 保存商品分类属性 /// </summary> /// <param name="dto"></param> public void SaveGoodsProperty(MdmGoodsPropertyMstrDto dto) { string propertyId = dto.Id; //保存主属性 MdmGoodsPropertyMstrDto mstrProperty = new MdmGoodsPropertyMstrDto() { PROPERTY_NAME = dto.PROPERTY_NAME, PROPERTY_TYPE = 2, PROPERTY_PARENTID = dto.PROPERTY_EN_NAME, PROPERTY_LEVEL = 0, PROPERTY_EN_NAME = dto.PROPERTY_EN_NAME, Id = propertyId }; if (!SaveProperty(mstrProperty, ref propertyId)) { throw new Exception("绑定分类失败"); } //保存属性明细 string propertyItemId = ""; string where = ""; string _values = "|" + dto.PROPERTY_DEFAULT_VALUE + "|"; string[] arr = dto.PROPERTY_DEFAULT_VALUE.Split('|'); foreach (var item in arr) { MdmGoodsPropertyMstrDto itemProperty = new MdmGoodsPropertyMstrDto() { PROPERTY_NAME = dto.PROPERTY_NAME, PROPERTY_TYPE = 3, PROPERTY_PARENTID = propertyId, PROPERTY_LEVEL = 0, PROPERTY_EN_NAME = dto.PROPERTY_EN_NAME, PROPERTY_DEFAULT_VALUE = item }; if (!_mdmGoodsPropertyMstrRepository.ValidateProperty(propertyId, item) && !string.IsNullOrEmpty(item)) { if (!SaveProperty(itemProperty, ref propertyItemId)) { throw new Exception("绑定属性明细失败"); } } //修改sku时,删除项验证 if (!string.IsNullOrEmpty(propertyId)) { var list = _mdmGoodsPropertyMstrRepository.GetAllList(m => m.PROPERTY_PARENTID == propertyId); //遍历数据库所有已存sku值 foreach (MdmGoodsPropertyMstr model in list) { //若该值已被删除(不包含在新数据内) if (!_values.Contains("|" + model.PROPERTY_DEFAULT_VALUE + "|")) { //验证该值是否被商品使用 var mstrList = _mdmGoodsMstrRepository.GetAllList(m => m.SKU_PROPERTY_ID1 == model.Id || m.SKU_PROPERTY_ID2 == model.Id || m.SKU_PROPERTY_ID3 == model.Id || m.SKU_PROPERTY_ID4 == model.Id || m.SKU_PROPERTY_ID5 == model.Id); if (mstrList != null && mstrList.Count > 0) { throw new Exception("sku已被使用:" + model.PROPERTY_DEFAULT_VALUE); } } } } where += " and PROPERTY_DEFAULT_VALUE!='" + item + "'"; } _mdmGoodsPropertyMstrRepository.DelProValue(propertyId, where); }