| | |
| | | } |
| | | |
| | | @Test |
| | | void fixesTheCollectingSubMerchantOnThePaidOrder() { |
| | | Map<String, Object> created = appOrderPortalService.create(talentId, new AppOrderCreateRequest(merchantId, productId, null), "app-order-collector-" + System.nanoTime()); |
| | | |
| | | Map<String, Object> onboarding = jdbc.queryForMap("select store_id, provider_huifu_id from merchant_onboarding_application where id = ?", onboardingId); |
| | | Map<String, Object> order = jdbc.queryForMap(""" |
| | | select collect_onboarding_id, collect_store_id, collect_huifu_id |
| | | from benefit_order where order_no = ? |
| | | """, created.get("orderNo")); |
| | | assertThat(order).containsEntry("collect_onboarding_id", onboardingId) |
| | | .containsEntry("collect_store_id", onboarding.get("store_id")) |
| | | .containsEntry("collect_huifu_id", onboarding.get("provider_huifu_id")); |
| | | } |
| | | |
| | | @Test |
| | | void leavesTheCollectingSubMerchantEmptyOnAFreeOrder() { |
| | | jdbc.update(""" |
| | | update merchant_product |
| | | set rights_config = ? |
| | | where id = ? |
| | | """, "[{\"level\":\"卓越人才卡\",\"enabled\":true,\"free\":true,\"limitCount\":1,\"exceedDiscount\":6,\"resetCycle\":\"每月\"}]", productId); |
| | | |
| | | Map<String, Object> freeOrder = appOrderPortalService.create(talentId, new AppOrderCreateRequest(merchantId, productId, null), "app-order-free-collector-" + System.nanoTime()); |
| | | |
| | | Map<String, Object> order = jdbc.queryForMap(""" |
| | | select pay_amount, collect_onboarding_id, collect_huifu_id |
| | | from benefit_order where order_no = ? |
| | | """, freeOrder.get("orderNo")); |
| | | assertThat(order).containsEntry("pay_amount", 0L) |
| | | .containsEntry("collect_onboarding_id", null) |
| | | .containsEntry("collect_huifu_id", null); |
| | | } |
| | | |
| | | @Test |
| | | void refusesPaidOrderWhenTheApprovedOnboardingHasNoHuifuId() { |
| | | jdbc.update("update merchant_onboarding_application set provider_huifu_id=null where id=?", onboardingId); |
| | | |
| | | assertThatThrownBy(() -> appOrderPortalService.create(talentId, new AppOrderCreateRequest(merchantId, productId, null), "app-order-no-huifu-" + System.nanoTime())) |
| | | .isInstanceOf(BusinessException.class) |
| | | .hasMessageContaining("斗拱商户号"); |
| | | } |
| | | |
| | | @Test |
| | | void usesAvailableFreeCountBeforeChargingTheProductPrice() { |
| | | jdbc.update(""" |
| | | update merchant_product |