/// <summary>
        /// 获取所有C2
        /// </summary>
        /// <returns></returns>
        public JsonResult AjaxAllCategory2List()
        {
            string sysNo = Request.Params["sysno"].Trim();

            return(new JsonResult()
            {
                Data = ProductMaintainService.GetAllCategory2List(int.Parse(sysNo))
            });
        }
示例#2
0
        static void Main(string[] args)
        {
            //初始化商家代理商品的数据,商家编号在appsetting的配置中
            //所有的代理级别都是原厂
            //init c3
            Console.WriteLine("init c3...");
            List <Nesoft.SellerPortal.Entity.Product.CategoryInfo> c1 = ProductMaintainService.GetAllCategory1List();
            List <Nesoft.SellerPortal.Entity.Product.CategoryInfo> c2 = new List <Nesoft.SellerPortal.Entity.Product.CategoryInfo>();
            List <Nesoft.SellerPortal.Entity.Product.CategoryInfo> c3 = new List <Nesoft.SellerPortal.Entity.Product.CategoryInfo>();

            c1.ForEach(p => c2.AddRange(ProductMaintainService.GetAllCategory2List(p.SysNo)));
            c2.ForEach(p => c3.AddRange(ProductMaintainService.GetAllCategory3List(p.SysNo)));
            Console.WriteLine("C3 total is : {0}", c3.Count);

            //init brand

            Console.WriteLine("init brand...");
            BrandQueryFilter filter = new BrandQueryFilter();

            filter.Status    = ValidStatus.Active;
            filter.PageIndex = 0;
            filter.PageSize  = 100000;

            var brands = CommonService.QueryBrandList(filter);

            Console.WriteLine("brand total is : {0}", brands.ResultList.Count);

            brands.ResultList.ForEach(b =>
            {
                c3.ForEach(c =>
                {
                    VendorAgentInfo agent = new VendorAgentInfo();
                    agent.C3SysNo         = c.SysNo;
                    agent.C3Name          = c.CategoryName;
                    //agent.C2SysNo = 10;
                    agent.AgentLevel = "原厂";
                    agent.BrandInfo  = new BrandInfo
                    {
                        SysNo          = b.SysNo,
                        BrandNameLocal = b.BrandNameLocal
                    };
                    agent.Status      = VendorAgentStatus.Draft;
                    agent.CompanyCode = "8601";

                    AppendToSeller(new List <VendorAgentInfo> {
                        agent
                    });
                });
            });

            Console.ReadKey();
        }
示例#3
0
        //[ValidateInput(false)]
        public ActionResult AjaxSaveStoreAgentProduct()
        {
            List <VendorAgentInfo> agent = new List <VendorAgentInfo>();
            var data      = SerializationUtility.JsonDeserialize2 <List <VendorAgentInfo> >(Request.Form["data"]);
            var isRequest = bool.Parse(Request.Form["isRequest"]);

            data.ForEach(p =>
            {
                p.CompanyCode = CurrUser.CompanyCode;
                //p.Status = VendorAgentStatus.Draft;
            });
            var sellerSysNo = CurrUser.SellerSysNo;
            var sellerName  = CurrUser.SellerName;

            if (data[0].C3SysNo.HasValue && data[0].C3SysNo.Value != 0)
            {
                agent = data;
            }
            else if (data[0].C2SysNo.HasValue && data[0].C2SysNo.Value != 0)
            {
                var c3 = ProductMaintainService.GetAllCategory3List(data[0].C2SysNo.Value);
                c3.ForEach(p =>
                {
                    VendorAgentInfo temp = new VendorAgentInfo();
                    temp.AgentLevel      = data[0].AgentLevel;
                    temp.BrandInfo       = new BrandInfo
                    {
                        SysNo          = data[0].BrandInfo.SysNo,
                        BrandNameLocal = data[0].BrandInfo.BrandNameLocal
                    };
                    temp.Status      = data[0].Status;
                    temp.C2SysNo     = data[0].C2SysNo;
                    temp.C2Name      = data[0].C2Name;
                    temp.C3SysNo     = p.SysNo;
                    temp.C3Name      = p.CategoryName;
                    temp.CompanyCode = data[0].CompanyCode;
                    agent.Add(temp);
                });
                var originAgentInfo = StoreService.QueryStoreAgentInfos(sellerSysNo);
                agent.RemoveAll(p => originAgentInfo.Any(q => q.C3Name == p.C3Name &&
                                                         q.BrandInfo.SysNo == p.BrandInfo.SysNo));
            }
            else if (data[0].C1SysNo.HasValue && data[0].C1SysNo.Value != 0)
            {
                List <ECommerce.Entity.Product.CategoryInfo> c2list = ProductMaintainService.GetAllCategory2List(data[0].C1SysNo.Value);
                for (int n = 0; n < c2list.Count; n++)
                {
                    List <ECommerce.Entity.Product.CategoryInfo> c3list = ProductMaintainService.GetAllCategory3List(c2list[n].SysNo);
                    for (int i = 0; i < c3list.Count; i++)
                    {
                        VendorAgentInfo temp = new VendorAgentInfo();
                        temp.AgentLevel = data[0].AgentLevel;
                        temp.BrandInfo  = new BrandInfo {
                            SysNo = data[0].BrandInfo.SysNo, BrandNameLocal = data[0].BrandInfo.BrandNameLocal
                        };
                        temp.Status      = data[0].Status;
                        temp.C2SysNo     = data[0].C2SysNo;
                        temp.C2Name      = data[0].C2Name;
                        temp.C3SysNo     = c3list[i].SysNo;
                        temp.C3Name      = c3list[i].CategoryName;
                        temp.CompanyCode = data[0].CompanyCode;
                        agent.Add(temp);
                    }
                }

                var originAgentInfo = StoreService.QueryStoreAgentInfos(sellerSysNo);
                agent.RemoveAll(p => originAgentInfo.Any(q => q.C3Name == p.C3Name &&
                                                         q.BrandInfo.SysNo == p.BrandInfo.SysNo));
            }

            StoreService.SaveStoreAgentProduct(agent, sellerSysNo, sellerName, isRequest);
            return(Json(new { Success = true, Message = LanguageHelper.GetText("操作成功"), Data = StoreService.QueryStoreAgentInfos(CurrUser.SellerSysNo) }));
        }