${function(){
let finishCallback = `loyalty-benefit-package-card-benefit-detail-modal-934-modal.open;`;
if (!!data.status) {
finishCallback = `loyalty-global-toast-render.rerender(data='LOYALTY_SERVER_UNAUTHORIZED', redo=true);loyalty-panel-event-bus.emit(eventName='loyalty.refresh', origin='global');loyalty-global-loading.hide;`;
}
return `
${function(){
const iconMap = {
PAID_BENEFITS_1: "//app-assets.staticdj.com/apps/apployalty/paid_benefits_icon-b3f05972.svg",
POINT_ICON_1: "//app-assets.staticdj.com/apps/apployalty/point_icon_1-2de57b3f.svg",
POINT_ICON_2: "//app-assets.staticdj.com/apps/apployalty/point_icon_2-42f85bf2.svg",
CUSTOM_ICON_1: "//app-assets.staticdj.com/apps/apployalty/custom_icon_1-84f40f10.svg",
CUSTOM_ICON_2: "//app-assets.staticdj.com/apps/apployalty/custom_icon_2-94c8cfe9.svg",
FREE_SHIPPING_ICON_1: "//app-assets.staticdj.com/apps/apployalty/free_shipping_icon_2-03171771.svg",
FREE_SHIPPING_ICON_2: "//app-assets.staticdj.com/apps/apployalty/free_shipping_icon_2-03171771.svg",
ORDER_DISCOUNT_ICON_1: "//app-assets.staticdj.com/apps/apployalty/order_discount_icon_1-af2765d4.svg",
ORDER_DISCOUNT_ICON_2: "//app-assets.staticdj.com/apps/apployalty/order_discount_icon_2-1b28dd73.svg",
PRODUCT_DISCOUNT_ICON_1: "//app-assets.staticdj.com/apps/apployalty/product_discount_icon_1-843ecc47.svg",
PRODUCT_DISCOUNT_ICON_2: "//app-assets.staticdj.com/apps/apployalty/product_discount_icon_2-24233960.svg",
BUY_X_GET_Y_ICON_1: "//app-assets.staticdj.com/apps/apployalty/buy_x_get_y_icon_1-dcdd028e.svg",
BUY_X_GET_Y_ICON_2: "//app-assets.staticdj.com/apps/apployalty/buy_x_get_y_icon_2-f5630e76.svg"
};
const currentIcon = iconMap[benefit.icon] || benefit.icon;
return `
`;
}()}
${data.benefit.name}
${data.benefit.desc}
${function(){
if (!data.status) {
return `
${data.benefit.reward.point_value}
${function(){
const { discount_code_activity } = data.benefit?.reward || {};
const { discount_type, obtain_product, discount_value } = discount_code_activity || {};
if (discount_type === 'fixed_amount') {
return `
`
}
if (discount_type === 'percentage') {
return `
${parseInt(discount_value)}% OFF
`
}
if (discount_type === 'free_shipping') {
return `
FREE SHIPPING
`
}
return '';
}()}
${function(){
const {discount_type, prerequisite_value, prerequisite_type, obtain_product} = data.benefit?.reward.discount_code_activity || {};
if (discount_type === 'buy_x_get_y') {
const x = prerequisite_value;
const y = obtain_product.product_count;
const obtain_value = obtain_product.obtain_value;
if(obtain_product.obtain_type === 'free') {
if (prerequisite_type === 'quantity') {
return `Buy ${x} Get ${y} Free`;
} else if (prerequisite_type === 'subtotal') {
return `Buy Get ${y} Free`;
}
}
if(obtain_product.obtain_type === 'percentage') {
if (prerequisite_type === 'quantity') {
return `Buy ${x} , get ${y} at ${obtain_value}% OFF`;
} else if (prerequisite_type === 'subtotal') {
return `Buy , get ${y} at ${obtain_value}% OFF`;
}
}
if(obtain_product.obtain_type === 'fixed_amount') {
if (prerequisite_type === 'quantity') {
return `Buy ${x} get ${y} with off each`;
} else if (prerequisite_type === 'subtotal') {
return `Buy get ${y} with off each`;
}
}
}
return '';
}()}
${function(){
const { prerequisite_type, prerequisite_value, discount_type, obtain_product, max_free_shipping } = data.benefit?.reward.discount_code_activity || {};
if (prerequisite_type === 'none' && discount_type === 'free_shipping' && max_free_shipping !== -1) {
return `Up to , no threshold`;
}
if (prerequisite_type === 'quantity' && discount_type === 'free_shipping' && max_free_shipping !== -1) {
return `Up to , the order is available when it contains at least ${parseInt(prerequisite_value)} items`;
}
if (prerequisite_type === 'subtotal' && discount_type === 'free_shipping' && max_free_shipping !== -1) {
return `Up to , available when the order amount exceeds `;
}
if (prerequisite_type === 'none') {
return `No threshold`;
}
if (prerequisite_type === 'quantity') {
return `The order is available when it contains at least ${parseInt(prerequisite_value)} items`;
}
if (prerequisite_type === 'subtotal') {
return `Available when the order amount exceeds `;
}
return '';
}()}
${function(){
if (data.discount_code?.available_times === -1) {
return `Available`;
} else if (data.discount_code?.available_times > 0) {
return `Can be used ${data.discount_code?.available_times} times`;
}
return 'Exhausted';
}()}
`;
}
return '';
}()}
${function(){
const {execution_schedule, trigger_type} = data.benefit.benefit_config;
const { type, date } = execution_schedule || {};
if (data.benefit.type === 'point') {
if (trigger_type === 'onetime') {
return `After you successfully purchase the benefit package, it will be immediately issued to your account.`;
} else if (trigger_type === 'periodic') {
if (type === 'monthly') {
return `After successfully purchasing the benefit package, it will be automatically issued to your account every month.`;
} else if (type === 'weekly') {
return `After you successfully purchase the benefit package, it will be automatically issued to your account every week.`;
} else if (type === 'cycle') {
return `After you successfully purchase the benefit package, it will be automatically issued to your account every ${execution_schedule.days[0]} days.`;
}
} else if (type === 'specific_date') {
return `The benefit will be issued to your account on ${ date } every year.`;
}
} else {
if (trigger_type === 'onetime') {
return `After you successfully purchase the benefit package, it will be immediately issued to your account.`;
} else if (trigger_type === 'periodic') {
if (type === 'monthly') {
return `After you successfully purchase the benefit package, the discount code will be automatically refreshed monthly.`;
} else if (type === 'weekly') {
return `After you successfully purchase the benefit package, the discount code will be automatically refreshed weekly.`;
} else if (type === 'cycle') {
return `After you successfully purchase the benefit package, it will be automatically issued to your account every ${execution_schedule.days[0]} days.`;
}
} else if (type === 'specific_date') {
return `The benefit will be issued to your account on ${ date } every year.`;
}
}
}()}
${data.discount_code?.discount_code}
Copy
${function(){
const {execution_schedule, trigger_type} = data.benefit.benefit_config;
const { type, date } = execution_schedule || {};
if (data.benefit.type === 'point') {
if (trigger_type === 'periodic') {
if (type === 'monthly') {
if (data.had_reward) {
return `The benefit of the month has been issued to your account. The next issuance will occur in
`;
} else {
return `Next refresh time:
`;
}
} else if (type === 'weekly') {
if (data.had_reward) {
return `The benefit of the week has been issued to your account. The next issuance will occur in
`;
} else {
return `Next refresh time:
`;
}
}
}
if (trigger_type === 'onetime') {
if (data.had_reward) {
return `The benefit has been issued to your account.`;
} else {
return `Next refresh time:
`;
}
}
if (data.had_reward) {
return `The benefit has been issued to your account. The next issuance will occur in
`;
} else {
return `Next refresh time:
`;
}
} else {
return `Next refresh time:
`;
}
}()}