petshop-10-services.spp
petshop/order/petshop-10-services.spp
Download original file · Petstore source contents
1domain petshop;23atomic query listOrders(key Buyer, ShopOrder[]);45atomic update releaseUnpaidInventory(StockLine[], UnpaidCancellationAgreement);67atomic update releasePaidInventory(StockLine[], PaidCancellationAgreement);8quantum update refundCancellationFunds(Buyer, Merchant, PaidCancellationAgreement) {9Buyer.wallet += PaidCancellationAgreement.refundAmount;10Merchant.cash -= PaidCancellationAgreement.refundAmount;11}1213atomic calculate prepareOrderInventory(ShopOrder, StockLine[]) {14StockLine[] = new StockLine[] {15};16for (OrderLine line : ShopOrder.lines) {17boolean exists = false;18for (StockLine stock : StockLine[]) {19if (stock.goods.sku == line.goods.sku) {20exists = true;21}22}23if (!exists) {24StockLine stock = new StockLine();25stock.goods = line.goods;26StockLine[] = append(StockLine[], stock);27}28}29}3031atomic update reserveInventory(StockLine[], ShopOrder);