sync promotion
This commit is contained in:
		
							parent
							
								
									8cf7da2c02
								
							
						
					
					
						commit
						59ac317c58
					
				
							
								
								
									
										2
									
								
								Makefile
								
								
								
								
							
							
						
						
									
										2
									
								
								Makefile
								
								
								
								
							| 
						 | 
				
			
			@ -6,5 +6,5 @@ push:
 | 
			
		|||
run:
 | 
			
		||||
	dbt deps --profiles-dir=. --project-dir=.
 | 
			
		||||
    #dbt run --profiles-dir=. --project-dir=. --full-refresh
 | 
			
		||||
	dbt run --profiles-dir=. --project-dir=. --full-refresh --select order_deliveries
 | 
			
		||||
	dbt run --profiles-dir=. --project-dir=. --full-refresh --select order_items
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -20,6 +20,8 @@ select
 | 
			
		|||
    {{ json_extract_scalar('_airbyte_data', ['commission'], ['commission']) }} as commission,
 | 
			
		||||
    {{ json_extract_scalar('_airbyte_data', ['isRejected'], ['isRejected']) }} as isrejected,
 | 
			
		||||
    {{ json_extract_scalar('_airbyte_data', ['quantityPromotion'], ['quantityPromotion']) }} as quantitypromotion,
 | 
			
		||||
    {{ json_extract_scalar('_airbyte_data', ['supplierCommission'], ['supplierCommission']) }} as suppliercommission,
 | 
			
		||||
    {{ json_extract_scalar('_airbyte_data', ['supplierCommissionTotal'], ['supplierCommissionTotal']) }} as suppliercommissiontotal,
 | 
			
		||||
    _airbyte_ab_id,
 | 
			
		||||
    _airbyte_emitted_at,
 | 
			
		||||
    {{ current_timestamp() }} as _airbyte_normalized_at
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -20,6 +20,8 @@ select
 | 
			
		|||
    cast(commission as {{ dbt_utils.type_float() }}) as commission,
 | 
			
		||||
    {{ cast_to_boolean('isrejected') }} as isrejected,
 | 
			
		||||
    cast(quantitypromotion as {{ dbt_utils.type_float() }}) as quantitypromotion,
 | 
			
		||||
    cast(supplierCommission as {{ dbt_utils.type_string() }}) as supplierCommission,
 | 
			
		||||
    cast(supplierCommissionTotal as {{ dbt_utils.type_float() }}) as supplierCommissionTotal,
 | 
			
		||||
    _airbyte_ab_id,
 | 
			
		||||
    _airbyte_emitted_at,
 | 
			
		||||
    {{ current_timestamp() }} as _airbyte_normalized_at
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -21,6 +21,8 @@ select
 | 
			
		|||
        'commission',
 | 
			
		||||
        boolean_to_string('isrejected'),
 | 
			
		||||
        'quantitypromotion',
 | 
			
		||||
        'supplierCommission',
 | 
			
		||||
        'supplierCommissionTotal',
 | 
			
		||||
    ]) }} as _airbyte_promotion_orders_hashid,
 | 
			
		||||
    tmp.*
 | 
			
		||||
from {{ ref('promotion_orders_ab2') }} tmp
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -25,6 +25,7 @@ select
 | 
			
		|||
    {{ json_extract_scalar('_airbyte_data', ['conditionForUser'], ['conditionForUser']) }} as conditionforuser,
 | 
			
		||||
    {{ json_extract_scalar('_airbyte_data', ['isUnlimitedQuantity'], ['isUnlimitedQuantity']) }} as isunlimitedquantity,
 | 
			
		||||
    {{ json_extract_scalar('_airbyte_data', ['isApplyForOrderWholesale'], ['isApplyForOrderWholesale']) }} as isapplyfororderwholesale,
 | 
			
		||||
    {{ json_extract_scalar('_airbyte_data', ['supplierCommission'], ['supplierCommission']) }} as suppliercommission,
 | 
			
		||||
    _airbyte_ab_id,
 | 
			
		||||
    _airbyte_emitted_at,
 | 
			
		||||
    {{ current_timestamp() }} as _airbyte_normalized_at
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -25,6 +25,7 @@ select
 | 
			
		|||
    cast(conditionforuser as {{ dbt_utils.type_string() }}) as conditionforuser,
 | 
			
		||||
    {{ cast_to_boolean('isunlimitedquantity') }} as isunlimitedquantity,
 | 
			
		||||
    {{ cast_to_boolean('isapplyfororderwholesale') }} as isapplyfororderwholesale,
 | 
			
		||||
    cast(supplierCommission as {{ dbt_utils.type_string() }}) as supplierCommission,
 | 
			
		||||
    _airbyte_ab_id,
 | 
			
		||||
    _airbyte_emitted_at,
 | 
			
		||||
    {{ current_timestamp() }} as _airbyte_normalized_at
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -26,6 +26,7 @@ select
 | 
			
		|||
        'conditionforuser',
 | 
			
		||||
        boolean_to_string('isunlimitedquantity'),
 | 
			
		||||
        boolean_to_string('isapplyfororderwholesale'),
 | 
			
		||||
        'supplierCommission',
 | 
			
		||||
    ]) }} as _airbyte_promotions_hashid,
 | 
			
		||||
    tmp.*
 | 
			
		||||
from {{ ref('promotions_ab2') }} tmp
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -27,6 +27,7 @@ select
 | 
			
		|||
    {{ adapter.quote('user') }} AS seller_id,
 | 
			
		||||
    {{ adapter.quote('order') }} AS order_id,
 | 
			
		||||
    {{ adapter.quote('product') }} AS product_id,
 | 
			
		||||
    cast({{ adapter.quote('promotions') }} AS jsonb) AS promotions,
 | 
			
		||||
    _airbyte_ab_id,
 | 
			
		||||
    _airbyte_emitted_at,
 | 
			
		||||
    {{ current_timestamp() }} as _airbyte_normalized_at,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -20,6 +20,9 @@ select
 | 
			
		|||
    -- cast({{ adapter.quote('sharepercent') }}::json->>'selly' AS numeric) AS share_percent_selly,
 | 
			
		||||
    {{ adapter.quote('supplier') }}::json->>'_id' AS supplier_id,
 | 
			
		||||
    {{ adapter.quote('supplier') }}::json->>'name' AS supplier_name,
 | 
			
		||||
    {{ adapter.quote('suppliercommission') }}::json->>'type' AS supplier_commission_type,
 | 
			
		||||
    cast({{ adapter.quote('suppliercommission') }}::json->>'value' AS numeric) AS supplier_commission_value,
 | 
			
		||||
    cast({{ adapter.quote('suppliercommissiontotal') }} AS numeric) AS supplier_commission_total,
 | 
			
		||||
    _airbyte_ab_id,
 | 
			
		||||
    _airbyte_emitted_at,
 | 
			
		||||
    {{ current_timestamp() }} as _airbyte_normalized_at,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -22,6 +22,8 @@ select
 | 
			
		|||
    cast({{ adapter.quote('options') }}::json->'bonus'->>'value' AS numeric) AS options_bonus_value,
 | 
			
		||||
    {{ adapter.quote('conditionforuser') }}::json->>'applyFor' AS condition_for_user_apply_for,
 | 
			
		||||
    {{ adapter.quote('conditionforuser') }}::json->>'gender' AS condition_for_user_gender,
 | 
			
		||||
    {{ adapter.quote('suppliercommission') }}::json->>'type' AS supplier_commission_type,
 | 
			
		||||
    cast({{ adapter.quote('suppliercommission') }}::json->>'value' AS numeric) AS supplier_commission_value,
 | 
			
		||||
    articleid AS article_id,
 | 
			
		||||
    isapplyfororderwholesale AS is_apply_for_order_wholesale,
 | 
			
		||||
    createdat::timestamp AS created_at,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue