@chevre/domain 21.8.0-alpha.26 → 21.8.0-alpha.27
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.
|
@@ -66,9 +66,12 @@ export declare class MongoRepository {
|
|
|
66
66
|
}): Promise<factory.unitPriceOffer.IUnitPriceOffer>;
|
|
67
67
|
count(params: factory.unitPriceOffer.ISearchConditions): Promise<number>;
|
|
68
68
|
search(params: factory.unitPriceOffer.ISearchConditions, projection?: IProjection): Promise<factory.unitPriceOffer.IUnitPriceOffer[]>;
|
|
69
|
-
save(params: factory.
|
|
69
|
+
save(params: factory.aggregateOffer.IAggregateOffer): Promise<factory.aggregateOffer.IAggregateOffer>;
|
|
70
|
+
/**
|
|
71
|
+
* sskts専用オファー保管
|
|
72
|
+
*/
|
|
70
73
|
saveManyByIdentifier(params: {
|
|
71
|
-
attributes: factory.
|
|
74
|
+
attributes: factory.aggregateOffer.IAggregateOffer;
|
|
72
75
|
upsert?: boolean;
|
|
73
76
|
}[]): Promise<void>;
|
|
74
77
|
/**
|
package/lib/chevre/repo/offer.js
CHANGED
|
@@ -447,9 +447,14 @@ class MongoRepository {
|
|
|
447
447
|
save(params) {
|
|
448
448
|
return __awaiter(this, void 0, void 0, function* () {
|
|
449
449
|
let doc;
|
|
450
|
+
// AggregateOffer対応(2023-09-03~)
|
|
451
|
+
if (!Array.isArray(params.offers) || params.offers.length === 0) {
|
|
452
|
+
throw new factory.errors.ArgumentNull('aggregateOffer.offers');
|
|
453
|
+
}
|
|
450
454
|
if (params.id === '') {
|
|
451
455
|
const id = uniqid();
|
|
452
|
-
doc = yield this.offerModel.create(Object.assign(Object.assign({}, params), { _id: id
|
|
456
|
+
doc = yield this.offerModel.create(Object.assign(Object.assign({}, params), { _id: id, 'offers.id': id // AggregateOffer対応(2023-09-03~)
|
|
457
|
+
}));
|
|
453
458
|
}
|
|
454
459
|
else {
|
|
455
460
|
// 上書き禁止属性を除外(2022-08-24~)
|
|
@@ -463,11 +468,18 @@ class MongoRepository {
|
|
|
463
468
|
return doc.toObject();
|
|
464
469
|
});
|
|
465
470
|
}
|
|
471
|
+
/**
|
|
472
|
+
* sskts専用オファー保管
|
|
473
|
+
*/
|
|
466
474
|
saveManyByIdentifier(params) {
|
|
467
475
|
return __awaiter(this, void 0, void 0, function* () {
|
|
468
476
|
const bulkWriteOps = [];
|
|
469
477
|
if (Array.isArray(params)) {
|
|
470
478
|
params.forEach((p) => {
|
|
479
|
+
// AggregateOffer対応(2023-09-03~)
|
|
480
|
+
if (!Array.isArray(p.attributes.offers) || p.attributes.offers.length === 0) {
|
|
481
|
+
throw new factory.errors.ArgumentNull('aggregateOffer.offers');
|
|
482
|
+
}
|
|
471
483
|
const id = uniqid();
|
|
472
484
|
const $set = Object.assign({}, p.attributes);
|
|
473
485
|
if (typeof $set.id === 'string') {
|
|
@@ -486,7 +498,10 @@ class MongoRepository {
|
|
|
486
498
|
},
|
|
487
499
|
update: {
|
|
488
500
|
$set: $set,
|
|
489
|
-
$setOnInsert: {
|
|
501
|
+
$setOnInsert: {
|
|
502
|
+
_id: id,
|
|
503
|
+
'offers.id': id // AggregateOffer対応(2023-09-03~)
|
|
504
|
+
}
|
|
490
505
|
},
|
|
491
506
|
upsert: (p.upsert !== undefined) ? p.upsert : false
|
|
492
507
|
}
|
|
@@ -513,6 +528,9 @@ class MongoRepository {
|
|
|
513
528
|
$pull: {
|
|
514
529
|
addOn: {
|
|
515
530
|
'itemOffered.id': { $in: params.addOn.itemOffered.id.$in }
|
|
531
|
+
},
|
|
532
|
+
'offers.addOn': {
|
|
533
|
+
'itemOffered.id': { $in: params.addOn.itemOffered.id.$in } // AggregateOffer対応(2023-09-03~)
|
|
516
534
|
}
|
|
517
535
|
}
|
|
518
536
|
})
|
|
@@ -44,5 +44,5 @@ export declare function coaTicket2offer(params: {
|
|
|
44
44
|
ticketResult: COA.factory.master.ITicketResult;
|
|
45
45
|
defaultCurrencyType?: factory.categoryCode.ICategoryCode;
|
|
46
46
|
defaultMembershipType?: factory.categoryCode.ICategoryCode;
|
|
47
|
-
}): factory.
|
|
47
|
+
}): factory.aggregateOffer.IAggregateOffer;
|
|
48
48
|
export {};
|
|
@@ -340,17 +340,7 @@ function coaTicket2offer(params) {
|
|
|
340
340
|
? params.ticketResult.ticketNameEng
|
|
341
341
|
: ''
|
|
342
342
|
};
|
|
343
|
-
const
|
|
344
|
-
price: unitPriceSpec.price,
|
|
345
|
-
typeOf: unitPriceSpec.typeOf
|
|
346
|
-
};
|
|
347
|
-
const subOffers = [{
|
|
348
|
-
typeOf: factory.offerType.Offer,
|
|
349
|
-
identifier: identifier,
|
|
350
|
-
name: offerName,
|
|
351
|
-
priceSpecification: subOfferPriceSpec
|
|
352
|
-
}];
|
|
353
|
-
return Object.assign(Object.assign(Object.assign({ project: { typeOf: factory.organizationType.Project, id: params.project.id }, typeOf: factory.offerType.Offer, priceCurrency: factory.priceCurrency.JPY, id: '', identifier: identifier, name: offerName, description: {
|
|
343
|
+
const unitPriceOffer = Object.assign(Object.assign(Object.assign({ project: { typeOf: factory.organizationType.Project, id: params.project.id }, typeOf: factory.offerType.Offer, priceCurrency: factory.priceCurrency.JPY, id: '', identifier: identifier, name: offerName, description: {
|
|
354
344
|
ja: '',
|
|
355
345
|
en: ''
|
|
356
346
|
}, alternateName: {
|
|
@@ -360,12 +350,14 @@ function coaTicket2offer(params) {
|
|
|
360
350
|
: ''
|
|
361
351
|
}, availability: factory.itemAvailability.InStock, itemOffered: {
|
|
362
352
|
typeOf: factory.product.ProductType.EventService
|
|
363
|
-
},
|
|
353
|
+
}, priceSpecification: unitPriceSpec }, (Array.isArray(eligibleMembershipType)) ? { eligibleMembershipType } : undefined), (Array.isArray(eligibleMonetaryAmount)) ? { eligibleMonetaryAmount } : undefined), { additionalProperty: [
|
|
364
354
|
{ name: 'theaterCode', value: params.theaterCode },
|
|
365
355
|
...Object.keys(params.ticketResult)
|
|
366
356
|
.map((key) => {
|
|
367
357
|
return { name: String(key), value: String(params.ticketResult[key]) };
|
|
368
358
|
})
|
|
369
359
|
] });
|
|
360
|
+
const subOffers = [unitPriceOffer];
|
|
361
|
+
return Object.assign(Object.assign({}, unitPriceOffer), { offers: subOffers });
|
|
370
362
|
}
|
|
371
363
|
exports.coaTicket2offer = coaTicket2offer;
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
}
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@chevre/factory": "4.329.0-alpha.
|
|
12
|
+
"@chevre/factory": "4.329.0-alpha.4",
|
|
13
13
|
"@cinerino/sdk": "3.166.0-alpha.5",
|
|
14
14
|
"@motionpicture/coa-service": "9.2.0",
|
|
15
15
|
"@motionpicture/gmo-service": "5.2.0",
|
|
@@ -117,5 +117,5 @@
|
|
|
117
117
|
"postversion": "git push origin --tags",
|
|
118
118
|
"prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
|
|
119
119
|
},
|
|
120
|
-
"version": "21.8.0-alpha.
|
|
120
|
+
"version": "21.8.0-alpha.27"
|
|
121
121
|
}
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
// tslint:disable:no-console
|
|
2
|
-
import * as moment from 'moment';
|
|
3
|
-
import * as mongoose from 'mongoose';
|
|
4
|
-
|
|
5
|
-
import { chevre } from '../../../lib/index';
|
|
6
|
-
|
|
7
|
-
// const project = { id: String(process.env.PROJECT_ID) };
|
|
8
|
-
// const EXCLUDED_PROJECT_ID = process.env.EXCLUDED_PROJECT_ID;
|
|
9
|
-
|
|
10
|
-
// tslint:disable-next-line:max-func-body-length
|
|
11
|
-
async function main() {
|
|
12
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
13
|
-
|
|
14
|
-
const actionRepo = new chevre.repository.Action(mongoose.connection);
|
|
15
|
-
|
|
16
|
-
const cursor = actionRepo.getCursor(
|
|
17
|
-
{
|
|
18
|
-
typeOf: { $eq: chevre.factory.actionType.AuthorizeAction },
|
|
19
|
-
actionStatus: { $eq: chevre.factory.actionStatusType.CompletedActionStatus },
|
|
20
|
-
'object.typeOf': { $exists: true, $eq: chevre.factory.action.authorize.paymentMethod.any.ResultType.Payment },
|
|
21
|
-
'result.typeOf': { $exists: true, $eq: chevre.factory.action.authorize.paymentMethod.any.ResultType.Payment },
|
|
22
|
-
startDate: {
|
|
23
|
-
$gte: moment('2022-08-16T00:00:00Z')
|
|
24
|
-
.toDate()
|
|
25
|
-
// $lte: moment('2023-08-01T00:00:00Z')
|
|
26
|
-
// .toDate()
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
_id: 1,
|
|
31
|
-
typeOf: 1,
|
|
32
|
-
result: 1,
|
|
33
|
-
project: 1,
|
|
34
|
-
startDate: 1,
|
|
35
|
-
actionStatus: 1
|
|
36
|
-
}
|
|
37
|
-
);
|
|
38
|
-
console.log('actions found');
|
|
39
|
-
|
|
40
|
-
let i = 0;
|
|
41
|
-
let updateCount = 0;
|
|
42
|
-
await cursor.eachAsync(async (doc) => {
|
|
43
|
-
i += 1;
|
|
44
|
-
const action: Pick<
|
|
45
|
-
chevre.factory.action.authorize.paymentMethod.any.IAction,
|
|
46
|
-
'id' | 'project' | 'result' | 'typeOf' | 'startDate' | 'actionStatus'
|
|
47
|
-
> = doc.toObject();
|
|
48
|
-
|
|
49
|
-
const oldPaymentMethodType = (<any>action).result?.paymentMethod;
|
|
50
|
-
const paymentMethodType = action.result?.paymentMethodAsObject?.typeOf;
|
|
51
|
-
const alreadyMigrated = typeof paymentMethodType === 'string' && oldPaymentMethodType === paymentMethodType;
|
|
52
|
-
|
|
53
|
-
if (alreadyMigrated) {
|
|
54
|
-
console.log('already exist...', action.project.id, action.id, action.startDate, paymentMethodType, i);
|
|
55
|
-
} else {
|
|
56
|
-
if (typeof oldPaymentMethodType !== 'string') {
|
|
57
|
-
console.error('updating action...', action.project.id, action.id, action.startDate, oldPaymentMethodType, i, updateCount);
|
|
58
|
-
throw new Error('oldPaymentMethodType undefined');
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
const newPaymentMethodAsObject: chevre.factory.action.authorize.paymentMethod.any.IResultPaymentMethod = {
|
|
62
|
-
typeOf: oldPaymentMethodType
|
|
63
|
-
};
|
|
64
|
-
console.log(
|
|
65
|
-
'updating action...', action.project.id, action.id, action.startDate, newPaymentMethodAsObject.typeOf, i, updateCount);
|
|
66
|
-
await actionRepo.updateById({
|
|
67
|
-
id: action.id,
|
|
68
|
-
update: {
|
|
69
|
-
'result.paymentMethodAsObject': newPaymentMethodAsObject
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
updateCount += 1;
|
|
73
|
-
console.log('updated.', action.project.id, action.id, action.startDate, newPaymentMethodAsObject.typeOf, i, updateCount);
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
console.log(i, 'actions checked');
|
|
78
|
-
console.log(updateCount, 'actions updated');
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
main()
|
|
82
|
-
.then()
|
|
83
|
-
.catch(console.error);
|