|
|
@@ -1,7 +1,11 @@
|
|
|
package com.uas.platform.b2c.prod.store.service.impl;
|
|
|
|
|
|
+import com.uas.platform.b2c.advertise.ad.model.StoreAds;
|
|
|
+import com.uas.platform.b2c.advertise.ad.model.StoreAdsType;
|
|
|
+import com.uas.platform.b2c.advertise.ad.service.StoreAdsService;
|
|
|
import com.uas.platform.b2c.core.config.SysConf;
|
|
|
import com.uas.platform.b2c.core.support.SystemSession;
|
|
|
+import com.uas.platform.b2c.core.utils.JacksonUtils;
|
|
|
import com.uas.platform.b2c.core.utils.UuidUtils;
|
|
|
import com.uas.platform.b2c.prod.commodity.dao.GoodsDao;
|
|
|
import com.uas.platform.b2c.prod.product.component.dao.ComponentDao;
|
|
|
@@ -9,6 +13,7 @@ import com.uas.platform.b2c.prod.product.component.modal.Component;
|
|
|
import com.uas.platform.b2c.prod.store.dao.QualificationDao;
|
|
|
import com.uas.platform.b2c.prod.store.dao.StoreBrandInfoDao;
|
|
|
import com.uas.platform.b2c.prod.store.dao.StoreInDao;
|
|
|
+import com.uas.platform.b2c.prod.store.exception.EmptyParameterException;
|
|
|
import com.uas.platform.b2c.prod.store.model.Qualification;
|
|
|
import com.uas.platform.b2c.prod.store.model.StoreApply;
|
|
|
import com.uas.platform.b2c.prod.store.model.StoreBrandInfo;
|
|
|
@@ -71,16 +76,19 @@ public class StoreInServiceImpl implements StoreInService {
|
|
|
|
|
|
private final StoreBrandInfoDao brandInfoDao;
|
|
|
|
|
|
+ private final StoreAdsService adsService;
|
|
|
+
|
|
|
private final SysConf sysConf;
|
|
|
|
|
|
@Autowired
|
|
|
- public StoreInServiceImpl(StoreInDao storeDao, QualificationDao qualificationDao, GoodsDao goodsDao, ComponentDao componentDao, PurchaseDao purchaseDao, StoreBrandInfoDao brandInfoDao, SysConf sysConf) {
|
|
|
+ public StoreInServiceImpl(StoreInDao storeDao, QualificationDao qualificationDao, GoodsDao goodsDao, ComponentDao componentDao, PurchaseDao purchaseDao, StoreBrandInfoDao brandInfoDao, StoreAdsService adsService, SysConf sysConf) {
|
|
|
this.storeDao = storeDao;
|
|
|
this.qualificationDao = qualificationDao;
|
|
|
this.goodsDao = goodsDao;
|
|
|
this.componentDao = componentDao;
|
|
|
this.purchaseDao = purchaseDao;
|
|
|
this.brandInfoDao = brandInfoDao;
|
|
|
+ this.adsService = adsService;
|
|
|
this.sysConf = sysConf;
|
|
|
}
|
|
|
|
|
|
@@ -417,6 +425,62 @@ public class StoreInServiceImpl implements StoreInService {
|
|
|
}, pageInfo);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ public StoreIn tagStoreInWhenAdminRecommend(StoreAdsType type, StoreIn store) {
|
|
|
+ if (type == null) {
|
|
|
+ throw new EmptyParameterException("店铺广告类型不能为空");
|
|
|
+ }
|
|
|
+ if (store == null || store.getId() == null) {
|
|
|
+ throw new EmptyParameterException("待推荐店铺的ID不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ store = storeDao.findOne(store.getId());
|
|
|
+
|
|
|
+ StoreAds ads = new StoreAds();
|
|
|
+ ads.setStoreId(store.getId());
|
|
|
+ ads.setStoreType(store.getType());
|
|
|
+ ads.setType(type);
|
|
|
+
|
|
|
+ ads = adsService.saveWhenAdminRecommend(ads);
|
|
|
+
|
|
|
+ if (ads != null) {
|
|
|
+ // 为店铺打上标签
|
|
|
+ String tagsJson = StringUtils.isEmpty(store.getTags()) ? "[]" : store.getTags();
|
|
|
+ List<StoreAdsType> tags = JacksonUtils.fromJsonArray(tagsJson, StoreAdsType.class);
|
|
|
+ Set<StoreAdsType> tagSet = new HashSet<>(tags);
|
|
|
+ tagSet.add(type);
|
|
|
+ store.setTags(JacksonUtils.toJson(tagSet));
|
|
|
+
|
|
|
+ storeDao.save(store);
|
|
|
+ }
|
|
|
+ return store;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ public StoreIn cancelStoreTagsWhenAdminCancel(StoreAdsType type, StoreIn store) {
|
|
|
+ if (type == null) {
|
|
|
+ throw new EmptyParameterException("店铺广告类型不能为空");
|
|
|
+ }
|
|
|
+ if (store == null || store.getId() == null) {
|
|
|
+ throw new EmptyParameterException("待推荐店铺的ID不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ store = storeDao.findOne(store.getId());
|
|
|
+ StoreAds ads = adsService.deleteOneWhenAdminCancel(store.getId(), type);
|
|
|
+
|
|
|
+ // 为店铺打上标签
|
|
|
+ String tagsJson = StringUtils.isEmpty(store.getTags()) ? "[]" : store.getTags();
|
|
|
+ List<StoreAdsType> tags = JacksonUtils.fromJsonArray(tagsJson, StoreAdsType.class);
|
|
|
+ Set<StoreAdsType> tagSet = new HashSet<>(tags);
|
|
|
+ tagSet.remove(type);
|
|
|
+ store.setTags(JacksonUtils.toJson(tagSet));
|
|
|
+
|
|
|
+ storeDao.save(store);
|
|
|
+ return store;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public List<StoreIn> findFiveStores(String types, Integer num) {
|
|
|
String[] typeArray = types.split("-");
|