feat: 套餐购买支持易支付、支付宝支付

This commit is contained in:
xiaojunnuo
2024-12-23 00:24:31 +08:00
parent 9c8c7a7812
commit faa28f88f9
69 changed files with 1073 additions and 407 deletions
@@ -1,4 +1,5 @@
import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm';
import { PipelineEntity } from '../../pipeline/entity/pipeline.js';
@Entity('cd_cert_info')
export class CertInfoEntity {
@@ -51,4 +52,6 @@ export class CertInfoEntity {
default: () => 'CURRENT_TIMESTAMP',
})
updateTime: Date;
pipeline?: PipelineEntity;
}
@@ -0,0 +1,5 @@
export * from "./entity/site-info.js";
export * from "./entity/cert-info.js";
export * from "./service/cert-info-service.js";
export * from "./service/site-info-service.js";
@@ -1,5 +1,5 @@
import { Provide } from '@midwayjs/core';
import { BaseService } from '@certd/lib-server';
import { BaseService, PageReq } from '@certd/lib-server';
import { InjectEntityModel } from '@midwayjs/typeorm';
import { Repository } from 'typeorm';
import { CertInfoEntity } from '../entity/cert-info.js';
@@ -14,6 +14,10 @@ export class CertInfoService extends BaseService<CertInfoEntity> {
return this.repository;
}
async page(pageReq: PageReq<CertInfoEntity>) {
return await super.page(pageReq);
}
async getUserDomainCount(userId: number) {
if (!userId) {
throw new Error('userId is required');
@@ -23,10 +27,11 @@ export class CertInfoService extends BaseService<CertInfoEntity> {
});
}
async updateDomains(pipelineId: number, domains: string[]) {
async updateDomains(pipelineId: number, userId: number, domains: string[]) {
const found = await this.repository.findOne({
where: {
pipelineId,
userId,
},
});
const bean = new CertInfoEntity();
@@ -36,11 +41,21 @@ export class CertInfoService extends BaseService<CertInfoEntity> {
} else {
//create
bean.pipelineId = pipelineId;
bean.userId = userId;
if (!domains || domains.length === 0) {
return;
}
}
bean.domain = domains[0];
bean.domains = domains.join(',');
bean.domainCount = domains.length;
if (!domains || domains.length === 0) {
bean.domain = '';
bean.domains = '';
bean.domainCount = 0;
} else {
bean.domain = domains[0];
bean.domains = domains.join(',');
bean.domainCount = domains.length;
}
await this.addOrUpdate(bean);
}