Skip to content

Instantly share code, notes, and snippets.

@n1c01a5
Created October 21, 2017 14:05
Show Gist options
  • Save n1c01a5/79a77ca39b4b3ce45f5e37802d9cd896 to your computer and use it in GitHub Desktop.
Save n1c01a5/79a77ca39b4b3ce45f5e37802d9cd896 to your computer and use it in GitHub Desktop.
pragma solidity ^0.4.15;
contract UniversalOrder {
enum StatusOrder {
Paid,
Refunded
}
struct Order {
address owner;
address airlineAddress;
uint price;
StatusOrder statusOrder;
uint departureDate; // timestamp
}
// orderId => Order
mapping (string => Order) public orders;
enum StatusRule {
Delay,
Cancelled
}
struct Rule {
StatusRule statusRule;
uint delay; // delay of the lag time (timestamp)
uint ratioRefund;
}
Rule[] public rules;
// airline function
function addRule (uint _statusRule, uint _delay, uint _ratioRefund) public {
Rule storage rule;
rule.statusRule = StatusRule.Delay;
rule.delay = _delay;
rule.ratioRefund = _ratioRefund;
}
// customer function
function book (string _orderId, address _airlineAddress, uint _departureDate) public payable {
Order storage order;
order.owner = msg.sender;
order.price = msg.value;
order.airlineAddress = msg.sender;
order.statusOrder = StatusOrder.Paid;
order.departureDate = _departureDate;
orders[_orderId] = order;
}
function reimburse () public returns (bool) {
return true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment