diff --git a/.gitignore b/.gitignore index e43b0f9..3bd52c0 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,5 @@ .DS_Store +deploy +.DS_Store +**/*.log +.DS_Store diff --git a/container/.gitignore b/container/.gitignore new file mode 100644 index 0000000..fb03ec7 --- /dev/null +++ b/container/.gitignore @@ -0,0 +1,4 @@ +mysql +nginx +cube/conf/.cubestore +!docker-compose.yml \ No newline at end of file diff --git a/container/cube/conf/cube.js b/container/cube/conf/cube.js new file mode 100644 index 0000000..3587701 --- /dev/null +++ b/container/cube/conf/cube.js @@ -0,0 +1,5 @@ +module.exports = { + dbType: 'mysql', + apiSecret: 'your-secret-here', + webSockets: true +}; \ No newline at end of file diff --git a/container/cube/conf/model/cubes/area.yml b/container/cube/conf/model/cubes/area.yml new file mode 100644 index 0000000..4e468b6 --- /dev/null +++ b/container/cube/conf/model/cubes/area.yml @@ -0,0 +1,29 @@ +cubes: + - name: area + sql_table: inventory_v2.area + data_source: default + + joins: [] + + dimensions: + - name: id + sql: id + type: number + primary_key: true + + - name: code + sql: code + type: string + + - name: name + sql: name + type: string + + measures: + - name: count + type: count + + pre_aggregations: + # Pre-aggregation definitions go here. + # Learn more in the documentation: https://cube.dev/docs/caching/pre-aggregations/getting-started + diff --git a/container/cube/conf/model/cubes/auth_code.yml b/container/cube/conf/model/cubes/auth_code.yml new file mode 100644 index 0000000..41e6917 --- /dev/null +++ b/container/cube/conf/model/cubes/auth_code.yml @@ -0,0 +1,28 @@ +cubes: + - name: auth_code + sql_table: inventory_v2.auth_code + data_source: default + + joins: [] + + dimensions: + - name: code + sql: code + type: string + + - name: device_id + sql: device_id + type: string + + - name: expires_at + sql: expires_at + type: time + + measures: + - name: count + type: count + + pre_aggregations: + # Pre-aggregation definitions go here. + # Learn more in the documentation: https://cube.dev/docs/caching/pre-aggregations/getting-started + diff --git a/container/cube/conf/model/cubes/category.yml b/container/cube/conf/model/cubes/category.yml new file mode 100644 index 0000000..89e483e --- /dev/null +++ b/container/cube/conf/model/cubes/category.yml @@ -0,0 +1,45 @@ +cubes: + - name: category + sql_table: inventory_v2.category + data_source: default + + joins: [] + + dimensions: + - name: id + sql: id + type: number + primary_key: true + + - name: name + sql: name + type: string + + - name: shortname + sql: "{CUBE}.`shortName`" + type: string + + - name: title + sql: title + type: string + + - name: titlecn + sql: "{CUBE}.`titleCN`" + type: string + + - name: createdat + sql: "{CUBE}.`createdAt`" + type: time + + - name: updatedat + sql: "{CUBE}.`updatedAt`" + type: time + + measures: + - name: count + type: count + + pre_aggregations: + # Pre-aggregation definitions go here. + # Learn more in the documentation: https://cube.dev/docs/caching/pre-aggregations/getting-started + diff --git a/container/cube/conf/model/cubes/category_attribute.yml b/container/cube/conf/model/cubes/category_attribute.yml new file mode 100644 index 0000000..b221899 --- /dev/null +++ b/container/cube/conf/model/cubes/category_attribute.yml @@ -0,0 +1,32 @@ +cubes: + - name: category_attribute + sql_table: inventory_v2.category_attribute + data_source: default + + joins: + - name: category + sql: "{CUBE}.category_id = {category.id}" + relationship: many_to_one + + dimensions: + - name: id + sql: id + type: number + primary_key: true + + - name: createdat + sql: "{CUBE}.`createdAt`" + type: time + + - name: updatedat + sql: "{CUBE}.`updatedAt`" + type: time + + measures: + - name: count + type: count + + pre_aggregations: + # Pre-aggregation definitions go here. + # Learn more in the documentation: https://cube.dev/docs/caching/pre-aggregations/getting-started + diff --git a/container/cube/conf/model/cubes/category_v2.yml b/container/cube/conf/model/cubes/category_v2.yml new file mode 100644 index 0000000..c7de255 --- /dev/null +++ b/container/cube/conf/model/cubes/category_v2.yml @@ -0,0 +1,41 @@ +cubes: + - name: category_v2 + sql_table: inventory_v2.category_v2 + data_source: default + + joins: [] + + dimensions: + - name: id + sql: id + type: number + primary_key: true + + - name: name + sql: name + type: string + + - name: title + sql: title + type: string + + - name: titlecn + sql: "{CUBE}.`titleCN`" + type: string + + - name: createdat + sql: "{CUBE}.`createdAt`" + type: time + + - name: updatedat + sql: "{CUBE}.`updatedAt`" + type: time + + measures: + - name: count + type: count + + pre_aggregations: + # Pre-aggregation definitions go here. + # Learn more in the documentation: https://cube.dev/docs/caching/pre-aggregations/getting-started + diff --git a/container/cube/conf/model/cubes/customer.yml b/container/cube/conf/model/cubes/customer.yml new file mode 100644 index 0000000..26e7cfe --- /dev/null +++ b/container/cube/conf/model/cubes/customer.yml @@ -0,0 +1,87 @@ +cubes: + - name: customer + sql_table: inventory_v2.customer + data_source: default + + joins: + - name: site + sql: "{CUBE}.site_id = {site.id}" + relationship: many_to_one + + dimensions: + - name: id + sql: id + type: number + primary_key: true + - name: customer_state + sql: "JSON_EXTRACT({customer.shipping}, '$.state')" + type: string + + - name: avatar + sql: avatar + type: string + + - name: billing + sql: billing + type: string + + - name: email + sql: email + type: string + + - name: first_name + sql: first_name + type: string + + - name: fullname + sql: fullname + type: string + + - name: last_name + sql: last_name + type: string + + - name: origin_id + sql: origin_id + type: string + + - name: phone + sql: phone + type: string + + - name: raw + sql: raw + type: string + + - name: shipping + sql: shipping + type: string + + - name: username + sql: username + type: string + + - name: created_at + sql: created_at + type: time + + - name: site_created_at + sql: site_created_at + type: time + + - name: site_updated_at + sql: site_updated_at + type: time + + - name: updated_at + sql: updated_at + type: time + + measures: + - name: count + type: count + + pre_aggregations: + # Pre-aggregation definitions go here. + # Learn more in the documentation: https://cube.dev/docs/caching/pre-aggregations/getting-started + diff --git a/container/cube/conf/model/cubes/customer_tag.yml b/container/cube/conf/model/cubes/customer_tag.yml new file mode 100644 index 0000000..415d2a3 --- /dev/null +++ b/container/cube/conf/model/cubes/customer_tag.yml @@ -0,0 +1,37 @@ +cubes: + - name: customer_tag + sql_table: inventory_v2.customer_tag + data_source: default + + joins: [] + + dimensions: + - name: id + sql: id + type: number + primary_key: true + + - name: email + sql: email + type: string + + - name: tag + sql: tag + type: string + + - name: createdat + sql: "{CUBE}.`createdAt`" + type: time + + - name: updatedat + sql: "{CUBE}.`updatedAt`" + type: time + + measures: + - name: count + type: count + + pre_aggregations: + # Pre-aggregation definitions go here. + # Learn more in the documentation: https://cube.dev/docs/caching/pre-aggregations/getting-started + diff --git a/container/cube/conf/model/cubes/device_whitelist.yml b/container/cube/conf/model/cubes/device_whitelist.yml new file mode 100644 index 0000000..fe59897 --- /dev/null +++ b/container/cube/conf/model/cubes/device_whitelist.yml @@ -0,0 +1,29 @@ +cubes: + - name: device_whitelist + sql_table: inventory_v2.device_whitelist + data_source: default + + joins: [] + + dimensions: + - name: id + sql: id + type: number + primary_key: true + + - name: device_id + sql: device_id + type: string + + - name: created_at + sql: created_at + type: time + + measures: + - name: count + type: count + + pre_aggregations: + # Pre-aggregation definitions go here. + # Learn more in the documentation: https://cube.dev/docs/caching/pre-aggregations/getting-started + diff --git a/container/cube/conf/model/cubes/dict.yml b/container/cube/conf/model/cubes/dict.yml new file mode 100644 index 0000000..19cd952 --- /dev/null +++ b/container/cube/conf/model/cubes/dict.yml @@ -0,0 +1,37 @@ +cubes: + - name: dict + sql_table: inventory_v2.dict + data_source: default + + joins: [] + + dimensions: + - name: id + sql: id + type: number + primary_key: true + + - name: name + sql: name + type: string + + - name: title + sql: title + type: string + + - name: createdat + sql: "{CUBE}.`createdAt`" + type: time + + - name: updatedat + sql: "{CUBE}.`updatedAt`" + type: time + + measures: + - name: count + type: count + + pre_aggregations: + # Pre-aggregation definitions go here. + # Learn more in the documentation: https://cube.dev/docs/caching/pre-aggregations/getting-started + diff --git a/container/cube/conf/model/cubes/dict_item.yml b/container/cube/conf/model/cubes/dict_item.yml new file mode 100644 index 0000000..d7ae7b7 --- /dev/null +++ b/container/cube/conf/model/cubes/dict_item.yml @@ -0,0 +1,60 @@ +cubes: + - name: dict_item + sql_table: inventory_v2.dict_item + data_source: default + + joins: + - name: dict + sql: "{CUBE}.dict_id = {dict.id}" + relationship: many_to_one + + dimensions: + - name: id + sql: id + type: number + primary_key: true + + - name: description + sql: description + type: string + + - name: image + sql: image + type: string + + - name: name + sql: name + type: string + + - name: shortname + sql: "{CUBE}.`shortName`" + type: string + + - name: title + sql: title + type: string + + - name: titlecn + sql: "{CUBE}.`titleCN`" + type: string + + - name: value + sql: value + type: string + + - name: createdat + sql: "{CUBE}.`createdAt`" + type: time + + - name: updatedat + sql: "{CUBE}.`updatedAt`" + type: time + + measures: + - name: count + type: count + + pre_aggregations: + # Pre-aggregation definitions go here. + # Learn more in the documentation: https://cube.dev/docs/caching/pre-aggregations/getting-started + diff --git a/container/cube/conf/model/cubes/order.yml b/container/cube/conf/model/cubes/order.yml new file mode 100644 index 0000000..1ec175d --- /dev/null +++ b/container/cube/conf/model/cubes/order.yml @@ -0,0 +1,160 @@ +cubes: + - name: order + sql_table: inventory_v2.order + data_source: default + + joins: + - name: customer + sql: "{CUBE}.customer_id = {customer.id}" + relationship: many_to_one + + - name: shipment + sql: "{CUBE}.shipment_id = {shipment.id}" + relationship: many_to_one + + - name: site + sql: "{CUBE}.`siteId` = {site.id}" + relationship: many_to_one + + dimensions: + - name: id + sql: id + type: number + primary_key: true + + - name: billing + sql: billing + type: string + + - name: cart_hash + sql: cart_hash + type: string + + - name: created_via + sql: created_via + type: string + + - name: currency + sql: currency + type: string + + - name: currency_symbol + sql: currency_symbol + type: string + + - name: customer_email + sql: customer_email + type: string + + - name: customer_ip_address + sql: customer_ip_address + type: string + + - name: customer_note + sql: customer_note + type: string + + - name: customer_user_agent + sql: customer_user_agent + type: string + + - name: device_type + sql: device_type + type: string + + - name: externalorderid + sql: "{CUBE}.`externalOrderId`" + type: string + + - name: meta_data + sql: meta_data + type: string + + - name: number + sql: number + type: string + + - name: order_key + sql: order_key + type: string + + - name: orderstatus + sql: "{CUBE}.`orderStatus`" + type: string + + - name: payment_method + sql: payment_method + type: string + + - name: payment_method_title + sql: payment_method_title + type: string + + - name: payment_url + sql: payment_url + type: string + + - name: shipping + sql: shipping + type: string + + - name: source_type + sql: source_type + type: string + + - name: status + sql: status + type: string + + - name: transaction_id + sql: transaction_id + type: string + + - name: utm_source + sql: utm_source + type: string + + - name: createdat + sql: "{CUBE}.`createdAt`" + type: time + + - name: date_created + sql: date_created + type: time + + - name: updatedat + sql: "{CUBE}.`updatedAt`" + type: time + + - name: date_completed + sql: date_completed + type: time + + - name: date_modified + sql: date_modified + type: time + + - name: date_paid + sql: date_paid + type: time + + measures: + - name: count + type: count + + - name: discount_total + sql: discount_total + type: sum + + - name: shipping_total + sql: shipping_total + type: sum + + - name: total + sql: total + type: sum + + pre_aggregations: + # Pre-aggregation definitions go here. + # Learn more in the documentation: https://cube.dev/docs/caching/pre-aggregations/getting-started + diff --git a/container/cube/conf/model/cubes/order_coupon.yml b/container/cube/conf/model/cubes/order_coupon.yml new file mode 100644 index 0000000..7ab2678 --- /dev/null +++ b/container/cube/conf/model/cubes/order_coupon.yml @@ -0,0 +1,64 @@ +cubes: + - name: order_coupon + sql_table: inventory_v2.order_coupon + data_source: default + + joins: + - name: order + sql: "{CUBE}.`orderId` = {order.id}" + relationship: many_to_one + + - name: site + sql: "{CUBE}.`siteId` = {site.id}" + relationship: many_to_one + + dimensions: + - name: id + sql: id + type: number + primary_key: true + + - name: code + sql: code + type: string + + - name: discount + sql: discount + type: string + + - name: discount_tax + sql: discount_tax + type: string + + - name: discount_type + sql: discount_type + type: string + + - name: externalordercouponid + sql: "{CUBE}.`externalOrderCouponId`" + type: string + + - name: externalorderid + sql: "{CUBE}.`externalOrderId`" + type: string + + - name: createdat + sql: "{CUBE}.`createdAt`" + type: time + + - name: updatedat + sql: "{CUBE}.`updatedAt`" + type: time + + measures: + - name: count + type: count + + - name: nominal_amount + sql: nominal_amount + type: sum + + pre_aggregations: + # Pre-aggregation definitions go here. + # Learn more in the documentation: https://cube.dev/docs/caching/pre-aggregations/getting-started + diff --git a/container/cube/conf/model/cubes/order_fee.yml b/container/cube/conf/model/cubes/order_fee.yml new file mode 100644 index 0000000..a74ed41 --- /dev/null +++ b/container/cube/conf/model/cubes/order_fee.yml @@ -0,0 +1,64 @@ +cubes: + - name: order_fee + sql_table: inventory_v2.order_fee + data_source: default + + joins: + - name: order + sql: "{CUBE}.`orderId` = {order.id}" + relationship: many_to_one + + - name: site + sql: "{CUBE}.`siteId` = {site.id}" + relationship: many_to_one + + dimensions: + - name: id + sql: id + type: number + primary_key: true + + - name: amount + sql: amount + type: string + + - name: externalorderfeeid + sql: "{CUBE}.`externalOrderFeeId`" + type: string + + - name: externalorderid + sql: "{CUBE}.`externalOrderId`" + type: string + + - name: name + sql: name + type: string + + - name: tax_class + sql: tax_class + type: string + + - name: tax_status + sql: tax_status + type: string + + - name: createdat + sql: "{CUBE}.`createdAt`" + type: time + + - name: updatedat + sql: "{CUBE}.`updatedAt`" + type: time + + measures: + - name: count + type: count + + - name: total + sql: total + type: sum + + pre_aggregations: + # Pre-aggregation definitions go here. + # Learn more in the documentation: https://cube.dev/docs/caching/pre-aggregations/getting-started + diff --git a/container/cube/conf/model/cubes/order_fulfillment.yml b/container/cube/conf/model/cubes/order_fulfillment.yml new file mode 100644 index 0000000..1f7b767 --- /dev/null +++ b/container/cube/conf/model/cubes/order_fulfillment.yml @@ -0,0 +1,68 @@ +cubes: + - name: order_fulfillment + sql_table: inventory_v2.order_fulfillment + data_source: default + + joins: + - name: order + sql: "{CUBE}.order_id = {order.id}" + relationship: many_to_one + + - name: site + sql: "{CUBE}.site_id = {site.id}" + relationship: many_to_one + + dimensions: + - name: id + sql: id + type: number + primary_key: true + + - name: external_fulfillment_id + sql: external_fulfillment_id + type: string + + - name: external_order_id + sql: external_order_id + type: string + + - name: items + sql: items + type: string + + - name: shipping_method + sql: shipping_method + type: string + + - name: shipping_provider + sql: shipping_provider + type: string + + - name: status + sql: status + type: string + + - name: tracking_number + sql: tracking_number + type: string + + - name: created_at + sql: created_at + type: time + + - name: date_created + sql: date_created + type: time + + - name: updated_at + sql: updated_at + type: time + + measures: + - name: count + type: count + + pre_aggregations: + # Pre-aggregation definitions go here. + # Learn more in the documentation: https://cube.dev/docs/caching/pre-aggregations/getting-started + diff --git a/container/cube/conf/model/cubes/order_item.yml b/container/cube/conf/model/cubes/order_item.yml new file mode 100644 index 0000000..e8d81fa --- /dev/null +++ b/container/cube/conf/model/cubes/order_item.yml @@ -0,0 +1,112 @@ +cubes: + - name: order_item + sql_table: inventory_v2.order_item + data_source: default + + joins: + - name: order + sql: "{CUBE}.`orderId` = {order.id}" + relationship: many_to_one + + - name: site + sql: "{CUBE}.`siteId` = {site.id}" + relationship: many_to_one + + dimensions: + - name: id + sql: id + type: number + primary_key: true + + - name: bundled_by + sql: bundled_by + type: string + + - name: bundled_item_title + sql: bundled_item_title + type: string + + - name: bundled_items + sql: bundled_items + type: string + + - name: externalorderid + sql: "{CUBE}.`externalOrderId`" + type: string + + - name: externalorderitemid + sql: "{CUBE}.`externalOrderItemId`" + type: string + + - name: externalproductid + sql: "{CUBE}.`externalProductId`" + type: string + + - name: externalvariationid + sql: "{CUBE}.`externalVariationId`" + type: string + + - name: global_unique_id + sql: global_unique_id + type: string + + - name: image + sql: image + type: string + + - name: meta_data + sql: meta_data + type: string + + - name: name + sql: name + type: string + + - name: parent_name + sql: parent_name + type: string + + - name: sku + sql: sku + type: string + + - name: tax_class + sql: tax_class + type: string + + - name: taxes + sql: taxes + type: string + + - name: createdat + sql: "{CUBE}.`createdAt`" + type: time + + - name: updatedat + sql: "{CUBE}.`updatedAt`" + type: time + + measures: + - name: count + type: count + + - name: price + sql: price + type: sum + + - name: quantity + sql: quantity + type: sum + + - name: subtotal + sql: subtotal + type: sum + + - name: total + sql: total + type: sum + + pre_aggregations: + # Pre-aggregation definitions go here. + # Learn more in the documentation: https://cube.dev/docs/caching/pre-aggregations/getting-started + diff --git a/container/cube/conf/model/cubes/order_item_original.yml b/container/cube/conf/model/cubes/order_item_original.yml new file mode 100644 index 0000000..4d68142 --- /dev/null +++ b/container/cube/conf/model/cubes/order_item_original.yml @@ -0,0 +1,56 @@ +cubes: + - name: order_item_original + sql_table: inventory_v2.order_item_original + data_source: default + + joins: + - name: order + sql: "{CUBE}.order_id = {order.id}" + relationship: many_to_one + + - name: product + sql: "{CUBE}.`productId` = {product.id}" + relationship: many_to_one + + - name: site + sql: "{CUBE}.`siteId` = {site.id}" + relationship: many_to_one + + dimensions: + - name: id + sql: id + type: number + primary_key: true + + - name: externalorderitemid + sql: "{CUBE}.`externalOrderItemId`" + type: string + + - name: name + sql: name + type: string + + - name: sku + sql: sku + type: string + + - name: createdat + sql: "{CUBE}.`createdAt`" + type: time + + - name: updatedat + sql: "{CUBE}.`updatedAt`" + type: time + + measures: + - name: count + type: count + + - name: quantity + sql: quantity + type: sum + + pre_aggregations: + # Pre-aggregation definitions go here. + # Learn more in the documentation: https://cube.dev/docs/caching/pre-aggregations/getting-started + diff --git a/container/cube/conf/model/cubes/order_note.yml b/container/cube/conf/model/cubes/order_note.yml new file mode 100644 index 0000000..c1575f6 --- /dev/null +++ b/container/cube/conf/model/cubes/order_note.yml @@ -0,0 +1,40 @@ +cubes: + - name: order_note + sql_table: inventory_v2.order_note + data_source: default + + joins: + - name: order + sql: "{CUBE}.`orderId` = {order.id}" + relationship: many_to_one + + - name: user + sql: "{CUBE}.`userId` = {user.id}" + relationship: many_to_one + + dimensions: + - name: id + sql: id + type: number + primary_key: true + + - name: content + sql: content + type: string + + - name: createdat + sql: "{CUBE}.`createdAt`" + type: time + + - name: updatedat + sql: "{CUBE}.`updatedAt`" + type: time + + measures: + - name: count + type: count + + pre_aggregations: + # Pre-aggregation definitions go here. + # Learn more in the documentation: https://cube.dev/docs/caching/pre-aggregations/getting-started + diff --git a/container/cube/conf/model/cubes/order_refund.yml b/container/cube/conf/model/cubes/order_refund.yml new file mode 100644 index 0000000..357f123 --- /dev/null +++ b/container/cube/conf/model/cubes/order_refund.yml @@ -0,0 +1,60 @@ +cubes: + - name: order_refund + sql_table: inventory_v2.order_refund + data_source: default + + joins: + - name: order + sql: "{CUBE}.`orderId` = {order.id}" + relationship: many_to_one + + - name: site + sql: "{CUBE}.`siteId` = {site.id}" + relationship: many_to_one + + dimensions: + - name: id + sql: id + type: number + primary_key: true + + - name: externalorderid + sql: "{CUBE}.`externalOrderId`" + type: string + + - name: externalrefundid + sql: "{CUBE}.`externalRefundId`" + type: string + + - name: meta_data + sql: meta_data + type: string + + - name: reason + sql: reason + type: string + + - name: createdat + sql: "{CUBE}.`createdAt`" + type: time + + - name: date_created + sql: date_created + type: time + + - name: updatedat + sql: "{CUBE}.`updatedAt`" + type: time + + measures: + - name: count + type: count + + - name: amount + sql: amount + type: sum + + pre_aggregations: + # Pre-aggregation definitions go here. + # Learn more in the documentation: https://cube.dev/docs/caching/pre-aggregations/getting-started + diff --git a/container/cube/conf/model/cubes/order_refund_item.yml b/container/cube/conf/model/cubes/order_refund_item.yml new file mode 100644 index 0000000..714f89b --- /dev/null +++ b/container/cube/conf/model/cubes/order_refund_item.yml @@ -0,0 +1,76 @@ +cubes: + - name: order_refund_item + sql_table: inventory_v2.order_refund_item + data_source: default + + joins: + - name: site + sql: "{CUBE}.`siteId` = {site.id}" + relationship: many_to_one + + dimensions: + - name: id + sql: id + type: number + primary_key: true + + - name: externalproductid + sql: "{CUBE}.`externalProductId`" + type: string + + - name: externalrefundid + sql: "{CUBE}.`externalRefundId`" + type: string + + - name: externalrefunditemid + sql: "{CUBE}.`externalRefundItemId`" + type: string + + - name: externalvariationid + sql: "{CUBE}.`externalVariationId`" + type: string + + - name: name + sql: name + type: string + + - name: sku + sql: sku + type: string + + - name: tax_class + sql: tax_class + type: string + + - name: createdat + sql: "{CUBE}.`createdAt`" + type: time + + - name: updatedat + sql: "{CUBE}.`updatedAt`" + type: time + + measures: + - name: count + type: count + + - name: price + sql: price + type: sum + + - name: quantity + sql: quantity + type: sum + + - name: subtotal + sql: subtotal + type: sum + + - name: total + sql: total + type: sum + + pre_aggregations: + # Pre-aggregation definitions go here. + # Learn more in the documentation: https://cube.dev/docs/caching/pre-aggregations/getting-started + diff --git a/container/cube/conf/model/cubes/order_sale.yml b/container/cube/conf/model/cubes/order_sale.yml new file mode 100644 index 0000000..162e62b --- /dev/null +++ b/container/cube/conf/model/cubes/order_sale.yml @@ -0,0 +1,84 @@ +cubes: + - name: order_sale + sql_table: inventory_v2.order_sale + data_source: default + + joins: + - name: order + sql: "{CUBE}.`orderId` = {order.id}" + relationship: many_to_one + + - name: product + sql: "{CUBE}.`productId` = {product.id}" + relationship: many_to_one + + - name: site + sql: "{CUBE}.`siteId` = {site.id}" + relationship: many_to_one + + dimensions: + - name: id + sql: id + type: number + primary_key: true + + - name: brand + sql: brand + type: string + + - name: category + sql: category + type: string + + - name: externalorderitemid + sql: "{CUBE}.`externalOrderItemId`" + type: string + + - name: flavor + sql: flavor + type: string + + - name: humidity + sql: humidity + type: string + + - name: name + sql: name + type: string + + - name: size + sql: size + type: string + + - name: sku + sql: sku + type: string + + - name: strength + sql: strength + type: string + + - name: version + sql: version + type: string + + - name: createdat + sql: "{CUBE}.`createdAt`" + type: time + + - name: updatedat + sql: "{CUBE}.`updatedAt`" + type: time + + measures: + - name: count + type: count + + - name: quantity + sql: quantity + type: sum + + pre_aggregations: + # Pre-aggregation definitions go here. + # Learn more in the documentation: https://cube.dev/docs/caching/pre-aggregations/getting-started + diff --git a/container/cube/conf/model/cubes/order_sale_original.yml b/container/cube/conf/model/cubes/order_sale_original.yml new file mode 100644 index 0000000..78f00f9 --- /dev/null +++ b/container/cube/conf/model/cubes/order_sale_original.yml @@ -0,0 +1,60 @@ +cubes: + - name: order_sale_original + sql_table: inventory_v2.order_sale_original + data_source: default + + joins: + - name: order + sql: "{CUBE}.order_id = {order.id}" + relationship: many_to_one + + - name: product + sql: "{CUBE}.`productId` = {product.id}" + relationship: many_to_one + + - name: site + sql: "{CUBE.siteid} = {site.id}" + relationship: many_to_one + + dimensions: + - name: id + sql: id + type: number + primary_key: true + + - name: externalorderitemid + sql: "{CUBE}.`externalOrderItemId`" + type: string + + - name: name + sql: name + type: string + + - name: siteid + sql: "{CUBE}.`siteId`" + type: string + + - name: sku + sql: sku + type: string + + - name: createdat + sql: "{CUBE}.`createdAt`" + type: time + + - name: updatedat + sql: "{CUBE}.`updatedAt`" + type: time + + measures: + - name: count + type: count + + - name: quantity + sql: quantity + type: sum + + pre_aggregations: + # Pre-aggregation definitions go here. + # Learn more in the documentation: https://cube.dev/docs/caching/pre-aggregations/getting-started + diff --git a/container/cube/conf/model/cubes/order_shipment.yml b/container/cube/conf/model/cubes/order_shipment.yml new file mode 100644 index 0000000..faf5a3a --- /dev/null +++ b/container/cube/conf/model/cubes/order_shipment.yml @@ -0,0 +1,40 @@ +cubes: + - name: order_shipment + sql_table: inventory_v2.order_shipment + data_source: default + + joins: + - name: order + sql: "{CUBE}.order_id = {order.id}" + relationship: many_to_one + + - name: shipment + sql: "{CUBE}.shipment_id = {shipment.id}" + relationship: many_to_one + + - name: site_stock_points_stock_point + sql: "{CUBE}.`stockPointId` = {site_stock_points_stock_point}.`stockPointId`" + relationship: many_to_one + + - name: site_v2_stock_points_stock_point + sql: "{CUBE}.`stockPointId` = {site_v2_stock_points_stock_point}.`stockPointId`" + relationship: many_to_one + + - name: stock_point + sql: "{CUBE}.`stockPointId` = {stock_point.id}" + relationship: many_to_one + + dimensions: + - name: id + sql: id + type: number + primary_key: true + + measures: + - name: count + type: count + + pre_aggregations: + # Pre-aggregation definitions go here. + # Learn more in the documentation: https://cube.dev/docs/caching/pre-aggregations/getting-started + diff --git a/container/cube/conf/model/cubes/order_shipping.yml b/container/cube/conf/model/cubes/order_shipping.yml new file mode 100644 index 0000000..c7778fb --- /dev/null +++ b/container/cube/conf/model/cubes/order_shipping.yml @@ -0,0 +1,60 @@ +cubes: + - name: order_shipping + sql_table: inventory_v2.order_shipping + data_source: default + + joins: + - name: order + sql: "{CUBE}.`orderId` = {order.id}" + relationship: many_to_one + + - name: site + sql: "{CUBE}.`siteId` = {site.id}" + relationship: many_to_one + + dimensions: + - name: id + sql: id + type: number + primary_key: true + + - name: externalorderid + sql: "{CUBE}.`externalOrderId`" + type: string + + - name: externalordershippingid + sql: "{CUBE}.`externalOrderShippingId`" + type: string + + - name: instance_id + sql: instance_id + type: string + + - name: method_id + sql: method_id + type: string + + - name: method_title + sql: method_title + type: string + + - name: createdat + sql: "{CUBE}.`createdAt`" + type: time + + - name: updatedat + sql: "{CUBE}.`updatedAt`" + type: time + + measures: + - name: count + type: count + + - name: total + sql: total + type: sum + + pre_aggregations: + # Pre-aggregation definitions go here. + # Learn more in the documentation: https://cube.dev/docs/caching/pre-aggregations/getting-started + diff --git a/container/cube/conf/model/cubes/order_tracking.yml b/container/cube/conf/model/cubes/order_tracking.yml new file mode 100644 index 0000000..7c05b60 --- /dev/null +++ b/container/cube/conf/model/cubes/order_tracking.yml @@ -0,0 +1,88 @@ +cubes: + - name: order_tracking + sql_table: inventory_v2.order_tracking + data_source: default + + joins: + - name: order + sql: "{CUBE.orderid} = {order.id}" + relationship: many_to_one + + - name: shipment + sql: "{CUBE.shipment_id} = {shipment.id}" + relationship: many_to_one + + - name: site + sql: "{CUBE.siteid} = {site.id}" + relationship: many_to_one + + dimensions: + - name: id + sql: id + type: number + primary_key: true + + - name: custom_tracking_provider + sql: custom_tracking_provider + type: string + + - name: externalorderid + sql: "{CUBE}.`externalOrderId`" + type: string + + - name: orderid + sql: "{CUBE}.`orderId`" + type: string + + - name: shipment_id + sql: shipment_id + type: string + + - name: siteid + sql: "{CUBE}.`siteId`" + type: string + + - name: status_shipped + sql: status_shipped + type: string + + - name: tracking_id + sql: tracking_id + type: string + + - name: tracking_link + sql: tracking_link + type: string + + - name: tracking_number + sql: tracking_number + type: string + + - name: tracking_product_code + sql: tracking_product_code + type: string + + - name: tracking_provider + sql: tracking_provider + type: string + + - name: createdat + sql: "{CUBE}.`createdAt`" + type: time + + - name: updatedat + sql: "{CUBE}.`updatedAt`" + type: time + + - name: date_shipped + sql: date_shipped + type: time + + measures: + - name: count + type: count + + pre_aggregations: + # Pre-aggregation definitions go here. + # Learn more in the documentation: https://cube.dev/docs/caching/pre-aggregations/getting-started + diff --git a/container/cube/conf/model/cubes/order_tracking_product.yml b/container/cube/conf/model/cubes/order_tracking_product.yml new file mode 100644 index 0000000..d1b914a --- /dev/null +++ b/container/cube/conf/model/cubes/order_tracking_product.yml @@ -0,0 +1,48 @@ +cubes: + - name: order_tracking_product + sql_table: inventory_v2.order_tracking_product + data_source: default + + joins: + - name: order_tracking + sql: "{CUBE}.`orderTrackingId` = {order_tracking.id}" + relationship: many_to_one + + - name: product + sql: "{CUBE}.`productId` = {product.id}" + relationship: many_to_one + + dimensions: + - name: id + sql: id + type: number + primary_key: true + + - name: nume + sql: nume + type: string + + - name: sku + sql: sku + type: string + + - name: createdat + sql: "{CUBE}.`createdAt`" + type: time + + - name: updatedat + sql: "{CUBE}.`updatedAt`" + type: time + + measures: + - name: count + type: count + + - name: quantity + sql: quantity + type: sum + + pre_aggregations: + # Pre-aggregation definitions go here. + # Learn more in the documentation: https://cube.dev/docs/caching/pre-aggregations/getting-started + diff --git a/container/cube/conf/model/cubes/product.yml b/container/cube/conf/model/cubes/product.yml new file mode 100644 index 0000000..8aa3b0d --- /dev/null +++ b/container/cube/conf/model/cubes/product.yml @@ -0,0 +1,72 @@ +cubes: + - name: product + sql_table: inventory_v2.product + data_source: default + + joins: + - name: category + sql: "{CUBE}.`categoryId` = {category.id}" + relationship: many_to_one + + dimensions: + - name: id + sql: id + type: number + primary_key: true + + - name: description + sql: description + type: string + + - name: image + sql: image + type: string + + - name: name + sql: name + type: string + + - name: namecn + sql: "{CUBE}.`nameCn`" + type: string + + - name: shortdescription + sql: "{CUBE}.`shortDescription`" + type: string + + - name: siteskus + sql: "{CUBE}.`siteSkus`" + type: string + + - name: sku + sql: sku + type: string + + - name: type + sql: type + type: string + + - name: createdat + sql: "{CUBE}.`createdAt`" + type: time + + - name: updatedat + sql: "{CUBE}.`updatedAt`" + type: time + + measures: + - name: count + type: count + + - name: price + sql: price + type: sum + + - name: promotionprice + sql: "{CUBE}.`promotionPrice`" + type: sum + + pre_aggregations: + # Pre-aggregation definitions go here. + # Learn more in the documentation: https://cube.dev/docs/caching/pre-aggregations/getting-started + diff --git a/container/cube/conf/model/cubes/product_attributes_dict_item.yml b/container/cube/conf/model/cubes/product_attributes_dict_item.yml new file mode 100644 index 0000000..e08595a --- /dev/null +++ b/container/cube/conf/model/cubes/product_attributes_dict_item.yml @@ -0,0 +1,28 @@ +cubes: + - name: product_attributes_dict_item + sql_table: inventory_v2.product_attributes_dict_item + data_source: default + + joins: + - name: dict_item + sql: "{CUBE}.dictItemId = {dict_item.id}" + relationship: many_to_one + + - name: product + sql: "{CUBE}.productId = {product.id}" + relationship: many_to_one + + dimensions: + - name: dictItemId + sql: dictItemId + type: number + primary_key: true + + measures: + - name: count + type: count + + pre_aggregations: + # Pre-aggregation definitions go here. + # Learn more in the documentation: https://cube.dev/docs/caching/pre-aggregations/getting-started + diff --git a/container/cube/conf/model/cubes/product_site_sku.yml b/container/cube/conf/model/cubes/product_site_sku.yml new file mode 100644 index 0000000..9419e27 --- /dev/null +++ b/container/cube/conf/model/cubes/product_site_sku.yml @@ -0,0 +1,36 @@ +cubes: + - name: product_site_sku + sql_table: inventory_v2.product_site_sku + data_source: default + + joins: + - name: product + sql: "{CUBE}.`productId` = {product.id}" + relationship: many_to_one + + dimensions: + - name: id + sql: id + type: number + primary_key: true + + - name: sitesku + sql: "{CUBE}.`siteSku`" + type: string + + - name: createdat + sql: "{CUBE}.`createdAt`" + type: time + + - name: updatedat + sql: "{CUBE}.`updatedAt`" + type: time + + measures: + - name: count + type: count + + pre_aggregations: + # Pre-aggregation definitions go here. + # Learn more in the documentation: https://cube.dev/docs/caching/pre-aggregations/getting-started + diff --git a/container/cube/conf/model/cubes/product_stock_component.yml b/container/cube/conf/model/cubes/product_stock_component.yml new file mode 100644 index 0000000..57c5158 --- /dev/null +++ b/container/cube/conf/model/cubes/product_stock_component.yml @@ -0,0 +1,40 @@ +cubes: + - name: product_stock_component + sql_table: inventory_v2.product_stock_component + data_source: default + + joins: + - name: product + sql: "{CUBE}.`productId` = {product.id}" + relationship: many_to_one + + dimensions: + - name: id + sql: id + type: number + primary_key: true + + - name: sku + sql: sku + type: string + + - name: createdat + sql: "{CUBE}.`createdAt`" + type: time + + - name: updatedat + sql: "{CUBE}.`updatedAt`" + type: time + + measures: + - name: count + type: count + + - name: quantity + sql: quantity + type: sum + + pre_aggregations: + # Pre-aggregation definitions go here. + # Learn more in the documentation: https://cube.dev/docs/caching/pre-aggregations/getting-started + diff --git a/container/cube/conf/model/cubes/product_v2.yml b/container/cube/conf/model/cubes/product_v2.yml new file mode 100644 index 0000000..5190e5f --- /dev/null +++ b/container/cube/conf/model/cubes/product_v2.yml @@ -0,0 +1,64 @@ +cubes: + - name: product_v2 + sql_table: inventory_v2.product_v2 + data_source: default + + joins: + - name: category + sql: "{CUBE}.`categoryId` = {category.id}" + relationship: many_to_one + + dimensions: + - name: id + sql: id + type: number + primary_key: true + + - name: description + sql: description + type: string + + - name: name + sql: name + type: string + + - name: namecn + sql: "{CUBE}.`nameCn`" + type: string + + - name: shortdescription + sql: "{CUBE}.`shortDescription`" + type: string + + - name: sku + sql: sku + type: string + + - name: type + sql: type + type: string + + - name: createdat + sql: "{CUBE}.`createdAt`" + type: time + + - name: updatedat + sql: "{CUBE}.`updatedAt`" + type: time + + measures: + - name: count + type: count + + - name: price + sql: price + type: sum + + - name: promotionprice + sql: "{CUBE}.`promotionPrice`" + type: sum + + pre_aggregations: + # Pre-aggregation definitions go here. + # Learn more in the documentation: https://cube.dev/docs/caching/pre-aggregations/getting-started + diff --git a/container/cube/conf/model/cubes/product_v2_attributes_dict_item.yml b/container/cube/conf/model/cubes/product_v2_attributes_dict_item.yml new file mode 100644 index 0000000..f6f681b --- /dev/null +++ b/container/cube/conf/model/cubes/product_v2_attributes_dict_item.yml @@ -0,0 +1,28 @@ +cubes: + - name: product_v2_attributes_dict_item + sql_table: inventory_v2.product_v2_attributes_dict_item + data_source: default + + joins: + - name: dict_item + sql: "{CUBE}.dictItemId = {dict_item.id}" + relationship: many_to_one + + - name: product_v2 + sql: "{CUBE}.productV2Id = {product_v2.id}" + relationship: many_to_one + + dimensions: + - name: dictItemId + sql: dictItemId + type: number + primary_key: true + + measures: + - name: count + type: count + + pre_aggregations: + # Pre-aggregation definitions go here. + # Learn more in the documentation: https://cube.dev/docs/caching/pre-aggregations/getting-started + diff --git a/container/cube/conf/model/cubes/purchase_order.yml b/container/cube/conf/model/cubes/purchase_order.yml new file mode 100644 index 0000000..db43498 --- /dev/null +++ b/container/cube/conf/model/cubes/purchase_order.yml @@ -0,0 +1,56 @@ +cubes: + - name: purchase_order + sql_table: inventory_v2.purchase_order + data_source: default + + joins: + - name: site_stock_points_stock_point + sql: "{CUBE}.`stockPointId` = {site_stock_points_stock_point}.`stockPointId`" + relationship: many_to_one + + - name: site_v2_stock_points_stock_point + sql: "{CUBE}.`stockPointId` = {site_v2_stock_points_stock_point}.`stockPointId`" + relationship: many_to_one + + - name: stock_point + sql: "{CUBE}.`stockPointId` = {stock_point.id}" + relationship: many_to_one + + dimensions: + - name: id + sql: id + type: number + primary_key: true + + - name: note + sql: note + type: string + + - name: ordernumber + sql: "{CUBE}.`orderNumber`" + type: string + + - name: status + sql: status + type: string + + - name: createdat + sql: "{CUBE}.`createdAt`" + type: time + + - name: updatedat + sql: "{CUBE}.`updatedAt`" + type: time + + - name: expectedarrivaltime + sql: "{CUBE}.`expectedArrivalTime`" + type: time + + measures: + - name: count + type: count + + pre_aggregations: + # Pre-aggregation definitions go here. + # Learn more in the documentation: https://cube.dev/docs/caching/pre-aggregations/getting-started + diff --git a/container/cube/conf/model/cubes/purchase_order_item.yml b/container/cube/conf/model/cubes/purchase_order_item.yml new file mode 100644 index 0000000..7b752d8 --- /dev/null +++ b/container/cube/conf/model/cubes/purchase_order_item.yml @@ -0,0 +1,40 @@ +cubes: + - name: purchase_order_item + sql_table: inventory_v2.purchase_order_item + data_source: default + + joins: + - name: purchase_order + sql: "{CUBE}.`purchaseOrderId` = {purchase_order.id}" + relationship: many_to_one + + dimensions: + - name: id + sql: id + type: number + primary_key: true + + - name: name + sql: name + type: string + + - name: sku + sql: sku + type: string + + measures: + - name: count + type: count + + - name: price + sql: price + type: sum + + - name: quantity + sql: quantity + type: sum + + pre_aggregations: + # Pre-aggregation definitions go here. + # Learn more in the documentation: https://cube.dev/docs/caching/pre-aggregations/getting-started + diff --git a/container/cube/conf/model/cubes/service.yml b/container/cube/conf/model/cubes/service.yml new file mode 100644 index 0000000..946994a --- /dev/null +++ b/container/cube/conf/model/cubes/service.yml @@ -0,0 +1,37 @@ +cubes: + - name: service + sql_table: inventory_v2.service + data_source: default + + joins: [] + + dimensions: + - name: id + sql: id + type: string + primary_key: true + + - name: carrier_name + sql: carrier_name + type: string + + - name: service_name + sql: service_name + type: string + + - name: createdat + sql: "{CUBE}.`createdAt`" + type: time + + - name: updatedat + sql: "{CUBE}.`updatedAt`" + type: time + + measures: + - name: count + type: count + + pre_aggregations: + # Pre-aggregation definitions go here. + # Learn more in the documentation: https://cube.dev/docs/caching/pre-aggregations/getting-started + diff --git a/container/cube/conf/model/cubes/shipment.yml b/container/cube/conf/model/cubes/shipment.yml new file mode 100644 index 0000000..14072dd --- /dev/null +++ b/container/cube/conf/model/cubes/shipment.yml @@ -0,0 +1,96 @@ +cubes: + - name: shipment + sql_table: inventory_v2.shipment + data_source: default + + joins: + - name: order + sql: "{CUBE}.order_id = {order.id}" + relationship: many_to_one + + - name: stock_point + sql: "{CUBE}.stock_point_id = {stock_point.id}" + relationship: many_to_one + + dimensions: + - name: id + sql: id + type: number + primary_key: true + + - name: bol_number + sql: bol_number + type: string + + - name: customs_invoice_url + sql: customs_invoice_url + type: string + + - name: labels + sql: labels + type: string + + - name: pickup_confirmation_number + sql: pickup_confirmation_number + type: string + + - name: primary_tracking_number + sql: primary_tracking_number + type: string + + - name: rate + sql: rate + type: string + + - name: return_tracking_number + sql: return_tracking_number + type: string + + - name: state + sql: state + type: string + + - name: tracking_id + sql: tracking_id + type: string + + - name: tracking_numbers + sql: tracking_numbers + type: string + + - name: tracking_provider + sql: tracking_provider + type: string + + - name: tracking_url + sql: tracking_url + type: string + + - name: transaction_number + sql: transaction_number + type: string + + - name: type + sql: type + type: string + + - name: unique_id + sql: unique_id + type: string + + - name: createdat + sql: "{CUBE}.`createdAt`" + type: time + + - name: updatedat + sql: "{CUBE}.`updatedAt`" + type: time + + measures: + - name: count + type: count + + pre_aggregations: + # Pre-aggregation definitions go here. + # Learn more in the documentation: https://cube.dev/docs/caching/pre-aggregations/getting-started + diff --git a/container/cube/conf/model/cubes/shipment_item.yml b/container/cube/conf/model/cubes/shipment_item.yml new file mode 100644 index 0000000..4946869 --- /dev/null +++ b/container/cube/conf/model/cubes/shipment_item.yml @@ -0,0 +1,48 @@ +cubes: + - name: shipment_item + sql_table: inventory_v2.shipment_item + data_source: default + + joins: + - name: order + sql: "{CUBE}.order_id = {order.id}" + relationship: many_to_one + + - name: shipment + sql: "{CUBE}.shipment_id = {shipment.id}" + relationship: many_to_one + + dimensions: + - name: id + sql: id + type: number + primary_key: true + + - name: name + sql: name + type: string + + - name: sku + sql: sku + type: string + + - name: createdat + sql: "{CUBE}.`createdAt`" + type: time + + - name: updatedat + sql: "{CUBE}.`updatedAt`" + type: time + + measures: + - name: count + type: count + + - name: quantity + sql: quantity + type: sum + + pre_aggregations: + # Pre-aggregation definitions go here. + # Learn more in the documentation: https://cube.dev/docs/caching/pre-aggregations/getting-started + diff --git a/container/cube/conf/model/cubes/shipping_address.yml b/container/cube/conf/model/cubes/shipping_address.yml new file mode 100644 index 0000000..8b94273 --- /dev/null +++ b/container/cube/conf/model/cubes/shipping_address.yml @@ -0,0 +1,60 @@ +cubes: + - name: shipping_address + sql_table: inventory_v2.shipping_address + data_source: default + + joins: + - name: site_stock_points_stock_point + sql: "{CUBE}.`stockPointId` = {site_stock_points_stock_point}.`stockPointId`" + relationship: many_to_one + + - name: site_v2_stock_points_stock_point + sql: "{CUBE}.`stockPointId` = {site_v2_stock_points_stock_point}.`stockPointId`" + relationship: many_to_one + + - name: stock_point + sql: "{CUBE}.`stockPointId` = {stock_point.id}" + relationship: many_to_one + + dimensions: + - name: id + sql: id + type: number + primary_key: true + + - name: address + sql: address + type: string + + - name: name + sql: name + type: string + + - name: phone_number + sql: phone_number + type: string + + - name: phone_number_country + sql: phone_number_country + type: string + + - name: phone_number_extension + sql: phone_number_extension + type: string + + - name: createdat + sql: "{CUBE}.`createdAt`" + type: time + + - name: updatedat + sql: "{CUBE}.`updatedAt`" + type: time + + measures: + - name: count + type: count + + pre_aggregations: + # Pre-aggregation definitions go here. + # Learn more in the documentation: https://cube.dev/docs/caching/pre-aggregations/getting-started + diff --git a/container/cube/conf/model/cubes/shipping_item.yml b/container/cube/conf/model/cubes/shipping_item.yml new file mode 100644 index 0000000..5f3a7c7 --- /dev/null +++ b/container/cube/conf/model/cubes/shipping_item.yml @@ -0,0 +1,48 @@ +cubes: + - name: shipping_item + sql_table: inventory_v2.shipping_item + data_source: default + + joins: + - name: order + sql: "{CUBE}.`orderId` = {order.id}" + relationship: many_to_one + + - name: product + sql: "{CUBE}.`productId` = {product.id}" + relationship: many_to_one + + dimensions: + - name: id + sql: id + type: number + primary_key: true + + - name: name + sql: name + type: string + + - name: sku + sql: sku + type: string + + - name: createdat + sql: "{CUBE}.`createdAt`" + type: time + + - name: updatedat + sql: "{CUBE}.`updatedAt`" + type: time + + measures: + - name: count + type: count + + - name: quantity + sql: quantity + type: sum + + pre_aggregations: + # Pre-aggregation definitions go here. + # Learn more in the documentation: https://cube.dev/docs/caching/pre-aggregations/getting-started + diff --git a/container/cube/conf/model/cubes/site.yml b/container/cube/conf/model/cubes/site.yml new file mode 100644 index 0000000..17414db --- /dev/null +++ b/container/cube/conf/model/cubes/site.yml @@ -0,0 +1,61 @@ +cubes: + - name: site + sql_table: inventory_v2.site + data_source: default + + joins: [] + + dimensions: + - name: id + sql: id + type: number + primary_key: true + + - name: apiurl + sql: "{CUBE}.`apiUrl`" + type: string + + - name: consumerkey + sql: "{CUBE}.`consumerKey`" + type: string + + - name: consumersecret + sql: "{CUBE}.`consumerSecret`" + type: string + + - name: description + sql: description + type: string + + - name: name + sql: name + type: string + + - name: skuprefix + sql: "{CUBE}.`skuPrefix`" + type: string + + - name: token + sql: token + type: string + + - name: type + sql: type + type: string + + - name: webhook_url + sql: webhook_url + type: string + + - name: website_url + sql: website_url + type: string + + measures: + - name: count + type: count + + pre_aggregations: + # Pre-aggregation definitions go here. + # Learn more in the documentation: https://cube.dev/docs/caching/pre-aggregations/getting-started + diff --git a/container/cube/conf/model/cubes/site_areas_area.yml b/container/cube/conf/model/cubes/site_areas_area.yml new file mode 100644 index 0000000..ea03e78 --- /dev/null +++ b/container/cube/conf/model/cubes/site_areas_area.yml @@ -0,0 +1,28 @@ +cubes: + - name: site_areas_area + sql_table: inventory_v2.site_areas_area + data_source: default + + joins: + - name: area + sql: "{CUBE}.areaId = {area.id}" + relationship: many_to_one + + - name: site + sql: "{CUBE}.siteId = {site.id}" + relationship: many_to_one + + dimensions: + - name: areaId + sql: areaId + type: number + primary_key: true + + measures: + - name: count + type: count + + pre_aggregations: + # Pre-aggregation definitions go here. + # Learn more in the documentation: https://cube.dev/docs/caching/pre-aggregations/getting-started + diff --git a/container/cube/conf/model/cubes/site_stock_points_stock_point.yml b/container/cube/conf/model/cubes/site_stock_points_stock_point.yml new file mode 100644 index 0000000..16d296b --- /dev/null +++ b/container/cube/conf/model/cubes/site_stock_points_stock_point.yml @@ -0,0 +1,28 @@ +cubes: + - name: site_stock_points_stock_point + sql_table: inventory_v2.site_stock_points_stock_point + data_source: default + + joins: + - name: site + sql: "{CUBE}.siteId = {site.id}" + relationship: many_to_one + + - name: stock_point + sql: "{CUBE}.stockPointId = {stock_point.id}" + relationship: many_to_one + + dimensions: + - name: stockPointId + sql: stockPointId + type: number + primary_key: true + + measures: + - name: count + type: count + + pre_aggregations: + # Pre-aggregation definitions go here. + # Learn more in the documentation: https://cube.dev/docs/caching/pre-aggregations/getting-started + diff --git a/container/cube/conf/model/cubes/site_v2.yml b/container/cube/conf/model/cubes/site_v2.yml new file mode 100644 index 0000000..46fd653 --- /dev/null +++ b/container/cube/conf/model/cubes/site_v2.yml @@ -0,0 +1,57 @@ +cubes: + - name: site_v2 + sql_table: inventory_v2.site_v2 + data_source: default + + joins: [] + + dimensions: + - name: id + sql: id + type: number + primary_key: true + + - name: apiurl + sql: "{CUBE}.`apiUrl`" + type: string + + - name: consumerkey + sql: "{CUBE}.`consumerKey`" + type: string + + - name: consumersecret + sql: "{CUBE}.`consumerSecret`" + type: string + + - name: description + sql: description + type: string + + - name: name + sql: name + type: string + + - name: skuprefix + sql: "{CUBE}.`skuPrefix`" + type: string + + - name: token + sql: token + type: string + + - name: type + sql: type + type: string + + - name: website_url + sql: website_url + type: string + + measures: + - name: count + type: count + + pre_aggregations: + # Pre-aggregation definitions go here. + # Learn more in the documentation: https://cube.dev/docs/caching/pre-aggregations/getting-started + diff --git a/container/cube/conf/model/cubes/site_v2_areas_area.yml b/container/cube/conf/model/cubes/site_v2_areas_area.yml new file mode 100644 index 0000000..9117b74 --- /dev/null +++ b/container/cube/conf/model/cubes/site_v2_areas_area.yml @@ -0,0 +1,28 @@ +cubes: + - name: site_v2_areas_area + sql_table: inventory_v2.site_v2_areas_area + data_source: default + + joins: + - name: area + sql: "{CUBE}.areaId = {area.id}" + relationship: many_to_one + + - name: site_v2 + sql: "{CUBE}.siteV2Id = {site_v2.id}" + relationship: many_to_one + + dimensions: + - name: areaId + sql: areaId + type: number + primary_key: true + + measures: + - name: count + type: count + + pre_aggregations: + # Pre-aggregation definitions go here. + # Learn more in the documentation: https://cube.dev/docs/caching/pre-aggregations/getting-started + diff --git a/container/cube/conf/model/cubes/site_v2_stock_points_stock_point.yml b/container/cube/conf/model/cubes/site_v2_stock_points_stock_point.yml new file mode 100644 index 0000000..ed62bbe --- /dev/null +++ b/container/cube/conf/model/cubes/site_v2_stock_points_stock_point.yml @@ -0,0 +1,28 @@ +cubes: + - name: site_v2_stock_points_stock_point + sql_table: inventory_v2.site_v2_stock_points_stock_point + data_source: default + + joins: + - name: site_v2 + sql: "{CUBE}.siteV2Id = {site_v2.id}" + relationship: many_to_one + + - name: stock_point + sql: "{CUBE}.stockPointId = {stock_point.id}" + relationship: many_to_one + + dimensions: + - name: stockPointId + sql: stockPointId + type: number + primary_key: true + + measures: + - name: count + type: count + + pre_aggregations: + # Pre-aggregation definitions go here. + # Learn more in the documentation: https://cube.dev/docs/caching/pre-aggregations/getting-started + diff --git a/container/cube/conf/model/cubes/stock.yml b/container/cube/conf/model/cubes/stock.yml new file mode 100644 index 0000000..3de33d5 --- /dev/null +++ b/container/cube/conf/model/cubes/stock.yml @@ -0,0 +1,48 @@ +cubes: + - name: stock + sql_table: inventory_v2.stock + data_source: default + + joins: + - name: site_stock_points_stock_point + sql: "{CUBE}.`stockPointId` = {site_stock_points_stock_point}.`stockPointId`" + relationship: many_to_one + + - name: site_v2_stock_points_stock_point + sql: "{CUBE}.`stockPointId` = {site_v2_stock_points_stock_point}.`stockPointId`" + relationship: many_to_one + + - name: stock_point + sql: "{CUBE}.`stockPointId` = {stock_point.id}" + relationship: many_to_one + + dimensions: + - name: id + sql: id + type: number + primary_key: true + + - name: sku + sql: sku + type: string + + - name: createdat + sql: "{CUBE}.`createdAt`" + type: time + + - name: updatedat + sql: "{CUBE}.`updatedAt`" + type: time + + measures: + - name: count + type: count + + - name: quantity + sql: quantity + type: sum + + pre_aggregations: + # Pre-aggregation definitions go here. + # Learn more in the documentation: https://cube.dev/docs/caching/pre-aggregations/getting-started + diff --git a/container/cube/conf/model/cubes/stock_point.yml b/container/cube/conf/model/cubes/stock_point.yml new file mode 100644 index 0000000..c319b73 --- /dev/null +++ b/container/cube/conf/model/cubes/stock_point.yml @@ -0,0 +1,53 @@ +cubes: + - name: stock_point + sql_table: inventory_v2.stock_point + data_source: default + + joins: [] + + dimensions: + - name: id + sql: id + type: number + primary_key: true + + - name: contactperson + sql: "{CUBE}.`contactPerson`" + type: string + + - name: contactphone + sql: "{CUBE}.`contactPhone`" + type: string + + - name: location + sql: location + type: string + + - name: name + sql: name + type: string + + - name: upstreamname + sql: "{CUBE}.`upStreamName`" + type: string + + - name: createdat + sql: "{CUBE}.`createdAt`" + type: time + + - name: updatedat + sql: "{CUBE}.`updatedAt`" + type: time + + - name: deletedat + sql: "{CUBE}.`deletedAt`" + type: time + + measures: + - name: count + type: count + + pre_aggregations: + # Pre-aggregation definitions go here. + # Learn more in the documentation: https://cube.dev/docs/caching/pre-aggregations/getting-started + diff --git a/container/cube/conf/model/cubes/stock_point_areas_area.yml b/container/cube/conf/model/cubes/stock_point_areas_area.yml new file mode 100644 index 0000000..fd96be7 --- /dev/null +++ b/container/cube/conf/model/cubes/stock_point_areas_area.yml @@ -0,0 +1,36 @@ +cubes: + - name: stock_point_areas_area + sql_table: inventory_v2.stock_point_areas_area + data_source: default + + joins: + - name: area + sql: "{CUBE}.areaId = {area.id}" + relationship: many_to_one + + - name: site_stock_points_stock_point + sql: "{CUBE}.stockPointId = {site_stock_points_stock_point}.stockPointId" + relationship: many_to_one + + - name: site_v2_stock_points_stock_point + sql: "{CUBE}.stockPointId = {site_v2_stock_points_stock_point}.stockPointId" + relationship: many_to_one + + - name: stock_point + sql: "{CUBE}.stockPointId = {stock_point.id}" + relationship: many_to_one + + dimensions: + - name: areaId + sql: areaId + type: number + primary_key: true + + measures: + - name: count + type: count + + pre_aggregations: + # Pre-aggregation definitions go here. + # Learn more in the documentation: https://cube.dev/docs/caching/pre-aggregations/getting-started + diff --git a/container/cube/conf/model/cubes/stock_record.yml b/container/cube/conf/model/cubes/stock_record.yml new file mode 100644 index 0000000..13b87d6 --- /dev/null +++ b/container/cube/conf/model/cubes/stock_record.yml @@ -0,0 +1,48 @@ +cubes: + - name: stock_record + sql_table: inventory_v2.stock_record + data_source: default + + joins: + - name: site_stock_points_stock_point + sql: "{CUBE}.`stockPointId` = {site_stock_points_stock_point}.`stockPointId`" + relationship: many_to_one + + - name: site_v2_stock_points_stock_point + sql: "{CUBE}.`stockPointId` = {site_v2_stock_points_stock_point}.`stockPointId`" + relationship: many_to_one + + - name: stock_point + sql: "{CUBE}.`stockPointId` = {stock_point.id}" + relationship: many_to_one + + dimensions: + - name: id + sql: id + type: number + primary_key: true + + - name: note + sql: note + type: string + + - name: operationtype + sql: "{CUBE}.`operationType`" + type: string + + - name: sku + sql: sku + type: string + + - name: createdat + sql: "{CUBE}.`createdAt`" + type: time + + measures: + - name: count + type: count + + pre_aggregations: + # Pre-aggregation definitions go here. + # Learn more in the documentation: https://cube.dev/docs/caching/pre-aggregations/getting-started + diff --git a/container/cube/conf/model/cubes/subscription.yml b/container/cube/conf/model/cubes/subscription.yml new file mode 100644 index 0000000..b982dfc --- /dev/null +++ b/container/cube/conf/model/cubes/subscription.yml @@ -0,0 +1,84 @@ +cubes: + - name: subscription + sql_table: inventory_v2.subscription + data_source: default + + joins: + - name: customer + sql: "{CUBE}.customer_id = {customer.id}" + relationship: many_to_one + + - name: site + sql: "{CUBE}.`siteId` = {site.id}" + relationship: many_to_one + + dimensions: + - name: id + sql: id + type: number + primary_key: true + + - name: billing_period + sql: billing_period + type: string + + - name: currency + sql: currency + type: string + + - name: customer_email + sql: customer_email + type: string + + - name: externalsubscriptionid + sql: "{CUBE}.`externalSubscriptionId`" + type: string + + - name: line_items + sql: line_items + type: string + + - name: meta_data + sql: meta_data + type: string + + - name: status + sql: status + type: string + + - name: createdat + sql: "{CUBE}.`createdAt`" + type: time + + - name: updatedat + sql: "{CUBE}.`updatedAt`" + type: time + + - name: end_date + sql: end_date + type: time + + - name: next_payment_date + sql: next_payment_date + type: time + + - name: start_date + sql: start_date + type: time + + - name: trial_end + sql: trial_end + type: time + + measures: + - name: count + type: count + + - name: total + sql: total + type: sum + + pre_aggregations: + # Pre-aggregation definitions go here. + # Learn more in the documentation: https://cube.dev/docs/caching/pre-aggregations/getting-started + diff --git a/container/cube/conf/model/cubes/template.yml b/container/cube/conf/model/cubes/template.yml new file mode 100644 index 0000000..d36efd6 --- /dev/null +++ b/container/cube/conf/model/cubes/template.yml @@ -0,0 +1,45 @@ +cubes: + - name: template + sql_table: inventory_v2.template + data_source: default + + joins: [] + + dimensions: + - name: id + sql: id + type: number + primary_key: true + + - name: description + sql: description + type: string + + - name: name + sql: name + type: string + + - name: testdata + sql: "{CUBE}.`testData`" + type: string + + - name: value + sql: value + type: string + + - name: createdat + sql: "{CUBE}.`createdAt`" + type: time + + - name: updatedat + sql: "{CUBE}.`updatedAt`" + type: time + + measures: + - name: count + type: count + + pre_aggregations: + # Pre-aggregation definitions go here. + # Learn more in the documentation: https://cube.dev/docs/caching/pre-aggregations/getting-started + diff --git a/container/cube/conf/model/cubes/transfer.yml b/container/cube/conf/model/cubes/transfer.yml new file mode 100644 index 0000000..1b0af4f --- /dev/null +++ b/container/cube/conf/model/cubes/transfer.yml @@ -0,0 +1,45 @@ +cubes: + - name: transfer + sql_table: inventory_v2.transfer + data_source: default + + joins: [] + + dimensions: + - name: id + sql: id + type: number + primary_key: true + + - name: note + sql: note + type: string + + - name: ordernumber + sql: "{CUBE}.`orderNumber`" + type: string + + - name: createdat + sql: "{CUBE}.`createdAt`" + type: time + + - name: updatedat + sql: "{CUBE}.`updatedAt`" + type: time + + - name: arriveat + sql: "{CUBE}.`arriveAt`" + type: time + + - name: sendat + sql: "{CUBE}.`sendAt`" + type: time + + measures: + - name: count + type: count + + pre_aggregations: + # Pre-aggregation definitions go here. + # Learn more in the documentation: https://cube.dev/docs/caching/pre-aggregations/getting-started + diff --git a/container/cube/conf/model/cubes/transfer_item.yml b/container/cube/conf/model/cubes/transfer_item.yml new file mode 100644 index 0000000..c3ada11 --- /dev/null +++ b/container/cube/conf/model/cubes/transfer_item.yml @@ -0,0 +1,36 @@ +cubes: + - name: transfer_item + sql_table: inventory_v2.transfer_item + data_source: default + + joins: + - name: transfer + sql: "{CUBE}.`transferId` = {transfer.id}" + relationship: many_to_one + + dimensions: + - name: id + sql: id + type: number + primary_key: true + + - name: name + sql: name + type: string + + - name: sku + sql: sku + type: string + + measures: + - name: count + type: count + + - name: quantity + sql: quantity + type: sum + + pre_aggregations: + # Pre-aggregation definitions go here. + # Learn more in the documentation: https://cube.dev/docs/caching/pre-aggregations/getting-started + diff --git a/container/cube/conf/model/cubes/user.yml b/container/cube/conf/model/cubes/user.yml new file mode 100644 index 0000000..b2dc801 --- /dev/null +++ b/container/cube/conf/model/cubes/user.yml @@ -0,0 +1,41 @@ +cubes: + - name: user + sql_table: inventory_v2.user + data_source: default + + joins: [] + + dimensions: + - name: id + sql: id + type: number + primary_key: true + + - name: email + sql: email + type: string + + - name: password + sql: password + type: string + + - name: permissions + sql: permissions + type: string + + - name: remark + sql: remark + type: string + + - name: username + sql: username + type: string + + measures: + - name: count + type: count + + pre_aggregations: + # Pre-aggregation definitions go here. + # Learn more in the documentation: https://cube.dev/docs/caching/pre-aggregations/getting-started + diff --git a/container/cube/conf/model/views/example_view.yml b/container/cube/conf/model/views/example_view.yml new file mode 100644 index 0000000..6a43e0e --- /dev/null +++ b/container/cube/conf/model/views/example_view.yml @@ -0,0 +1,29 @@ +# In Cube, views are used to expose slices of your data graph and act as data marts. +# You can control which measures and dimensions are exposed to BIs or data apps, +# as well as the direction of joins between the exposed cubes. +# You can learn more about views in documentation here - https://cube.dev/docs/schema/reference/view + + +# The following example shows a view defined on top of orders and customers cubes. +# Both orders and customers cubes are exposed using the "includes" parameter to +# control which measures and dimensions are exposed. +# Prefixes can also be applied when exposing measures or dimensions. +# In this case, the customers' city dimension is prefixed with the cube name, +# resulting in "customers_city" when querying the view. + +# views: +# - name: example_view +# +# cubes: +# - join_path: orders +# includes: +# - status +# - created_date +# +# - total_amount +# - count +# +# - join_path: orders.customers +# prefix: true +# includes: +# - city \ No newline at end of file diff --git a/container/cube/query/state_count_query.json b/container/cube/query/state_count_query.json new file mode 100644 index 0000000..38c34cf --- /dev/null +++ b/container/cube/query/state_count_query.json @@ -0,0 +1,17 @@ +{ + "measures": [ + "customer.count" + ], + "dimensions": [ + "customer.customer_state" + ], + "filters": [], + "timeDimensions": [], + "order": [ + { + "id": "customer.count", + "desc": true + } + ], + "limit": 100 +} \ No newline at end of file diff --git a/container/docker-compose.dev.yml b/container/docker-compose.dev.yml new file mode 100644 index 0000000..d7b208b --- /dev/null +++ b/container/docker-compose.dev.yml @@ -0,0 +1,4 @@ +version: '3.8' + +services: + \ No newline at end of file diff --git a/container/docker-compose.prod.yml b/container/docker-compose.prod.yml new file mode 100644 index 0000000..a88c23e --- /dev/null +++ b/container/docker-compose.prod.yml @@ -0,0 +1,61 @@ +version: '3.8' + +services: + # MySQL 服务(可选,如果需要可以取消注释) + # mysql: + # image: mysql:8.0 + # container_name: mysql-container + # restart: on-failure + # environment: + # MYSQL_ROOT_PASSWORD: root + # MYSQL_DATABASE: mydb + # ports: + # - "3306:3306" + # volumes: + # - mysql-data:/var/lib/mysql + # networks: + # - app-network + + # API 服务 + api: + build: + context: ../../API + dockerfile: Dockerfile + container_name: api-container + restart: on-failure + environment: + - NODE_ENV=prod + # 数据库连接信息(连接到外部 MySQL 容器) + - MYSQL_HOST=host.docker.internal + - MYSQL_PORT=23306 + - MYSQL_USERNAME=root + - MYSQL_PASSWORD=root + - MYSQL_DATABASE=inventory + ports: + - "7001:7001" + networks: + - app-network + + # WEB 服务 + web: + build: + context: ../../WEB + dockerfile: Dockerfile + container_name: web-container + restart: on-failure + environment: + - NODE_ENV=prod + ports: + - "8080:80" + depends_on: + - api + networks: + - app-network + +# volumes: +# mysql-data: +# driver: local + +networks: + app-network: + driver: bridge diff --git a/container/docker-compose.yml b/container/docker-compose.yml index f9abdcd..c1bc168 100644 --- a/container/docker-compose.yml +++ b/container/docker-compose.yml @@ -7,12 +7,12 @@ services: # container_name: mysql-container # restart: on-failure # environment: - # MYSQL_ROOT_PASSWORD: root - # MYSQL_DATABASE: mydb + # MYSQL_ROOT_PASSWORD: 12345678 + # MYSQL_DATABASE: inventory_v2 # ports: - # - "3306:3306" + # - "23306:3306" # volumes: - # - mysql-data:/var/lib/mysql + # - ./mysql/data:/var/lib/mysql # networks: # - app-network @@ -35,6 +35,32 @@ services: command: sh -c "npm run dev" ports: - "7001:7001" + networks: + - app-network + + # Cube 服务 + cube: + image: cubejs/cube:latest + ports: + - 4000:4000 + environment: + - CUBEJS_DEV_MODE=true + - CUBEJS_DB_TYPE=mysql + - CUBEJS_DB_HOST=host.docker.internal + - CUBEJS_DB_PORT=23306 + - CUBEJS_DB_USER=cubejs + - CUBEJS_DB_PASS=12345678 + - CUBEJS_DB_NAME=inventory_v2 + - CUBEJS_DB_SSL=false + - CUBEJS_API_SECRET=your-secret-here + - CUBEJS_WEB_SOCKETS=true + # - CUBEJS_REFRESH_SCHEMA=true + volumes: + - ./cube/conf:/cube/conf + + # networks: + # - app-network + # network_mode: host # WEB 服务 web: diff --git a/docs/实际经验/SSL证书问题解决方案.md b/docs/实际经验/SSL证书问题解决方案.md index 917e099..c046559 100644 --- a/docs/实际经验/SSL证书问题解决方案.md +++ b/docs/实际经验/SSL证书问题解决方案.md @@ -17,11 +17,11 @@ ## 【使用流程】 -### 方案一:忽略SSL验证(仅开发环境) +### 方案一:忽略SSL验证(仅开发环境) #### 1. 修改axios配置 -在`src/service/wp.service.ts`中的`fetchPagedData`方法添加SSL配置: +在`src/service/wp.service.ts`中的`fetchPagedData`方法添加SSL配置: ```typescript // 在fetchPagedData方法中修改config配置 @@ -46,7 +46,7 @@ const config: AxiosRequestConfig = { #### 2. 全局axios配置 -在项目入口文件中添加全局配置: +在项目入口文件中添加全局配置: ```typescript // 在src/configuration.ts或app.ts中添加 @@ -61,11 +61,11 @@ if (process.env.NODE_ENV === 'development') { } ``` -### 方案二:环境变量控制(推荐) +### 方案二:环境变量控制(推荐) #### 1. 创建环境配置 -在`.env`文件中添加: +在`.env`文件中添加: ```bash # SSL配置 @@ -83,7 +83,7 @@ import { Config } from '@midwayjs/core'; @Provide() export class WPService { @Config('wpSite') - sites: WpSite[]; + sites: Site[]; // 获取SSL配置 private getHttpsAgent() { @@ -100,7 +100,7 @@ export class WPService { async fetchPagedData( endpoint: string, - site: WpSite, + site: Site, page: number = 1, perPage: number = 100 ): Promise { @@ -141,7 +141,7 @@ export class WPService { } catch (error) { // 增强错误处理 if (error.code === 'DEPTH_ZERO_SELF_SIGNED_CERT') { - console.error('SSL证书错误:请检查证书配置或在开发环境中忽略SSL验证'); + console.error('SSL证书错误:请检查证书配置或在开发环境中忽略SSL验证'); } throw error; } @@ -152,7 +152,7 @@ export class WPService { } ``` -### 方案三:安装自签名证书(生产环境推荐) +### 方案三:安装自签名证书(生产环境推荐) #### 1. 生成证书 @@ -181,7 +181,7 @@ openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt | 测试环境 | 建议验证 | 使用测试证书 | 中 | | 生产环境 | 必须验证 | 有效SSL证书 | 高 | -### 代码示例:环境检测 +### 代码示例:环境检测 ```typescript // 环境安全检测 diff --git a/docs/实际经验/URL拼接最佳实践.md b/docs/实际经验/URL拼接最佳实践.md index 294f7c7..90e7bd6 100644 --- a/docs/实际经验/URL拼接最佳实践.md +++ b/docs/实际经验/URL拼接最佳实践.md @@ -26,7 +26,7 @@ ## 【使用流程】 -### 步骤1:创建URL工具类 +### 步骤1:创建URL工具类 ```typescript // src/utils/url.util.ts @@ -56,12 +56,12 @@ export class UrlUtil { } /** - * 标准化URL路径(移除重复斜杠) + * 标准化URL路径(移除重复斜杠) * @param url 原始URL * @returns 标准化后的URL */ static normalizeUrl(url: string): string { - // 保护协议部分的双斜杠(如 http://) + // 保护协议部分的双斜杠(如 http://) const protocolMatch = url.match(/^([a-zA-Z][a-zA-Z\d+\-.]*:\/\/)/); const protocol = protocolMatch ? protocolMatch[1] : ''; const restUrl = protocolMatch ? url.slice(protocol.length) : url; @@ -72,7 +72,7 @@ export class UrlUtil { } ``` -### 步骤2:创建专用API URL构建器 +### 步骤2:创建专用API URL构建器 ```typescript // 扩展UrlUtil类,添加WordPress专用方法 @@ -102,7 +102,7 @@ export class UrlUtil { } ``` -### 步骤3:在服务中应用 +### 步骤3:在服务中应用 ```typescript // src/service/wp.service.ts @@ -112,22 +112,22 @@ import { UrlUtil } from '../utils/url.util'; export class WPService { async fetchPagedData( endpoint: string, - site: WpSite, + site: Site, page: number = 1, perPage: number = 100 ): Promise { const { wpApiUrl, consumerKey, consumerSecret } = site; - // 原始方式(容易出错) + // 原始方式(容易出错) // const url = `${wpApiUrl}/wp-json${endpoint}`; - // 推荐方式(安全可靠) + // 推荐方式(安全可靠) const url = UrlUtil.buildWpApiUrl(wpApiUrl, endpoint); // ... 其他代码 } - async createShipment(site: WpSite, orderId: string, data: Record) { + async createShipment(site: Site, orderId: string, data: Record) { const { wpApiUrl, consumerKey, consumerSecret } = site; // 复杂路径拼接示例 @@ -151,7 +151,7 @@ export class WPService { ### 问题场景演示 ```typescript -// 问题场景:配置文件中的URL格式不统一 +// 问题场景:配置文件中的URL格式不统一 const configs = [ { wpApiUrl: 'http://wp-test.local/' }, // 带尾部斜杠 { wpApiUrl: 'http://wp-test.local' }, // 不带尾部斜杠 @@ -169,7 +169,7 @@ configs.forEach(config => { endpoints.forEach(endpoint => { const badUrl = `${config.wpApiUrl}/wp-json${endpoint}`; console.log('问题URL:', badUrl); - // 输出可能包含: + // 输出可能包含: // http://wp-test.local//wp-json/wc/v3/orders // http://wp-test.localwp-json/wc/v3/products }); @@ -184,7 +184,7 @@ configs.forEach(config => { endpoints.forEach(endpoint => { const safeUrl = UrlUtil.buildWpApiUrl(config.wpApiUrl, endpoint); console.log('安全URL:', safeUrl); - // 输出始终正确: + // 输出始终正确: // http://wp-test.local/wp-json/wc/v3/orders // http://wp-test.local/wp-json/wc/v3/products }); diff --git a/docs/实际经验/使用webhook自动同步woocommerce的订单.md b/docs/实际经验/使用webhook自动同步woocommerce的订单.md index 55cf7bc..e8182db 100644 --- a/docs/实际经验/使用webhook自动同步woocommerce的订单.md +++ b/docs/实际经验/使用webhook自动同步woocommerce的订单.md @@ -2,9 +2,9 @@ ## erp-API 服务非 https 也可用配置 -webhook 调用的时候默认是需要 https,但开发时本地一般不配置 ssl(或者只是自签名),所以需要在 wordpress 中添加非 https 也可用配置。 -执行:在你应用的主题对应的 `functions.php` 中添加以下代码(可以放在最后)即可访问非https地址 -备注:路径:比如你应用的主题是 `twentytwentyfive`,则对应的文件路径是 `/app/public/wp-content/themes/twentytwentyfive/functions.php` +webhook 调用的时候默认是需要 https,但开发时本地一般不配置 ssl(或者只是自签名),所以需要在 wordpress 中添加非 https 也可用配置。 +执行:在你应用的主题对应的 `functions.php` 中添加以下代码(可以放在最后)即可访问非https地址 +备注:路径:比如你应用的主题是 `twentytwentyfive`,则对应的文件路径是 `/app/public/wp-content/themes/twentytwentyfive/functions.php` ```php add_filter( 'http_request_args', function( $args ) { @@ -33,8 +33,8 @@ if ( (isset($_GET['consumer_key']) && isset($_GET['consumer_secret'])) || isset( ## 在wordpress管理端网页添加webhook -地址: -举例说明: +地址: +举例说明: ![1760338330047](image/使用webhook自动同步woocommerce的订单/1760338330047.png) ## 最终在订单更新时会调用地址,然后进而调用 syncSingleOrder 函数 diff --git a/docs/实际经验/如何访问woocommerceAPI.md b/docs/实际经验/如何访问woocommerceAPI.md index 463514d..eef45f0 100644 --- a/docs/实际经验/如何访问woocommerceAPI.md +++ b/docs/实际经验/如何访问woocommerceAPI.md @@ -13,7 +13,7 @@ const config = { wpApiUrl: 'http://wp-test.local', // wordpress地址 consumerKey: 'ck_d6fc55914e2aba162bcf979a549e965a751e71ee', // woocommerce advanced 中创建rest api的key consumerSecret: 'cs_5828d66ddd23f17f7c7693f4414756ddb637fb47',// woocommerce advanced 中创建rest api的key - siteName: 'Local', + name: 'Local', // email配置对访问不重要 email: '*', emailPswd: '*', @@ -24,15 +24,15 @@ const config = { ``` -## 开通woocommere 权限(key) +## 开通woocommere 权限(key) -key只要添加即可使用(一般测试直接添加具有 READ WRITE 权限即可) +key只要添加即可使用(一般测试直接添加具有 READ WRITE 权限即可) ![1760323937560](image/如何连接wordpress/1760323937560.png) ## 常见问题 ### SSL证书问题 -因为是我们访问 woocommerce 所以可以直接忽略 ssl 错误(比如 axios 直接忽略) +因为是我们访问 woocommerce 所以可以直接忽略 ssl 错误(比如 axios 直接忽略) -如果遇到SSL证书错误(如`DEPTH_ZERO_SELF_SIGNED_CERT`),请参考:[SSL证书问题解决方案](./SSL证书问题解决方案.md) +如果遇到SSL证书错误(如`DEPTH_ZERO_SELF_SIGNED_CERT`),请参考:[SSL证书问题解决方案](./SSL证书问题解决方案.md) diff --git a/docs/实际经验/快速搭建你的wordpress.md b/docs/实际经验/快速搭建你的wordpress.md index 23847dc..c6c883a 100644 --- a/docs/实际经验/快速搭建你的wordpress.md +++ b/docs/实际经验/快速搭建你的wordpress.md @@ -1,5 +1,5 @@ # 如何快速搭建你的wordpress ## 直接使用 `local` 这个软件进行搭建 -网站: https://localwp.com/ +网站: https://localwp.com/ diff --git a/docs/实际经验/网络连接问题解决方案.md b/docs/实际经验/网络连接问题解决方案.md index f053bea..f2bc214 100644 --- a/docs/实际经验/网络连接问题解决方案.md +++ b/docs/实际经验/网络连接问题解决方案.md @@ -8,7 +8,7 @@ ### ECONNRESET 错误原因 -`ECONNRESET` 是一个网络连接重置错误,通常由以下原因引起: +`ECONNRESET` 是一个网络连接重置错误,通常由以下原因引起: 1. **服务器主动断开连接** - 服务器负载过高 @@ -103,7 +103,7 @@ if (hasMore) { ### 2. 超时配置 -- 设置合理的请求超时时间(建议 30-60 秒) +- 设置合理的请求超时时间(建议 30-60 秒) - 根据网络环境调整超时参数 ### 3. 重试策略 @@ -120,9 +120,9 @@ if (hasMore) { ## 代码实现 -已在 `wp.service.ts` 的 `fetchPagedData` 方法中实现以下改进: +已在 `wp.service.ts` 的 `fetchPagedData` 方法中实现以下改进: -1. ✅ 添加重试机制(最多重试3次) +1. ✅ 添加重试机制(最多重试3次) 2. ✅ 实现指数退避算法 3. ✅ 优化 HTTPS Agent 配置 4. ✅ 添加请求超时设置 diff --git a/docs/流程/上架流程.md b/docs/流程/上架流程.md new file mode 100644 index 0000000..125a5c2 --- /dev/null +++ b/docs/流程/上架流程.md @@ -0,0 +1,61 @@ +# 商品上架流程 + +本文档描述了从准备商品数据到同步至多个 WooCommerce 站点的完整流程。 + +## 流程图 (Mermaid) + +```mermaid +graph TD + %% 节点样式定义 + classDef process fill:#e1f5fe,stroke:#01579b,stroke-width:2px; + classDef storage fill:#fff9c4,stroke:#fbc02d,stroke-width:2px; + classDef action fill:#e8f5e9,stroke:#2e7d32,stroke-width:2px; + + Start((开始)) --> Step1[制作批量导入表] + + subgraph 数据准备阶段 + Step1 -->|包含| Info1[基础属性] + Step1 -->|包含| Info2[商品组成/SKU] + Info1 -.-> TableFile(Excel/CSV 文件) + Info2 -.-> TableFile + end + + TableFile --> Step2{导入 ERP 系统} + + subgraph ERP处理阶段 + Step2 -->|解析 & 存储| ERPDB[(ERP 商品数据库)] + ERPDB --> Step3[用户操作: 点击同步按钮] + end + + Step3 --> SyncProcess{分发同步任务} + + subgraph 多站点同步 + SyncProcess -->|API 推送| SiteA[WooCommerce 站点 A] + SyncProcess -->|API 推送| SiteB[WooCommerce 站点 B] + SyncProcess -->|API 推送| SiteC[WooCommerce 站点 C] + end + + SiteA --> End((上架完成)) + SiteB --> End + SiteC --> End + + %% 应用样式 + class Step1,Step2,Step3,SyncProcess process; + class ERPDB,TableFile storage; + class Start,End action; +``` + +## 详细步骤说明 + +1. **制作批量导入表** + * 准备 Excel 或 CSV 格式的数据表。 + * **关键内容**:必须包含商品的**基础属性**(如名称、描述、分类)和**商品组成**(如变体 SKU、价格、库存)。 + +2. **导入 ERP 系统** + * 将制作好的表格上传至 ERP 系统。 + * 系统会自动解析文件,将商品数据存入 ERP 的商品数据库中。 + +3. **多站点同步** + * 在 ERP 系统中找到已导入的商品。 + * 点击**“同步”**按钮。 + * 系统将自动把商品信息推送到配置好的多个 **WooCommerce** 站点,完成上架。 diff --git a/docs/流程/价格与促销.md b/docs/流程/价格与促销.md new file mode 100644 index 0000000..e69de29 diff --git a/docs/流程/原始流程/0.png b/docs/流程/原始流程/0.png new file mode 100644 index 0000000..d7e7a3b Binary files /dev/null and b/docs/流程/原始流程/0.png differ diff --git a/docs/流程/原始流程/Wordpress上品过程.docx b/docs/流程/原始流程/Wordpress上品过程.docx new file mode 100644 index 0000000..160f738 Binary files /dev/null and b/docs/流程/原始流程/Wordpress上品过程.docx differ diff --git a/docs/流程/原始流程/改价格.docx b/docs/流程/原始流程/改价格.docx new file mode 100644 index 0000000..fde4c4b Binary files /dev/null and b/docs/流程/原始流程/改价格.docx differ diff --git a/docs/流程/数据分析流程.md b/docs/流程/数据分析流程.md new file mode 100644 index 0000000..e69de29 diff --git a/docs/流程/物流流程.md b/docs/流程/物流流程.md new file mode 100644 index 0000000..e69de29 diff --git a/docs/账号.csv b/docs/账号.csv new file mode 100644 index 0000000..1f7dc2d --- /dev/null +++ b/docs/账号.csv @@ -0,0 +1,2 @@ +网站,账号 ,密码,验证码 +admin.yoone.ca,admin,yoone2025.,yoone2025!@YOONE0923 \ No newline at end of file diff --git a/docs/项目概览/项目分析报告.md b/docs/项目概览/项目分析报告.md index 95a9502..9c1cc7b 100644 --- a/docs/项目概览/项目分析报告.md +++ b/docs/项目概览/项目分析报告.md @@ -45,7 +45,7 @@ **业务描述**: 完整的订单生命周期管理,从创建到发货的全流程 **精彩之处**: -- 双状态管理:WooCommerce状态 + ERP内部状态 +- 双状态管理:WooCommerce状态 + ERP内部状态 - 完整的订单项目管理,支持原始订单和销售订单分离 - 订单退款、优惠券、运费等复杂业务场景支持 - 订单同步机制,支持从WooCommerce自动同步订单 @@ -79,7 +79,7 @@ **业务描述**: 集成多个物流服务商的发货管理系统 **精彩之处**: -- 集成多个物流服务商:FreightCom、CanadaPost、UniExpress +- 集成多个物流服务商:FreightCom、CanadaPost、UniExpress - 运费计算和比较功能 - 自动生成运单和跟踪号 - 物流状态同步到WooCommerce