@chevre/domain 20.1.0-alpha.13 → 20.1.0-alpha.15
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/migrateMovieTheaterOffersOnPOS.ts +69 -0
- package/lib/chevre/repo/event.d.ts +9 -4
- package/lib/chevre/repo/event.js +43 -40
- package/lib/chevre/repo/place.d.ts +1 -0
- package/lib/chevre/repo/place.js +5 -0
- package/lib/chevre/repo/transaction.d.ts +3 -1
- package/lib/chevre/repo/transaction.js +11 -5
- package/lib/chevre/service/assetTransaction/pay/potentialActions.js +7 -18
- package/lib/chevre/service/event.js +10 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/factory.d.ts +3 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/factory.js +6 -14
- package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateSeller.d.ts +3 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateSeller.js +3 -2
- package/lib/chevre/service/transaction/placeOrderInProgress.js +4 -2
- package/package.json +3 -3
- package/example/src/chevre/migrateMovieTicketChargePriceSpecs.ts +0 -92
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as mongoose from 'mongoose';
|
|
3
|
+
|
|
4
|
+
import { chevre } from '../../../lib/index';
|
|
5
|
+
|
|
6
|
+
// const project = { id: String(process.env.PROJECT_ID) };
|
|
7
|
+
|
|
8
|
+
async function main() {
|
|
9
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI);
|
|
10
|
+
|
|
11
|
+
const placeRepo = new chevre.repository.Place(mongoose.connection);
|
|
12
|
+
|
|
13
|
+
const cursor = placeRepo.getCursor(
|
|
14
|
+
{
|
|
15
|
+
// 'project.id': { $eq: project.id },
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
// _id: 1,
|
|
19
|
+
}
|
|
20
|
+
);
|
|
21
|
+
console.log('places found');
|
|
22
|
+
|
|
23
|
+
let i = 0;
|
|
24
|
+
let updateCount = 0;
|
|
25
|
+
await cursor.eachAsync(async (doc) => {
|
|
26
|
+
i += 1;
|
|
27
|
+
const movieTheater: chevre.factory.place.movieTheater.IPlace = doc.toObject();
|
|
28
|
+
const availabilityEndsGraceTimeOnPOSValue = movieTheater.offers?.availabilityEndsGraceTimeOnPOS?.value;
|
|
29
|
+
const availabilityStartsGraceTimeOnPOSValue = movieTheater.offers?.availabilityStartsGraceTimeOnPOS?.value;
|
|
30
|
+
|
|
31
|
+
if (typeof availabilityEndsGraceTimeOnPOSValue === 'number' && typeof availabilityStartsGraceTimeOnPOSValue === 'number') {
|
|
32
|
+
console.log(
|
|
33
|
+
'already migrated.',
|
|
34
|
+
movieTheater.project?.id, movieTheater.branchCode, movieTheater.name.ja, i);
|
|
35
|
+
} else {
|
|
36
|
+
const availabilityStartsGraceTimeOnPOS: Pick<chevre.factory.quantitativeValue.IQuantitativeValue<chevre.factory.unitCode.Day>, 'typeOf' | 'value' | 'unitCode'> = {
|
|
37
|
+
typeOf: 'QuantitativeValue',
|
|
38
|
+
value: -93,
|
|
39
|
+
unitCode: chevre.factory.unitCode.Day
|
|
40
|
+
};
|
|
41
|
+
const availabilityEndsGraceTimeOnPOS: Pick<chevre.factory.quantitativeValue.IQuantitativeValue<chevre.factory.unitCode.Sec>, 'typeOf' | 'value' | 'unitCode'> = {
|
|
42
|
+
typeOf: 'QuantitativeValue',
|
|
43
|
+
value: 2678400,
|
|
44
|
+
unitCode: chevre.factory.unitCode.Sec
|
|
45
|
+
};
|
|
46
|
+
console.log(
|
|
47
|
+
'updating movieTheater...',
|
|
48
|
+
movieTheater.project?.id, movieTheater.branchCode, movieTheater.name.ja, i);
|
|
49
|
+
await placeRepo.saveMovieTheater(<any>{
|
|
50
|
+
id: movieTheater.id,
|
|
51
|
+
'offers.availabilityEndsGraceTimeOnPOS': availabilityEndsGraceTimeOnPOS,
|
|
52
|
+
'offers.availabilityStartsGraceTimeOnPOS': availabilityStartsGraceTimeOnPOS
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
updateCount += 1;
|
|
56
|
+
console.log(
|
|
57
|
+
'updated',
|
|
58
|
+
movieTheater.project?.id, movieTheater.branchCode, movieTheater.name.ja, i);
|
|
59
|
+
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
console.log(i, 'places checked');
|
|
64
|
+
console.log(updateCount, 'places updated');
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
main()
|
|
68
|
+
.then()
|
|
69
|
+
.catch(console.error);
|
|
@@ -29,13 +29,14 @@ export interface IUpdateAggregateUseActionsParams {
|
|
|
29
29
|
noExistingAttributeName: 1;
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
|
+
export declare type ISearchConditions<T extends factory.eventType> = factory.event.ISearchConditions<T>;
|
|
32
33
|
/**
|
|
33
34
|
* イベントリポジトリ
|
|
34
35
|
*/
|
|
35
36
|
export declare class MongoRepository {
|
|
36
37
|
private readonly eventModel;
|
|
37
38
|
constructor(connection: Connection);
|
|
38
|
-
static CREATE_MONGO_CONDITIONS<T extends factory.eventType>(conditions:
|
|
39
|
+
static CREATE_MONGO_CONDITIONS<T extends factory.eventType>(conditions: ISearchConditions<T>): any[];
|
|
39
40
|
/**
|
|
40
41
|
* 複数イベントを作成する
|
|
41
42
|
*/
|
|
@@ -71,14 +72,18 @@ export declare class MongoRepository {
|
|
|
71
72
|
attributes: factory.event.IAttributes<factory.eventType.ScreeningEvent>;
|
|
72
73
|
useOldEventId: boolean;
|
|
73
74
|
}): Promise<factory.event.IEvent<factory.eventType.ScreeningEvent>>;
|
|
74
|
-
count<T extends factory.eventType>(params:
|
|
75
|
+
count<T extends factory.eventType>(params: ISearchConditions<T>): Promise<number>;
|
|
75
76
|
/**
|
|
76
77
|
* イベントを検索する
|
|
77
78
|
*/
|
|
78
|
-
search<T extends factory.eventType>(params:
|
|
79
|
+
search<T extends factory.eventType>(params: ISearchConditions<T>, projection?: {
|
|
80
|
+
[key: string]: number;
|
|
81
|
+
}): Promise<factory.event.IEvent<T>[]>;
|
|
79
82
|
findById<T extends factory.eventType>(params: {
|
|
80
83
|
id: string;
|
|
81
|
-
}, projection?:
|
|
84
|
+
}, projection?: {
|
|
85
|
+
[key: string]: number;
|
|
86
|
+
}): Promise<factory.event.IEvent<T>>;
|
|
82
87
|
/**
|
|
83
88
|
* イベントをキャンセルする
|
|
84
89
|
*/
|
package/lib/chevre/repo/event.js
CHANGED
|
@@ -24,6 +24,7 @@ exports.MongoRepository = void 0;
|
|
|
24
24
|
const uniqid = require("uniqid");
|
|
25
25
|
const factory = require("../factory");
|
|
26
26
|
const event_1 = require("./mongoose/model/event");
|
|
27
|
+
const USE_DEPRECATED_EVENT_SEARCH_CONDITIONS = process.env.USE_DEPRECATED_EVENT_SEARCH_CONDITIONS === '1';
|
|
27
28
|
/**
|
|
28
29
|
* イベントリポジトリ
|
|
29
30
|
*/
|
|
@@ -144,7 +145,7 @@ class MongoRepository {
|
|
|
144
145
|
}
|
|
145
146
|
// tslint:disable-next-line:no-single-line-block-comment
|
|
146
147
|
/* istanbul ignore else */
|
|
147
|
-
const superEventLocationIdEq = (_k = (_j = (_h =
|
|
148
|
+
const superEventLocationIdEq = (_k = (_j = (_h = params.superEvent) === null || _h === void 0 ? void 0 : _h.location) === null || _j === void 0 ? void 0 : _j.id) === null || _k === void 0 ? void 0 : _k.$eq;
|
|
148
149
|
if (typeof superEventLocationIdEq === 'string') {
|
|
149
150
|
andConditions.push({
|
|
150
151
|
'superEvent.location.id': {
|
|
@@ -190,45 +191,47 @@ class MongoRepository {
|
|
|
190
191
|
// tslint:disable-next-line:no-single-line-block-comment
|
|
191
192
|
/* istanbul ignore else */
|
|
192
193
|
if (params.offers !== undefined) {
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
194
|
+
if (USE_DEPRECATED_EVENT_SEARCH_CONDITIONS) {
|
|
195
|
+
// tslint:disable-next-line:no-single-line-block-comment
|
|
196
|
+
/* istanbul ignore else */
|
|
197
|
+
if (params.offers.availableFrom instanceof Date) {
|
|
198
|
+
andConditions.push({
|
|
199
|
+
'offers.availabilityEnds': {
|
|
200
|
+
$exists: true,
|
|
201
|
+
$gte: params.offers.availableFrom
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
// tslint:disable-next-line:no-single-line-block-comment
|
|
206
|
+
/* istanbul ignore else */
|
|
207
|
+
if (params.offers.availableThrough instanceof Date) {
|
|
208
|
+
andConditions.push({
|
|
209
|
+
'offers.availabilityStarts': {
|
|
210
|
+
$exists: true,
|
|
211
|
+
$lte: params.offers.availableThrough
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
// tslint:disable-next-line:no-single-line-block-comment
|
|
216
|
+
/* istanbul ignore else */
|
|
217
|
+
if (params.offers.validFrom instanceof Date) {
|
|
218
|
+
andConditions.push({
|
|
219
|
+
'offers.validThrough': {
|
|
220
|
+
$exists: true,
|
|
221
|
+
$gte: params.offers.validFrom
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
// tslint:disable-next-line:no-single-line-block-comment
|
|
226
|
+
/* istanbul ignore else */
|
|
227
|
+
if (params.offers.validThrough instanceof Date) {
|
|
228
|
+
andConditions.push({
|
|
229
|
+
'offers.validFrom': {
|
|
230
|
+
$exists: true,
|
|
231
|
+
$lte: params.offers.validThrough
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
}
|
|
232
235
|
}
|
|
233
236
|
const itemOfferedIdIn = (_m = (_l = params.offers.itemOffered) === null || _l === void 0 ? void 0 : _l.id) === null || _m === void 0 ? void 0 : _m.$in;
|
|
234
237
|
if (Array.isArray(itemOfferedIdIn)) {
|
package/lib/chevre/repo/place.js
CHANGED
|
@@ -1036,5 +1036,10 @@ class MongoRepository {
|
|
|
1036
1036
|
.exec();
|
|
1037
1037
|
});
|
|
1038
1038
|
}
|
|
1039
|
+
getCursor(conditions, projection) {
|
|
1040
|
+
return this.placeModel.find(conditions, projection)
|
|
1041
|
+
.sort({ branchCode: factory.sortType.Ascending })
|
|
1042
|
+
.cursor();
|
|
1043
|
+
}
|
|
1039
1044
|
}
|
|
1040
1045
|
exports.MongoRepository = MongoRepository;
|
|
@@ -12,7 +12,9 @@ export declare class MongoRepository {
|
|
|
12
12
|
/**
|
|
13
13
|
* 取引を開始する
|
|
14
14
|
*/
|
|
15
|
-
start<T extends factory.transactionType>(params: factory.transaction.IStartParams<T>
|
|
15
|
+
start<T extends factory.transactionType>(params: factory.transaction.IStartParams<T> & {
|
|
16
|
+
expiresInSeconds?: number;
|
|
17
|
+
}): Promise<factory.transaction.ITransaction<T>>;
|
|
16
18
|
/**
|
|
17
19
|
* 特定取引検索
|
|
18
20
|
*/
|
|
@@ -247,7 +247,15 @@ class MongoRepository {
|
|
|
247
247
|
*/
|
|
248
248
|
start(params) {
|
|
249
249
|
return __awaiter(this, void 0, void 0, function* () {
|
|
250
|
-
|
|
250
|
+
const startDate = new Date();
|
|
251
|
+
let expires = params.expires;
|
|
252
|
+
// expiresInSecondsの指定があれば優先して適用する(2022-11-25~)
|
|
253
|
+
if (typeof params.expiresInSeconds === 'number' && params.expiresInSeconds > 0) {
|
|
254
|
+
expires = moment(startDate)
|
|
255
|
+
.add(params.expiresInSeconds, 'seconds')
|
|
256
|
+
.toDate();
|
|
257
|
+
}
|
|
258
|
+
return this.transactionModel.create(Object.assign(Object.assign({}, params), { typeOf: params.typeOf, status: factory.transactionStatusType.InProgress, startDate, endDate: undefined, expires, tasksExportationStatus: factory.transactionTasksExportationStatus.Unexported }))
|
|
251
259
|
.then((doc) => doc.toObject());
|
|
252
260
|
});
|
|
253
261
|
}
|
|
@@ -433,8 +441,7 @@ class MongoRepository {
|
|
|
433
441
|
return __awaiter(this, void 0, void 0, function* () {
|
|
434
442
|
yield this.transactionModel.findByIdAndUpdate(params.id, {
|
|
435
443
|
tasksExportationStatus: factory.transactionTasksExportationStatus.Exported,
|
|
436
|
-
tasksExportedAt:
|
|
437
|
-
.toDate()
|
|
444
|
+
tasksExportedAt: new Date()
|
|
438
445
|
})
|
|
439
446
|
.exec();
|
|
440
447
|
});
|
|
@@ -460,8 +467,7 @@ class MongoRepository {
|
|
|
460
467
|
*/
|
|
461
468
|
cancel(params) {
|
|
462
469
|
return __awaiter(this, void 0, void 0, function* () {
|
|
463
|
-
const endDate =
|
|
464
|
-
.toDate();
|
|
470
|
+
const endDate = new Date();
|
|
465
471
|
// 進行中ステータスの取引を中止する
|
|
466
472
|
const doc = yield this.transactionModel.findOneAndUpdate({
|
|
467
473
|
typeOf: params.typeOf,
|
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.createPotentialActions = void 0;
|
|
4
4
|
const factory = require("../../../factory");
|
|
5
5
|
const order_1 = require("../../../factory/order");
|
|
6
|
-
const USE_NEW_PRICE_SPEC_ON_INFORM_PAY_ACTION = process.env.USE_NEW_PRICE_SPEC_ON_INFORM_PAY_ACTION === '1';
|
|
7
6
|
function createPayActions(params) {
|
|
8
7
|
var _a;
|
|
9
8
|
const payActions = [];
|
|
@@ -123,8 +122,7 @@ function createPayObjectServiceOutput(params) {
|
|
|
123
122
|
paymentServiceOutput = movieTickets.map((movieTicket) => {
|
|
124
123
|
var _a;
|
|
125
124
|
const reservation4invoice = movieTicket2reservation4invoice(movieTicket, order, String(paymentMethodType));
|
|
126
|
-
return Object.assign({ identifier: movieTicket.identifier }, (typeof reservation4invoice.
|
|
127
|
-
|| typeof ((_a = reservation4invoice.priceSpecification) === null || _a === void 0 ? void 0 : _a.typeOf) === 'string')
|
|
125
|
+
return Object.assign({ identifier: movieTicket.identifier }, (typeof ((_a = reservation4invoice.priceSpecification) === null || _a === void 0 ? void 0 : _a.typeOf) === 'string')
|
|
128
126
|
? {
|
|
129
127
|
serviceOutput: reservation4invoice
|
|
130
128
|
}
|
|
@@ -139,7 +137,6 @@ function createPayObjectServiceOutput(params) {
|
|
|
139
137
|
}
|
|
140
138
|
function movieTicket2reservation4invoice(movieTicket, order, paymentMethodType) {
|
|
141
139
|
var _a, _b;
|
|
142
|
-
let reservationPrice;
|
|
143
140
|
let priceComponents4invoice = [];
|
|
144
141
|
// Orderから対象予約を取得
|
|
145
142
|
const reservationOffer = (_a = order === null || order === void 0 ? void 0 : order.acceptedOffers) === null || _a === void 0 ? void 0 : _a.find((o) => {
|
|
@@ -174,7 +171,6 @@ function movieTicket2reservation4invoice(movieTicket, order, paymentMethodType)
|
|
|
174
171
|
if (reservationOffer !== undefined) {
|
|
175
172
|
const priceComponent = (_b = reservationOffer.priceSpecification) === null || _b === void 0 ? void 0 : _b.priceComponent;
|
|
176
173
|
if (Array.isArray(priceComponent)) {
|
|
177
|
-
reservationPrice = priceComponent.reduce((a, b) => a + Number(b.price), 0);
|
|
178
174
|
priceComponents4invoice = priceComponent.map((component) => {
|
|
179
175
|
var _a;
|
|
180
176
|
const accounting = (typeof ((_a = component.accounting) === null || _a === void 0 ? void 0 : _a.accountsReceivable) === 'number')
|
|
@@ -194,19 +190,12 @@ function movieTicket2reservation4invoice(movieTicket, order, paymentMethodType)
|
|
|
194
190
|
});
|
|
195
191
|
}
|
|
196
192
|
}
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
};
|
|
204
|
-
}
|
|
205
|
-
else {
|
|
206
|
-
return {
|
|
207
|
-
price: reservationPrice
|
|
208
|
-
};
|
|
209
|
-
}
|
|
193
|
+
return {
|
|
194
|
+
priceSpecification: {
|
|
195
|
+
typeOf: factory.priceSpecificationType.CompoundPriceSpecification,
|
|
196
|
+
priceComponent: priceComponents4invoice
|
|
197
|
+
}
|
|
198
|
+
};
|
|
210
199
|
}
|
|
211
200
|
function createInformPaymentActions(params) {
|
|
212
201
|
var _a;
|
|
@@ -648,6 +648,16 @@ function createMovieTheaterFromCOA(project, theaterFromCOA, screensFromCOA) {
|
|
|
648
648
|
typeOf: 'QuantitativeValue',
|
|
649
649
|
value: 1200,
|
|
650
650
|
unitCode: factory.unitCode.Sec
|
|
651
|
+
},
|
|
652
|
+
availabilityStartsGraceTimeOnPOS: {
|
|
653
|
+
typeOf: 'QuantitativeValue',
|
|
654
|
+
value: -93,
|
|
655
|
+
unitCode: factory.unitCode.Day
|
|
656
|
+
},
|
|
657
|
+
availabilityEndsGraceTimeOnPOS: {
|
|
658
|
+
typeOf: 'QuantitativeValue',
|
|
659
|
+
value: 2678400,
|
|
660
|
+
unitCode: factory.unitCode.Sec
|
|
651
661
|
}
|
|
652
662
|
}
|
|
653
663
|
};
|
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
import * as factory from '../../../factory';
|
|
2
|
-
export declare function createStartParams(params: factory.transaction.placeOrder.IStartParamsWithoutDetail, passport: factory.waiter.passport.IPassport | undefined, seller: factory.seller.ISeller, broker?: factory.order.IBroker): factory.transaction.placeOrder.IStartParams
|
|
2
|
+
export declare function createStartParams(params: factory.transaction.placeOrder.IStartParamsWithoutDetail, passport: factory.waiter.passport.IPassport | undefined, seller: factory.seller.ISeller, broker?: factory.order.IBroker, makesOfferFromClient?: factory.seller.IMakesOffer): factory.transaction.placeOrder.IStartParams & {
|
|
3
|
+
expiresInSeconds?: number;
|
|
4
|
+
};
|
|
@@ -2,28 +2,20 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createStartParams = void 0;
|
|
4
4
|
const factory = require("../../../factory");
|
|
5
|
-
function createStartParams(params, passport, seller, broker) {
|
|
6
|
-
var _a, _b, _c, _d;
|
|
5
|
+
function createStartParams(params, passport, seller, broker, makesOfferFromClient) {
|
|
6
|
+
var _a, _b, _c, _d, _e;
|
|
7
7
|
const transactionObject = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ passportToken: (typeof ((_a = params.object.passport) === null || _a === void 0 ? void 0 : _a.token) === 'string') ? params.object.passport.token : undefined, authorizeActions: [] }, (passport !== undefined) ? { passport } : undefined), (params.object.clientUser !== undefined && params.object.clientUser !== null)
|
|
8
8
|
? { clientUser: params.object.clientUser }
|
|
9
9
|
: undefined), (typeof ((_b = params.object) === null || _b === void 0 ? void 0 : _b.name) === 'string') ? { name: (_c = params.object) === null || _c === void 0 ? void 0 : _c.name } : undefined), (typeof (broker === null || broker === void 0 ? void 0 : broker.typeOf) === 'string') ? { broker: broker } : undefined), (typeof ((_d = params.object.customer) === null || _d === void 0 ? void 0 : _d.typeOf) === 'string') ? { customer: params.object.customer } : undefined);
|
|
10
10
|
if (typeof seller.id !== 'string') {
|
|
11
11
|
throw new factory.errors.NotFound('seller.id');
|
|
12
12
|
}
|
|
13
|
-
|
|
14
|
-
return {
|
|
15
|
-
project: { typeOf: seller.project.typeOf, id: seller.project.id },
|
|
16
|
-
typeOf: factory.transactionType.PlaceOrder,
|
|
17
|
-
agent: params.agent,
|
|
18
|
-
seller: {
|
|
13
|
+
return Object.assign({ project: { typeOf: seller.project.typeOf, id: seller.project.id }, typeOf: factory.transactionType.PlaceOrder, agent: params.agent, seller: {
|
|
19
14
|
id: seller.id,
|
|
20
15
|
name: seller.name,
|
|
21
16
|
typeOf: seller.typeOf
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
object: transactionObject,
|
|
26
|
-
expires: params.expires
|
|
27
|
-
};
|
|
17
|
+
}, object: transactionObject, expires: params.expires }, (typeof ((_e = makesOfferFromClient === null || makesOfferFromClient === void 0 ? void 0 : makesOfferFromClient.eligibleTransactionDuration) === null || _e === void 0 ? void 0 : _e.maxValue) === 'number')
|
|
18
|
+
? { expiresInSeconds: makesOfferFromClient.eligibleTransactionDuration.maxValue }
|
|
19
|
+
: undefined);
|
|
28
20
|
}
|
|
29
21
|
exports.createStartParams = createStartParams;
|
|
@@ -8,12 +8,13 @@ function validateSeller(params) {
|
|
|
8
8
|
if (typeof clientId !== 'string' || clientId.length === 0) {
|
|
9
9
|
throw new factory.errors.ArgumentNull('client_id');
|
|
10
10
|
}
|
|
11
|
-
const makesOfferFromClient = (_b = params.seller.makesOffer) === null || _b === void 0 ? void 0 : _b.
|
|
11
|
+
const makesOfferFromClient = (_b = params.seller.makesOffer) === null || _b === void 0 ? void 0 : _b.find((offer) => {
|
|
12
12
|
var _a;
|
|
13
13
|
return (_a = offer.availableAtOrFrom) === null || _a === void 0 ? void 0 : _a.some((availableApplication) => availableApplication.id === clientId);
|
|
14
14
|
});
|
|
15
|
-
if (makesOfferFromClient
|
|
15
|
+
if (makesOfferFromClient === undefined) {
|
|
16
16
|
throw new factory.errors.Argument('seller', 'makes no offers');
|
|
17
17
|
}
|
|
18
|
+
return { makesOfferFromClient };
|
|
18
19
|
}
|
|
19
20
|
exports.validateSeller = validateSeller;
|
|
@@ -28,13 +28,15 @@ exports.POINT_AWARD_IDENTIFIER_NAME = 'pointAwardIdentifiers';
|
|
|
28
28
|
function start(params) {
|
|
29
29
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
30
30
|
const seller = yield repos.seller.findById({ id: params.seller.id });
|
|
31
|
+
let makesOfferFromClient;
|
|
31
32
|
// 販売者オファー検証(2022-10-14~)
|
|
32
33
|
if (params.validateSeller === true) {
|
|
33
|
-
(0, validateSeller_1.validateSeller)({ seller, clientUser: params.object.clientUser });
|
|
34
|
+
const validateSellerResult = (0, validateSeller_1.validateSeller)({ seller, clientUser: params.object.clientUser });
|
|
35
|
+
makesOfferFromClient = validateSellerResult.makesOfferFromClient;
|
|
34
36
|
}
|
|
35
37
|
const passport = yield (0, validation_2.validateWaiterPassport)(params);
|
|
36
38
|
// 取引ファクトリーで新しい進行中取引オブジェクトを作成
|
|
37
|
-
const startParams = (0, factory_1.createStartParams)(params, passport, seller, params.broker);
|
|
39
|
+
const startParams = (0, factory_1.createStartParams)(params, passport, seller, params.broker, makesOfferFromClient);
|
|
38
40
|
let transaction;
|
|
39
41
|
try {
|
|
40
42
|
transaction = yield repos.transaction.start(startParams);
|
package/package.json
CHANGED
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
}
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@chevre/factory": "4.278.0-alpha.
|
|
13
|
-
"@cinerino/sdk": "3.133.0-alpha.
|
|
12
|
+
"@chevre/factory": "4.278.0-alpha.4",
|
|
13
|
+
"@cinerino/sdk": "3.133.0-alpha.2",
|
|
14
14
|
"@motionpicture/coa-service": "9.2.0",
|
|
15
15
|
"@motionpicture/gmo-service": "5.2.0",
|
|
16
16
|
"@sendgrid/mail": "6.4.0",
|
|
@@ -120,5 +120,5 @@
|
|
|
120
120
|
"postversion": "git push origin --tags",
|
|
121
121
|
"prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
|
|
122
122
|
},
|
|
123
|
-
"version": "20.1.0-alpha.
|
|
123
|
+
"version": "20.1.0-alpha.15"
|
|
124
124
|
}
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
// tslint:disable:no-console
|
|
2
|
-
import * as mongoose from 'mongoose';
|
|
3
|
-
|
|
4
|
-
import { chevre } from '../../../lib/index';
|
|
5
|
-
|
|
6
|
-
const project = { id: String(process.env.PROJECT_ID) };
|
|
7
|
-
type IMovieTicketPriceSpec =
|
|
8
|
-
chevre.factory.priceSpecification.IPriceSpecification<chevre.factory.priceSpecificationType.MovieTicketTypeChargeSpecification>;
|
|
9
|
-
const CREATING_VIDEO_FORMAT = 'all';
|
|
10
|
-
|
|
11
|
-
async function main() {
|
|
12
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI);
|
|
13
|
-
|
|
14
|
-
const priceSpecRepo = new chevre.repository.PriceSpecification(mongoose.connection);
|
|
15
|
-
|
|
16
|
-
const cursor = priceSpecRepo.getCursor(
|
|
17
|
-
{
|
|
18
|
-
'project.id': { $eq: project.id },
|
|
19
|
-
typeOf: { $eq: chevre.factory.priceSpecificationType.MovieTicketTypeChargeSpecification }
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
// _id: 1,
|
|
23
|
-
}
|
|
24
|
-
);
|
|
25
|
-
console.log('priceSpecs found');
|
|
26
|
-
|
|
27
|
-
let i = 0;
|
|
28
|
-
let updateCount = 0;
|
|
29
|
-
await cursor.eachAsync(async (doc) => {
|
|
30
|
-
i += 1;
|
|
31
|
-
const priceSpec: IMovieTicketPriceSpec = doc.toObject();
|
|
32
|
-
const appliesToVideoFormat = priceSpec.appliesToVideoFormat;
|
|
33
|
-
|
|
34
|
-
if (appliesToVideoFormat === CREATING_VIDEO_FORMAT) {
|
|
35
|
-
console.log(
|
|
36
|
-
'appliesToVideoFormat is...',
|
|
37
|
-
CREATING_VIDEO_FORMAT,
|
|
38
|
-
priceSpec.project?.id, priceSpec.appliesToMovieTicket.serviceType, priceSpec.appliesToVideoFormat, priceSpec.price, i);
|
|
39
|
-
} else {
|
|
40
|
-
// 券種区分について、もうひとつの上映方式に対応する価格仕様が存在しなければ、作成する
|
|
41
|
-
const priceSpecs = await priceSpecRepo.search({
|
|
42
|
-
limit: 1,
|
|
43
|
-
page: 1,
|
|
44
|
-
project: { id: { $eq: project.id } },
|
|
45
|
-
typeOf: chevre.factory.priceSpecificationType.MovieTicketTypeChargeSpecification,
|
|
46
|
-
appliesToVideoFormats: [CREATING_VIDEO_FORMAT],
|
|
47
|
-
appliesToMovieTicket: {
|
|
48
|
-
serviceTypes: [priceSpec.appliesToMovieTicket.serviceType]
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
const priceSpec4all = priceSpecs.shift();
|
|
52
|
-
if (priceSpec4all !== undefined) {
|
|
53
|
-
console.log(
|
|
54
|
-
'already exist.',
|
|
55
|
-
priceSpec.project?.id, priceSpec.appliesToMovieTicket.serviceType, priceSpec.appliesToVideoFormat, priceSpec.price, i);
|
|
56
|
-
} else {
|
|
57
|
-
const newPriceSpec: IMovieTicketPriceSpec = {
|
|
58
|
-
typeOf: chevre.factory.priceSpecificationType.MovieTicketTypeChargeSpecification,
|
|
59
|
-
project: priceSpec.project,
|
|
60
|
-
price: priceSpec.price,
|
|
61
|
-
priceCurrency: priceSpec.priceCurrency,
|
|
62
|
-
name: priceSpec.name,
|
|
63
|
-
appliesToMovieTicket: priceSpec.appliesToMovieTicket,
|
|
64
|
-
appliesToVideoFormat: CREATING_VIDEO_FORMAT,
|
|
65
|
-
valueAddedTaxIncluded: true
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
console.log(
|
|
69
|
-
'creating priceSpec...',
|
|
70
|
-
priceSpec.project?.id,
|
|
71
|
-
newPriceSpec.appliesToMovieTicket.serviceType, newPriceSpec.appliesToVideoFormat, newPriceSpec.price, i);
|
|
72
|
-
await priceSpecRepo.save({
|
|
73
|
-
attributes: newPriceSpec
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
updateCount += 1;
|
|
77
|
-
console.log(
|
|
78
|
-
'created',
|
|
79
|
-
priceSpec.project?.id,
|
|
80
|
-
newPriceSpec.appliesToMovieTicket.serviceType, newPriceSpec.appliesToVideoFormat, newPriceSpec.price, i);
|
|
81
|
-
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
console.log(i, 'priceSpecs checked');
|
|
87
|
-
console.log(updateCount, 'priceSpecs updated');
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
main()
|
|
91
|
-
.then()
|
|
92
|
-
.catch(console.error);
|