feat: 积分商城-供应商-对账-发票2
This commit is contained in:
@@ -12,11 +12,49 @@ type BridgePointsResponse = {
|
||||
}
|
||||
|
||||
export const supplierService = {
|
||||
decryptSupplierSession(keyword: string) {
|
||||
async decryptSupplierSession(keyword: string) {
|
||||
if (!keyword) {
|
||||
return serviceFail('用户参数不能为空')
|
||||
}
|
||||
|
||||
if (/^[a-f0-9]{32}$/i.test(keyword)) {
|
||||
const apiBase = getBridgeApiBase()
|
||||
if (!apiBase) {
|
||||
return serviceFail('平台积分商城接口地址未配置', 502, 'BRIDGE_SESSION_FAILED')
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await fetch(`${apiBase}/connect/supplier-session`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({ keyword })
|
||||
})
|
||||
const payload = (await response.json()) as {
|
||||
code?: number
|
||||
msg?: string
|
||||
data?: { userId?: unknown }
|
||||
}
|
||||
|
||||
if (!response.ok || payload.code !== 0) {
|
||||
return serviceFail(payload.msg || '获取用户会话失败')
|
||||
}
|
||||
|
||||
const userId = String(payload.data?.userId || '').trim()
|
||||
if (!userId) {
|
||||
return serviceFail('用户参数无效')
|
||||
}
|
||||
|
||||
return serviceOk({ userId })
|
||||
} catch (error) {
|
||||
logger.warn('supplier session exchange failed', {
|
||||
message: error instanceof Error ? error.message : String(error)
|
||||
})
|
||||
return serviceFail('获取用户会话失败', 502, 'BRIDGE_SESSION_FAILED')
|
||||
}
|
||||
}
|
||||
|
||||
const keyHex = process.env.SM4CBC_KEY_HEX || 'a1b2c3d4e5f60718293a4b5c6d7e8f90'
|
||||
const ivHex = process.env.SM4CBC_IV_HEX || 'f9e8d7c6b5a49382716f0e1d2c3b4a5f'
|
||||
const sessionKeyword = keyword.replace(/ /g, '+')
|
||||
|
||||
Reference in New Issue
Block a user