예제 #1
0
        /// <summary>
        /// 根据属性ID获取属性信息
        /// </summary>
        public string GetPropInfoById()
        {
            var      service = new PropService(CurrentUserInfo);
            PropInfo obj     = new PropInfo();
            string   content = string.Empty;

            string key = string.Empty;

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

            obj = service.GetPropInfoById(key);
            var SKUDomain = "SKU";

            if (obj != null)
            {
                obj.Children = service.GetPropListByParentId(SKUDomain, obj.Prop_Id);
            }

            var jsonData = new JsonData();

            jsonData.totalCount = obj == null ? "0" : "1";
            jsonData.data       = obj;

            content = jsonData.ToJSON();
            return(content);
        }
예제 #2
0
        public string SaveSkuValue(string pRequest)
        {
            var rp = pRequest.DeserializeJSONTo <APIRequest <SaveSkuValueRP> >();
            var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo;
            var rd = new SaveSkuRD();//返回值

            //处理促销分组
            //先把之前的删除掉
            var service = new PropService(loggingSessionInfo);//保存到t_sku表

            //  var skuPropServer = new SkuPropServer(loggingSessionInfo);//保存到T_Sku_Property

            if (string.IsNullOrEmpty(rp.Parameters.parent_prop_id))
            {
                throw new APIException("缺少参数【parent_prop_id】或参数值为空")
                      {
                          ErrorCode = 135
                      };
            }
            if (string.IsNullOrEmpty(rp.Parameters.prop_name))
            {
                throw new APIException("缺少参数【prop_name】或参数值为空")
                      {
                          ErrorCode = 135
                      };
            }

            string   error    = "";
            PropInfo itemInfo = new PropInfo();

            itemInfo.Prop_Id            = Guid.NewGuid().ToString();
            itemInfo.Prop_Name          = rp.Parameters.prop_name;
            itemInfo.Prop_Code          = itemInfo.Prop_Name;
            itemInfo.Prop_Eng_Name      = "";
            itemInfo.Prop_Type          = "3";                          //属性类型 1=组,2=属性,3=属性明细';
            itemInfo.Parent_Prop_id     = rp.Parameters.parent_prop_id; //父类id
            itemInfo.Prop_Level         = 2;
            itemInfo.Prop_Domain        = "SKU";
            itemInfo.Prop_Input_Flag    = "select";
            itemInfo.Prop_Max_Length    = 1000;
            itemInfo.Prop_Default_Value = "";
            itemInfo.Prop_Status        = 1;
            // itemInfo.Display_Index = ++i;
            if (service.CheckProp(itemInfo))//判断在同一个父类下面,是不是有这个属性代码了。
            {
                throw new APIException("该sku下面,已经有这个sku值了")
                      {
                          ErrorCode = 135
                      };
            }


            var children = service.GetPropListByParentId("SKU", rp.Parameters.parent_prop_id);
            int i        = children == null ? 0 : children.Count;

            itemInfo.Display_Index = ++i;
            service.SaveProp(itemInfo, ref error);



            var rsp = new SuccessResponse <IAPIResponseData>(rd);

            return(rsp.ToJSON());
        }