1. 程式人生 > >[資料倉庫]電商核心業務知識之訂單商品模組

[資料倉庫]電商核心業務知識之訂單商品模組

電商核心業務知識 訂單商品模組(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'; --------------------- 本文來自 houxiaoqin 的CSDN 部落格 ,全文地址請點選:https://blog.csdn.net/houxiaoqin/article/details/47612175?utm_source=copy