ts-glitter 18.9.7 → 18.9.9
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/lowcode/Entry.js +2 -2
- package/lowcode/Entry.ts +2 -2
- package/lowcode/cms-plugin/filter-options.js +57 -0
- package/lowcode/cms-plugin/filter-options.ts +66 -0
- package/lowcode/cms-plugin/module/order-excel.js +216 -5
- package/lowcode/cms-plugin/module/order-excel.ts +229 -5
- package/lowcode/cms-plugin/reconciliation-area.js +48 -78
- package/lowcode/cms-plugin/reconciliation-area.ts +50 -71
- package/lowcode/glitter-base/route/shopping.js +5 -0
- package/lowcode/glitter-base/route/shopping.ts +1509 -1499
- package/lowcode/jspage/index.js +1 -1
- package/lowcode/jspage/index.ts +1 -1
- package/lowcode/public-components/ai/ai-search.js +1 -1
- package/lowcode/public-components/ai/ai-search.ts +1 -1
- package/lowcode/public-models/order-info.js +65 -0
- package/lowcode/public-models/order-info.ts +66 -0
- package/package.json +1 -1
- package/src/api-public/controllers/shop.js +2 -0
- package/src/api-public/controllers/shop.js.map +1 -1
- package/src/api-public/controllers/shop.ts +2 -0
- package/src/api-public/services/data-analyze.d.ts +1 -1
- package/src/api-public/services/reconciliation.js +1 -1
- package/src/api-public/services/reconciliation.js.map +1 -1
- package/src/api-public/services/reconciliation.ts +1 -1
- package/src/api-public/services/shopping.d.ts +2 -0
- package/src/api-public/services/shopping.js +35 -6
- package/src/api-public/services/shopping.js.map +1 -1
- package/src/api-public/services/shopping.ts +37 -6
package/lowcode/Entry.js
CHANGED
|
@@ -132,7 +132,7 @@ export class Entry {
|
|
|
132
132
|
}
|
|
133
133
|
window.renderClock = (_b = window.renderClock) !== null && _b !== void 0 ? _b : createClock();
|
|
134
134
|
console.log(`Entry-time:`, window.renderClock.stop());
|
|
135
|
-
glitter.share.editerVersion = 'V_18.9.
|
|
135
|
+
glitter.share.editerVersion = 'V_18.9.9';
|
|
136
136
|
glitter.share.start = new Date();
|
|
137
137
|
const vm = { appConfig: [] };
|
|
138
138
|
window.saasConfig = {
|
|
@@ -350,7 +350,7 @@ export class Entry {
|
|
|
350
350
|
'assets/vendor/smooth-scroll/dist/smooth-scroll.polyfills.min.js',
|
|
351
351
|
'assets/vendor/swiper/swiper-bundle.min.js',
|
|
352
352
|
'assets/js/theme.min.js',
|
|
353
|
-
|
|
353
|
+
`${glitter.root_path}/jslib/lottie-player.js`,
|
|
354
354
|
], () => resolve(true), () => resolve(true));
|
|
355
355
|
});
|
|
356
356
|
return;
|
package/lowcode/Entry.ts
CHANGED
|
@@ -132,7 +132,7 @@ export class Entry {
|
|
|
132
132
|
}
|
|
133
133
|
(window as any).renderClock = (window as any).renderClock ?? createClock();
|
|
134
134
|
console.log(`Entry-time:`, (window as any).renderClock.stop());
|
|
135
|
-
glitter.share.editerVersion = 'V_18.9.
|
|
135
|
+
glitter.share.editerVersion = 'V_18.9.9';
|
|
136
136
|
glitter.share.start = new Date();
|
|
137
137
|
const vm = { appConfig: [] };
|
|
138
138
|
(window as any).saasConfig = {
|
|
@@ -361,7 +361,7 @@ export class Entry {
|
|
|
361
361
|
'assets/vendor/smooth-scroll/dist/smooth-scroll.polyfills.min.js',
|
|
362
362
|
'assets/vendor/swiper/swiper-bundle.min.js',
|
|
363
363
|
'assets/js/theme.min.js',
|
|
364
|
-
|
|
364
|
+
`${ glitter.root_path}/jslib/lottie-player.js`,
|
|
365
365
|
],
|
|
366
366
|
() => resolve(true),
|
|
367
367
|
() => resolve(true),
|
|
@@ -137,6 +137,7 @@ export class FilterOptions {
|
|
|
137
137
|
return [
|
|
138
138
|
{ key: 'orderStatus', type: 'multi_checkbox', name: '訂單狀態', data: this.orderStatusOptions },
|
|
139
139
|
{ key: 'payload', type: 'multi_checkbox', name: '付款狀態', data: this.payloadStatusOptions },
|
|
140
|
+
{ key: 'reconciliation_status', type: 'multi_checkbox', name: '對帳狀態', data: this.reconciliationOptions },
|
|
140
141
|
{ key: 'payment_select', type: 'multi_checkbox', name: '付款方式', data: (yield PaymentConfig.getSupportPayment()).map((dd) => {
|
|
141
142
|
if (dd.type === 'pos' && !(dd.name.includes('POS'))) {
|
|
142
143
|
const name = dd.name;
|
|
@@ -173,6 +174,53 @@ export class FilterOptions {
|
|
|
173
174
|
];
|
|
174
175
|
});
|
|
175
176
|
}
|
|
177
|
+
static getReconciliationFunnel() {
|
|
178
|
+
var _a, _b;
|
|
179
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
180
|
+
const saasConfig = window.parent.saasConfig;
|
|
181
|
+
const response = yield saasConfig.api.getPrivateConfig(saasConfig.config.appName, 'logistics_setting');
|
|
182
|
+
let configData = ((_a = response.response.result[0]) === null || _a === void 0 ? void 0 : _a.value) || {};
|
|
183
|
+
if (!configData.language_data) {
|
|
184
|
+
configData.language_data = {
|
|
185
|
+
'en-US': { info: '' },
|
|
186
|
+
'zh-CN': { info: '' },
|
|
187
|
+
'zh-TW': { info: configData.info || '' },
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
const shipmentOptions = ShipmentConfig.list
|
|
191
|
+
.map(dd => {
|
|
192
|
+
return { key: dd.value, name: dd.title };
|
|
193
|
+
})
|
|
194
|
+
.concat(((_b = configData.custom_delivery) !== null && _b !== void 0 ? _b : []).map((dd) => {
|
|
195
|
+
return { key: dd.id, name: dd.name };
|
|
196
|
+
}));
|
|
197
|
+
return [
|
|
198
|
+
{ key: 'orderStatus', type: 'multi_checkbox', name: '訂單狀態', data: this.orderStatusOptions },
|
|
199
|
+
{ key: 'reconciliation_status', type: 'multi_checkbox', name: '對帳狀態', data: this.reconciliationOptions },
|
|
200
|
+
{ key: 'payment_select', type: 'multi_checkbox', name: '付款方式', data: (yield PaymentConfig.getSupportPayment()).map((dd) => {
|
|
201
|
+
if (dd.type === 'pos' && !(dd.name.includes('POS'))) {
|
|
202
|
+
const name = dd.name;
|
|
203
|
+
dd.name = `<div class="d-flex">${[BgWidget.warningInsignia('POS'), name].join(`<div class="mx-1"></div>`)}</div>`;
|
|
204
|
+
}
|
|
205
|
+
return dd;
|
|
206
|
+
}) },
|
|
207
|
+
{ key: 'progress', type: 'multi_checkbox', name: '出貨狀況', data: this.progressOptions },
|
|
208
|
+
{ key: 'shipment', type: 'multi_checkbox', name: '運送方式', data: shipmentOptions },
|
|
209
|
+
{
|
|
210
|
+
key: 'shipment_time',
|
|
211
|
+
type: 'during',
|
|
212
|
+
name: '出貨日期',
|
|
213
|
+
data: {
|
|
214
|
+
centerText: '至',
|
|
215
|
+
list: [
|
|
216
|
+
{ key: 'start', type: 'date', placeHolder: '請選擇開始時間' },
|
|
217
|
+
{ key: 'end', type: 'date', placeHolder: '請選擇結束時間' },
|
|
218
|
+
],
|
|
219
|
+
},
|
|
220
|
+
},
|
|
221
|
+
];
|
|
222
|
+
});
|
|
223
|
+
}
|
|
176
224
|
}
|
|
177
225
|
FilterOptions.userFilterFrame = {
|
|
178
226
|
created_time: ['', ''],
|
|
@@ -205,6 +253,7 @@ FilterOptions.userSelect = [
|
|
|
205
253
|
];
|
|
206
254
|
FilterOptions.orderFilterFrame = {
|
|
207
255
|
orderStatus: [],
|
|
256
|
+
reconciliation_status: [],
|
|
208
257
|
payload: [],
|
|
209
258
|
progress: [],
|
|
210
259
|
payment_select: [],
|
|
@@ -235,6 +284,14 @@ FilterOptions.orderStatusOptions = [
|
|
|
235
284
|
{ key: '0', name: '處理中' },
|
|
236
285
|
{ key: '-1', name: '已取消' },
|
|
237
286
|
];
|
|
287
|
+
FilterOptions.reconciliationOptions = [
|
|
288
|
+
{ key: 'pending_entry', name: '待入帳' },
|
|
289
|
+
{ key: 'completed_entry', name: '已入帳' },
|
|
290
|
+
{ key: 'refunded', name: '已退款' },
|
|
291
|
+
{ key: 'completed_offset', name: '已沖帳' },
|
|
292
|
+
{ key: 'pending_offset', name: '待沖帳' },
|
|
293
|
+
{ key: 'pending_refund', name: '待退款' }
|
|
294
|
+
];
|
|
238
295
|
FilterOptions.payloadStatusOptions = [
|
|
239
296
|
{ key: '1', name: '已付款' },
|
|
240
297
|
{ key: '3', name: '部分付款' },
|
|
@@ -138,6 +138,7 @@ export class FilterOptions {
|
|
|
138
138
|
|
|
139
139
|
static orderFilterFrame = {
|
|
140
140
|
orderStatus: [],
|
|
141
|
+
reconciliation_status:[],
|
|
141
142
|
payload: [],
|
|
142
143
|
progress: [],
|
|
143
144
|
payment_select:[],
|
|
@@ -174,6 +175,16 @@ export class FilterOptions {
|
|
|
174
175
|
{ key: '-1', name: '已取消' },
|
|
175
176
|
];
|
|
176
177
|
|
|
178
|
+
static reconciliationOptions = [
|
|
179
|
+
{ key: 'pending_entry', name: '待入帳' }, // 待入帳 (Pending Entry)
|
|
180
|
+
{ key: 'completed_entry', name: '已入帳' }, // 已入帳 (Completed Entry)
|
|
181
|
+
{ key: 'refunded', name: '已退款' }, // 已退款 (Refunded)
|
|
182
|
+
{ key: 'completed_offset', name: '已沖帳' }, // 已沖帳 (Completed Offset)
|
|
183
|
+
{ key: 'pending_offset', name: '待沖帳' }, // 待沖帳 (Pending Offset)
|
|
184
|
+
{ key: 'pending_refund', name: '待退款' } // 待退款 (Pending Refund)
|
|
185
|
+
]
|
|
186
|
+
;
|
|
187
|
+
|
|
177
188
|
static payloadStatusOptions = [
|
|
178
189
|
{ key: '1', name: '已付款' },
|
|
179
190
|
{ key: '3', name: '部分付款' },
|
|
@@ -222,6 +233,7 @@ export class FilterOptions {
|
|
|
222
233
|
return [
|
|
223
234
|
{ key: 'orderStatus', type: 'multi_checkbox', name: '訂單狀態', data: this.orderStatusOptions },
|
|
224
235
|
{ key: 'payload', type: 'multi_checkbox', name: '付款狀態', data: this.payloadStatusOptions },
|
|
236
|
+
{ key: 'reconciliation_status', type: 'multi_checkbox', name: '對帳狀態', data: this.reconciliationOptions },
|
|
225
237
|
{ key: 'payment_select', type: 'multi_checkbox', name: '付款方式', data:( await PaymentConfig.getSupportPayment()).map((dd)=>{
|
|
226
238
|
if(dd.type==='pos' && !(dd.name.includes('POS'))){
|
|
227
239
|
const name=dd.name;
|
|
@@ -258,6 +270,60 @@ dd.name=`<div class="d-flex">${[BgWidget.warningInsignia('POS'),name].join(`<div
|
|
|
258
270
|
];
|
|
259
271
|
}
|
|
260
272
|
|
|
273
|
+
static async getReconciliationFunnel() {
|
|
274
|
+
const saasConfig: { config: any; api: any } = (window.parent as any).saasConfig;
|
|
275
|
+
const response: { response: any; result: boolean } = await saasConfig.api.getPrivateConfig(
|
|
276
|
+
saasConfig.config.appName,
|
|
277
|
+
'logistics_setting'
|
|
278
|
+
);
|
|
279
|
+
|
|
280
|
+
let configData: any = response.response.result[0]?.value || {};
|
|
281
|
+
if (!configData.language_data) {
|
|
282
|
+
configData.language_data = {
|
|
283
|
+
'en-US': { info: '' },
|
|
284
|
+
'zh-CN': { info: '' },
|
|
285
|
+
'zh-TW': { info: configData.info || '' },
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
const shipmentOptions = ShipmentConfig.list
|
|
290
|
+
.map(dd => {
|
|
291
|
+
return { key: dd.value, name: dd.title };
|
|
292
|
+
})
|
|
293
|
+
.concat(
|
|
294
|
+
(configData.custom_delivery ?? []).map((dd: any) => {
|
|
295
|
+
return { key: dd.id, name: dd.name };
|
|
296
|
+
})
|
|
297
|
+
);
|
|
298
|
+
|
|
299
|
+
|
|
300
|
+
return [
|
|
301
|
+
{ key: 'orderStatus', type: 'multi_checkbox', name: '訂單狀態', data: this.orderStatusOptions },
|
|
302
|
+
{ key: 'reconciliation_status', type: 'multi_checkbox', name: '對帳狀態', data: this.reconciliationOptions },
|
|
303
|
+
{ key: 'payment_select', type: 'multi_checkbox', name: '付款方式', data:( await PaymentConfig.getSupportPayment()).map((dd)=>{
|
|
304
|
+
if(dd.type==='pos' && !(dd.name.includes('POS'))){
|
|
305
|
+
const name=dd.name;
|
|
306
|
+
dd.name=`<div class="d-flex">${[BgWidget.warningInsignia('POS'),name].join(`<div class="mx-1"></div>`)}</div>`
|
|
307
|
+
}
|
|
308
|
+
return dd
|
|
309
|
+
}) },
|
|
310
|
+
{ key: 'progress', type: 'multi_checkbox', name: '出貨狀況', data: this.progressOptions },
|
|
311
|
+
{ key: 'shipment', type: 'multi_checkbox', name: '運送方式', data: shipmentOptions },
|
|
312
|
+
{
|
|
313
|
+
key: 'shipment_time',
|
|
314
|
+
type: 'during',
|
|
315
|
+
name: '出貨日期',
|
|
316
|
+
data: {
|
|
317
|
+
centerText: '至',
|
|
318
|
+
list: [
|
|
319
|
+
{ key: 'start', type: 'date', placeHolder: '請選擇開始時間' },
|
|
320
|
+
{ key: 'end', type: 'date', placeHolder: '請選擇結束時間' },
|
|
321
|
+
],
|
|
322
|
+
},
|
|
323
|
+
},
|
|
324
|
+
];
|
|
325
|
+
}
|
|
326
|
+
|
|
261
327
|
static returnOrderFunnel = [
|
|
262
328
|
{
|
|
263
329
|
key: 'progress',
|
|
@@ -14,6 +14,9 @@ import { PaymentConfig } from '../../glitter-base/global/payment-config.js';
|
|
|
14
14
|
import { BgWidget } from '../../backend-manager/bg-widget.js';
|
|
15
15
|
import { Tool } from '../../modules/tool.js';
|
|
16
16
|
import { Excel } from './excel.js';
|
|
17
|
+
import { ApiReconciliation } from '../../glitter-base/route/api-reconciliation.js';
|
|
18
|
+
import { ApiUser } from '../../glitter-base/route/user.js';
|
|
19
|
+
import { GlobalUser } from '../../glitter-base/global/global-user.js';
|
|
17
20
|
const html = String.raw;
|
|
18
21
|
export class OrderExcel {
|
|
19
22
|
static optionsView(gvc, callback) {
|
|
@@ -157,6 +160,48 @@ export class OrderExcel {
|
|
|
157
160
|
備註: (_f = orderData.user_info.note) !== null && _f !== void 0 ? _f : '無備註',
|
|
158
161
|
});
|
|
159
162
|
};
|
|
163
|
+
const getReconciliation = (dd, orderData) => {
|
|
164
|
+
var _a;
|
|
165
|
+
return formatJSON({
|
|
166
|
+
'對帳狀態': (() => {
|
|
167
|
+
var _a;
|
|
168
|
+
const received_c = ((_a = dd.total_received) !== null && _a !== void 0 ? _a : 0) + dd.offset_amount;
|
|
169
|
+
if (dd.total_received === null || dd.total_received === undefined) {
|
|
170
|
+
return '待入帳';
|
|
171
|
+
}
|
|
172
|
+
else if (dd.total_received === dd.total) {
|
|
173
|
+
return '已入帳';
|
|
174
|
+
}
|
|
175
|
+
else if (dd.total_received > dd.total && received_c === dd.total) {
|
|
176
|
+
return '已退款';
|
|
177
|
+
}
|
|
178
|
+
else if (dd.total_received < dd.total && received_c === dd.total) {
|
|
179
|
+
return '已沖帳';
|
|
180
|
+
}
|
|
181
|
+
else if (received_c < dd.total) {
|
|
182
|
+
return '待沖帳';
|
|
183
|
+
}
|
|
184
|
+
else if (received_c > dd.total) {
|
|
185
|
+
return '待退款';
|
|
186
|
+
}
|
|
187
|
+
})(),
|
|
188
|
+
'入帳金額': `$${((dd.total_received || 0) + (dd.offset_amount || 0)).toLocaleString()}`,
|
|
189
|
+
'入帳日期': dd.reconciliation_date
|
|
190
|
+
? gvc.glitter.ut.dateFormat(new Date(dd.reconciliation_date), 'yyyy-MM-dd')
|
|
191
|
+
: '-',
|
|
192
|
+
'應沖金額': (() => {
|
|
193
|
+
if (dd.total_received === dd.total ||
|
|
194
|
+
dd.total_received === null ||
|
|
195
|
+
dd.total_received === undefined) {
|
|
196
|
+
return '-';
|
|
197
|
+
}
|
|
198
|
+
else {
|
|
199
|
+
return `$${dd.orderData.total - (dd.total_received + (dd.offset_amount || 0))}`;
|
|
200
|
+
}
|
|
201
|
+
})(),
|
|
202
|
+
'沖帳原因': (_a = dd.offset_reason) !== null && _a !== void 0 ? _a : '-'
|
|
203
|
+
});
|
|
204
|
+
};
|
|
160
205
|
function exportOrdersToExcel(dataArray) {
|
|
161
206
|
if (!dataArray.length) {
|
|
162
207
|
dialog.errorMessage({ text: '無訂單資料可以匯出' });
|
|
@@ -165,8 +210,8 @@ export class OrderExcel {
|
|
|
165
210
|
const printArray = dataArray.flatMap(order => {
|
|
166
211
|
const orderData = order.orderData;
|
|
167
212
|
return showLineItems
|
|
168
|
-
? orderData.lineItems.map((item) => (Object.assign(Object.assign(Object.assign({}, getOrderJSON(order, orderData)), getProductJSON(item)), getUserJSON(order, orderData))))
|
|
169
|
-
: [Object.assign(Object.assign({}, getOrderJSON(order, orderData)), getUserJSON(order, orderData))];
|
|
213
|
+
? orderData.lineItems.map((item) => (Object.assign(Object.assign(Object.assign(Object.assign({}, getOrderJSON(order, orderData)), getProductJSON(item)), getUserJSON(order, orderData)), getReconciliation(order, orderData))))
|
|
214
|
+
: [Object.assign(Object.assign(Object.assign({}, getOrderJSON(order, orderData)), getUserJSON(order, orderData)), getReconciliation(order, orderData))];
|
|
170
215
|
});
|
|
171
216
|
const worksheet = XLSX.utils.json_to_sheet(printArray);
|
|
172
217
|
const workbook = XLSX.utils.book_new();
|
|
@@ -194,7 +239,7 @@ export class OrderExcel {
|
|
|
194
239
|
}
|
|
195
240
|
});
|
|
196
241
|
}
|
|
197
|
-
const limit =
|
|
242
|
+
const limit = 1000;
|
|
198
243
|
dialog.checkYesOrNot({
|
|
199
244
|
text: `系統將會依條件匯出資料,最多匯出${limit}筆<br/>確定要匯出嗎?`,
|
|
200
245
|
callback: bool => bool && fetchOrders(limit),
|
|
@@ -210,6 +255,7 @@ export class OrderExcel {
|
|
|
210
255
|
const isArchived = apiJSON.archived === 'true';
|
|
211
256
|
const isShipment = apiJSON.is_shipment;
|
|
212
257
|
const isPOS = apiJSON.is_pos;
|
|
258
|
+
const isReconciliation = apiJSON.is_reconciliation;
|
|
213
259
|
if (isShipment && isArchived)
|
|
214
260
|
return '已封存出貨單';
|
|
215
261
|
if (isShipment)
|
|
@@ -220,11 +266,13 @@ export class OrderExcel {
|
|
|
220
266
|
return '已封存訂單';
|
|
221
267
|
if (isPOS)
|
|
222
268
|
return 'POS訂單';
|
|
269
|
+
if (isReconciliation)
|
|
270
|
+
return '對帳單';
|
|
223
271
|
return '訂單';
|
|
224
272
|
})();
|
|
225
273
|
BgWidget.settingDialog({
|
|
226
274
|
gvc,
|
|
227
|
-
title: '
|
|
275
|
+
title: '匯出' + pageType,
|
|
228
276
|
width: 700,
|
|
229
277
|
innerHTML: gvc2 => {
|
|
230
278
|
return html `<div class="d-flex flex-column align-items-start gap-2">
|
|
@@ -258,7 +306,12 @@ export class OrderExcel {
|
|
|
258
306
|
const dataMap = {
|
|
259
307
|
search: apiJSON,
|
|
260
308
|
checked: Object.assign(Object.assign({}, apiJSON), { id_list: dataArray.map(data => data.id).join(',') }),
|
|
261
|
-
all: {
|
|
309
|
+
all: {
|
|
310
|
+
is_reconciliation: apiJSON.is_reconciliation,
|
|
311
|
+
is_shipment: apiJSON.is_shipment,
|
|
312
|
+
archived: apiJSON.archived,
|
|
313
|
+
is_pos: apiJSON.is_pos
|
|
314
|
+
},
|
|
262
315
|
};
|
|
263
316
|
this.export(gvc, dataMap[vm.select], vm.column);
|
|
264
317
|
}), '匯出'),
|
|
@@ -376,6 +429,129 @@ export class OrderExcel {
|
|
|
376
429
|
}
|
|
377
430
|
});
|
|
378
431
|
}
|
|
432
|
+
static importWithReconciliation(gvc, target, callback) {
|
|
433
|
+
var _a;
|
|
434
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
435
|
+
const dialog = new ShareDialog(gvc.glitter);
|
|
436
|
+
function errorMsg(text) {
|
|
437
|
+
dialog.dataLoading({ visible: false });
|
|
438
|
+
dialog.errorMessage({ text: text });
|
|
439
|
+
}
|
|
440
|
+
if ((_a = target.files) === null || _a === void 0 ? void 0 : _a.length) {
|
|
441
|
+
try {
|
|
442
|
+
dialog.dataLoading({ visible: true, text: '上傳檔案中' });
|
|
443
|
+
const jsonData = yield Excel.parseExcelToJson(gvc, target.files[0]);
|
|
444
|
+
const importMap = new Map();
|
|
445
|
+
for (let i = 0; i < jsonData.length; i++) {
|
|
446
|
+
const order = jsonData[i];
|
|
447
|
+
if ((!order['訂單編號']) || (!order['操作選項']) || (!order['入帳/沖帳日期']) || (!order['入帳/沖帳金額'])) {
|
|
448
|
+
(!order['訂單編號']) && errorMsg('請輸入訂單編號');
|
|
449
|
+
(!order['操作選項']) && errorMsg('請輸入操作選項');
|
|
450
|
+
(!order['入帳/沖帳日期']) && errorMsg('請輸入入帳/沖帳日期');
|
|
451
|
+
(!order['入帳/沖帳金額']) && errorMsg('請輸入入帳/沖帳金額');
|
|
452
|
+
return;
|
|
453
|
+
}
|
|
454
|
+
importMap.set(`${order['訂單編號']}`, order);
|
|
455
|
+
}
|
|
456
|
+
const cartTokens = [...importMap.keys()];
|
|
457
|
+
const getOrders = yield ApiShop.getOrder({
|
|
458
|
+
page: 0,
|
|
459
|
+
limit: 1000,
|
|
460
|
+
searchType: 'cart_token',
|
|
461
|
+
id_list: cartTokens.join(','),
|
|
462
|
+
});
|
|
463
|
+
if (!getOrders.result) {
|
|
464
|
+
errorMsg('訂單資料取得失敗');
|
|
465
|
+
return;
|
|
466
|
+
}
|
|
467
|
+
const orders = getOrders.response.data;
|
|
468
|
+
const orderMap = new Map(orders.map((order) => [order.cart_token, true]));
|
|
469
|
+
const importKey = cartTokens.find(key => !orderMap.has(key));
|
|
470
|
+
if (importKey) {
|
|
471
|
+
errorMsg(`訂單編號 #${importKey} 不存在`);
|
|
472
|
+
return;
|
|
473
|
+
}
|
|
474
|
+
for (const order of orders) {
|
|
475
|
+
try {
|
|
476
|
+
const compare = importMap.get(order.cart_token);
|
|
477
|
+
if ((compare['操作選項'] === '入帳') && (order.reconciliation_date)) {
|
|
478
|
+
errorMsg(`已入帳訂單不可再次入帳<br/>(訂單編號: ${order.cart_token})`);
|
|
479
|
+
return;
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
catch (error) {
|
|
483
|
+
errorMsg('訂單資料有誤');
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
const auth = yield ApiUser.getPermission({
|
|
487
|
+
page: 0,
|
|
488
|
+
limit: 100,
|
|
489
|
+
}).then(res => {
|
|
490
|
+
return res.response.data.find((dd) => {
|
|
491
|
+
return `${dd.user}` === `${GlobalUser.parseJWT(GlobalUser.saas_token).payload.userID}`;
|
|
492
|
+
});
|
|
493
|
+
});
|
|
494
|
+
const saveEvent = (order) => {
|
|
495
|
+
var _a;
|
|
496
|
+
const compare = importMap.get(order.cart_token);
|
|
497
|
+
const money = parseInt(compare['入帳/沖帳金額'], 10);
|
|
498
|
+
if (compare['操作選項'] === '入帳') {
|
|
499
|
+
return ApiReconciliation.putReconciliation({
|
|
500
|
+
order_id: order.cart_token,
|
|
501
|
+
update: {
|
|
502
|
+
reconciliation_date: new Date(compare['入帳/沖帳日期']).toISOString(),
|
|
503
|
+
total_received: money,
|
|
504
|
+
},
|
|
505
|
+
});
|
|
506
|
+
}
|
|
507
|
+
else {
|
|
508
|
+
order.offset_records = (_a = order.offset_records) !== null && _a !== void 0 ? _a : [];
|
|
509
|
+
return ApiReconciliation.putReconciliation({
|
|
510
|
+
order_id: order.cart_token,
|
|
511
|
+
update: {
|
|
512
|
+
offset_amount: order.offset_amount + money,
|
|
513
|
+
offset_reason: compare['沖帳原因'],
|
|
514
|
+
offset_records: JSON.stringify(JSON.parse(JSON.stringify(order.offset_records)).concat([
|
|
515
|
+
{
|
|
516
|
+
offset_amount: money,
|
|
517
|
+
offset_reason: compare['沖帳原因'],
|
|
518
|
+
offset_date: new Date(compare['入帳/沖帳日期']).toISOString(),
|
|
519
|
+
offset_note: compare['沖帳備註'],
|
|
520
|
+
user: auth.config
|
|
521
|
+
},
|
|
522
|
+
])),
|
|
523
|
+
},
|
|
524
|
+
});
|
|
525
|
+
}
|
|
526
|
+
};
|
|
527
|
+
try {
|
|
528
|
+
dialog.dataLoading({ visible: true });
|
|
529
|
+
const responses = yield Promise.all(orders.map((order) => {
|
|
530
|
+
return saveEvent(order);
|
|
531
|
+
}));
|
|
532
|
+
const failedResponse = responses.find(res => !res.result);
|
|
533
|
+
dialog.dataLoading({ visible: false });
|
|
534
|
+
if (failedResponse) {
|
|
535
|
+
console.error('匯入失敗:', failedResponse);
|
|
536
|
+
dialog.errorMessage({ text: '匯入失敗' });
|
|
537
|
+
}
|
|
538
|
+
else {
|
|
539
|
+
dialog.successMessage({ text: '匯入成功' });
|
|
540
|
+
setTimeout(() => callback(), 300);
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
catch (error) {
|
|
544
|
+
dialog.dataLoading({ visible: false });
|
|
545
|
+
console.error('批次更新錯誤:', error);
|
|
546
|
+
dialog.errorMessage({ text: '系統錯誤,請稍後再試' });
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
catch (error) {
|
|
550
|
+
console.error('Order Excel 解析失敗', error);
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
});
|
|
554
|
+
}
|
|
379
555
|
static importDialog(gvc, query, callback) {
|
|
380
556
|
const dialog = new ShareDialog(gvc.glitter);
|
|
381
557
|
const vm = {
|
|
@@ -387,6 +563,8 @@ export class OrderExcel {
|
|
|
387
563
|
return '出貨單';
|
|
388
564
|
if (query.isArchived)
|
|
389
565
|
return '已封存訂單';
|
|
566
|
+
if (query.is_reconciliation)
|
|
567
|
+
return '對帳單';
|
|
390
568
|
return '訂單';
|
|
391
569
|
})(),
|
|
392
570
|
};
|
|
@@ -405,6 +583,8 @@ export class OrderExcel {
|
|
|
405
583
|
Excel.downloadExcel(gvc, (() => {
|
|
406
584
|
if (query.isShipment)
|
|
407
585
|
return OrderExcel.importShipmentExample;
|
|
586
|
+
if (query.is_reconciliation)
|
|
587
|
+
return OrderExcel.importReconciliation;
|
|
408
588
|
if (query.isArchived)
|
|
409
589
|
return [];
|
|
410
590
|
return [];
|
|
@@ -419,6 +599,12 @@ export class OrderExcel {
|
|
|
419
599
|
callback();
|
|
420
600
|
});
|
|
421
601
|
}
|
|
602
|
+
if (query.is_reconciliation) {
|
|
603
|
+
return this.importWithReconciliation(gvc, vm.fileInput, () => {
|
|
604
|
+
gvc.glitter.closeDiaLog();
|
|
605
|
+
callback();
|
|
606
|
+
});
|
|
607
|
+
}
|
|
422
608
|
if (query.isArchived) {
|
|
423
609
|
}
|
|
424
610
|
},
|
|
@@ -510,6 +696,24 @@ OrderExcel.importShipmentExample = [
|
|
|
510
696
|
出貨單號碼: '1249900602345',
|
|
511
697
|
},
|
|
512
698
|
];
|
|
699
|
+
OrderExcel.importReconciliation = [
|
|
700
|
+
{
|
|
701
|
+
"訂單編號": '1241770010001',
|
|
702
|
+
"操作選項": '入帳',
|
|
703
|
+
'入帳/沖帳日期': '2025-01-01',
|
|
704
|
+
'入帳/沖帳金額': '2000',
|
|
705
|
+
"沖帳原因": '',
|
|
706
|
+
"沖帳備註": ''
|
|
707
|
+
},
|
|
708
|
+
{
|
|
709
|
+
"訂單編號": '1241770010002',
|
|
710
|
+
"操作選項": '沖帳',
|
|
711
|
+
'入帳/沖帳日期': '2025-01-02',
|
|
712
|
+
'入帳/沖帳金額': '-1000',
|
|
713
|
+
"沖帳原因": '支付金額異常',
|
|
714
|
+
"沖帳備註": '於玉山銀行進行查帳只有收到'
|
|
715
|
+
},
|
|
716
|
+
];
|
|
513
717
|
OrderExcel.headerColumn = {
|
|
514
718
|
訂單: [
|
|
515
719
|
'訂單編號',
|
|
@@ -545,4 +749,11 @@ OrderExcel.headerColumn = {
|
|
|
545
749
|
'會員等級',
|
|
546
750
|
'備註',
|
|
547
751
|
],
|
|
752
|
+
對帳資訊: [
|
|
753
|
+
'對帳狀態',
|
|
754
|
+
'入帳金額',
|
|
755
|
+
'入帳日期',
|
|
756
|
+
'應沖金額',
|
|
757
|
+
'沖帳原因'
|
|
758
|
+
]
|
|
548
759
|
};
|