|
@@ -25,14 +25,15 @@ export class ZeroOneChannelHandler implements ChannelHandler {
|
|
|
const data = ctx.request.body as any;
|
|
const data = ctx.request.body as any;
|
|
|
const {token, uid, channel_code, product_code} = data || {};
|
|
const {token, uid, channel_code, product_code} = data || {};
|
|
|
const finalProductCode = product_code || config.loginConfig?.productCode;
|
|
const finalProductCode = product_code || config.loginConfig?.productCode;
|
|
|
|
|
+ const tag = `[渠道${config.channelId}]`;
|
|
|
|
|
|
|
|
if (!token || !uid) {
|
|
if (!token || !uid) {
|
|
|
- logger.warn("0.1渠道登录验证失败: 缺少必要参数", {token, uid});
|
|
|
|
|
|
|
+ logger.warn(`${tag}登录验证失败: 缺少必要参数`, {token, uid});
|
|
|
return {code: 0, msg: "缺少必要参数 token 或 uid"};
|
|
return {code: 0, msg: "缺少必要参数 token 或 uid"};
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (!finalProductCode) {
|
|
if (!finalProductCode) {
|
|
|
- logger.error("0.1渠道登录验证失败: 未配置productCode");
|
|
|
|
|
|
|
+ logger.error(`${tag}登录验证失败: 未配置productCode`);
|
|
|
return {code: 0, msg: "服务器未配置productCode"};
|
|
return {code: 0, msg: "服务器未配置productCode"};
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -46,20 +47,20 @@ export class ZeroOneChannelHandler implements ChannelHandler {
|
|
|
params.channel_code = channel_code;
|
|
params.channel_code = channel_code;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- logger.info("0.1渠道登录验证请求", {url: requestUrl, params});
|
|
|
|
|
|
|
+ logger.info(`${tag}登录验证请求`, {url: requestUrl, params});
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
const response = await axios.get(requestUrl, {params, timeout: 8000});
|
|
const response = await axios.get(requestUrl, {params, timeout: 8000});
|
|
|
- logger.info("0.1渠道登录验证响应", {data: response.data});
|
|
|
|
|
|
|
+ logger.info(`${tag}登录验证响应`, {data: response.data});
|
|
|
|
|
|
|
|
if (response.data == "1") {
|
|
if (response.data == "1") {
|
|
|
return {code: 1, msg: "success"};
|
|
return {code: 1, msg: "success"};
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- logger.warn("0.1渠道登录验证失败: 接口返回非1", {data: response.data});
|
|
|
|
|
|
|
+ logger.warn(`${tag}登录验证失败: 接口返回非1`, {data: response.data});
|
|
|
return {code: 0, msg: "登录验证失败"};
|
|
return {code: 0, msg: "登录验证失败"};
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
|
- logger.error("0.1渠道登录验证异常", error);
|
|
|
|
|
|
|
+ logger.error(`${tag}登录验证异常`, error);
|
|
|
return {code: 0, msg: "登录验证异常"};
|
|
return {code: 0, msg: "登录验证异常"};
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -71,11 +72,12 @@ export class ZeroOneChannelHandler implements ChannelHandler {
|
|
|
*/
|
|
*/
|
|
|
async handlePayment(ctx: Context, config: ChannelConfig): Promise<PaymentResult> {
|
|
async handlePayment(ctx: Context, config: ChannelConfig): Promise<PaymentResult> {
|
|
|
const data = ctx.request.body as any;
|
|
const data = ctx.request.body as any;
|
|
|
- logger.info("0.1渠道支付回调参数", {url: ctx.href, params: data});
|
|
|
|
|
|
|
+ const tag = `[渠道${config.channelId}]`;
|
|
|
|
|
+ logger.info(`${tag}支付回调参数`, {url: ctx.href, params: data});
|
|
|
|
|
|
|
|
const {nt_data, sign, md5Sign} = data || {};
|
|
const {nt_data, sign, md5Sign} = data || {};
|
|
|
if (!nt_data || !sign || !md5Sign) {
|
|
if (!nt_data || !sign || !md5Sign) {
|
|
|
- logger.warn("0.1渠道支付回调失败: 缺少必要参数", {nt_data, sign, md5Sign});
|
|
|
|
|
|
|
+ logger.warn(`${tag}支付回调失败: 缺少必要参数`, {nt_data, sign, md5Sign});
|
|
|
return {code: 0, msg: "缺少必要参数"};
|
|
return {code: 0, msg: "缺少必要参数"};
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -83,12 +85,12 @@ export class ZeroOneChannelHandler implements ChannelHandler {
|
|
|
const callbackKey = config.paymentConfig?.callbackKey;
|
|
const callbackKey = config.paymentConfig?.callbackKey;
|
|
|
|
|
|
|
|
if (!md5Key || !callbackKey) {
|
|
if (!md5Key || !callbackKey) {
|
|
|
- logger.error("0.1渠道支付回调失败: 未配置QuickSDK密钥");
|
|
|
|
|
|
|
+ logger.error(`${tag}支付回调失败: 未配置QuickSDK密钥`);
|
|
|
return {code: 0, msg: "服务器未配置渠道密钥"};
|
|
return {code: 0, msg: "服务器未配置渠道密钥"};
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (!SignatureVerifier.verifyQuickSign(data, md5Key)) {
|
|
if (!SignatureVerifier.verifyQuickSign(data, md5Key)) {
|
|
|
- logger.warn("0.1渠道支付回调失败: 签名验证失败");
|
|
|
|
|
|
|
+ logger.warn(`${tag}支付回调失败: 签名验证失败`);
|
|
|
return {code: 0, msg: "签名验证失败"};
|
|
return {code: 0, msg: "签名验证失败"};
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -103,12 +105,12 @@ export class ZeroOneChannelHandler implements ChannelHandler {
|
|
|
const amountStr = message.amount?.[0];
|
|
const amountStr = message.amount?.[0];
|
|
|
|
|
|
|
|
if (!orderId || !outTradeNo || typeof status === "undefined" || !amountStr) {
|
|
if (!orderId || !outTradeNo || typeof status === "undefined" || !amountStr) {
|
|
|
- logger.error("0.1渠道支付回调失败: XML缺少必要字段", {message});
|
|
|
|
|
|
|
+ logger.error(`${tag}支付回调失败: XML缺少必要字段`, {message});
|
|
|
return {code: 0, msg: "回调数据不完整"};
|
|
return {code: 0, msg: "回调数据不完整"};
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (status !== "0") {
|
|
if (status !== "0") {
|
|
|
- logger.warn("0.1渠道支付状态非成功", {status});
|
|
|
|
|
|
|
+ logger.warn(`${tag}支付状态非成功`, {status});
|
|
|
return {code: 0, msg: "支付状态失败"};
|
|
return {code: 0, msg: "支付状态失败"};
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -124,7 +126,7 @@ export class ZeroOneChannelHandler implements ChannelHandler {
|
|
|
|
|
|
|
|
const orderInfo = validation.orderInfo;
|
|
const orderInfo = validation.orderInfo;
|
|
|
if (Number(orderInfo.amount) !== amount) {
|
|
if (Number(orderInfo.amount) !== amount) {
|
|
|
- logger.warn("0.1渠道支付金额不匹配", {
|
|
|
|
|
|
|
+ logger.warn(`${tag}支付金额不匹配`, {
|
|
|
orderId,
|
|
orderId,
|
|
|
requestAmount: amount,
|
|
requestAmount: amount,
|
|
|
orderAmount: orderInfo.amount
|
|
orderAmount: orderInfo.amount
|
|
@@ -132,17 +134,17 @@ export class ZeroOneChannelHandler implements ChannelHandler {
|
|
|
return {code: 0, msg: "订单金额不一致"};
|
|
return {code: 0, msg: "订单金额不一致"};
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- logger.info(`0.1渠道支付订单${orderId}开始发货`);
|
|
|
|
|
|
|
+ logger.info(`${tag}支付订单${orderId}开始发货`);
|
|
|
const result = await PaymentHelper.deliverOrder(
|
|
const result = await PaymentHelper.deliverOrder(
|
|
|
orderInfo,
|
|
orderInfo,
|
|
|
ctx.request.ip,
|
|
ctx.request.ip,
|
|
|
validation.url,
|
|
validation.url,
|
|
|
outTradeNo
|
|
outTradeNo
|
|
|
);
|
|
);
|
|
|
- logger.info(`0.1渠道支付订单${orderId}发货完成`, {result});
|
|
|
|
|
|
|
+ logger.info(`${tag}支付订单${orderId}发货完成`, {result});
|
|
|
return result;
|
|
return result;
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
|
- logger.error("0.1渠道支付回调解析异常", error);
|
|
|
|
|
|
|
+ logger.error(`${tag}支付回调解析异常`, error);
|
|
|
return {code: 0, msg: "回调解析异常"};
|
|
return {code: 0, msg: "回调解析异常"};
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|