biz9-logic 4.8.145 → 4.8.148
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 +65 -56
- package/package.json +1 -1
- package/test.js +3 -1
package/biz9_config
CHANGED
package/index.js
CHANGED
|
@@ -34,6 +34,20 @@ class Item_Logic {
|
|
|
34
34
|
}
|
|
35
35
|
return item;
|
|
36
36
|
}
|
|
37
|
+
static get_not_found = (data_type,id,option) =>{
|
|
38
|
+
if(!id){
|
|
39
|
+
id=0;
|
|
40
|
+
}
|
|
41
|
+
let item = Item_Logic.get_test("",data_type,id,{get_blank:true})
|
|
42
|
+
item.id = 0;
|
|
43
|
+
item.id_key = id;
|
|
44
|
+
item.title = "Item Not Found";
|
|
45
|
+
item.title_url = Str.get_title_url(item.title);
|
|
46
|
+
if(option.app_id){
|
|
47
|
+
item.app_id = option.app_id;
|
|
48
|
+
}
|
|
49
|
+
return item;
|
|
50
|
+
};
|
|
37
51
|
static get_test_list = (data_type,option) =>{
|
|
38
52
|
option = Field_Logic.get_option(data_type,option?option:{});
|
|
39
53
|
let item_list = [];
|
|
@@ -215,11 +229,22 @@ class Page_Logic {
|
|
|
215
229
|
return item_list;
|
|
216
230
|
}
|
|
217
231
|
}
|
|
232
|
+
class Order_Logic {
|
|
233
|
+
static get_order_number = () => {
|
|
234
|
+
return FieldType.ORDER_NUMBER + Number.get_id(99999);
|
|
235
|
+
};
|
|
236
|
+
}
|
|
218
237
|
class Cart_Logic {
|
|
219
238
|
static get_cart_number = () => {
|
|
220
239
|
return FieldType.CART_NUMBER + Number.get_id(99999);
|
|
221
|
-
}
|
|
222
|
-
static
|
|
240
|
+
};
|
|
241
|
+
static get_cart = (user_id) => {
|
|
242
|
+
return DataItem.get_new(DataType.CART,0,{user_id:user_id,cart_number:Cart_Logic.get_cart_number(),quanity:1,grand_total:0,cart_item_list:[]});
|
|
243
|
+
};
|
|
244
|
+
static get_cart_item = (parent_data_type,parent_id,cart_number,user_id,quanity) =>{
|
|
245
|
+
return DataItem.get_new(DataType.CART_ITEM,0,{parent_data_type:parent_data_type,parent_id:parent_id,cart_number:cart_number,user_id:user_id,quanity:quanity,sub_total:0,cart_sub_item_list:[]});
|
|
246
|
+
};
|
|
247
|
+
static get_test_item = (cart_item_id,cart_number,user_id,parent_data_type,parent_id,option) =>{
|
|
223
248
|
option = Field_Logic.get_option(DataType.CART_ITEM,option?option:{generate_id:Str.check_is_null(cart_item_id)? true : false });
|
|
224
249
|
let cart_item = DataItem.get_new(DataType.CART_ITEM,Number.get_guid(),Field_Logic.get_test("Cart Item "+Number.get_id(),option));
|
|
225
250
|
cart_item.cart_item_id = cart_item_id;
|
|
@@ -230,13 +255,13 @@ class Cart_Logic {
|
|
|
230
255
|
if(option.get_cart_sub_item){
|
|
231
256
|
cart_item.cart_sub_item_list = [];
|
|
232
257
|
for(let a = 0;a<option.cart_sub_item_count;a++){
|
|
233
|
-
let cart_sub_item = Cart_Logic.
|
|
258
|
+
let cart_sub_item = Cart_Logic.get_test_sub_item(cart_number,user_id,cart_item.id,parent_data_type,parent_id,{get_value:true,get_cart_sub_item:option.get_cart_sub_item,cart_sub_item_count:option.cart_sub_item_count});
|
|
234
259
|
cart_item.cart_sub_item_list.push(cart_sub_item);
|
|
235
260
|
}
|
|
236
261
|
}
|
|
237
262
|
return cart_item;
|
|
238
263
|
};
|
|
239
|
-
static
|
|
264
|
+
static get_test_sub_item = (cart_number,user_id,cart_item_id,parent_data_type,parent_id,option) =>{
|
|
240
265
|
option = Field_Logic.get_option(DataType.CART_SUB_ITEM,option?option:{});
|
|
241
266
|
let item_blank = Item_Logic.get_test('Sub Item '+Number.get_id(),DataType.ITEM,0,{generate_id:true});
|
|
242
267
|
let cart_sub_item = DataItem.get_new(DataType.CART_SUB_ITEM,Number.get_guid(),Field_Logic.get_test("Cart Sub Item "+Number.get_id(),option));
|
|
@@ -311,7 +336,7 @@ class Product_Logic {
|
|
|
311
336
|
let product_list = Product_Logic.get_test_list(product_option);
|
|
312
337
|
cart.cart_item_list = [];
|
|
313
338
|
for(let a = 0;a<product_list.length;a++){
|
|
314
|
-
let product_cart_item =Cart_Logic.
|
|
339
|
+
let product_cart_item =Cart_Logic.get_test_item(cart_number,cart.id,user_id,product_list[a].data_type,product_list[a].id,{get_value:false,get_cart_sub_item:option.get_cart_sub_item,cart_sub_item_count:option.cart_sub_item_count,generate_id:true});
|
|
315
340
|
product_cart_item.parent_item = product_list[a];
|
|
316
341
|
cart.cart_item_list.push(product_cart_item);
|
|
317
342
|
}
|
|
@@ -775,6 +800,7 @@ class FieldType {
|
|
|
775
800
|
static KEY_ADMIN="key_admin";
|
|
776
801
|
static KEY_APP_ID="key_app_id";
|
|
777
802
|
static KEY_BUSINESS="key_business";
|
|
803
|
+
static KEY_TEMPLATE="key_template";
|
|
778
804
|
static KEY_CART="key_cart";
|
|
779
805
|
static KEY_GUEST="key_guest";
|
|
780
806
|
static KEY_ORDER="key_order";
|
|
@@ -1029,16 +1055,16 @@ class Favorite_Logic {
|
|
|
1029
1055
|
static get_user_search_filter = (parent_data_type,user_id) =>{
|
|
1030
1056
|
return {
|
|
1031
1057
|
$and: [
|
|
1032
|
-
{ parent_data_type: { $regex:parent_data_type, $options: "i" } },
|
|
1033
|
-
{ user_id: { $regex:user_id, $options: "i" } }
|
|
1058
|
+
{ parent_data_type: { $regex:String(parent_data_type), $options: "i" } },
|
|
1059
|
+
{ user_id: { $regex:String(user_id), $options: "i" } }
|
|
1034
1060
|
] };
|
|
1035
1061
|
}
|
|
1036
1062
|
static get_search_filter = (parent_data_type,parent_id,user_id) =>{
|
|
1037
1063
|
return {
|
|
1038
1064
|
$and: [
|
|
1039
|
-
{ parent_data_type: { $regex:parent_data_type, $options: "i" } },
|
|
1040
|
-
{ parent_id: { $regex:parent_id, $options: "i" } },
|
|
1041
|
-
{ user_id: { $regex:user_id, $options: "i" } }
|
|
1065
|
+
{ parent_data_type: { $regex:String(parent_data_type), $options: "i" } },
|
|
1066
|
+
{ parent_id: { $regex:String(parent_id), $options: "i" } },
|
|
1067
|
+
{ user_id: { $regex:String(user_id), $options: "i" } }
|
|
1042
1068
|
] };
|
|
1043
1069
|
}
|
|
1044
1070
|
}
|
|
@@ -1057,8 +1083,8 @@ class Review_Logic {
|
|
|
1057
1083
|
static get_search_filter = (parent_data_type,parent_id) =>{
|
|
1058
1084
|
return {
|
|
1059
1085
|
$and: [
|
|
1060
|
-
{ parent_data_type: { $regex:parent_data_type, $options: "i" } },
|
|
1061
|
-
{ parent_id: { $regex:parent_id, $options: "i" } },
|
|
1086
|
+
{ parent_data_type: { $regex:String(parent_data_type), $options: "i" } },
|
|
1087
|
+
{ parent_id: { $regex:String(parent_id), $options: "i" } },
|
|
1062
1088
|
] };
|
|
1063
1089
|
}
|
|
1064
1090
|
static get_test = (parent_data_type,parent_id,user_id,option) =>{
|
|
@@ -1266,62 +1292,29 @@ class Cart_Url {
|
|
|
1266
1292
|
let action_url="cart/update/"+parent_data_type+"/"+user_id;
|
|
1267
1293
|
return get_cloud_url_main(biz9_config.APP_ID,biz9_config.URL,action_url,params);
|
|
1268
1294
|
};
|
|
1269
|
-
static get = (biz9_config,
|
|
1270
|
-
let action_url="cart/get/"+
|
|
1295
|
+
static get = (biz9_config,cart_number,params) => {
|
|
1296
|
+
let action_url="cart/get/"+cart_number;
|
|
1271
1297
|
return get_cloud_url_main(biz9_config.APP_ID,biz9_config.URL,action_url,params);
|
|
1272
1298
|
};
|
|
1273
1299
|
static delete = (biz9_config,id,params) => {
|
|
1274
1300
|
let action_url="cart/delete/"+id;
|
|
1275
1301
|
return get_cloud_url_main(biz9_config.APP_ID,biz9_config.URL,action_url,params);
|
|
1276
1302
|
};
|
|
1277
|
-
static search = (biz9_config,params) => {
|
|
1278
|
-
let action_url="cart/search";
|
|
1279
|
-
return get_cloud_url_main(biz9_config.APP_ID,biz9_config.URL,action_url,params);
|
|
1280
|
-
};
|
|
1281
1303
|
}
|
|
1282
1304
|
class Order_Url {
|
|
1283
|
-
static
|
|
1284
|
-
let action_url="order/
|
|
1285
|
-
return get_cloud_url_main(biz9_config.APP_ID,biz9_config.URL,action_url,params);
|
|
1286
|
-
};
|
|
1287
|
-
static checkout_success = (biz9_config,cart_number,params) => {
|
|
1288
|
-
let action_url="order/checkout-success/"+cart_number;
|
|
1305
|
+
static update = (biz9_config,params) => {
|
|
1306
|
+
let action_url="order/update";
|
|
1289
1307
|
return get_cloud_url_main(biz9_config.APP_ID,biz9_config.URL,action_url,params);
|
|
1290
1308
|
};
|
|
1291
|
-
static
|
|
1292
|
-
let action_url="order/
|
|
1309
|
+
static get = (biz9_config,order_number,params) => {
|
|
1310
|
+
let action_url="order/get/"+order_number;
|
|
1293
1311
|
return get_cloud_url_main(biz9_config.APP_ID,biz9_config.URL,action_url,params);
|
|
1294
1312
|
};
|
|
1295
|
-
static
|
|
1296
|
-
let action_url="order/
|
|
1297
|
-
return get_cloud_url_main(biz9_config.APP_ID,biz9_config.URL,action_url,params);
|
|
1298
|
-
};
|
|
1299
|
-
static cart_delete = (biz9_config,id,params) => {
|
|
1300
|
-
let action_url="order/cart-delete/"+id;
|
|
1301
|
-
return get_cloud_url_main(biz9_config.APP_ID,biz9_config.URL,action_url,params);
|
|
1302
|
-
};
|
|
1303
|
-
static cart_search = (biz9_config,params) => {
|
|
1304
|
-
let action_url="order/cart-search/";
|
|
1305
|
-
return get_cloud_url_main(biz9_config.APP_ID,biz9_config.URL,action_url,params);
|
|
1306
|
-
};
|
|
1307
|
-
static order_update = (biz9_config,params) => {
|
|
1308
|
-
let action_url="order/order-update/";
|
|
1309
|
-
return get_cloud_url_main(biz9_config.APP_ID,biz9_config.URL,action_url,params);
|
|
1310
|
-
};
|
|
1311
|
-
static order_get = (biz9_config,order_id,params) => {
|
|
1312
|
-
let action_url="order/order-get/"+order_id;
|
|
1313
|
-
return get_cloud_url_main(biz9_config.APP_ID,biz9_config.URL,action_url,params);
|
|
1314
|
-
};
|
|
1315
|
-
static order_delete = (biz9_config,id,params) => {
|
|
1316
|
-
let action_url="order/order-delete/"+id;
|
|
1317
|
-
return get_cloud_url_main(biz9_config.APP_ID,biz9_config.URL,action_url,params);
|
|
1318
|
-
};
|
|
1319
|
-
static order_search = (biz9_config,params) => {
|
|
1320
|
-
let action_url="order/order-search/";
|
|
1313
|
+
static delete = (biz9_config,id,params) => {
|
|
1314
|
+
let action_url="order/delete/"+id;
|
|
1321
1315
|
return get_cloud_url_main(biz9_config.APP_ID,biz9_config.URL,action_url,params);
|
|
1322
1316
|
};
|
|
1323
1317
|
}
|
|
1324
|
-
|
|
1325
1318
|
class Product_Url {
|
|
1326
1319
|
static get = (biz9_config,key,params) => {
|
|
1327
1320
|
let action_url="product/get/"+key;
|
|
@@ -1884,20 +1877,35 @@ class User_Logic {
|
|
|
1884
1877
|
static get_guest(){
|
|
1885
1878
|
return DataItem.get_new(DataType.USER,Number.get_id(999),{is_guest:true,title:"Guest",country:"United States"});
|
|
1886
1879
|
}
|
|
1887
|
-
static
|
|
1880
|
+
static get_request_user(req){
|
|
1888
1881
|
if(!req || !req.session.user){
|
|
1889
1882
|
let user=DataItem.get_new(DataType.USER,Number.get_id(9999999),{is_guest:true});
|
|
1890
1883
|
req.session.user=user;
|
|
1891
1884
|
}
|
|
1892
1885
|
return req.session.user;
|
|
1893
1886
|
}
|
|
1894
|
-
static
|
|
1887
|
+
static set_request_user(req){
|
|
1895
1888
|
req.session.user=user;
|
|
1896
1889
|
}
|
|
1897
|
-
static
|
|
1890
|
+
static del_request_user(req){
|
|
1898
1891
|
req.session.user=null;
|
|
1899
1892
|
delete req.session.user;
|
|
1900
1893
|
}
|
|
1894
|
+
static get_not_found = (user_id,option) =>{
|
|
1895
|
+
if(!user_id){
|
|
1896
|
+
user_id=0;
|
|
1897
|
+
}
|
|
1898
|
+
let user = User_Logic.get_test("",{get_blank:true})
|
|
1899
|
+
user.id = 0;
|
|
1900
|
+
user.id_key = user_id;
|
|
1901
|
+
user.title = "User Not Found";
|
|
1902
|
+
user.first_name = "User Not Found";
|
|
1903
|
+
user.title_url = Str.get_title_url(user.title);
|
|
1904
|
+
if(option.app_id){
|
|
1905
|
+
user.app_id = option.app_id;
|
|
1906
|
+
}
|
|
1907
|
+
return user;
|
|
1908
|
+
};
|
|
1901
1909
|
static get_test = (title,option) =>{
|
|
1902
1910
|
[title,option] = Field_Logic.get_option_title(title,option);
|
|
1903
1911
|
option = Field_Logic.get_option(DataType.USER,option?option:{});
|
|
@@ -2021,6 +2029,7 @@ module.exports = {
|
|
|
2021
2029
|
Product_Logic,
|
|
2022
2030
|
Review_Logic,
|
|
2023
2031
|
Review_Url,
|
|
2032
|
+
Order_Logic,
|
|
2024
2033
|
Order_Url,
|
|
2025
2034
|
Service_Logic,
|
|
2026
2035
|
Service_Url,
|
package/package.json
CHANGED
package/test.js
CHANGED
|
@@ -103,7 +103,7 @@ describe("connect", () => {
|
|
|
103
103
|
//let user_list = User_Logic.get_test_list();
|
|
104
104
|
//Log.w('user',user);
|
|
105
105
|
//Log.w('user_list',user_list);
|
|
106
|
-
Log.w('guest',User_Logic.get_guest());
|
|
106
|
+
//Log.w('guest',User_Logic.get_guest());
|
|
107
107
|
/* --USER--END */
|
|
108
108
|
|
|
109
109
|
/* --SEARCH--START */
|
|
@@ -153,6 +153,8 @@ describe("connect", () => {
|
|
|
153
153
|
|
|
154
154
|
|
|
155
155
|
/* --CONTENT--START */
|
|
156
|
+
let item_list = Content_Logic.get_test_list({content_count:6,get_item:false,get_value:false,get_blank:true});
|
|
157
|
+
Log.w('content_list',item_list);
|
|
156
158
|
//let content = Content_Logic.get_test("cool 1");
|
|
157
159
|
//let content = Content_Logic.get_test("Content 1",{get_value:true,get_item:true})
|
|
158
160
|
//Log.w("content",content);
|