biz9-logic 4.9.18 → 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 +19 -11
- package/package.json +1 -1
- package/test.js +5 -3
package/biz9_config
CHANGED
package/index.js
CHANGED
|
@@ -86,11 +86,11 @@ 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";
|
|
@@ -465,8 +465,8 @@ class Order_Logic {
|
|
|
465
465
|
parent_data_type:cart_item.parent_data_type,
|
|
466
466
|
parent_id:cart_item.parent_id,
|
|
467
467
|
user_id:order.user_id,
|
|
468
|
-
quanity:cart_item.quanity,
|
|
469
|
-
cost:cart_item.cost,
|
|
468
|
+
quanity:cart_item.quanity?cart_item.quanity:0,
|
|
469
|
+
cost:cart_item.cost?cart_item.cost:0,
|
|
470
470
|
order_sub_item_list:[]
|
|
471
471
|
});
|
|
472
472
|
cart_item.cart_sub_item_list.forEach(cart_sub_item => {
|
|
@@ -475,8 +475,8 @@ class Order_Logic {
|
|
|
475
475
|
parent_data_type:cart_sub_item.parent_data_type,
|
|
476
476
|
parent_id:cart_sub_item.parent_id,
|
|
477
477
|
user_id:order.user_id,
|
|
478
|
-
quanity:cart_sub_item.quanity,
|
|
479
|
-
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
|
|
480
480
|
})
|
|
481
481
|
order_item.order_sub_item_list.push(order_sub_item);
|
|
482
482
|
});
|
|
@@ -491,10 +491,11 @@ class Order_Logic {
|
|
|
491
491
|
order_number:order_number,
|
|
492
492
|
payment_method_type:payment_method_type,
|
|
493
493
|
payment_amount:payment_amount,
|
|
494
|
+
payment_amount:payment_amount,
|
|
494
495
|
transaction_id:Title.ORDER_TRANSACTION_ID + Num.get_id(99999)
|
|
495
496
|
});
|
|
496
497
|
};
|
|
497
|
-
|
|
498
|
+
static get_total = (order) => {
|
|
498
499
|
let grand_total = 0;
|
|
499
500
|
order.order_item_list.forEach(order_item => {
|
|
500
501
|
order_item.sub_total = 0;
|
|
@@ -510,19 +511,26 @@ class Order_Logic {
|
|
|
510
511
|
}
|
|
511
512
|
});
|
|
512
513
|
});
|
|
513
|
-
|
|
514
|
+
order.grand_total = grand_total;
|
|
514
515
|
return order;
|
|
515
516
|
};
|
|
516
517
|
}
|
|
517
518
|
class Cart_Logic {
|
|
518
|
-
static get_new = (parent_data_type,user_id) => {
|
|
519
|
-
|
|
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;
|
|
520
528
|
};
|
|
521
529
|
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:[]});
|
|
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:[]});
|
|
523
531
|
};
|
|
524
532
|
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});
|
|
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});
|
|
526
534
|
};
|
|
527
535
|
static get_total = (cart) => {
|
|
528
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
|
|
|
@@ -32,7 +32,8 @@ describe("connect", () => {
|
|
|
32
32
|
function(call) {
|
|
33
33
|
console.log('CONNECT-START');
|
|
34
34
|
|
|
35
|
-
let post_cart = Cart_Logic.get_new(DataType.PRODUCT,0);
|
|
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
|
+
/*
|
|
36
37
|
let post_cart_list = [];
|
|
37
38
|
let post_cart_item = Cart_Logic.get_new_cart_item(DataType.PRODUCT,123,post_cart.cart_number,1,30);
|
|
38
39
|
let post_cart_sub_item = Cart_Logic.get_new_cart_sub_item(DataType.PRODUCT,1234,post_cart.cart_number,1,10);
|
|
@@ -40,9 +41,10 @@ describe("connect", () => {
|
|
|
40
41
|
post_cart_item.cart_sub_item_list.push(post_cart_sub_item);
|
|
41
42
|
post_cart_item.cart_sub_item_list.push(post_cart_sub_item_2);
|
|
42
43
|
post_cart.cart_item_list.push(post_cart_item);
|
|
44
|
+
*/
|
|
43
45
|
|
|
44
46
|
Log.w('post_cart',post_cart);
|
|
45
|
-
Log.w('post_cart_2',Cart_Logic.get_total(post_cart));
|
|
47
|
+
//Log.w('post_cart_2',Cart_Logic.get_total(post_cart));
|
|
46
48
|
|
|
47
49
|
|
|
48
50
|
console.log('CONNECT-END');
|