# QR + Coupons and Task Sequences v0.2 #### Links: [graphQL queries](https://hackmd.io/@arnold-goes-digital/SyMoOAjfh) # MINOR CHANGES FOR NOW! **19.04.2023** - CodeService will handle CouponService requirements for now. ## 1. use reward **Scenario**: User goes into a restaurant and shows reward/user identification qr code to the POS system -> if user level = coupon reward level -> send coupon pos data with qr request ```mermaid sequenceDiagram participant app as CustomerApp participant hygraph as Hygraph participant reward as RewardService participant code as CodeService participant pos as POS participant receipt as ReceiptService app->>hygraph: getCouponsByType(reward) hygraph->>app: return active coupons app->>reward: getRewardLevelByUserId(userId) reward->>app: return reward level for user app->>app: filter if user reward level == coupon Note over app: Open available coupons view app->>app: user opens user QR Note over app: open QR code view app->>code: getQRcodeWithCouponID(userId,couponId,singleUse,POSresponse) code->>app: return QR datacode app->>pos: show QR code to reader pos->>code: getDataByCode(userId,codeId,...) code->>pos: return payload* with saved pos response pos->>pos: process payment pos->>receipt: send receipt data ``` ```json JSON Response { "customerId": "6666", "discountList": [ { "posDiscountId": "afe998ca-293b-4521-9803-0e9aaa7f6deb", // premade to flowpos "discountId": "R123" // our own coupon id from hygraph "compulsoryError": "User can get this IF total payment is over 7e" // possible extradata (shown as popup on POS) } ] } ``` ## 2. use a coupon **Scenario**: User goes into a restaurant and opens coupons view -> get active coupons -> get coupons used by customer -> show available coupons for user -> send coupon pos data with qr request ```mermaid sequenceDiagram participant app as CustomerApp participant hygraph as Hygraph participant coupon as CouponService participant code as CodeService participant pos as POS participant receipt as ReceiptService app->>hygraph: getCouponsByType(coupon) hygraph->>app: return active coupons app->>coupon: getUsedCouponsByUserId(userId) coupon->>app: return coupons used by user app->>app: filter used coupons from all Note over app: Open available coupons view app->>app: user opens coupon app->>code: getQRcodeWithCouponID(userId,couponId,singleUse,POSresponse) code->>app: return QR datacode Note over app: open QR code view app->>pos: show QR code to reader pos->>code: getDataByCode(userId,codeId,...) code->>pos: return payload* with saved pos response pos->>pos: process payment pos->>receipt: send receipt data receipt->>coupon: PUT userId + couponId = used ``` ```json JSON Response { "customerId": "6666", "discountList": { "posDiscountId": "afe998ca-293b-4521-9803-0e9aaa7f6deb", // premade to flowpos "discountId": "C123" // our own coupon id from hygraph } } ``` ## 3. use a "campaign" **Scenario**: User goes into a restaurant and opens campaign view -> difference from coupons -> can be used multiple times -> get active "campaign" coupons -> show available coupons for user -> send coupon pos data with qr request ```mermaid sequenceDiagram participant app as CustomerApp participant hygraph as Hygraph participant coupon as CouponService participant code as CodeService participant pos as POS participant receipt as ReceiptService app->>hygraph: getCouponsByType(campaign) hygraph->>app: return active coupons Note over app: Open available campaign view app->>app: user opens campaign app->>code: getQRcodeWithCouponID(userId,couponId,singleUse,POSresponse) code->>app: return QR datacode Note over app: open QR code view app->>pos: show QR code to reader pos->>code: getDataByCode(userId,codeId,...) code->>pos: return payload* with saved pos response pos->>pos: process payment pos->>receipt: send receipt data ``` ```json JSON Response { "customerId": "6666", "discountList": { "posDiscountId": "afe998ca-293b-4521-9803-0e9aaa7f6deb", // premade to flowpos "discountId": "C123" // our own coupon id from hygraph } } ``` ## 4. use a "task" **Scenario**: User is a member of beta test group. -> One active task to do at a time (show task open) -> When task is completed (show task done) -> new task every mon, wed, fri -> push notification "new task available" -> different from coupons / rewards -> no pos action -> needs a form from hubspot ```mermaid sequenceDiagram participant app as CustomerApp participant hygraph as Hygraph participant coupon as CouponService participant hubspot as Hubspot app->>hygraph: getCouponsByType(task) hygraph->>app: return active tasks app->>coupon: getUsedCouponsByUserId(userId) coupon->>app: return coupons used by user app->>app: filter current coupons(task) status Note over app: Open current task view <br /> show description <br /> show hubspot form app->>app: user fills form and submits app->>coupon: update CouponService markTaskCompeleted(userId,taskId) app->>hubspot: Submit form ``` ## 5. Mark coupon as used ```mermaid sequenceDiagram participant pos as POS participant rs as ReceiptService participant cs as CouponService pos-->>rs: send receipt (with coupon code) rs-->>cs: mark coupon used for user ```