|
@@ -6,6 +6,7 @@ import { BaseService } from '@cool-midway/core';
|
|
|
import { InjectEntityModel } from '@midwayjs/typeorm';
|
|
|
import { Repository } from 'typeorm';
|
|
|
import { PaymentService } from './payment';
|
|
|
+import {MerchantEntity} from "../entity/merchant";
|
|
|
@Provide()
|
|
|
export class IndividualService extends BaseService {
|
|
|
@InjectEntityModel(IndividualEntity)
|
|
@@ -17,6 +18,9 @@ export class IndividualService extends BaseService {
|
|
|
ctx;
|
|
|
@InjectEntityModel(CustomerEntity)
|
|
|
customerEntity: Repository<CustomerEntity>;
|
|
|
+
|
|
|
+ @InjectEntityModel(MerchantEntity)
|
|
|
+ merchantEntity: Repository<MerchantEntity>;
|
|
|
@Config(ALL)
|
|
|
config;
|
|
|
@Init()
|
|
@@ -32,7 +36,7 @@ export class IndividualService extends BaseService {
|
|
|
* @returns
|
|
|
*/
|
|
|
async add(param) {
|
|
|
- let merchantId = this.getMerchantId(param);
|
|
|
+ let merchantId = await this.getMerchantId(param);
|
|
|
const custom = {
|
|
|
...param,
|
|
|
out_user_id: merchantId,
|
|
@@ -42,12 +46,11 @@ export class IndividualService extends BaseService {
|
|
|
let res = await this.paymentService
|
|
|
.setChannel('SUNPAY')
|
|
|
.setCustomerInfo(custom);
|
|
|
- param.merchant = {
|
|
|
- id: merchantId,
|
|
|
- };
|
|
|
+ param.merchantId = merchantId
|
|
|
await super.add({
|
|
|
...param,
|
|
|
...param.company,
|
|
|
+ customer_id: res.data.customer_id,
|
|
|
});
|
|
|
return res;
|
|
|
}
|
|
@@ -69,13 +72,18 @@ export class IndividualService extends BaseService {
|
|
|
this._isOpenApi = payload
|
|
|
}
|
|
|
|
|
|
- getMerchantId(params) {
|
|
|
+ async getMerchantId(params) {
|
|
|
let merchantId;
|
|
|
if (this._isOpenApi) {
|
|
|
merchantId = params.out_user_id;
|
|
|
+ } else if (params?.mch_id || params?.mchId) {
|
|
|
+ // const merchantInfo = await this.merchantEntity.findOneBy({
|
|
|
+ // mchId: params?.mch_id
|
|
|
+ // })
|
|
|
+ merchantId = params?.mch_id || params?.mchId
|
|
|
} else {
|
|
|
const { merchant } = this.ctx.admin;
|
|
|
- merchantId = merchant.id;
|
|
|
+ merchantId = merchant.mchId;
|
|
|
}
|
|
|
return merchantId
|
|
|
}
|