|
@@ -1,11 +1,22 @@
|
|
package com.caimei365.commodity.service.impl;
|
|
package com.caimei365.commodity.service.impl;
|
|
|
|
|
|
|
|
+import com.caimei365.commodity.components.PriceUtilService;
|
|
import com.caimei365.commodity.mapper.ShopMapper;
|
|
import com.caimei365.commodity.mapper.ShopMapper;
|
|
|
|
+import com.caimei365.commodity.model.ResponseJson;
|
|
|
|
+import com.caimei365.commodity.model.search.ProductListVo;
|
|
|
|
+import com.caimei365.commodity.model.vo.PaginationVo;
|
|
|
|
+import com.caimei365.commodity.model.vo.ProductShopVO;
|
|
|
|
+import com.caimei365.commodity.model.vo.PromotionsVo;
|
|
import com.caimei365.commodity.service.ShopService;
|
|
import com.caimei365.commodity.service.ShopService;
|
|
|
|
+import com.caimei365.commodity.utils.ImageUtils;
|
|
|
|
+import com.github.pagehelper.PageHelper;
|
|
|
|
+import com.github.pagehelper.PageInfo;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
/**
|
|
* Description
|
|
* Description
|
|
@@ -18,4 +29,125 @@ import javax.annotation.Resource;
|
|
public class ShopServiceImpl implements ShopService {
|
|
public class ShopServiceImpl implements ShopService {
|
|
@Resource
|
|
@Resource
|
|
private ShopMapper shopMapper;
|
|
private ShopMapper shopMapper;
|
|
|
|
+ @Resource
|
|
|
|
+ private PriceUtilService priceUtilService;
|
|
|
|
+ @Value("${caimei.wwwDomain}")
|
|
|
|
+ private String domain;
|
|
|
|
+ /**
|
|
|
|
+ * 供应商-主推商品
|
|
|
|
+ *
|
|
|
|
+ * @param shopId 供应商Id
|
|
|
|
+ * @param identity 用户身份:1协销,2会员机构,3供应商,4普通机构
|
|
|
|
+ * @return List<ProductListVo>
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public ResponseJson<List<ProductListVo>> getMainProducts(Integer shopId, Integer identity) {
|
|
|
|
+ if (shopId == null) {
|
|
|
|
+ return ResponseJson.error("参数异常:缺少供应商Id", null);
|
|
|
|
+ }
|
|
|
|
+ // identity: 0个人,1协销,2会员机构,3供应商,4普通机构
|
|
|
|
+ // p_visibility:3:所有人可见,2:普通机构可见,1:会员机构可见
|
|
|
|
+ List<Integer> visibilityList = new ArrayList<>();
|
|
|
|
+ if (identity == 1 || identity == 2) {
|
|
|
|
+ // 协销 | 会员机构 | 综合供应商
|
|
|
|
+ visibilityList.addAll(Arrays.asList(1,2,3));
|
|
|
|
+ } else if (identity == 4) {
|
|
|
|
+ // 普通机构
|
|
|
|
+ visibilityList.addAll(Arrays.asList(2,3));
|
|
|
|
+ } else {
|
|
|
|
+ // 游客|所有人
|
|
|
|
+ visibilityList.add(3);
|
|
|
|
+ }
|
|
|
|
+ List<ProductListVo> list = shopMapper.getMainProducts(shopId, visibilityList);
|
|
|
|
+ // 设置价格等级 及 老图片路径
|
|
|
|
+ list.forEach(product -> {
|
|
|
|
+ product.setPriceGrade(priceUtilService.getPriceGrade(product.getPrice()));
|
|
|
|
+ product.setPrice(0d);
|
|
|
|
+ product.setImage(ImageUtils.getImageURL("product", product.getImage(), 0, domain));
|
|
|
|
+ });
|
|
|
|
+ return ResponseJson.success(list);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 供应商-我的商品列表
|
|
|
|
+ *
|
|
|
|
+ * @param shopId 供应商Id
|
|
|
|
+ * @param name 商品名称
|
|
|
|
+ * @param productCode 货号
|
|
|
|
+ * @param validFlag 状态:0逻辑删除,1待审核,2已上架,3已下架,8审核未通过,9已隐身,10已冻结
|
|
|
|
+ * @param featuredFlag 是否主推:0否,1是
|
|
|
|
+ * @param typeSort 分类类型:1产品,2仪器
|
|
|
|
+ * @param bigTypeId 一级分类Id
|
|
|
|
+ * @param smallTypeId 二级分类Id
|
|
|
|
+ * @param tinyTypeId 三级级分类Id
|
|
|
|
+ * @param pageNum 页码
|
|
|
|
+ * @param pageSize 每页数量
|
|
|
|
+ * @return PageInfo<ProductShopVO>
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public ResponseJson<PageInfo<ProductShopVO>> getShopProducts(Integer shopId, String name, String productCode, Integer validFlag, Integer featuredFlag, Integer typeSort, Integer bigTypeId, Integer smallTypeId, Integer tinyTypeId, int pageNum, int pageSize) {
|
|
|
|
+ if (null == shopId) {
|
|
|
|
+ return ResponseJson.error("参数异常:缺少供应商Id", null);
|
|
|
|
+ }
|
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
|
+ PageHelper.startPage(pageNum, pageSize);
|
|
|
|
+ List<ProductShopVO> productList = shopMapper.getShopProductsSelect(shopId, name, productCode, validFlag, featuredFlag, typeSort, bigTypeId, smallTypeId, tinyTypeId);
|
|
|
|
+// if (null != productList && productList.size() > 0) {
|
|
|
|
+// for (ProductShopVO product : productList) {
|
|
|
|
+// product.setMainImage(ImageUtils.getImageURL("product", product.getMainImage(), 0, domain));
|
|
|
|
+// String typeName = shopMapper.getTypeName(product.getBigTypeId(), product.getSmallTypeId(), product.getTinyTypeId());
|
|
|
|
+// product.setTypeName(typeName);
|
|
|
|
+// //店铺促销
|
|
|
|
+// PromotionsVo promotions = promotionsDao.getSupplierPromotionsBySupplierId(product.getShopID());
|
|
|
|
+// if (promotions == null) {
|
|
|
|
+// promotions = promotionsDao.getProductPromotionsByProductId(product.getProductID());
|
|
|
|
+// }
|
|
|
|
+// if (null != promotions) {
|
|
|
|
+// List<CartItem> productGifts = null;
|
|
|
|
+// List<CartItem> promotionsProduct = null;
|
|
|
|
+// if (2 == promotions.getMode()) {
|
|
|
|
+// //满减商品
|
|
|
|
+// promotionsProduct = promotionsDao.findPromotionsProduct(promotions.getId());
|
|
|
|
+// } else if (3 == promotions.getMode()) {
|
|
|
|
+// //满赠商品
|
|
|
|
+// promotionsProduct = promotionsDao.findPromotionsProduct(promotions.getId());
|
|
|
|
+// productGifts = promotionsDao.getProductGifts(promotions.getId());
|
|
|
|
+// }
|
|
|
|
+// //促销商品
|
|
|
|
+// if (null != promotionsProduct && promotionsProduct.size() > 0) {
|
|
|
|
+// promotionsProduct.forEach(p -> {
|
|
|
|
+// if (p != null) {
|
|
|
|
+// p.setImage(ImageUtils.getImageURL("product", p.getImage(), 0, domain));
|
|
|
|
+// }
|
|
|
|
+// });
|
|
|
|
+// promotions.setProductList(promotionsProduct);
|
|
|
|
+// }
|
|
|
|
+// //促销赠品
|
|
|
|
+// if (null != productGifts && productGifts.size() > 0) {
|
|
|
|
+// productGifts.forEach(p -> {
|
|
|
|
+// p.setImage(ImageUtils.getImageURL("product", p.getImage(), 0, domain));
|
|
|
|
+// });
|
|
|
|
+// promotions.setGiftList(productGifts);
|
|
|
|
+// }
|
|
|
|
+// product.setPromotions(promotions);
|
|
|
|
+// } else if ("1".equals(product.getLadderPriceFlag())) {
|
|
|
|
+// //启用阶梯价格
|
|
|
|
+// sellerProductService.getLadderPrice(product);
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// PaginationVo<ProductShopVO> productPage = new PaginationVo<>(productList);
|
|
|
|
+// map.put("productPage", productPage);
|
|
|
|
+// List<ProductShopVO> mainProduct = supplierDao.findMainProduct(product.getShopID());
|
|
|
|
+// //主推商品数量
|
|
|
|
+// int featuredNum = 0;
|
|
|
|
+// if (null != mainProduct) {
|
|
|
|
+// featuredNum = mainProduct.size();
|
|
|
|
+// }
|
|
|
|
+// map.put("featuredNum", featuredNum);
|
|
|
|
+// return ResponseJson.success(map);
|
|
|
|
+
|
|
|
|
+ return null;
|
|
|
|
+
|
|
|
|
+ }
|
|
}
|
|
}
|