@chevre/domain 22.8.0-alpha.17 → 22.8.0-alpha.19
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/migrateSellerReturnPolicies.ts +37 -30
- package/example/src/chevre/transaction/processReturnOrder.ts +1 -0
- package/lib/chevre/service/transaction/returnOrder/preStart.d.ts +2 -0
- package/lib/chevre/service/transaction/returnOrder/preStart.js +20 -4
- package/lib/chevre/service/transaction/returnOrder.d.ts +2 -0
- package/package.json +3 -3
|
@@ -37,17 +37,19 @@ async function main() {
|
|
|
37
37
|
alreadyMigrated = true;
|
|
38
38
|
} else {
|
|
39
39
|
for (const policy of hasMerchantReturnPolicy) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
40
|
+
if (policy.restockingFee !== undefined) {
|
|
41
|
+
const existingPolicy = (await sellerReturnPolicyRepo.projectFields(
|
|
42
|
+
{
|
|
43
|
+
limit: 1,
|
|
44
|
+
page: 1,
|
|
45
|
+
project: { id: { $eq: seller.project.id } },
|
|
46
|
+
restockingFee: { value: { $eq: policy.restockingFee.value } }
|
|
47
|
+
},
|
|
48
|
+
['identifier']
|
|
49
|
+
)).shift();
|
|
50
|
+
if (existingPolicy === undefined) {
|
|
51
|
+
alreadyMigrated = false;
|
|
52
|
+
}
|
|
51
53
|
}
|
|
52
54
|
}
|
|
53
55
|
}
|
|
@@ -57,26 +59,31 @@ async function main() {
|
|
|
57
59
|
'already migrated.', seller.id, seller.project.id, i);
|
|
58
60
|
} else {
|
|
59
61
|
if (Array.isArray(hasMerchantReturnPolicy)) {
|
|
60
|
-
const newPolicies: ISavingReturnPolicy[] =
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
typeOf: '
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
62
|
+
const newPolicies: ISavingReturnPolicy[] = [];
|
|
63
|
+
hasMerchantReturnPolicy.forEach((policy) => {
|
|
64
|
+
if (policy.restockingFee !== undefined) {
|
|
65
|
+
newPolicies.push({
|
|
66
|
+
project: { id: seller.project.id, typeOf: chevre.factory.organizationType.Project },
|
|
67
|
+
name: { ja: `${policy.merchantReturnDays}日以内:${policy.restockingFee.value}円` },
|
|
68
|
+
typeOf: 'MerchantReturnPolicy',
|
|
69
|
+
restockingFee: {
|
|
70
|
+
typeOf: 'MonetaryAmount',
|
|
71
|
+
currency: 'JPY',
|
|
72
|
+
value: policy.restockingFee.value
|
|
73
|
+
},
|
|
74
|
+
identifier: `ReturnPolicy${policy.restockingFee.value}in${policy.merchantReturnDays}`,
|
|
75
|
+
merchantReturnDays: policy.merchantReturnDays,
|
|
76
|
+
...(Array.isArray(policy.applicablePaymentMethod))
|
|
77
|
+
? { applicablePaymentMethod: policy.applicablePaymentMethod }
|
|
78
|
+
: undefined,
|
|
79
|
+
...(typeof policy.itemCondition?.id === 'string')
|
|
80
|
+
? { itemCondition: policy.itemCondition }
|
|
81
|
+
: undefined
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
|
|
79
85
|
});
|
|
86
|
+
|
|
80
87
|
for (const newPolicy of newPolicies) {
|
|
81
88
|
const existingPolicy = (await sellerReturnPolicyRepo.projectFields(
|
|
82
89
|
{
|
|
@@ -32,6 +32,7 @@ async function main() {
|
|
|
32
32
|
project: await chevre.repository.Project.createInstance(mongoose.connection),
|
|
33
33
|
reservation: await chevre.repository.Reservation.createInstance(mongoose.connection),
|
|
34
34
|
seller: await chevre.repository.Seller.createInstance(mongoose.connection),
|
|
35
|
+
sellerReturnPolicy: await chevre.repository.SellerReturnPolicy.createInstance(mongoose.connection),
|
|
35
36
|
transaction: await chevre.repository.Transaction.createInstance(mongoose.connection)
|
|
36
37
|
});
|
|
37
38
|
console.log(result);
|
|
@@ -8,6 +8,7 @@ import type { OrderRepo } from '../../../repo/order';
|
|
|
8
8
|
import type { ProjectRepo } from '../../../repo/project';
|
|
9
9
|
import type { ReservationRepo } from '../../../repo/reservation';
|
|
10
10
|
import type { ISellerWithId, SellerRepo } from '../../../repo/seller';
|
|
11
|
+
import type { SellerReturnPolicyRepo } from '../../../repo/sellerReturnPolicy';
|
|
11
12
|
interface IPreStartOperationRepos {
|
|
12
13
|
acceptedOffer: AcceptedOfferRepo;
|
|
13
14
|
event: EventRepo;
|
|
@@ -18,6 +19,7 @@ interface IPreStartOperationRepos {
|
|
|
18
19
|
project: ProjectRepo;
|
|
19
20
|
reservation: ReservationRepo;
|
|
20
21
|
seller: SellerRepo;
|
|
22
|
+
sellerReturnPolicy: SellerReturnPolicyRepo;
|
|
21
23
|
}
|
|
22
24
|
type IPreStartOperation<T> = (repos: IPreStartOperationRepos) => Promise<T>;
|
|
23
25
|
type IFixedSeller = Pick<ISellerWithId, 'id' | 'name' | 'project' | 'hasMerchantReturnPolicy' | 'typeOf'>;
|
|
@@ -24,7 +24,6 @@ exports.preStart = preStart;
|
|
|
24
24
|
const createDebug = require("debug");
|
|
25
25
|
const http_status_1 = require("http-status");
|
|
26
26
|
const moment = require("moment-timezone");
|
|
27
|
-
// import * as request from 'request';
|
|
28
27
|
const factory = require("../../../factory");
|
|
29
28
|
const debug = createDebug('chevre-domain:service');
|
|
30
29
|
/**
|
|
@@ -60,10 +59,27 @@ function preStart(params) {
|
|
|
60
59
|
typeOf: factory.eventType.ScreeningEvent
|
|
61
60
|
}, ['startDate']);
|
|
62
61
|
}
|
|
63
|
-
|
|
64
|
-
if (
|
|
65
|
-
|
|
62
|
+
const returnPolicies = [];
|
|
63
|
+
if (Array.isArray(seller.hasMerchantReturnPolicy)) {
|
|
64
|
+
for (const policy of seller.hasMerchantReturnPolicy) {
|
|
65
|
+
if (policy.restockingFee !== undefined) {
|
|
66
|
+
returnPolicies.push(policy);
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
// support sellerReturnPolicyRepo(2025-01-19~)
|
|
70
|
+
const sellerReturnPolicy = (yield repos.sellerReturnPolicy.projectFields({
|
|
71
|
+
limit: 1,
|
|
72
|
+
page: 1,
|
|
73
|
+
project: { id: { $eq: seller.project.id } },
|
|
74
|
+
identifier: { $eq: policy.identifier }
|
|
75
|
+
}, ['applicablePaymentMethod', 'identifier', 'itemCondition', 'merchantReturnDays', 'restockingFee', 'typeOf'])).shift();
|
|
76
|
+
if (sellerReturnPolicy !== undefined) {
|
|
77
|
+
returnPolicies.push(sellerReturnPolicy);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
66
81
|
}
|
|
82
|
+
debug('returnOrder.preStart: returnPolicies:', JSON.stringify(returnPolicies));
|
|
67
83
|
// アイテムコンディション取得
|
|
68
84
|
let offerItemConditions = [];
|
|
69
85
|
const itemConditionIds = returnPolicies
|
|
@@ -10,6 +10,7 @@ import type { OrderRepo } from '../../repo/order';
|
|
|
10
10
|
import type { ProjectRepo } from '../../repo/project';
|
|
11
11
|
import type { ReservationRepo } from '../../repo/reservation';
|
|
12
12
|
import type { SellerRepo } from '../../repo/seller';
|
|
13
|
+
import type { SellerReturnPolicyRepo } from '../../repo/sellerReturnPolicy';
|
|
13
14
|
import type { SettingRepo } from '../../repo/setting';
|
|
14
15
|
import type { TaskRepo } from '../../repo/task';
|
|
15
16
|
import type { IStartedTransaction, TransactionRepo } from '../../repo/transaction';
|
|
@@ -24,6 +25,7 @@ interface IStartOperationRepos {
|
|
|
24
25
|
project: ProjectRepo;
|
|
25
26
|
reservation: ReservationRepo;
|
|
26
27
|
seller: SellerRepo;
|
|
28
|
+
sellerReturnPolicy: SellerReturnPolicyRepo;
|
|
27
29
|
transaction: TransactionRepo;
|
|
28
30
|
}
|
|
29
31
|
type IStartOperation<T> = (repos: IStartOperationRepos) => Promise<T>;
|
package/package.json
CHANGED
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@aws-sdk/client-cognito-identity-provider": "3.600.0",
|
|
13
13
|
"@aws-sdk/credential-providers": "3.600.0",
|
|
14
|
-
"@chevre/factory": "4.392.0-alpha.
|
|
15
|
-
"@cinerino/sdk": "10.20.0-alpha.
|
|
14
|
+
"@chevre/factory": "4.392.0-alpha.12",
|
|
15
|
+
"@cinerino/sdk": "10.20.0-alpha.8",
|
|
16
16
|
"@motionpicture/coa-service": "9.6.0",
|
|
17
17
|
"@motionpicture/gmo-service": "5.3.0",
|
|
18
18
|
"@sendgrid/mail": "6.4.0",
|
|
@@ -112,5 +112,5 @@
|
|
|
112
112
|
"postversion": "git push origin --tags",
|
|
113
113
|
"prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
|
|
114
114
|
},
|
|
115
|
-
"version": "22.8.0-alpha.
|
|
115
|
+
"version": "22.8.0-alpha.19"
|
|
116
116
|
}
|