feat: order action per status change
This commit is contained in:
122
app/actions/orderStatusActions/examples.go
Normal file
122
app/actions/orderStatusActions/examples.go
Normal file
@@ -0,0 +1,122 @@
|
||||
package orderStatusActions
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"git.ma-al.com/goc_daniel/b2b/app/model/enums"
|
||||
)
|
||||
|
||||
func init() {
|
||||
GlobalRegistry.Register(enums.OrderStatusConfirmed, ActionChain{
|
||||
SendOrderConfirmationEmail,
|
||||
NotifyInventorySystem,
|
||||
})
|
||||
|
||||
GlobalRegistry.Register(enums.OrderStatusProcessing, ActionChain{
|
||||
NotifyWarehouse,
|
||||
ReserveInventory,
|
||||
})
|
||||
|
||||
GlobalRegistry.Register(enums.OrderStatusShipped, ActionChain{
|
||||
NotifyWarehouseShipped,
|
||||
GenerateTrackingNumber,
|
||||
SendShippingNotificationEmail,
|
||||
})
|
||||
|
||||
GlobalRegistry.Register(enums.OrderStatusDelivered, ActionChain{
|
||||
SendDeliveryConfirmationEmail,
|
||||
NotifyFulfillmentComplete,
|
||||
})
|
||||
|
||||
GlobalRegistry.Register(enums.OrderStatusCancelled, ActionChain{
|
||||
SendCancellationEmail,
|
||||
ReleaseInventory,
|
||||
ProcessRefund,
|
||||
})
|
||||
|
||||
GlobalRegistry.Register(enums.OrderStatusReturned, ActionChain{
|
||||
SendReturnConfirmationEmail,
|
||||
NotifyReturnsDepartment,
|
||||
})
|
||||
|
||||
GlobalRegistry.Register(enums.OrderStatusRefunded, ActionChain{
|
||||
NotifyRefundProcessed,
|
||||
})
|
||||
|
||||
GlobalRegistry.Register(enums.OrderStatusPending, ActionChain{})
|
||||
}
|
||||
|
||||
var SendOrderConfirmationEmail = WithID("send_order_confirmation_email", func(actionCtx ActionContext) ActionResult {
|
||||
log.Printf("Sending order confirmation email for order %d", actionCtx.OrderId)
|
||||
return ActionResult{Err: nil}
|
||||
})
|
||||
|
||||
var NotifyInventorySystem = WithID("notify_inventory_system", func(actionCtx ActionContext) ActionResult {
|
||||
log.Printf("Notifying inventory system for order %d", actionCtx.OrderId)
|
||||
return ActionResult{Err: nil}
|
||||
})
|
||||
|
||||
var NotifyWarehouse = WithID("notify_warehouse", func(actionCtx ActionContext) ActionResult {
|
||||
log.Printf("Notifying warehouse for order %d", actionCtx.OrderId)
|
||||
return ActionResult{Err: nil}
|
||||
})
|
||||
|
||||
var ReserveInventory = WithID("reserve_inventory", func(actionCtx ActionContext) ActionResult {
|
||||
log.Printf("Reserving inventory for order %d", actionCtx.OrderId)
|
||||
return ActionResult{Err: nil}
|
||||
})
|
||||
|
||||
var NotifyWarehouseShipped = WithID("notify_warehouse_shipped", func(actionCtx ActionContext) ActionResult {
|
||||
log.Printf("Notifying warehouse of shipment for order %d", actionCtx.OrderId)
|
||||
return ActionResult{Err: nil}
|
||||
})
|
||||
|
||||
var GenerateTrackingNumber = WithID("generate_tracking_number", func(actionCtx ActionContext) ActionResult {
|
||||
log.Printf("Generating tracking number for order %d", actionCtx.OrderId)
|
||||
return ActionResult{Err: nil}
|
||||
})
|
||||
|
||||
var SendShippingNotificationEmail = WithID("send_shipping_notification_email", func(actionCtx ActionContext) ActionResult {
|
||||
log.Printf("Sending shipping notification email for order %d", actionCtx.OrderId)
|
||||
return ActionResult{Err: nil}
|
||||
})
|
||||
|
||||
var SendDeliveryConfirmationEmail = WithID("send_delivery_confirmation_email", func(actionCtx ActionContext) ActionResult {
|
||||
log.Printf("Sending delivery confirmation email for order %d", actionCtx.OrderId)
|
||||
return ActionResult{Err: nil}
|
||||
})
|
||||
|
||||
var NotifyFulfillmentComplete = WithID("notify_fulfillment_complete", func(actionCtx ActionContext) ActionResult {
|
||||
log.Printf("Notifying fulfillment complete for order %d", actionCtx.OrderId)
|
||||
return ActionResult{Err: nil}
|
||||
})
|
||||
|
||||
var SendCancellationEmail = WithID("send_cancellation_email", func(actionCtx ActionContext) ActionResult {
|
||||
log.Printf("Sending cancellation email for order %d", actionCtx.OrderId)
|
||||
return ActionResult{Err: nil}
|
||||
})
|
||||
|
||||
var ReleaseInventory = WithID("release_inventory", func(actionCtx ActionContext) ActionResult {
|
||||
log.Printf("Releasing inventory for order %d", actionCtx.OrderId)
|
||||
return ActionResult{Err: nil}
|
||||
})
|
||||
|
||||
var ProcessRefund = WithID("process_refund", func(actionCtx ActionContext) ActionResult {
|
||||
log.Printf("Processing refund for order %d", actionCtx.OrderId)
|
||||
return ActionResult{Err: nil}
|
||||
})
|
||||
|
||||
var SendReturnConfirmationEmail = WithID("send_return_confirmation_email", func(actionCtx ActionContext) ActionResult {
|
||||
log.Printf("Sending return confirmation email for order %d", actionCtx.OrderId)
|
||||
return ActionResult{Err: nil}
|
||||
})
|
||||
|
||||
var NotifyReturnsDepartment = WithID("notify_returns_department", func(actionCtx ActionContext) ActionResult {
|
||||
log.Printf("Notifying returns department for order %d", actionCtx.OrderId)
|
||||
return ActionResult{Err: nil}
|
||||
})
|
||||
|
||||
var NotifyRefundProcessed = WithID("notify_refund_processed", func(actionCtx ActionContext) ActionResult {
|
||||
log.Printf("Notifying refund processed for order %d", actionCtx.OrderId)
|
||||
return ActionResult{Err: nil}
|
||||
})
|
||||
Reference in New Issue
Block a user