@chevre/domain 25.0.0-alpha.12 → 25.0.0-alpha.13
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.
|
@@ -26,7 +26,7 @@ const schemaDefinition = {
|
|
|
26
26
|
orderDate: { type: Date, required: true },
|
|
27
27
|
dateReturned: Date,
|
|
28
28
|
orderedItem: [mongoose_1.SchemaTypes.Mixed],
|
|
29
|
-
identifier: String, // 注文取引IDとして再定義(2026-06-22~)
|
|
29
|
+
identifier: { type: String, required: true }, // 注文取引IDとして再定義(2026-06-22~)
|
|
30
30
|
// 以下廃止(2026-06-13~)
|
|
31
31
|
// identifier: SchemaTypes.Mixed, // 廃止するためにMixed化(2026-06-12~)
|
|
32
32
|
// isGift: Boolean,
|
|
@@ -115,21 +115,23 @@ class OrderInTransactionRepo extends acceptedOfferInReserve_1.AcceptedOfferInRes
|
|
|
115
115
|
if (!Array.isArray(params.acceptedOffers) || params.acceptedOffers.length === 0) {
|
|
116
116
|
return;
|
|
117
117
|
}
|
|
118
|
-
const
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
118
|
+
const { orderNumber, project, identifier } = params;
|
|
119
|
+
await this.createPlaceOrderIfNotExists({ orderNumber, project, identifier });
|
|
120
|
+
// const setOnInsert: IInitalOrderInTransaction = {
|
|
121
|
+
// typeOf: factory.transactionType.PlaceOrder,
|
|
122
|
+
// orderDate: new Date(), // orderDate required(2024-12-09~)
|
|
123
|
+
// orderNumber: params.orderNumber,
|
|
124
|
+
// project: params.project,
|
|
125
|
+
// identifier: params.identifier // 取引ID(2026-06-22~)
|
|
126
|
+
// };
|
|
127
|
+
const result = await this.orderModel.updateOne({
|
|
126
128
|
typeOf: { $eq: factory_1.factory.transactionType.PlaceOrder },
|
|
127
129
|
orderNumber: { $eq: params.orderNumber },
|
|
128
130
|
// プロジェクトでもフィルター(注文番号重複バグがあったため)(2026-02-21~)
|
|
129
131
|
// 万が一異なるプロジェクトで同じ注文番号でオファーを受け入れようとしても、DBにインデックスによってDuplicateKey
|
|
130
132
|
'project.id': { $eq: params.project.id }
|
|
131
133
|
}, {
|
|
132
|
-
$setOnInsert: setOnInsert,
|
|
134
|
+
// $setOnInsert: setOnInsert, // createPlaceOrderIfNotExistsへ移行(2026-06-24~)
|
|
133
135
|
$push: {
|
|
134
136
|
acceptedOffers: {
|
|
135
137
|
$each: params.acceptedOffers
|
|
@@ -140,8 +142,15 @@ class OrderInTransactionRepo extends acceptedOfferInReserve_1.AcceptedOfferInRes
|
|
|
140
142
|
broker: { id: params.broker.id, typeOf: params.broker.typeOf }
|
|
141
143
|
}) // set broker(2026-06-21~)
|
|
142
144
|
}
|
|
143
|
-
}, {
|
|
145
|
+
}, {
|
|
146
|
+
// upsert: true // createPlaceOrderIfNotExistsへ移行(2026-06-24~)
|
|
147
|
+
})
|
|
144
148
|
.exec();
|
|
149
|
+
if (result.matchedCount !== 1) {
|
|
150
|
+
console.error(params, result);
|
|
151
|
+
throw new factory_1.factory.errors.Internal(`orderInTransaction not found`);
|
|
152
|
+
}
|
|
153
|
+
return result;
|
|
145
154
|
}
|
|
146
155
|
/**
|
|
147
156
|
* serialNumberからオファーを除外する
|
|
@@ -181,7 +190,7 @@ class OrderInTransactionRepo extends acceptedOfferInReserve_1.AcceptedOfferInRes
|
|
|
181
190
|
}
|
|
182
191
|
}
|
|
183
192
|
async setCustomer(params) {
|
|
184
|
-
const { customer, orderNumber, project } = params;
|
|
193
|
+
const { customer, orderNumber, project, identifier } = params;
|
|
185
194
|
const filter = {
|
|
186
195
|
typeOf: { $eq: factory_1.factory.transactionType.PlaceOrder },
|
|
187
196
|
orderNumber: { $eq: orderNumber },
|
|
@@ -189,19 +198,27 @@ class OrderInTransactionRepo extends acceptedOfferInReserve_1.AcceptedOfferInRes
|
|
|
189
198
|
// 万が一異なるプロジェクトで同じ注文番号でオファーを受け入れようとしても、DBにインデックスによってDuplicateKey
|
|
190
199
|
'project.id': { $eq: project.id }
|
|
191
200
|
};
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
201
|
+
await this.createPlaceOrderIfNotExists({ orderNumber, project, identifier });
|
|
202
|
+
// const setOnInsert: IInitalOrderInTransaction = {
|
|
203
|
+
// typeOf: factory.transactionType.PlaceOrder,
|
|
204
|
+
// orderDate: new Date(), // orderDate required(2024-12-09~)
|
|
205
|
+
// orderNumber,
|
|
206
|
+
// project,
|
|
207
|
+
// identifier: params.identifier // 取引ID(2026-06-22~)
|
|
208
|
+
// };
|
|
199
209
|
const setKeys = { customer };
|
|
200
|
-
|
|
201
|
-
$setOnInsert: setOnInsert,
|
|
210
|
+
const result = await this.orderModel.updateOne(filter, {
|
|
211
|
+
// $setOnInsert: setOnInsert, // createPlaceOrderIfNotExistsへ移行(2026-06-24~)
|
|
202
212
|
$set: setKeys
|
|
203
|
-
}, {
|
|
213
|
+
}, {
|
|
214
|
+
// upsert: true // createPlaceOrderIfNotExistsへ移行(2026-06-24~)
|
|
215
|
+
})
|
|
204
216
|
.exec();
|
|
217
|
+
if (result.matchedCount !== 1) {
|
|
218
|
+
console.error(params, result);
|
|
219
|
+
throw new factory_1.factory.errors.Internal(`orderInTransaction not found`);
|
|
220
|
+
}
|
|
221
|
+
return result;
|
|
205
222
|
}
|
|
206
223
|
/**
|
|
207
224
|
* 注文ドキュメントからcustomer属性を参照する
|
package/package.json
CHANGED