ts-glitter 20.6.8 → 20.7.0
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 +2 -2
- package/lowcode/Entry.ts +2 -2
- package/lowcode/backend-manager/bg-blog.js +617 -621
- package/lowcode/backend-manager/bg-blog.ts +2323 -2325
- package/lowcode/backend-manager/bg-line.js +5 -4
- package/lowcode/backend-manager/bg-line.ts +5 -4
- package/lowcode/backend-manager/bg-list-component.js +9 -0
- package/lowcode/backend-manager/bg-list-component.ts +15 -1
- package/lowcode/backend-manager/bg-notify.js +6 -4
- package/lowcode/backend-manager/bg-notify.ts +6 -4
- package/lowcode/backend-manager/bg-product.js +145 -0
- package/lowcode/backend-manager/bg-product.ts +153 -0
- package/lowcode/backend-manager/bg-sns.js +5 -3
- package/lowcode/backend-manager/bg-sns.ts +5 -3
- package/lowcode/backend-manager/bg-widget.js +92 -4
- package/lowcode/backend-manager/bg-widget.ts +122 -6
- package/lowcode/backend-manager/splitPage.js +0 -39
- package/lowcode/backend-manager/splitPage.ts +0 -40
- package/lowcode/cms-plugin/auto-fcm-advertise.js +17 -5
- package/lowcode/cms-plugin/auto-fcm-advertise.ts +19 -6
- package/lowcode/cms-plugin/auto-fcm-history.js +2732 -0
- package/lowcode/cms-plugin/auto-fcm-history.ts +2995 -0
- package/lowcode/cms-plugin/cms-router.js +5 -0
- package/lowcode/cms-plugin/cms-router.ts +6 -0
- package/lowcode/cms-plugin/filter-options.js +80 -27
- package/lowcode/cms-plugin/filter-options.ts +83 -27
- package/lowcode/cms-plugin/language-backend.js +50 -39
- package/lowcode/cms-plugin/language-backend.ts +109 -95
- package/lowcode/cms-plugin/menus-setting.js +175 -151
- package/lowcode/cms-plugin/menus-setting.ts +620 -591
- package/lowcode/cms-plugin/model/order.d.ts +1 -0
- package/lowcode/cms-plugin/module/data.js +7 -7
- package/lowcode/cms-plugin/module/data.ts +262 -233
- package/lowcode/cms-plugin/module/delivery-html.js +18 -10
- package/lowcode/cms-plugin/module/delivery-html.ts +26 -10
- package/lowcode/cms-plugin/module/order-setting.js +458 -328
- package/lowcode/cms-plugin/module/order-setting.ts +622 -351
- package/lowcode/cms-plugin/module/product-excel.js +1 -1
- package/lowcode/cms-plugin/module/product-excel.ts +2 -1
- package/lowcode/cms-plugin/order/order-module.js +90 -1
- package/lowcode/cms-plugin/order/order-module.ts +106 -1
- package/lowcode/cms-plugin/pos-pages/payment-page.js +11 -8
- package/lowcode/cms-plugin/pos-pages/payment-page.ts +28 -15
- package/lowcode/cms-plugin/pos-pages/products-page.js +0 -39
- package/lowcode/cms-plugin/pos-pages/products-page.ts +0 -40
- package/lowcode/cms-plugin/shopping-collections.ts +1 -3
- package/lowcode/cms-plugin/shopping-finance-setting.js +19 -80
- package/lowcode/cms-plugin/shopping-finance-setting.ts +19 -87
- package/lowcode/cms-plugin/shopping-order-manager.js +122 -38
- package/lowcode/cms-plugin/shopping-order-manager.ts +160 -58
- package/lowcode/cms-plugin/shopping-product-setting.js +364 -376
- package/lowcode/cms-plugin/shopping-product-setting.ts +406 -415
- package/lowcode/cms-plugin/shopping-setting-advance.js +57 -16
- package/lowcode/cms-plugin/shopping-setting-advance.ts +69 -18
- package/lowcode/cms-plugin/stock-history.js +75 -63
- package/lowcode/cms-plugin/stock-history.ts +390 -376
- package/lowcode/cms-plugin/user/user-module.js +2 -43
- package/lowcode/cms-plugin/user/user-module.ts +2 -46
- package/lowcode/cms-plugin/user-list.js +4 -6
- package/lowcode/cms-plugin/user-list.ts +35 -38
- package/lowcode/css/editor.css +42 -3
- package/lowcode/glitter-base/global/language.js +6 -1
- package/lowcode/glitter-base/global/language.ts +10 -4
- package/lowcode/glitter-base/global/payment-config.js +19 -16
- package/lowcode/glitter-base/global/payment-config.ts +22 -16
- package/lowcode/glitter-base/global/shipment-config.js +6 -5
- package/lowcode/glitter-base/global/shipment-config.ts +12 -10
- package/lowcode/glitter-base/route/fcm.js +21 -1
- package/lowcode/glitter-base/route/fcm.ts +22 -2
- package/lowcode/glitter-base/route/shopping.js +8 -32
- package/lowcode/glitter-base/route/shopping.ts +10 -33
- package/lowcode/glitter-base/route/stock.ts +1 -0
- package/lowcode/glitter-base/route/user.js +11 -2
- package/lowcode/glitter-base/route/user.ts +23 -12
- package/lowcode/jspage/function-page/setting_editor.js +9 -0
- package/lowcode/jspage/function-page/setting_editor.ts +9 -0
- package/lowcode/public-components/blogs/list.js +223 -195
- package/lowcode/public-components/blogs/list.ts +383 -352
- package/lowcode/public-components/product/product-list.js +8 -4
- package/lowcode/public-components/product/product-list.ts +9 -4
- package/lowcode/public-components/terms-related/index.js +1 -1
- package/lowcode/public-components/terms-related/index.ts +1 -1
- package/lowcode/public-components/user-manager/um-login.js +1 -1
- package/lowcode/public-components/user-manager/um-login.ts +2 -2
- package/lowcode/public-components/user-manager/um-order.js +41 -5
- package/lowcode/public-components/user-manager/um-order.ts +58 -20
- package/lowcode/public-components/user-manager/um-voucher.ts +2 -2
- package/nhi4veq3gk.json +1 -0
- package/package.json +1 -1
- package/src/Language.d.ts +2 -0
- package/src/Language.js +66 -65
- package/src/Language.js.map +1 -1
- package/src/Language.ts +719 -715
- package/src/api-public/config/shipment-config.js +3 -2
- package/src/api-public/config/shipment-config.js.map +1 -1
- package/src/api-public/config/shipment-config.ts +3 -2
- package/src/api-public/controllers/ai-chat.js.map +1 -1
- package/src/api-public/controllers/ai-chat.ts +1 -2
- package/src/api-public/controllers/fcm.js +23 -58
- package/src/api-public/controllers/fcm.js.map +1 -1
- package/src/api-public/controllers/fcm.ts +28 -56
- package/src/api-public/controllers/shop.js +7 -1
- package/src/api-public/controllers/shop.js.map +1 -1
- package/src/api-public/controllers/shop.ts +17 -10
- package/src/api-public/controllers/user.js +1 -0
- package/src/api-public/controllers/user.js.map +1 -1
- package/src/api-public/controllers/user.ts +2 -0
- package/src/api-public/services/auto-send-email.js +247 -187
- package/src/api-public/services/auto-send-email.js.map +1 -1
- package/src/api-public/services/auto-send-email.ts +568 -505
- package/src/api-public/services/delivery.js +1 -1
- package/src/api-public/services/delivery.js.map +1 -1
- package/src/api-public/services/delivery.ts +6 -5
- package/src/api-public/services/financial-service.js +1 -2
- package/src/api-public/services/financial-service.js.map +1 -1
- package/src/api-public/services/financial-service.ts +4 -6
- package/src/api-public/services/manager.d.ts +4 -3
- package/src/api-public/services/manager.js +8 -12
- package/src/api-public/services/manager.js.map +1 -1
- package/src/api-public/services/manager.ts +57 -59
- package/src/api-public/services/model/handlePaymentTransaction.d.ts +1 -1
- package/src/api-public/services/model/handlePaymentTransaction.js +23 -3
- package/src/api-public/services/model/handlePaymentTransaction.js.map +1 -1
- package/src/api-public/services/model/handlePaymentTransaction.ts +25 -36
- package/src/api-public/services/schedule.d.ts +1 -0
- package/src/api-public/services/schedule.js +27 -0
- package/src/api-public/services/schedule.js.map +1 -1
- package/src/api-public/services/schedule.ts +30 -0
- package/src/api-public/services/shopping.d.ts +22 -2
- package/src/api-public/services/shopping.js +371 -95
- package/src/api-public/services/shopping.js.map +1 -1
- package/src/api-public/services/shopping.ts +499 -141
- package/src/api-public/services/stock.js +0 -3
- package/src/api-public/services/stock.js.map +1 -1
- package/src/api-public/services/stock.ts +3 -3
- package/src/api-public/services/user.d.ts +1 -0
- package/src/api-public/services/user.js +32 -12
- package/src/api-public/services/user.js.map +1 -1
- package/src/api-public/services/user.ts +38 -19
- package/src/api-public/services/workers.js +3 -3
- package/src/api-public/services/workers.js.map +1 -1
- package/src/api-public/services/workers.ts +103 -103
- package/src/app-project/ios/proshake/AppDelegate.swift +51 -7
- package/src/app-project/ios/proshake/Info.plist +11 -9
- package/src/app-project/ios/proshake/SceneDelegate.swift +18 -0
- package/src/app-project/ios/proshake/glitter-interface/BasicUtil.swift +43 -2
- package/src/app-project/ios/proshake/glitter-interface/Ecommerce.swift +56 -0
- package/src/app-project/ios/proshake.xcodeproj/project.xcworkspace/xcuserdata/jianzhi.wang.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/src/app-project/serverless/src/modules/database.js +1 -1
- package/src/app-project/serverless/src/modules/database.js.map +1 -1
- package/src/app-project/serverless/src/modules/database.ts +171 -171
- package/src/controllers/template.d.ts +1 -1
- package/src/controllers/template.js +16 -16
- package/src/controllers/template.js.map +1 -1
- package/src/controllers/template.ts +98 -84
- package/src/modules/database.js +3 -1
- package/src/modules/database.js.map +1 -1
- package/src/modules/database.ts +185 -181
- package/src/modules/firebase.d.ts +17 -0
- package/src/modules/firebase.js +126 -0
- package/src/modules/firebase.js.map +1 -1
- package/src/modules/firebase.ts +169 -0
- package/src/public-config-initial/auto-fcm.js +8 -2
- package/src/public-config-initial/auto-fcm.js.map +1 -1
- package/src/public-config-initial/auto-fcm.ts +15 -6
- package/src/services/app.d.ts +2 -1
- package/src/services/app.js.map +1 -1
- package/src/services/app.ts +2 -1
- package/src/services/ios-project.js +12 -6
- package/src/services/ios-project.js.map +1 -1
- package/src/services/ios-project.ts +12 -6
- package/src/services/template.d.ts +3 -2
- package/src/services/template.js +2 -1
- package/src/services/template.js.map +1 -1
- package/src/services/template.ts +13 -20
|
@@ -35,7 +35,7 @@ const product_initial_js_1 = require("./product-initial.js");
|
|
|
35
35
|
const ut_timer_js_1 = require("../utils/ut-timer.js");
|
|
36
36
|
const auto_fcm_js_1 = require("../../public-config-initial/auto-fcm.js");
|
|
37
37
|
const handlePaymentTransaction_js_1 = __importDefault(require("./model/handlePaymentTransaction.js"));
|
|
38
|
-
const
|
|
38
|
+
const Language_js_1 = require("../../Language.js");
|
|
39
39
|
class OrderDetail {
|
|
40
40
|
constructor(subtotal, shipment) {
|
|
41
41
|
this.discount = 0;
|
|
@@ -204,14 +204,14 @@ class Shopping {
|
|
|
204
204
|
}
|
|
205
205
|
if (query.filter_visible) {
|
|
206
206
|
if (query.filter_visible === 'true') {
|
|
207
|
-
querySql.push(`(content->>'$.visible'
|
|
207
|
+
querySql.push(`(content->>'$.visible' IS NULL || content->>'$.visible' = 'true')`);
|
|
208
208
|
}
|
|
209
209
|
else {
|
|
210
210
|
querySql.push(`(content->>'$.visible' = 'false')`);
|
|
211
211
|
}
|
|
212
212
|
}
|
|
213
213
|
else if (!query.is_manger && `${query.show_hidden}` !== 'true') {
|
|
214
|
-
querySql.push(`(content->>'$.visible'
|
|
214
|
+
querySql.push(`(content->>'$.visible' IS NULL || content->>'$.visible' = 'true')`);
|
|
215
215
|
}
|
|
216
216
|
if (query.productType) {
|
|
217
217
|
query.productType.split(',').map(dd => {
|
|
@@ -345,6 +345,28 @@ class Shopping {
|
|
|
345
345
|
querySql.push(`(content->>'$.channel' IS NULL ${channelJoin})`);
|
|
346
346
|
}
|
|
347
347
|
}
|
|
348
|
+
if (query.manager_tag) {
|
|
349
|
+
const tagSplit = query.manager_tag.split(',').map(tag => tag.trim());
|
|
350
|
+
if (tagSplit.length > 0) {
|
|
351
|
+
const tagJoin = tagSplit.map(tag => {
|
|
352
|
+
return `JSON_CONTAINS(content->>'$.product_customize_tag', '"${tag}"')`;
|
|
353
|
+
});
|
|
354
|
+
querySql.push(`(${tagJoin.join(' OR ')})`);
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
if (query.general_tag) {
|
|
358
|
+
const tagSplit = query.general_tag.split(',').map(tag => tag.trim());
|
|
359
|
+
if (tagSplit.length > 0) {
|
|
360
|
+
const tagJoin = tagSplit.map(tag => {
|
|
361
|
+
var _a;
|
|
362
|
+
return `(JSON_CONTAINS(
|
|
363
|
+
JSON_EXTRACT(content, '$.product_tag.language."${(_a = query.language) !== null && _a !== void 0 ? _a : 'zh-TW'}"'),
|
|
364
|
+
JSON_QUOTE('${tag}')
|
|
365
|
+
))`;
|
|
366
|
+
});
|
|
367
|
+
querySql.push(`(${tagJoin.join(' OR ')})`);
|
|
368
|
+
}
|
|
369
|
+
}
|
|
348
370
|
if (query.id_list && idStr) {
|
|
349
371
|
querySql.push(`(id in (${idStr}))`);
|
|
350
372
|
}
|
|
@@ -745,6 +767,147 @@ class Shopping {
|
|
|
745
767
|
throw exception_js_1.default.BadRequestError('BAD_REQUEST', 'GetProduct Error:' + e, null);
|
|
746
768
|
}
|
|
747
769
|
}
|
|
770
|
+
async initProductCustomizeTagConifg() {
|
|
771
|
+
var _a, _b;
|
|
772
|
+
try {
|
|
773
|
+
const managerTags = await new user_js_1.User(this.app).getConfigV2({ key: 'product_manager_tags', user_id: 'manager' });
|
|
774
|
+
console.log(`initProductCustomizeTagConifg=>getData=>`, managerTags);
|
|
775
|
+
if (managerTags && Array.isArray(managerTags.list)) {
|
|
776
|
+
return managerTags;
|
|
777
|
+
}
|
|
778
|
+
console.log(`query_sql=>`, `SELECT GROUP_CONCAT(DISTINCT JSON_UNQUOTE(JSON_EXTRACT(content, '$.product_customize_tag')) SEPARATOR ',') AS unique_tags
|
|
779
|
+
FROM \`${this.app}\`.t_manager_post
|
|
780
|
+
WHERE JSON_UNQUOTE(JSON_EXTRACT(content, '$.type')) = 'product'`);
|
|
781
|
+
const getData = await database_js_1.default.query(`
|
|
782
|
+
SELECT GROUP_CONCAT(DISTINCT JSON_UNQUOTE(JSON_EXTRACT(content, '$.product_customize_tag')) SEPARATOR ',') AS unique_tags
|
|
783
|
+
FROM \`${this.app}\`.t_manager_post
|
|
784
|
+
WHERE JSON_UNQUOTE(JSON_EXTRACT(content, '$.type')) = 'product'
|
|
785
|
+
`, []);
|
|
786
|
+
const unique_tags_string = (_b = (_a = getData[0]) === null || _a === void 0 ? void 0 : _a.unique_tags) !== null && _b !== void 0 ? _b : '';
|
|
787
|
+
console.log(`JSON_STRING=>`, `[${unique_tags_string}]`);
|
|
788
|
+
const unique_tags_array = JSON.parse(`[${unique_tags_string}]`);
|
|
789
|
+
const unique_tags_flot = Array.isArray(unique_tags_array) ? unique_tags_array.flat() : [];
|
|
790
|
+
const data = { list: [...new Set(unique_tags_flot)] };
|
|
791
|
+
console.log(`product_manager_tags=>setData=>`, managerTags);
|
|
792
|
+
await new user_js_1.User(this.app).setConfig({
|
|
793
|
+
key: 'product_manager_tags',
|
|
794
|
+
user_id: 'manager',
|
|
795
|
+
value: data,
|
|
796
|
+
});
|
|
797
|
+
return data;
|
|
798
|
+
}
|
|
799
|
+
catch (error) {
|
|
800
|
+
throw exception_js_1.default.BadRequestError('BAD_REQUEST', 'Set product customize tag conifg Error:' + error, null);
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
async setProductCustomizeTagConifg(add_tags) {
|
|
804
|
+
var _a;
|
|
805
|
+
const tagConfig = await new user_js_1.User(this.app).getConfigV2({ key: 'product_manager_tags', user_id: 'manager' });
|
|
806
|
+
const tagList = (_a = tagConfig === null || tagConfig === void 0 ? void 0 : tagConfig.list) !== null && _a !== void 0 ? _a : [];
|
|
807
|
+
const data = { list: [...new Set([...tagList, ...add_tags])] };
|
|
808
|
+
await new user_js_1.User(this.app).setConfig({
|
|
809
|
+
key: 'product_manager_tags',
|
|
810
|
+
user_id: 'manager',
|
|
811
|
+
value: data,
|
|
812
|
+
});
|
|
813
|
+
return data;
|
|
814
|
+
}
|
|
815
|
+
async initProductGeneralTagConifg() {
|
|
816
|
+
var _a, _b;
|
|
817
|
+
try {
|
|
818
|
+
const generalTags = await new user_js_1.User(this.app).getConfigV2({ key: 'product_general_tags', user_id: 'manager' });
|
|
819
|
+
if (generalTags && Array.isArray(generalTags.list)) {
|
|
820
|
+
return generalTags;
|
|
821
|
+
}
|
|
822
|
+
console.log(`initProductCustomizeTagConifg=>getData=>`, generalTags);
|
|
823
|
+
const getData = await database_js_1.default.query(`
|
|
824
|
+
SELECT GROUP_CONCAT(DISTINCT JSON_UNQUOTE(JSON_EXTRACT(content, '$.product_tag.language')) SEPARATOR ',') AS unique_tags
|
|
825
|
+
FROM \`${this.app}\`.t_manager_post
|
|
826
|
+
WHERE JSON_UNQUOTE(JSON_EXTRACT(content, '$.type')) = 'product'
|
|
827
|
+
`, []);
|
|
828
|
+
const unique_tags_string = (_b = (_a = getData[0]) === null || _a === void 0 ? void 0 : _a.unique_tags) !== null && _b !== void 0 ? _b : '';
|
|
829
|
+
console.log(`JSON_STRING=>`, `[${unique_tags_string}]`);
|
|
830
|
+
const unique_tags_array = JSON.parse(`[${unique_tags_string}]`);
|
|
831
|
+
console.log(`JSON_DATA=>`, unique_tags_array);
|
|
832
|
+
const unique_tags_flot = Array.isArray(unique_tags_array) ? unique_tags_array.flat() : [];
|
|
833
|
+
const list = {};
|
|
834
|
+
unique_tags_flot.map(item => {
|
|
835
|
+
Language_js_1.Language.locationList.map(lang => {
|
|
836
|
+
var _a;
|
|
837
|
+
list[lang] = [...((_a = list[lang]) !== null && _a !== void 0 ? _a : []), ...item[lang]];
|
|
838
|
+
});
|
|
839
|
+
});
|
|
840
|
+
Language_js_1.Language.locationList.map(lang => {
|
|
841
|
+
list[lang] = [...new Set(list[lang])];
|
|
842
|
+
});
|
|
843
|
+
const data = { list };
|
|
844
|
+
await new user_js_1.User(this.app).setConfig({
|
|
845
|
+
key: 'product_general_tags',
|
|
846
|
+
user_id: 'manager',
|
|
847
|
+
value: data,
|
|
848
|
+
});
|
|
849
|
+
return data;
|
|
850
|
+
}
|
|
851
|
+
catch (error) {
|
|
852
|
+
throw exception_js_1.default.BadRequestError('BAD_REQUEST', 'Set product general tag conifg Error:' + error, null);
|
|
853
|
+
}
|
|
854
|
+
}
|
|
855
|
+
async setProductGeneralTagConifg(add_tags) {
|
|
856
|
+
var _a, _b;
|
|
857
|
+
const tagConfig = (_a = (await new user_js_1.User(this.app).getConfigV2({ key: 'product_general_tags', user_id: 'manager' }))) !== null && _a !== void 0 ? _a : (await this.initProductGeneralTagConifg());
|
|
858
|
+
(_b = tagConfig.list) !== null && _b !== void 0 ? _b : (tagConfig.list = {});
|
|
859
|
+
Language_js_1.Language.locationList.map(lang => {
|
|
860
|
+
var _a;
|
|
861
|
+
const originList = (_a = tagConfig.list[lang]) !== null && _a !== void 0 ? _a : [];
|
|
862
|
+
const updateList = add_tags[lang];
|
|
863
|
+
tagConfig.list[lang] = [...new Set([...originList, ...updateList])];
|
|
864
|
+
});
|
|
865
|
+
await new user_js_1.User(this.app).setConfig({
|
|
866
|
+
key: 'product_general_tags',
|
|
867
|
+
user_id: 'manager',
|
|
868
|
+
value: tagConfig,
|
|
869
|
+
});
|
|
870
|
+
return tagConfig;
|
|
871
|
+
}
|
|
872
|
+
async initOrderCustomizeTagConifg() {
|
|
873
|
+
var _a, _b;
|
|
874
|
+
try {
|
|
875
|
+
const managerTags = await new user_js_1.User(this.app).getConfigV2({ key: 'order_manager_tags', user_id: 'manager' });
|
|
876
|
+
if (managerTags && Array.isArray(managerTags.list)) {
|
|
877
|
+
return managerTags;
|
|
878
|
+
}
|
|
879
|
+
const getData = await database_js_1.default.query(`
|
|
880
|
+
SELECT GROUP_CONCAT(DISTINCT JSON_UNQUOTE(JSON_EXTRACT(orderData, '$.tags')) SEPARATOR ',') AS unique_tags
|
|
881
|
+
FROM \`${this.app}\`.t_checkout
|
|
882
|
+
WHERE JSON_UNQUOTE(JSON_EXTRACT(orderData, '$.tags')) IS NOT NULL
|
|
883
|
+
`, []);
|
|
884
|
+
const unique_tags_string = (_b = (_a = getData[0]) === null || _a === void 0 ? void 0 : _a.unique_tags) !== null && _b !== void 0 ? _b : '';
|
|
885
|
+
const unique_tags_array = JSON.parse(`[${unique_tags_string}]`);
|
|
886
|
+
const unique_tags_flot = Array.isArray(unique_tags_array) ? unique_tags_array.flat() : [];
|
|
887
|
+
const data = { list: [...new Set(unique_tags_flot)] };
|
|
888
|
+
await new user_js_1.User(this.app).setConfig({
|
|
889
|
+
key: 'order_manager_tags',
|
|
890
|
+
user_id: 'manager',
|
|
891
|
+
value: data,
|
|
892
|
+
});
|
|
893
|
+
return data;
|
|
894
|
+
}
|
|
895
|
+
catch (error) {
|
|
896
|
+
throw exception_js_1.default.BadRequestError('BAD_REQUEST', 'Set order customize tag conifg Error:' + express_1.default, null);
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
async setOrderCustomizeTagConifg(add_tags) {
|
|
900
|
+
var _a;
|
|
901
|
+
const tagConfig = await new user_js_1.User(this.app).getConfigV2({ key: 'order_manager_tags', user_id: 'manager' });
|
|
902
|
+
const tagList = (_a = tagConfig === null || tagConfig === void 0 ? void 0 : tagConfig.list) !== null && _a !== void 0 ? _a : [];
|
|
903
|
+
const data = { list: [...new Set([...tagList, ...add_tags])] };
|
|
904
|
+
await new user_js_1.User(this.app).setConfig({
|
|
905
|
+
key: 'order_manager_tags',
|
|
906
|
+
user_id: 'manager',
|
|
907
|
+
value: data,
|
|
908
|
+
});
|
|
909
|
+
return data;
|
|
910
|
+
}
|
|
748
911
|
async getAllUseVoucher(userID) {
|
|
749
912
|
const now = Date.now();
|
|
750
913
|
const allVoucher = (await this.querySql([`(content->>'$.type'='voucher')`], {
|
|
@@ -1188,9 +1351,9 @@ class Shopping {
|
|
|
1188
1351
|
async function getOrder(orderID) {
|
|
1189
1352
|
try {
|
|
1190
1353
|
const result = await database_js_1.default.query(`
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1354
|
+
SELECT *
|
|
1355
|
+
FROM \`${app}\`.t_checkout
|
|
1356
|
+
WHERE cart_token = ?`, [orderID]);
|
|
1194
1357
|
return result[0];
|
|
1195
1358
|
}
|
|
1196
1359
|
catch (e) {
|
|
@@ -1232,6 +1395,7 @@ class Shopping {
|
|
|
1232
1395
|
};
|
|
1233
1396
|
const newOrderID = Date.now();
|
|
1234
1397
|
const carData = {
|
|
1398
|
+
orderID: `${newOrderID}`,
|
|
1235
1399
|
discount: (_b = orderData.discount) !== null && _b !== void 0 ? _b : 0,
|
|
1236
1400
|
customer_info: orderData.customer_info || {},
|
|
1237
1401
|
lineItems: (_c = orderData.lineItems) !== null && _c !== void 0 ? _c : [],
|
|
@@ -1242,7 +1406,6 @@ class Shopping {
|
|
|
1242
1406
|
rebate: (_j = orderData.rebate) !== null && _j !== void 0 ? _j : 0,
|
|
1243
1407
|
goodsWeight: 0,
|
|
1244
1408
|
use_rebate: orderData.use_rebate || 0,
|
|
1245
|
-
orderID: `${newOrderID}`,
|
|
1246
1409
|
shipment_support: shipment_setting.support,
|
|
1247
1410
|
shipment_info: shipment_setting.info,
|
|
1248
1411
|
shipment_selector: [
|
|
@@ -1275,8 +1438,12 @@ class Shopping {
|
|
|
1275
1438
|
fbp: sqlData.fbp,
|
|
1276
1439
|
editRecord: [],
|
|
1277
1440
|
};
|
|
1278
|
-
|
|
1279
|
-
|
|
1441
|
+
await order_event_js_1.OrderEvent.insertOrder({
|
|
1442
|
+
cartData: orderData,
|
|
1443
|
+
status: 0,
|
|
1444
|
+
app: this.app,
|
|
1445
|
+
});
|
|
1446
|
+
const result = await new handlePaymentTransaction_js_1.default(this.app, orderData.customer_info.payment_select).processPayment(carData, return_url);
|
|
1280
1447
|
return result;
|
|
1281
1448
|
}
|
|
1282
1449
|
}
|
|
@@ -1328,7 +1495,7 @@ class Shopping {
|
|
|
1328
1495
|
querySql.push(`(archived="${query.archived}")`);
|
|
1329
1496
|
}
|
|
1330
1497
|
else if (query.archived === 'false') {
|
|
1331
|
-
querySql.push(`((archived
|
|
1498
|
+
querySql.push(`((archived IS NULL) or (archived!='true'))`);
|
|
1332
1499
|
}
|
|
1333
1500
|
query.status && querySql.push(`status IN (${query.status})`);
|
|
1334
1501
|
query.email && querySql.push(`email=${database_js_1.default.escape(query.email)}`);
|
|
@@ -1479,8 +1646,48 @@ class Shopping {
|
|
|
1479
1646
|
}
|
|
1480
1647
|
}
|
|
1481
1648
|
async splitOrder(obj) {
|
|
1482
|
-
var _a, _b;
|
|
1483
1649
|
try {
|
|
1650
|
+
async function processCheckoutsStaggered(splitOrderArray, orderData, context) {
|
|
1651
|
+
const promises = splitOrderArray.map((order, index) => {
|
|
1652
|
+
return new Promise((resolve, reject) => {
|
|
1653
|
+
const delay = 1000 * index;
|
|
1654
|
+
setTimeout(() => {
|
|
1655
|
+
var _a, _b;
|
|
1656
|
+
const payload = {
|
|
1657
|
+
code_array: [],
|
|
1658
|
+
order_id: (_b = (_a = orderData === null || orderData === void 0 ? void 0 : orderData.splitOrders) === null || _a === void 0 ? void 0 : _a[index]) !== null && _b !== void 0 ? _b : '',
|
|
1659
|
+
line_items: order.lineItems,
|
|
1660
|
+
customer_info: order.customer_info,
|
|
1661
|
+
return_url: '',
|
|
1662
|
+
user_info: order.user_info,
|
|
1663
|
+
discount: order.discount,
|
|
1664
|
+
voucher: order.voucher,
|
|
1665
|
+
total: order.total,
|
|
1666
|
+
pay_status: Number(order.pay_status),
|
|
1667
|
+
};
|
|
1668
|
+
context
|
|
1669
|
+
.toCheckout(payload, 'split')
|
|
1670
|
+
.then(() => {
|
|
1671
|
+
resolve();
|
|
1672
|
+
})
|
|
1673
|
+
.catch((error) => {
|
|
1674
|
+
reject(error);
|
|
1675
|
+
});
|
|
1676
|
+
}, delay);
|
|
1677
|
+
});
|
|
1678
|
+
});
|
|
1679
|
+
try {
|
|
1680
|
+
await Promise.all(promises);
|
|
1681
|
+
return true;
|
|
1682
|
+
}
|
|
1683
|
+
catch (e) {
|
|
1684
|
+
console.error('處理拆分訂單結帳時至少發生一個錯誤 (從 Promise.all 捕獲):', e);
|
|
1685
|
+
return {
|
|
1686
|
+
result: 'failure',
|
|
1687
|
+
reason: e,
|
|
1688
|
+
};
|
|
1689
|
+
}
|
|
1690
|
+
}
|
|
1484
1691
|
const currentTime = new Date().toISOString();
|
|
1485
1692
|
function generateOrderIds(orderId, arrayLength) {
|
|
1486
1693
|
const orderIdArray = [];
|
|
@@ -1515,21 +1722,7 @@ class Shopping {
|
|
|
1515
1722
|
cart_token: orderData.orderID,
|
|
1516
1723
|
orderData,
|
|
1517
1724
|
});
|
|
1518
|
-
|
|
1519
|
-
await (new checkout_event_js_1.CheckoutEvent(this.app, this.token)).toCheckout({
|
|
1520
|
-
code_array: [],
|
|
1521
|
-
order_id: (_b = (_a = orderData === null || orderData === void 0 ? void 0 : orderData.splitOrders) === null || _a === void 0 ? void 0 : _a[index]) !== null && _b !== void 0 ? _b : '',
|
|
1522
|
-
line_items: order.lineItems,
|
|
1523
|
-
customer_info: order.customer_info,
|
|
1524
|
-
return_url: '',
|
|
1525
|
-
user_info: order.user_info,
|
|
1526
|
-
discount: order.discount,
|
|
1527
|
-
voucher: order.voucher,
|
|
1528
|
-
total: order.total,
|
|
1529
|
-
pay_status: Number(order.pay_status),
|
|
1530
|
-
}, 'split');
|
|
1531
|
-
}
|
|
1532
|
-
return true;
|
|
1725
|
+
return await processCheckoutsStaggered(splitOrderArray, orderData, this);
|
|
1533
1726
|
}
|
|
1534
1727
|
catch (e) {
|
|
1535
1728
|
throw exception_js_1.default.BadRequestError('BAD_REQUEST', 'splitOrder Error:' + e, null);
|
|
@@ -1955,7 +2148,12 @@ class Shopping {
|
|
|
1955
2148
|
delete update.orderData.user_info.shipment_date;
|
|
1956
2149
|
}
|
|
1957
2150
|
const updateProgress = update.orderData.progress;
|
|
1958
|
-
if (
|
|
2151
|
+
if (updateProgress === 'wait' &&
|
|
2152
|
+
update.orderData.user_info.shipment_number &&
|
|
2153
|
+
update.orderData.user_info.shipment_number !== origin.orderData.user_info.shipment_number) {
|
|
2154
|
+
await this.sendNotifications(orderData, 'in_stock');
|
|
2155
|
+
}
|
|
2156
|
+
else if (prevProgress !== updateProgress) {
|
|
1959
2157
|
if (updateProgress === 'shipping') {
|
|
1960
2158
|
await this.sendNotifications(orderData, 'shipment');
|
|
1961
2159
|
}
|
|
@@ -1977,6 +2175,9 @@ class Shopping {
|
|
|
1977
2175
|
SET ?
|
|
1978
2176
|
WHERE id = ?;
|
|
1979
2177
|
`, [updateData, origin.id]);
|
|
2178
|
+
if (Array.isArray(update.orderData.tags)) {
|
|
2179
|
+
await this.setOrderCustomizeTagConifg(update.orderData.tags);
|
|
2180
|
+
}
|
|
1980
2181
|
await Promise.all(origin.orderData.lineItems.map(async (lineItem) => {
|
|
1981
2182
|
var _a;
|
|
1982
2183
|
const shopping = new Shopping(this.app, this.token);
|
|
@@ -2121,6 +2322,7 @@ class Shopping {
|
|
|
2121
2322
|
const typeMap = {
|
|
2122
2323
|
shipment: 'shipment',
|
|
2123
2324
|
arrival: 'shipment-arrival',
|
|
2325
|
+
in_stock: 'in-stock',
|
|
2124
2326
|
};
|
|
2125
2327
|
if (lineID) {
|
|
2126
2328
|
const line = new line_message_1.LineMessage(this.app);
|
|
@@ -2289,10 +2491,11 @@ class Shopping {
|
|
|
2289
2491
|
}
|
|
2290
2492
|
async getCheckOut(query) {
|
|
2291
2493
|
try {
|
|
2292
|
-
let querySql = ['1=1'];
|
|
2293
|
-
let orderString = 'order by id desc';
|
|
2294
2494
|
const timer = new ut_timer_js_1.UtTimer('get-checkout-info');
|
|
2295
2495
|
timer.checkPoint('start');
|
|
2496
|
+
const querySql = ['o.id IS NOT NULL'];
|
|
2497
|
+
let orderString = 'order by created_time desc';
|
|
2498
|
+
await this.initOrderCustomizeTagConifg();
|
|
2296
2499
|
if (query.search && query.searchType) {
|
|
2297
2500
|
switch (query.searchType) {
|
|
2298
2501
|
case 'cart_token':
|
|
@@ -2338,7 +2541,7 @@ class Shopping {
|
|
|
2338
2541
|
let search = [];
|
|
2339
2542
|
query.reconciliation_status.map(status => {
|
|
2340
2543
|
if (status === 'pending_entry') {
|
|
2341
|
-
search.push(`total_received
|
|
2544
|
+
search.push(`total_received IS NULL`);
|
|
2342
2545
|
}
|
|
2343
2546
|
else if (status === 'completed_entry') {
|
|
2344
2547
|
search.push(`total_received = total`);
|
|
@@ -2350,10 +2553,10 @@ class Shopping {
|
|
|
2350
2553
|
search.push(`(total_received < total) && ((total_received + offset_amount) = total)`);
|
|
2351
2554
|
}
|
|
2352
2555
|
else if (status === 'pending_offset') {
|
|
2353
|
-
search.push(`(total_received < total) && (offset_amount
|
|
2556
|
+
search.push(`(total_received < total) && (offset_amount IS NULL)`);
|
|
2354
2557
|
}
|
|
2355
2558
|
else if (status === 'pending_refund') {
|
|
2356
|
-
search.push(`(total_received > total) && (offset_amount
|
|
2559
|
+
search.push(`(total_received > total) && (offset_amount IS NULL)`);
|
|
2357
2560
|
}
|
|
2358
2561
|
});
|
|
2359
2562
|
querySql.push(`(${search
|
|
@@ -2393,7 +2596,7 @@ class Shopping {
|
|
|
2393
2596
|
querySql.push(`shipment_number is NOT null`);
|
|
2394
2597
|
}
|
|
2395
2598
|
else if (query.progress === 'wait') {
|
|
2396
|
-
querySql.push(`shipment_number
|
|
2599
|
+
querySql.push(`shipment_number IS NULL`);
|
|
2397
2600
|
}
|
|
2398
2601
|
let newArray = query.progress.split(',');
|
|
2399
2602
|
let temp = '';
|
|
@@ -2413,7 +2616,7 @@ class Shopping {
|
|
|
2413
2616
|
querySql.push(`order_source='POS'`);
|
|
2414
2617
|
}
|
|
2415
2618
|
else if (query.is_pos === 'false') {
|
|
2416
|
-
querySql.push(`(order_source!='POS' or order_source
|
|
2619
|
+
querySql.push(`(order_source!='POS' or order_source IS NULL)`);
|
|
2417
2620
|
}
|
|
2418
2621
|
if (query.shipment) {
|
|
2419
2622
|
let shipment = query.shipment.split(',');
|
|
@@ -2458,36 +2661,90 @@ class Shopping {
|
|
|
2458
2661
|
break;
|
|
2459
2662
|
}
|
|
2460
2663
|
}
|
|
2461
|
-
|
|
2664
|
+
if (query.manager_tag) {
|
|
2665
|
+
const tagSplit = query.manager_tag.split(',').map(tag => tag.trim());
|
|
2666
|
+
if (tagSplit.length > 0) {
|
|
2667
|
+
const tagJoin = tagSplit.map(tag => {
|
|
2668
|
+
return `JSON_CONTAINS(orderData->>'$.tags', '"${tag}"')`;
|
|
2669
|
+
});
|
|
2670
|
+
querySql.push(`(${tagJoin.join(' OR ')})`);
|
|
2671
|
+
}
|
|
2672
|
+
}
|
|
2673
|
+
if (query.status) {
|
|
2674
|
+
querySql.push(`o.status IN (${query.status})`);
|
|
2675
|
+
}
|
|
2462
2676
|
const orderMath = [];
|
|
2463
2677
|
query.email && orderMath.push(`(email=${database_js_1.default.escape(query.email)})`);
|
|
2464
2678
|
query.phone && orderMath.push(`(email=${database_js_1.default.escape(query.phone)})`);
|
|
2465
2679
|
if (orderMath.length) {
|
|
2466
|
-
querySql.push(`(${orderMath.join('
|
|
2680
|
+
querySql.push(`(${orderMath.join(' OR ')})`);
|
|
2681
|
+
}
|
|
2682
|
+
if (query.member_levels) {
|
|
2683
|
+
let temp = [];
|
|
2684
|
+
const queryLevel = query.member_levels.split(',');
|
|
2685
|
+
const queryIdLevel = queryLevel.filter(level => level !== 'null');
|
|
2686
|
+
if (queryLevel.includes('null')) {
|
|
2687
|
+
temp = [`u.member_level IS NULL`, `u.member_level = ''`];
|
|
2688
|
+
}
|
|
2689
|
+
if (queryIdLevel.length > 0) {
|
|
2690
|
+
temp = [
|
|
2691
|
+
...temp,
|
|
2692
|
+
`u.member_level IN (${queryIdLevel
|
|
2693
|
+
.map(level => {
|
|
2694
|
+
return database_js_1.default.escape(level);
|
|
2695
|
+
})
|
|
2696
|
+
.join(',')})`,
|
|
2697
|
+
];
|
|
2698
|
+
}
|
|
2699
|
+
if (temp.length > 0) {
|
|
2700
|
+
querySql.push(`(${temp.join(' OR ')})`);
|
|
2701
|
+
}
|
|
2467
2702
|
}
|
|
2468
2703
|
if (query.filter_type === 'true' || query.archived) {
|
|
2469
2704
|
if (query.archived === 'true') {
|
|
2470
|
-
querySql.push(`(archived="${query.archived}")
|
|
2471
|
-
AND (order_status IS NULL OR order_status NOT IN (-99))`);
|
|
2705
|
+
querySql.push(`(archived="${query.archived}") AND (order_status IS NULL OR order_status NOT IN (-99))`);
|
|
2472
2706
|
}
|
|
2473
2707
|
else {
|
|
2474
|
-
querySql.push(`((archived="${query.archived}") or (archived
|
|
2708
|
+
querySql.push(`((archived="${query.archived}") or (archived IS NULL))`);
|
|
2475
2709
|
}
|
|
2476
2710
|
}
|
|
2477
2711
|
else if (query.filter_type === 'normal') {
|
|
2478
|
-
querySql.push(`((archived
|
|
2712
|
+
querySql.push(`((archived IS NULL) or (archived!='true'))`);
|
|
2479
2713
|
}
|
|
2480
2714
|
if (!(query.filter_type === 'true' || query.archived)) {
|
|
2481
|
-
querySql.push(`((order_status
|
|
2482
|
-
}
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
|
|
2715
|
+
querySql.push(`((order_status IS NULL) or (order_status NOT IN (-99)))`);
|
|
2716
|
+
}
|
|
2717
|
+
const baseSelect = `
|
|
2718
|
+
SELECT
|
|
2719
|
+
o.*,
|
|
2720
|
+
i.invoice_no,
|
|
2721
|
+
i.invoice_data,
|
|
2722
|
+
i.\`status\` as invoice_status
|
|
2723
|
+
FROM`;
|
|
2724
|
+
const joinClause = `LEFT JOIN \`${this.app}\`.t_invoice_memory i ON o.cart_token = i.order_id AND i.status = 1`;
|
|
2725
|
+
const whereClause = `WHERE ${querySql.join(' AND ')}`;
|
|
2726
|
+
let sql;
|
|
2727
|
+
if (query.member_levels) {
|
|
2728
|
+
sql = `
|
|
2729
|
+
(
|
|
2730
|
+
(
|
|
2731
|
+
${baseSelect} \`${this.app}\`.t_user u
|
|
2732
|
+
LEFT JOIN \`${this.app}\`.t_checkout o ON o.email = u.phone
|
|
2733
|
+
${joinClause}
|
|
2734
|
+
${whereClause}
|
|
2735
|
+
)
|
|
2736
|
+
UNION
|
|
2737
|
+
(
|
|
2738
|
+
${baseSelect} \`${this.app}\`.t_user u
|
|
2739
|
+
LEFT JOIN \`${this.app}\`.t_checkout o ON o.email = u.email
|
|
2740
|
+
${joinClause}
|
|
2741
|
+
${whereClause}
|
|
2742
|
+
)
|
|
2743
|
+
) ${orderString}`;
|
|
2744
|
+
}
|
|
2745
|
+
else {
|
|
2746
|
+
sql = `${baseSelect} \`${this.app}\`.t_checkout o ${joinClause} ${whereClause} ${orderString}`;
|
|
2747
|
+
}
|
|
2491
2748
|
if (query.returnSearch == 'true') {
|
|
2492
2749
|
const data = await database_js_1.default.query(`SELECT *
|
|
2493
2750
|
FROM \`${this.app}\`.t_checkout
|
|
@@ -2512,12 +2769,12 @@ class Shopping {
|
|
|
2512
2769
|
}
|
|
2513
2770
|
return data[0];
|
|
2514
2771
|
}
|
|
2515
|
-
const response_data = await new Promise(async (resolve
|
|
2516
|
-
timer.checkPoint('start-query-response_data');
|
|
2772
|
+
const response_data = await new Promise(async (resolve) => {
|
|
2517
2773
|
if (query.id) {
|
|
2518
2774
|
const data = (await database_js_1.default.query(`SELECT *
|
|
2519
2775
|
FROM (${sql}) as subqyery limit ${query.page * query.limit}, ${query.limit}
|
|
2520
2776
|
`, []))[0];
|
|
2777
|
+
timer.checkPoint('get response_data (has query.id)');
|
|
2521
2778
|
resolve({
|
|
2522
2779
|
data: data,
|
|
2523
2780
|
result: !!data,
|
|
@@ -2527,13 +2784,11 @@ class Shopping {
|
|
|
2527
2784
|
const data = await database_js_1.default.query(`SELECT *
|
|
2528
2785
|
FROM (${sql}) as subqyery limit ${query.page * query.limit}, ${query.limit}
|
|
2529
2786
|
`, []);
|
|
2530
|
-
timer.checkPoint('
|
|
2531
|
-
console.log(sql);
|
|
2787
|
+
timer.checkPoint('get response_data (not query.id)');
|
|
2532
2788
|
resolve({
|
|
2533
2789
|
data: data,
|
|
2534
2790
|
total: (await database_js_1.default.query(`SELECT count(1)
|
|
2535
|
-
|
|
2536
|
-
`, []))[0]['count(1)'],
|
|
2791
|
+
FROM (${sql}) as subqyery`, []))[0]['count(1)'],
|
|
2537
2792
|
});
|
|
2538
2793
|
}
|
|
2539
2794
|
});
|
|
@@ -2552,8 +2807,7 @@ class Shopping {
|
|
|
2552
2807
|
try {
|
|
2553
2808
|
order.orderData.cash_flow = (await new financial_service_js_1.PayNow(this.app, keyData['paynow']).confirmAndCaptureOrder(order.orderData.paynow_id)).result;
|
|
2554
2809
|
}
|
|
2555
|
-
catch (e) {
|
|
2556
|
-
}
|
|
2810
|
+
catch (e) { }
|
|
2557
2811
|
}
|
|
2558
2812
|
if (order.orderData.user_info.shipment_refer === 'paynow') {
|
|
2559
2813
|
const pay_now = new paynow_logistics_js_1.PayNowLogistics(this.app);
|
|
@@ -2602,11 +2856,12 @@ class Shopping {
|
|
|
2602
2856
|
catch (e) { }
|
|
2603
2857
|
})
|
|
2604
2858
|
.concat(obMap.map(async (order) => {
|
|
2859
|
+
var _a;
|
|
2605
2860
|
const invoice = (await new invoice_js_1.Invoice(this.app).getInvoice({
|
|
2606
2861
|
page: 0,
|
|
2607
2862
|
limit: 1,
|
|
2608
2863
|
search: order.cart_token,
|
|
2609
|
-
searchType: order.orderData.order_number,
|
|
2864
|
+
searchType: (_a = order.orderData) === null || _a === void 0 ? void 0 : _a.order_number,
|
|
2610
2865
|
})).data[0];
|
|
2611
2866
|
order.invoice_number = invoice && invoice.invoice_no;
|
|
2612
2867
|
}))
|
|
@@ -2871,21 +3126,28 @@ class Shopping {
|
|
|
2871
3126
|
else if (Object.keys(variant.stockList).length === 0) {
|
|
2872
3127
|
variant.stockList[storeConfig.list[0].id] = { count: variant.stock };
|
|
2873
3128
|
}
|
|
2874
|
-
const
|
|
2875
|
-
|
|
2876
|
-
|
|
2877
|
-
|
|
2878
|
-
content: JSON.stringify(variant),
|
|
2879
|
-
product_id: content.id,
|
|
2880
|
-
},
|
|
2881
|
-
]);
|
|
3129
|
+
const insertObj = {
|
|
3130
|
+
content: JSON.stringify(variant),
|
|
3131
|
+
product_id: content.id,
|
|
3132
|
+
};
|
|
2882
3133
|
const originalVariant = originVariants.find((item) => JSON.parse(item.spec).join(',') === variant.spec.join(','));
|
|
2883
3134
|
if (originalVariant) {
|
|
2884
|
-
|
|
3135
|
+
insertObj.id = originalVariant.id;
|
|
3136
|
+
sourceMap[originalVariant.id] = originalVariant.id;
|
|
2885
3137
|
}
|
|
3138
|
+
const insertData = await database_js_1.default.query(`INSERT INTO \`${this.app}\`.t_variants
|
|
3139
|
+
SET ?
|
|
3140
|
+
`, [insertObj]);
|
|
2886
3141
|
return insertData;
|
|
2887
3142
|
});
|
|
2888
|
-
|
|
3143
|
+
const chunk = 10;
|
|
3144
|
+
const chunkLength = Math.ceil(insertPromises.length / chunk);
|
|
3145
|
+
for (let i = 0; i < chunkLength; i++) {
|
|
3146
|
+
const promisesArray = insertPromises.slice(i * chunk, (i + 1) * chunk);
|
|
3147
|
+
setTimeout(async () => {
|
|
3148
|
+
await Promise.all(promisesArray);
|
|
3149
|
+
}, 200);
|
|
3150
|
+
}
|
|
2889
3151
|
const exhibitionConfig = await _user.getConfigV2({ key: 'exhibition_manager', user_id: 'manager' });
|
|
2890
3152
|
exhibitionConfig.list = (_b = exhibitionConfig.list) !== null && _b !== void 0 ? _b : [];
|
|
2891
3153
|
exhibitionConfig.list.forEach((exhibition) => {
|
|
@@ -3439,11 +3701,11 @@ class Shopping {
|
|
|
3439
3701
|
productArray[index] = product;
|
|
3440
3702
|
}
|
|
3441
3703
|
else {
|
|
3442
|
-
console.error('Product id not exist:', product);
|
|
3704
|
+
console.error('Product id not exist:', product.title);
|
|
3443
3705
|
}
|
|
3444
3706
|
}
|
|
3445
3707
|
else {
|
|
3446
|
-
console.error('Product has not id:', product);
|
|
3708
|
+
console.error('Product has not id:', product.title);
|
|
3447
3709
|
}
|
|
3448
3710
|
resolve(true);
|
|
3449
3711
|
});
|
|
@@ -3473,8 +3735,9 @@ class Shopping {
|
|
|
3473
3735
|
return [product.id || null, (_a = this.token) === null || _a === void 0 ? void 0 : _a.userID, JSON.stringify(product)];
|
|
3474
3736
|
});
|
|
3475
3737
|
if (productArray.length) {
|
|
3476
|
-
const data = await database_js_1.default.query(`
|
|
3477
|
-
INTO \`${this.app}\`.\`t_manager_post\` (id,userID,content) values
|
|
3738
|
+
const data = await database_js_1.default.query(`REPLACE
|
|
3739
|
+
INTO \`${this.app}\`.\`t_manager_post\` (id,userID,content) values ?
|
|
3740
|
+
`, [
|
|
3478
3741
|
productArray.map((product) => {
|
|
3479
3742
|
var _a;
|
|
3480
3743
|
if (!product.id) {
|
|
@@ -3503,30 +3766,43 @@ class Shopping {
|
|
|
3503
3766
|
product.id = product.id || insertIDStart++;
|
|
3504
3767
|
return new Shopping(this.app, this.token).postVariantsAndPriceValue(product);
|
|
3505
3768
|
});
|
|
3506
|
-
|
|
3769
|
+
const chunk = 10;
|
|
3770
|
+
const chunkLength = Math.ceil(promises.length / chunk);
|
|
3771
|
+
for (let i = 0; i < chunkLength; i++) {
|
|
3772
|
+
const promisesArray = promises.slice(i * chunk, (i + 1) * chunk);
|
|
3773
|
+
setTimeout(async () => {
|
|
3774
|
+
await Promise.all(promisesArray);
|
|
3775
|
+
}, 200);
|
|
3776
|
+
}
|
|
3507
3777
|
}
|
|
3508
3778
|
async putProduct(content) {
|
|
3509
|
-
|
|
3510
|
-
const language = await app_js_1.App.getSupportLanguage(this.app);
|
|
3511
|
-
for (const b of language) {
|
|
3512
|
-
const find_conflict = await database_js_1.default.query(`select count(1)
|
|
3513
|
-
from \`${this.app}\`.\`t_manager_post\`
|
|
3514
|
-
where content ->>'$.language_data."${b}".seo.domain'='${decodeURIComponent(content.language_data[b].seo.domain)}'
|
|
3515
|
-
and id != ${content.id}`, []);
|
|
3516
|
-
if (find_conflict[0]['count(1)'] > 0) {
|
|
3517
|
-
throw exception_js_1.default.BadRequestError('BAD_REQUEST', 'DOMAIN ALREADY EXISTS:', {
|
|
3518
|
-
message: '網域已被使用',
|
|
3519
|
-
code: '733',
|
|
3520
|
-
});
|
|
3521
|
-
}
|
|
3522
|
-
}
|
|
3523
|
-
}
|
|
3779
|
+
var _a, _b, _c;
|
|
3524
3780
|
try {
|
|
3525
3781
|
content.type = 'product';
|
|
3782
|
+
if (content.language_data) {
|
|
3783
|
+
const language = await app_js_1.App.getSupportLanguage(this.app);
|
|
3784
|
+
for (const b of language) {
|
|
3785
|
+
const find_conflict = await database_js_1.default.query(`SELECT count(1)
|
|
3786
|
+
FROM \`${this.app}\`.t_manager_post
|
|
3787
|
+
WHERE content ->>'$.language_data."${b}".seo.domain'='${decodeURIComponent(content.language_data[b].seo.domain)}'
|
|
3788
|
+
AND id != ${content.id}`, []);
|
|
3789
|
+
if (find_conflict[0]['count(1)'] > 0) {
|
|
3790
|
+
throw exception_js_1.default.BadRequestError('BAD_REQUEST', 'DOMAIN ALREADY EXISTS:', {
|
|
3791
|
+
message: '網域已被使用',
|
|
3792
|
+
code: '733',
|
|
3793
|
+
});
|
|
3794
|
+
}
|
|
3795
|
+
}
|
|
3796
|
+
}
|
|
3526
3797
|
this.checkVariantDataType(content.variants);
|
|
3527
|
-
|
|
3798
|
+
await Promise.all([
|
|
3799
|
+
this.setProductCustomizeTagConifg((_a = content.product_customize_tag) !== null && _a !== void 0 ? _a : []),
|
|
3800
|
+
this.setProductGeneralTagConifg((_c = (_b = content.product_tag) === null || _b === void 0 ? void 0 : _b.language) !== null && _c !== void 0 ? _c : []),
|
|
3801
|
+
]);
|
|
3802
|
+
await database_js_1.default.query(`UPDATE \`${this.app}\`.\`t_manager_post\`
|
|
3528
3803
|
SET ?
|
|
3529
|
-
|
|
3804
|
+
WHERE id = ?
|
|
3805
|
+
`, [
|
|
3530
3806
|
{
|
|
3531
3807
|
content: JSON.stringify(content),
|
|
3532
3808
|
},
|
|
@@ -3696,7 +3972,7 @@ class Shopping {
|
|
|
3696
3972
|
query.id && querySql.push(`(v.id = ${query.id})`);
|
|
3697
3973
|
if (query.id_list) {
|
|
3698
3974
|
if ((_a = query.id_list) === null || _a === void 0 ? void 0 : _a.includes('-')) {
|
|
3699
|
-
querySql.push(`(v.product_id in (${query.id_list.split(',').map(
|
|
3975
|
+
querySql.push(`(v.product_id in (${query.id_list.split(',').map(dd => {
|
|
3700
3976
|
return dd.split('-')[0];
|
|
3701
3977
|
})}))`);
|
|
3702
3978
|
}
|
|
@@ -3793,7 +4069,7 @@ class Shopping {
|
|
|
3793
4069
|
if ((_c = query.id_list) === null || _c === void 0 ? void 0 : _c.includes('-')) {
|
|
3794
4070
|
data.data = data.data.filter((dd) => {
|
|
3795
4071
|
var _a;
|
|
3796
|
-
return (_a = query.id_list) === null || _a === void 0 ? void 0 : _a.split(',').find(
|
|
4072
|
+
return (_a = query.id_list) === null || _a === void 0 ? void 0 : _a.split(',').find(d1 => {
|
|
3797
4073
|
return d1 === [dd.product_id, ...dd.variant_content.spec].join('-');
|
|
3798
4074
|
});
|
|
3799
4075
|
});
|
|
@@ -3884,8 +4160,8 @@ class Shopping {
|
|
|
3884
4160
|
SET ?
|
|
3885
4161
|
WHERE id = ?`, [{ content: JSON.stringify(data.variant_content) }, data.id]);
|
|
3886
4162
|
let variants = (await database_js_1.default.query(`SELECT *
|
|
3887
|
-
|
|
3888
|
-
|
|
4163
|
+
FROM \`${this.app}\`.t_variants
|
|
4164
|
+
WHERE product_id = ?`, [data.product_id])).map((dd) => {
|
|
3889
4165
|
return dd.content;
|
|
3890
4166
|
});
|
|
3891
4167
|
data.product_content.variants = variants;
|