喻健
2018-11-08 a94b7685716096afb867716c96065a60db7b9564
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
package com.yeshi.fanli.service.impl.lable;
 
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
 
import javax.annotation.Resource;
 
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
 
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
 
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.yeshi.fanli.entity.bus.lable.QualityFactory;
import com.yeshi.fanli.entity.taobao.SearchFilter;
import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBriefExtra;
import com.yeshi.fanli.entity.taobao.TaoBaoSearchNav;
import com.yeshi.fanli.entity.taobao.TaoBaoSearchResult;
import com.yeshi.fanli.entity.taobao.TaoBaoShopInfo;
import com.yeshi.fanli.service.inter.hongbao.HongBaoManageService;
import com.yeshi.fanli.service.inter.lable.QualityGoodsService;
import com.yeshi.fanli.service.inter.lable.TaoKeGoodsService;
import com.yeshi.fanli.service.inter.taobao.TaoBaoShopService;
import com.yeshi.fanli.util.StringUtil;
import com.yeshi.fanli.util.taobao.TaoBaoUtil;
import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
import org.yeshi.utils.JsonUtil;
import org.yeshi.utils.taobao.TbImgUtil;
 
@Service
public class TaoKeGoodsServiceImpl implements TaoKeGoodsService {
 
    @Resource
    private HongBaoManageService manageService;
 
    @Resource
    private TaoBaoShopService taoBaoShopService;
    
    @Resource
    private QualityGoodsService qualityGoodsService;
    
 
    @Cacheable(value = "taoKeMaterialCache", key = "'listByMaterial-'+#materialId +'-'+#pageIndex")
    @Override
    public List<TaoBaoGoodsBrief> listByMaterial(Integer materialId, Integer pageIndex, int pageSize) throws Exception {
 
        TaoBaoSearchResult result = TaoKeApiUtil.getMaterialByMaterialId(materialId, pageIndex, pageSize);
 
        if (result == null) {
            return null;
        }
 
        return result.getTaoBaoGoodsBriefs();
    }
 
    @Override
    @Cacheable(value = "taoKeMaterialCache", key = "'getBrandsGoods-'+#materialId +'-'+#pageIndex")
    public JSONObject getBrandsGoods(Integer materialId, int pageIndex, int pageSize) throws Exception {
 
        TaoBaoSearchResult result = TaoKeApiUtil.getMaterialByMaterialId(materialId, pageIndex, pageSize);
 
        if (result == null) {
            return null;
        }
 
        List<TaoBaoGoodsBrief> listGoods = result.getTaoBaoGoodsBriefs();
        if (listGoods == null || listGoods.size() == 0) {
            return null;
        }
 
        JSONArray arrayGoods = new JSONArray();
        Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
                .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
 
        Map<String, String> map = manageService.convertMap();
        String proportion = map.get("hongbao_goods_proportion");
        String fcRate = map.get("hongbao_fc_ratio");
 
        listGoods.parallelStream().forEach(taoBaoGoodsBrief -> {
 
            // Long sellerId = taoBaoGoodsBrief.getSellerId();
            // String title = taoBaoGoodsBrief.getTitle();
            // Long auctionId = taoBaoGoodsBrief.getAuctionId();
 
            // TaoBaoShopInfo shopInfo = TaoBaoShopUtil.getTaoBaoShopInfo(title,
            // sellerId, auctionId);
 
            TaoBaoShopInfo shopInfo = taoBaoShopService.getTaoBaoShopInfo(taoBaoGoodsBrief);
 
            if (shopInfo != null) {
                taoBaoGoodsBrief.setShopTitle(shopInfo.getShopTitle());
                String shopType = shopInfo.getShopType();
                if (shopType.contains("tm")) {
                    taoBaoGoodsBrief.setUserType(1);
                } else {
                    taoBaoGoodsBrief.setUserType(0);
                }
            }
 
            int count = taoBaoGoodsBrief.getBiz30day();
            if (count >= 10000) {
                double sales = count;
                String salesCountMidea = String.format("%.1f", sales / 10000);
                taoBaoGoodsBrief.setSalesCount(salesCountMidea + "万");
            } else {
                taoBaoGoodsBrief.setSalesCount(count + "");
            }
 
            // 改变图片尺寸
            String pictUrl = taoBaoGoodsBrief.getPictUrl();
            if (!StringUtil.isNullOrEmpty(pictUrl) && !pictUrl.contains("320x320")) {
                taoBaoGoodsBrief.setPictUrl(TbImgUtil.getTBSize320Img(pictUrl));
            }
 
            arrayGoods
                    .add(gson.toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion, fcRate, null)));
 
        });
 
        JSONObject data = new JSONObject();
        data.put("count", arrayGoods.size());
        data.put("result_list", arrayGoods);
 
        return data;
    }
 
    @Override
    @Cacheable(value = "taoKeMaterialCache", key = "'getBrandsShops-'+#materialId +'-'+#pageIndex")
    public JSONObject getBrandsShops(Integer materialId, int pageIndex, int pageSize) throws Exception {
 
        TaoBaoSearchResult result = TaoKeApiUtil.getMaterialByMaterialId(materialId, pageIndex, pageSize);
 
        if (result == null) {
            return null;
        }
 
        List<TaoBaoGoodsBrief> listGoods = result.getTaoBaoGoodsBriefs();
        if (listGoods == null || listGoods.size() == 0) {
            return null;
        }
 
        Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
                .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
 
        JSONArray arrayShop = new JSONArray();
 
        listGoods.parallelStream().forEach(taoBaoGoodsBrief -> {
 
            // Long sellerId = taoBaoGoodsBrief.getSellerId();
            // String title = taoBaoGoodsBrief.getTitle();
            // Long auctionId = taoBaoGoodsBrief.getAuctionId();
 
            // TaoBaoShopInfo shopInfo = TaoBaoShopUtil.getTaoBaoShopInfo(title,
            // sellerId, auctionId);
 
            TaoBaoShopInfo shopInfo = taoBaoShopService.getTaoBaoShopInfo(taoBaoGoodsBrief);
 
            if (shopInfo != null) {
 
                JSONObject jsonShop = new JSONObject();
                String shopType = shopInfo.getShopType();
                if (shopType.contains("tm")) {
                    shopInfo.setShopType("2");
                } else {
                    shopInfo.setShopType("1");
                }
 
                jsonShop.put("shopInfo", shopInfo);
                jsonShop.put("auctionId", taoBaoGoodsBrief.getAuctionId());
                arrayShop.add(gson.toJson(jsonShop));
            }
 
        });
 
        JSONObject data = new JSONObject();
        data.put("count", listGoods.size());
        data.put("result_list", arrayShop);
 
        return data;
    }
 
    @Override
    @Cacheable(value = "searchWuLiaoCache", key = "'searchWuLiao-'+#sf")
    public JSONObject searchWuLiao(SearchFilter sf) {
 
        // 淘宝物料接口查询
        TaoBaoSearchResult result = TaoKeApiUtil.searchWuLiao(sf);
 
        List<TaoBaoSearchNav> navList = TaoBaoUtil.getBaseNav();
        if (result.getNavList() != null)
            navList.addAll(result.getNavList());
 
        Gson gson = new GsonBuilder().create();
        JSONObject data = new JSONObject();
        data.put("nav", gson.toJson(navList));
 
        List<TaoBaoGoodsBriefExtra> re = new ArrayList<TaoBaoGoodsBriefExtra>();
        List<TaoBaoGoodsBrief> taoBaoGoodsBriefs = result.getTaoBaoGoodsBriefs();
 
        int fq = sf.getQuan();
        int fh = sf.getHongbao();
        boolean ft = sf.isTmall();
 
        Map<String, String> map = manageService.convertMap();
        String proportion = map.get("hongbao_goods_proportion");
        String fcRate = map.get("hongbao_fc_ratio");
 
        if (fq == 0 && fh == 0 && !ft) {
            if (result != null && result.getTaoBaoGoodsBriefs() != null)
                for (TaoBaoGoodsBrief bf : result.getTaoBaoGoodsBriefs()) {
                    int count = bf.getBiz30day();
 
                    String startBiz30day = sf.getStartBiz30day();
                    if (!StringUtil.isNullOrEmpty(startBiz30day)) {
                        int biz30day = Integer.parseInt(startBiz30day);
                        if (count < biz30day) {
                            break;
                        }
                    }
 
                    if (count >= 10000) { // 对销量数据做处理 页面展示7.3万
                        double sales = count;
                        String salesCountMidea = String.format("%.1f", sales / 10000);
                        bf.setSalesCount(salesCountMidea + "万");
                        re.add(TaoBaoUtil.getTaoBaoGoodsBriefExtra(bf, proportion, fcRate, ""));
                    } else {
                        bf.setSalesCount(count + "");
                        re.add(TaoBaoUtil.getTaoBaoGoodsBriefExtra(bf, proportion, fcRate, ""));
                    }
                }
        } else {
            TaoBaoGoodsBriefExtra taoBaoGoodsBriefExtra;
            if (taoBaoGoodsBriefs != null)
                for (TaoBaoGoodsBrief taoBaoGoodsBrief : taoBaoGoodsBriefs) {
 
                    int count = taoBaoGoodsBrief.getBiz30day();
 
                    String startBiz30day = sf.getStartBiz30day();
                    if (!StringUtil.isNullOrEmpty(startBiz30day)) {
                        int biz30day = Integer.parseInt(startBiz30day);
                        if (count < biz30day) {
                            break;
                        }
                    }
 
                    if (count >= 10000) {
                        double sales = count;
                        String salesCountMidea = String.format("%.1f", sales / 10000);
                        taoBaoGoodsBrief.setSalesCount(salesCountMidea + "万");
                        taoBaoGoodsBriefExtra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion,
                                fcRate, "");
                        re.add(taoBaoGoodsBriefExtra);
                    } else {
                        taoBaoGoodsBrief.setSalesCount(count + "");
                        taoBaoGoodsBriefExtra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion,
                                fcRate, "");
                        re.add(taoBaoGoodsBriefExtra);
                    }
                }
        }
 
        Gson gson2 = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
                .excludeFieldsWithoutExposeAnnotation().create();
 
        data.put("result", gson2.toJson(re));
        data.put("count", result.getTaoBaoHead().getDocsfound());
 
        return data;
    }
 
    @Override
    @Cacheable(value = "searchWuLiaoCache", key = "'searchWuLiaoList-'+#sf")
    public List<TaoBaoGoodsBrief> searchWuLiaoList(SearchFilter sf) {
 
        // 淘宝物料接口查询
        TaoBaoSearchResult result = TaoKeApiUtil.searchWuLiao(sf);
        if (result == null)
            return null;
 
        return result.getTaoBaoGoodsBriefs();
    }
    
    
    @Override
    public JSONObject listByWuLiao(int page, String key, String cateIds, String filterParams, String order,
            String startprice, String endprice, String searchParam) {
 
        SearchFilter sf = new SearchFilter();
        sf.setKey(key);
        sf.setPage(page);
        sf.setCateIds(cateIds);
 
        if (!com.yeshi.fanli.util.StringUtil.isNullOrEmpty(startprice)) {
            sf.setStartPrice(new BigDecimal(startprice));
        }
 
        if (!com.yeshi.fanli.util.StringUtil.isNullOrEmpty(endprice)) {
            sf.setEndPrice(new BigDecimal(endprice));
        }
 
        if (com.yeshi.fanli.util.StringUtil.isNullOrEmpty(order)) {
            // 默认销量从高到低排序
            sf.setSort(TaoBaoUtil.SORT_SALE_HIGH_TO_LOW);
        } else {
            if (Integer.parseInt(order) == 1) {
                sf.setSort(TaoBaoUtil.SORT_SALE_HIGH_TO_LOW);
            } else if (Integer.parseInt(order) == 2) {
                sf.setSort(TaoBaoUtil.SORT_PRICE_HIGH_TO_LOW);
            } else if (Integer.parseInt(order) == 3) {
                sf.setSort(TaoBaoUtil.SORT_PRICE_LOW_TO_HIGH);
            }
        }
 
        if (!com.yeshi.fanli.util.StringUtil.isNullOrEmpty(filterParams)) {
 
            Set<String> params = new HashSet<String>();
 
            JSONArray array = JSONArray.fromObject(filterParams);
 
            for (int i = 0; i < array.size(); i++) {
 
                String type = array.optJSONObject(i).optString("type");
 
                switch (type) {
                case "shoptype":
                    if (array.optJSONObject(i).optInt("id") == 21) {
                        sf.setTmFlagship(false); // 不筛�?
                    } else {
                        sf.setTmFlagship(true);
                        sf.setTmall(true);
                        sf.setShopTag("b2c");
                    }
                    break;
 
                case "category":
                    sf.setCateIds(array.optJSONObject(i).optString("id"));
                    break;
 
                case "userType":
                    sf.setCateIds(array.optJSONObject(i).optString("id"));
                    break;
 
                case "baoyou":
                    sf.setBaoYou(true);
                    break;
 
                case "quantype":
                    sf.setQuan(1);
                    if (sf.isTmFlagship()) {
                        sf.setShopTag(sf.getShopTag() + ",dpyhq");
                    } else {
                        sf.setShopTag("dpyhq");
                    }
                    break;
 
                case "hongbaotype":
                    if (array.optJSONObject(i).optInt("id") == 41) {
                        sf.setHongbao(1);
                    } else {
                        sf.setHongbao(2);
                    }
                    break;
 
                case "property":
                    String pid = (String) array.optJSONObject(i).opt("pid");
                    String id = (String) array.optJSONObject(i).opt("id");
                    boolean flag = false;
                    String str = null;
                    for (String string : params) {
                        flag = string.contains(pid + ":");
                        if (flag) {
                            str = string;
                            break;
                        }
                    }
                    if (flag) {
                        params.add(str + "," + id);
                        params.remove(str);
                    } else {
                        params.add(pid + ":" + id);
                    }
                    break;
 
                case "fahuodi":
                    int provinceId = array.optJSONObject(i).optInt("id");
                    sf.setProvinceId(provinceId);
                    break;
 
                default:
                    break;
                }
            }
            sf.setParams(params);
        }
 
        // 淘宝物料接口查询
        TaoBaoSearchResult result = TaoKeApiUtil.searchWuLiao(sf);
 
        List<TaoBaoSearchNav> navList = TaoBaoUtil.getBaseNav();
        if (result.getNavList() != null)
            navList.addAll(result.getNavList());
 
        Gson gson = new GsonBuilder().create();
        JSONObject data = new JSONObject();
        data.put("nav", gson.toJson(navList));
 
        List<TaoBaoGoodsBriefExtra> re = new ArrayList<TaoBaoGoodsBriefExtra>();
        List<TaoBaoGoodsBrief> taoBaoGoodsBriefs = result.getTaoBaoGoodsBriefs();
 
        int fq = sf.getQuan();
        int fh = sf.getHongbao();
        boolean ft = sf.isTmall();
 
        Map<String, String> map = manageService.convertMap();
        String proportion = map.get("hongbao_goods_proportion");
        String fcRate = map.get("hongbao_fc_ratio");
 
        if (fq == 0 && fh == 0 && !ft) {
            if (result != null && result.getTaoBaoGoodsBriefs() != null)
                for (TaoBaoGoodsBrief bf : result.getTaoBaoGoodsBriefs()) {
                    int count = bf.getBiz30day();
                    if (count >= 10000) { // 对销量数据做处理 页面展示7.3万
                        double sales = count;
                        String salesCountMidea = String.format("%.1f", sales / 10000);
                        bf.setSalesCount(salesCountMidea + "万");
                        re.add(TaoBaoUtil.getTaoBaoGoodsBriefExtra(bf, proportion, fcRate, ""));
                    } else {
                        bf.setSalesCount(count + "");
                        re.add(TaoBaoUtil.getTaoBaoGoodsBriefExtra(bf, proportion, fcRate, ""));
                    }
                }
        } else {
            TaoBaoGoodsBriefExtra taoBaoGoodsBriefExtra;
            if (taoBaoGoodsBriefs != null)
                for (TaoBaoGoodsBrief taoBaoGoodsBrief : taoBaoGoodsBriefs) {
                    int count = taoBaoGoodsBrief.getBiz30day();
                    if (count >= 10000) {
                        double sales = count;
                        String salesCountMidea = String.format("%.1f", sales / 10000);
                        taoBaoGoodsBrief.setSalesCount(salesCountMidea + "万");
                        taoBaoGoodsBriefExtra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion,
                                fcRate, "");
                        re.add(taoBaoGoodsBriefExtra);
                    } else {
                        taoBaoGoodsBrief.setSalesCount(count + "");
                        taoBaoGoodsBriefExtra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion,
                                fcRate, "");
                        re.add(taoBaoGoodsBriefExtra);
                    }
                }
        }
 
        Gson gson2 = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
                .excludeFieldsWithoutExposeAnnotation().create();
 
        data.put("result", gson2.toJson(re));
        data.put("count", result.getTaoBaoHead().getDocsfound());
 
        return data;
    }
    
    
    @Override
    public void setSearchFilter(SearchFilter searchfilter, String filter, String order,
            String startprice, String endprice, String fastFilter, Integer totalSales) {
 
        
        if (!StringUtil.isNullOrEmpty(startprice)) {
            searchfilter.setStartPrice(new BigDecimal(startprice));
        }
 
        if (!StringUtil.isNullOrEmpty(endprice)) {
            searchfilter.setEndPrice(new BigDecimal(endprice));
        }
 
        if (totalSales != null) {
            searchfilter.setStartBiz30day(totalSales + "");
        }
 
        if (!StringUtil.isNullOrEmpty(fastFilter)) {
            if (!StringUtil.isNullOrEmpty(filter)) {
                JSONArray filterArray = JSONArray.fromObject(filter);
                JSONArray fastFilterArray = JSONArray.fromObject(fastFilter);
                filterArray.addAll(fastFilterArray);
                filter = filterArray.toString();
            } else {
                filter = fastFilter;
            }
        }
 
        if (!StringUtil.isNullOrEmpty(filter)) {
            // 查询淘宝天猫
            JSONArray array = JSONArray.fromObject(filter);
            for (int i = 0; i < array.size(); i++) {
                String type = array.optJSONObject(i).optString("type");
                /* 含券 */
                if ("quantype".equalsIgnoreCase(type)) {
                    searchfilter.setQuan(1);
                    continue;
                }
                /* 搜索天猫 */
                if ("shoptype".equalsIgnoreCase(type)) {
                    searchfilter.setTmall(true);
                    continue;
                }
            }
        }
        
        
        if (!com.yeshi.fanli.util.StringUtil.isNullOrEmpty(order)) {
            if (Integer.parseInt(order) == 1 || Integer.parseInt(order) == 0) {
                searchfilter.setSort(TaoBaoUtil.SORT_SALE_HIGH_TO_LOW);
            } else if (Integer.parseInt(order) == 2) {
                searchfilter.setSort(TaoBaoUtil.SORT_PRICE_HIGH_TO_LOW);
            } else if (Integer.parseInt(order) == 3) {
                searchfilter.setSort(TaoBaoUtil.SORT_PRICE_LOW_TO_HIGH);
            } else if (Integer.parseInt(order) == 4) {
                searchfilter.setSort(TaoBaoUtil.SORT_TOTAL_SALES_HIGH_TO_LOW);
            } else if (Integer.parseInt(order) == 5) {
                searchfilter.setSort(TaoBaoUtil.SORT_SALE_LOW_TO_HIGH);
            }
        } else {
            searchfilter.setSort(TaoBaoUtil.SORT_SALE_HIGH_TO_LOW);
        }
        
    }
 
    
    @Override
    @Cacheable(value = "qualityCache",key="'countByQuality-'+#start+'-'+#searchKey+'-'+#systemCid+'-'+#listLabId")
    public List<QualityFactory> queryByQuality(long start, int count,String searchKey, Long systemCid,
            List<Long> listLabId) {
        
        /* 1、 精选库筛选 */
        List<QualityFactory> listQuality = null;
        
        if (listLabId != null && listLabId.size() > 0) {
            // 含标签
            listQuality = qualityGoodsService.listQueryByKeyAndlabIDs(start, count, searchKey,
                    listLabId, null, systemCid, null, null, null, null, null);
        } else {
            listQuality = qualityGoodsService.listQueryByKey(start, count, searchKey, null,
                    systemCid, null, null, null, null, null);
        }
        
        return listQuality;
    }
 
    
    @Override
    @Cacheable(value = "qualityCache",key="'countByQuality-'+#searchKey+'-'+#systemCid+'-'+#listLabId")
    public long countByQuality(String searchKey, Long systemCid, List<Long> listLabId) {
        
        long incount = 0;
        
        if (listLabId != null && listLabId.size() > 0) {
            // 含标签
            incount = qualityGoodsService.countQueryKeyAndlabIDs(searchKey, listLabId, systemCid, 
                    null, null, null, null, null);
        } else {
            incount = qualityGoodsService.countQueryByKey(searchKey, systemCid, null, null, null, null, null);
        }
        
        return incount;
    }
 
 
 
    @Override
    public JSONObject listQualityGoods(List<QualityFactory> listQuality, List<TaoBaoGoodsBrief> searchWuLiaoList, 
            Map<String, String> map ) {
        
        JSONArray array = new JSONArray();
        Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
                .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
        
        String proportion = map.get("hongbao_goods_proportion");
        String fcRate = map.get("hongbao_fc_ratio");
 
        /* 遍历列表数据 */
        for (QualityFactory selectionGoods : listQuality) {
 
            TaoBaoGoodsBrief taoBaoGoodsBrief = selectionGoods.getTaoBaoGoodsBrief();
 
            if (taoBaoGoodsBrief == null) {
                continue;
            }
 
            int biz30day = taoBaoGoodsBrief.getBiz30day();
            if (biz30day >= 10000) {
                double sales = biz30day;
                String salesCountMidea = String.format("%.1f", sales / 10000);
                taoBaoGoodsBrief.setSalesCount(salesCountMidea + "万");
            } else {
                taoBaoGoodsBrief.setSalesCount(biz30day + "");
            }
 
            array.add(gson.toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion, fcRate, null)));
        }
 
        if (searchWuLiaoList != null && searchWuLiaoList.size() > 0) {
            /* 遍历列表数据 */
            for (TaoBaoGoodsBrief taoBaoGoodsBrief : searchWuLiaoList) {
 
                int biz30day = taoBaoGoodsBrief.getBiz30day();
 
                if (biz30day >= 10000) {
                    double sales = biz30day;
                    String salesCountMidea = String.format("%.1f", sales / 10000);
                    taoBaoGoodsBrief.setSalesCount(salesCountMidea + "万");
                } else {
                    taoBaoGoodsBrief.setSalesCount(biz30day + "");
                }
 
                array.add(gson
                        .toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion, fcRate, null)));
            }
        }
 
        JSONObject data = new JSONObject();
 
        List<TaoBaoSearchNav> navList = new ArrayList<TaoBaoSearchNav>();
        Gson gsonBuilder = new GsonBuilder().create();
        data.put("nav", gsonBuilder.toJson(navList));
        data.put("count", 5000);
        data.put("result", array);
        
        return data;
    }
    
}