ts-glitter 20.5.4 → 20.5.6
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 +1 -1
- package/lowcode/Entry.ts +1 -1
- package/lowcode/backend-manager/bg-product.js +68 -47
- package/lowcode/backend-manager/bg-product.ts +83 -62
- package/lowcode/cms-plugin/module/delivery-html.js +137 -239
- package/lowcode/cms-plugin/module/delivery-html.ts +155 -257
- package/lowcode/cms-plugin/module/order-setting.js +49 -44
- package/lowcode/cms-plugin/module/order-setting.ts +84 -80
- package/lowcode/cms-plugin/shopping-order-manager.ts +1 -1
- package/lowcode/public-components/product/pd-class.js +27 -45
- package/lowcode/public-components/product/pd-class.ts +32 -53
- package/package.json +1 -1
- package/src/api-public/services/user-update.js +1 -1
- package/src/api-public/services/user-update.ts +1 -1
- package/src/services/app.js +1 -1
- package/src/services/app.js.map +1 -1
- package/src/services/app.ts +1 -1
|
@@ -3,6 +3,7 @@ import { Tool } from '../../modules/tool.js';
|
|
|
3
3
|
import { BgWidget } from '../../backend-manager/bg-widget.js';
|
|
4
4
|
import { ApiUser } from '../../glitter-base/route/user.js';
|
|
5
5
|
import { CartData, OrderData } from './data.js';
|
|
6
|
+
import { OrderSetting } from '../module/order-setting.js';
|
|
6
7
|
|
|
7
8
|
const html = String.raw;
|
|
8
9
|
|
|
@@ -60,14 +61,14 @@ export class DeliveryHTML {
|
|
|
60
61
|
return '載入中';
|
|
61
62
|
}
|
|
62
63
|
|
|
63
|
-
const printMap: Record<PrintType, string> = {
|
|
64
|
-
shipment: this.shipmentHTML(vm,
|
|
65
|
-
pick: this.pickHTML(vm, glitter, dataArray),
|
|
66
|
-
address: this.addressHTML(vm, dataArray),
|
|
67
|
-
shipAddr: this.shipAddrHTML(vm,
|
|
64
|
+
const printMap: Record<PrintType, () => string> = {
|
|
65
|
+
shipment: () => this.shipmentHTML(vm, gvc, dataArray),
|
|
66
|
+
pick: () => this.pickHTML(vm, glitter, dataArray),
|
|
67
|
+
address: () => this.addressHTML(vm, dataArray),
|
|
68
|
+
shipAddr: () => this.shipAddrHTML(vm, gvc, dataArray),
|
|
68
69
|
};
|
|
69
70
|
|
|
70
|
-
return html`<div class="container" id="${containerID}">${printMap[type]}</div>`;
|
|
71
|
+
return html`<div class="container" id="${containerID}">${printMap[type]?.()}</div>`;
|
|
71
72
|
},
|
|
72
73
|
divCreate: {
|
|
73
74
|
style: 'min-height: calc(100vh - 70px); padding: 20px;',
|
|
@@ -335,119 +336,155 @@ export class DeliveryHTML {
|
|
|
335
336
|
`);
|
|
336
337
|
}
|
|
337
338
|
|
|
338
|
-
// 出貨明細
|
|
339
|
-
static
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
<
|
|
378
|
-
|
|
379
|
-
|
|
339
|
+
// 出貨明細 - 表頭
|
|
340
|
+
static shipmentHeader(vm: any, glitter: any) {
|
|
341
|
+
return html`<div class="header">
|
|
342
|
+
<h1 class="subtitle">商店名稱:${vm.store.shop_name}</h1>
|
|
343
|
+
<h1 class="title">${vm.info.title}</h1>
|
|
344
|
+
<h1 class="subtitle">${vm.info.subtitle}時間:${glitter.ut.dateFormat(new Date(), 'yyyy-MM-dd hh:mm')}</h1>
|
|
345
|
+
</div>`;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
// 出貨明細 - 配送資訊
|
|
349
|
+
static shipmentDetail(glitter: any, data: CartData) {
|
|
350
|
+
const orderData = data.orderData;
|
|
351
|
+
|
|
352
|
+
function paymentStatus(cart: CartData) {
|
|
353
|
+
const statusMessages: Record<string, string> = {
|
|
354
|
+
'0': cart.orderData.proof_purchase ? '待核款' : '未付款',
|
|
355
|
+
'1': '已付款',
|
|
356
|
+
'-2': '已退款',
|
|
357
|
+
'3': '部分付款',
|
|
358
|
+
};
|
|
359
|
+
|
|
360
|
+
return statusMessages[`${cart.status}`] || '付款失敗';
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
return html`<div class="details">
|
|
364
|
+
<table>
|
|
365
|
+
<tr>
|
|
366
|
+
<td>訂單編號:${data.cart_token}</td>
|
|
367
|
+
<td>送貨方式:${OrderSetting.getShippingMethodText(orderData)}</td>
|
|
368
|
+
</tr>
|
|
369
|
+
<tr>
|
|
370
|
+
<td>訂購日期:${glitter.ut.dateFormat(new Date(data.created_time), 'yyyy-MM-dd hh:mm')}</td>
|
|
371
|
+
<td>
|
|
372
|
+
送貨地址:${[orderData.user_info.city, orderData.user_info.area, orderData.user_info.address]
|
|
373
|
+
.filter(Boolean)
|
|
374
|
+
.join('')}
|
|
375
|
+
</td>
|
|
376
|
+
</tr>
|
|
377
|
+
<tr>
|
|
378
|
+
<td>訂購人帳號:${orderData.email}</td>
|
|
379
|
+
<td>收件人姓名:${orderData.user_info.name}</td>
|
|
380
|
+
</tr>
|
|
381
|
+
<tr>
|
|
382
|
+
<td>付款方式:${OrderSetting.getPaymentMethodText(orderData)}</td>
|
|
383
|
+
<td>收件人電話:${orderData.user_info.phone}</td>
|
|
384
|
+
</tr>
|
|
385
|
+
<tr>
|
|
386
|
+
<td>付款狀態:${paymentStatus(data)}</td>
|
|
387
|
+
<td>收件人信箱:${orderData.user_info.email}</td>
|
|
388
|
+
</tr>
|
|
389
|
+
</table>
|
|
390
|
+
</div>`;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
// 出貨明細 - 產品項目
|
|
394
|
+
static shipmentItems(gvc: GVC, orderData: OrderData) {
|
|
395
|
+
return html`<div class="items">
|
|
396
|
+
<table>
|
|
397
|
+
<thead>
|
|
398
|
+
<tr>
|
|
399
|
+
<th class="text-left">項次</th>
|
|
400
|
+
<th class="text-left">圖片</th>
|
|
401
|
+
<th class="text-left">商品名稱</th>
|
|
402
|
+
<th class="text-right">單價</th>
|
|
403
|
+
<th class="text-right">數量</th>
|
|
404
|
+
<th class="text-right">金額</th>
|
|
405
|
+
</tr>
|
|
406
|
+
</thead>
|
|
407
|
+
<tbody>
|
|
408
|
+
${orderData.lineItems
|
|
409
|
+
.map((item, index) => {
|
|
410
|
+
return html`
|
|
380
411
|
<tr>
|
|
381
|
-
<
|
|
382
|
-
<
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
<
|
|
412
|
+
<td class="text-left">${index + 1}</td>
|
|
413
|
+
<td class="text-left">
|
|
414
|
+
${BgWidget.validImageBox({ gvc, image: item.preview_image ?? '', width: 40 })}
|
|
415
|
+
</td>
|
|
416
|
+
<td class="text-left">${item.title} ${item.spec.length > 0 ? `(${item.spec.join('/')})` : ''}</td>
|
|
417
|
+
<td class="text-right">${item.sale_price.toLocaleString()}</td>
|
|
418
|
+
<td class="text-right">${item.count}</td>
|
|
419
|
+
<td class="text-right">
|
|
420
|
+
$ ${Tool.floatAdd(item.sale_price * Number(item.count), 0).toLocaleString()}
|
|
421
|
+
</td>
|
|
386
422
|
</tr>
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
<td class="text-left">
|
|
395
|
-
${item.title} ${item.spec.length > 0 ? `(${item.spec.join('/')})` : ''}
|
|
396
|
-
</td>
|
|
397
|
-
<td class="text-right">${item.sale_price.toLocaleString()}</td>
|
|
398
|
-
<td class="text-right">${item.count}</td>
|
|
399
|
-
<td class="text-right">$ ${Tool.floatAdd(item.sale_price * Number(item.count), 0).toLocaleString()}</td>
|
|
400
|
-
</tr>
|
|
401
|
-
`;
|
|
402
|
-
})
|
|
403
|
-
.join('')}
|
|
404
|
-
</tbody>
|
|
405
|
-
</table>
|
|
406
|
-
</div>
|
|
407
|
-
<div class="summary">
|
|
408
|
-
<table>
|
|
409
|
-
<tr>
|
|
410
|
-
<td>小計:</td>
|
|
411
|
-
<td>
|
|
412
|
-
$
|
|
413
|
-
${(
|
|
414
|
-
orderData.total +
|
|
415
|
-
orderData.discount -
|
|
416
|
-
orderData.shipment_fee +
|
|
417
|
-
orderData.use_rebate
|
|
418
|
-
).toLocaleString()}
|
|
419
|
-
</td>
|
|
420
|
-
</tr>
|
|
421
|
-
<tr>
|
|
422
|
-
<td>運費:</td>
|
|
423
|
-
<td>${orderData.shipment_fee.toLocaleString()}</td>
|
|
424
|
-
</tr>
|
|
425
|
-
<tr>
|
|
426
|
-
<td>折扣:</td>
|
|
427
|
-
<td>-${orderData.discount.toLocaleString()}</td>
|
|
428
|
-
</tr>
|
|
429
|
-
<tr>
|
|
430
|
-
<td>購物金折抵:</td>
|
|
431
|
-
<td>-${orderData.use_rebate.toLocaleString()}</td>
|
|
432
|
-
</tr>
|
|
433
|
-
<tr>
|
|
434
|
-
<td>總計:</td>
|
|
435
|
-
<td>$ ${orderData.total.toLocaleString()}</td>
|
|
436
|
-
</tr>
|
|
437
|
-
</table>
|
|
438
|
-
</div>
|
|
439
|
-
${orderData.order_note && orderData.order_note.length > 0
|
|
440
|
-
? html` <div>【訂單備註】</div>
|
|
441
|
-
<p class="note">${orderData.order_note.replace(/\n/g, '<br />')}</p>`
|
|
442
|
-
: ''}
|
|
443
|
-
</div>
|
|
444
|
-
`;
|
|
445
|
-
};
|
|
423
|
+
`;
|
|
424
|
+
})
|
|
425
|
+
.join('')}
|
|
426
|
+
</tbody>
|
|
427
|
+
</table>
|
|
428
|
+
</div>`;
|
|
429
|
+
}
|
|
446
430
|
|
|
431
|
+
// 出貨明細 - 總結
|
|
432
|
+
static shipmentSummary(orderData: OrderData) {
|
|
433
|
+
return html`<div class="summary">
|
|
434
|
+
<table>
|
|
435
|
+
<tr>
|
|
436
|
+
<td>小計:</td>
|
|
437
|
+
<td>
|
|
438
|
+
$ ${(orderData.total + orderData.discount - orderData.shipment_fee + orderData.use_rebate).toLocaleString()}
|
|
439
|
+
</td>
|
|
440
|
+
</tr>
|
|
441
|
+
<tr>
|
|
442
|
+
<td>運費:</td>
|
|
443
|
+
<td>$ ${orderData.shipment_fee.toLocaleString()}</td>
|
|
444
|
+
</tr>
|
|
445
|
+
<tr>
|
|
446
|
+
<td>折扣:</td>
|
|
447
|
+
<td>- $ ${orderData.discount.toLocaleString()}</td>
|
|
448
|
+
</tr>
|
|
449
|
+
<tr>
|
|
450
|
+
<td>購物金折抵:</td>
|
|
451
|
+
<td>- $ ${orderData.use_rebate.toLocaleString()}</td>
|
|
452
|
+
</tr>
|
|
453
|
+
<tr>
|
|
454
|
+
<td>總計:</td>
|
|
455
|
+
<td>$ ${orderData.total.toLocaleString()}</td>
|
|
456
|
+
</tr>
|
|
457
|
+
</table>
|
|
458
|
+
</div>`;
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
// 出貨明細 - 備註
|
|
462
|
+
static shipmentNote(orderData: OrderData) {
|
|
463
|
+
return orderData.order_note && orderData.order_note.length > 0
|
|
464
|
+
? html` <div>【訂單備註】</div>
|
|
465
|
+
<p class="note">${orderData.order_note.replace(/\n/g, '<br />')}</p>`
|
|
466
|
+
: '';
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
// 取得出貨明細頁面
|
|
470
|
+
static getShipmentPage(vm: any, gvc: GVC, data: CartData) {
|
|
471
|
+
const glitter = gvc.glitter;
|
|
472
|
+
const orderData = data.orderData;
|
|
473
|
+
return [
|
|
474
|
+
this.shipmentHeader(vm, glitter),
|
|
475
|
+
this.shipmentDetail(glitter, data),
|
|
476
|
+
this.shipmentItems(gvc, orderData),
|
|
477
|
+
this.shipmentSummary(orderData),
|
|
478
|
+
this.shipmentNote(orderData),
|
|
479
|
+
].join('');
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
// 列印出貨明細
|
|
483
|
+
static shipmentHTML(vm: any, gvc: GVC, dataArray: CartData[]) {
|
|
447
484
|
return dataArray
|
|
448
485
|
.map(data => {
|
|
449
486
|
try {
|
|
450
|
-
return
|
|
487
|
+
return html` <div class="page">${this.getShipmentPage(vm, gvc, data)}</div>`;
|
|
451
488
|
} catch (e) {
|
|
452
489
|
const text = `訂單 #${data.cart_token} 列印出貨發生錯誤`;
|
|
453
490
|
console.error(`${text}: ${e}`);
|
|
@@ -457,7 +494,7 @@ export class DeliveryHTML {
|
|
|
457
494
|
.join('');
|
|
458
495
|
}
|
|
459
496
|
|
|
460
|
-
//
|
|
497
|
+
// 列印揀貨單
|
|
461
498
|
static pickHTML(vm: any, glitter: any, dataArray: CartData[]) {
|
|
462
499
|
const formulaLineItems = () => {
|
|
463
500
|
const mergedItems = dataArray
|
|
@@ -514,7 +551,7 @@ export class DeliveryHTML {
|
|
|
514
551
|
`;
|
|
515
552
|
}
|
|
516
553
|
|
|
517
|
-
//
|
|
554
|
+
// 列印地址貼條
|
|
518
555
|
static addressHTML(vm: any, dataArray: CartData[]) {
|
|
519
556
|
const dataMap = dataArray.map(order => {
|
|
520
557
|
const orderData = order.orderData;
|
|
@@ -565,8 +602,8 @@ export class DeliveryHTML {
|
|
|
565
602
|
.join('');
|
|
566
603
|
}
|
|
567
604
|
|
|
568
|
-
//
|
|
569
|
-
static shipAddrHTML(vm: any,
|
|
605
|
+
// 列印出貨明細 + 地址貼條
|
|
606
|
+
static shipAddrHTML(vm: any, gvc: GVC, dataArray: CartData[]) {
|
|
570
607
|
const section = (data: CartData) => {
|
|
571
608
|
const orderData = data.orderData;
|
|
572
609
|
|
|
@@ -600,105 +637,7 @@ export class DeliveryHTML {
|
|
|
600
637
|
</div>
|
|
601
638
|
<div style="text-align: end">訂單編號: ${data.cart_token}</div>
|
|
602
639
|
</div>
|
|
603
|
-
|
|
604
|
-
<h1 class="subtitle">商店名稱:${vm.store.shop_name}</h1>
|
|
605
|
-
<h1 class="title">${vm.info.title}</h1>
|
|
606
|
-
<h1 class="subtitle">${vm.info.subtitle}時間:${glitter.ut.dateFormat(new Date(), 'yyyy-MM-dd hh:mm')}</h1>
|
|
607
|
-
</div>
|
|
608
|
-
<div class="details">
|
|
609
|
-
<table>
|
|
610
|
-
<tr>
|
|
611
|
-
<td>訂單編號:${data.cart_token}</td>
|
|
612
|
-
<td>送貨方式:${this.getShippingMethodText(orderData)}</td>
|
|
613
|
-
</tr>
|
|
614
|
-
<tr>
|
|
615
|
-
<td>訂購日期:${glitter.ut.dateFormat(new Date(data.created_time), 'yyyy-MM-dd hh:mm')}</td>
|
|
616
|
-
<td>
|
|
617
|
-
送貨地址:${[orderData.user_info.city, orderData.user_info.area, orderData.user_info.address]
|
|
618
|
-
.filter(Boolean)
|
|
619
|
-
.join('')}
|
|
620
|
-
</td>
|
|
621
|
-
</tr>
|
|
622
|
-
<tr>
|
|
623
|
-
<td>訂購人帳號:${orderData.email}</td>
|
|
624
|
-
<td>收件人姓名:${orderData.user_info.name}</td>
|
|
625
|
-
</tr>
|
|
626
|
-
<tr>
|
|
627
|
-
<td>付款方式:${this.getPaymentMethodText(orderData)}</td>
|
|
628
|
-
<td>收件人電話:${orderData.user_info.phone}</td>
|
|
629
|
-
</tr>
|
|
630
|
-
<tr>
|
|
631
|
-
<td>付款狀態:${this.paymentStatus(data)}</td>
|
|
632
|
-
<td>收件人信箱:${orderData.user_info.email}</td>
|
|
633
|
-
</tr>
|
|
634
|
-
</table>
|
|
635
|
-
</div>
|
|
636
|
-
<div class="items">
|
|
637
|
-
<table>
|
|
638
|
-
<thead>
|
|
639
|
-
<tr>
|
|
640
|
-
<th class="text-left">項次</th>
|
|
641
|
-
<th class="text-left">商品名稱</th>
|
|
642
|
-
<th class="text-right">單價</th>
|
|
643
|
-
<th class="text-right">數量</th>
|
|
644
|
-
<th class="text-right">金額</th>
|
|
645
|
-
</tr>
|
|
646
|
-
</thead>
|
|
647
|
-
<tbody>
|
|
648
|
-
${orderData.lineItems
|
|
649
|
-
.map((item, index) => {
|
|
650
|
-
return html`
|
|
651
|
-
<tr>
|
|
652
|
-
<td class="text-left">${index + 1}</td>
|
|
653
|
-
<td class="text-left">
|
|
654
|
-
${item.title} ${item.spec.length > 0 ? `(${item.spec.join('/')})` : ''}
|
|
655
|
-
</td>
|
|
656
|
-
<td class="text-right">${item.sale_price.toLocaleString()}</td>
|
|
657
|
-
<td class="text-right">${item.count}</td>
|
|
658
|
-
<td class="text-right">$ ${Tool.floatAdd(item.sale_price * Number(item.count)??0, 0).toLocaleString()}</td>
|
|
659
|
-
</tr>
|
|
660
|
-
`;
|
|
661
|
-
})
|
|
662
|
-
.join('')}
|
|
663
|
-
</tbody>
|
|
664
|
-
</table>
|
|
665
|
-
</div>
|
|
666
|
-
<div class="summary">
|
|
667
|
-
<table>
|
|
668
|
-
<tr>
|
|
669
|
-
<td>小計:</td>
|
|
670
|
-
<td>
|
|
671
|
-
$
|
|
672
|
-
${(
|
|
673
|
-
orderData.total +
|
|
674
|
-
orderData.discount -
|
|
675
|
-
orderData.shipment_fee +
|
|
676
|
-
orderData.use_rebate
|
|
677
|
-
).toLocaleString()}
|
|
678
|
-
</td>
|
|
679
|
-
</tr>
|
|
680
|
-
<tr>
|
|
681
|
-
<td>運費:</td>
|
|
682
|
-
<td>${orderData.shipment_fee.toLocaleString()}</td>
|
|
683
|
-
</tr>
|
|
684
|
-
<tr>
|
|
685
|
-
<td>折扣:</td>
|
|
686
|
-
<td>-${orderData.discount.toLocaleString()}</td>
|
|
687
|
-
</tr>
|
|
688
|
-
<tr>
|
|
689
|
-
<td>購物金折抵:</td>
|
|
690
|
-
<td>-${orderData.use_rebate.toLocaleString()}</td>
|
|
691
|
-
</tr>
|
|
692
|
-
<tr>
|
|
693
|
-
<td>總計:</td>
|
|
694
|
-
<td>$ ${orderData.total.toLocaleString()}</td>
|
|
695
|
-
</tr>
|
|
696
|
-
</table>
|
|
697
|
-
</div>
|
|
698
|
-
${orderData.order_note && orderData.order_note.length > 0
|
|
699
|
-
? html` <div>【訂單備註】</div>
|
|
700
|
-
<p class="note">${orderData.order_note.replace(/\n/g, '<br />')}</p>`
|
|
701
|
-
: ''}
|
|
640
|
+
${this.getShipmentPage(vm, gvc, data)}
|
|
702
641
|
</div>
|
|
703
642
|
`;
|
|
704
643
|
};
|
|
@@ -715,45 +654,4 @@ export class DeliveryHTML {
|
|
|
715
654
|
})
|
|
716
655
|
.join('');
|
|
717
656
|
}
|
|
718
|
-
|
|
719
|
-
// 付款方式
|
|
720
|
-
static getPaymentMethodText(orderData: OrderData) {
|
|
721
|
-
const paymentMethods: Record<string, string> = {
|
|
722
|
-
POS: '門市POS付款',
|
|
723
|
-
off_line: '線下付款',
|
|
724
|
-
newWebPay: '藍新金流',
|
|
725
|
-
ecPay: '綠界金流',
|
|
726
|
-
line_pay: 'Line Pay',
|
|
727
|
-
atm: '銀行轉帳',
|
|
728
|
-
line: 'Line 轉帳',
|
|
729
|
-
cash_on_delivery: '貨到付款',
|
|
730
|
-
};
|
|
731
|
-
|
|
732
|
-
return orderData.orderSource === 'POS'
|
|
733
|
-
? paymentMethods['POS']
|
|
734
|
-
: paymentMethods[orderData.customer_info.payment_select] || '線下付款';
|
|
735
|
-
}
|
|
736
|
-
|
|
737
|
-
// 配送方式
|
|
738
|
-
static getShippingMethodText(orderData: OrderData) {
|
|
739
|
-
const shippingMethods: Record<string, string> = {
|
|
740
|
-
UNIMARTC2C: '7-11店到店',
|
|
741
|
-
FAMIC2C: '全家店到店',
|
|
742
|
-
OKMARTC2C: 'OK店到店',
|
|
743
|
-
HILIFEC2C: '萊爾富店到店',
|
|
744
|
-
};
|
|
745
|
-
|
|
746
|
-
return shippingMethods[orderData.user_info.shipment] || '宅配';
|
|
747
|
-
}
|
|
748
|
-
|
|
749
|
-
// 付款狀態
|
|
750
|
-
static paymentStatus(cart: CartData) {
|
|
751
|
-
const statusMessages: Record<string, string> = {
|
|
752
|
-
'0': cart.orderData.proof_purchase ? '待核款' : '未付款',
|
|
753
|
-
'1': '已付款',
|
|
754
|
-
'-2': '已退款',
|
|
755
|
-
};
|
|
756
|
-
|
|
757
|
-
return statusMessages[`${cart.status}`] || '付款失敗';
|
|
758
|
-
}
|
|
759
657
|
}
|
|
@@ -8,27 +8,19 @@ import { EditorElem } from '../../glitterBundle/plugins/editor-elem.js';
|
|
|
8
8
|
const html = String.raw;
|
|
9
9
|
export class OrderSetting {
|
|
10
10
|
static getPaymentMethodText(orderData) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
return '銀行轉帳';
|
|
25
|
-
case 'line':
|
|
26
|
-
return 'Line 轉帳';
|
|
27
|
-
case 'cash_on_delivery':
|
|
28
|
-
return '貨到付款';
|
|
29
|
-
default:
|
|
30
|
-
return '線下付款';
|
|
31
|
-
}
|
|
11
|
+
const paymentMethods = {
|
|
12
|
+
POS: '門市POS付款',
|
|
13
|
+
off_line: '線下付款',
|
|
14
|
+
newWebPay: '藍新金流',
|
|
15
|
+
ecPay: '綠界金流',
|
|
16
|
+
line_pay: 'Line Pay',
|
|
17
|
+
atm: '銀行轉帳',
|
|
18
|
+
line: 'Line 轉帳',
|
|
19
|
+
cash_on_delivery: '貨到付款',
|
|
20
|
+
};
|
|
21
|
+
return orderData.orderSource === 'POS'
|
|
22
|
+
? paymentMethods['POS']
|
|
23
|
+
: paymentMethods[orderData.customer_info.payment_select] || '線下付款';
|
|
32
24
|
}
|
|
33
25
|
static getShippingMethodText(orderData) {
|
|
34
26
|
switch (orderData.user_info.shipment) {
|
|
@@ -1691,26 +1683,30 @@ export class OrderSetting {
|
|
|
1691
1683
|
});
|
|
1692
1684
|
const handleSave = () => {
|
|
1693
1685
|
const alertHTML = html `
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
<
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1686
|
+
<div class="d-flex flex-column">
|
|
1687
|
+
<div class="tx_normal text-start">
|
|
1688
|
+
您即將拆分訂單,系統將產生 ${splitOrderArray.length} 筆子訂單,拆分後:
|
|
1689
|
+
</div>
|
|
1690
|
+
<ul class="${gClass('dialog-ul')}">
|
|
1691
|
+
<li>原訂單調整金額與折扣,運費及附加費維持不變。子訂單按比例分配優惠。</li>
|
|
1692
|
+
<li>子訂單繼承母訂單設定,發票需手動作廢與重開。</li>
|
|
1693
|
+
<li>代收金額更新,已建立的出貨單需取消並重新建立。</li>
|
|
1694
|
+
</ul>
|
|
1695
|
+
</div>
|
|
1702
1696
|
`;
|
|
1703
1697
|
dialog.checkYesOrNotWithCustomWidth({
|
|
1704
1698
|
callback: bool => {
|
|
1705
1699
|
if (bool) {
|
|
1706
1700
|
orderData.lineItems.forEach((lineItem, index) => {
|
|
1707
1701
|
let count = 0;
|
|
1708
|
-
count = splitOrderArray.reduce((total, order) => {
|
|
1702
|
+
count = splitOrderArray.reduce((total, order) => {
|
|
1703
|
+
return (total += Number(order.lineItems[index].count));
|
|
1704
|
+
}, 0);
|
|
1709
1705
|
lineItem.count -= count;
|
|
1710
1706
|
});
|
|
1711
1707
|
const passData = {
|
|
1712
1708
|
orderData: orderData,
|
|
1713
|
-
splitOrderArray: splitOrderArray
|
|
1709
|
+
splitOrderArray: splitOrderArray,
|
|
1714
1710
|
};
|
|
1715
1711
|
ApiShop.combineOrder(vm.dataObject).then(r => {
|
|
1716
1712
|
if (r.result && r.response) {
|
|
@@ -1743,10 +1739,9 @@ export class OrderSetting {
|
|
|
1743
1739
|
else {
|
|
1744
1740
|
checkBTN = BgWidget.disableSave('拆分訂單');
|
|
1745
1741
|
}
|
|
1746
|
-
return html `
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
}, divCreate: { class: `${gClass('footer')}` }
|
|
1742
|
+
return html ` ${BgWidget.cancel(gvc.event(closeDialog))} ${checkBTN} `;
|
|
1743
|
+
},
|
|
1744
|
+
divCreate: { class: `${gClass('footer')}` },
|
|
1750
1745
|
});
|
|
1751
1746
|
const renderHint = (gvc) => {
|
|
1752
1747
|
const phoneCardStyle = isDesktop
|
|
@@ -1775,15 +1770,18 @@ export class OrderSetting {
|
|
|
1775
1770
|
})
|
|
1776
1771
|
.join('')}
|
|
1777
1772
|
</ul>
|
|
1778
|
-
<div
|
|
1773
|
+
<div
|
|
1774
|
+
class="${gClass('split-rule')} ms-auto d-flex align-items-end"
|
|
1775
|
+
onclick="${gvc.event(() => {
|
|
1779
1776
|
BgWidget.settingDialog({
|
|
1780
1777
|
gvc: gvc,
|
|
1781
1778
|
title: '拆單需知',
|
|
1782
1779
|
width: 766,
|
|
1783
1780
|
innerHTML: gvc => {
|
|
1784
|
-
return html `
|
|
1785
|
-
|
|
1786
|
-
|
|
1781
|
+
return html ` <ul class="${gClass('dialog-ul')}">
|
|
1782
|
+
<li>
|
|
1783
|
+
原訂單將保留剩餘商品,訂單金額與折扣將調整;子訂單將包含選定商品,並按比例分配優惠折扣
|
|
1784
|
+
</li>
|
|
1787
1785
|
<li>拆單後運費及附加費用不變,將保留於原訂單內,如需更改,請手動編輯訂單新增費用</li>
|
|
1788
1786
|
<li>子訂單會預設繼承母訂單的配送與付款方式,如需更改,請手動編輯訂單內容</li>
|
|
1789
1787
|
<li>子訂單若要重新開立發票,請至發票頁面手動建立</li>
|
|
@@ -1795,7 +1793,10 @@ export class OrderSetting {
|
|
|
1795
1793
|
return '';
|
|
1796
1794
|
},
|
|
1797
1795
|
});
|
|
1798
|
-
})}"
|
|
1796
|
+
})}"
|
|
1797
|
+
>
|
|
1798
|
+
詳細拆單規則
|
|
1799
|
+
</div>
|
|
1799
1800
|
</div>
|
|
1800
1801
|
</div>
|
|
1801
1802
|
`)}
|
|
@@ -1910,7 +1911,7 @@ export class OrderSetting {
|
|
|
1910
1911
|
<img class="${gClass('product-preview-img')}" src="${item.preview_image}" alt="產品圖片" />
|
|
1911
1912
|
<div class="d-flex flex-column flex-grow-1" style="gap:2px;">
|
|
1912
1913
|
<div class="tx_normal_14" style="white-space: normal;line-height: normal;">
|
|
1913
|
-
${Tool.truncateString((_a = item.title) !== null && _a !== void 0 ? _a :
|
|
1914
|
+
${Tool.truncateString((_a = item.title) !== null && _a !== void 0 ? _a : '', 10)} -${spec}
|
|
1914
1915
|
</div>
|
|
1915
1916
|
<div class="tx_normal_14 ${gClass('font-gray')}">
|
|
1916
1917
|
存貨單位 (SKU): ${(_b = item.sku) !== null && _b !== void 0 ? _b : '無SKU'}
|
|
@@ -2002,9 +2003,11 @@ export class OrderSetting {
|
|
|
2002
2003
|
});
|
|
2003
2004
|
};
|
|
2004
2005
|
const renderBlock = (gvc) => {
|
|
2005
|
-
const subBlock = splitOrderArray
|
|
2006
|
+
const subBlock = splitOrderArray
|
|
2007
|
+
.map((order, index) => {
|
|
2006
2008
|
return html `<div class="${gClass('summary-subSummary')}"></div>`;
|
|
2007
|
-
})
|
|
2009
|
+
})
|
|
2010
|
+
.join('');
|
|
2008
2011
|
return html `
|
|
2009
2012
|
<div class="d-flex" style="height:27px;">
|
|
2010
2013
|
<div class="${gClass('summary-title')}"></div>
|
|
@@ -2063,7 +2066,9 @@ export class OrderSetting {
|
|
|
2063
2066
|
<div class="d-flex align-items-center">
|
|
2064
2067
|
<span class="text-decoration-line-through">${orderData.total}</span
|
|
2065
2068
|
><i class="fa-solid fa-arrow-right ${gClass('font-blue')} ${gClass('summary-right')}"></i
|
|
2066
|
-
><span class="${gClass('font-blue')}"
|
|
2069
|
+
><span class="${gClass('font-blue')}"
|
|
2070
|
+
>${sale_price - split_price - discount + orderData.shipment_fee}</span
|
|
2071
|
+
>
|
|
2067
2072
|
</div>
|
|
2068
2073
|
`;
|
|
2069
2074
|
}
|