Subversion Repositories SmartDukaan

Rev

Rev 845 | Rev 956 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

namespace java in.shop2020.model.v1.order
namespace py shop2020.thriftpy.model.v1.order
/***
        Order objects.
*/
enum OrderStatus{
        PAYMENT_PENDING,
        PAYMENT_FAILED,
        INIT,
        SUBMITTED_FOR_PROCESSING,
        ACCEPTED,
        INVENTORY_LOW,
        REJECTED,
        BILLED,
        READY_FOR_SHIPPING,
        SHIPPED_FROM_WH,
        SHIPPED_TO_LOGST,
        IN_TRANSIT,
        DELIVERY_SUCCESS,
        DELIVERY_FAILED_FIRST_ATTEMPT,
        DELIVERY_FAILED_SECOND_ATTEMPT,
        DELIVERY_FAILED_THIRD_ATTEMPT,
        DELIVERY_FAILED_WORNG_ADDRESS
        COMPLETED,
        CANCELED,
        FAILED
}

enum TransactionStatus{
        INIT,
        IN_PROCESS,
        COMPLETED,
        FAILED
}


struct LineItem{
        1:i64 id,
        2:i64 item_id,
        3:string brand,
        4:string model_number,
        5:string model_name,
        6:string extra_info,
        7:double quantity,
        8:double unit_price,
        9:double unit_weight,
        10:double total_price,
        11:double total_weight,
        12:string color
}


struct Order{
        1:i64 id,
        2:i64 warehouse_id,
        /**
                item info
        **/
        3:list<LineItem> lineitems,
        /**
          logistics info
        **/
        4:i64 logistics_provider_id,
        5:string airwaybill_no,
        6:string tracking_id,
        7:i64 expected_delivery_time,
        /**
          customer info
        **/
        8:i64 customer_id,
        9:string customer_name,
        10:string customer_mobilenumber,
        11:string customer_pincode,
        12:string customer_address1,
        13:string customer_address2,
        14:string customer_email,
        15:string customer_city,
        16:string customer_state,

        /**
                status and misc info
        **/
        17:OrderStatus status,
        18:string statusDescription,
        19:double total_amount,
        20:double total_weight,
        /**
                billing info
        **/
        21:string invoice_number,
        22:string billed_by,
        /**
                timestamps
        **/
        23:i64 created_timestamp,
        24:i64 accepted_timestamp,
        25:i64 billing_timestamp,
        26:i64 shipping_timestamp,
        27:i64 delivery_timestamp,
        28:i64 jacket_number,
}

struct Transaction{
        1:i64 id,
        2:list<Order> orders,
        3:i64 createdOn,
        4:TransactionStatus transactionStatus,
        5:string statusDescription,
        6:i64 shoppingCartid,
        7:i64 customer_id
}

struct Alert{
        1:i64 id,
        2:i64 order_id,
        3:i64 type,
        4:i64 time_set,
        5:string comment,
        6:i64 time_unset
}

exception TransactionServiceException{
        1:i32 errorCode,
        2:string message
}

service TransactionService{
        
        /**
        * For closing the open session in sqlalchemy
        */
        void closeSession(),
        
        i64 createTransaction(1:Transaction transaction) throws (1:TransactionServiceException ex),
        
        //      Get transaction methods.
        Transaction getTransaction(1:i64 id) throws (1:TransactionServiceException ex),
        list<Transaction> getTransactionsForCustomer(1:i64 customerId, 2:i64 from_date, 3:i64 to_date, 4:TransactionStatus status) throws (1:TransactionServiceException ex),
        list<Transaction> getTransactionsForShoppingCartId(1:i64 shoppingCartId) throws (1:TransactionServiceException ex),
        TransactionStatus getTransactionStatus(1:i64 transactionId) throws (1:TransactionServiceException ex),
        bool changeTransactionStatus(1:i64 transactionId, 2:TransactionStatus status, 3:string description) throws (1:TransactionServiceException ex),

        //      Order getter and setters
        
        /*
        list<Transaction> getTransactionsForShipmentStatus(1:ShipmentStatus status, 2:i64 from_date, 3:i64 to_date) throws (1:TransactionServiceException ex),
        list<Transaction> getTransactionsForCustomer(1:i64 customerId, 2:i64 from_date, 3:i64 to_date, 4:TransactionStatus status) throws (1:TransactionServiceException ex),
        list<Transaction> getTransactionsForCustomerAndShipmentStatus(1:i64 customerId, 2:i64 from_date, 3:i64 to_date, 4:ShipmentStatus status) throws (1:TransactionServiceException ex),
        list<Transaction> getTransactionsForShoppingCartId(1:i64 shoppingCartId) throws (1:TransactionServiceException ex),
        TransactionStatus getTransactionStatus(1:i64 transactionId) throws (1:TransactionServiceException ex),
        bool changeTransactionStatus(1:i64 transactionId, 2:TransactionStatus status, 3:string description) throws (1:TransactionServiceException ex),
        */
        
        list<Order> getAllOrders(1:OrderStatus status, 2:i64 from_date, 3:i64 to_date, 4:i64 warehouse_id) throws (1:TransactionServiceException ex),
        bool changeOrderStatus(1:i64 orderId, 2:OrderStatus status, 3:string description) throws (1:TransactionServiceException ex),
        bool addBillingDetails(1:i64 orderId, 2:string invoice_number, 3:i64 jacket_number, 4:string billed_by) throws (1:TransactionServiceException ex),

        bool acceptOrder(1:i64 orderId) throws (1:TransactionServiceException ex),
        bool billOrder(1:i64 orderId) throws (1:TransactionServiceException ex),
                
        list<Order> getOrdersForTransaction(1:i64 transactionId)  throws (1:TransactionServiceException ex),
        list<Order> getOrdersForCustomer(1:i64 customerId, 2:i64 from_date, 3:i64 to_date, 4:OrderStatus status) throws (1:TransactionServiceException ex),
        i64 createOrder(1:Order order) throws (1:TransactionServiceException ex),
        Order getOrder(1:i64 id) throws (1:TransactionServiceException ex),
        list<LineItem> getLineItemsForOrder(1:i64 orderId) throws (1:TransactionServiceException ex),
        
        /**
        Marks all BILLED orders for a warehouse and a provider as SHIPPED_FROM_WH
        */
        bool markOrdersAsManifested(1:i64 warehouseId, 2:i64 providerId) throws (1:TransactionServiceException ex),
        //Alerts apis 
        list<Alert> getAlerts(1:i64 orderId, 2:bool valid),
        void setAlert(1:i64 orderId, 2:bool unset, 3:i64 type, 4: string comment),
}


/*

enum PaymentStatus{
        FAILURE,
        SUCCESS
}

enum ShipmentStatus{
        YET_TO_SHIP,
        SHIPPED,
        IN_TRANSIT,
        DELIVERY_SUCCESS,
        DELIVERY_FAILED_FIRST_ATTEMPT,
        DELIVERY_FAILED_SECOND_ATTEMPT,
        DELIVERY_FAILED_THIRD_ATTEMPT,
        DELIVERY_FAILED_WORNG_ADDRESS
}

enum TransactionStatus{
        INCOMPLETE,
        INIT,
        SUBMITTED_FOR_PROCESSING,
        ORDER_FULFILLMENT,
        READY_FOR_SHIPPING,
        SHIPPED,
        COMPLETED,
        CANCELED,
        FAILED, 
        BILLED  
}


struct Item{
        1:i64 id,
        2:double price,
        3:double weight
}

struct LineItem{
        1:Item item,
        2:i64 id,
        3:i64 addedOn,
        4:map<string,string> additionalInfo
}

struct OrderInfo{
        1:i64 id,
        2:list<LineItem> lineitems
}

struct Billing{
        1:i64 id,
        2:string billNumber,
        3:list<LineItem> lineItem,
        4:i64 generatedTimestamp,
        5:string generatedBy
}

struct BillingInfo{
        1:i64 id,
        2:list<Billing> billings
}

struct Shipment{
        1:i64 id,
        2:string address,
        3:string trackingId,
        4:list<LineItem> lineItems,
        5:ShipmentStatus status,
        6:i64 shipmentTimestamp,
        7:i64 deliveryTimestamp,
        8:double value,
        9:double insurance,
        10:double weight,
        11:string airwayBillNo,
        12:string provider
}

struct ShipmentInfo{
        1:list<Shipment> shipments,
        2:i64 id
}

struct Payment{
        1:i64 id,
        2:string merchant_tx_id,
        3:string bank_tx_id,
        4:string mode,
        5:double amount,
        6:PaymentStatus status,
        7:string description,
        9:i64 submissionTimestamp,
        10:i64 completionTimestamp
}

struct PaymentInfo{
        1:i64 id,
        2:map<i64,Payment> payments
}

struct Transaction{
        1:i64 id,
        2:OrderInfo orderInfo,
        3:ShipmentInfo shipmentInfo,
        4:BillingInfo billingInfo,
        5:PaymentInfo paymentInfo,
        6:i64 createdOn,
        7:i64 expectedDeliveryTime,
        8:TransactionStatus transactionStatus,
        9:string statusDescription,
        10:i64 customer_id,
        11:i64 shoppingCartid,
        12:i64 warehouse_id
}

struct Alert{
        1:i64 id,
        2:i64 transaction_id,
        3:i64 type,
        4:i64 time_set,
        5:string comment,
        6:i64 time_unset
}

struct ExtraOrderInfo{
        1:i64 id,
        2:i64 transaction_id,
        3:i64 sku_id,
        4:string model_name,
        5:string vendor_info,
        6:string colour
}



exception TransactionServiceException{
        1:i32 errorCode,
        2:string message
}

service TransactionService{
        
        i64 createTransaction(1:Transaction transaction) throws (1:TransactionServiceException ex),
        
        //      Get transaction methods.
        
        Transaction getTransaction(1:i64 id) throws (1:TransactionServiceException ex),
        list<Transaction> getAllTransactions(1:TransactionStatus status, 2:i64 from_date, 3:i64 to_date, 4:i64 warehouse_id) throws (1:TransactionServiceException ex),
        list<Transaction> getTransactionsForShipmentStatus(1:ShipmentStatus status, 2:i64 from_date, 3:i64 to_date) throws (1:TransactionServiceException ex),
        list<Transaction> getTransactionsForCustomer(1:i64 customerId, 2:i64 from_date, 3:i64 to_date, 4:TransactionStatus status) throws (1:TransactionServiceException ex),
        list<Transaction> getTransactionsForCustomerAndShipmentStatus(1:i64 customerId, 2:i64 from_date, 3:i64 to_date, 4:ShipmentStatus status) throws (1:TransactionServiceException ex),
        list<Transaction> getTransactionsForShoppingCartId(1:i64 shoppingCartId) throws (1:TransactionServiceException ex),
        TransactionStatus getTransactionStatus(1:i64 transactionId) throws (1:TransactionServiceException ex),
        bool changeTransactionStatus(1:i64 transactionId, 2:TransactionStatus status, 3:string description) throws (1:TransactionServiceException ex),
        
        //      Get and set individual objects in it
        
        OrderInfo getOrderInfo(1:i64 transactionId) throws (1:TransactionServiceException ex),
        ShipmentInfo getShippingInfo(1:i64 transactionId) throws (1:TransactionServiceException ex),
        BillingInfo getBillingInfo(1:i64 transactionId) throws (1:TransactionServiceException ex),
        bool addBilling(1:i64 tranactionId,2: Billing billing) throws (1:TransactionServiceException ex),
        bool setShippingTracker(1:i64 transactionId, 2:i64 shippingId, 3:string trackingId, 4:string airwayBillNo, 5:string provider) throws (1:TransactionServiceException ex),
        bool setShippingDate(1:i64 transactionId, 2:i64 shippingId, 3:i64 timestamp) throws (1:TransactionServiceException ex),
        bool setDeliveryDate(1:i64 transactionId, 2:i64 shippingid, 3:i64 timestamp) throws (1:TransactionServiceException ex),
        bool changeShippingStatus(1:i64 transactionId, 2:i64 shippingId, 3:ShipmentStatus status, 4:string description) throws (1:TransactionServiceException ex),
        bool addTrail(1:i64 transactionId, 2:string description)throws (1:TransactionServiceException ex),
        //Alerts apis set on 5th June
        list<Alert> getAlerts(1:i64 transactionId, 2:bool valid),
        void setAlert(1:i64 transactionId, 2:bool unset, 3:i64 type, 4: string comment),
        //extra order info apis. added for demo
        ExtraOrderInfo getExtraInfo(1:i64 transaction_id),
        void setExtraInfo(1:i64 transaction_id, 2:i64 sku_id, 3:string model, 4:string colour, 5:string vendor)
}
*/