|
@@ -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,18 +325,205 @@ 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);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 供应商主页列表配置列表
|
|
|
+ *
|
|
|
+ * @param shopId
|
|
|
+ * @param category
|
|
|
+ * @param pageNum
|
|
|
+ * @param pageSize
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public ResponseJson<PaginationVo<CmShopCategoryVo>> getShopCategory(Integer shopId, String category, int pageNum, int pageSize) {
|
|
|
+ PageHelper.startPage(pageNum, pageSize);
|
|
|
+ List<CmShopCategoryVo> shopCategory = shopMapper.getShopCategory(shopId, category);
|
|
|
+ PaginationVo<CmShopCategoryVo> page = new PaginationVo<>(shopCategory);
|
|
|
+ return ResponseJson.success(page);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 一键排序
|
|
|
+ *
|
|
|
+ * @param id
|
|
|
+ * @param sort
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public ResponseJson renewShopCategory(Integer id, Integer sort) {
|
|
|
+ shopMapper.updateCategorySort(id, sort);
|
|
|
+ return ResponseJson.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 供应商商品类别回显
|
|
|
+ *
|
|
|
+ * @param id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public ResponseJson<CmShopCategoryVo> echoShopCategory(Integer id) {
|
|
|
+ CmShopCategoryVo shopCategoryById = shopMapper.getShopCategoryById(id);
|
|
|
+ List<ProductItemVo> categoryProductList = shopMapper.getCategoryProductById(id);
|
|
|
+ categoryProductList.forEach(product -> {
|
|
|
+ product.setImage(ImageUtils.getImageURL("product", product.getImage(), 0 , wwwDomain));
|
|
|
+ });
|
|
|
+ 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, Integer categoryId, String name, int pageNum, int pageSize) {
|
|
|
+ PageHelper.startPage(pageNum, pageSize);
|
|
|
+ List<ProductItemVo> shopProductList = shopMapper.getShopProductList(shopId, name);
|
|
|
+ // 供应商已选择商品, 同类别不可重复选择
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保存商品类别
|
|
|
+ *
|
|
|
+ * @param jsonParamsDto
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 排除不在该商品类别的商品
|
|
|
+ if(productIdList.size() > 0) {
|
|
|
+ shopMapper.updateCategoryProduct(categoryId, productIdList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return ResponseJson.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除供应商商品类别
|
|
|
+ *
|
|
|
+ * @param id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public ResponseJson deleteCategory(Integer id) {
|
|
|
+ shopMapper.deleteCategory(id);
|
|
|
+ return ResponseJson.success();
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 供应商首页-轮播图片
|
|
|
*
|
|
|
* @param shopId 供应商Id
|
|
|
+ * @param title 标题
|
|
|
*/
|
|
|
@Override
|
|
|
- public ResponseJson<List<ShopBannerVo>> getShopHomeImages(Integer shopId) {
|
|
|
- List<ShopBannerVo> images = shopMapper.getShopHomeImages(shopId);
|
|
|
- return ResponseJson.success(images);
|
|
|
+ public ResponseJson<PaginationVo<ShopBannerVo>> getShopHomeImages(Integer shopId, String title, int pageNum, int pageSize) {
|
|
|
+ PageHelper.startPage(pageNum, pageSize);
|
|
|
+ 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();
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -359,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);
|
|
@@ -1238,11 +1425,12 @@ public class ShopServiceImpl implements ShopService {
|
|
|
}
|
|
|
set = new HashSet<>();
|
|
|
List<ReturnEntityVo> userIdentity1 = shopMapper.getUserIdentity(startTime, endTime, shopKeyword);
|
|
|
- // 所有值之和
|
|
|
- AtomicInteger maxUserValue = new AtomicInteger(0);
|
|
|
if (null != userIdentity1 && userIdentity1.size() > 0) {
|
|
|
+ userIdentity1.removeIf( user -> StringUtils.isBlank(user.getName()));
|
|
|
+ // 所有值之和
|
|
|
+ AtomicInteger maxUserValue = new AtomicInteger(0);
|
|
|
for (ReturnEntityVo returnEntityVo : userIdentity1) {
|
|
|
- maxUserValue.updateAndGet(max -> max + Integer.parseInt(returnEntityVo.getValue()));
|
|
|
+ // maxUserValue.set(MathUtil.add(Integer.parseInt(returnEntityVo.getValue()),maxUserValue.get()).intValue());
|
|
|
if (!set.contains(returnEntityVo.getName())) {
|
|
|
set.add(returnEntityVo.getName());
|
|
|
userIdentity.add(returnEntityVo);
|
|
@@ -1252,15 +1440,23 @@ public class ShopServiceImpl implements ShopService {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- userIdentity.forEach(returnUserIdentity -> returnUserIdentity.setValue(MathUtil.div(returnUserIdentity.getValue(), maxUserValue.get(), 2).toString()));
|
|
|
+ userIdentity.forEach( user -> maxUserValue.set(MathUtil.add(Integer.parseInt(user.getValue()), maxUserValue.get()).intValue()));
|
|
|
+ userIdentity.forEach(returnUserIdentity -> {
|
|
|
+ log.info("returnUserIdentity.getValue()==="+returnUserIdentity.getValue());
|
|
|
+ log.info("maxUserValue.get()==="+maxUserValue.get());
|
|
|
+ String values = MathUtil.mul(MathUtil.div(returnUserIdentity.getValue(), maxUserValue.get(), 2), 100).toString();
|
|
|
+ log.info("values==="+values);
|
|
|
+ returnUserIdentity.setValue(values);
|
|
|
+ });
|
|
|
}
|
|
|
set = new HashSet<>();
|
|
|
List<ReturnEntityVo> clubType1 = shopMapper.getClubType(startTime, endTime, shopKeyword);
|
|
|
if (null != clubType1 && clubType1.size() > 0) {
|
|
|
+ clubType1.removeIf( club -> StringUtils.isBlank(club.getName()));
|
|
|
// 所有值之和
|
|
|
AtomicInteger maxClubTypeValue = new AtomicInteger(0);
|
|
|
for (ReturnEntityVo returnEntityVo : clubType1) {
|
|
|
- maxClubTypeValue.updateAndGet(max -> max + Integer.parseInt(returnEntityVo.getValue()));
|
|
|
+ // maxClubTypeValue.set(MathUtil.add(Integer.parseInt(returnEntityVo.getValue()), maxClubTypeValue.get()).intValue());
|
|
|
if (!set.contains(returnEntityVo.getName())) {
|
|
|
set.add(returnEntityVo.getName());
|
|
|
clubType.add(returnEntityVo);
|
|
@@ -1270,7 +1466,14 @@ public class ShopServiceImpl implements ShopService {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- userIdentity.forEach(returnUserIdentity -> returnUserIdentity.setValue(MathUtil.div(returnUserIdentity.getValue(), maxClubTypeValue.get(), 2).toString()));
|
|
|
+ clubType.forEach( club -> maxClubTypeValue.set(MathUtil.add(Integer.parseInt(club.getValue()), maxClubTypeValue.get()).intValue()));
|
|
|
+ clubType.forEach(returnUserIdentity -> {
|
|
|
+ log.info("returnUserIdentity.getValue()==="+returnUserIdentity.getValue());
|
|
|
+ log.info("maxClubTypeValue.get()==="+maxClubTypeValue.get());
|
|
|
+ String values = MathUtil.mul(MathUtil.div(returnUserIdentity.getValue(), maxClubTypeValue.get(), 2), 100).toString();
|
|
|
+ log.info("values==="+values);
|
|
|
+ returnUserIdentity.setValue(values);
|
|
|
+ });
|
|
|
}
|
|
|
}
|
|
|
map.put("channels", regionMap);
|