USE [befri_Goldhoo]
GO

/****** Object:  View [shop_order].[V_SalesItem]    Script Date: 2021/3/31 10:32:32 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO


ALTER VIEW [shop_order].[V_SalesItem]
AS
SELECT i.InventoryTypeId AS ItemType, i.InventoryId AS ItemId, i.InventoryNumber AS ItemNumber, 
                  i.InventoryName AS ItemName, i.AliasName, i.Spec, i.CostPrice, i.SalesPrice, i.SearchCode, i.InventoryCategoryId, 
                  i.IsCustomizable, i.Added, i.Status, i.IsHot, i.IsNew, i.Description, i.IsClearance, i.IsDiscount, i.PriceType, 
                  ic.CategoryNumber, ic.CategoryName, ic.DisplayOrder, vimi.ThumbnailUrl AS MasterImageUrl, vimi.HandledUrl, 
                  ZH.InventoryName AS ZHInvName, ZH.InventoryNumber AS ZHInvNumber, DZ.InventoryName AS DZInvName, 
                  DZ.InventoryNumber AS DZInvNumber, ii.Introduction, i.DeliveryCycle, i.DeliveryCycleStr, i.ProductionProperty, 
                  vtmp.Text AS ProductionPropertyText, i.ModifiedOn
FROM     basedata.Inventory AS i LEFT OUTER JOIN
                  basedata.InventoryCategory AS ic ON i.InventoryCategoryId = ic.InventoryCategoryId LEFT OUTER JOIN
                  basedata.V_InventoryMasterImage AS vimi ON i.InventoryId = vimi.InventoryId LEFT OUTER JOIN
                  basedata.CombtItemMember AS Co ON Co.CombtItemId = i.InventoryId LEFT OUTER JOIN
                  basedata.Inventory AS ZH ON ZH.InventoryId = Co.SuitId LEFT OUTER JOIN
                  basedata.CustomItemMember AS Cu ON Cu.CustomItemId = i.InventoryId LEFT OUTER JOIN
                  basedata.Inventory AS DZ ON DZ.InventoryId = Cu.MemberItemId LEFT OUTER JOIN
                  basedata.InventoryIntro AS ii ON i.InventoryId = ii.InventoryId LEFT OUTER JOIN
                  dbo.ValueTextMap AS vtmp ON i.ProductionProperty = vtmp.Value AND vtmp.TableName = 'basedata.Inventory' AND 
                  vtmp.FieldName = 'ProductionProperty'


GO


