|
|
@@ -45,6 +45,8 @@ import com.ruoyi.web.modules.store.constant.ShopConstants;
|
|
45
|
45
|
import com.ruoyi.web.modules.store.domain.BizShop;
|
|
46
|
46
|
import com.ruoyi.web.modules.store.facade.IShopGlobalConfigFacade;
|
|
47
|
47
|
import com.ruoyi.web.modules.store.mapper.BizShopMapper;
|
|
|
48
|
+import com.ruoyi.web.modules.template.domain.BizGoodsAttrTemplate;
|
|
|
49
|
+import com.ruoyi.web.modules.template.mapper.BizGoodsAttrTemplateMapper;
|
|
48
|
50
|
|
|
49
|
51
|
@Service
|
|
50
|
52
|
public class GoodsServiceImpl implements IGoodsService
|
|
|
@@ -82,6 +84,9 @@ public class GoodsServiceImpl implements IGoodsService
|
|
82
|
84
|
@Autowired
|
|
83
|
85
|
private IGoodsOrderFacade goodsOrderFacade;
|
|
84
|
86
|
|
|
|
87
|
+ @Autowired
|
|
|
88
|
+ private BizGoodsAttrTemplateMapper attrTemplateMapper;
|
|
|
89
|
+
|
|
85
|
90
|
@Override
|
|
86
|
91
|
public List<GoodsListVO> selectPlatformList(BizGoods query)
|
|
87
|
92
|
{
|
|
|
@@ -135,6 +140,7 @@ public class GoodsServiceImpl implements IGoodsService
|
|
135
|
140
|
validateSaveFields(dto, true);
|
|
136
|
141
|
assertPlatformCategoryLevel2(dto.getCategoryId());
|
|
137
|
142
|
assertShopCategoryIfPresent(shopId, dto.getShopCategoryId());
|
|
|
143
|
+ assertAttrTemplateIfPresent(shopId, dto.getAttrTemplateId());
|
|
138
|
144
|
BizGoods goods = buildGoodsFromDto(dto);
|
|
139
|
145
|
goods.setShopId(shopId);
|
|
140
|
146
|
goods.setGoodsSn(goodsSnGenerator.nextSn());
|
|
|
@@ -164,6 +170,7 @@ public class GoodsServiceImpl implements IGoodsService
|
|
164
|
170
|
assertPlatformCategoryLevel2(dto.getCategoryId());
|
|
165
|
171
|
}
|
|
166
|
172
|
assertShopCategoryIfPresent(shopId, dto.getShopCategoryId());
|
|
|
173
|
+ assertAttrTemplateIfPresent(shopId, dto.getAttrTemplateId());
|
|
167
|
174
|
BizGoods update = buildGoodsFromDto(dto);
|
|
168
|
175
|
update.setGoodsId(dto.getGoodsId());
|
|
169
|
176
|
update.setUpdateBy(operator);
|
|
|
@@ -403,6 +410,7 @@ public class GoodsServiceImpl implements IGoodsService
|
|
403
|
410
|
vo.setShopId(goods.getShopId());
|
|
404
|
411
|
vo.setCategoryId(goods.getCategoryId());
|
|
405
|
412
|
vo.setShopCategoryId(goods.getShopCategoryId());
|
|
|
413
|
+ vo.setAttrTemplateId(goods.getAttrTemplateId());
|
|
406
|
414
|
vo.setGoodsSn(goods.getGoodsSn());
|
|
407
|
415
|
vo.setGoodsName(goods.getGoodsName());
|
|
408
|
416
|
vo.setMainPic(goods.getMainPic());
|
|
|
@@ -421,6 +429,14 @@ public class GoodsServiceImpl implements IGoodsService
|
|
421
|
429
|
{
|
|
422
|
430
|
vo.setShopCategoryPath(categoryFacade.getCategoryPath(goods.getShopCategoryId()));
|
|
423
|
431
|
}
|
|
|
432
|
+ if (goods.getAttrTemplateId() != null)
|
|
|
433
|
+ {
|
|
|
434
|
+ BizGoodsAttrTemplate template = attrTemplateMapper.selectById(goods.getAttrTemplateId(), goods.getShopId());
|
|
|
435
|
+ if (template != null)
|
|
|
436
|
+ {
|
|
|
437
|
+ vo.setAttrTemplateName(template.getTemplateName());
|
|
|
438
|
+ }
|
|
|
439
|
+ }
|
|
424
|
440
|
vo.setCanAudit(GoodsConstants.STATUS_PENDING.equals(goods.getGoodsStatus()));
|
|
425
|
441
|
vo.setCanOffShelf(GoodsConstants.STATUS_ON_SALE.equals(goods.getGoodsStatus()));
|
|
426
|
442
|
vo.setCanSubmit(canSubmitStatus(goods.getGoodsStatus()));
|
|
|
@@ -513,6 +529,7 @@ public class GoodsServiceImpl implements IGoodsService
|
|
513
|
529
|
BizGoods goods = new BizGoods();
|
|
514
|
530
|
goods.setCategoryId(dto.getCategoryId());
|
|
515
|
531
|
goods.setShopCategoryId(dto.getShopCategoryId());
|
|
|
532
|
+ goods.setAttrTemplateId(dto.getAttrTemplateId());
|
|
516
|
533
|
goods.setGoodsName(dto.getGoodsName());
|
|
517
|
534
|
goods.setMainPic(dto.getMainPic());
|
|
518
|
535
|
goods.setDetailContent(dto.getDetailContent());
|
|
|
@@ -589,6 +606,19 @@ public class GoodsServiceImpl implements IGoodsService
|
|
589
|
606
|
}
|
|
590
|
607
|
}
|
|
591
|
608
|
|
|
|
609
|
+ private void assertAttrTemplateIfPresent(Long shopId, Long attrTemplateId)
|
|
|
610
|
+ {
|
|
|
611
|
+ if (attrTemplateId == null)
|
|
|
612
|
+ {
|
|
|
613
|
+ return;
|
|
|
614
|
+ }
|
|
|
615
|
+ BizGoodsAttrTemplate template = attrTemplateMapper.selectById(attrTemplateId, shopId);
|
|
|
616
|
+ if (template == null)
|
|
|
617
|
+ {
|
|
|
618
|
+ throw new ServiceException(GoodsConstants.MSG_ATTR_TEMPLATE_INVALID);
|
|
|
619
|
+ }
|
|
|
620
|
+ }
|
|
|
621
|
+
|
|
592
|
622
|
private boolean canSubmitStatus(String status)
|
|
593
|
623
|
{
|
|
594
|
624
|
return GoodsConstants.STATUS_DRAFT.equals(status)
|