biz9-logic 4.9.8 → 4.9.11
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/biz9_config +1 -1
- package/index.js +46 -12
- package/package.json +1 -1
- package/test.js +4 -4
package/biz9_config
CHANGED
package/index.js
CHANGED
|
@@ -466,6 +466,7 @@ class Order_Logic {
|
|
|
466
466
|
parent_id:cart_item.parent_id,
|
|
467
467
|
user_id:order.user_id,
|
|
468
468
|
quanity:cart_item.quanity,
|
|
469
|
+
cost:cart_item.cost,
|
|
469
470
|
order_sub_item_list:[]
|
|
470
471
|
});
|
|
471
472
|
cart_item.cart_sub_item_list.forEach(cart_sub_item => {
|
|
@@ -474,14 +475,15 @@ class Order_Logic {
|
|
|
474
475
|
parent_data_type:cart_sub_item.parent_data_type,
|
|
475
476
|
parent_id:cart_sub_item.parent_id,
|
|
476
477
|
user_id:order.user_id,
|
|
477
|
-
quanity:cart_sub_item.quanity
|
|
478
|
+
quanity:cart_sub_item.quanity,
|
|
479
|
+
cost:cart_sub_item.cost
|
|
478
480
|
})
|
|
479
481
|
order_item.order_sub_item_list.push(order_sub_item);
|
|
480
482
|
});
|
|
481
|
-
|
|
482
483
|
order.order_item_list.push(order_item);
|
|
483
484
|
|
|
484
485
|
});
|
|
486
|
+
order = Order_Logic.caculate_total(order);
|
|
485
487
|
return order;
|
|
486
488
|
};
|
|
487
489
|
static get_new_order_payment = (order_number,payment_method_type,payment_amount) => {
|
|
@@ -493,17 +495,53 @@ class Order_Logic {
|
|
|
493
495
|
transaction_id:Order_Logic.TRANSACTION_ID + Num.get_id(99999)
|
|
494
496
|
});
|
|
495
497
|
};
|
|
498
|
+
static caculate_total = (order) => {
|
|
499
|
+
let grand_total = 0;
|
|
500
|
+
order.order_item_list.forEach(order_item => {
|
|
501
|
+
order_item.sub_total = 0;
|
|
502
|
+
if(!isNaN(order_item.cost)){
|
|
503
|
+
order_item.sub_total = (order_item.sub_total + order_item.cost) * order_item.quanity;
|
|
504
|
+
order.grand_total = order.grand_total + order_item.sub_total;
|
|
505
|
+
}
|
|
506
|
+
order_item.order_sub_item_list.forEach(order_sub_item => {
|
|
507
|
+
order_sub_item.sub_total = 0;
|
|
508
|
+
if(!isNaN(order_sub_item.cost)){
|
|
509
|
+
order_sub_item.sub_total = (order_sub_item.sub_total + order_sub_item.cost) * order_sub_item.quanity;
|
|
510
|
+
order.grand_total = order.grand_total + order_sub_item.sub_total;
|
|
511
|
+
}
|
|
512
|
+
});
|
|
513
|
+
});
|
|
514
|
+
return order;
|
|
515
|
+
};
|
|
496
516
|
}
|
|
497
517
|
class Cart_Logic {
|
|
498
518
|
static get_new = (parent_data_type,user_id) => {
|
|
499
519
|
return DataItem.get_new(DataType.CART,0,{user_id:user_id,cart_number:Title.CART_NUMBER + Num.get_id(99999),parent_data_type:parent_data_type,grand_total:0,cart_item_list:[]});
|
|
500
520
|
};
|
|
501
|
-
static get_new_cart_item = (parent_data_type,parent_id,cart_number,quanity) =>{
|
|
502
|
-
return DataItem.get_new(DataType.CART_ITEM,0,{parent_data_type:parent_data_type,parent_id:parent_id,cart_number:cart_number,quanity:quanity,cart_sub_item_list:[]});
|
|
521
|
+
static get_new_cart_item = (parent_data_type,parent_id,cart_number,quanity,cost) =>{
|
|
522
|
+
return DataItem.get_new(DataType.CART_ITEM,0,{parent_data_type:parent_data_type,parent_id:parent_id,cart_number:cart_number,quanity:quanity,cost:cost?cost:0,cart_sub_item_list:[]});
|
|
503
523
|
};
|
|
504
|
-
static get_new_cart_sub_item = (parent_data_type,parent_id,cart_number,quanity) =>{
|
|
505
|
-
return DataItem.get_new(DataType.CART_SUB_ITEM,0,{parent_data_type:parent_data_type,parent_id:parent_id,cart_number:cart_number,quanity:quanity});
|
|
524
|
+
static get_new_cart_sub_item = (parent_data_type,parent_id,cart_number,quanity,cost) =>{
|
|
525
|
+
return DataItem.get_new(DataType.CART_SUB_ITEM,0,{parent_data_type:parent_data_type,parent_id:parent_id,cart_number:cart_number,quanity:quanity,cost:cost?cost:0});
|
|
506
526
|
};
|
|
527
|
+
static get_grand_total = (cart) => {
|
|
528
|
+
let grand_total = 0;
|
|
529
|
+
cart.cart_item_list.forEach(cart_item => {
|
|
530
|
+
cart_item.sub_total = 0;
|
|
531
|
+
if(!isNaN(cart_item.cost)){
|
|
532
|
+
cart_item.sub_total = (cart_item.sub_total + cart_item.cost) * cart_item.quanity;
|
|
533
|
+
grand_total = grand_total + cart_item.sub_total;
|
|
534
|
+
}
|
|
535
|
+
cart_item.cart_sub_item_list.forEach(cart_sub_item => {
|
|
536
|
+
cart_sub_item.sub_total = 0;
|
|
537
|
+
if(!isNaN(cart_sub_item.cost)){
|
|
538
|
+
cart_sub_item.sub_total = (cart_sub_item.sub_total + cart_sub_item.cost) * cart_sub_item.quanity;
|
|
539
|
+
grand_total = grand_total + cart_sub_item.sub_total;
|
|
540
|
+
}
|
|
541
|
+
});
|
|
542
|
+
});
|
|
543
|
+
return grand_total;
|
|
544
|
+
};
|
|
507
545
|
}
|
|
508
546
|
class Product_Logic {
|
|
509
547
|
static get_new = (title,type,category,option) => {
|
|
@@ -1551,6 +1589,7 @@ class App_Logic {
|
|
|
1551
1589
|
return {data_type:data_type,filter:filter,sort_by:sort_by,page_current:page_current,page_size:page_size};
|
|
1552
1590
|
}
|
|
1553
1591
|
static get_not_found = (data_type,id,option) =>{
|
|
1592
|
+
option=option?option:{app_id:'blank'};
|
|
1554
1593
|
if(data_type != DataType.USER){
|
|
1555
1594
|
if(!id){
|
|
1556
1595
|
id=0;
|
|
@@ -1567,12 +1606,9 @@ class App_Logic {
|
|
|
1567
1606
|
}
|
|
1568
1607
|
return item;
|
|
1569
1608
|
}else{
|
|
1570
|
-
if(!user_id){
|
|
1571
|
-
user_id=0;
|
|
1572
|
-
}
|
|
1573
1609
|
let user = User_Logic.get_test("",{get_blank:true})
|
|
1574
1610
|
user.id = 0;
|
|
1575
|
-
user.id_key =
|
|
1611
|
+
user.id_key = id;
|
|
1576
1612
|
user.title = "User Not Found";
|
|
1577
1613
|
user.first_name = "User Not Found";
|
|
1578
1614
|
user.title_url = Str.get_title_url(user.title);
|
|
@@ -1719,7 +1755,6 @@ class Url {
|
|
|
1719
1755
|
static CART_DELETE="item/cart_delete";
|
|
1720
1756
|
static CART="item/cart";
|
|
1721
1757
|
static CART_POST="item/cart_post";
|
|
1722
|
-
static SEARCH_CART="item/cart_search";
|
|
1723
1758
|
//category
|
|
1724
1759
|
static CATEGORY_DETAIL="category/detail";
|
|
1725
1760
|
static CATEGORY_HOME="category/home";
|
|
@@ -1764,7 +1799,6 @@ class Url {
|
|
|
1764
1799
|
static ORDER_DELETE="item/order_delete";
|
|
1765
1800
|
static ORDER="item/order";
|
|
1766
1801
|
static ORDER_POST="item/order_post";
|
|
1767
|
-
static ORDER_SEARCH="item/order_search";
|
|
1768
1802
|
//page
|
|
1769
1803
|
static HOME="page/home";
|
|
1770
1804
|
static ABOUT="page/about";
|
package/package.json
CHANGED
package/test.js
CHANGED
|
@@ -33,7 +33,6 @@ describe("connect", () => {
|
|
|
33
33
|
console.log('CONNECT-START');
|
|
34
34
|
console.log(Cart_Logic.get_new(DataType.PRODUCT,123));
|
|
35
35
|
|
|
36
|
-
/*
|
|
37
36
|
let post_type_list = [
|
|
38
37
|
Demo_Logic.get_new_type('Computer 1',{
|
|
39
38
|
get_category:true,category_count:12,category_data_type:DataType.PRODUCT,categorys:'',
|
|
@@ -44,6 +43,7 @@ describe("connect", () => {
|
|
|
44
43
|
];
|
|
45
44
|
|
|
46
45
|
Log.w('post_type_list',post_type_list);
|
|
46
|
+
|
|
47
47
|
let post_item_count = 0;
|
|
48
48
|
let post_category_count = 0;
|
|
49
49
|
for(const item_type of post_type_list){
|
|
@@ -59,11 +59,11 @@ describe("connect", () => {
|
|
|
59
59
|
};
|
|
60
60
|
|
|
61
61
|
Log.w('post_type_list',post_type_list);
|
|
62
|
-
Log.w('
|
|
62
|
+
Log.w('post_type_list',post_type_list[0].categorys);
|
|
63
|
+
//Log.w('post_item_count',post_item_count);
|
|
63
64
|
|
|
64
|
-
*/
|
|
65
65
|
console.log('CONNECT-END');
|
|
66
|
-
call();
|
|
66
|
+
//call();
|
|
67
67
|
},
|
|
68
68
|
function(call) {
|
|
69
69
|
console.log('GET_START_DATE_TIME_BY_LIST-START');
|