电商核心业务知识


订单商品模块(9张表)
--订单主要信息表
drop table if exists itqsc.ods_b2c_orders;
create external table itqsc.ods_b2c_orders
(
order_id  bigint, -订单ID(主键)
order_no string, -订单号
order_date timestamp, -订单日期
user_id bigint, -用户ID
user_name string, -登陆名
order_money double, -订单金额
order_type string, -订单类型
order_status string, -订单状态
pay_type string, -支付类型
pay_status string, -支付状态
order_source string, -订单来源
last_update_time timestamp, -订单最后修改时间
dw_date timestamp
)
partitioned by
(dt string)
LOCATION 'hdfs://hadoop0:9000/user/hadoop/dev/itqsc/ods_b2c_orders';


--订单商品信息表
drop table if exists itqsc.ods_b2c_orders_goods;
create external table itqsc.ods_b2c_orders_goods
(
order_id  bigint, -订单ID
goods_id bignit, -商品ID
cat_id bigint, -类目ID
size_id bigint, -条码ID(联合主键)
cat_name string, -类目名称
goods_price double, -商品价格
goods_amout bigint, -数量
last_update_time timestamp, -最后修改时间
dw_date timestamp
)
partitioned by
(dt string)
LOCATION 'hdfs://hadoop0:9000/user/hadoop/dev/itqsc/ods_b2c_orders_goods';




--订单详细信息表
drop table if exists itqsc.ods_b2c_orders_desc;
create external table itqsc.ods_b2c_orders_desc
(
order_id  bigint, -订单ID(主键)
order_no string, -订单号
consignee string, -收货人姓名
area_id bigint, -收货人地址ID
area_name string, -收货人ID对应地址段
address string, -收货人街道地址
mobilephone string, -收货人手机号
telphone string, -收货人电话
coupon_id bigint, -使用代金券ID
coupon_money double, -使用代金券金额
carriage_money double, -运费
last_update_time timestamp, -最后修改时间
dw_date timestamp
)
partitioned by
(dt string)
LOCATION 'hdfs://hadoop0:9000/user/hadoop/dev/itqsc/ods_b2c_orders_desc';


----订单与商品宽表(核心地位,又叫SKU表),以上三表的关联,粒度非常细
drop table if exists itqsc.dm_b2c_orders_goods;
create external table itqsc.dm_b2c_orders_goods
(
order_id  bigint, -订单ID
goods_id bignit, -商品ID
cat_id bigint, -类目ID
size_id bigint, -条码ID
cat_name string, -类目名称
goods_price double, -商品价格
goods_amount bigint, -数量
order_no string, -订单号
order_date timestamp, -订单日期
user_id bigint, -用户ID
user_name string, -登陆名
order_money double, -订单金额
order_type string, -订单类型
order_status string, -订单状态
pay_type string, -支付类型
pay_status string, -支付状态
order_source string, -订单来源
coupon_id bigint, -使用代金券ID
coupon_money double, -使用代金券金额
carriage_money double, -运费
dw_date timestamp
)


----订单宽表(核心地位)
drop table if exists itqsc.dm_b2c_orders;
create external table itqsc.dm_b2c_orders
(
order_id  bigint, -订单ID
order_no string, -订单号
order_date timestamp, -订单日期
user_id bigint, -用户ID
user_name string, -登陆名
order_money double, -订单金额
order_type string, -订单类型
order_status string, -订单状态
pay_type string, -支付类型
pay_status string, -支付状态
order_source string, -订单来源
consignee string, -收货人姓名
area_id bigint, -收货人地址ID
area_name string, -收货人ID对应地址段
address string, -收货人街道地址
mobilephone string, -收货人手机号
telphone string, -收货人电话
coupon_id bigint, -使用代金券ID
coupon_money double, -使用代金券金额
carriage_money double, -运费
create_time timestamp, -创建时间
last_update_time, timestamp, -最后修改时间
dw_date timestamp
)


--购物车表
drop table if exists itqsc.ods_b2c_cart;
create external table itqsc.ods_b2c_cart
(
id bigint, -ID
session_id string, --session_id
user_id  bigint, -用户
goods_id bigint, -商品ID
number bigint, - 商品数量
add_time timestamp, -商品加入时间
cancel_time timestamp, -商品取消时间
submit_time timestamp, -商品提交时间
dw_date timestamp
)
partitioned by
(dt string)
LOCATION 'hdfs://hadoop0:9000/user/hadoop/dev/itqsc/ods_b2c_cart';


-订单指标表
drop table if exists itqsc.dm_user_order_tag;
create external table itqsc.dm_user_order_tag
(
user_id  bigint, -用户
first_order_time timestamp, -第一次消费时间
last_order_time timestamp, -最近一次消费时间
first_order_ago bigint, -首单距今时间
last_order_ago bigint, -尾单距今时间
month1_order_cnt bigint, -近30天购买次数
month1_order_amt bouble, -近30天购买金额
month2_order_cnt bigint, -近60天购买次数
month2_order_amt bouble, -近60天购买金额
month3_order_cnt bigint, -近90天购买次数
month3_order_amt double, -近90天购买金额
max_order_amt double, -最大消费金额
min_order_amt double, -最小消费金额
total_order_cnt bigint, -累计消费次数(不汗退拒)
total_order_amt double,-累计消费金额(不汗退拒)
total_coupon_amt double,-累计使用代金券金额
user_avg_amt double, -客单价(含退拒)
month3_user_avg_amt double, -近90天客单位(含退拒)
common_address string, -常用收货地区
common_paytype string, -常用支付方式
month1_cart_cnt bigint, -近30天购物车次数
month1_cart_goods_cnt bigint, -近30天购物车商品件数
month1_cart_submit_cnt bigint, -近30天购物车提交商品件数
month1_cart_rate double, -近30天购物车成功率
month1_cart_cancel_cnt bigint, -近30天购物车放弃件数
dw_date timestamp
)
partitioned by
(dt string)
LOCATION 'hdfs://hadoop0:9000/user/hadoop/dev/itqsc/dm_user_order_tag';


-商品信息表
drop table if exists itqsc.ods_b2c_goods;
create external table itqsc.ods_b2c_goods(
sku_id bigint, -sku编号
sku_name string, -SKU名称
goods_id bigint, -商品编号
goods_no string, -商品货号
goods_sn string, -商品条码
goods_name string, -商品名称
size_id bigint, -尺码编号
size_name string, -尺码名称
colour_id bigint, -颜色ID
shop_id bigint, -店铺编号
shop_name bigint, -店铺名称
curr_price double, -售卖价格
market_price double, -市场价格
discount double, -折扣比例
cost_price double, -成本价格
cost_type string, -成本类型
warehouse string, -所在仓库
stock_cnt bigint, -进货数量 
stock_amt double, -进货货值
first_cat bignit, -一级分类ID
first_cat_name string, -一级分类名称
second_cat bigint, -二级分类ID
second_cat_name string, -二级分类名称
third_cat bignit, -三级分类ID
third_cat_name string, -三级分类名称
dw_date timestamp
)


-商品指标计算
drop table if exists itqsc.dm_user_goods_amt;
create external table itqsc.dm_user_goods_amt
(
user_id  bigint, -用户
p_sales_cnt bigint, -排除退拒销售数量
p_sales_amt double, -排除退拒销售金额
p_sales_cnt_amt double, -排除退拒销售金额(扣促销减免)
h_sales_cnt bigint, -含退拒销售数量
h_sales_amt double, -含退拒销售金额
h_sales_cnt_amt double, -含退拒销售金额(扣促销减免)
return_cnt bigint, -退货商品数量
return_amt double, -退货商品金额
reject_cnt bigint, -拒收商品数量
reject_amt double, -拒收商品金额
common_first_cat string, -最常购买商品一级类目名称
common_second_cat string, -最常购买商品二级类目名称
common_third_cat string, -最常购买商品三级类目名称
dw_date timestamp
)
partitioned by
(dt string) LOCATION 'hdfs://hadoop0:9000/user/hadoop/dev/itqsc/dm_user_goods_amt'; ---------------------