admin
2019-03-14 eed607d87b2eee1f09b4a28da614f3ad0b46601d
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
639
package com.yeshi.fanli.service.impl.goods;
 
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.Serializable;
import java.net.URLEncoder;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.UUID;
 
import javax.annotation.Resource;
import javax.transaction.Transactional;
 
import org.apache.commons.beanutils.PropertyUtils;
import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.orm.hibernate4.HibernateCallback;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import org.yeshi.utils.tencentcloud.COSManager;
 
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.yeshi.fanli.dao.goods.GoodsClassDao;
import com.yeshi.fanli.dao.mybatis.GoodsClassMapper;
import com.yeshi.fanli.dao.mybatis.lable.LabelClassMapper;
import com.yeshi.fanli.entity.admin.GoodsClassAdmin;
import com.yeshi.fanli.entity.bus.clazz.GoodsClass;
import com.yeshi.fanli.entity.bus.clazz.GoodsSubClass;
import com.yeshi.fanli.entity.bus.su.clazz.SuperGoodsClass;
import com.yeshi.fanli.entity.system.BusinessSystem;
import com.yeshi.fanli.service.inter.config.BusinessSystemService;
import com.yeshi.fanli.service.inter.goods.ClassRecommendGoodsService;
import com.yeshi.fanli.service.inter.goods.GoodsClassService;
import com.yeshi.fanli.service.inter.goods.GoodsSecondClassService;
import com.yeshi.fanli.service.inter.goods.GoodsSubClassService;
import com.yeshi.fanli.service.inter.goods.SuperGoodsClassService;
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.StringUtil;
import com.yeshi.fanli.util.Utils;
 
@Service
public class GoodsClassServiceImpl implements GoodsClassService {
 
    @Resource
    private GoodsClassDao goodsClassDao;
 
    @Resource
    private BusinessSystemService businessSystemService;
 
    @Resource
    private SuperGoodsClassService superGoodsClassService;
 
    @Resource
    private ClassRecommendGoodsService classRecommendGoodsService;
 
    @Resource
    private GoodsSecondClassService goodsSecondClassService;
 
    @Resource
    private GoodsClassMapper goodsClassMapper;
    
    @Resource
    private LabelClassMapper labelClassMapper;
    
    
    @Resource
    private GoodsSubClassService goodsSubClassService;
    
 
    public GoodsClass getGoodsClass(long gcid) {
        return goodsClassDao.find(GoodsClass.class, gcid);
    }
 
    @Override
    public void deleteGoodsClass(final long id) {
        goodsClassDao.excute(new HibernateCallback() {
                public Object doInHibernate(Session session)
                        throws HibernateException {
                    Query query = session.createQuery("delete from GoodsClass  where  id = ? ");
                    query.setParameter(0, id);
                    query.executeUpdate();
                    return null;
                }
            });
    }
    
    @Override
    @SuppressWarnings("unchecked")
    public List<GoodsClass> getByorderby(int orderby) {
        
        List<GoodsClass> goodsClassList = (List<GoodsClass>) goodsClassDao.excute(new HibernateCallback<List<GoodsClass>>() {
            public List<GoodsClass> doInHibernate(Session session) throws HibernateException {
                Query query = session.createQuery(" from GoodsClass rs where rs.orderby = ? ");
                query.setParameter(0, orderby);
                return query.list();
            }
        });
        
        return goodsClassList;
    }
    
    
    @SuppressWarnings("unchecked")
    public List<GoodsClassAdmin> getGoodsClassAdmins(int index, String platform, String packages, String key) {
        final int strat = index * Constant.PAGE_SIZE;
        platform = Utils.getMap().get(platform);
        BusinessSystem system = businessSystemService.getBusinessSystem(platform, packages);
        List<GoodsClass> GoodsClassList = null;
        List<SuperGoodsClass> superGoodsClassList = null;
        Map<Long, GoodsClassAdmin> goodsClassAdminMap = new HashMap<Long, GoodsClassAdmin>();
        List<GoodsClassAdmin> goodsClassAdmin = new ArrayList<GoodsClassAdmin>();
        if (system == null) {
            final String likekey = "%" + key + "%";
            GoodsClassList = (List<GoodsClass>) goodsClassDao.excute(new HibernateCallback<List<GoodsClass>>() {
                public List<GoodsClass> doInHibernate(Session session) throws HibernateException {
                    Query query = session.createQuery(" from GoodsClass rs where rs.name like ? ");
                    query.setFirstResult(strat);
                    query.setMaxResults(Constant.PAGE_SIZE);
                    query.setParameter(0, likekey);
                    return query.list();
                }
            });
            List<Long> gcIdList = new ArrayList<Long>();
            for (GoodsClass rs : GoodsClassList) {
                gcIdList.add(rs.getId());
            }
            superGoodsClassList = superGoodsClassService.getSuperGoodsClasss(gcIdList);
            Map<Long, List<BusinessSystem>> superMap = new HashMap<Long, List<BusinessSystem>>();
            Long rsId = null;
            List<BusinessSystem> systemList = null;
            for (SuperGoodsClass srs : superGoodsClassList) {
                rsId = srs.getGoodsClass().getId();
                systemList = superMap.get(rsId);
                if (systemList == null) {
                    systemList = new ArrayList<BusinessSystem>();
                }
                systemList.add(srs.getSystem());
                superMap.put(rsId, systemList);
            }
            GoodsClassAdmin rsa = null;
            for (GoodsClass GoodsClass : GoodsClassList) {
                long id = GoodsClass.getId();
                rsa = goodsClassAdminMap.get(id);
                if (rsa == null) {
                    rsa = new GoodsClassAdmin();
                }
                List<BusinessSystem> list = superMap.get(id);
                if (list != null) {
                    rsa.getSystemList().addAll(superMap.get(id));
                }
                rsa.setGoodsClass(GoodsClass);
                goodsClassAdminMap.put(id, rsa);
            }
        } else if (system != null) {
            String likekey = "%" + key + "%";
            superGoodsClassList = superGoodsClassService.getSuperGoodsClassList(system.getId(), strat,
                    Constant.PAGE_SIZE, likekey);
            List<Long> gcIdList = new ArrayList<Long>();
            for (SuperGoodsClass superGoodsClass : superGoodsClassList) {
                GoodsClass GoodsClass = superGoodsClass.getGoodsClass();
                gcIdList.add(GoodsClass.getId());
            }
            superGoodsClassList = superGoodsClassService.getSuperGoodsClasss(gcIdList);
            GoodsClassAdmin rsa = null;
            for (SuperGoodsClass superGoodsClass : superGoodsClassList) {
                GoodsClass goodsClass = superGoodsClass.getGoodsClass();
                rsa = goodsClassAdminMap.get(goodsClass.getId());
                if (rsa == null) {
                    rsa = new GoodsClassAdmin(goodsClass);
                }
                rsa.getSystemList().add(superGoodsClass.getSystem());
                goodsClassAdminMap.put(goodsClass.getId(), rsa);
            }
        }
        Map map = Utils.orderBy(goodsClassAdminMap);
        Collection<GoodsClassAdmin> values = map.values();
        goodsClassAdmin.addAll(values);
        return goodsClassAdmin;
 
    }
 
    public int getCount(String platform, String packages, final String key) {
        platform = Utils.getMap().get(platform);
        final BusinessSystem system = businessSystemService.getBusinessSystem(platform, packages);
        return (Integer) goodsClassDao.excute(new HibernateCallback<Integer>() {
 
            public Integer doInHibernate(Session session) throws HibernateException {
                String k = "%" + key + "%";
                if (system == null) {
                    // Query query = session.createSQLQuery("select
                    // count(a.name) from (select `name` from yeshi_ec_class
                    // where `name` like ?) a");
                    Query query = session.createQuery("select count(gc.id) from GoodsClass gc where gc.name like ?");
                    query.setParameter(0, k);
                    Long result = (Long) query.uniqueResult();
                    int intValue = result.intValue();
                    return intValue;
                } else {
                    // Query query =session.createSQLQuery("select count(a.name)
                    // from (select hs.name from yeshi_ec_super_goodsclass shs
                    // left join yeshi_ec_class hs on shs.goodsclass_id=hs.id
                    // where shs.system_id=? and hs.name like ?) a");
                    Query query = session.createQuery(
                            "select count(sgc.id) from SuperGoodsClass sgc where sgc.goodsClass.name like ? and sgc.system.id=?");
                    query.setParameter(0, k);
                    query.setParameter(1, system.getId());
                    Long result = (Long) query.uniqueResult();
                    int intValue = result.intValue();
                    return intValue;
                }
            }
        });
    }
 
    // @Transactional
    // public void addGoodsClass(GoodsClass goodsClass) {
    // goodsClass.setCreatetime(java.lang.System.currentTimeMillis());
    // Serializable id = goodsClassDao.save(goodsClass);
    // Properties properties = new Properties();
    // InputStream in = null;
    // try {
    // in = new BufferedInputStream (new FileInputStream("url.properties"));
    // properties.load(in);
    // String url = (String) properties.get("url");
    // goodsClass.setUrl(url+id);
    // goodsClassDao.update(goodsClass);
    // } catch (FileNotFoundException e) {
    // e.printStackTrace();
    // } catch (IOException e) {
    // e.printStackTrace();
    // }finally{
    // if(in !=null){
    // try {
    // in.close();
    // } catch (IOException e) {
    // e.printStackTrace();
    // }
    // }
    // }
    // }
 
    public Integer addGoodsClass(final GoodsClass goodsClass) {
 
        return (Integer) goodsClassDao.excute(new HibernateCallback() {
 
            public Object doInHibernate(Session session) throws HibernateException {
                session.getTransaction().begin();
                goodsClass.setCreatetime(java.lang.System.currentTimeMillis());
                Serializable id = session.save(goodsClass);
                Properties properties = new Properties();
                InputStream in = null;
                try {
                    in = this.getClass().getClassLoader().getResourceAsStream("url.properties");
                    properties.load(in);
                    String url = (String) properties.get("url");
                    url = MessageFormat.format(url, id, goodsClass.getKey(), goodsClass.getName());
                    goodsClass.setUrl(url);
                    session.update(goodsClass);
                    session.flush();
                    session.getTransaction().commit();
                } catch (FileNotFoundException e) {
                    session.getTransaction().rollback();
                    e.printStackTrace();
                    return 1;
                } catch (IOException e) {
                    session.getTransaction().rollback();
                    e.printStackTrace();
                    return 2;
                } finally {
                    if (in != null) {
                        try {
                            in.close();
                        } catch (IOException e) {
                            e.printStackTrace();
                        }
                    }
                }
                return null;
            }
        });
    }
 
    
    @Transactional
    public void deleteGoodsClasss(long[] gcids) {
        for (long id : gcids) {
            superGoodsClassService.deleteSuperGoodsClass(id);
            classRecommendGoodsService.deleteClassGoodsByGC(id);
            goodsSecondClassService.deleteSecondClassByGC(id);
            goodsClassDao.delete(new GoodsClass(id));
        }
    }
    
    public Integer updateGoodsClass(final GoodsClass goodsClass) {
 
        return (Integer) goodsClassDao.excute(new HibernateCallback() {
 
            public Object doInHibernate(Session session) throws HibernateException {
                session.getTransaction().begin();
                goodsClass.setCreatetime(java.lang.System.currentTimeMillis());
                session.update(goodsClass);
                Properties properties = new Properties();
                InputStream in = null;
                try {
                    in = this.getClass().getClassLoader().getResourceAsStream("url.properties");
                    properties.load(in);
                    String url = (String) properties.get("url");
                    
                    java.lang.System.out.println(goodsClass.getKey());
                    java.lang.System.out.println(goodsClass.getName());
                    
                    String encodeKey = URLEncoder.encode(goodsClass.getKey(), "utf-8");
                    String encodeName = URLEncoder.encode(goodsClass.getName(), "utf-8");
                    url = MessageFormat.format(url, goodsClass.getId(), encodeKey, encodeName);
                    goodsClass.setUrl(url);
                    session.update(goodsClass);
                    session.flush();
                    session.getTransaction().commit();
                } catch (FileNotFoundException e) {
                    session.getTransaction().rollback();
                    e.printStackTrace();
                    return 1;
                } catch (IOException e) {
                    session.getTransaction().rollback();
                    e.printStackTrace();
                    return 2;
                } finally {
                    if (in != null) {
                        try {
                            in.close();
                        } catch (IOException e) {
                            e.printStackTrace();
                        }
                    }
                }
                return null;
            }
        });
    }
 
    @SuppressWarnings("unchecked")
    @Override
    public List<GoodsClass> queryAll(String platform, String packages) throws Exception{
 
        List<BusinessSystem> defultList = businessSystemService.getBusinessSystems();
 
        platform = Utils.getMap().get(platform);
        BusinessSystem system = businessSystemService.getBusinessSystem(platform, packages);
        
        List<GoodsClass> goodsClassList = new ArrayList<GoodsClass>();
        List<SuperGoodsClass> superGoodsClassList = null;
        List<Long> gcIdList = new ArrayList<Long>();
        
        if (system == null) {
            
            goodsClassList = (List<GoodsClass>) goodsClassDao.excute(new HibernateCallback<List<GoodsClass>>() {
                public List<GoodsClass> doInHibernate(Session session) throws HibernateException {
                    Query query = session.createQuery(" from GoodsClass order by orderby");
                    return query.list();
                }
            });
            
            if (goodsClassList == null || goodsClassList.size() == 0) {
                return null;
            }
            
            /* 存放类别id集合 */
            for (GoodsClass rs : goodsClassList) {
                gcIdList.add(rs.getId());
            }
 
        } else if (system != null) {
            superGoodsClassList = superGoodsClassService.getSuperGoodsClassAll(system.getId());
            
            if (goodsClassList == null || goodsClassList.size() == 0) {
                return null;
            }
            
            for (SuperGoodsClass superGoodsClass : superGoodsClassList) {
                GoodsClass goodsClass = superGoodsClass.getGoodsClass();
                goodsClassList.add(goodsClass);
                gcIdList.add(goodsClass.getId());
            }
            
        }
        
        /* 根据类别 id 查询关联系统数据 */
        superGoodsClassList = superGoodsClassService.getSuperGoodsClasss(gcIdList);
 
        for (GoodsClass gclass : goodsClassList) {
            
            Long iosClick = gclass.getIosClick();
            Long androidClick = gclass.getAndroidClick();
 
            if (iosClick != null && androidClick != null) {
                gclass.setCountClick(iosClick + androidClick);
            } else if (androidClick != null) {
                gclass.setCountClick(androidClick);
            } else if (iosClick != null) {
                gclass.setCountClick(iosClick);
            } else {
                gclass.setCountClick(0l);
            }
 
            int countlabel = labelClassMapper.getCountQueryByClassId(gclass.getId());
            gclass.setCountlabel(countlabel);
 
            List<Long> gList = new ArrayList<Long>();
            if (superGoodsClassList != null && superGoodsClassList.size() > 0) {
                for (SuperGoodsClass srs : superGoodsClassList) {
                    
                    long rsId = srs.getGoodsClass().getId();
                    
                    if (gclass.getId() == rsId) {
                        BusinessSystem gsystem = srs.getSystem();
                        gList.add(gsystem.getId());
                    }
                }
            }
            
            List<BusinessSystem> newList = new ArrayList<BusinessSystem>();
            // 是否有关联系统选项
            for (BusinessSystem dsystem : defultList) {
                
                BusinessSystem newsystem = new BusinessSystem();
                
                PropertyUtils.copyProperties(newsystem, dsystem);
                newsystem.setCheck(0);
                
                if (gList != null && gList.size() > 0) {
                    Long did = newsystem.getId();
                    for (Long gid : gList) {
                        if (gid == did) {
                            newsystem.setCheck(1);
                        }
                    }
                }
                
                newList.add(newsystem);
            }
             
            gclass.setSystemList(newList);
             
        }
        
        return goodsClassList;
 
    }
    
    public List<GoodsClass> getGoodsClassAll() {
        return goodsClassDao.list("from GoodsClass order by orderby");
    }
 
    @Override
    public String getKwById(Long id) {
        return goodsClassMapper.getKwById(id);
    }
    
    @Override
    public GoodsClass selectByPrimaryKey(Long gcid) {
        return goodsClassMapper.selectByPrimaryKey(gcid);
    }
    
    @Override
    public int updateByPrimaryKeySelective(GoodsClass record) {
        return goodsClassMapper.updateByPrimaryKeySelective(record);
    }
    
    
    
    @Override
    public List<GoodsClass> queryAll() {
        return goodsClassMapper.queryAll();
    }
    
    @Cacheable(value="classCache",key="'getGoodsClass-'+#gcid")
    @Override
    public GoodsClass getGoodsClassCache(long gcid) {
        return getGoodsClass(gcid);
    }
 
    @Override
    @SuppressWarnings("unchecked")
    public long saveAdd(GoodsClass record, MultipartFile file) throws Exception{
        
        long result = 0;        
        record.setCreatetime(java.lang.System.currentTimeMillis());
        
        /*  上传新图片  */
        if (file != null) {
            InputStream inputStream = file.getInputStream();
            String contentType = file.getContentType();
            String type = contentType.substring(contentType.indexOf("/") + 1);
            // 上传文件相对位置
            String fileUrl="ClassImg/"+UUID.randomUUID().toString().replace("-", "") + "." + type;
            String uploadFilePath = COSManager.getInstance().uploadFile(inputStream, fileUrl).getUrl();
            
            record.setPicture(uploadFilePath);
        }
        
        addGoodsClass(record);
        
        record.setOrderby((int)record.getId());
        updateGoodsClass(record);
        
        long id = record.getId();
        if (id > 0) 
            return id;
        
        return result;
    }
    
    @Override
    public void uploadPicture(GoodsClass record, MultipartFile file) throws Exception {
        
        InputStream inputStream = file.getInputStream();
        String contentType = file.getContentType();
        String type = contentType.substring(contentType.indexOf("/") + 1);
        // 上传文件相对位置
        String fileUrl="ClassImg/"+UUID.randomUUID().toString().replace("-", "") + "." + type;
        
        boolean deleteFile =true;
        
        /*  修改图片时,先删除已存在图片  */
        String picture = record.getPicture();
        if (!StringUtil.isNullOrEmpty(picture)) 
            deleteFile = COSManager.getInstance().deleteFile(picture);
        
        String uploadFilePath = null;
        /*  上传新图片  */
        if (deleteFile) {
            uploadFilePath = COSManager.getInstance().uploadFile(inputStream, fileUrl).getUrl();
        }
        
        /*  更新数据库信息  */
        if (!StringUtil.isNullOrEmpty(uploadFilePath)) {
            record.setPicture(uploadFilePath);
            updateGoodsClass(record);
        }
        
    }
 
    /**
     * 删除图片
     */
    @Override
    public void removePicture(GoodsClass record) throws Exception {
        
        String fileUrl = record.getPicture();
        boolean deleteFile = true;
        
        if (StringUtil.isNullOrEmpty(fileUrl)) {
            return;
        }
        
        deleteFile = COSManager.getInstance().deleteFile(fileUrl);
        if (deleteFile) {
            record.setPicture(null);
            // 更新数据库
             updateGoodsClass(record);
        } 
    }
 
    @Override
    @Cacheable(value="classCache",key="'getListClassCache-'+#systemId")
    public List<GoodsClass> getListClassCache(Long systemId) throws Exception {
        List<SuperGoodsClass> superGoodsClassList = superGoodsClassService.getSuperGoodsClassBySystemId(systemId);
        
        if (superGoodsClassList == null || superGoodsClassList.size() == 0) {
            return null;
        }
        
        List<GoodsClass> goodsClassList = new ArrayList<GoodsClass>();
        for (SuperGoodsClass superGoodsClass : superGoodsClassList) {
            GoodsClass goodsClass = superGoodsClass.getGoodsClass();
            goodsClassList.add(goodsClass);
        }
        
        return goodsClassList;
    }
    
    
    @Override
    @Cacheable(value="classCache",key="'getClassListAllCache-'+#systemId")
    public List<Map<String, Object>> getClassListAllCache(Long systemId) throws Exception {
 
        List<GoodsClass> goodsClassList = goodsClassMapper.listGoodsClassBySystemId(systemId);
        if (goodsClassList == null || goodsClassList.size() == 0) {
            return null;
        }
 
        List<Long> listID = new ArrayList<Long>();
        for (GoodsClass coodsClass : goodsClassList) {
            listID.add(coodsClass.getId());
        }
    
        List<GoodsSubClass> listSub = goodsSubClassService.queryByListCid(listID);
        
        Gson gson = new GsonBuilder().create();
 
        List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
        for (GoodsClass goodsClass : goodsClassList) {
 
            List<GoodsSubClass> subClassList = new ArrayList<GoodsSubClass>();
            
            if (listSub != null && listSub.size() > 0) {
                Iterator<GoodsSubClass> iterator = listSub.iterator();
                while (iterator.hasNext()) {
                    GoodsSubClass goodsSubClass = iterator.next();
                    GoodsClass goodsClassInner = goodsSubClass.getRootClass();
                    if (goodsClass.getId() == goodsClassInner.getId()) {
                        // 对应下子分类
                        subClassList.add(goodsSubClass);
                        iterator.remove();
                    }
                }
            }
 
            Map<String, Object> map = new HashMap<String, Object>();
            map.put("gclass", goodsClass);
            map.put("subList", gson.toJson(subClassList));
 
            list.add(map);
        }
 
        return list;
    }
    
}