|
@@ -7,7 +7,6 @@ |
|
@@ -7,7 +7,6 @@ |
7
|
const utils = '../../../utils';
|
7
|
const utils = '../../../utils';
|
8
|
const logger = global.yoho.logger;
|
8
|
const logger = global.yoho.logger;
|
9
|
const crypto = global.yoho.crypto;
|
9
|
const crypto = global.yoho.crypto;
|
10
|
-const camelCase = global.yoho.camelCase;
|
|
|
11
|
const _ = require('lodash');
|
10
|
const _ = require('lodash');
|
12
|
const helpers = global.yoho.helpers;
|
11
|
const helpers = global.yoho.helpers;
|
13
|
const api = global.yoho.API;
|
12
|
const api = global.yoho.API;
|
|
@@ -27,16 +26,13 @@ const yhChannel = { |
|
@@ -27,16 +26,13 @@ const yhChannel = { |
27
|
|
26
|
|
28
|
/* 多品牌店铺列表数据信息处理*/
|
27
|
/* 多品牌店铺列表数据信息处理*/
|
29
|
const _processBrandShops = (list) => {
|
28
|
const _processBrandShops = (list) => {
|
30
|
- const formatDat = [];
|
29
|
+ let formatDat = [];
|
31
|
|
30
|
|
32
|
- list = list || [];
|
|
|
33
|
- list = camelCase(list);
|
|
|
34
|
-
|
|
|
35
|
- _.forEach(list, (item) => {
|
|
|
36
|
- if (item.shopId) {
|
31
|
+ _.forEach(list, item => {
|
|
|
32
|
+ if (item.shop_id) {
|
37
|
formatDat.push({
|
33
|
formatDat.push({
|
38
|
url: helpers.urlFormat('/product/index/brand/', {
|
34
|
url: helpers.urlFormat('/product/index/brand/', {
|
39
|
- shop_id: item.brandId
|
35
|
+ shop_id: item.shop_id
|
40
|
}),
|
36
|
}),
|
41
|
thumb: helpers.image(item.brandIco, 75, 40),
|
37
|
thumb: helpers.image(item.brandIco, 75, 40),
|
42
|
name: item.brandName
|
38
|
name: item.brandName
|
|
@@ -98,11 +94,7 @@ const _getShopDecorator = (shopId) => { |
|
@@ -98,11 +94,7 @@ const _getShopDecorator = (shopId) => { |
98
|
cache: true,
|
94
|
cache: true,
|
99
|
code: 200
|
95
|
code: 200
|
100
|
}).then((result) => {
|
96
|
}).then((result) => {
|
101
|
- if (result.data) {
|
|
|
102
|
- return camelCase(result.data);
|
|
|
103
|
- } else {
|
|
|
104
|
- return '';
|
|
|
105
|
- }
|
97
|
+ return result.data;
|
106
|
});
|
98
|
});
|
107
|
};
|
99
|
};
|
108
|
|
100
|
|
|
@@ -118,11 +110,7 @@ const _getShopInfo = (shopId, uid) => { |
|
@@ -118,11 +110,7 @@ const _getShopInfo = (shopId, uid) => { |
118
|
shop_id: shopId,
|
110
|
shop_id: shopId,
|
119
|
uid: uid || 0
|
111
|
uid: uid || 0
|
120
|
}, {code: 200}).then((result) => {
|
112
|
}, {code: 200}).then((result) => {
|
121
|
- if (result.data) {
|
|
|
122
|
- return camelCase(result.data);
|
|
|
123
|
- } else {
|
|
|
124
|
- return {};
|
|
|
125
|
- }
|
113
|
+ return result.data;
|
126
|
});
|
114
|
});
|
127
|
};
|
115
|
};
|
128
|
|
116
|
|
|
@@ -139,11 +127,7 @@ const _getShopCategory = (shopId, channel, gender) => { |
|
@@ -139,11 +127,7 @@ const _getShopCategory = (shopId, channel, gender) => { |
139
|
gender: gender || '1,3',
|
127
|
gender: gender || '1,3',
|
140
|
shop_id: shopId
|
128
|
shop_id: shopId
|
141
|
}, {code: 200}).then(result => {
|
129
|
}, {code: 200}).then(result => {
|
142
|
- if (result && result.code === 200) {
|
|
|
143
|
- return camelCase(result.data);
|
|
|
144
|
- } else {
|
|
|
145
|
- return {};
|
|
|
146
|
- }
|
130
|
+ return result.data;
|
147
|
});
|
131
|
});
|
148
|
};
|
132
|
};
|
149
|
|
133
|
|
|
@@ -212,11 +196,8 @@ const getShopBrands = (shopId) => { |
|
@@ -212,11 +196,8 @@ const getShopBrands = (shopId) => { |
212
|
method: 'app.shops.getShopsBrands',
|
196
|
method: 'app.shops.getShopsBrands',
|
213
|
shop_id: shopId
|
197
|
shop_id: shopId
|
214
|
}, {code: 200}).then((result) => {
|
198
|
}, {code: 200}).then((result) => {
|
215
|
- if (result && result.code === 200) {
|
|
|
216
|
- result = camelCase(result.data);
|
|
|
217
|
- return result[0].brandId;
|
|
|
218
|
- } else {
|
|
|
219
|
- return {};
|
199
|
+ if (result[0]) {
|
|
|
200
|
+ return result[0].brand_id;
|
220
|
}
|
201
|
}
|
221
|
});
|
202
|
});
|
222
|
};
|
203
|
};
|
|
@@ -256,10 +237,10 @@ const _formShopData = (data, shopId, isApp) => { |
|
@@ -256,10 +237,10 @@ const _formShopData = (data, shopId, isApp) => { |
256
|
if (data.decorator) {
|
237
|
if (data.decorator) {
|
257
|
|
238
|
|
258
|
_.forEach(data.decorator.list, floor => {
|
239
|
_.forEach(data.decorator.list, floor => {
|
259
|
- let resData = JSON.parse(floor.resourceData);
|
240
|
+ let resData = JSON.parse(floor.resource_data);
|
260
|
|
241
|
|
261
|
- if (floor.resourceName) {
|
|
|
262
|
- floor[_.camelCase(floor.resourceName)] = true;
|
242
|
+ if (floor.resource_name) {
|
|
|
243
|
+ floor[_.camelCase(floor.resource_name)] = true;
|
263
|
}
|
244
|
}
|
264
|
|
245
|
|
265
|
// 店铺banner
|
246
|
// 店铺banner
|
|
@@ -382,10 +363,11 @@ const _formShopData = (data, shopId, isApp) => { |
|
@@ -382,10 +363,11 @@ const _formShopData = (data, shopId, isApp) => { |
382
|
};
|
363
|
};
|
383
|
|
364
|
|
384
|
formatData = _.assign({
|
365
|
formatData = _.assign({
|
385
|
- shopIntro: data.shopInfo.shopIntro,
|
|
|
386
|
- logoImg: data.shopInfo.shopLogo,
|
|
|
387
|
- storeName: (data.shopInfo.isShowShopName === 'Y') ? data.shopInfo.shopName : '',
|
|
|
388
|
- collect: data.shopInfo.isFavorite === 'Y',
|
366
|
+ shopIntro: _.get(data, 'shopInfo.shop_intro', ''),
|
|
|
367
|
+ logoImg: _.get(data, 'shopInfo.shop_logo', ''),
|
|
|
368
|
+ storeName: (_.get(data, 'shopInfo.is_show_shop_name', '') === 'Y') ?
|
|
|
369
|
+ _.get(data, 'shopInfo.shop_name', '') : '',
|
|
|
370
|
+ collect: _.get(data, 'shopInfo.is_favorite', '') === 'Y',
|
389
|
url: helpers.urlFormat('', {
|
371
|
url: helpers.urlFormat('', {
|
390
|
shop_id: shopId
|
372
|
shop_id: shopId
|
391
|
}, 'search'), // 搜索链接
|
373
|
}, 'search'), // 搜索链接
|
|
@@ -434,14 +416,14 @@ const _formShopData = (data, shopId, isApp) => { |
|
@@ -434,14 +416,14 @@ const _formShopData = (data, shopId, isApp) => { |
434
|
shop_id: shopId
|
416
|
shop_id: shopId
|
435
|
});
|
417
|
});
|
436
|
} else {
|
418
|
} else {
|
437
|
- _.forEach(data.shopCategory, (item) => {
|
419
|
+ _.forEach(data.shopCategory, item => {
|
438
|
shopCategory.list.push({
|
420
|
shopCategory.list.push({
|
439
|
url: helpers.urlFormat('', {
|
421
|
url: helpers.urlFormat('', {
|
440
|
shop_id: shopId,
|
422
|
shop_id: shopId,
|
441
|
- sort: item.relationParameter.sort
|
423
|
+ sort: item.relation_parameter.sort
|
442
|
}, 'search'),
|
424
|
}, 'search'),
|
443
|
- categoryId: item.categoryId,
|
|
|
444
|
- name: item.categoryName
|
425
|
+ categoryId: item.category_id,
|
|
|
426
|
+ name: item.category_name
|
445
|
});
|
427
|
});
|
446
|
});
|
428
|
});
|
447
|
}
|
429
|
}
|
|
@@ -477,8 +459,8 @@ const getBaseShopData = (params, shopInfo) => { |
|
@@ -477,8 +459,8 @@ const getBaseShopData = (params, shopInfo) => { |
477
|
|
459
|
|
478
|
if (result[0] && _.has(result[0], 'list')) {
|
460
|
if (result[0] && _.has(result[0], 'list')) {
|
479
|
_.forEach(result[0].list, item => {
|
461
|
_.forEach(result[0].list, item => {
|
480
|
- if (item.resourceName === 'shopTopBanner_base') {
|
|
|
481
|
- let banner = JSON.parse(item.resourceData);
|
462
|
+ if (item.resource_name === 'shopTopBanner_base') {
|
|
|
463
|
+ let banner = JSON.parse(item.resource_data);
|
482
|
|
464
|
|
483
|
finalResult = _.assign(finalResult, {
|
465
|
finalResult = _.assign(finalResult, {
|
484
|
baseShopHome: {
|
466
|
baseShopHome: {
|
|
@@ -521,7 +503,7 @@ const getShopData = (req, shopId, uid, isApp) => { |
|
@@ -521,7 +503,7 @@ const getShopData = (req, shopId, uid, isApp) => { |
521
|
return _getShopInfo(shopId, uid).then(shopInfoResult => {
|
503
|
return _getShopInfo(shopId, uid).then(shopInfoResult => {
|
522
|
|
504
|
|
523
|
/* 基础店铺返回程序内的跳转信号,跳转到基础店铺 */
|
505
|
/* 基础店铺返回程序内的跳转信号,跳转到基础店铺 */
|
524
|
- if (shopInfoResult.shopTemplateType && parseInt(shopInfoResult.shopTemplateType, 10) === 1) {
|
506
|
+ if (shopInfoResult.shop_template_type && parseInt(shopInfoResult.shop_template_type, 10) === 1) {
|
525
|
return {
|
507
|
return {
|
526
|
goBrand: shopInfoResult
|
508
|
goBrand: shopInfoResult
|
527
|
};
|
509
|
};
|
|
@@ -556,7 +538,8 @@ const getShopData = (req, shopId, uid, isApp) => { |
|
@@ -556,7 +538,8 @@ const getShopData = (req, shopId, uid, isApp) => { |
556
|
let shopCoupons = result[2] || [];
|
538
|
let shopCoupons = result[2] || [];
|
557
|
|
539
|
|
558
|
// 店铺分类
|
540
|
// 店铺分类
|
559
|
- return _getShopCategory(shopId, channel).then((shopCategory) => {
|
541
|
+ return _getShopCategory(shopId, channel).then(shopCategory => {
|
|
|
542
|
+
|
560
|
shopData = _.assign({
|
543
|
shopData = _.assign({
|
561
|
shopCategory: shopCategory
|
544
|
shopCategory: shopCategory
|
562
|
}, shopData);
|
545
|
}, shopData);
|
|
@@ -597,31 +580,27 @@ const getShopFav = (req, shopId, uid) => { |
|
@@ -597,31 +580,27 @@ const getShopFav = (req, shopId, uid) => { |
597
|
* @return array banner数据
|
580
|
* @return array banner数据
|
598
|
*/
|
581
|
*/
|
599
|
const getBrandIntro = (brandId, uid) => {
|
582
|
const getBrandIntro = (brandId, uid) => {
|
600
|
- let param = {};
|
|
|
601
|
-
|
|
|
602
|
- param = {
|
|
|
603
|
- uid: uid,
|
583
|
+ let param = {
|
|
|
584
|
+ uid: uid
|
604
|
};
|
585
|
};
|
605
|
|
586
|
|
606
|
return api.get('', _.assign({
|
587
|
return api.get('', _.assign({
|
607
|
method: 'app.brand.getBrandIntro',
|
588
|
method: 'app.brand.getBrandIntro',
|
608
|
brand_id: brandId
|
589
|
brand_id: brandId
|
609
|
}, param), {
|
590
|
}, param), {
|
|
|
591
|
+ code: 200,
|
610
|
cache: true
|
592
|
cache: true
|
611
|
- }).then((result) => {
|
|
|
612
|
- if (result && result.code === 200) {
|
|
|
613
|
- let list = camelCase(result.data) || {};
|
593
|
+ }).then(result => {
|
|
|
594
|
+
|
|
|
595
|
+ let list = result.data;
|
614
|
|
596
|
|
615
|
return {
|
597
|
return {
|
616
|
- id: list.brandId,
|
|
|
617
|
- intro: list.brandIntro,
|
|
|
618
|
- collected: (list.isFavorite && list.isFavorite === 'Y') ? true : false,
|
|
|
619
|
- title: list.brandName ? list.brandName : ''
|
598
|
+ id: list.brand_id,
|
|
|
599
|
+ intro: list.brand_intro,
|
|
|
600
|
+ collected: list.is_favorite && list.is_favorite === 'Y',
|
|
|
601
|
+ title: list.brand_name ? list.brand_name : ''
|
620
|
};
|
602
|
};
|
621
|
- } else {
|
|
|
622
|
- logger.error('get brand introduction api return code is not 200');
|
|
|
623
|
- return {};
|
|
|
624
|
- }
|
603
|
+
|
625
|
});
|
604
|
});
|
626
|
};
|
605
|
};
|
627
|
|
606
|
|
|
@@ -660,27 +639,23 @@ const getBrandLogoByDomain = (domain) => { |
|
@@ -660,27 +639,23 @@ const getBrandLogoByDomain = (domain) => { |
660
|
method: 'web.brand.byDomain',
|
639
|
method: 'web.brand.byDomain',
|
661
|
domain: domain
|
640
|
domain: domain
|
662
|
}, {
|
641
|
}, {
|
|
|
642
|
+ code: 200,
|
663
|
cache: true
|
643
|
cache: true
|
664
|
- }).then((result) => {
|
|
|
665
|
- if (result && result.code === 200) {
|
644
|
+ }).then(result => {
|
666
|
if (result.data) {
|
645
|
if (result.data) {
|
667
|
- let formatData = camelCase(result.data);
|
646
|
+ let formatData = result.data;
|
668
|
|
647
|
|
669
|
return {
|
648
|
return {
|
670
|
id: formatData.id,
|
649
|
id: formatData.id,
|
671
|
url: helpers.urlFormat('', null, formatData.brandDomain),
|
650
|
url: helpers.urlFormat('', null, formatData.brandDomain),
|
672
|
thumb: helpers.image(formatData.brandIco, 75, 40),
|
651
|
thumb: helpers.image(formatData.brandIco, 75, 40),
|
673
|
- name: formatData.brandName,
|
|
|
674
|
- shopId: formatData.shopId ? formatData.shopId : 0, // 店铺id
|
652
|
+ name: formatData.brand_name,
|
|
|
653
|
+ shopId: formatData.shop_id ? formatData.shop_id : 0, // 店铺id
|
675
|
type: formatData.type ? formatData.type : 0
|
654
|
type: formatData.type ? formatData.type : 0
|
676
|
};
|
655
|
};
|
677
|
} else {
|
656
|
} else {
|
678
|
return false;
|
657
|
return false;
|
679
|
}
|
658
|
}
|
680
|
- } else {
|
|
|
681
|
- logger.error('get brand logo by domain api return code is not 200');
|
|
|
682
|
- return {};
|
|
|
683
|
- }
|
|
|
684
|
});
|
659
|
});
|
685
|
};
|
660
|
};
|
686
|
|
661
|
|
|
@@ -694,12 +669,12 @@ const getBrandShops = (brandId) => { |
|
@@ -694,12 +669,12 @@ const getBrandShops = (brandId) => { |
694
|
method: 'app.shop.queryShopsByBrandId',
|
669
|
method: 'app.shop.queryShopsByBrandId',
|
695
|
brand_id: brandId
|
670
|
brand_id: brandId
|
696
|
}, {
|
671
|
}, {
|
|
|
672
|
+ code: 200,
|
697
|
cache: true
|
673
|
cache: true
|
698
|
- }).then((result) => {
|
|
|
699
|
- if (result && result.code === 200) {
|
674
|
+ }).then(result => {
|
|
|
675
|
+ if (result.data) {
|
700
|
return _processBrandShops(result.data);
|
676
|
return _processBrandShops(result.data);
|
701
|
} else {
|
677
|
} else {
|
702
|
- logger.error('get shop list by brandId api return code is not 200');
|
|
|
703
|
return {};
|
678
|
return {};
|
704
|
}
|
679
|
}
|
705
|
});
|
680
|
});
|
|
@@ -748,13 +723,8 @@ const getShopIntro = (shopId) => { |
|
@@ -748,13 +723,8 @@ const getShopIntro = (shopId) => { |
748
|
return api.get('', {
|
723
|
return api.get('', {
|
749
|
method: 'app.shops.getIntro',
|
724
|
method: 'app.shops.getIntro',
|
750
|
shop_id: shopId
|
725
|
shop_id: shopId
|
751
|
- }).then((result) => {
|
|
|
752
|
- if (result && result.code === 200) {
|
|
|
753
|
- return camelCase(result.data);
|
|
|
754
|
- } else {
|
|
|
755
|
- logger.error('get shop intro api return code is not 200');
|
|
|
756
|
- return {};
|
|
|
757
|
- }
|
726
|
+ }, {code: 200, cache: true}).then(result => {
|
|
|
727
|
+ return result.data;
|
758
|
});
|
728
|
});
|
759
|
};
|
729
|
};
|
760
|
|
730
|
|
|
@@ -779,7 +749,7 @@ const getShopCategory = (params) => { |
|
@@ -779,7 +749,7 @@ const getShopCategory = (params) => { |
779
|
_.forEach(value.sub, (subValue, subKey) => {
|
749
|
_.forEach(value.sub, (subValue, subKey) => {
|
780
|
value.sub[subKey].url = helpers.urlFormat('/product/search/list', {
|
750
|
value.sub[subKey].url = helpers.urlFormat('/product/search/list', {
|
781
|
shop_id: params.shopId,
|
751
|
shop_id: params.shopId,
|
782
|
- sort: _.get(value, 'relationParameter.sort', ''),
|
752
|
+ sort: _.get(value, 'relation_parameter.sort', ''),
|
783
|
title: subValue.categoryName,
|
753
|
title: subValue.categoryName,
|
784
|
query: subValue.categoryName
|
754
|
query: subValue.categoryName
|
785
|
});
|
755
|
});
|