feat: 强化出库上链一致性(确认中即已上链/出库时间必填/上链须先出库)
This commit is contained in:
@@ -5,6 +5,7 @@ import { ErrorCode, ProofStatus, QUEUE_NAMES } from '@artveris/shared';
|
||||
import { PrismaService } from '../prisma/prisma.service';
|
||||
import { BusinessException } from '../common/exceptions/business.exception';
|
||||
import { StorageService } from '../storage/storage.service';
|
||||
import { isOutbound } from '../outbound/outbound.util';
|
||||
import { BlockchainService } from './blockchain.service';
|
||||
|
||||
@Injectable()
|
||||
@@ -36,6 +37,10 @@ export class AttestationService {
|
||||
if (!code.artworkId || !code.artwork) {
|
||||
throw new BusinessException(ErrorCode.BAD_REQUEST, '追溯码未绑定作品,无法上链');
|
||||
}
|
||||
// 上链代表已登记出库:未出库不允许上链(杜绝「已上链未登记」的不一致状态)
|
||||
if (!isOutbound(code)) {
|
||||
throw new BusinessException(ErrorCode.BAD_REQUEST, '该追溯码尚未登记出库,请先登记出库再上链');
|
||||
}
|
||||
|
||||
// 防重复上链:已存在「上链成功/上链中/待上链」的存证则拒绝;仅失败(FAILED)的可再次发起。
|
||||
const active = await this.prisma.blockchainProof.findFirst({
|
||||
|
||||
Reference in New Issue
Block a user