Ejemplo n.º 1
0
        public void SyncWelfareBrand()
        {
            var interfaceName      = "syncwelFareBrand";
            var loggingSessionInfo = BaseService.GetLoggingSession();
            var brandService       = new BrandDetailBLL(loggingSessionInfo);

            var dsBrands = new DataSet();
            var brands   = new BrandList();

            brands.brandlist = new List <Brand>();

            //更新接口同步表
            var queryList = UpdateInterfaceTimestamp(interfaceName, loggingSessionInfo);

            if (queryList != null && queryList.Length > 0)
            {
                //存在,根据日期条件查询
                dsBrands = brandService.GetSynWelfareBrandList(queryList.FirstOrDefault().LatestTime.ToString());
            }
            else
            {
                //不存在,查询所有数据
                dsBrands = brandService.GetSynWelfareBrandList(string.Empty);
            }

            if (dsBrands != null && dsBrands.Tables.Count > 0 && dsBrands.Tables[0].Rows.Count > 0)
            {
                brands.brandlist = DataTableToObject.ConvertToList <Brand>(dsBrands.Tables[0]);
                var content = brands.ToJSON();

                //将描述字段Encode
                foreach (var item in brands.brandlist)
                {
                    item.branddesc = HttpUtility.UrlEncode(item.branddesc, Encoding.UTF8);
                    byte[] buff = Encoding.UTF8.GetBytes(item.branddesc);
                    item.branddesc = Convert.ToBase64String(buff);
                }

                //上传数据
                var result = UploadData(interfaceName, brands.ToJSON());

                //写入接口日志
                var logEntity = new ZInterfaceLogEntity()
                {
                    LogId         = Utils.NewGuid(),
                    InterfaceName = interfaceName,
                    Params        = content,
                    ResultCode    = result.code,
                    ResultDesc    = result.description
                };

                InsertInterfaceLog(logEntity, loggingSessionInfo);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 获取列表
        /// </summary>
        public string GetListData()
        {
            var service = new BrandDetailBLL(new SessionManager().CurrentUserLoginInfo);
            IList <BrandDetailEntity> data = new List <BrandDetailEntity>();
            string content = string.Empty;

            data = service.GetAll().ToList();

            var jsonData = new JsonData();

            jsonData.totalCount = data.Count.ToString();
            jsonData.data       = data;

            content = jsonData.ToJSON();
            return(content);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 删除
        /// </summary>
        public string BrandDetailDeleteData()
        {
            string content      = string.Empty;
            string error        = "";
            var    responseData = new ResponseData();
            var    service      = new BrandDetailBLL(this.CurrentUserInfo);
            var    propService  = new PropService(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)
                {
                    var propObj = new BrandDetailEntity();
                    propObj.BrandId = id;
                    service.Delete(propObj);
                    //propService.DeleteProp(new PropInfo() { Prop_Id = id });

                    service.SetBrandAndPropSyn(propObj.BrandId, propObj.BrandName, 1, 1, out error);
                }
            }

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

            content = responseData.ToJSON();
            return(content);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 根据属性ID获取属性信息
        /// </summary>
        public string GetBrandDetailInfoById()
        {
            var service               = new BrandDetailBLL(CurrentUserInfo);
            BrandDetailEntity obj     = new BrandDetailEntity();
            string            content = string.Empty;

            string key = string.Empty;

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

            obj = service.GetByID(key);

            var jsonData = new JsonData();

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

            content = jsonData.ToJSON();
            return(content);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 查询属性
        /// </summary>
        public string GetBrandDetailListData()
        {
            var form = Request("form").DeserializeJSONTo <BrandDetailQueryEntity>();

            var service = new BrandDetailBLL(CurrentUserInfo);
            IList <BrandDetailEntity> list;
            string content = string.Empty;

            int pageIndex = Utils.GetIntVal(FormatParamValue(Request("page"))) - 1;

            BrandDetailEntity queryEntity = new BrandDetailEntity();

            queryEntity.BrandName = FormatParamValue(form.BrandName);
            queryEntity.BrandCode = FormatParamValue(form.BrandCode);
            //if (Request("parentId") != null && Request("parentId").Length > 0)// && Request("parentId") != "ALL")
            //{
            //    queryEntity.Parent_Prop_id = FormatParamValue(Request("parentId"));
            //}
            //else
            //{
            //    queryEntity.Parent_Prop_id = "-99";
            //}

            list = service.GetWebBrandDetail(queryEntity, pageIndex, PageSize);
            var dataTotalCount = service.GetWebBrandDetailCount(queryEntity);

            var jsonData = new JsonData();

            jsonData.totalCount = dataTotalCount.ToString();
            jsonData.data       = list;

            content = string.Format("{{\"totalCount\":{1},\"topics\":{0}}}",
                                    jsonData.data.ToJSON(),
                                    jsonData.totalCount);
            return(content);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 保存
        /// </summary>
        public string SaveBrandDetailData()
        {
            var service               = new BrandDetailBLL(CurrentUserInfo);
            var objectImagesBLL       = new ObjectImagesBLL(CurrentUserInfo);
            var propService           = new PropService(CurrentUserInfo);
            BrandDetailEntity obj     = new BrandDetailEntity();
            string            content = string.Empty;
            string            error   = "";
            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("item_id") != null && Request("item_id") != string.Empty)
            {
                item_id = Request("item_id").ToString().Trim();
            }

            obj = key.DeserializeJSONTo <BrandDetailEntity>();

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

            if (item_id.Trim().Length == 0)
            {
                obj.BrandId    = Utils.NewGuid();
                obj.CustomerId = this.CurrentUserInfo.CurrentUser.customer_id;
                service.Create(obj);

                var tmpImageList = objectImagesBLL.QueryByEntity(new ObjectImagesEntity()
                {
                    ObjectId = obj.BrandId
                }, null);
                if (tmpImageList != null && tmpImageList.Length > 0)
                {
                    foreach (var tmpImageItem in tmpImageList)
                    {
                        objectImagesBLL.Delete(tmpImageItem);
                    }
                }
                if (obj.ItemImageList != null)
                {
                    foreach (var tmpImageItem in obj.ItemImageList)
                    {
                        tmpImageItem.ObjectId   = obj.BrandId;
                        tmpImageItem.CustomerId = this.CurrentUserInfo.CurrentUser.customer_id;
                        objectImagesBLL.Create(tmpImageItem);
                    }
                }

                service.SetBrandAndPropSyn(obj.BrandId, obj.BrandName, 1, 0, out error);
            }
            else
            {
                obj.BrandId    = item_id;
                obj.CustomerId = CurrentUserInfo.CurrentUser.customer_id;
                service.Update(obj, false);

                var tmpImageList = objectImagesBLL.QueryByEntity(
                    new ObjectImagesEntity()
                {
                    ObjectId = obj.BrandId
                }, null);
                if (tmpImageList != null && tmpImageList.Length > 0)
                {
                    foreach (var tmpImageItem in tmpImageList)
                    {
                        objectImagesBLL.Delete(tmpImageItem);
                    }
                }
                if (obj.ItemImageList != null)
                {
                    foreach (var tmpImageItem in obj.ItemImageList)
                    {
                        tmpImageItem.ObjectId   = obj.BrandId;
                        tmpImageItem.CustomerId = this.CurrentUserInfo.CurrentUser.customer_id;
                        objectImagesBLL.Create(tmpImageItem);
                    }
                }

                service.SetBrandAndPropSyn(obj.BrandId, obj.BrandName, 1, 0, out error);
            }

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

            content = responseData.ToJSON();
            return(content);
        }
Ejemplo n.º 7
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);
        }
Ejemplo n.º 8
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);
        }