forked from wangziqi/gongxue-base
feat: add point activities and exchange
This commit is contained in:
@@ -74,6 +74,11 @@ const ids = {
|
||||
tenantCheckInBadge: '00000000-0000-0000-0000-000000000873',
|
||||
tenantScoreBadge: '00000000-0000-0000-0000-000000000874',
|
||||
tenantFeedbackBadge: '00000000-0000-0000-0000-000000000875',
|
||||
tenantActivityBadge: '00000000-0000-0000-0000-000000000876',
|
||||
pointActivityTask: '00000000-0000-0000-0000-000000000877',
|
||||
pointSystemTask: '00000000-0000-0000-0000-000000000878',
|
||||
pointExchangeItem: '00000000-0000-0000-0000-000000000879',
|
||||
pointExpensiveExchangeItem: '00000000-0000-0000-0000-000000000880',
|
||||
partnerTenant: '00000000-0000-0000-0000-000000000901',
|
||||
partnerSubscription: '00000000-0000-0000-0000-000000000902',
|
||||
partnerInvoice: '00000000-0000-0000-0000-000000000903',
|
||||
@@ -222,6 +227,42 @@ async function main() {
|
||||
[tenantId, ids.user, ids.tenantAdminUser, ids.question, ids.questionTwo],
|
||||
);
|
||||
|
||||
await client.query(
|
||||
`
|
||||
delete from public.user_point_exchange_orders
|
||||
where tenant_id = $1
|
||||
and (
|
||||
user_id in ($2::uuid, $3::uuid)
|
||||
or item_id = any($4::uuid[])
|
||||
or idempotency_key like 'integration-%'
|
||||
)
|
||||
`,
|
||||
[
|
||||
tenantId,
|
||||
ids.user,
|
||||
ids.secondStudentUser,
|
||||
[ids.pointExchangeItem, ids.pointExpensiveExchangeItem],
|
||||
],
|
||||
);
|
||||
|
||||
await client.query(
|
||||
`
|
||||
delete from public.user_point_activity_claims
|
||||
where tenant_id = $1
|
||||
and (
|
||||
user_id in ($2::uuid, $3::uuid)
|
||||
or task_id = any($4::uuid[])
|
||||
or coalesce(metadata->>'source', '') = 'integration-test'
|
||||
)
|
||||
`,
|
||||
[
|
||||
tenantId,
|
||||
ids.user,
|
||||
ids.secondStudentUser,
|
||||
[ids.pointActivityTask, ids.pointSystemTask],
|
||||
],
|
||||
);
|
||||
|
||||
await client.query(
|
||||
`
|
||||
delete from public.user_score_events
|
||||
@@ -234,6 +275,32 @@ async function main() {
|
||||
[tenantId, ids.user, ids.tenantAdminUser, ids.secondStudentUser, ids.leaderboardScoreEventSecond],
|
||||
);
|
||||
|
||||
await client.query(
|
||||
`
|
||||
delete from public.point_exchange_items
|
||||
where tenant_id = $1
|
||||
and (
|
||||
id = any($2::uuid[])
|
||||
or coalesce(legacy_id, '') like 'integration-point-exchange-%'
|
||||
or code::text like 'integration-%'
|
||||
)
|
||||
`,
|
||||
[tenantId, [ids.pointExchangeItem, ids.pointExpensiveExchangeItem]],
|
||||
);
|
||||
|
||||
await client.query(
|
||||
`
|
||||
delete from public.point_activity_tasks
|
||||
where tenant_id = $1
|
||||
and (
|
||||
id = any($2::uuid[])
|
||||
or coalesce(legacy_id, '') like 'integration-point-task-%'
|
||||
or code::text like 'integration-%'
|
||||
)
|
||||
`,
|
||||
[tenantId, [ids.pointActivityTask, ids.pointSystemTask]],
|
||||
);
|
||||
|
||||
await client.query(
|
||||
`
|
||||
delete from public.audit_logs
|
||||
@@ -336,7 +403,12 @@ async function main() {
|
||||
[tenantId, ids.leaderboardSessionUser, ids.leaderboardSessionSecond],
|
||||
);
|
||||
|
||||
const checkoutCouponCodes = ['SMOKE50', 'SMOKEFREE'];
|
||||
const checkoutCouponCodes = [
|
||||
'SMOKE50',
|
||||
'SMOKEFREE',
|
||||
'IT-COUPON-001',
|
||||
'IT-POINT-EXCHANGE-COUPON',
|
||||
];
|
||||
|
||||
await client.query(
|
||||
`
|
||||
@@ -345,14 +417,31 @@ async function main() {
|
||||
and (
|
||||
coupon_id = any($2::uuid[])
|
||||
or coupon_code = any($3::text[])
|
||||
or coupon_code like any($4::text[])
|
||||
or coupon_id in (
|
||||
select id from public.coupons
|
||||
where tenant_id = $1
|
||||
and (
|
||||
campaign_name in ('integration-coupon-rules', 'integration-point-exchange', 'tenant-admin-coupon-smoke')
|
||||
or code::text like any($4::text[])
|
||||
)
|
||||
)
|
||||
or order_id in (
|
||||
select id from public.orders
|
||||
where tenant_id = $1
|
||||
and (raw_payload->'pricing'->>'couponCode') = any($3::text[])
|
||||
and (
|
||||
(raw_payload->'pricing'->>'couponCode') = any($3::text[])
|
||||
or (raw_payload->'pricing'->>'couponCode') like any($4::text[])
|
||||
)
|
||||
)
|
||||
)
|
||||
`,
|
||||
[tenantId, [ids.checkoutCoupon, ids.freeCheckoutCoupon], checkoutCouponCodes],
|
||||
[
|
||||
tenantId,
|
||||
[ids.checkoutCoupon, ids.freeCheckoutCoupon],
|
||||
checkoutCouponCodes,
|
||||
['ITMIN%', 'ITDIS%', 'ITREG%', 'ITMULTI%', 'ITFIRST%', 'IT-POINT-%'],
|
||||
],
|
||||
);
|
||||
|
||||
await client.query(
|
||||
@@ -423,6 +512,25 @@ async function main() {
|
||||
[tenantId, checkoutCouponCodes],
|
||||
);
|
||||
|
||||
await client.query(
|
||||
`
|
||||
delete from public.coupons
|
||||
where tenant_id = $1
|
||||
and (
|
||||
id = any($2::uuid[])
|
||||
or code::text = any($3::text[])
|
||||
or code::text like any($4::text[])
|
||||
or campaign_name in ('integration-coupon-rules', 'integration-point-exchange', 'tenant-admin-coupon-smoke')
|
||||
)
|
||||
`,
|
||||
[
|
||||
tenantId,
|
||||
[ids.checkoutCoupon, ids.freeCheckoutCoupon],
|
||||
checkoutCouponCodes,
|
||||
['ITMIN%', 'ITDIS%', 'ITREG%', 'ITMULTI%', 'ITFIRST%', 'IT-POINT-%'],
|
||||
],
|
||||
);
|
||||
|
||||
await client.query(
|
||||
`
|
||||
delete from public.commission_settlement_items
|
||||
|
||||
Reference in New Issue
Block a user