Administrator
2018-10-30 c0c91fbda1ba601c4c8cb6d12fd43dfbe02eea5d
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
package com.yeshi.fanli.service.impl.goods;
 
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;
 
import javax.annotation.Resource;
import javax.transaction.Transactional;
 
import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;
import org.springframework.orm.hibernate4.HibernateCallback;
import org.springframework.stereotype.Service;
 
import com.yeshi.fanli.dao.config.AddEveryDayTaskDao;
import com.yeshi.fanli.dao.goods.RecommendSectionGoodsDao;
import com.yeshi.fanli.dao.mybatis.taobao.TaoBaoGoodsBriefMapper;
import com.yeshi.fanli.dao.taobao.TaoBaoGoodsBriefDao;
import com.yeshi.fanli.entity.admin.EveryDayTask;
import com.yeshi.fanli.entity.bus.clazz.GoodsClass;
import com.yeshi.fanli.entity.bus.recommend.RecommendSection;
import com.yeshi.fanli.entity.bus.recommend.RecommendSectionGoods;
import com.yeshi.fanli.entity.taobao.PidUser;
import com.yeshi.fanli.entity.taobao.SearchFilter;
import com.yeshi.fanli.entity.taobao.TBPid;
import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
import com.yeshi.fanli.entity.taobao.TaoBaoUnionConfig;
import com.yeshi.fanli.entity.taobao.TaoKeAppInfo;
import com.yeshi.fanli.exception.ExistObjectException;
import com.yeshi.fanli.exception.NotExistObjectException;
import com.yeshi.fanli.exception.ShareGoodsException;
import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
import com.yeshi.fanli.service.inter.goods.ClassRecommendGoodsService;
import com.yeshi.fanli.service.inter.goods.GoodsClassService;
import com.yeshi.fanli.service.inter.goods.RecommendSectionGoodsService;
import com.yeshi.fanli.service.inter.goods.RecommendSectionService;
import com.yeshi.fanli.service.inter.goods.TaoBaoCouponService;
import com.yeshi.fanli.service.inter.goods.TaoBaoGoodsBriefService;
import com.yeshi.fanli.service.inter.hongbao.HongBaoManageService;
import com.yeshi.fanli.service.inter.taobao.TaoBaoUnionConfigService;
import com.yeshi.fanli.service.inter.user.TBPidService;
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.StringUtil;
import com.yeshi.fanli.util.taobao.TaoBaoUtil;
import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
import org.yeshi.utils.NumberUtil;
 
@Service
public class TaoBaoGoodsBriefServiceImpl implements TaoBaoGoodsBriefService {
 
    @Resource
    private TaoBaoGoodsBriefDao taoBaoGoodsBriefDao;
 
    @Resource
    private RecommendSectionGoodsDao recommendSectionGoodsDao;
 
    @Resource
    private RecommendSectionGoodsService recommendSectionGoodsService;
 
    @Resource
    private RecommendSectionService recommendSectionService;
 
    @Resource
    private ClassRecommendGoodsService classRecommendGoodsService;
 
    @Resource
    private GoodsClassService goodsClassService;
 
    @Resource
    private AddEveryDayTaskDao addEveryDayTaskDao;
 
    @Resource
    private HongBaoManageService hongBaoManageService;
 
    @Resource
    private TaoBaoCouponService taoBaoCouponService;
 
    @Resource
    private TaoBaoGoodsBriefMapper taoBaoGoodsBriefMapper;
 
    @Resource
    private TBPidService tbPidService;
 
    @Resource
    private TaoBaoUnionConfigService taoBaoUnionConfigService;
 
    public void save(TaoBaoGoodsBrief taoBaoGoodsBrief) throws ExistObjectException {
 
        long auctionId = taoBaoGoodsBrief.getAuctionId();
        List<TaoBaoGoodsBrief> list = taoBaoGoodsBriefDao.list("from TaoBaoGoodsBrief tb where tb.auctionId = ?",
                new Serializable[] { auctionId });
        if (list.size() > 0) {
            throw new ExistObjectException("已存在该商品");
        }
 
        taoBaoGoodsBrief.setCreatetime(new Date());
        taoBaoGoodsBriefDao.create(taoBaoGoodsBrief);
    }
 
    public List<TaoBaoGoodsBrief> getTBList(int index, String key) {
 
        int start = index * Constant.PAGE_SIZE;
 
        boolean b = NumberUtil.isNumeric(key);
        if (b) {
            return taoBaoGoodsBriefDao.list(
                    "from TaoBaoGoodsBrief tb where tb.title like ? or tb.auctionId = ? order by tb.id desc", start,
                    Constant.PAGE_SIZE, new Serializable[] { "%" + key + "%", Long.parseLong(key) });
        } else {
            return taoBaoGoodsBriefDao.list("from TaoBaoGoodsBrief tb where tb.title like ? order by tb.id desc", start,
                    Constant.PAGE_SIZE, new Serializable[] { "%" + key + "%" });
        }
 
    }
 
    public int getCount(String key) {
        boolean b = NumberUtil.isNumeric(key);
        Long lcount = 0L;
        if (b) {
            lcount = taoBaoGoodsBriefDao.getCount(
                    "select count(*) from TaoBaoGoodsBrief tb where tb.title like ? or tb.auctionId = ? ",
                    new Serializable[] { "%" + key + "%", Long.parseLong(key) });
        } else {
            lcount = taoBaoGoodsBriefDao.getCount("select count(*) from TaoBaoGoodsBrief tb where tb.title like ? ",
                    new Serializable[] { "%" + key + "%" });
        }
 
        return lcount.intValue();
    }
 
    public TaoBaoGoodsBrief getTaoBao(long id) {
 
        return taoBaoGoodsBriefDao.find(TaoBaoGoodsBrief.class, id);
    }
 
    public TaoBaoGoodsBrief getTaoBaoByAuctionId(long id) {
        List<TaoBaoGoodsBrief> list = taoBaoGoodsBriefDao
                .list("from  TaoBaoGoodsBrief goods where goods.auctionId=" + id);
        if (list == null || list.size() == 0)
            return null;
        else
            return list.get(0);
    }
 
    @Transactional
    public void deleteTaoBaoGoods(final long id) {
        taoBaoGoodsBriefDao.excute(new HibernateCallback() {
 
            public Object doInHibernate(Session session) throws HibernateException {
                recommendSectionGoodsService.deleteRecommendSectionGoodsByTB(id);
                classRecommendGoodsService.deleteRecommendGoodsByTB(id);
                Query query = session.createQuery("delete from TaoBaoGoodsBrief tb where tb.id = ?");
                query.setParameter(0, id);
                return query.executeUpdate();
            }
        });
    }
 
    @Transactional
    public void addRecommendSectionGoods(long rsid, long tbid) throws NotExistObjectException, ExistObjectException {
        RecommendSection recommendSection = recommendSectionService.getRecommendSection(rsid);
        TaoBaoGoodsBrief taobao = taoBaoGoodsBriefDao.find(TaoBaoGoodsBrief.class, tbid);
        if (recommendSection == null || taobao == null) {
            throw new NotExistObjectException("不存在该板块或者淘宝商品");
        }
        recommendSectionGoodsService.addRecommendSectionGoods(recommendSection, taobao);
    }
 
    /**
     * 添加商品到每日任务
     */
    @Override
    public void addEveryDayTask(long tbid) throws NotExistObjectException, ExistObjectException {
        TaoBaoGoodsBrief taobao = taoBaoGoodsBriefDao.find(TaoBaoGoodsBrief.class, tbid);
        if (taobao == null) {
            throw new NotExistObjectException("不存在该淘宝商品");
        }
        EveryDayTask everyDaoTask = new EveryDayTask();
        everyDaoTask.setEtGoods(taobao);
        everyDaoTask.setEtCreateTime(new Date());
        addEveryDayTaskDao.create(everyDaoTask);
    }
 
    @Transactional
    public void addClassRecommendGoods(long gcid, long tbid) throws NotExistObjectException, ExistObjectException {
        GoodsClass goodsClass = goodsClassService.getGoodsClass(gcid);
        TaoBaoGoodsBrief taobao = taoBaoGoodsBriefDao.find(TaoBaoGoodsBrief.class, tbid);
        if (goodsClass == null || taobao == null) {
            throw new NotExistObjectException("不存在该分类或者淘宝商品");
        }
        classRecommendGoodsService.addRecommendGoods(goodsClass, taobao);
    }
 
    public TaoBaoGoodsBrief getTaoBaoByAuctionId(String tbid) {
        List<TaoBaoGoodsBrief> list = taoBaoGoodsBriefDao.list("from TaoBaoGoodsBrief tb where tb.auctionId=?",
                new Serializable[] { Long.parseLong(tbid) });
        if (list.size() == 0) {
            return null;
        }
        return list.get(0);
    }
 
    public void updateTBGoods(TaoBaoGoodsBrief tb) throws NotExistObjectException {
        TaoBaoGoodsBrief find = taoBaoGoodsBriefDao.find(TaoBaoGoodsBrief.class, tb.getId());
        if (find == null) {
            throw new NotExistObjectException("不存在该对象");
        }
        find.setPictUrl(tb.getPictUrl());
        find.setTitle(tb.getTitle());
        taoBaoGoodsBriefDao.update(find);
    }
 
    @SuppressWarnings("unchecked")
    public List<TaoBaoGoodsBrief> getAllTaoBao() {
        return (List<TaoBaoGoodsBrief>) taoBaoGoodsBriefDao.excute(new HibernateCallback<List<TaoBaoGoodsBrief>>() {
 
            public List<TaoBaoGoodsBrief> doInHibernate(Session session) throws HibernateException {
                Query query = session.createQuery("from TaoBaoGoodsBrief ");
                return query.list();
            }
        });
    }
 
    public void getUpdateTaoBao() {
        List<TaoBaoGoodsBrief> list = getAllTaoBao();
        int len = list.size();
        for (TaoBaoGoodsBrief taoBaoGoodsBrief : list) {
            try {
                Thread.sleep(2000);
            } catch (InterruptedException e) {
                continue;
            }
            try {
                updateTaoBaoGoods(taoBaoGoodsBrief);
            } catch (TaobaoGoodsDownException e) {
                e.printStackTrace();
            }
            len--;
            System.out.println("还剩:" + len + "个商品未更新");
        }
        return;
    }
 
    public void updateTaoBaoGoods(TaoBaoGoodsBrief taoBaoGoodsBrief) throws TaobaoGoodsDownException {
 
        SearchFilter filter = new SearchFilter();
        filter.setKey("https://item.taobao.com/item.htm?id=" + taoBaoGoodsBrief.getAuctionId());
        TaoBaoGoodsBrief tb = TaoKeApiUtil.searchGoodsDetail(taoBaoGoodsBrief.getAuctionId());
        if (tb == null) {
            return;
        }
 
        taoBaoGoodsBrief.setCouponLink(tb.getCouponLink());
        taoBaoGoodsBrief.setCouponActivityId(tb.getCouponActivityId());
        taoBaoGoodsBrief.setCouponAmount(tb.getCouponAmount());
        taoBaoGoodsBrief.setCouponEffectiveStartTime(tb.getCouponEffectiveStartTime());
        taoBaoGoodsBrief.setCouponEffectiveEndTime(tb.getCouponEffectiveEndTime());
        taoBaoGoodsBrief.setCouponInfo(tb.getCouponInfo());
        taoBaoGoodsBrief.setCouponLeftCount(tb.getCouponLeftCount());
        taoBaoGoodsBrief.setCouponLinkTaoToken(tb.getCouponLinkTaoToken());
        taoBaoGoodsBrief.setCouponOriLink(tb.getCouponOriLink());
        taoBaoGoodsBrief.setCouponShortLink(tb.getCouponShortLink());
        taoBaoGoodsBrief.setCouponStartFee(tb.getCouponStartFee());
        taoBaoGoodsBrief.setCouponTotalCount(tb.getCouponTotalCount());
        taoBaoGoodsBrief.setBiz30day(tb.getBiz30day());
        taoBaoGoodsBrief.setTkRate(tb.getTkRate());
        taoBaoGoodsBrief.setZkPrice(tb.getZkPrice());
        taoBaoGoodsBrief.setEventRate(tb.getEventRate());
        taoBaoGoodsBrief.setTkMktStatus(tb.getTkMktStatus());
        taoBaoGoodsBrief.setReservePrice(tb.getReservePrice());
 
        taoBaoGoodsBrief.setCreatetime(new Date());
        taoBaoGoodsBriefDao.update(taoBaoGoodsBrief);
 
    }
 
    public int getInvalidCount() {
        Long count = taoBaoGoodsBriefDao.getCount("select count(tb.id) from TaoBaoGoodsBrief tb where tb.tkRate = 0");
        return count.intValue();
    }
 
    public List<TaoBaoGoodsBrief> getInvalidTB(int pageIndex) {
        int start = (pageIndex - 1) * Constant.PAGE_SIZE;
        return taoBaoGoodsBriefDao.list("from TaoBaoGoodsBrief tb where tb.tkRate = 0 ", start, Constant.PAGE_SIZE,
                new Serializable[] {});
    }
 
    /**
     * 从yeshi_ec_recommend_section_goods表中查询数据
     */
    @SuppressWarnings("unchecked")
    @Override
    public List<RecommendSectionGoods> listRecommendSectionGoods() {
        return recommendSectionGoodsDao.list("from RecommendSectionGoods");
    }
 
    @Override
    public String getGoodsUserHongBao(TaoBaoGoodsBrief goods) {
        Map<String, String> convertMap = hongBaoManageService.convertMap();
        String proportion = convertMap.get("hongbao_goods_proportion");
        return TaoBaoUtil.getGoodsHongBaoInfo(goods, new BigDecimal(proportion));
    }
 
    @Override
    public BigDecimal getShareGoodsUserHongBao(TaoBaoGoodsBrief goods) {
        Map<String, String> convertMap = hongBaoManageService.convertMap();
        String proportion = convertMap.get("hongbao_goods_proportion");
        return TaoBaoUtil.getShareGoodsHongBaoInfo(goods, new BigDecimal(proportion));
    }
 
    @Override
    public List<TaoBaoGoodsBrief> queryByAuctionId(Long auctionId) {
        return taoBaoGoodsBriefMapper.queryByAuctionId(auctionId);
    }
    
    @Override
    public List<TaoBaoGoodsBrief> listQueryByAuctionId(List<Long> list) {
        return taoBaoGoodsBriefMapper.queryGoodsByAuctionId(list);
    }
    
    
 
    @Override
    public int insertSelective(TaoBaoGoodsBrief taoBaoGoodsBrief) {
 
        return taoBaoGoodsBriefMapper.insertSelective(taoBaoGoodsBrief);
    }
    
    @Override
    public int insertBatch(List<TaoBaoGoodsBrief> list) {
 
        return taoBaoGoodsBriefMapper.insertBatch(list);
    }
 
    @Override
    public TaoBaoGoodsBrief selectByPrimaryKey(Long id) {
        return taoBaoGoodsBriefMapper.selectByPrimaryKey(id);
    }
 
    @Override
    public int updateByPrimaryKey(TaoBaoGoodsBrief taoBaoGoodsBrief) {
        return taoBaoGoodsBriefMapper.updateByPrimaryKey(taoBaoGoodsBrief);
    }
    
    
    @Override
    public void updateTBGoodsWithNewInfo(TaoBaoGoodsBrief tb) throws NotExistObjectException {
        if (tb == null)
            return;
        List<TaoBaoGoodsBrief> findList = taoBaoGoodsBriefDao
                .list("from TaoBaoGoodsBrief tb where tb.auctionId=" + tb.getAuctionId());
        if (findList != null && findList.size() > 0) {
            for (TaoBaoGoodsBrief goods : findList) {
                tb.setId(goods.getId());
                if (!StringUtil.isNullOrEmpty(goods.getPictUrl()))
                    tb.setPictUrl(goods.getPictUrl());
                taoBaoGoodsBriefDao.update(tb);
            }
        }
 
    }
 
    @Override
    public void updateTaoBaoGoodsByMybatis(TaoBaoGoodsBrief taoBaoGoodsBrief) throws TaobaoGoodsDownException {
 
        SearchFilter filter = new SearchFilter();
        filter.setKey("https://item.taobao.com/item.htm?id=" + taoBaoGoodsBrief.getAuctionId());
        TaoBaoGoodsBrief tb = TaoKeApiUtil.searchGoodsDetail(taoBaoGoodsBrief.getAuctionId());
        if (tb == null) {
            return;
        }
 
        taoBaoGoodsBrief.setCouponLink(tb.getCouponLink());
        taoBaoGoodsBrief.setCouponActivityId(tb.getCouponActivityId());
        taoBaoGoodsBrief.setCouponAmount(tb.getCouponAmount());
        taoBaoGoodsBrief.setCouponEffectiveStartTime(tb.getCouponEffectiveStartTime());
        taoBaoGoodsBrief.setCouponEffectiveEndTime(tb.getCouponEffectiveEndTime());
        taoBaoGoodsBrief.setCouponInfo(tb.getCouponInfo());
        taoBaoGoodsBrief.setCouponLeftCount(tb.getCouponLeftCount());
        taoBaoGoodsBrief.setCouponLinkTaoToken(tb.getCouponLinkTaoToken());
        taoBaoGoodsBrief.setCouponOriLink(tb.getCouponOriLink());
        taoBaoGoodsBrief.setCouponShortLink(tb.getCouponShortLink());
        taoBaoGoodsBrief.setCouponStartFee(tb.getCouponStartFee());
        taoBaoGoodsBrief.setCouponTotalCount(tb.getCouponTotalCount());
        taoBaoGoodsBrief.setBiz30day(tb.getBiz30day());
        taoBaoGoodsBrief.setTkRate(tb.getTkRate());
        taoBaoGoodsBrief.setZkPrice(tb.getZkPrice());
        taoBaoGoodsBrief.setEventRate(tb.getEventRate());
        taoBaoGoodsBrief.setTkMktStatus(tb.getTkMktStatus());
        taoBaoGoodsBrief.setReservePrice(tb.getReservePrice());
        taoBaoGoodsBrief.setCreatetime(new Date());
 
        setGoodsBriefDefault(taoBaoGoodsBrief);
 
        taoBaoGoodsBriefMapper.updateByPrimaryKeySelective(taoBaoGoodsBrief);
 
    }
 
    @Override
    public void updateByPrimaryKeySelective(TaoBaoGoodsBrief taoBaoGoodsBrief) throws TaobaoGoodsDownException {
        setGoodsBriefDefault(taoBaoGoodsBrief);
        taoBaoGoodsBriefMapper.updateByPrimaryKeySelective(taoBaoGoodsBrief);
    }
 
    @Override
    public void setGoodsBriefDefault(TaoBaoGoodsBrief goodsBrief) {
 
        BigDecimal defaultZero = new BigDecimal("0");
 
        if (goodsBrief.getBiz30day() == null)
            goodsBrief.setBiz30day(0);
 
        if (goodsBrief.getCouponAmount() == null)
            goodsBrief.setCouponAmount(defaultZero);
 
        if (goodsBrief.getCouponLeftCount() == null)
            goodsBrief.setCouponLeftCount(0);
 
        if (goodsBrief.getCouponStartFee() == null)
            goodsBrief.setCouponStartFee(defaultZero);
 
        if (goodsBrief.getCouponTotalCount() == null)
            goodsBrief.setCouponTotalCount(0);
 
        if (goodsBrief.getDayLeft() == null)
            goodsBrief.setDayLeft(0);
 
        if (goodsBrief.getEventCreatorId() == null)
            goodsBrief.setEventCreatorId(0);
 
        if (goodsBrief.getHasRecommended() == null)
            goodsBrief.setHasRecommended(0);
 
        if (goodsBrief.getHasSame() == null)
            goodsBrief.setHasSame(0);
 
        if (goodsBrief.getIncludeDxjh() == null)
            goodsBrief.setIncludeDxjh(0);
 
        if (goodsBrief.getLeafCatId() == null)
            goodsBrief.setIncludeDxjh(0);
 
        if (goodsBrief.getReservePrice() == null)
            goodsBrief.setReservePrice(defaultZero);
 
        if (goodsBrief.getRfdRate() == null)
            goodsBrief.setRfdRate(0);
 
        if (goodsBrief.getRootCatId() == null)
            goodsBrief.setRootCatId(0);
 
        if (goodsBrief.getRootCatScore() == null)
            goodsBrief.setRootCatScore(0);
 
        if (goodsBrief.getSameItemPid() == null)
            goodsBrief.setSameItemPid(0L);
 
        if (goodsBrief.getSellerId() == null)
            goodsBrief.setSellerId(0L);
 
        if (goodsBrief.getTkCommFee() == null)
            goodsBrief.setTkCommFee(defaultZero);
 
        if (goodsBrief.getTkRate() == null)
            goodsBrief.setTkRate(defaultZero);
 
        if (goodsBrief.getTotalFee() == null)
            goodsBrief.setTotalFee(defaultZero);
 
        if (goodsBrief.getTotalNum() == null)
            goodsBrief.setTotalNum(0);
 
        if (goodsBrief.getUserType() == null)
            goodsBrief.setUserType(0);
 
        if (goodsBrief.getZkPrice() == null)
            goodsBrief.setZkPrice(defaultZero);
        
    }
 
    @Override
    public TaoBaoGoodsBrief getTaoBaoGoodsDetailForShare(Long auctionId, Long uid) throws ShareGoodsException {
        if (uid == null || uid == 0)
            throw new ShareGoodsException(201, "用户ID为空");
        if (auctionId == null || auctionId == 0)
            throw new ShareGoodsException(202, "商品ID为空");
        // 获取PID信息
        TBPid tbPid = tbPidService.getTBPid(uid, PidUser.TYPE_SHARE_GOODS);
        if (tbPid == null)
            throw new ShareGoodsException(203, "未能获取到PID");
        String appId = tbPid.getPid().split("_")[2];
        // 获取淘客媒体信息
        TaoBaoUnionConfig config = taoBaoUnionConfigService.getConfigByAppIdCache(appId);
        if (config == null)
            throw new ShareGoodsException(204, "媒体数据为空");
 
        TaoKeAppInfo taoKeAppInfo = new TaoKeAppInfo();
        taoKeAppInfo.setAdzoneId(tbPid.getPid().split("_")[3]);
        taoKeAppInfo.setAppKey(config.getAppKey());
        taoKeAppInfo.setAppSecret(config.getAppSecret());
        taoKeAppInfo.setPid(tbPid.getPid());
        TaoBaoGoodsBrief taoBaoGoodsBrief = null;
        try {
            taoBaoGoodsBrief = TaoKeApiUtil.searchGoodsDetail(auctionId, taoKeAppInfo);
        } catch (TaobaoGoodsDownException e) {
            e.printStackTrace();
        }
 
        if (taoBaoGoodsBrief == null)
            throw new ShareGoodsException(204, "商品详情数据为空");
 
        return taoBaoGoodsBrief;
    }
 
    
    @Override
    public void updateBatchSelective(List<TaoBaoGoodsBrief> list) {
         taoBaoGoodsBriefMapper.updateBatchSelective(list);
    }
    
}