新增 affiliate_dash 履约配置与商品映射(阶段 3)
- bootstrap CORE_PROFILES + routing ROUTABLE/DEFAULT_PRIORITY 接入 affiliate_dash - planner 上下文 affiliateDash 块 + resolveDynamicAffiliateDashProfile - product-resolution: 91 productNo→sku 映射匹配(skuMapping) + snapshot.affiliateDash - prepare 前余额预检(getAffiliateDashWallet) - AFFILIATE_DASH_SKU_MAPPING_JSON env 注入 - admin 后端接口(GET/POST 配置、match、products、wallet)+ 前端 Tabs 面板 - 联调:模拟 91 进单命中 affiliate_dash 路由, 未命中回退;前后端 typecheck + 212 测试通过
This commit is contained in:
@@ -3,6 +3,7 @@ import type { JsonObject } from '../../types/json.js'
|
||||
import type { OrderItemRow, OrderRow } from '../../types/repository/rows.js'
|
||||
import {
|
||||
FULFILLMENT_EXECUTOR_KEYS,
|
||||
isAffiliateDashExecutor,
|
||||
isKuaishouCloudExecutor,
|
||||
isKuaishouFeifeiExecutor,
|
||||
} from './executors/types.js'
|
||||
@@ -98,6 +99,7 @@ function buildFulfillmentTaskContext({
|
||||
const itemSnapshot = parseJsonObject(item.item_snapshot_json)
|
||||
const cloudtentaclesConfig = parseJsonObject(fulfillmentConfig.cloudtentacles)
|
||||
const kuaishouFeifeiConfig = parseJsonObject(fulfillmentConfig.kuaishouFeifei)
|
||||
const affiliateDashConfig = parseJsonObject(fulfillmentConfig.affiliateDash)
|
||||
const kuaishouConsumeConfig = parseJsonObject(fulfillmentConfig.kuaishouConsume)
|
||||
const kuaishouShopConfig = parseJsonObject(fulfillmentConfig.kuaishouShop)
|
||||
const cloudSourceKeys = normalizeStringArray(cloudtentaclesConfig.cloudSourceKeys)
|
||||
@@ -223,6 +225,33 @@ function buildFulfillmentTaskContext({
|
||||
lastSyncedAt: null,
|
||||
}
|
||||
: null,
|
||||
affiliateDash: isAffiliateDashExecutor(executorKey)
|
||||
? {
|
||||
flowType: 'affiliate_dash',
|
||||
sku: String(affiliateDashConfig.sku || '').trim(),
|
||||
productName: String(
|
||||
affiliateDashConfig.productName || item.sku_name || '',
|
||||
).trim(),
|
||||
orderNo: '',
|
||||
clientOrderNo: '',
|
||||
orderStatus: '',
|
||||
canShip: false,
|
||||
cannotShipReason: '',
|
||||
providerOrderNo: '',
|
||||
failureReason: '',
|
||||
amount: 0,
|
||||
currency: '',
|
||||
bindUuid: '',
|
||||
bindUrl: '',
|
||||
qrUrl: '',
|
||||
gameAccount: '',
|
||||
expectedGameAccount: '',
|
||||
bindMismatch: false,
|
||||
submitStatus: '',
|
||||
consumeStatus: 'pending',
|
||||
lastSyncedAt: null,
|
||||
}
|
||||
: null,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -240,6 +269,10 @@ async function resolveDynamicFulfillmentProfile(
|
||||
return resolveDynamicKuaishouFeifeiProfile(item, getProfileByKey)
|
||||
}
|
||||
|
||||
if (selectedExecutorKey === FULFILLMENT_EXECUTOR_KEYS.AFFILIATE_DASH) {
|
||||
return resolveDynamicAffiliateDashProfile(item, getProfileByKey)
|
||||
}
|
||||
|
||||
if (selectedExecutorKey === FULFILLMENT_EXECUTOR_KEYS.MANUAL_DISPATCH) {
|
||||
return resolveDynamicManualDispatchProfile(item, getProfileByKey)
|
||||
}
|
||||
@@ -247,7 +280,8 @@ async function resolveDynamicFulfillmentProfile(
|
||||
|
||||
return (
|
||||
await resolveDynamicCloudtentaclesProfile(item, getProfileByKey) ||
|
||||
await resolveDynamicKuaishouFeifeiProfile(item, getProfileByKey)
|
||||
await resolveDynamicKuaishouFeifeiProfile(item, getProfileByKey) ||
|
||||
await resolveDynamicAffiliateDashProfile(item, getProfileByKey)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -357,6 +391,45 @@ async function resolveDynamicKuaishouFeifeiProfile(
|
||||
}
|
||||
}
|
||||
|
||||
async function resolveDynamicAffiliateDashProfile(
|
||||
item: OrderItemRow,
|
||||
getProfileByKey: FulfillmentProfileResolver,
|
||||
): Promise<FulfillmentBindingLike | null> {
|
||||
const snapshot = parseJsonObject(item.item_snapshot_json)
|
||||
const affiliateDash = parseJsonObject(snapshot.affiliateDash)
|
||||
const sku = String(affiliateDash.sku || '').trim()
|
||||
if (!sku) {
|
||||
return null
|
||||
}
|
||||
|
||||
const profile = await getProfileByKey(FULFILLMENT_EXECUTOR_KEYS.AFFILIATE_DASH)
|
||||
if (!profile) {
|
||||
return null
|
||||
}
|
||||
|
||||
return {
|
||||
...profile,
|
||||
profile_id: Number(profile.id || profile.profile_id || 0),
|
||||
profile_key: FULFILLMENT_EXECUTOR_KEYS.AFFILIATE_DASH,
|
||||
profile_name: String(profile.profile_name || profile.name || 'affiliate-dash 履约').trim(),
|
||||
executor_key: FULFILLMENT_EXECUTOR_KEYS.AFFILIATE_DASH,
|
||||
requires_claim: true,
|
||||
auto_dispatch: false,
|
||||
config_json: {
|
||||
flowType: 'affiliate_dash',
|
||||
configId: `affiliate_dash:${sku}`,
|
||||
affiliateDash: {
|
||||
sku,
|
||||
productName: String(
|
||||
affiliateDash.skuName || affiliateDash.productName || item.sku_name || '',
|
||||
).trim(),
|
||||
matchMode: String(affiliateDash.matchMode || 'affiliate_dash_sku_mapping').trim(),
|
||||
},
|
||||
notes: '91卡券商品自动匹配 affiliate-dash sku 映射',
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
async function resolveDynamicManualDispatchProfile(
|
||||
item: OrderItemRow,
|
||||
getProfileByKey: FulfillmentProfileResolver,
|
||||
|
||||
Reference in New Issue
Block a user