@chevre/domain 21.32.0-alpha.8 → 21.32.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/example/src/chevre/findCheckAction.ts +37 -0
- package/example/src/chevre/investigateCheckMovieTicketActions.ts +60 -0
- package/example/src/chevre/searchCheckMovieTicketResultYkknInfo.ts +36 -0
- package/example/src/chevre/transaction/acceptCOAOffer.ts +78 -0
- package/example/src/chevre/transaction/processPlaceOrder.ts +1 -0
- package/example/src/chevre/unsetUnnecessaryFields.ts +11 -5
- package/lib/chevre/errorHandler.d.ts +4 -0
- package/lib/chevre/errorHandler.js +33 -1
- package/lib/chevre/repo/action.d.ts +50 -7
- package/lib/chevre/repo/action.js +111 -11
- package/lib/chevre/repo/aggregation.d.ts +4 -0
- package/lib/chevre/repo/aggregation.js +6 -0
- package/lib/chevre/repo/confirmationNumber.d.ts +1 -1
- package/lib/chevre/repo/confirmationNumber.js +7 -7
- package/lib/chevre/repo/mongoose/schemas/action.js +2 -1
- package/lib/chevre/repo/mongoose/schemas/aggregation.js +3 -14
- package/lib/chevre/repo/mongoose/schemas/task.js +2 -12
- package/lib/chevre/repo/task.d.ts +4 -0
- package/lib/chevre/repo/task.js +6 -0
- package/lib/chevre/repository.d.ts +1 -1
- package/lib/chevre/repository.js +1 -1
- package/lib/chevre/service/assetTransaction/pay.d.ts +14 -2
- package/lib/chevre/service/assetTransaction/pay.js +10 -6
- package/lib/chevre/service/code.d.ts +1 -1
- package/lib/chevre/service/offer/event/authorize.d.ts +1 -3
- package/lib/chevre/service/offer/event/authorize.js +7 -7
- package/lib/chevre/service/offer/event/voidTransaction/processVoidTransaction4chevre.d.ts +24 -0
- package/lib/chevre/service/offer/event/voidTransaction/processVoidTransaction4chevre.js +35 -0
- package/lib/chevre/service/offer/event/voidTransaction/processVoidTransaction4coa.d.ts +9 -0
- package/lib/chevre/service/offer/event/voidTransaction/processVoidTransaction4coa.js +130 -0
- package/lib/chevre/service/offer/event/voidTransaction.d.ts +10 -3
- package/lib/chevre/service/offer/event/voidTransaction.js +77 -92
- package/lib/chevre/service/offer/event/{cancel.d.ts → voidTransactionByActionId.d.ts} +8 -22
- package/lib/chevre/service/offer/event/voidTransactionByActionId.js +85 -0
- package/lib/chevre/service/offer/event.d.ts +1 -2
- package/lib/chevre/service/offer/event.js +2 -3
- package/lib/chevre/service/offer/eventServiceByCOA/acceptOffer/authorize.d.ts +23 -0
- package/lib/chevre/service/offer/eventServiceByCOA/acceptOffer/authorize.js +258 -0
- package/lib/chevre/service/offer/eventServiceByCOA/acceptOffer/factory.d.ts +15 -0
- package/lib/chevre/service/offer/eventServiceByCOA/acceptOffer/factory.js +20 -0
- package/lib/chevre/service/offer/eventServiceByCOA/acceptOffer.d.ts +33 -0
- package/lib/chevre/service/offer/eventServiceByCOA/acceptOffer.js +182 -0
- package/lib/chevre/service/offer/eventServiceByCOA/authorize.d.ts +1 -3
- package/lib/chevre/service/offer/eventServiceByCOA/authorize.js +7 -7
- package/lib/chevre/service/offer/eventServiceByCOA/cancel.d.ts +3 -0
- package/lib/chevre/service/offer/eventServiceByCOA/cancel.js +5 -1
- package/lib/chevre/service/offer/eventServiceByCOA/changeOffers.d.ts +1 -3
- package/lib/chevre/service/offer/eventServiceByCOA/changeOffers.js +7 -7
- package/lib/chevre/service/offer/eventServiceByCOA/findAcceptAction.d.ts +41 -0
- package/lib/chevre/service/offer/eventServiceByCOA/findAcceptAction.js +66 -0
- package/lib/chevre/service/offer/eventServiceByCOA.d.ts +3 -1
- package/lib/chevre/service/offer/eventServiceByCOA.js +6 -1
- package/lib/chevre/service/payment/any.d.ts +55 -3
- package/lib/chevre/service/payment/any.js +99 -6
- package/lib/chevre/service/task/acceptCOAOffer.d.ts +6 -0
- package/lib/chevre/service/task/acceptCOAOffer.js +102 -0
- package/lib/chevre/service/task/authorizePayment.js +2 -0
- package/lib/chevre/service/task/publishPaymentUrl.d.ts +6 -0
- package/lib/chevre/service/task/publishPaymentUrl.js +70 -0
- package/lib/chevre/service/task/voidReserveTransaction.d.ts +2 -2
- package/lib/chevre/service/task/voidReserveTransaction.js +34 -13
- package/lib/chevre/service/task.js +3 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/confirm.d.ts +1 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/publishConfirmationNumberIfNotExist.d.ts +1 -1
- package/package.json +3 -3
- package/example/src/chevre/migrateAuthorizePaymentActions.ts +0 -75
- package/lib/chevre/service/offer/event/cancel.js +0 -57
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.
|
|
12
|
+
exports.ConfirmationNumberRepo = void 0;
|
|
13
13
|
const cdigit = require("cdigit");
|
|
14
14
|
const moment = require("moment-timezone");
|
|
15
15
|
const util = require("util");
|
|
@@ -20,7 +20,7 @@ const CONFIRMATION_NUMBER_MIN_LENGH = 4;
|
|
|
20
20
|
/**
|
|
21
21
|
* 確認番号リポジトリ
|
|
22
22
|
*/
|
|
23
|
-
class
|
|
23
|
+
class ConfirmationNumberRepo {
|
|
24
24
|
constructor(redisClient) {
|
|
25
25
|
this.redisClient = redisClient;
|
|
26
26
|
}
|
|
@@ -33,7 +33,7 @@ class RedisRepository {
|
|
|
33
33
|
return aligndNumber;
|
|
34
34
|
}
|
|
35
35
|
static createKey(params) {
|
|
36
|
-
return util.format('%s:%s',
|
|
36
|
+
return util.format('%s:%s', ConfirmationNumberRepo.REDIS_KEY_PREFIX_NEW, moment(params.orderDate)
|
|
37
37
|
.tz('Asia/Tokyo')
|
|
38
38
|
.format('YYMM'));
|
|
39
39
|
}
|
|
@@ -46,7 +46,7 @@ class RedisRepository {
|
|
|
46
46
|
const TTL = moment(params.orderDate)
|
|
47
47
|
.add(1, 'month')
|
|
48
48
|
.diff(moment(params.orderDate), 'seconds');
|
|
49
|
-
const key =
|
|
49
|
+
const key = ConfirmationNumberRepo.createKey({ orderDate: params.orderDate });
|
|
50
50
|
const [incrReply] = yield this.redisClient.multi()
|
|
51
51
|
.incr(key)
|
|
52
52
|
.expire(key, TTL)
|
|
@@ -58,7 +58,7 @@ class RedisRepository {
|
|
|
58
58
|
throw new factory.errors.ServiceUnavailable('confirmation number not incremented unexpectedly');
|
|
59
59
|
}
|
|
60
60
|
// 桁数調整
|
|
61
|
-
let confirmationNumber =
|
|
61
|
+
let confirmationNumber = ConfirmationNumberRepo.alignDigits(incrReply);
|
|
62
62
|
// checkdigit
|
|
63
63
|
const cd = cdigit.luhn.compute(confirmationNumber);
|
|
64
64
|
// debug('check digit:', cd);
|
|
@@ -69,5 +69,5 @@ class RedisRepository {
|
|
|
69
69
|
});
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
|
-
|
|
73
|
-
exports.
|
|
72
|
+
ConfirmationNumberRepo.REDIS_KEY_PREFIX_NEW = 'confirmationNumber';
|
|
73
|
+
exports.ConfirmationNumberRepo = ConfirmationNumberRepo;
|
|
@@ -27,7 +27,8 @@ const schemaDefinition = {
|
|
|
27
27
|
location: mongoose_1.SchemaTypes.Mixed,
|
|
28
28
|
replacer: mongoose_1.SchemaTypes.Mixed,
|
|
29
29
|
targetCollection: mongoose_1.SchemaTypes.Mixed,
|
|
30
|
-
sameAs: mongoose_1.SchemaTypes.Mixed
|
|
30
|
+
sameAs: mongoose_1.SchemaTypes.Mixed,
|
|
31
|
+
cancelAction: mongoose_1.SchemaTypes.Mixed // add(2024-05-26~)
|
|
31
32
|
};
|
|
32
33
|
const schemaOptions = {
|
|
33
34
|
autoIndex: settings_1.MONGO_AUTO_INDEX,
|
|
@@ -16,10 +16,8 @@ const schemaOptions = {
|
|
|
16
16
|
writeConcern: writeConcern_1.writeConcern,
|
|
17
17
|
strict: false,
|
|
18
18
|
strictQuery: false,
|
|
19
|
-
timestamps:
|
|
20
|
-
|
|
21
|
-
updatedAt: 'updatedAt'
|
|
22
|
-
},
|
|
19
|
+
timestamps: false,
|
|
20
|
+
versionKey: false,
|
|
23
21
|
toJSON: {
|
|
24
22
|
getters: false,
|
|
25
23
|
virtuals: false,
|
|
@@ -44,14 +42,5 @@ function createSchema() {
|
|
|
44
42
|
return schema;
|
|
45
43
|
}
|
|
46
44
|
exports.createSchema = createSchema;
|
|
47
|
-
const indexes = [
|
|
48
|
-
[
|
|
49
|
-
{ createdAt: 1 },
|
|
50
|
-
{ name: 'searchByCreatedAt' }
|
|
51
|
-
],
|
|
52
|
-
[
|
|
53
|
-
{ updatedAt: 1 },
|
|
54
|
-
{ name: 'searchByUpdatedAt' }
|
|
55
|
-
]
|
|
56
|
-
];
|
|
45
|
+
const indexes = [];
|
|
57
46
|
exports.indexes = indexes;
|
|
@@ -33,10 +33,8 @@ const schemaOptions = {
|
|
|
33
33
|
writeConcern: writeConcern_1.writeConcern,
|
|
34
34
|
strict: true,
|
|
35
35
|
strictQuery: false,
|
|
36
|
-
timestamps:
|
|
37
|
-
|
|
38
|
-
updatedAt: 'updatedAt'
|
|
39
|
-
},
|
|
36
|
+
timestamps: false,
|
|
37
|
+
versionKey: false,
|
|
40
38
|
toJSON: {
|
|
41
39
|
getters: false,
|
|
42
40
|
virtuals: false,
|
|
@@ -51,14 +49,6 @@ const schemaOptions = {
|
|
|
51
49
|
}
|
|
52
50
|
};
|
|
53
51
|
const indexes = [
|
|
54
|
-
[
|
|
55
|
-
{ createdAt: 1 },
|
|
56
|
-
{ name: 'searchByCreatedAt' }
|
|
57
|
-
],
|
|
58
|
-
[
|
|
59
|
-
{ updatedAt: 1 },
|
|
60
|
-
{ name: 'searchByUpdatedAt' }
|
|
61
|
-
],
|
|
62
52
|
[
|
|
63
53
|
{ 'project.id': 1, runsAt: -1 },
|
|
64
54
|
{ name: 'searchByProjectId-v20220721' }
|
|
@@ -168,6 +168,10 @@ export declare class MongoRepository {
|
|
|
168
168
|
};
|
|
169
169
|
}): Promise<number>;
|
|
170
170
|
getCursor(conditions: any, projection: any): import("mongoose").Cursor<any, import("mongoose").QueryOptions<any>>;
|
|
171
|
+
unsetUnnecessaryFields(params: {
|
|
172
|
+
filter: any;
|
|
173
|
+
$unset: any;
|
|
174
|
+
}): Promise<import("mongodb").UpdateResult>;
|
|
171
175
|
aggregateTask(params: {
|
|
172
176
|
project?: {
|
|
173
177
|
id?: {
|
package/lib/chevre/repo/task.js
CHANGED
|
@@ -645,6 +645,12 @@ class MongoRepository {
|
|
|
645
645
|
.sort({ runsAt: factory.sortType.Ascending })
|
|
646
646
|
.cursor();
|
|
647
647
|
}
|
|
648
|
+
unsetUnnecessaryFields(params) {
|
|
649
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
650
|
+
return this.taskModel.updateMany(params.filter, { $unset: params.$unset }, { timestamps: false })
|
|
651
|
+
.exec();
|
|
652
|
+
});
|
|
653
|
+
}
|
|
648
654
|
aggregateTask(params) {
|
|
649
655
|
return __awaiter(this, void 0, void 0, function* () {
|
|
650
656
|
const statuses = yield Promise.all([
|
|
@@ -61,7 +61,7 @@ import type { MongoRepository as TransactionRepo } from './repo/transaction';
|
|
|
61
61
|
import type { RedisRepository as TransactionNumberRepo } from './repo/transactionNumber';
|
|
62
62
|
import type { TransactionProcessRepository } from './repo/transactionProcess';
|
|
63
63
|
import type { MongoRepository as TripRepo } from './repo/trip';
|
|
64
|
-
import type {
|
|
64
|
+
import type { ConfirmationNumberRepo } from './repo/confirmationNumber';
|
|
65
65
|
import type { RedisRepository as OrderNumberRepo } from './repo/orderNumber';
|
|
66
66
|
import type { GMORepository as CreditCardRepo } from './repo/paymentMethod/creditCard';
|
|
67
67
|
import type { CognitoRepository as PersonRepo } from './repo/person';
|
package/lib/chevre/repository.js
CHANGED
|
@@ -199,7 +199,7 @@ var ConfirmationNumber;
|
|
|
199
199
|
function createInstance(...params) {
|
|
200
200
|
return __awaiter(this, void 0, void 0, function* () {
|
|
201
201
|
if (repo === undefined) {
|
|
202
|
-
repo = (yield Promise.resolve().then(() => require('./repo/confirmationNumber'))).
|
|
202
|
+
repo = (yield Promise.resolve().then(() => require('./repo/confirmationNumber'))).ConfirmationNumberRepo;
|
|
203
203
|
}
|
|
204
204
|
return new repo(...params);
|
|
205
205
|
});
|
|
@@ -76,8 +76,20 @@ export type IPublishPaymentUrlResult = CreditCardPayment.IPaymentAgencyTransacti
|
|
|
76
76
|
/**
|
|
77
77
|
* 外部決済ロケーション発行
|
|
78
78
|
*/
|
|
79
|
-
export declare function publishPaymentUrl(params: factory.assetTransaction.pay.IStartParamsWithoutDetail,
|
|
80
|
-
|
|
79
|
+
export declare function publishPaymentUrl(params: factory.assetTransaction.pay.IStartParamsWithoutDetail, options: {
|
|
80
|
+
purposeAsTransaction: {
|
|
81
|
+
id: string;
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* 実行者
|
|
85
|
+
*/
|
|
86
|
+
executor?: {
|
|
87
|
+
/**
|
|
88
|
+
* task ID
|
|
89
|
+
* taskによって実行されている場合値が存在する
|
|
90
|
+
*/
|
|
91
|
+
id?: string;
|
|
92
|
+
};
|
|
81
93
|
}): IPublishPaymentUrlOperation<IPublishPaymentUrlResult>;
|
|
82
94
|
/**
|
|
83
95
|
* 決済ロケーションを無効化する
|
|
@@ -23,9 +23,9 @@ const debug = createDebug('chevre-domain:service:assetTransaction');
|
|
|
23
23
|
* 外部決済ロケーション発行
|
|
24
24
|
*/
|
|
25
25
|
// tslint:disable-next-line:max-func-body-length
|
|
26
|
-
function publishPaymentUrl(params,
|
|
26
|
+
function publishPaymentUrl(params, options) {
|
|
27
27
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
28
|
-
var _a, _b, _c;
|
|
28
|
+
var _a, _b, _c, _d, _e;
|
|
29
29
|
const paymentServiceType = (_a = params.object) === null || _a === void 0 ? void 0 : _a.typeOf;
|
|
30
30
|
// 金額をfix
|
|
31
31
|
const amount = (_b = params.object.paymentMethod) === null || _b === void 0 ? void 0 : _b.amount;
|
|
@@ -40,22 +40,26 @@ function publishPaymentUrl(params, purposeAsTransaction) {
|
|
|
40
40
|
// 決済サービス確認
|
|
41
41
|
const paymentServiceId = getPaymentServiceId(params);
|
|
42
42
|
// 決済受入アクション生成(2024-03-28~)
|
|
43
|
+
const taskId = (_c = options === null || options === void 0 ? void 0 : options.executor) === null || _c === void 0 ? void 0 : _c.id;
|
|
43
44
|
const actionAttributes = Object.assign({ project: params.project, typeOf: factory.actionType.AcceptAction, agent: params.agent, object: {
|
|
44
45
|
object: params.object,
|
|
45
46
|
transactionNumber,
|
|
46
47
|
typeOf: params.typeOf
|
|
47
|
-
}
|
|
48
|
-
? {
|
|
48
|
+
}, purpose: { typeOf: factory.transactionType.PlaceOrder, id: options.purposeAsTransaction.id } }, (typeof taskId === 'string')
|
|
49
|
+
? { sameAs: { id: taskId, typeOf: 'Task' } } // タスク関連付け(2024-05-22~)
|
|
49
50
|
: undefined);
|
|
50
51
|
const action = yield repos.action.start(actionAttributes);
|
|
51
52
|
let result;
|
|
52
53
|
try {
|
|
53
54
|
switch (paymentServiceType) {
|
|
54
55
|
case factory.service.paymentService.PaymentServiceType.CreditCard:
|
|
55
|
-
const authorizeResult = yield CreditCardPayment.authorize(params, paymentServiceId, {
|
|
56
|
+
const authorizeResult = yield CreditCardPayment.authorize(params, paymentServiceId, {
|
|
57
|
+
processPublishPaymentUrl: true,
|
|
58
|
+
executor: (typeof ((_d = options.executor) === null || _d === void 0 ? void 0 : _d.id) === 'string') ? { id: options.executor.id } : {} // タスク関連付け(2024-05-22~)
|
|
59
|
+
})(repos);
|
|
56
60
|
let paymentUrl;
|
|
57
61
|
// 3DS拡張(2024-01-02~)
|
|
58
|
-
const retUrl = (
|
|
62
|
+
const retUrl = (_e = params.object.paymentMethod.creditCard) === null || _e === void 0 ? void 0 : _e.retUrl;
|
|
59
63
|
if (typeof retUrl === 'string' && retUrl.length > 0) {
|
|
60
64
|
paymentUrl = authorizeResult.execTranResult.redirectUrl;
|
|
61
65
|
}
|
|
@@ -51,5 +51,5 @@ declare function verifyToken(params: {
|
|
|
51
51
|
action?: ActionRepo;
|
|
52
52
|
authorization: AuthorizationRepo;
|
|
53
53
|
ticket: TicketRepo;
|
|
54
|
-
}) => Promise<factory.authorization.IObject | import("@chevre/factory/lib/action/
|
|
54
|
+
}) => Promise<factory.authorization.IObject | import("@chevre/factory/lib/action/accept/coaOffer").IPurpose>;
|
|
55
55
|
export { IToken, ICode, IPayload, IPayloadWithNoVersion, getToken, verifyToken };
|
|
@@ -71,13 +71,13 @@ function authorize(params) {
|
|
|
71
71
|
acceptedOffers4result = processStartReserveResult.acceptedOffers4result;
|
|
72
72
|
// add orderInTransaction(2024-01-15~)
|
|
73
73
|
if (!noOfferSpecified) {
|
|
74
|
-
if (params.options.useCreateOrderOnOfferAccepted) {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}
|
|
74
|
+
// if (params.options.useCreateOrderOnOfferAccepted) {
|
|
75
|
+
yield (0, any_1.acceptOffer)({
|
|
76
|
+
project: transaction.project,
|
|
77
|
+
purpose: { id: transaction.id },
|
|
78
|
+
acceptedOffers: acceptedOffers4result
|
|
79
|
+
})(repos);
|
|
80
|
+
// }
|
|
81
81
|
}
|
|
82
82
|
break;
|
|
83
83
|
default:
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import * as factory from '../../../../factory';
|
|
2
|
+
import type { MongoRepository as ActionRepo } from '../../../../repo/action';
|
|
3
|
+
import type { MongoRepository as AssetTransactionRepo } from '../../../../repo/assetTransaction';
|
|
4
|
+
import type { MongoRepository as OrderInTransactionRepo } from '../../../../repo/orderInTransaction';
|
|
5
|
+
import type { RedisRepository as OfferRateLimitRepo } from '../../../../repo/rateLimit/offer';
|
|
6
|
+
import type { MongoRepository as ReservationRepo } from '../../../../repo/reservation';
|
|
7
|
+
import type { StockHolderRepository as StockHolderRepo } from '../../../../repo/stockHolder';
|
|
8
|
+
import type { MongoRepository as TaskRepo } from '../../../../repo/task';
|
|
9
|
+
import type { MongoRepository as TransactionRepo } from '../../../../repo/transaction';
|
|
10
|
+
export import WebAPIIdentifier = factory.service.webAPI.Identifier;
|
|
11
|
+
interface IVoidTransactionRepos {
|
|
12
|
+
action: ActionRepo;
|
|
13
|
+
assetTransaction: AssetTransactionRepo;
|
|
14
|
+
stockHolder: StockHolderRepo;
|
|
15
|
+
offerRateLimit: OfferRateLimitRepo;
|
|
16
|
+
orderInTransaction: OrderInTransactionRepo;
|
|
17
|
+
reservation: ReservationRepo;
|
|
18
|
+
task: TaskRepo;
|
|
19
|
+
transaction: TransactionRepo;
|
|
20
|
+
}
|
|
21
|
+
declare function processVoidTransaction4chevre(params: {
|
|
22
|
+
action: factory.action.authorize.offer.eventService.IAction<WebAPIIdentifier.Chevre>;
|
|
23
|
+
}): (repos: IVoidTransactionRepos) => Promise<void>;
|
|
24
|
+
export { processVoidTransaction4chevre };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.processVoidTransaction4chevre = exports.WebAPIIdentifier = void 0;
|
|
13
|
+
const factory = require("../../../../factory");
|
|
14
|
+
const reserve_1 = require("../../../assetTransaction/reserve");
|
|
15
|
+
exports.WebAPIIdentifier = factory.service.webAPI.Identifier;
|
|
16
|
+
function processVoidTransaction4chevre(params) {
|
|
17
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
18
|
+
var _a;
|
|
19
|
+
const transactionNumber = (_a = params.action.object.pendingTransaction) === null || _a === void 0 ? void 0 : _a.transactionNumber;
|
|
20
|
+
if (typeof transactionNumber === 'string') {
|
|
21
|
+
// 取引が存在すれば中止
|
|
22
|
+
const assetTransactions = yield repos.assetTransaction.search({
|
|
23
|
+
limit: 1,
|
|
24
|
+
page: 1,
|
|
25
|
+
project: { id: { $eq: params.action.project.id } },
|
|
26
|
+
typeOf: factory.assetTransactionType.Reserve,
|
|
27
|
+
transactionNumber: { $eq: transactionNumber }
|
|
28
|
+
}, ['_id']);
|
|
29
|
+
if (assetTransactions.length > 0) {
|
|
30
|
+
yield (0, reserve_1.cancel)({ transactionNumber })(repos);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
exports.processVoidTransaction4chevre = processVoidTransaction4chevre;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as factory from '../../../../factory';
|
|
2
|
+
export import WebAPIIdentifier = factory.service.webAPI.Identifier;
|
|
3
|
+
declare function processVoidTransaction4coa(params: {
|
|
4
|
+
action: factory.action.authorize.offer.eventService.IAction<WebAPIIdentifier.COA>;
|
|
5
|
+
}): Promise<void>;
|
|
6
|
+
declare function processVoidTransactionByAcceptAction4coa(params: {
|
|
7
|
+
action: factory.action.accept.coaOffer.IAction;
|
|
8
|
+
}): Promise<void>;
|
|
9
|
+
export { processVoidTransaction4coa, processVoidTransactionByAcceptAction4coa };
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.processVoidTransactionByAcceptAction4coa = exports.processVoidTransaction4coa = exports.WebAPIIdentifier = void 0;
|
|
13
|
+
const COA = require("@motionpicture/coa-service");
|
|
14
|
+
const http_status_1 = require("http-status");
|
|
15
|
+
const credentials_1 = require("../../../../credentials");
|
|
16
|
+
const factory = require("../../../../factory");
|
|
17
|
+
const coaAuthClient = new COA.auth.RefreshToken({
|
|
18
|
+
endpoint: credentials_1.credentials.coa.endpoint,
|
|
19
|
+
refreshToken: credentials_1.credentials.coa.refreshToken,
|
|
20
|
+
useFetch: credentials_1.credentials.coa.useFetch
|
|
21
|
+
});
|
|
22
|
+
exports.WebAPIIdentifier = factory.service.webAPI.Identifier;
|
|
23
|
+
function processVoidTransaction4coa(params) {
|
|
24
|
+
var _a, _b;
|
|
25
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
+
// COAの場合、objectあるいはresultに連携内容情報が記録されているので、その情報を元に仮予約を取り消す
|
|
27
|
+
let delTmpReserveParams;
|
|
28
|
+
// objectに進行中取引情報があれば利用する(2023-09-11~)
|
|
29
|
+
const pendingTransaction = params.action.object.pendingTransaction;
|
|
30
|
+
if (typeof (pendingTransaction === null || pendingTransaction === void 0 ? void 0 : pendingTransaction.typeOf) === 'string') {
|
|
31
|
+
delTmpReserveParams = {
|
|
32
|
+
theaterCode: pendingTransaction.theaterCode,
|
|
33
|
+
dateJouei: pendingTransaction.dateJouei,
|
|
34
|
+
titleCode: pendingTransaction.titleCode,
|
|
35
|
+
titleBranchNum: pendingTransaction.titleBranchNum,
|
|
36
|
+
timeBegin: pendingTransaction.timeBegin,
|
|
37
|
+
tmpReserveNum: pendingTransaction.tmpReserveNum
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
const coaRequestBody = (_a = params.action.result) === null || _a === void 0 ? void 0 : _a.requestBody;
|
|
42
|
+
const coaResponseBody = (_b = params.action.result) === null || _b === void 0 ? void 0 : _b.responseBody;
|
|
43
|
+
if (coaRequestBody !== undefined && coaResponseBody !== undefined) {
|
|
44
|
+
delTmpReserveParams = {
|
|
45
|
+
theaterCode: coaRequestBody.theaterCode,
|
|
46
|
+
dateJouei: coaRequestBody.dateJouei,
|
|
47
|
+
titleCode: coaRequestBody.titleCode,
|
|
48
|
+
titleBranchNum: coaRequestBody.titleBranchNum,
|
|
49
|
+
timeBegin: coaRequestBody.timeBegin,
|
|
50
|
+
tmpReserveNum: coaResponseBody.tmpReserveNum
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
if (delTmpReserveParams !== undefined) {
|
|
55
|
+
// COAで仮予約取消
|
|
56
|
+
try {
|
|
57
|
+
const reserveService = new COA.service.Reserve({
|
|
58
|
+
endpoint: credentials_1.credentials.coa.endpoint,
|
|
59
|
+
auth: coaAuthClient
|
|
60
|
+
}, { timeout: credentials_1.credentials.coa.timeout });
|
|
61
|
+
yield reserveService.delTmpReserve(delTmpReserveParams);
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
let deleted = false;
|
|
65
|
+
// COAサービスエラーの場合ハンドリング
|
|
66
|
+
// tslint:disable-next-line:no-single-line-block-comment
|
|
67
|
+
/* istanbul ignore if */
|
|
68
|
+
if (error.name === 'COAServiceError') {
|
|
69
|
+
if (typeof error.code === 'number' && error.code < http_status_1.INTERNAL_SERVER_ERROR) {
|
|
70
|
+
// すでに取消済の場合こうなるので、okとする
|
|
71
|
+
if (error.message === '座席取消失敗') {
|
|
72
|
+
deleted = true;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
if (!deleted) {
|
|
77
|
+
throw error;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
exports.processVoidTransaction4coa = processVoidTransaction4coa;
|
|
84
|
+
function processVoidTransactionByAcceptAction4coa(params) {
|
|
85
|
+
var _a, _b, _c;
|
|
86
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
87
|
+
// instrument,resultに連携内容情報が保管されているので、その情報を元に仮予約を取り消す
|
|
88
|
+
let delTmpReserveParams;
|
|
89
|
+
const coaRequestBody = (_a = params.action.instrument) === null || _a === void 0 ? void 0 : _a.requestBody;
|
|
90
|
+
const coaResponseBody = (_c = (_b = params.action.result) === null || _b === void 0 ? void 0 : _b.result) === null || _c === void 0 ? void 0 : _c.responseBody;
|
|
91
|
+
if (coaRequestBody !== undefined && coaResponseBody !== undefined) {
|
|
92
|
+
delTmpReserveParams = {
|
|
93
|
+
theaterCode: coaRequestBody.theaterCode,
|
|
94
|
+
dateJouei: coaRequestBody.dateJouei,
|
|
95
|
+
titleCode: coaRequestBody.titleCode,
|
|
96
|
+
titleBranchNum: coaRequestBody.titleBranchNum,
|
|
97
|
+
timeBegin: coaRequestBody.timeBegin,
|
|
98
|
+
tmpReserveNum: coaResponseBody.tmpReserveNum
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
if (delTmpReserveParams !== undefined) {
|
|
102
|
+
// COAで仮予約取消
|
|
103
|
+
try {
|
|
104
|
+
const reserveService = new COA.service.Reserve({
|
|
105
|
+
endpoint: credentials_1.credentials.coa.endpoint,
|
|
106
|
+
auth: coaAuthClient
|
|
107
|
+
}, { timeout: credentials_1.credentials.coa.timeout });
|
|
108
|
+
yield reserveService.delTmpReserve(delTmpReserveParams);
|
|
109
|
+
}
|
|
110
|
+
catch (error) {
|
|
111
|
+
let deleted = false;
|
|
112
|
+
// COAサービスエラーの場合ハンドリング
|
|
113
|
+
// tslint:disable-next-line:no-single-line-block-comment
|
|
114
|
+
/* istanbul ignore if */
|
|
115
|
+
if (error.name === 'COAServiceError') {
|
|
116
|
+
if (typeof error.code === 'number' && error.code < http_status_1.INTERNAL_SERVER_ERROR) {
|
|
117
|
+
// すでに取消済の場合こうなるので、okとする
|
|
118
|
+
if (error.message === '座席取消失敗') {
|
|
119
|
+
deleted = true;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
if (!deleted) {
|
|
124
|
+
throw error;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
exports.processVoidTransactionByAcceptAction4coa = processVoidTransactionByAcceptAction4coa;
|
|
@@ -19,8 +19,15 @@ interface IVoidTransactionRepos {
|
|
|
19
19
|
transaction: TransactionRepo;
|
|
20
20
|
}
|
|
21
21
|
/**
|
|
22
|
-
* 興行オファー承認取消(タスクから実行)
|
|
23
|
-
* 取引中の承認アクション全てについて処理する
|
|
22
|
+
* 興行オファー承認取消(タスクから実行 or apiから実行))
|
|
23
|
+
* 取引中の承認アクション全てについて処理する or 特定の承認アクションについて処理する
|
|
24
24
|
*/
|
|
25
|
-
export declare function voidTransaction(params: factory.task.IData<factory.taskName.VoidReserveTransaction>
|
|
25
|
+
export declare function voidTransaction(params: factory.task.IData<factory.taskName.VoidReserveTransaction> & {
|
|
26
|
+
sameAs?: {
|
|
27
|
+
/**
|
|
28
|
+
* 実行元タスクID
|
|
29
|
+
*/
|
|
30
|
+
id: string;
|
|
31
|
+
};
|
|
32
|
+
}): (repos: IVoidTransactionRepos) => Promise<void>;
|
|
26
33
|
export {};
|