Пример #1
0
 public void CreateSimilarProduct(ProductGroupMaintainSimilarProductVM data, EventHandler <RestClientEventArgs <CreateSimilerProductRsp> > callback)
 {
     _restClient.Create(CreateSimilarProductRelativeUrl, CovertProductGroupMaintainSimilarProductVMToProductGroupEntity(data), callback);
 }
Пример #2
0
        private ProductGroup CovertProductGroupMaintainSimilarProductVMToProductGroupEntity(ProductGroupMaintainSimilarProductVM data)
        {
            var productGroup = new ProductGroup
            {
                SysNo       = data.MainPageVM.ProductGroupSysNo,
                ProductList = new List <ProductInfo>(),
                OperateUser = new UserInfo
                {
                    SysNo           = CPApplication.Current.LoginUser.UserSysNo,
                    UserDisplayName = CPApplication.Current.LoginUser.DisplayName
                },
                CompanyCode  = CPApplication.Current.CompanyCode,
                LanguageCode = ConstValue.BizLanguageCode
            };

            data.SelectedProduct.Where(p => p.IsChecked).ForEach(p =>
            {
                var product                = new ProductInfo();
                product.PromotionTitle     = new LanguageContent(String.Empty);
                product.ProductConsignFlag = VendorConsignFlag.Sell;
                product.ProductStatus      = ProductStatus.InActive_UnShow;
                product.ProductPOInfo      = new ProductPOInfo();
                product.ProductPayType     = ProductPayType.MoneyOnly;
                product.Merchant           = new Merchant {
                    SysNo = 1
                };                                            //泰隆优选商品
                product.OperateUser = new UserInfo
                {
                    SysNo           = CPApplication.Current.LoginUser.UserSysNo,
                    UserDisplayName = CPApplication.Current.LoginUser.DisplayName
                };
                product.CompanyCode      = CPApplication.Current.CompanyCode;
                product.LanguageCode     = ConstValue.BizLanguageCode;
                product.ProductPriceInfo = new ProductPriceInfo
                {
                    BasicPrice                = 999999,
                    CashRebate                = 0,
                    CurrentPrice              = 999999,
                    DiscountAmount            = 0,
                    MaxCountPerDay            = 1,
                    MinCountPerOrder          = 1,
                    PayType                   = ProductPayType.MoneyOnly,
                    Point                     = 0,
                    ProductRankPrice          = new List <ProductRankPriceInfo>(),
                    ProductWholeSalePriceInfo = new List <ProductWholeSalePriceInfo>(),
                    UnitCost                  = 999999,
                    UnitCostWithoutTax        = 999999,
                    VirtualPrice              = Math.Round(Convert.ToDecimal(p.VirtualPrice), 2)
                };
                product.ProductWarrantyInfo = new ProductWarrantyInfo
                {
                    HostWarrantyDay    = 0,
                    IsNoExtendWarranty = true,
                    OfferVATInvoice    = OfferVATInvoice.Yes,
                    PartWarrantyDay    = 0,
                    ServiceInfo        = String.Empty,
                    ServicePhone       = String.Empty,
                    Warranty           = new LanguageContent(String.Empty),
                    WarrantyShow       = WarrantyShow.No
                };

                product.ProductBasicInfo = new ProductBasicInfo
                {
                    Attention        = new LanguageContent(String.Empty),
                    IsAccessoryShow  = ProductIsAccessoryShow.No,
                    IsTakePicture    = ProductIsTakePicture.No,
                    IsVirtualPic     = ProductIsVirtualPic.No,
                    Keywords         = new LanguageContent(String.Empty),
                    LongDescription  = new LanguageContent(String.Empty),
                    Note             = String.Empty,
                    PackageList      = new LanguageContent(String.Empty),
                    Performance      = String.Empty,
                    PhotoDescription = new LanguageContent(String.Empty),
                    ProductBrandInfo = new BrandInfo {
                        SysNo = data.MainPageVM.BasicInfoVM.ProductGroupBrand.SysNo
                    },
                    ProductBriefAddition = new LanguageContent(String.Empty),
                    ProductBriefTitle    = new LanguageContent(p.ProductTitle),
                    ProductCategoryInfo  = new CategoryInfo {
                        SysNo = data.MainPageVM.BasicInfoVM.ProductGroupCategory.SysNo
                    },
                    ProductDimensionInfo = new ProductDimensionInfo {
                        Height = 0, Length = 0, Weight = 0, Width = 0
                    },
                    ProductInfoFinishStatus = ProductInfoFinishStatus.No,
                    ProductLink             = String.Empty,
                    ProductModel            = new LanguageContent(p.ProductModel),
                    ProductProperties       = ConvertPropertyValueListVMToProductPropertyList(p.PropertyValueList),
                    ProductTitle            = new LanguageContent(p.ProductTitle),
                    ShortDescription        = new LanguageContent(String.Empty),
                    UPCCode     = p.UPCCode,
                    BMCode      = p.BMCode,
                    ProductType = ProductType.Normal,
                    TradeType   = TradeType.Internal//泰隆银行默认为国内商品
                };
                product.OrginCode = p.CountryCode;
                productGroup.ProductList.Add(product);
            });
            return(productGroup);
        }
        public ProductGroupMaintainAddSimilarProduct()
        {
            InitializeComponent();

            (new ProductCreateFacade()).GetProductCountryList((obj, arg) =>
            {
                if (arg.FaultsHandle())
                {
                    return;
                }
                CountryList = arg.Result;
            });
            _vm = new ProductGroupMaintainSimilarProductVM();

            new ProductGroupFacade().GetProductList(_vm.MainPageVM.ProductListVM.ProductGroupProductVMList
                                                    .Select(p => p.ProductSysNo).ToList(), (o, a) =>
            {
                if (a.FaultsHandle())
                {
                    return;
                }
                _vm.GroupProductList = a.Result;
                new ProductGroupFacade().GetPropertyValueInfoByPropertySysNoList(
                    _vm.MainPageVM.PropertyVM.ProductGroupSettings
                    .Where(setting => setting.ProductGroupProperty.SysNo != 0).Select(p => p.ProductGroupProperty.SysNo)
                    .ToList(), (obj, args) =>
                {
                    if (args.FaultsHandle())
                    {
                        return;
                    }
                    _vm.MainPageVM.PropertyVM.ProductGroupSettings.ForEach(setting =>
                    {
                        if (args.Result.ContainsKey(setting.ProductGroupProperty.SysNo) &&
                            args.Result[setting.ProductGroupProperty.SysNo].Count > 0)
                        {
                            var selectGroupProperty = new SelectGroupProperty
                            {
                                Property = new PropertyVM
                                {
                                    SysNo        = setting.ProductGroupProperty.SysNo,
                                    PropertyName = setting.ProductGroupProperty.PropertyName
                                }
                            };
                            args.Result[setting.ProductGroupProperty.SysNo]
                            .ForEach(property =>
                            {
                                if (property.SysNo.HasValue)
                                {
                                    selectGroupProperty.SelectedPropertyValueList.Add(
                                        new SelectedPropertyValue
                                    {
                                        IsChecked = _vm.GroupProductList
                                                    .Any(p => p.ProductBasicInfo.ProductProperties
                                                         .Any(value => value.Property.SysNo == property.SysNo)),
                                        PropertyValue = new PropertyValueVM
                                        {
                                            SysNo            = property.SysNo.Value,
                                            ValueDescription = property.ValueDescription.Content
                                        }
                                    });
                                }
                            });
                            _vm.SelectGroupPropertyValue.Add(selectGroupProperty);
                        }
                    });



                    if (_vm.SelectGroupPropertyValue.Count > 0)
                    {
                        _vm.SelectGroupPropertyValue[0].SelectedPropertyValueList.ForEach(i =>
                        {
                            var control = new CheckBox();
                            var binding = new Binding
                            {
                                Source = i,
                                Path   = new PropertyPath("IsChecked"),
                                Mode   = BindingMode.TwoWay
                            };
                            control.SetBinding(ToggleButton.IsCheckedProperty, binding);
                            control.IsEnabled = !i.IsChecked;
                            control.Content   = i.PropertyValue.ValueDescription;
                            control.Click    += (CheckBoxClick);
                            FirstPropertyList.Children.Add(control);
                        });


                        dgProductList.Columns.Insert(1, new DataGridTextColumn
                        {
                            Header  = _vm.SelectGroupPropertyValue[0].Property.PropertyName,
                            Binding = new Binding("PropertyValueList[0].ValueDescription")
                        });
                    }

                    if (_vm.SelectGroupPropertyValue.Count > 1)
                    {
                        _vm.SelectGroupPropertyValue[1].SelectedPropertyValueList.ForEach(i =>
                        {
                            var control = new CheckBox();
                            var binding = new Binding
                            {
                                Source = i,
                                Path   = new PropertyPath("IsChecked"),
                                Mode   = BindingMode.TwoWay
                            };
                            control.SetBinding(ToggleButton.IsCheckedProperty, binding);
                            control.IsEnabled = !i.IsChecked;
                            control.Content   = i.PropertyValue.ValueDescription;
                            control.Click    += (CheckBoxClick);
                            SecondPropertyList.Children.Add(control);
                        });

                        dgProductList.Columns.Insert(2, new DataGridTextColumn
                        {
                            Header  = _vm.SelectGroupPropertyValue[1].Property.PropertyName,
                            Binding = new Binding("PropertyValueList[1].ValueDescription")
                        });
                    }
                    BuildProductList();
                    DataContext = _vm;
                });
            });
        }