|
@@ -8,7 +8,8 @@ import {CustomerEntity} from '../../../payment/entity/customer';
|
|
|
import {PaymentService} from '../../../payment/service/payment';
|
|
|
import {SunPayAdapter} from '../../../payment/adapter/sunpay.adapter';
|
|
|
import {OpenPaymentAccountEntity} from '../../entity/open_payment_account';
|
|
|
-import {OpenAccountEntity} from "../../entity/open_account";
|
|
|
+import {OpenAccountEntity} from '../../entity/open_account';
|
|
|
+import {EasyPayAdapter} from '../../../payment/adapter/easypay.adapter';
|
|
|
|
|
|
/**
|
|
|
* 描述
|
|
@@ -34,10 +35,12 @@ export class accountsService extends BaseService {
|
|
|
@InjectEntityModel(OpenPaymentAccountEntity)
|
|
|
openPaymentAccountEntity: Repository<OpenPaymentAccountEntity>;
|
|
|
|
|
|
-
|
|
|
@InjectEntityModel(OpenAccountEntity)
|
|
|
openAccountEntity: Repository<OpenAccountEntity>;
|
|
|
|
|
|
+ @Inject()
|
|
|
+ easyPayAdapter: EasyPayAdapter;
|
|
|
+
|
|
|
async addAccounts(params, res) {
|
|
|
// openPaymentAccountEntity.
|
|
|
const openUserObj = {
|
|
@@ -48,8 +51,30 @@ export class accountsService extends BaseService {
|
|
|
status: res.data.status || '',
|
|
|
source: 'EASYPAY',
|
|
|
};
|
|
|
- this.ctx.logger.info(`添加va账户,${JSON.stringify(openUserObj)}`)
|
|
|
+ this.ctx.logger.info(`添加va账户,${JSON.stringify(openUserObj)}`);
|
|
|
delete openUserObj.id;
|
|
|
return await this.openAccountEntity.insert(openUserObj);
|
|
|
}
|
|
|
+
|
|
|
+ async getInfoByMchId(mchId) {
|
|
|
+ const res = await this.openAccountEntity.findOne({
|
|
|
+ where: {
|
|
|
+ mch_id: mchId,
|
|
|
+ },
|
|
|
+ });
|
|
|
+ let account_info = {};
|
|
|
+ // 如果已经申请过的话,请求渠道的详情数据
|
|
|
+ if (res?.account_id && res.status !== 'ACTIVE') {
|
|
|
+ account_info = await this.easyPayAdapter.request(
|
|
|
+ 'GET',
|
|
|
+ `/v3/accounts/${res?.account_id}`
|
|
|
+ );
|
|
|
+ }
|
|
|
+ console.log(6262626262, res);
|
|
|
+ console.log(6262626262, account_info);
|
|
|
+ return {
|
|
|
+ ...res,
|
|
|
+ account_info,
|
|
|
+ };
|
|
|
+ }
|
|
|
}
|