Other Channel Types
Marketplace
For integration with the marketplace from Omnitron, there are certain operations that must take place such as reconciliation processes, mapping of attributes, etc. As in every marketplace, there are two different roles. One is the marketplace, and the other is the supplier;
Marketplace can sell its own products through any channel, as well as the products of all suppliers in reconciliation, through this platform.
Supplier can sell their own products through any channel, as well as through the marketplaces, in reconciliation and as channels. In other words, a company providing the marketplace system through the Omnitron does not prevent the sale of its own products and does not cause any problems for the supplier either.
Model Structure
We can discuss this section under two items; marketplace and supplier. For the marketplace, an order is created using a model derived from Order, called Vendor Order. This allows us to distinguish orders. (omnitron.orders.models.VendorOrder
)
Figure 1: VendorOrder Model Fields and Inheritance
For the supplier, an order is created using the Order model without any differences from normal order. (omnitron.orders.models.Order
)
Data Source is the model name of the digital contract. Contains name
, stock_list
, price_list
, is_active
, commission_rate
, maturity_rate
, token
, conf
and supplier_code
.
Figure 2: DataSource Model it’s Relations
Reconciliation is the model name of the reconciliation previously referred to. Contains data_source
, channel
, start_date
, end_date
, status
, creation_type(automatic or manuel)
, item_selection_type(orderitem or orderitem and cancellation)
,number
, name
, total_income
, total_expanse
, total_commission
, commission
, maturity
and conf
. When the necessary contexts are provided through the frontend, the relevant record is created.
Figure 3: Reconciliation Model it’s Relations
VendorOrder; An Order model unlike the normal Order is created and linked with this model inherited from the Order with a foreignkey (order). data_source
and sent_date
are also in this model.
Figure 4: Fields only in VendorOrder
VendorOrderItem; Inherited from OrderItem. And the order foreign key is linked directly as VendorOrder. As in VendorOrder, the OrderItem model is created and linked with the model with a foreignkey (base).
Figure 5: VendorOrderItem Model Fields and Inheritance
Script
After providing the attribute mapping that needs to be entered for the supplier from the marketplace Omnitron, the contract must be created from the Unified Digital Contract screen of the Unified Network menu from the marketplace Omnitron.
{
"reconciliation_conf":{
"data_source_name":"AD",
"item_selection_strategy":{
"days_later":6,
"strategy_type":"delivered_date"
},
"commission":"10.00000",
"maturity":90,
"creation_strategy":{
"day_of_week":2,
"strategy_type":"weekly"
},
"creation_strategy_change_date":"2020-02-10 16:06:19.979257+00:00"
}
}
If the supplier is from Omnitron, the channel type must be created by selecting Unified on the Sales Channels screen accessed from the Settings menu. When unified is selected, the input field will open for entering the unified digital contract key. The API key value provided when creating the digital contract from the Marketplace Omnitron must be entered in this input field.
Conf. example of the relevant channel,
{
"token": "<marketplace token>",
"server": "http://<marketplace_url>",
"shipping_company": "ups"
}
The user must wait for 10-15 minutes after these operations. Meanwhile, the digital contract process begins. The process is completed with the execution of the relevant tasks.
Service
VendorOrderService
(omnitron.orders.service.VendorOrderService)
create_order: The method used to create vendor orders.
number
,channel
anddata_source
perform existence checks and create the vendor order.update_order: sends the
old_status
,old_cancel_status
andold_external_status
values to audit context for recording the statuses. If the status update has been sent to the relevant method, it is sent to the order items withupdate_order_item
inVendorOrderItemService
, and then toupdate_order_item
inOrderItemService
. Finally, what needs to be updated in order is updated and saved.order_status_update: After controlling whether there are active items of
order
, if there is none,is_refund
is controlled and theorder status
value is updated asrefunded
ifis_refund
True, and ascancelled
if not. If there are active items, we advance the process by adding the status value of the active OrderItem.reject_order_cancel: As in
update_order
, it is sent to the audit context for recording the statuses. Then we send the order linked to the vendor order toreject_order_cancel
inOrderService
. We follow this withorder_status_update
.approved_order_cancel: As in
update_order
, it is sent to the audit context for recording the statuses.Cancellation_info
control is made; if there is none,cancellation_info
is added, if there is any, the approving party is entered. If this party isdata_source
, operations such as addinginvoice_number
are carried out. If ERP, it is sent toapproved_order_cancel
inOrderService
. It is then sent toorder_status_update
.cancel_order: Here, we first collect the reasons in the order that is linked to the vendor order; then, we send the order linked to the vendor order to
cancel_order
inOrderService
.
Figure 6: VendorOrderService Methods
VendorOrderItemService
(omnitron.orders.service.VendorOrderItemService)
create_order_item: A method that allows to create vendor order items.
update_order_item: Sends the order item linked to the vendor order item to
update_order_item
inOrderItemService
.bulk_update_order_item: Puts through serializer for update and sends to
update_order_item_with_base
.update_order_item_with_base: First, it sends the order item linked to the vendor order item to
update_order_item
inOrderItemService
. It then checks thatretail_store
inshipping_address
and the order.status value are delivered, and sends toupdate_base_order_item
.update_base_order_item: Collects certain data and sends the order item linked to the vendor order item to
update_order_item
inOrderItemService
.update_order_item_send_stock: Sends the product_stock value in
stock_list
linked toorder_item
toupdate_sold_quantity_reported
method inProductStockService
.send_shipping_info: Sends the order item linked to the vendor order item to
send_shipping_info
inOrderItemService
.
Figure 7: VendorOrderItemService Methods
Channel Tasks
All tasks are in omnitron.channels.integrations.akinon.tasks
. As in other channels, there is data that the supplier needs to send. Tasks such as providing price & stock information, sending products, picking orders, etc. are located here.
Commands are located on serializer_class
in omnitron.channels.integrations.akinon.integration.Integration
.
These are:
InsertProduct: Throws a post to
omnitron.products.resources.views.DistributedProductViewSet
and inserts the product.UpdateProduct: Inherited from
InsertProduct
. The product is updated by throwing aPUT
request to the same location.CreateProductIntegrationObject: Throws a
GET
request toomnitron.products.resources.views.DistributedProductViewSet
and picks the products. Defined as the failed action ofInsertProduct
.UpdateOrderIsSend: Throws a
PATH
request toomnitron.orders.resources.views.VendorOrderViewSet
and updates the send status.UpdateSendStock: Throws a
POST
request toomnitron.orders.resources.views.VendorOrderItemViewSet
and updates stock.InsertImage: Throws a
POST
toomnitron.products.resources.views.DistributedDownloadableImageViewSet
and allows to insert images for the relevant product.CreateDownloadableImageIntegrationObject: Defined as the failed action of
InsertImage
. Throws aGET
request toomnitron.products.resources.views.DistributedDownloadableImageViewSet
.DeleteProduct: Throws a
DELETE
request toomnitron.products.resources.views.DistributedProductViewSet
with theremote id
information of the product to be deleted.GetAttributeValues: Throws a
GET
request toomnitron.products.resources.views.DistributedAttributeValueViewSet
and gets the attribute values.GetAttributeSets: Throws a
GET
request toomnitron.products.resources.views.DistributedAttributeSetViewSet
and gets the attributesets.UpsertStock: Throws a
POST
request toomnitron.catalogs.resources.views.DistributedProductStockViewSet
and carries out bulk update if there is stock, or bulk addition if there is no stock.UpsertPrice: Carries out price update and addition actions such as
UpsertStock
. Destination of the thrown request is;omnitron.catalogs.resources.views.DistributedProductPriceViewSet
GetOrders: Request is thrown with
GET
request fromomnitron.orders.resources.views.VendorOrderViewSet
and in line with certain conditions. For instance; in case ofstart_date
,end_date
andorder_number
andget_url
conditions, it is added to the filter, the query is completed and the request is thrown.CancelOrders: Request is sent to the omnitron.orders.resources.views.VendorOrderViewSet.cancel endpoint. The integration action of the sending party is added based on the response to this request.
UpdateOrderItems: When there is an update requirement for order items, a patch request is sent to omnitron.orders.resources.views.VendorOrderItemViewSet.
BulkUpdateOrderItems: Does the same thing as UpdateOrderItems, but in bulk.
GetCancellationPlans: A request is thrown to
omnitron.orders.resources.views.VendorCancellationPlanViewSet
. It collects all created cancellation plans and creates those not available.ApproveCancellationPlan: Throws a
POST
request toomnitron.orders.resources.views.VendorOrderViewSet.cancellation_approved_order
endpoint for the approval of the cancellation of the relevant order.RejectCancellationPlan: Throws a
POST
request toomnitron.orders.resources.views.VendorOrderViewSet.cancellation_reject_order
endpoint for the rejection of the cancellation of the relevant order.RejectOrderCancel: Does the same things as
RejectCancellationPlan
.GetReconciliations: Throws a
GET
request toomnitron.orders.resources.views.VendorReconciliationViewSet
and gets reconciliations. Suspends or proceeds with orders according to the reconciliation status.UpdateReconciliationStatus: Throws a
POST
request toomnitron.orders.resources.views.VendorReconciliationViewSet
and notifies the other party of the update in the reconciliation.CreateOrderIntegrationObject: Throws a
GET
request toomnitron.orders.resources.views.VendorOrderViewSet
with order number filterCreateOrderItemIntegrationObject: Throws a
GET
request toomnitron.orders.resources.views.VendorOrderViewSet
and creates integration actions for order items in the supplier.DeleteImage: Throws a
DELETE
request toomnitron.products.resources.views.DistributedDownloadableImageViewSet
and updates downloadable image in seller.UpdateImage: Throws a
PUT
request toomnitron.products.resources.views.DistributedDownloadableImageViewSet
with order number filter
Views
omnitron.orders.resources.views.VendorOrderViewSet
Inherited from OrderViewSet
. There are two more methods different from OrderViewSet
; these are on get_queryset
and cancel
. For get_queryset
, the data source has been filtered and returned through the orders with the token in the request and the token in the datasource. For cancel
, such a course of action has been taken for data source control.
Figure 8: VendorOrderViewSet Structure
omnitron.orders.resources.views.VendorOrderItemViewSet
In this class, it has been inherited from OrderItemViewSet
.
get_queryset: The data source has been filtered and returned through the orders with the token in the request and the token in the datasource
perform_update: Overridden so that the serialized data is sent to
omnitron.orders.service.VendorOrderItemService.update_order_item_with_base
method.bulk_update: Overridden so that the request data is sent to
omnitron.orders.service.VendorOrderItemService.bulk_update_order_item
method.
Figure 9: VendorOrderItemViewSet Structure
Serializers
omnitron.orders.resources.serializers.VendorOrderSerializer
Inherited from OrderSerializer
.
omnitron.orders.resources.serializers.VendorOrderCreateSerializer
Inherited from OrderSerializer, with validate
method overridden. Here, discount_amount
, amount
and installment_interest_amount
’s orderitems
linked to the vendor order were fetched as and filled in as attrs
.
omnitron.orders.resources.serializers.VendorOrderItemSerializer
Inherited from BaseOrderItemSerializer
.