wzy
2022-10-12 4615437af0749766f519c10734e19360b0877ece
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
package com.matrix.system.hive.service.imp;
 
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import com.matrix.core.constance.MatrixConstance;
import com.matrix.core.exception.GlobleException;
import com.matrix.core.pojo.PaginationVO;
import com.matrix.core.tools.DateUtil;
import com.matrix.core.tools.StringUtils;
import com.matrix.core.tools.WebUtil;
import com.matrix.system.app.dto.ShoppingGoodsListDto;
import com.matrix.system.app.vo.ShoppingGoodsDetailVo;
import com.matrix.system.app.vo.ShoppingGoodsListVo;
import com.matrix.system.common.bean.SysUsers;
import com.matrix.system.common.dao.UtilDao;
import com.matrix.system.common.tools.ServiceUtil;
import com.matrix.system.constance.Dictionary;
import com.matrix.system.constance.TableMapping;
import com.matrix.system.hive.bean.ShoppingGoods;
import com.matrix.system.hive.bean.ShoppingGoodsAssemble;
import com.matrix.system.hive.bean.ShoppingGoodsCategory;
import com.matrix.system.hive.bean.SysShopInfo;
import com.matrix.system.hive.dao.MoneyCardAssembleDao;
import com.matrix.system.hive.dao.ShoppingGoodsAssembleDao;
import com.matrix.system.hive.dao.ShoppingGoodsDao;
import com.matrix.system.hive.dao.SysShopInfoDao;
import com.matrix.system.hive.service.ShoppingGoodsService;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
 
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
 
 
/**
 * @date 2016-07-30 09:54
 */
@Service("shoppingGoodsService")
public class ShoppingGoodsServiceImpl implements ShoppingGoodsService {
 
    @Autowired
    private ShoppingGoodsDao shoppingGoodsDao;
    @Autowired
    private MoneyCardAssembleDao moneyCardAssembleDao;
 
    @Autowired
    private ShoppingGoodsAssembleDao shoppingGoodsAssembleDao;
    @Autowired
    private UtilDao utilDao;
 
    @Autowired
    private ServiceUtil serviceUtil;
 
    @Autowired
    private SysShopInfoDao shopInfoDao;
 
 
 
    @Override
    @Transactional(rollbackFor = Exception.class)
    public int add(ShoppingGoods shoppingGoods) {
        SysUsers sysUsers = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY);
        SysShopInfo shopInfo = shopInfoDao.selectById(sysUsers.getShopId());
 
 
        if(shopInfo.getShopType()==SysShopInfo.SHOP_TYPE_ZONGBU){
            shoppingGoods.setHeadquarters(1);
        }else{
            shoppingGoods.setHeadquarters(2);
        }
 
        shoppingGoods.setShopId(sysUsers.getShopId());
 
        //去重查询
        ShoppingGoods queryGoods=new ShoppingGoods();
        queryGoods.setCompanyId(shoppingGoods.getCompanyId());
        queryGoods.setCode(shoppingGoods.getCode());
        queryGoods.setIsDel(ShoppingGoods.NORMAL);
        List<ShoppingGoods>  oldGoods=shoppingGoodsDao.selectByModel(queryGoods);
        if(CollUtil.isNotEmpty(oldGoods)){
            throw new GlobleException("编号" + shoppingGoods.getCode() + "重复");
        }
 
 
        if (shoppingGoods.getRealSealCount() == null) {
            shoppingGoods.setRealSealCount(0);
        }
 
        shoppingGoods.setCreateTime(new Date());
        setPublicAttr(shoppingGoods);
 
        setShoppingGoodsInvalidTime(shoppingGoods);
 
        if (shoppingGoods.getReferencePice() == null) {
            //赠送金额
            shoppingGoods.setReferencePice(0D);
        }
        // 验证套餐卡卡必须填写最大使用次数
        if (Dictionary.FLAG_YES_Y.equals(shoppingGoods.getIsCourse()) && Dictionary.FLAG_NO_N.equals(shoppingGoods.getIsInfinite())) {
            if (shoppingGoods.getCarUseCount() == null) {
                shoppingGoods.setCarUseCount(0);
            }
        }
 
        if (shoppingGoods.getReferencePice() == null) {
            shoppingGoods.setReferencePice(0d);
        }
        shoppingGoods.setZjm(StringUtils.toHanyuPinyin(shoppingGoods.getName())+","+StringUtils.toHeadWordHanyuPinyin(shoppingGoods.getName()));
        shoppingGoods.setIsDel(ShoppingGoods.NORMAL);
        //新增销售产品
        int i = shoppingGoodsDao.insert(shoppingGoods);
 
        if (ShoppingGoods.SHOPPING_GOODS_TYPE_CZK.equals(shoppingGoods.getGoodType())) {
            setCardAssemble(shoppingGoods);
        } else {
            setGoodsAssembles(shoppingGoods);
        }
 
 
 
        return i;
    }
 
    private void setShoppingGoodsInvalidTime(ShoppingGoods shoppingGoods) {
        // 若未设置购买有效期和消耗有效期,则默认永久有效
//        if (shoppingGoods.getBuyDateNum() == null && shoppingGoods.getUseDateNum() == null) {
//            shoppingGoods.setInvalidTime(DateUtil.stringToDate("2099-12-31", DateUtil.DATE_FORMAT_DD));
//        } else {
//            // 计算失效日期,判断购买有效期和消耗有效期哪个先失效,则为失效日期
//            Date buyValidDate = DateUtil.calDate(shoppingGoods.getBuyDateNum(), shoppingGoods.getBuyDateUnit());
//            Date useValidDate = DateUtil.calDate(shoppingGoods.getUseDateNum(), shoppingGoods.getUseDateUnit());
//            if (buyValidDate.after(useValidDate)) {
//                shoppingGoods.setInvalidTime(useValidDate);
//            } else {
//                shoppingGoods.setInvalidTime(buyValidDate);
//            }
//            shoppingGoods.setBuyValid(shoppingGoods.getBuyDateNum() + shoppingGoods.getBuyDateUnit());
//            shoppingGoods.setUseValid(shoppingGoods.getUseDateNum() + shoppingGoods.getUseDateUnit());
//        }
 
        if (shoppingGoods.getBuyDateNum() != null && StringUtils.isNotBlank(shoppingGoods.getBuyDateUnit())) {
            shoppingGoods.setBuyValid(shoppingGoods.getBuyDateNum() + shoppingGoods.getBuyDateUnit());
        } else {
            shoppingGoods.setBuyValid(null);
        }
 
        if (shoppingGoods.getUseDateNum() != null && StringUtils.isNotBlank(shoppingGoods.getUseDateUnit())) {
            shoppingGoods.setUseValid(shoppingGoods.getUseDateNum() + shoppingGoods.getUseDateUnit());
        } else {
            shoppingGoods.setUseValid(null);
        }
    }
 
    private void setGoodsAssembles(ShoppingGoods shoppingGoods) {
        //先清空原有关系,在新增
        shoppingGoodsAssembleDao.deleteByGoodsId(shoppingGoods.getId());
        List<ShoppingGoodsAssemble> assembles = new ArrayList<>();
        if (CollectionUtils.isNotEmpty(shoppingGoods.getAssembleGoods())) {
            assembles.addAll(shoppingGoods.getAssembleGoods());
        }
        if (CollectionUtils.isNotEmpty(shoppingGoods.getAssembleProj())) {
            assembles.addAll(shoppingGoods.getAssembleProj());
        }
        if (CollectionUtils.isNotEmpty(assembles)) {
            assembles.forEach(item -> item.setShoppingGoodsId(shoppingGoods.getId()));
            shoppingGoodsAssembleDao.batchInsert(assembles);
        }
    }
 
    /**
     * 设置充值卡,绑定的消费产品
     *
     * @param cardGoods
     * @author jiangyouyao
     */
    private void setCardAssemble(ShoppingGoods cardGoods) {
        moneyCardAssembleDao.deleteByCardId(cardGoods.getId());
        if (CollectionUtils.isNotEmpty(cardGoods.getCardAssembles())) {
            cardGoods.getCardAssembles().forEach(item -> item.setCardId(cardGoods.getId()));
            moneyCardAssembleDao.batchInsert(cardGoods.getCardAssembles());
        }
    }
 
    @Transactional(rollbackFor = Exception.class)
    @Override
    public int modify(ShoppingGoods shoppingGoods) {
        ShoppingGoods checkShoppingGoods = shoppingGoodsDao.selectById(shoppingGoods.getId());
 
        // 校验去重
        if (serviceUtil.updateCheckRepeatTowColumn("shopping_goods",
                "code", shoppingGoods.getCode(),
                "company_id", checkShoppingGoods.getCompanyId(), "id", shoppingGoods.getId())) {
            throw new GlobleException("编号" + shoppingGoods.getCode() + "重复");
        }
 
 
        // 验证套餐卡卡必须填写最大使用次数
        if (Dictionary.FLAG_YES_Y.equals(shoppingGoods.getIsCourse())) {
            if (shoppingGoods.getCarUseCount() == null) {
                throw new GlobleException("套餐卡必须填写最大使用次数!");
            }
        }
 
        if (ShoppingGoods.SHOPPING_GOODS_TYPE_CZK.equals(shoppingGoods.getGoodType())) {
            setCardAssemble(shoppingGoods);
        }else{
 
            //清除原有绑定关系
            shoppingGoodsAssembleDao.deleteByGoodsId(shoppingGoods.getId());
            //合并绑定的产品和项目
            List<ShoppingGoodsAssemble> assembles = new ArrayList<>();
            if(CollectionUtils.isNotEmpty(shoppingGoods.getAssembleGoods())){
                assembles.addAll(shoppingGoods.getAssembleGoods());
            }
            //如果是套餐叠加套餐绑定的项目部分
            if (Dictionary.SHOPPING_GOODS_TYPE_TC.equals(shoppingGoods.getGoodType())){
                assembles.addAll(shoppingGoods.getAssembleProj());
            }
 
            if (CollectionUtils.isNotEmpty(assembles)) {
                assembles.forEach(item -> item.setShoppingGoodsId(shoppingGoods.getId()));
                shoppingGoodsAssembleDao.batchInsert(assembles);
            }
 
        }
        setShoppingGoodsInvalidTime(shoppingGoods);
 
        return shoppingGoodsDao.update(shoppingGoods);
 
    }
 
    @Override
    public int update(Long id) {
        return shoppingGoodsDao.update2(id);
 
    }
 
    @Override
    @Transactional(rollbackFor = Exception.class)
    public int remove(List<Long> list) {
        SysUsers user = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY);
        SysShopInfo zbShop = shopInfoDao.selectZbShop(user.getCompanyId());
        //非总部员工只能删除自己门店的产品
        if(user.getShopId()!=zbShop.getId()){
            //校验是否可以删除
            List<ShoppingGoods> dataList = shoppingGoodsDao.selectByIds(list);
            List<ShoppingGoods> collect = dataList.stream().filter(goods -> !Objects.equals(user.getShopId(), goods.getShopId())).collect(Collectors.toList());
            if(CollUtil.isNotEmpty(collect)){
                throw new GlobleException("非总部员工只能删除自己门店的产品");
            }
        }
        return shoppingGoodsDao.deleteByIds(list);
 
    }
 
    @Override
    @Transactional(rollbackFor = Exception.class)
    public int removeById(Long id) {
        return shoppingGoodsDao.deleteById(id);
 
    }
 
    @Override
    public List<ShoppingGoods> findInPage(ShoppingGoods shoppingGoods, PaginationVO pageVo) {
 
        return shoppingGoodsDao.selectInPage(shoppingGoods, pageVo);
 
    }
 
    @Override
    public List<ShoppingGoods> findAll(ShoppingGoods shoppingGoods) {
 
        return shoppingGoodsDao.selectAll(shoppingGoods);
 
    }
 
    @Override
    public ShoppingGoods findByCode(String goodsCode) {
        return shoppingGoodsDao.findByCode(goodsCode);
    }
 
    @Override
    public List<ShoppingGoods> findByModel(ShoppingGoods shoppingGoods) {
 
        return shoppingGoodsDao.selectByModel(shoppingGoods);
 
    }
 
    @Override
    public int findTotal(ShoppingGoods shoppingGoods) {
 
        return shoppingGoodsDao.selectTotalRecord(shoppingGoods);
 
    }
 
    @Override
    public ShoppingGoods findById(Long id) {
 
        return shoppingGoodsDao.selectById(id);
 
    }
 
 
    public void updateAassembel(List<ShoppingGoodsAssemble> list, Long id, List<ShoppingGoodsAssemble> checkList,
                                boolean isUpdate) {
        String ids = ",";
        if (list != null) {
            for (ShoppingGoodsAssemble asseble : list) {
                if (asseble.getTotal() == null && asseble.getPrice() == null) {
                    continue;
                }
                if (asseble.getId() == null) {
//                    if (!isUpdate) {
//                        throw new GlobleException("该商品已产生订单,不能再增删绑定信息!");
//                    }
                    // 设置商品id
                    asseble.setShoppingGoodsId(id);
                    shoppingGoodsAssembleDao.insert(asseble);
                } else {
                    ids = ids + asseble.getId() + ",";
                    shoppingGoodsAssembleDao.update(asseble);
                }
            }
        }
 
        for (ShoppingGoodsAssemble asseble : checkList) {
            if (ids.length() > 1) {
                if (!ids.contains("," + asseble.getId() + ",")) {
                    if (!isUpdate) {
                        throw new GlobleException("该商品已产生订单,不能再删除绑定信息!");
                    }
                    shoppingGoodsAssembleDao.deleteById(asseble.getId());
                }
            } else {
                //如果原产品已经被删除了则清除绑定关系
                shoppingGoodsAssembleDao.deleteById(asseble.getId());
            }
        }
    }
 
    /**
     * 设置公共的属性,设置isAssemble属性,如果goodType='项目'则绑定价=售价,数量为1,为非组合商品,没有图片给一张默认的图片地址
     *
     * @param shoppingGoods
     */
    public void setPublicAttr(ShoppingGoods shoppingGoods) {
        // 设置默认图片
        setDefaultImg(shoppingGoods);
        // 不同类型设置不同的默认的属性
        String type = shoppingGoods.getGoodType();
        switch (type) {
            case Dictionary.SHOPPING_GOODS_TYPE_JJCP:
                shoppingGoods.setIsAssemble(Dictionary.FLAG_NO);
                break;
            case Dictionary.SHOPPING_GOODS_TYPE_XM:
                // 如果是项目的话绑定价和售价一样,且数量默认为1
                shoppingGoods.setIsAssemble(Dictionary.FLAG_NO);
                break;
            case Dictionary.SHOPPING_GOODS_TYPE_TC:
                shoppingGoods.setIsAssemble(Dictionary.FLAG_YES);
                break;
            case Dictionary.SHOPPING_GOODS_TYPE_ZHK:
                shoppingGoods.setIsAssemble(Dictionary.FLAG_YES);
                break;
        }
    }
 
    /**
     * 商城商品这是一张默认图片
     *
     * @param shoppingGoods
     */
    public void setDefaultImg(ShoppingGoods shoppingGoods) {
        // 如果没有图片则给一张默认图片
        String img = shoppingGoods.getImg();
        if (img == null || img.equals("")) {
            shoppingGoods.setImg(Dictionary.DEFAULT_IMG);
        }
        if (shoppingGoods.getWeiImg() == null || shoppingGoods.getWeiImg().equals("")) {
            shoppingGoods.setWeiImg(Dictionary.DEFAULT_IMG);
        }
    }
 
 
 
    /**
     * 检测是否能更新 @Title: checkIsUpdate  @author:jyy @return boolean
     * 返回类型 @date 2016年9月18日 上午10:06:23 @throws
     */
    @Override
    public boolean checkIsUpdate(Long id) {
        ShoppingGoods goods = shoppingGoodsDao.selectById(id);
 
        /*
         * if (goods.getGoodType().equals(Dictionary.GOODS_ATTR_HOME)) { for
         * (ShoppingGoodsAssemble assemble : goods.getAssembleGoods()) { if
         * (utilDao.selectCount(TableMapping.SHOPPING_ORDER_ITEM, "goods_id",
         * assemble.getId() + "") > 0) { return false; } } } else
         */
        if (utilDao.selectCount(TableMapping.SHOPPING_ORDER_ITEM, "goods_id", goods.getId() + "") > 0) {
            return false;
        }
        if (utilDao.selectCount(TableMapping.SYS_ORDER_ITEM, "goods_id", goods.getId() + "") > 0) {
            return false;
        }
        return true;
    }
 
    /**
     *
     */
    @Override
    public List<ShoppingGoods> findInPageNoTaocan(ShoppingGoods shoppingGoods, PaginationVO pageVo) {
        return shoppingGoodsDao.selectInPageNoTaocan(shoppingGoods);
    }
 
    /**
     *
     */
    @Override
    public int findTotalNoTaocan(ShoppingGoods shoppingGoods) {
        return shoppingGoodsDao.selectTotalNoTaocan(shoppingGoods);
    }
 
    /**
     * 数据迁移专用查找,数据迁移专用查找返回简单对象
     */
    @Override
    public List<ShoppingGoods> findByModelData(ShoppingGoods shoppingGoods) {
 
        return shoppingGoodsDao.selectByModelData(shoppingGoods);
    }
 
    /**
     * 计算失效时间
     *
     * @param shoppingGoods
     * @param type 1 - 购买时  2 - 消耗时
     * @param buyDate 购买日期, 当计算消耗日期时,不能为空
     * @return
     */
    @Override
    public Date calInvalidTime(ShoppingGoods shoppingGoods, @NotNull Integer type, Date buyDate) {
        if (StringUtils.isBlank(shoppingGoods.getBuyValid()) && StringUtils.isBlank(shoppingGoods.getUseValid()) && shoppingGoods.getInvalidTime() == null) {
            return DateUtil.stringToDate("2099-12-31", DateUtil.DATE_FORMAT_DD);
        }
 
        if (type == 2 && shoppingGoods.getUseDateNum() == null && StringUtils.isNotBlank(shoppingGoods.getBuyDateUnit())) {
            return DateUtil.stringToDate("2099-12-31", DateUtil.DATE_FORMAT_DD);
        }
 
        if (type == 2 && buyDate == null) {
            throw new GlobleException("购买日期不能为空");
        }
 
        Date target = null;
        Date buyValidDate = null;
        if (type == 1 && StrUtil.isNotBlank(shoppingGoods.getBuyValid())) {
            buyValidDate = DateUtil.stringToDate(shoppingGoods.getBuyValid(), "yyyy-MM-dd");
        } else {
            buyValidDate = buyDate;
        }
 
        Date useValidDate = DateUtil.stringToDate("2099-12-31", DateUtil.DATE_FORMAT_DD);
        if (type == 2 && StrUtil.isNotBlank(shoppingGoods.getUseValid())) {
            useValidDate = DateUtil.stringToDate(shoppingGoods.getUseValid(), "yyyy-MM-dd");
        }
 
        if (buyValidDate != null) {
            if (buyValidDate.after(useValidDate)) {
                target = useValidDate;
            } else {
                target = buyValidDate;
            }
        }
 
        if (shoppingGoods.getInvalidTime() != null) {
            if (target != null) {
                if (target.after(shoppingGoods.getInvalidTime())) {
                    target = shoppingGoods.getInvalidTime();
                }
            } else {
                target = shoppingGoods.getInvalidTime();
            }
        }
        return target;
    }
 
 
    @Override
    public List<ShoppingGoodsListVo> findShoppingGoodsListForApi(ShoppingGoodsListDto shoppingGoodsListDto) {
        SysUsers user = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY);
        shoppingGoodsListDto.setShopId(user.getShopId());
        PaginationVO pageVo = new PaginationVO();
        int offset = (shoppingGoodsListDto.getPageNum() - 1) * shoppingGoodsListDto.getPageSize();
        int limit = shoppingGoodsListDto.getPageSize();
        pageVo.setOffset(offset);
        pageVo.setLimit(limit);
        return shoppingGoodsDao.selectShoppingGoodsApiInPage(shoppingGoodsListDto, pageVo);
    }
 
    @Override
    public int findShoppingGoodsListTotalForApi(ShoppingGoodsListDto shoppingGoodsListDto) {
        SysUsers user = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY);
        shoppingGoodsListDto.setShopId(user.getShopId());
 
        return shoppingGoodsDao.selectShopppingGoodsAipTotal(shoppingGoodsListDto);
    }
 
    @Override
    public ShoppingGoodsDetailVo findApiShoppingGoodsDetailById(Long id) {
        ShoppingGoods shoppingGoods = shoppingGoodsDao.selectById(id);
        ShoppingGoodsDetailVo goodsDetailVo = goodsToGoodsDetailVo(shoppingGoods);
 
        if (ShoppingGoods.SHOPPING_GOODS_TYPE_TC.equals(shoppingGoods.getGoodType())) {
            List<ShoppingGoodsDetailVo> products = shoppingGoodsAssembleDao.selectGoodsRelationGoodsList(shoppingGoods.getId(), ShoppingGoods.SHOPPING_GOODS_TYPE_JJCP);
            List<ShoppingGoodsDetailVo> proj = shoppingGoodsAssembleDao.selectGoodsRelationGoodsList(shoppingGoods.getId(), ShoppingGoods.SHOPPING_GOODS_TYPE_XM);
 
            goodsDetailVo.setAssembleTaocanProduct(products);
            goodsDetailVo.setAssembleTaocanProj(proj);
        } else if (ShoppingGoods.SHOPPING_GOODS_TYPE_XM.equals(shoppingGoods.getGoodType())) {
            List<ShoppingGoodsDetailVo> products = shoppingGoodsAssembleDao.selectGoodsRelationGoodsList(shoppingGoods.getId(), null);
            goodsDetailVo.setAssembleProj(products);
        } else if (ShoppingGoods.SHOPPING_GOODS_TYPE_CZK.equals(shoppingGoods.getGoodType())) {
            List<ShoppingGoodsDetailVo> cardGoods = moneyCardAssembleDao.selectCardRelationGoods(shoppingGoods.getId());
            List<ShoppingGoodsCategory> cardCategory = moneyCardAssembleDao.selectCardRelationCategory(shoppingGoods.getId());
 
            goodsDetailVo.setAssembleProj(cardGoods);
            goodsDetailVo.setCardCategory(cardCategory);
        }
        return goodsDetailVo;
    }
 
    private ShoppingGoodsDetailVo goodsToGoodsDetailVo(ShoppingGoods shoppingGoods) {
        ShoppingGoodsDetailVo goodsDetailVo = new ShoppingGoodsDetailVo();
        goodsDetailVo.setImg(shoppingGoods.getImg());
        goodsDetailVo.setGoodsName(shoppingGoods.getName());
        goodsDetailVo.setGoodsNo(shoppingGoods.getCode());
        goodsDetailVo.setGoodsType(shoppingGoods.getGoodType());
        goodsDetailVo.setDesc(shoppingGoods.getDescription());
        goodsDetailVo.setMaxSaleCnt(shoppingGoods.getCarMaxSaleCount());
        goodsDetailVo.setLimitBuyCnt(shoppingGoods.getIsOnce());
        goodsDetailVo.setMaxUseCnt(shoppingGoods.getCarUseCount());
        goodsDetailVo.setMeasure(shoppingGoods.getMeasure());
        goodsDetailVo.setVolume(shoppingGoods.getVolume());
        goodsDetailVo.setSalePrice(BigDecimal.valueOf(shoppingGoods.getSealPice()));
        goodsDetailVo.setSaleCnt(shoppingGoods.getRealSealCount());
        goodsDetailVo.setGiftPrice(BigDecimal.valueOf(shoppingGoods.getReferencePice() == null ? 0 : shoppingGoods.getReferencePice()));
        return goodsDetailVo;
    }
}