@chevre/domain 21.2.0-alpha.65 → 21.2.0-alpha.67
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/searchSellers.ts +22 -0
- package/example/src/chevre/transaction/processReturnOrder.ts +40 -0
- package/example/src/playOnMoment.ts +3 -3
- package/lib/chevre/repo/mongoose/schemas/seller.js +6 -0
- package/lib/chevre/repo/seller.js +19 -19
- package/lib/chevre/service/transaction/returnOrder.js +5 -2
- package/package.json +3 -3
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// tslint:disable:no-implicit-dependencies no-console
|
|
2
|
+
import { chevre } from '../../../lib/index';
|
|
3
|
+
|
|
4
|
+
import * as mongoose from 'mongoose';
|
|
5
|
+
|
|
6
|
+
// const project = { id: String(process.env.PROJECT_ID) };
|
|
7
|
+
|
|
8
|
+
async function main() {
|
|
9
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
10
|
+
|
|
11
|
+
const sellerRepo = new chevre.repository.Seller(mongoose.connection);
|
|
12
|
+
const sellers = await sellerRepo.search({
|
|
13
|
+
hasMerchantReturnPolicy: { itemCondition: { id: { $eq: '646dc7848b3c1437d43dbfeb' } } }
|
|
14
|
+
});
|
|
15
|
+
console.log('sellers:', sellers);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
main()
|
|
19
|
+
.then(() => {
|
|
20
|
+
console.log('success!');
|
|
21
|
+
})
|
|
22
|
+
.catch(console.error);
|
|
@@ -0,0 +1,40 @@
|
|
|
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, { autoIndex: false });
|
|
10
|
+
|
|
11
|
+
const result = await chevre.service.transaction.returnOrder.start({
|
|
12
|
+
project: { id: project.id, typeOf: chevre.factory.organizationType.Project },
|
|
13
|
+
expiresInSeconds: 60,
|
|
14
|
+
agent: { id: 'xxx', typeOf: chevre.factory.creativeWorkType.WebApplication },
|
|
15
|
+
object: {
|
|
16
|
+
order: [{
|
|
17
|
+
confirmationNumber: '99916',
|
|
18
|
+
orderNumber: 'TTT2-8507485-9273468'
|
|
19
|
+
}],
|
|
20
|
+
reason: chevre.factory.transaction.returnOrder.Reason.Customer
|
|
21
|
+
},
|
|
22
|
+
seller: {
|
|
23
|
+
id: 'xxx'
|
|
24
|
+
}
|
|
25
|
+
})({
|
|
26
|
+
event: new chevre.repository.Event(mongoose.connection),
|
|
27
|
+
merchantReturnPolicy: new chevre.repository.MerchantReturnPolicy(mongoose.connection),
|
|
28
|
+
offer: new chevre.repository.Offer(mongoose.connection),
|
|
29
|
+
offerItemCondition: new chevre.repository.OfferItemCondition(mongoose.connection),
|
|
30
|
+
order: new chevre.repository.Order(mongoose.connection),
|
|
31
|
+
reservation: new chevre.repository.Reservation(mongoose.connection),
|
|
32
|
+
seller: new chevre.repository.Seller(mongoose.connection),
|
|
33
|
+
transaction: new chevre.repository.Transaction(mongoose.connection)
|
|
34
|
+
});
|
|
35
|
+
console.log(result);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
main()
|
|
39
|
+
.then(console.log)
|
|
40
|
+
.catch(console.error);
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
// tslint:disable:no-console
|
|
2
2
|
import * as moment from 'moment-timezone';
|
|
3
3
|
|
|
4
|
-
const startDate = moment('2023-05-
|
|
4
|
+
const startDate = moment('2023-05-27T00:00:00Z')
|
|
5
5
|
.toDate();
|
|
6
6
|
const gracePeriodBeforeStartInDaysMin = {
|
|
7
7
|
timezone: 'Asia/Tokyo',
|
|
8
|
-
time: '
|
|
9
|
-
period: { value:
|
|
8
|
+
time: '09:38:00',
|
|
9
|
+
period: { value: 3 }
|
|
10
10
|
};
|
|
11
11
|
const returningDate = new Date();
|
|
12
12
|
|
|
@@ -75,3 +75,9 @@ schema.index({ additionalProperty: 1, branchCode: 1 }, {
|
|
|
75
75
|
additionalProperty: { $exists: true }
|
|
76
76
|
}
|
|
77
77
|
});
|
|
78
|
+
schema.index({ 'hasMerchantReturnPolicy.itemCondition.id': 1, branchCode: 1 }, {
|
|
79
|
+
name: 'searchByHasMerchantReturnPolicyItemConditionId',
|
|
80
|
+
partialFilterExpression: {
|
|
81
|
+
'hasMerchantReturnPolicy.itemCondition.id': { $exists: true }
|
|
82
|
+
}
|
|
83
|
+
});
|
|
@@ -32,21 +32,12 @@ class MongoRepository {
|
|
|
32
32
|
}
|
|
33
33
|
// tslint:disable-next-line:max-func-body-length
|
|
34
34
|
static CREATE_MONGO_CONDITIONS(params) {
|
|
35
|
-
var _a, _b, _c, _d, _e, _f;
|
|
35
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
36
36
|
// MongoDB検索条件
|
|
37
37
|
const andConditions = [];
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
if (params.project.id !== undefined && params.project.id !== null) {
|
|
42
|
-
if (typeof params.project.id.$eq === 'string') {
|
|
43
|
-
andConditions.push({
|
|
44
|
-
'project.id': {
|
|
45
|
-
$eq: params.project.id.$eq
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
}
|
|
38
|
+
const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
|
|
39
|
+
if (typeof projectIdEq === 'string') {
|
|
40
|
+
andConditions.push({ 'project.id': { $eq: projectIdEq } });
|
|
50
41
|
}
|
|
51
42
|
const nameRegex = params.name;
|
|
52
43
|
if (typeof nameRegex === 'string' && nameRegex.length > 0) {
|
|
@@ -67,7 +58,7 @@ class MongoRepository {
|
|
|
67
58
|
]
|
|
68
59
|
});
|
|
69
60
|
}
|
|
70
|
-
const branchCodeEq = (
|
|
61
|
+
const branchCodeEq = (_c = params.branchCode) === null || _c === void 0 ? void 0 : _c.$eq;
|
|
71
62
|
if (typeof branchCodeEq === 'string') {
|
|
72
63
|
andConditions.push({
|
|
73
64
|
branchCode: {
|
|
@@ -75,7 +66,7 @@ class MongoRepository {
|
|
|
75
66
|
}
|
|
76
67
|
});
|
|
77
68
|
}
|
|
78
|
-
const branchCodeRegex = (
|
|
69
|
+
const branchCodeRegex = (_d = params.branchCode) === null || _d === void 0 ? void 0 : _d.$regex;
|
|
79
70
|
if (typeof branchCodeRegex === 'string' && branchCodeRegex.length > 0) {
|
|
80
71
|
andConditions.push({
|
|
81
72
|
branchCode: {
|
|
@@ -83,7 +74,7 @@ class MongoRepository {
|
|
|
83
74
|
}
|
|
84
75
|
});
|
|
85
76
|
}
|
|
86
|
-
const additionalPropertyAll = (
|
|
77
|
+
const additionalPropertyAll = (_e = params.additionalProperty) === null || _e === void 0 ? void 0 : _e.$all;
|
|
87
78
|
if (Array.isArray(additionalPropertyAll)) {
|
|
88
79
|
andConditions.push({
|
|
89
80
|
additionalProperty: {
|
|
@@ -92,7 +83,7 @@ class MongoRepository {
|
|
|
92
83
|
}
|
|
93
84
|
});
|
|
94
85
|
}
|
|
95
|
-
const additionalPropertyIn = (
|
|
86
|
+
const additionalPropertyIn = (_f = params.additionalProperty) === null || _f === void 0 ? void 0 : _f.$in;
|
|
96
87
|
if (Array.isArray(additionalPropertyIn)) {
|
|
97
88
|
andConditions.push({
|
|
98
89
|
additionalProperty: {
|
|
@@ -101,7 +92,7 @@ class MongoRepository {
|
|
|
101
92
|
}
|
|
102
93
|
});
|
|
103
94
|
}
|
|
104
|
-
const additionalPropertyNin = (
|
|
95
|
+
const additionalPropertyNin = (_g = params.additionalProperty) === null || _g === void 0 ? void 0 : _g.$nin;
|
|
105
96
|
if (Array.isArray(additionalPropertyNin)) {
|
|
106
97
|
andConditions.push({
|
|
107
98
|
additionalProperty: {
|
|
@@ -109,7 +100,7 @@ class MongoRepository {
|
|
|
109
100
|
}
|
|
110
101
|
});
|
|
111
102
|
}
|
|
112
|
-
const additionalPropertyElemMatch = (
|
|
103
|
+
const additionalPropertyElemMatch = (_h = params.additionalProperty) === null || _h === void 0 ? void 0 : _h.$elemMatch;
|
|
113
104
|
if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
|
|
114
105
|
andConditions.push({
|
|
115
106
|
additionalProperty: {
|
|
@@ -118,6 +109,15 @@ class MongoRepository {
|
|
|
118
109
|
}
|
|
119
110
|
});
|
|
120
111
|
}
|
|
112
|
+
const hasMerchantReturnPolicyItemConditionIdEq = (_l = (_k = (_j = params.hasMerchantReturnPolicy) === null || _j === void 0 ? void 0 : _j.itemCondition) === null || _k === void 0 ? void 0 : _k.id) === null || _l === void 0 ? void 0 : _l.$eq;
|
|
113
|
+
if (typeof hasMerchantReturnPolicyItemConditionIdEq === 'string') {
|
|
114
|
+
andConditions.push({
|
|
115
|
+
'hasMerchantReturnPolicy.itemCondition.id': {
|
|
116
|
+
$exists: true,
|
|
117
|
+
$eq: hasMerchantReturnPolicyItemConditionIdEq
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
121
|
return andConditions;
|
|
122
122
|
}
|
|
123
123
|
/**
|
|
@@ -13,11 +13,13 @@ exports.exportTasksById = exports.confirm = exports.start = void 0;
|
|
|
13
13
|
/**
|
|
14
14
|
* 返品取引サービス
|
|
15
15
|
*/
|
|
16
|
+
const createDebug = require("debug");
|
|
16
17
|
const moment = require("moment-timezone");
|
|
17
18
|
const factory = require("../../factory");
|
|
18
19
|
const factory_1 = require("./returnOrder/exportTasks/factory");
|
|
19
20
|
const potentialActions_1 = require("./returnOrder/potentialActions");
|
|
20
21
|
const errorHandler_1 = require("../../errorHandler");
|
|
22
|
+
const debug = createDebug('chevre-domain:service');
|
|
21
23
|
/**
|
|
22
24
|
* 返品取引開始
|
|
23
25
|
*/
|
|
@@ -310,11 +312,12 @@ function findApplicableReturnPolicy(params) {
|
|
|
310
312
|
.startOf('days')
|
|
311
313
|
.subtract(gracePeriodBeforeStartInDaysMin.period.value, 'days')
|
|
312
314
|
.format('YYYY-MM-DD');
|
|
313
|
-
const returnMaxDate = moment(`${minDate}T${gracePeriodBeforeStartInDaysMin.time}
|
|
314
|
-
|
|
315
|
+
const returnMaxDate = moment.tz(`${minDate}T${gracePeriodBeforeStartInDaysMin.time}`, gracePeriodBeforeStartInDaysMin.timezone);
|
|
316
|
+
debug('returnMaxDate:', returnMaxDate, 'returningDate:', returningDate);
|
|
315
317
|
return returnMaxDate.isSameOrAfter(moment(returningDate));
|
|
316
318
|
});
|
|
317
319
|
}
|
|
320
|
+
debug('satisfyGracePeriodInDaysMin:', satisfyGracePeriodInDaysMin);
|
|
318
321
|
satisfyItemCondition = satisfyGracePeriodMaxValue && satisfyGracePeriodMinValue
|
|
319
322
|
&& satisfyGracePeriodInDaysMax && satisfyGracePeriodInDaysMin;
|
|
320
323
|
}
|
package/package.json
CHANGED
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
}
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@chevre/factory": "4.313.0-alpha.
|
|
13
|
-
"@cinerino/sdk": "3.
|
|
12
|
+
"@chevre/factory": "4.313.0-alpha.10",
|
|
13
|
+
"@cinerino/sdk": "3.157.0-alpha.0",
|
|
14
14
|
"@motionpicture/coa-service": "9.2.0",
|
|
15
15
|
"@motionpicture/gmo-service": "5.2.0",
|
|
16
16
|
"@sendgrid/mail": "6.4.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.2.0-alpha.
|
|
120
|
+
"version": "21.2.0-alpha.67"
|
|
121
121
|
}
|