|
@@ -40,43 +40,40 @@ export class CustomerService extends BaseService {
|
|
message: '不支持的类型',
|
|
message: '不支持的类型',
|
|
};
|
|
};
|
|
}
|
|
}
|
|
|
|
+ // 白标用户
|
|
const customer = await this.customerEntity.findOne({
|
|
const customer = await this.customerEntity.findOne({
|
|
where: {
|
|
where: {
|
|
customer_id: data.customer_id,
|
|
customer_id: data.customer_id,
|
|
- merchantId: data.out_user_id,
|
|
|
|
},
|
|
},
|
|
});
|
|
});
|
|
|
|
+ const isWhiteLabel = customer?.out_user_id.length > 0;
|
|
if (!customer) {
|
|
if (!customer) {
|
|
- // 获取商户的回调
|
|
|
|
- await this.request(customer.webhook_url, {
|
|
|
|
- biz_status: 'FAIL',
|
|
|
|
- biz_type: 'CREATECUSTOMER',
|
|
|
|
- data: data
|
|
|
|
- })
|
|
|
|
return {
|
|
return {
|
|
is_success: false,
|
|
is_success: false,
|
|
message: '客户不存在',
|
|
message: '客户不存在',
|
|
};
|
|
};
|
|
}
|
|
}
|
|
if (customer.status == 'SUCCESS') {
|
|
if (customer.status == 'SUCCESS') {
|
|
- // 获取商户的回调
|
|
|
|
- await this.request(customer.webhook_url, {
|
|
|
|
- biz_status: 'SUCCESS',
|
|
|
|
- biz_type: 'CREATECUSTOMER',
|
|
|
|
- data: data
|
|
|
|
- })
|
|
|
|
|
|
+ if(isWhiteLabel) {
|
|
|
|
+ // 获取商户的回调
|
|
|
|
+ await this.request(customer?.webhook_url, {
|
|
|
|
+ biz_status: 'SUCCESS',
|
|
|
|
+ biz_type: 'CREATECUSTOMER',
|
|
|
|
+ data: data
|
|
|
|
+ })
|
|
|
|
+ }
|
|
return {
|
|
return {
|
|
is_success: true,
|
|
is_success: true,
|
|
message: '成功',
|
|
message: '成功',
|
|
};
|
|
};
|
|
}
|
|
}
|
|
|
|
+
|
|
const status = biz_status === 'FAIL' ? -1 : 1;
|
|
const status = biz_status === 'FAIL' ? -1 : 1;
|
|
- customer.status = biz_status;
|
|
|
|
|
|
+ customer.status = biz_status;
|
|
|
|
+ // 平台用户
|
|
const business = await this.businessEntity.findOne({
|
|
const business = await this.businessEntity.findOne({
|
|
where: {
|
|
where: {
|
|
- merchant: {
|
|
|
|
- id: data.out_user_id,
|
|
|
|
- },
|
|
|
|
|
|
+ customer_id: data.customer_id,
|
|
},
|
|
},
|
|
});
|
|
});
|
|
if (business) {
|
|
if (business) {
|
|
@@ -90,9 +87,7 @@ export class CustomerService extends BaseService {
|
|
} else {
|
|
} else {
|
|
const individual = await this.individualEntity.findOne({
|
|
const individual = await this.individualEntity.findOne({
|
|
where: {
|
|
where: {
|
|
- merchant: {
|
|
|
|
- id: data.out_user_id,
|
|
|
|
- },
|
|
|
|
|
|
+ customer_id: data.customer_id
|
|
},
|
|
},
|
|
});
|
|
});
|
|
if (individual) {
|
|
if (individual) {
|
|
@@ -106,12 +101,16 @@ export class CustomerService extends BaseService {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
await this.customerEntity.save(customer);
|
|
await this.customerEntity.save(customer);
|
|
- // 获取商户的回调
|
|
|
|
- await this.request(customer.webhook_url, {
|
|
|
|
- biz_status: 'SUCCESS',
|
|
|
|
- biz_type: 'CREATECUSTOMER',
|
|
|
|
- data: data
|
|
|
|
- })
|
|
|
|
|
|
+ // 白标用户
|
|
|
|
+ if(isWhiteLabel) {
|
|
|
|
+ // 通知商户的回调
|
|
|
|
+ const whiteRes = await this.request(customer?.webhook_url, {
|
|
|
|
+ biz_status: biz_status,
|
|
|
|
+ biz_type: 'CREATECUSTOMER',
|
|
|
|
+ data: data
|
|
|
|
+ })
|
|
|
|
+ // return whiteRes TODO Max 白标用户的回调是否通知到上游
|
|
|
|
+ }
|
|
return {
|
|
return {
|
|
is_success: true,
|
|
is_success: true,
|
|
message: '成功',
|
|
message: '成功',
|