@chevre/domain 21.20.0 → 21.21.0-alpha.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/migrateDeleteTransactionTasks.ts +2 -2
- package/example/src/chevre/transaction/processPlaceOrder.ts +0 -2
- package/lib/chevre/repo/seller.d.ts +4 -0
- package/lib/chevre/repo/seller.js +6 -0
- package/lib/chevre/service/assetTransaction/pay.d.ts +0 -3
- package/lib/chevre/service/payment/any.d.ts +0 -3
- package/lib/chevre/service/payment/creditCard.js +0 -6
- package/package.json +1 -1
- package/example/src/chevre/migrateEventMakesOfferAvailableAtOrFrom.ts +0 -87
- package/example/src/chevre/migrateOfferAvailableAtOrFrom.ts +0 -63
|
@@ -20,11 +20,11 @@ async function main() {
|
|
|
20
20
|
runsAt: {
|
|
21
21
|
$gte: moment()
|
|
22
22
|
// tslint:disable-next-line:no-magic-numbers
|
|
23
|
-
.add(
|
|
23
|
+
.add(153, 'days')
|
|
24
24
|
.toDate(),
|
|
25
25
|
$lte: moment()
|
|
26
26
|
// tslint:disable-next-line:no-magic-numbers
|
|
27
|
-
.add(
|
|
27
|
+
.add(180, 'days')
|
|
28
28
|
.toDate()
|
|
29
29
|
}
|
|
30
30
|
// _id: { $eq: '64aba5f37b8b8ef9eca60be5' }
|
|
@@ -71,7 +71,6 @@ async function main() {
|
|
|
71
71
|
paymentAccepted: await chevre.repository.SellerPaymentAccepted.createInstance(mongoose.connection),
|
|
72
72
|
paymentService: await chevre.repository.PaymentService.createInstance(mongoose.connection),
|
|
73
73
|
paymentServiceProvider: await chevre.repository.PaymentServiceProvider.createInstance(mongoose.connection),
|
|
74
|
-
person: await chevre.repository.Person.createInstance({ userPoolId: '' }),
|
|
75
74
|
transactionNumber: await chevre.repository.TransactionNumber.createInstance(client),
|
|
76
75
|
transaction: await chevre.repository.Transaction.createInstance(mongoose.connection)
|
|
77
76
|
});
|
|
@@ -128,7 +127,6 @@ async function main() {
|
|
|
128
127
|
paymentAccepted: await chevre.repository.SellerPaymentAccepted.createInstance(mongoose.connection),
|
|
129
128
|
paymentService: await chevre.repository.PaymentService.createInstance(mongoose.connection),
|
|
130
129
|
paymentServiceProvider: await chevre.repository.PaymentServiceProvider.createInstance(mongoose.connection),
|
|
131
|
-
person: await chevre.repository.Person.createInstance({ userPoolId: '' }),
|
|
132
130
|
product: await chevre.repository.Product.createInstance(mongoose.connection),
|
|
133
131
|
task: await chevre.repository.Task.createInstance(mongoose.connection),
|
|
134
132
|
transactionNumber: await chevre.repository.TransactionNumber.createInstance(client),
|
|
@@ -82,6 +82,10 @@ export declare class MongoRepository {
|
|
|
82
82
|
id: string;
|
|
83
83
|
};
|
|
84
84
|
}): Promise<void>;
|
|
85
|
+
addAvailableAtOrFrom(params: {
|
|
86
|
+
id: string;
|
|
87
|
+
makesOffer: factory.seller.IMakesOffer;
|
|
88
|
+
}): Promise<any>;
|
|
85
89
|
getCursor(conditions: FilterQuery<factory.seller.ISeller>, projection: any): import("mongoose").Cursor<any, import("mongoose").QueryOptions<any>>;
|
|
86
90
|
unsetUnnecessaryFields(params: {
|
|
87
91
|
filter: any;
|
|
@@ -303,6 +303,12 @@ class MongoRepository {
|
|
|
303
303
|
.exec();
|
|
304
304
|
});
|
|
305
305
|
}
|
|
306
|
+
addAvailableAtOrFrom(params) {
|
|
307
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
308
|
+
return this.organizationModel.findOneAndUpdate({ _id: { $eq: params.id } }, { $push: { makesOffer: params.makesOffer } })
|
|
309
|
+
.exec();
|
|
310
|
+
});
|
|
311
|
+
}
|
|
306
312
|
getCursor(conditions, projection) {
|
|
307
313
|
return this.organizationModel.find(conditions, projection)
|
|
308
314
|
.sort({ branchCode: factory.sortType.Ascending })
|
|
@@ -11,7 +11,6 @@ import type { MongoRepository as EventRepo } from '../../repo/event';
|
|
|
11
11
|
import type { MongoRepository as OrderRepo } from '../../repo/order';
|
|
12
12
|
import type { MongoRepository as PaymentServiceRepo } from '../../repo/paymentService';
|
|
13
13
|
import type { MongoRepository as PaymentServiceProviderRepo } from '../../repo/paymentServiceProvider';
|
|
14
|
-
import type { CognitoRepository as PersonRepo } from '../../repo/person';
|
|
15
14
|
import type { MongoRepository as ProductRepo } from '../../repo/product';
|
|
16
15
|
import type { MongoRepository as PaymentAcceptedRepo } from '../../repo/sellerPaymentAccepted';
|
|
17
16
|
import type { MongoRepository as TaskRepo } from '../../repo/task';
|
|
@@ -25,7 +24,6 @@ export interface IStartOperationRepos {
|
|
|
25
24
|
paymentAccepted: PaymentAcceptedRepo;
|
|
26
25
|
paymentService: PaymentServiceRepo;
|
|
27
26
|
paymentServiceProvider: PaymentServiceProviderRepo;
|
|
28
|
-
person: PersonRepo;
|
|
29
27
|
product: ProductRepo;
|
|
30
28
|
assetTransaction: AssetTransactionRepo;
|
|
31
29
|
task: TaskRepo;
|
|
@@ -60,7 +58,6 @@ export type IPublishPaymentUrlOperation<T> = (repos: {
|
|
|
60
58
|
paymentAccepted: PaymentAcceptedRepo;
|
|
61
59
|
paymentService: PaymentServiceRepo;
|
|
62
60
|
paymentServiceProvider: PaymentServiceProviderRepo;
|
|
63
|
-
person: PersonRepo;
|
|
64
61
|
}) => Promise<T>;
|
|
65
62
|
export type IInvalidatePaymentUrlOperation<T> = (repos: {
|
|
66
63
|
accountingReport: AccountingReportRepo;
|
|
@@ -8,7 +8,6 @@ import type { MongoRepository as AssetTransactionRepo } from '../../repo/assetTr
|
|
|
8
8
|
import type { MongoRepository as EventRepo } from '../../repo/event';
|
|
9
9
|
import type { MongoRepository as PaymentServiceRepo } from '../../repo/paymentService';
|
|
10
10
|
import type { MongoRepository as PaymentServiceProviderRepo } from '../../repo/paymentServiceProvider';
|
|
11
|
-
import type { CognitoRepository as PersonRepo } from '../../repo/person';
|
|
12
11
|
import type { MongoRepository as ProductRepo } from '../../repo/product';
|
|
13
12
|
import type { MongoRepository as PaymentAcceptedRepo } from '../../repo/sellerPaymentAccepted';
|
|
14
13
|
import type { MongoRepository as TaskRepo } from '../../repo/task';
|
|
@@ -60,7 +59,6 @@ interface IAuthorizeRepos {
|
|
|
60
59
|
paymentAccepted: PaymentAcceptedRepo;
|
|
61
60
|
paymentService: PaymentServiceRepo;
|
|
62
61
|
paymentServiceProvider: PaymentServiceProviderRepo;
|
|
63
|
-
person: PersonRepo;
|
|
64
62
|
product: ProductRepo;
|
|
65
63
|
task: TaskRepo;
|
|
66
64
|
transaction: TransactionRepo;
|
|
@@ -72,7 +70,6 @@ interface IPublishPaymentUrlRepos {
|
|
|
72
70
|
paymentAccepted: PaymentAcceptedRepo;
|
|
73
71
|
paymentService: PaymentServiceRepo;
|
|
74
72
|
paymentServiceProvider: PaymentServiceProviderRepo;
|
|
75
|
-
person: PersonRepo;
|
|
76
73
|
transaction: TransactionRepo;
|
|
77
74
|
transactionNumber: TransactionNumberRepo;
|
|
78
75
|
}
|
|
@@ -20,7 +20,6 @@ const credentials_1 = require("../../credentials");
|
|
|
20
20
|
const factory = require("../../factory");
|
|
21
21
|
const onPaid_1 = require("./any/onPaid");
|
|
22
22
|
const onRefund_1 = require("./any/onRefund");
|
|
23
|
-
// import { person2username } from './any/person2username';
|
|
24
23
|
const debug = createDebug('chevre-domain:service:payment');
|
|
25
24
|
/**
|
|
26
25
|
* クレジットカード決済承認
|
|
@@ -28,11 +27,6 @@ const debug = createDebug('chevre-domain:service:payment');
|
|
|
28
27
|
function authorize(params, paymentServiceId, options) {
|
|
29
28
|
// tslint:disable-next-line:max-func-body-length
|
|
30
29
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
31
|
-
// const project = <Pick<factory.project.IProject, 'settings'>>await repos.project.findById({
|
|
32
|
-
// id: params.project.id,
|
|
33
|
-
// inclusion: ['settings'],
|
|
34
|
-
// exclusion: []
|
|
35
|
-
// });
|
|
36
30
|
var _a, _b, _c, _d, _e;
|
|
37
31
|
// CreditCard系統の決済方法タイプは動的
|
|
38
32
|
const paymentMethodType = (_a = params.object.paymentMethod) === null || _a === void 0 ? void 0 : _a.identifier;
|
package/package.json
CHANGED
|
@@ -1,87 +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
|
-
const OLD_CLIENT = String(process.env.OLD_CLIENT);
|
|
8
|
-
const NEW_CLIENT = String(process.env.NEW_CLIENT);
|
|
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 eventRepo = await chevre.repository.Event.createInstance(mongoose.connection);
|
|
15
|
-
|
|
16
|
-
const cursor = eventRepo.getCursor(
|
|
17
|
-
{
|
|
18
|
-
'project.id': { $eq: project.id },
|
|
19
|
-
// _id: { $eq: 'als04raei' },
|
|
20
|
-
'offers.seller.makesOffer.availableAtOrFrom.id': { $eq: OLD_CLIENT },
|
|
21
|
-
typeOf: { $eq: chevre.factory.eventType.ScreeningEvent }
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
_id: 1,
|
|
25
|
-
offers: 1,
|
|
26
|
-
project: 1,
|
|
27
|
-
startDate: 1
|
|
28
|
-
}
|
|
29
|
-
);
|
|
30
|
-
console.log('events found');
|
|
31
|
-
|
|
32
|
-
let i = 0;
|
|
33
|
-
let updateCount = 0;
|
|
34
|
-
await cursor.eachAsync(async (doc) => {
|
|
35
|
-
i += 1;
|
|
36
|
-
const event: Pick<
|
|
37
|
-
chevre.factory.event.screeningEvent.IEvent,
|
|
38
|
-
'id' | 'offers' | 'project' | 'startDate'
|
|
39
|
-
> = doc.toObject();
|
|
40
|
-
|
|
41
|
-
const eventOffers = <chevre.factory.event.screeningEvent.IOffer>event.offers;
|
|
42
|
-
const alreadyMigrated = eventOffers.seller.makesOffer.some(
|
|
43
|
-
({ availableAtOrFrom }) => availableAtOrFrom?.some((({ id }) => id === NEW_CLIENT))
|
|
44
|
-
);
|
|
45
|
-
const offerOnOldClient = eventOffers.seller.makesOffer.find(
|
|
46
|
-
({ availableAtOrFrom }) => availableAtOrFrom?.some((({ id }) => id === OLD_CLIENT))
|
|
47
|
-
);
|
|
48
|
-
if (offerOnOldClient === undefined) {
|
|
49
|
-
throw new Error('!oldClientExists');
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
if (alreadyMigrated) {
|
|
53
|
-
await eventRepo.deleteAvailableAtOrFrom({
|
|
54
|
-
id: String(event.id),
|
|
55
|
-
offers: {
|
|
56
|
-
seller: {
|
|
57
|
-
makesOffer: { availableAtOrFrom: { id: OLD_CLIENT } }
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
console.log('already exist.', event.project.id, event.id, event.startDate, i);
|
|
62
|
-
} else {
|
|
63
|
-
const offerNewOldClient: chevre.factory.event.screeningEvent.ISellerMakesOffer = {
|
|
64
|
-
...offerOnOldClient,
|
|
65
|
-
availableAtOrFrom: [{ id: NEW_CLIENT }]
|
|
66
|
-
};
|
|
67
|
-
console.log('updating...', event.project.id, event.id, event.startDate, i);
|
|
68
|
-
await eventRepo.addAvailableAtOrFrom({
|
|
69
|
-
id: String(event.id),
|
|
70
|
-
offers: {
|
|
71
|
-
seller: {
|
|
72
|
-
makesOffer: offerNewOldClient
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
updateCount += 1;
|
|
77
|
-
console.log('updated.', event.project.id, event.id, event.startDate, i);
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
console.log(i, 'offers checked');
|
|
82
|
-
console.log(updateCount, 'offers updated');
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
main()
|
|
86
|
-
.then()
|
|
87
|
-
.catch(console.error);
|
|
@@ -1,63 +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
|
-
const OLD_CLIENT = String(process.env.OLD_CLIENT);
|
|
8
|
-
const NEW_CLIENT = String(process.env.NEW_CLIENT);
|
|
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 offerRepo = await chevre.repository.Offer.createInstance(mongoose.connection);
|
|
15
|
-
|
|
16
|
-
const cursor = offerRepo.getCursor(
|
|
17
|
-
{
|
|
18
|
-
'project.id': { $eq: project.id },
|
|
19
|
-
// _id: { $eq: 'blqm9a6ui' },
|
|
20
|
-
'offers.availableAtOrFrom.id': { $eq: OLD_CLIENT }
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
_id: 1,
|
|
24
|
-
offers: 1,
|
|
25
|
-
project: 1
|
|
26
|
-
}
|
|
27
|
-
);
|
|
28
|
-
console.log('offers found');
|
|
29
|
-
|
|
30
|
-
let i = 0;
|
|
31
|
-
let updateCount = 0;
|
|
32
|
-
await cursor.eachAsync(async (doc) => {
|
|
33
|
-
i += 1;
|
|
34
|
-
const aggregateOffer: chevre.factory.aggregateOffer.IAggregateOffer = doc.toObject();
|
|
35
|
-
|
|
36
|
-
const alreadyMigrated = aggregateOffer.offers[0].availableAtOrFrom?.some(({ id }) => id === NEW_CLIENT);
|
|
37
|
-
console.log(aggregateOffer.offers[0].availableAtOrFrom, i);
|
|
38
|
-
|
|
39
|
-
if (alreadyMigrated) {
|
|
40
|
-
await offerRepo.deleteAvailableAtOrFrom({
|
|
41
|
-
id: String(aggregateOffer.id),
|
|
42
|
-
offers: { availableAtOrFrom: { id: OLD_CLIENT } }
|
|
43
|
-
});
|
|
44
|
-
console.log('already exist.', aggregateOffer.project.id, aggregateOffer.id, i);
|
|
45
|
-
} else {
|
|
46
|
-
console.log('updating...', aggregateOffer.project.id, aggregateOffer.id, i);
|
|
47
|
-
await offerRepo.addAvailableAtOrFrom({
|
|
48
|
-
id: String(aggregateOffer.id),
|
|
49
|
-
identifier: aggregateOffer.offers[0].identifier,
|
|
50
|
-
offers: { availableAtOrFrom: { id: NEW_CLIENT } }
|
|
51
|
-
});
|
|
52
|
-
updateCount += 1;
|
|
53
|
-
console.log('updated.', aggregateOffer.project.id, aggregateOffer.id, i);
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
console.log(i, 'offers checked');
|
|
58
|
-
console.log(updateCount, 'offers updated');
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
main()
|
|
62
|
-
.then()
|
|
63
|
-
.catch(console.error);
|