Esempio n. 1
0
        /// <summary>
        /// 删除
        /// </summary>
        public string PropDeleteData()
        {
            string content        = string.Empty;
            string error          = "";
            var    responseData   = new ResponseData();
            var    service        = new PropService(this.CurrentUserInfo);
            var    brandDetailBLL = new BrandDetailBLL(this.CurrentUserInfo);
            var    skuPropServer  = new SkuPropServer(this.CurrentUserInfo);

            string key = string.Empty;

            if (FormatParamValue(Request("ids")) != null && FormatParamValue(Request("ids")) != string.Empty)
            {
                key = FormatParamValue(Request("ids")).ToString().Trim();
            }

            if (key == null || key.Trim().Length == 0)
            {
                responseData.success = false;
                responseData.msg     = "ID不能为空";
                return(responseData.ToJSON());
            }



            string[] ids = key.Split(',');

            if (ids.Length > 0)
            {
                foreach (var id in ids)
                {
                    if (skuPropServer.ISCheckSkuProp(id))
                    {
                        responseData.success = false;
                        responseData.msg     = "属性已被引用";
                        return(responseData.ToJSON());
                    }
                    if (skuPropServer.ISCheckSkuProp2(id))
                    {
                        responseData.success = false;
                        responseData.msg     = "规格已被引用";
                        return(responseData.ToJSON());
                    }
                }
            }
            if (ids.Length > 0)
            {
                foreach (var id in ids)
                {
                    var propObj = new PropInfo();
                    propObj.Prop_Id = id;

                    var      tmpPropObj = service.GetPropInfoById(id);
                    PropInfo parentObj  = null;
                    if (tmpPropObj.Parent_Prop_id != null && tmpPropObj.Parent_Prop_id.Trim().Length > 0)
                    {
                        parentObj = service.GetPropInfoById(tmpPropObj.Parent_Prop_id);
                    }
                    if (parentObj != null && (parentObj.Prop_Code == "品牌" || parentObj.Prop_Id == "F8823C2EBACF4965BA134D3B10BD0B9F"))
                    {
                        brandDetailBLL.SetBrandAndPropSyn(propObj.Prop_Id, propObj.Prop_Name, 2, 1, out error);
                    }



                    service.DeleteProp(propObj);

                    SkuPropInfo skuPropInfo = new SkuPropInfo();
                    skuPropInfo.prop_id = propObj.Prop_Id;
                    skuPropServer.DeleteSkuProp(skuPropInfo);
                }
            }

            responseData.success = true;
            responseData.msg     = error;

            content = responseData.ToJSON();
            return(content);
        }
Esempio n. 2
0
        /// <summary>
        /// 保存属性
        /// </summary>
        public string SavePropData()
        {
            var      service        = new PropService(CurrentUserInfo);
            var      brandDetailBLL = new BrandDetailBLL(CurrentUserInfo);
            var      skuPropServer  = new SkuPropServer(this.CurrentUserInfo);
            PropInfo item           = new PropInfo();
            string   content        = string.Empty;
            var      responseData   = new ResponseData();

            string key     = string.Empty;
            string item_id = string.Empty;

            if (Request("item") != null && Request("item") != string.Empty)
            {
                key = Request("item").ToString().Trim();
            }
            if (Request("PropId") != null && Request("PropId") != string.Empty)
            {
                item_id = Request("PropId").ToString().Trim();
            }

            item = key.DeserializeJSONTo <PropInfo>();

            PropInfo parentObj = new PropInfo();

            parentObj.Prop_Level = 1;
            if (item.Parent_Prop_id != null && item.Parent_Prop_id.Trim().Length > 0)
            {
                parentObj = service.GetPropInfoById(item.Parent_Prop_id);
                if (parentObj != null)
                {
                    item.Prop_Level = parentObj.Prop_Level + 1;
                }
            }
            else
            {
                item.Parent_Prop_id = "-99";
                item.Prop_Status    = 1;
            }

            if (item.Prop_Domain == "SKU" && item.Prop_Level == 2)
            {
                if (service.CheckSkuLast(item.Parent_Prop_id))
                {
                    responseData.success = false;
                    responseData.msg     = "SKU组最多有5个子节点";
                    return(responseData.ToJSON());
                }
            }

            if (item.Prop_Name == null || item.Prop_Name.Trim().Length == 0)
            {
                responseData.success = false;
                responseData.msg     = "名称不能为空";
                return(responseData.ToJSON());
            }
            if (item.Prop_Code == null || item.Prop_Code.Trim().Length == 0)
            {
                responseData.success = false;
                responseData.msg     = "代码不能为空";
                return(responseData.ToJSON());
            }


            #region 商品sku 属性时判断  Display_Index只能在1-5,且不能在
            if (item.Prop_Type == "2" && item.Prop_Domain == "SKU")
            {
                string skuMsg = string.Empty;
                if (item.Display_Index < 1 || item.Display_Index > 5)
                {
                    skuMsg = "序号必须在1~5范围内";
                }

                //是否存在sku

                if (skuPropServer.CheckSkuPropByDisplayindex(this.CurrentUserInfo.CurrentLoggingManager.Customer_Id, item.Display_Index))
                {
                    skuMsg = "序号被占用,请重新选择1~5的序号。";
                }
                if (!string.IsNullOrWhiteSpace(skuMsg))
                {
                    responseData.msg = skuMsg;
                    return(responseData.ToJSON());
                }
            }
            #endregion


            bool   status  = true;
            string message = "保存成功";
            //------------------------------------------------
            //if (item.Prop_Domain.Equals("SKU") && item.Prop_Level.Equals("3"))
            //{
            //    item.Prop_Domain = "ITEM";
            //}
            //-----------------------------------------------------------------
            item.Prop_Status = 1;
            if (item.Prop_Id.Trim().Length == 0)
            {
                item.Prop_Id = Utils.NewGuid();
                service.SaveProp(item, ref message);
            }
            else
            {
                service.SaveProp(item, ref message);
            }

            if (message != "属性代码已存在")
            {
                if (item.Prop_Type == "2" && item.Prop_Domain == "SKU")
                {
                    string skuMsg = string.Empty;
                    if (item.Display_Index < 1 && item.Display_Index > 5)
                    {
                        skuMsg = "序号必须在1~5范围内";
                    }

                    //是否存在sku

                    if (skuPropServer.CheckSkuPropByDisplayindex(this.CurrentUserInfo.CurrentLoggingManager.Customer_Id, item.Display_Index))
                    {
                        skuMsg = "序号被占用,请重新选择1~5的序号。";
                    }
                    if (!string.IsNullOrWhiteSpace(skuMsg))
                    {
                        responseData.msg = skuMsg;
                        return(responseData.ToJSON());
                    }

                    //如果不存在属性关系
                    if (!skuPropServer.CheckSkuProp(item.Prop_Id))
                    {
                        SkuPropInfo skuPropInfo = new SkuPropInfo();
                        skuPropInfo.sku_prop_id   = Utils.NewGuid();
                        skuPropInfo.prop_id       = item.Prop_Id;
                        skuPropInfo.CustomerId    = this.CurrentUserInfo.CurrentLoggingManager.Customer_Id;
                        skuPropInfo.status        = item.Prop_Status.ToString();
                        skuPropInfo.display_index = item.Display_Index;
                        skuPropServer.AddSkuProp(skuPropInfo);
                    }
                }
                else
                {
                    SkuPropInfo skuPropInfo = new SkuPropInfo();
                    skuPropInfo.prop_id = item.Prop_Id;
                    skuPropServer.DeleteSkuProp(skuPropInfo);
                }
            }
            else
            {
                status = false;
            }



            if (parentObj != null && (parentObj.Prop_Code == "品牌" || parentObj.Prop_Id == "F8823C2EBACF4965BA134D3B10BD0B9F"))
            {
                brandDetailBLL.SetBrandAndPropSyn(item.Prop_Id, item.Prop_Name, 2, 0, out message);
            }

            responseData.success = status;
            responseData.msg     = message;

            content = responseData.ToJSON();
            return(content);
        }