@chevre/domain 21.6.0-alpha.9 → 21.6.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.
@@ -1,5 +1,5 @@
1
1
  // tslint:disable:no-console
2
- import * as moment from 'moment';
2
+ import * as moment from 'moment-timezone';
3
3
  import * as mongoose from 'mongoose';
4
4
 
5
5
  import { chevre } from '../../../lib/index';
@@ -15,7 +15,7 @@ async function main() {
15
15
 
16
16
  const cursor = creativeWorkRepo.getCursor(
17
17
  {
18
- 'offers.availabilityEnds': { $exists: true }
18
+ // 'offers.availabilityEnds': { $exists: true }
19
19
  },
20
20
  {}
21
21
  );
@@ -23,8 +23,8 @@ async function main() {
23
23
 
24
24
  let i = 0;
25
25
  let updateCount = 0;
26
- let datePublishedUndefinedCount = 0;
27
- let datePublishedIsAfterNowCount = 0;
26
+ // let datePublishedUndefinedCount = 0;
27
+ // let datePublishedIsAfterNowCount = 0;
28
28
  await cursor.eachAsync(async (doc) => {
29
29
  i += 1;
30
30
  const movie: chevre.factory.creativeWork.movie.ICreativeWork = doc.toObject();
@@ -35,30 +35,32 @@ async function main() {
35
35
  if (!(createdAt instanceof Date)) {
36
36
  throw new Error('createdAt not Date');
37
37
  }
38
- const alreadyMigrated = availabilityStarts instanceof Date;
38
+ const alreadyMigrated = availabilityStarts instanceof Date
39
+ && moment(availabilityStarts)
40
+ .isSame(moment(createdAt)
41
+ .tz('Asia/Tokyo')
42
+ .startOf('day')
43
+ );
39
44
 
40
45
  if (alreadyMigrated) {
41
- console.log('already exist...', movie.project.id, movie.id, movie.identifier, availabilityStarts, availabilityEnds, i);
46
+ console.log(
47
+ 'already exist...', movie.project.id, movie.id, movie.identifier, availabilityStarts, availabilityEnds, createdAt, i);
42
48
 
43
- if (moment(movie.datePublished)
44
- .isAfter(moment())) {
45
- datePublishedIsAfterNowCount += 1;
46
- // tslint:disable-next-line:max-line-length
47
- // throw new Error(`movie.datePublished isAfter now ${movie.project.id} ${movie.id} ${movie.identifier} ${movie.datePublished}`);
48
-
49
- }
49
+ // if (moment(movie.datePublished)
50
+ // .isAfter(moment())) {
51
+ // datePublishedIsAfterNowCount += 1;
52
+ // }
50
53
  } else {
51
- if (movie.datePublished === undefined) {
52
- console.error('movie.datePublished undefined', movie.project.id, movie.id, movie.identifier, i);
53
- // throw new Error('movie.datePublished undefined');
54
- datePublishedUndefinedCount += 1;
55
- }
54
+ // if (movie.datePublished === undefined) {
55
+ // console.error('movie.datePublished undefined', movie.project.id, movie.id, movie.identifier, i);
56
+ // // throw new Error('movie.datePublished undefined');
57
+ // datePublishedUndefinedCount += 1;
58
+ // }
56
59
 
57
- availabilityStarts = (movie.datePublished !== undefined)
58
- ? moment(movie.datePublished)
59
- .toDate()
60
- : moment(createdAt)
61
- .toDate();
60
+ availabilityStarts = moment(createdAt)
61
+ .tz('Asia/Tokyo')
62
+ .startOf('day')
63
+ .toDate();
62
64
  console.log('updating movie...', movie.project.id, movie.id, movie.identifier, availabilityStarts, availabilityEnds, i);
63
65
  await creativeWorkRepo.saveMovie(<any>{
64
66
  id: String(movie.id),
@@ -71,8 +73,8 @@ async function main() {
71
73
 
72
74
  console.log(i, 'creativeWorks checked');
73
75
  console.log(updateCount, 'creativeWorks updated');
74
- console.log(datePublishedUndefinedCount, 'datePublishedUndefinedCount');
75
- console.log(datePublishedIsAfterNowCount, 'datePublishedIsAfterNowCount');
76
+ // console.log(datePublishedUndefinedCount, 'datePublishedUndefinedCount');
77
+ // console.log(datePublishedIsAfterNowCount, 'datePublishedIsAfterNowCount');
76
78
 
77
79
  }
78
80
 
@@ -0,0 +1,28 @@
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: true });
10
+
11
+ const sellerRepo = new chevre.repository.Seller(mongoose.connection);
12
+
13
+ const sellers = await sellerRepo.search(
14
+ {
15
+ project: { id: { $eq: project.id } },
16
+ paymentAccepted: { paymentMethodType: { $eq: 'Cash' } },
17
+ hasMerchantReturnPolicy: { applicablePaymentMethod: {} }
18
+ },
19
+ ['name'],
20
+ []
21
+ );
22
+ console.log('sellers found', sellers);
23
+ console.log(sellers.length, 'sellers found');
24
+ }
25
+
26
+ main()
27
+ .then()
28
+ .catch(console.error);
@@ -55,18 +55,15 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
55
55
  typeOf: string;
56
56
  name?: any;
57
57
  project?: any;
58
- alternateName?: string | undefined;
59
58
  description?: string | undefined;
60
59
  additionalProperty?: any;
61
60
  identifier?: string | undefined;
62
61
  duration?: string | undefined;
63
62
  alternativeHeadline?: string | undefined;
64
- copyrightHolder?: any;
65
63
  copyrightYear?: number | undefined;
66
64
  datePublished?: Date | undefined;
67
65
  distributor?: any;
68
66
  headline?: string | undefined;
69
- license?: string | undefined;
70
67
  thumbnailUrl?: string | undefined;
71
68
  contentRating?: string | undefined;
72
69
  offers?: any;
@@ -74,18 +71,15 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
74
71
  typeOf: string;
75
72
  name?: any;
76
73
  project?: any;
77
- alternateName?: string | undefined;
78
74
  description?: string | undefined;
79
75
  additionalProperty?: any;
80
76
  identifier?: string | undefined;
81
77
  duration?: string | undefined;
82
78
  alternativeHeadline?: string | undefined;
83
- copyrightHolder?: any;
84
79
  copyrightYear?: number | undefined;
85
80
  datePublished?: Date | undefined;
86
81
  distributor?: any;
87
82
  headline?: string | undefined;
88
- license?: string | undefined;
89
83
  thumbnailUrl?: string | undefined;
90
84
  contentRating?: string | undefined;
91
85
  offers?: any;
@@ -93,18 +87,15 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
93
87
  typeOf: string;
94
88
  name?: any;
95
89
  project?: any;
96
- alternateName?: string | undefined;
97
90
  description?: string | undefined;
98
91
  additionalProperty?: any;
99
92
  identifier?: string | undefined;
100
93
  duration?: string | undefined;
101
94
  alternativeHeadline?: string | undefined;
102
- copyrightHolder?: any;
103
95
  copyrightYear?: number | undefined;
104
96
  datePublished?: Date | undefined;
105
97
  distributor?: any;
106
98
  headline?: string | undefined;
107
- license?: string | undefined;
108
99
  thumbnailUrl?: string | undefined;
109
100
  contentRating?: string | undefined;
110
101
  offers?: any;
@@ -16,15 +16,15 @@ const schema = new mongoose_1.Schema({
16
16
  },
17
17
  identifier: String,
18
18
  name: mongoose_1.SchemaTypes.Mixed,
19
- alternateName: String,
19
+ // alternateName: String,
20
20
  alternativeHeadline: String,
21
21
  description: String,
22
- copyrightHolder: mongoose_1.SchemaTypes.Mixed,
22
+ // copyrightHolder: SchemaTypes.Mixed,
23
23
  copyrightYear: Number,
24
24
  datePublished: Date,
25
25
  distributor: mongoose_1.SchemaTypes.Mixed,
26
26
  headline: String,
27
- license: String,
27
+ // license: String,
28
28
  thumbnailUrl: String,
29
29
  duration: String,
30
30
  contentRating: String,
@@ -75,6 +75,18 @@ schema.index({ additionalProperty: 1, branchCode: 1 }, {
75
75
  additionalProperty: { $exists: true }
76
76
  }
77
77
  });
78
+ schema.index({ 'paymentAccepted.paymentMethodType': 1, branchCode: 1 }, {
79
+ name: 'searchByPaymentAccepted',
80
+ partialFilterExpression: {
81
+ 'paymentAccepted.paymentMethodType': { $exists: true }
82
+ }
83
+ });
84
+ schema.index({ 'hasMerchantReturnPolicy.applicablePaymentMethod': 1, branchCode: 1 }, {
85
+ name: 'searchByHasMerchantReturnPolicyApplicablePaymentMethod',
86
+ partialFilterExpression: {
87
+ 'hasMerchantReturnPolicy.applicablePaymentMethod': { $exists: true }
88
+ }
89
+ });
78
90
  schema.index({ 'hasMerchantReturnPolicy.itemCondition.id': 1, branchCode: 1 }, {
79
91
  name: 'searchByHasMerchantReturnPolicyItemConditionId',
80
92
  partialFilterExpression: {
@@ -34,7 +34,7 @@ class MongoRepository {
34
34
  }
35
35
  // tslint:disable-next-line:max-func-body-length
36
36
  static CREATE_MONGO_CONDITIONS(params) {
37
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
37
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
38
38
  // MongoDB検索条件
39
39
  const andConditions = [];
40
40
  const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
@@ -120,7 +120,19 @@ class MongoRepository {
120
120
  }
121
121
  });
122
122
  }
123
- const hasMerchantReturnPolicyItemConditionIdEq = (_q = (_p = (_o = params.hasMerchantReturnPolicy) === null || _o === void 0 ? void 0 : _o.itemCondition) === null || _p === void 0 ? void 0 : _p.id) === null || _q === void 0 ? void 0 : _q.$eq;
123
+ const paymentAcceptedEq = (_p = (_o = params.paymentAccepted) === null || _o === void 0 ? void 0 : _o.paymentMethodType) === null || _p === void 0 ? void 0 : _p.$eq;
124
+ if (typeof paymentAcceptedEq === 'string') {
125
+ andConditions.push({
126
+ 'paymentAccepted.paymentMethodType': { $exists: true, $eq: paymentAcceptedEq }
127
+ });
128
+ }
129
+ const hasMerchantReturnApplicablePaymentMethodEq = (_r = (_q = params.hasMerchantReturnPolicy) === null || _q === void 0 ? void 0 : _q.applicablePaymentMethod) === null || _r === void 0 ? void 0 : _r.$eq;
130
+ if (typeof hasMerchantReturnApplicablePaymentMethodEq === 'string') {
131
+ andConditions.push({
132
+ 'hasMerchantReturnPolicy.applicablePaymentMethod': { $exists: true, $eq: hasMerchantReturnApplicablePaymentMethodEq }
133
+ });
134
+ }
135
+ const hasMerchantReturnPolicyItemConditionIdEq = (_u = (_t = (_s = params.hasMerchantReturnPolicy) === null || _s === void 0 ? void 0 : _s.itemCondition) === null || _t === void 0 ? void 0 : _t.id) === null || _u === void 0 ? void 0 : _u.$eq;
124
136
  if (typeof hasMerchantReturnPolicyItemConditionIdEq === 'string') {
125
137
  andConditions.push({
126
138
  'hasMerchantReturnPolicy.itemCondition.id': {
@@ -6,7 +6,7 @@ exports.createStartParams = void 0;
6
6
  */
7
7
  const factory = require("../../../factory");
8
8
  function createStartParams(params) {
9
- var _a, _b, _c, _d, _e, _f;
9
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
10
10
  const paymentMethodType = (_a = params.object.paymentMethod) === null || _a === void 0 ? void 0 : _a.typeOf;
11
11
  if (typeof paymentMethodType !== 'string') {
12
12
  throw new factory.errors.ArgumentNull('object.paymentMethod.typeOf');
@@ -19,6 +19,17 @@ function createStartParams(params) {
19
19
  const name = (_d = params.object.paymentMethod) === null || _d === void 0 ? void 0 : _d.name;
20
20
  const informPaymentParams = createInformPaymentParams({ paymentService: params.paymentService });
21
21
  const accountId = (_f = (_e = params.payAction.object[0]) === null || _e === void 0 ? void 0 : _e.paymentMethod) === null || _f === void 0 ? void 0 : _f.accountId;
22
+ // 手数料は、CreditCardIFかつカード通貨区分が存在しない場合のみ設定すればよい
23
+ let refundFee;
24
+ if (((_g = params.paymentService) === null || _g === void 0 ? void 0 : _g.typeOf) === factory.service.paymentService.PaymentServiceType.CreditCard) {
25
+ // カード通貨区分の存在する決済サービスを考慮(2023-08-09~)
26
+ const paymentServiceOutputAmountCurrency = (_j = (_h = params.paymentService.serviceOutput) === null || _h === void 0 ? void 0 : _h.amount) === null || _j === void 0 ? void 0 : _j.currency;
27
+ if (typeof paymentServiceOutputAmountCurrency !== 'string') {
28
+ if (typeof params.object.refundFee === 'number') {
29
+ refundFee = params.object.refundFee;
30
+ }
31
+ }
32
+ }
22
33
  return {
23
34
  project: { typeOf: factory.organizationType.Project, id: params.project.id },
24
35
  transactionNumber: params.transactionNumber,
@@ -29,9 +40,7 @@ function createStartParams(params) {
29
40
  ? params.payAction.object[0].id
30
41
  : '', onPaymentStatusChanged: { informPayment: informPaymentParams }, paymentMethod: Object.assign({ additionalProperty: (Array.isArray(additionalProperty)) ? additionalProperty : [], name: (typeof name === 'string') ? name : paymentMethodType, paymentMethodId: paymentMethodId, typeOf: paymentMethodType }, (Array.isArray(params.payAction.object) && params.payAction.object.length > 0)
31
42
  ? { totalPaymentDue: params.payAction.object[0].paymentMethod.totalPaymentDue }
32
- : undefined) }, (typeof params.object.refundFee === 'number')
33
- ? { refundFee: params.object.refundFee }
34
- : undefined),
43
+ : undefined) }, (typeof refundFee === 'number') ? { refundFee } : undefined),
35
44
  expires: params.expires
36
45
  };
37
46
  }
@@ -211,11 +211,15 @@ function validateNumItems(params) {
211
211
  }
212
212
  exports.validateNumItems = validateNumItems;
213
213
  function validatePaymentMethods(params) {
214
- debug('processing validatePaymentMethods...maxNumCreditCardPaymentMethod:', settings_1.settings.maxNumCreditCardPaymentMethod);
215
214
  if (typeof settings_1.settings.maxNumCreditCardPaymentMethod === 'number') {
216
215
  // CreditCard IFの決済方法の最大値検証
217
- const creditCardPaymentMethodCount = params.order.paymentMethods.filter((p) => p.issuedThrough.typeOf === factory.service.paymentService.PaymentServiceType.CreditCard).length;
218
- debug('processing validatePaymentMethods...creditCardPaymentMethodCount:', creditCardPaymentMethodCount);
216
+ const creditCardPaymentMethodCount = params.order.paymentMethods.filter((p) => {
217
+ var _a, _b;
218
+ // カード通貨区分の存在する決済サービスを考慮(2023-08-09~)
219
+ const serviceOutputAmountCurrency = (_b = (_a = p.issuedThrough.serviceOutput) === null || _a === void 0 ? void 0 : _a.amount) === null || _b === void 0 ? void 0 : _b.currency;
220
+ return p.issuedThrough.typeOf === factory.service.paymentService.PaymentServiceType.CreditCard
221
+ && typeof serviceOutputAmountCurrency !== 'string';
222
+ }).length;
219
223
  if (creditCardPaymentMethodCount > settings_1.settings.maxNumCreditCardPaymentMethod) {
220
224
  throw new factory.errors.Argument('Transaction', (0, util_1.format)(`Number of paymentMethods issued through ${factory.service.paymentService.PaymentServiceType.CreditCard} payment service must be less than equal to %s`, settings_1.settings.maxNumCreditCardPaymentMethod));
221
225
  }
package/package.json CHANGED
@@ -9,8 +9,8 @@
9
9
  }
10
10
  ],
11
11
  "dependencies": {
12
- "@chevre/factory": "4.324.0-alpha.5",
13
- "@cinerino/sdk": "3.162.3",
12
+ "@chevre/factory": "4.324.0",
13
+ "@cinerino/sdk": "3.163.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.6.0-alpha.9"
120
+ "version": "21.6.0"
121
121
  }