|
@@ -6,10 +6,7 @@ import com.caimei365.user.components.RedisService;
|
|
|
import com.caimei365.user.feign.CommodityFeign;
|
|
|
import com.caimei365.user.mapper.*;
|
|
|
import com.caimei365.user.model.ResponseJson;
|
|
|
-import com.caimei365.user.model.dto.BaikeProductDto;
|
|
|
-import com.caimei365.user.model.dto.ShopArticleDto;
|
|
|
-import com.caimei365.user.model.dto.ShopBannerDto;
|
|
|
-import com.caimei365.user.model.dto.ShopUpdateDto;
|
|
|
+import com.caimei365.user.model.dto.*;
|
|
|
import com.caimei365.user.model.po.*;
|
|
|
import com.caimei365.user.model.vo.*;
|
|
|
import com.caimei365.user.service.ShopService;
|
|
@@ -36,6 +33,8 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|
|
import java.util.stream.Collectors;
|
|
|
import java.util.stream.Stream;
|
|
|
|
|
|
+import static com.alibaba.fastjson.JSON.parseObject;
|
|
|
+
|
|
|
/**
|
|
|
* Description
|
|
|
*
|
|
@@ -326,6 +325,12 @@ public class ShopServiceImpl implements ShopService {
|
|
|
if (null != taxLicense && taxLicense.size() > 0) {
|
|
|
supplier.setMedicalPracticeLicenseImg3(taxLicense.get(0));
|
|
|
}
|
|
|
+ // banner
|
|
|
+ List<ShopBannerVo> shopHomeImages = shopMapper.getShopHomeImages(shopId, null);
|
|
|
+ supplier.setShopHomeImages(shopHomeImages);
|
|
|
+ // 商品类别
|
|
|
+ List<CmShopCategoryVo> shopCategory = shopMapper.getShopCategory(shopId, null);
|
|
|
+ supplier.setShopCategory(shopCategory);
|
|
|
return ResponseJson.success(supplier);
|
|
|
}
|
|
|
|
|
@@ -349,14 +354,13 @@ public class ShopServiceImpl implements ShopService {
|
|
|
/**
|
|
|
* 一键排序
|
|
|
*
|
|
|
- * @param cmShopCategoryList
|
|
|
+ * @param id
|
|
|
+ * @param sort
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
- public ResponseJson renewShopCategory(List<CmShopCategoryVo> cmShopCategoryList) {
|
|
|
- cmShopCategoryList.forEach(category -> {
|
|
|
- shopMapper.updateCategorySort(category);
|
|
|
- });
|
|
|
+ public ResponseJson renewShopCategory(Integer id, Integer sort) {
|
|
|
+ shopMapper.updateCategorySort(id, sort);
|
|
|
return ResponseJson.success();
|
|
|
}
|
|
|
|
|
@@ -367,34 +371,43 @@ public class ShopServiceImpl implements ShopService {
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
- public ResponseJson<Map<String, Object>> echoShopCategory(Integer id) {
|
|
|
- Map<String, Object> map = new HashMap<>();
|
|
|
+ public ResponseJson<CmShopCategoryVo> echoShopCategory(Integer id) {
|
|
|
CmShopCategoryVo shopCategoryById = shopMapper.getShopCategoryById(id);
|
|
|
- map.put("category", shopCategoryById);
|
|
|
- List<CmShopCategoryProductVo> categoryProductList = shopMapper.getCategoryProductById(id);
|
|
|
+ List<ProductItemVo> categoryProductList = shopMapper.getCategoryProductById(id);
|
|
|
categoryProductList.forEach(product -> {
|
|
|
- product.setMallImage(ImageUtils.getImageURL("product", product.getMallImage(), 0 , wwwDomain));
|
|
|
+ product.setImage(ImageUtils.getImageURL("product", product.getImage(), 0 , wwwDomain));
|
|
|
});
|
|
|
- map.put("categorProduct", categoryProductList);
|
|
|
- return ResponseJson.success(map);
|
|
|
+ shopCategoryById.setProducts(categoryProductList);
|
|
|
+ return ResponseJson.success(shopCategoryById);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 选择商品
|
|
|
*
|
|
|
* @param shopId
|
|
|
+ * @param categoryId
|
|
|
* @param name
|
|
|
* @param pageNum
|
|
|
* @param pageSize
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
- public ResponseJson<PaginationVo<ProductItemVo>> getShopProductList(Integer shopId, String name, int pageNum, int pageSize) {
|
|
|
+ public ResponseJson<PaginationVo<ProductItemVo>> getShopProductList(Integer shopId, Integer categoryId, String name, int pageNum, int pageSize) {
|
|
|
PageHelper.startPage(pageNum, pageSize);
|
|
|
List<ProductItemVo> shopProductList = shopMapper.getShopProductList(shopId, name);
|
|
|
- shopProductList.forEach(product -> {
|
|
|
+ // 供应商已选择商品, 同类别不可重复选择
|
|
|
+ List<Integer> categoryProductIdList = new ArrayList<>();
|
|
|
+ if (null != categoryId) {
|
|
|
+ categoryProductIdList = shopMapper.getCategoryProductIdList(shopId, categoryId);
|
|
|
+ }
|
|
|
+ for (ProductItemVo product : shopProductList) {
|
|
|
product.setImage(ImageUtils.getImageURL("product", product.getImage(), 0 , wwwDomain));
|
|
|
- });
|
|
|
+ if (null != categoryProductIdList && categoryProductIdList.contains(product.getProductId())) {
|
|
|
+ product.setFlag(false);
|
|
|
+ } else {
|
|
|
+ product.setFlag(true);
|
|
|
+ }
|
|
|
+ }
|
|
|
PaginationVo<ProductItemVo> page = new PaginationVo<>(shopProductList);
|
|
|
return ResponseJson.success(page);
|
|
|
}
|
|
@@ -402,44 +415,74 @@ public class ShopServiceImpl implements ShopService {
|
|
|
/**
|
|
|
* 保存商品类别
|
|
|
*
|
|
|
- * @param category
|
|
|
+ * @param jsonParamsDto
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
- public ResponseJson saveShopCategory(CmShopCategoryVo category) {
|
|
|
- if(null == category.getId()) {
|
|
|
- // 新增
|
|
|
- shopMapper.insertCategory(category);
|
|
|
- } else {
|
|
|
- // 修改
|
|
|
- shopMapper.updateCategory(category);
|
|
|
- }
|
|
|
- Integer categoryId = category.getId();
|
|
|
- if (StringUtils.isNotBlank(category.getProductIds())) {
|
|
|
- // 处理类别商品
|
|
|
- List<Integer> productIdList = new ArrayList<>();
|
|
|
- // 该类别下所有商品
|
|
|
- List<Integer> categoryProductIds = shopMapper.getCategoryProductIds(categoryId);
|
|
|
- if (category.getProductIds().contains(",")) {
|
|
|
- String[] productIds = category.getProductIds().split(",");
|
|
|
- for (String productId : productIds) {
|
|
|
- int proId = Integer.parseInt(productId);
|
|
|
+ public ResponseJson saveShopCategory(JsonParamsDto jsonParamsDto) {
|
|
|
+ try {
|
|
|
+ // 处理json数据
|
|
|
+ JSONObject jsonObject = parseObject(jsonParamsDto.getParams());
|
|
|
+ Integer id = jsonObject.getInteger("id");
|
|
|
+ Integer shopId = jsonObject.getInteger("shopId");
|
|
|
+ String category = jsonObject.getString("category");
|
|
|
+ Integer sort = jsonObject.getInteger("sort");
|
|
|
+ String productIds = jsonObject.getString("productIds");
|
|
|
+ if (null == shopId) {
|
|
|
+ return ResponseJson.error(-1, "供应商Id不能为空", null);
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(category) || StringUtils.isEmpty(category)) {
|
|
|
+ return ResponseJson.error(-1, "类别名称不能为空", null);
|
|
|
+ }
|
|
|
+ if (null == sort) {
|
|
|
+ return ResponseJson.error(-1, "类别排序不能为空", null);
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(productIds) || StringUtils.isEmpty(productIds)) {
|
|
|
+ return ResponseJson.error(-1, "商品不能为空", null);
|
|
|
+ }
|
|
|
+ CmShopCategoryVo cmShopCategoryVo = new CmShopCategoryVo();
|
|
|
+ cmShopCategoryVo.setId(id);
|
|
|
+ cmShopCategoryVo.setShopId(shopId);
|
|
|
+ cmShopCategoryVo.setCategory(category);
|
|
|
+ cmShopCategoryVo.setSort(sort);
|
|
|
+ cmShopCategoryVo.setProductIds(productIds);
|
|
|
+ if(null == id) {
|
|
|
+ // 新增
|
|
|
+ shopMapper.insertCategory(cmShopCategoryVo);
|
|
|
+ } else {
|
|
|
+ // 修改
|
|
|
+ shopMapper.updateCategory(cmShopCategoryVo);
|
|
|
+ }
|
|
|
+ Integer categoryId = cmShopCategoryVo.getId();
|
|
|
+
|
|
|
+ if (StringUtils.isNotBlank(cmShopCategoryVo.getProductIds())) {
|
|
|
+ // 处理类别商品
|
|
|
+ List<Integer> productIdList = new ArrayList<>();
|
|
|
+ // 该类别下所有商品
|
|
|
+ List<Integer> categoryProductIds = shopMapper.getCategoryProductIds(categoryId);
|
|
|
+ if (cmShopCategoryVo.getProductIds().contains(",")) {
|
|
|
+ String[] productIdArr = cmShopCategoryVo.getProductIds().split(",");
|
|
|
+ for (String productId : productIdArr) {
|
|
|
+ int proId = Integer.parseInt(productId);
|
|
|
+ productIdList.add(proId);
|
|
|
+ if (!categoryProductIds.contains(proId)) {
|
|
|
+ shopMapper.insertCategoryProduct(categoryId, proId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ int proId = Integer.parseInt(cmShopCategoryVo.getProductIds());
|
|
|
productIdList.add(proId);
|
|
|
if (!categoryProductIds.contains(proId)) {
|
|
|
shopMapper.insertCategoryProduct(categoryId, proId);
|
|
|
}
|
|
|
}
|
|
|
- } else {
|
|
|
- int proId = Integer.parseInt(category.getProductIds());
|
|
|
- productIdList.add(proId);
|
|
|
- if (!categoryProductIds.contains(proId)) {
|
|
|
- shopMapper.insertCategoryProduct(categoryId, proId);
|
|
|
+ // 排除不在该商品类别的商品
|
|
|
+ if(productIdList.size() > 0) {
|
|
|
+ shopMapper.updateCategoryProduct(categoryId, productIdList);
|
|
|
}
|
|
|
}
|
|
|
- // 排除不在该商品类别的商品
|
|
|
- if(productIdList.size() > 0) {
|
|
|
- shopMapper.updateCategoryProduct(categoryId, productIdList);
|
|
|
- }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
}
|
|
|
return ResponseJson.success();
|
|
|
}
|
|
@@ -460,15 +503,29 @@ public class ShopServiceImpl implements ShopService {
|
|
|
* 供应商首页-轮播图片
|
|
|
*
|
|
|
* @param shopId 供应商Id
|
|
|
+ * @param title 标题
|
|
|
*/
|
|
|
@Override
|
|
|
- public ResponseJson<PaginationVo<ShopBannerVo>> getShopHomeImages(Integer shopId, int pageNum, int pageSize) {
|
|
|
+ public ResponseJson<PaginationVo<ShopBannerVo>> getShopHomeImages(Integer shopId, String title, int pageNum, int pageSize) {
|
|
|
PageHelper.startPage(pageNum, pageSize);
|
|
|
- List<ShopBannerVo> images = shopMapper.getShopHomeImages(shopId);
|
|
|
+ List<ShopBannerVo> images = shopMapper.getShopHomeImages(shopId, title);
|
|
|
PaginationVo<ShopBannerVo> page = new PaginationVo<>(images);
|
|
|
return ResponseJson.success(page);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 一键排序
|
|
|
+ *
|
|
|
+ * @param id
|
|
|
+ * @param sort
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public ResponseJson updateShopBannerSort(Integer id, Integer sort) {
|
|
|
+ shopMapper.updateShopBannerSort(id, sort);
|
|
|
+ return ResponseJson.success();
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 供应商-更新轮播图片
|
|
|
*
|
|
@@ -488,13 +545,14 @@ public class ShopServiceImpl implements ShopService {
|
|
|
if (null != shopBannerDto.getId()) {
|
|
|
// 更新
|
|
|
shopBanner.setId(shopBannerDto.getId());
|
|
|
+ shopBanner.setSort(shopBanner.getSort());
|
|
|
shopMapper.updateShopHomeImage(shopBanner);
|
|
|
} else {
|
|
|
// 新增
|
|
|
- int count = shopMapper.getShopHomeImageCount(shopBannerDto.getShopId());
|
|
|
+ /*int count = shopMapper.getShopHomeImageCount(shopBannerDto.getShopId());
|
|
|
if (count >= 4) {
|
|
|
return ResponseJson.error("主页广告图的上限是4张图!", null);
|
|
|
- }
|
|
|
+ }*/
|
|
|
shopMapper.insertShopHomeImage(shopBanner);
|
|
|
}
|
|
|
return ResponseJson.success(null);
|