Exemplo n.º 1
0
        public void Deal(ItemDetailAmountContract contract)
        {
            var facade         = new T_Sku_PriceFacade();
            var itemPropFacade = new T_Item_PropertyFacade();

            facade.DeleteBySkuIdAndPriceTypeId(contract.ItemDetailId, ConfigMgr.ItemPriceTypeId_Inventory);
            facade.DeleteBySkuIdAndPriceTypeId(contract.ItemDetailId, ConfigMgr.ItemPriceTypeId_SalesVolume);
            itemPropFacade.DeleteBySkuId(contract.ItemDetailId);
            var dbEntityList = ConvertToT_Sku_PriceEntityList(contract);

            switch (contract.Operation)
            {
            case OptEnum.Create:
            case OptEnum.Update:
                foreach (var i in dbEntityList)
                {
                    facade.Create(i);
                }
                itemPropFacade.CreateQty(contract.ItemDetailId);
                itemPropFacade.CreateSalesCount(contract.ItemDetailId);
                break;

            case OptEnum.Delete:
                break;
            }
        }
Exemplo n.º 2
0
        public void Deal(ItemContract contract)
        {
            var itemFacade                = new T_ItemFacade();
            var itemSkuPropFacade         = new T_ItemSkuPropFacade();
            var skuPriceFacade            = new T_Sku_PriceFacade();
            var skuFacade                 = new T_SkuFacade();
            var itemDeliveryMappingFacade = new T_Item_Delivery_MappingFacade();
            var itemPropertyFacade        = new T_Item_PropertyFacade();
            var propFacade                = new T_PropFacade();

            itemFacade.Delete(new T_ItemEntity {
                item_id = contract.ItemId
            });
            itemSkuPropFacade.DeleteByItemId(contract.ItemId);
            skuPriceFacade.DeleteByItemId(contract.ItemId);
            skuFacade.DeleteByItemId(contract.ItemId);
            itemDeliveryMappingFacade.DeleteByItemId(contract.ItemId);
            switch (contract.Operation)
            {
            case OptEnum.Create:
            case OptEnum.Update:
                if (contract.ItemDetailList == null || contract.ItemDetailList.Count == 0)
                {
                    return;
                }
                var itemEntity         = ConvertToT_ItemEntity(contract);
                var itemSkuPropEntity  = ConvertToT_ItemSkuPropEntity(contract);
                var skuPriceEntityList = ConvertToT_Sku_PriceEntityList(contract);
                var skuEntityList      = ConvertToT_SkuEntityList(contract);
                var deliveryList       = ConvertToT_Item_Delivery_MappingEntityList(contract);
                itemFacade.Create(itemEntity);
                if (itemSkuPropEntity != null)
                {
                    itemSkuPropFacade.Create(itemSkuPropEntity);
                }
                foreach (var i in skuPriceEntityList)
                {
                    skuPriceFacade.Create(i);
                }
                foreach (var i in skuEntityList)
                {
                    skuFacade.Create(i);
                }
                foreach (var i in deliveryList)
                {
                    itemDeliveryMappingFacade.Create(i);
                }
                if (contract.ItemId.StartsWith("S_"))
                {
                    //删除库存
                    itemPropertyFacade.DeleteByItemId(contract.ItemId);
                    //添加库存
                    var inventory = new T_Item_PropertyEntity
                    {
                        item_property_id = Guid.NewGuid().ToString("N"),
                        item_id          = contract.ItemId,
                        prop_id          = propFacade.GetIdByCode("Qty"),
                        prop_value       = "10000000",
                        status           = "1",
                        create_time      =
                            contract.CreateTime == null
                                    ? null
                                    : contract.CreateTime.Value.ToString("yyyy-MM-dd hh:mm:ss"),
                        modify_time =
                            contract.ModifyTime == null
                                    ? null
                                    : contract.ModifyTime.Value.ToString("yyyy-MM-dd hh:mm:ss")
                    };
                    itemPropertyFacade.Create(inventory);
                }
                break;
            }
        }