biz9-logic 4.9.17 → 4.9.20
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 +20 -17
- package/package.json +1 -1
- package/test.js +13 -32
package/biz9_config
CHANGED
package/index.js
CHANGED
|
@@ -86,36 +86,31 @@ class Title {
|
|
|
86
86
|
static ORDER_TRANSACTION_ID="TR-";
|
|
87
87
|
static ORDER_PAYMENT_STATUS_OPEN="Open";
|
|
88
88
|
static ORDER_PAYMENT_STATUS_COMPLETE="Complete";
|
|
89
|
-
static ORDER_PAYMENT_PLAN_PENDING="Pending";
|
|
90
89
|
static ORDER_PAYMENT_PLAN_1="1 Payment";
|
|
91
90
|
static ORDER_PAYMENT_PLAN_2="2 Payments";
|
|
92
91
|
static ORDER_PAYMENT_PLAN_3="3 Payments";
|
|
93
92
|
static ORDER_PAYMENT_PLAN_4="4 Payments";
|
|
93
|
+
static ORDER_PAYMENT_PLAN_5="5 Payments";
|
|
94
94
|
static ORDER_PAYMENT_METHOD_STRIPE="Stripe";
|
|
95
95
|
static ORDER_PAYMENT_METHOD_CASH="Cash";
|
|
96
96
|
static ORDER_PAYMENT_METHOD_OTHER="Other";
|
|
97
97
|
static ORDER_PAYMENT_METHOD_TEST="Test";
|
|
98
|
-
|
|
99
98
|
//cart
|
|
100
99
|
static CART_NUMBER="CA-";
|
|
101
|
-
|
|
102
100
|
//data_type
|
|
103
101
|
static DATA_TYPE_BLOG_POST="Blog Post";
|
|
104
102
|
static DATA_TYPE_CATEGORY="Category";
|
|
105
103
|
static DATA_TYPE_CONTENT="Content";
|
|
106
|
-
|
|
107
104
|
//role
|
|
108
105
|
static USER_ROLE_SUPER_ADMIN='Super Admin';
|
|
109
106
|
static USER_ROLE_ADMIN='Admin';
|
|
110
107
|
static USER_ROLE_MANAGER='Manager';
|
|
111
108
|
static USER_ROLE_USER='User';
|
|
112
109
|
static USER_ROLE_GUEST='Guest';
|
|
113
|
-
|
|
114
110
|
//app
|
|
115
111
|
static APP_MOBILE="Mobile";
|
|
116
112
|
static APP_WEBSITE="Website";
|
|
117
113
|
static APP_LANDING="Landing";
|
|
118
|
-
|
|
119
114
|
//social
|
|
120
115
|
static SOCIAL_URL_FACEBOOK="https://facebook.com/";
|
|
121
116
|
static SOCIAL_URL_TWITTER="https://twitter.com/";
|
|
@@ -470,8 +465,8 @@ class Order_Logic {
|
|
|
470
465
|
parent_data_type:cart_item.parent_data_type,
|
|
471
466
|
parent_id:cart_item.parent_id,
|
|
472
467
|
user_id:order.user_id,
|
|
473
|
-
quanity:cart_item.quanity,
|
|
474
|
-
cost:cart_item.cost,
|
|
468
|
+
quanity:cart_item.quanity?cart_item.quanity:0,
|
|
469
|
+
cost:cart_item.cost?cart_item.cost:0,
|
|
475
470
|
order_sub_item_list:[]
|
|
476
471
|
});
|
|
477
472
|
cart_item.cart_sub_item_list.forEach(cart_sub_item => {
|
|
@@ -480,8 +475,8 @@ class Order_Logic {
|
|
|
480
475
|
parent_data_type:cart_sub_item.parent_data_type,
|
|
481
476
|
parent_id:cart_sub_item.parent_id,
|
|
482
477
|
user_id:order.user_id,
|
|
483
|
-
quanity:cart_sub_item.quanity,
|
|
484
|
-
cost:cart_sub_item.cost
|
|
478
|
+
quanity:cart_sub_item.quanity?cart_sub_item.quanity:0,
|
|
479
|
+
cost:cart_sub_item.cost?cart_sub_item.cost:0
|
|
485
480
|
})
|
|
486
481
|
order_item.order_sub_item_list.push(order_sub_item);
|
|
487
482
|
});
|
|
@@ -496,10 +491,11 @@ class Order_Logic {
|
|
|
496
491
|
order_number:order_number,
|
|
497
492
|
payment_method_type:payment_method_type,
|
|
498
493
|
payment_amount:payment_amount,
|
|
499
|
-
|
|
494
|
+
payment_amount:payment_amount,
|
|
495
|
+
transaction_id:Title.ORDER_TRANSACTION_ID + Num.get_id(99999)
|
|
500
496
|
});
|
|
501
497
|
};
|
|
502
|
-
|
|
498
|
+
static get_total = (order) => {
|
|
503
499
|
let grand_total = 0;
|
|
504
500
|
order.order_item_list.forEach(order_item => {
|
|
505
501
|
order_item.sub_total = 0;
|
|
@@ -515,19 +511,26 @@ class Order_Logic {
|
|
|
515
511
|
}
|
|
516
512
|
});
|
|
517
513
|
});
|
|
518
|
-
|
|
514
|
+
order.grand_total = grand_total;
|
|
519
515
|
return order;
|
|
520
516
|
};
|
|
521
517
|
}
|
|
522
518
|
class Cart_Logic {
|
|
523
|
-
static get_new = (parent_data_type,user_id) => {
|
|
524
|
-
|
|
519
|
+
static get_new = (parent_data_type,user_id,option) => {
|
|
520
|
+
option = option?option:{get_payment_plan:false,payment_plan:Title.ORDER_PAYMENT_PLAN_1,payment_plan_status:Title.ORDER_PAYMENT_STATUS_OPEN};
|
|
521
|
+
Log.w('rrrrr',option);
|
|
522
|
+
let order = 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:[]});
|
|
523
|
+
if(option.get_payment_plan){
|
|
524
|
+
order.payment_plan = option.payment_plan;
|
|
525
|
+
order.payment_status = option.payment_plan_status;
|
|
526
|
+
}
|
|
527
|
+
return order;
|
|
525
528
|
};
|
|
526
529
|
static get_new_cart_item = (parent_data_type,parent_id,cart_number,quanity,cost) =>{
|
|
527
|
-
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:[]});
|
|
530
|
+
return DataItem.get_new(DataType.CART_ITEM,0,{parent_data_type:parent_data_type,parent_id:parent_id,cart_number:cart_number,quanity:quanity?quanity:0,cost:cost?cost:0,cart_sub_item_list:[]});
|
|
528
531
|
};
|
|
529
532
|
static get_new_cart_sub_item = (parent_data_type,parent_id,cart_number,quanity,cost) =>{
|
|
530
|
-
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});
|
|
533
|
+
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?quanity:0,cost:cost?cost:0});
|
|
531
534
|
};
|
|
532
535
|
static get_total = (cart) => {
|
|
533
536
|
let grand_total = 0;
|
package/package.json
CHANGED
package/test.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const series = require('async-series');
|
|
2
|
-
const {DataItem,DataType,Page_Logic,Product_Logic,Type,Stat_Logic,Service_Logic,Blog_Post_Logic,Event_Logic,Demo_Logic,Cart_Logic} = require('./index');
|
|
2
|
+
const {DataItem,DataType,Page_Logic,Product_Logic,Type,Title,Stat_Logic,Service_Logic,Blog_Post_Logic,Event_Logic,Demo_Logic,Cart_Logic} = require('./index');
|
|
3
3
|
const {Log,Num,Str} = require('biz9-utility');
|
|
4
4
|
const {Scriptz}= require('biz9-scriptz');
|
|
5
5
|
|
|
@@ -31,40 +31,21 @@ describe("connect", () => {
|
|
|
31
31
|
series([
|
|
32
32
|
function(call) {
|
|
33
33
|
console.log('CONNECT-START');
|
|
34
|
-
//console.log(Cart_Logic.get_new(DataType.PRODUCT,123));
|
|
35
|
-
//console.log(Type.get_title(Str.get_title(DataType.BLOG_POST)));
|
|
36
|
-
console.log(Type.get_title(DataType.BLOG_POST));
|
|
37
|
-
/*
|
|
38
|
-
|
|
39
|
-
let post_type_list = [
|
|
40
|
-
Demo_Logic.get_new_type('Computer 1',{
|
|
41
|
-
get_category:true,category_count:12,category_data_type:DataType.PRODUCT,categorys:'',
|
|
42
|
-
get_item:true,item_count:500,item_data_type:DataType.PRODUCT,items:null}),
|
|
43
|
-
Demo_Logic.get_new_type('Computer 2',{
|
|
44
|
-
get_category:true,category_count:12,category_data_type:DataType.PRODUCT,categorys:'',
|
|
45
|
-
get_item:true,item_count:500,item_data_type:DataType.PRODUCT,items:null})
|
|
46
|
-
];
|
|
47
34
|
|
|
48
|
-
|
|
35
|
+
let post_cart = Cart_Logic.get_new(DataType.PRODUCT,0,{get_payment_plan:true,payment_plan:Title.ORDER_PAYMENT_PLAN_1,payment_plan_status:Title.ORDER_PAYMENT_STATUS_OPEN});
|
|
36
|
+
/*
|
|
37
|
+
let post_cart_list = [];
|
|
38
|
+
let post_cart_item = Cart_Logic.get_new_cart_item(DataType.PRODUCT,123,post_cart.cart_number,1,30);
|
|
39
|
+
let post_cart_sub_item = Cart_Logic.get_new_cart_sub_item(DataType.PRODUCT,1234,post_cart.cart_number,1,10);
|
|
40
|
+
let post_cart_sub_item_2 = Cart_Logic.get_new_cart_sub_item(DataType.PRODUCT,1234,post_cart.cart_number,1,30);
|
|
41
|
+
post_cart_item.cart_sub_item_list.push(post_cart_sub_item);
|
|
42
|
+
post_cart_item.cart_sub_item_list.push(post_cart_sub_item_2);
|
|
43
|
+
post_cart.cart_item_list.push(post_cart_item);
|
|
44
|
+
*/
|
|
49
45
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
for(const item_type of post_type_list){
|
|
53
|
-
for(const item_cat of item_type.categorys){
|
|
54
|
-
post_category_count = post_category_count+1;
|
|
55
|
-
if(!item_cat.items){
|
|
56
|
-
item_cat.items = []
|
|
57
|
-
}
|
|
58
|
-
for(const item_item of item_cat.items){
|
|
59
|
-
post_item_count = post_item_count+1;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
};
|
|
46
|
+
Log.w('post_cart',post_cart);
|
|
47
|
+
//Log.w('post_cart_2',Cart_Logic.get_total(post_cart));
|
|
63
48
|
|
|
64
|
-
Log.w('post_type_list',post_type_list);
|
|
65
|
-
Log.w('post_type_list',post_type_list[0].categorys);
|
|
66
|
-
*/
|
|
67
|
-
//Log.w('post_item_count',post_item_count);
|
|
68
49
|
|
|
69
50
|
console.log('CONNECT-END');
|
|
70
51
|
//call();
|