|
@@ -1,17 +1,13 @@
|
|
package com.caimei365.user.service.impl;
|
|
package com.caimei365.user.service.impl;
|
|
|
|
|
|
import com.caimei365.user.feign.CommodityFeign;
|
|
import com.caimei365.user.feign.CommodityFeign;
|
|
-import com.caimei365.user.mapper.ArticleMapper;
|
|
|
|
-import com.caimei365.user.mapper.BaseMapper;
|
|
|
|
-import com.caimei365.user.mapper.PersonalCenterMapper;
|
|
|
|
-import com.caimei365.user.mapper.ShopMapper;
|
|
|
|
|
|
+import com.caimei365.user.mapper.*;
|
|
import com.caimei365.user.model.ResponseJson;
|
|
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.ShopArticleDto;
|
|
import com.caimei365.user.model.dto.ShopBannerDto;
|
|
import com.caimei365.user.model.dto.ShopBannerDto;
|
|
import com.caimei365.user.model.dto.ShopUpdateDto;
|
|
import com.caimei365.user.model.dto.ShopUpdateDto;
|
|
-import com.caimei365.user.model.po.ArticlePo;
|
|
|
|
-import com.caimei365.user.model.po.ShopCertPo;
|
|
|
|
-import com.caimei365.user.model.po.UserPo;
|
|
|
|
|
|
+import com.caimei365.user.model.po.*;
|
|
import com.caimei365.user.model.vo.*;
|
|
import com.caimei365.user.model.vo.*;
|
|
import com.caimei365.user.service.ShopService;
|
|
import com.caimei365.user.service.ShopService;
|
|
import com.caimei365.user.utils.DateUtil;
|
|
import com.caimei365.user.utils.DateUtil;
|
|
@@ -48,6 +44,8 @@ public class ShopServiceImpl implements ShopService {
|
|
@Resource
|
|
@Resource
|
|
private ArticleMapper articleMapper;
|
|
private ArticleMapper articleMapper;
|
|
@Resource
|
|
@Resource
|
|
|
|
+ private BaikeProductMapper baikeProductMapper;
|
|
|
|
+ @Resource
|
|
private PersonalCenterMapper personalCenterMapper;
|
|
private PersonalCenterMapper personalCenterMapper;
|
|
@Value("${spring.cloud.config.profile}")
|
|
@Value("${spring.cloud.config.profile}")
|
|
private String active;
|
|
private String active;
|
|
@@ -499,7 +497,7 @@ public class ShopServiceImpl implements ShopService {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public ResponseJson<PageInfo<ShopArticleVo>> getShopArticleList(ShopArticleDto shopArticleDto, int pageNum, int pageSize) {
|
|
public ResponseJson<PageInfo<ShopArticleVo>> getShopArticleList(ShopArticleDto shopArticleDto, int pageNum, int pageSize) {
|
|
- if (null == shopArticleDto) {
|
|
|
|
|
|
+ if (null == shopArticleDto.getShopId()) {
|
|
return ResponseJson.error("参数异常", null);
|
|
return ResponseJson.error("参数异常", null);
|
|
}
|
|
}
|
|
PageHelper.startPage(pageNum, pageSize);
|
|
PageHelper.startPage(pageNum, pageSize);
|
|
@@ -534,4 +532,115 @@ public class ShopServiceImpl implements ShopService {
|
|
commodityFeign.updateArticleIndex(articleId);
|
|
commodityFeign.updateArticleIndex(articleId);
|
|
return ResponseJson.success(null);
|
|
return ResponseJson.success(null);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public ResponseJson<Void> saveBaikeProduct(BaikeProductDto baikeProductDto) {
|
|
|
|
+ if (null == baikeProductDto.getShopId()) {
|
|
|
|
+ return ResponseJson.error("参数异常,供应商id不能为空", null);
|
|
|
|
+ }
|
|
|
|
+ if (StringUtils.isEmpty(baikeProductDto.getName())) {
|
|
|
|
+ return ResponseJson.error("参数异常,百科名称不能为空", null);
|
|
|
|
+ }
|
|
|
|
+ // 新增商品标识
|
|
|
|
+ boolean newProductFlag = null == baikeProductDto.getProductId() || 0 == baikeProductDto.getProductId();
|
|
|
|
+ BaikeProductPo baikeProductPo = new BaikeProductPo();
|
|
|
|
+ BeanUtils.copyProperties(baikeProductDto, baikeProductPo);
|
|
|
|
+ // 保存供应商百科商品
|
|
|
|
+ if (newProductFlag) {
|
|
|
|
+ baikeProductPo.setPublishSource(2);
|
|
|
|
+ baikeProductPo.setAuditStatus(1);
|
|
|
|
+ baikeProductPo.setBasePv(0);
|
|
|
|
+ baikeProductPo.setActualPv(0);
|
|
|
|
+ baikeProductMapper.insertBaikeProduct(baikeProductPo);
|
|
|
|
+ } else {
|
|
|
|
+ baikeProductPo.setAuditStatus(1);
|
|
|
|
+ baikeProductMapper.updateBaikeProduct(baikeProductPo);
|
|
|
|
+ }
|
|
|
|
+ Integer productId = baikeProductPo.getProductId();
|
|
|
|
+ // 删除原先的图片/参数/问题数据
|
|
|
|
+ if (!newProductFlag) {
|
|
|
|
+ baikeProductMapper.deleteParamsByProductId(productId);
|
|
|
|
+ baikeProductMapper.deleteImagesByProductId(productId);
|
|
|
|
+ baikeProductMapper.deleteQuestionsByProductId(productId);
|
|
|
|
+ }
|
|
|
|
+ // 保存参数
|
|
|
|
+ List<BaikeProductParamPo> paramList = baikeProductDto.getParamList();
|
|
|
|
+ paramList.forEach(param->{
|
|
|
|
+ if (StringUtils.isNotEmpty(param.getName()) && StringUtils.isNotEmpty(param.getContent())) {
|
|
|
|
+ baikeProductMapper.insertProductParam(param.getName(), param.getContent(), productId);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ // 保存认证图片
|
|
|
|
+ List<String> authImageList = baikeProductDto.getAuthImageList();
|
|
|
|
+ authImageList.forEach(authImage-> baikeProductMapper.insertProductImage(authImage, productId, 1));
|
|
|
|
+ // 保存展示图片
|
|
|
|
+ List<String> displayImageList = baikeProductDto.getDisplayImageList();
|
|
|
|
+ displayImageList.forEach(diplayImage-> baikeProductMapper.insertProductImage(diplayImage, productId, 2));
|
|
|
|
+ // 保存问题
|
|
|
|
+ List<BaikeProductQuestionPo> questionList = baikeProductDto.getQuestionList();
|
|
|
|
+ questionList.forEach(question->{
|
|
|
|
+ if (StringUtils.isNotEmpty(question.getQuestion()) && StringUtils.isNotEmpty(question.getAnswer())) {
|
|
|
|
+ baikeProductMapper.insertProductQuestion(question.getQuestion(), question.getAnswer(), productId);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ return ResponseJson.success(null);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public ResponseJson<BaikeProductFormVo> getBaikeProductById(Integer productId) {
|
|
|
|
+ if (null == productId) {
|
|
|
|
+ return ResponseJson.error("参数异常", null);
|
|
|
|
+ }
|
|
|
|
+ // 查询商品信息
|
|
|
|
+ BaikeProductFormVo baikeProduct = baikeProductMapper.getBaikeProductById(productId);
|
|
|
|
+ // 参数列表
|
|
|
|
+ List<BaikeProductParamPo> paramList = baikeProductMapper.getParamList(productId);
|
|
|
|
+ baikeProduct.setParamList(paramList);
|
|
|
|
+ // 产品/仪器认证图片列表
|
|
|
|
+ List<String> authImageList = baikeProductMapper.getImageList(productId, 1);
|
|
|
|
+ baikeProduct.setAuthImageList(authImageList);
|
|
|
|
+ // 效果展示图片列表
|
|
|
|
+ List<String> displayImageList = baikeProductMapper.getImageList(productId, 2);
|
|
|
|
+ baikeProduct.setDisplayImageList(displayImageList);
|
|
|
|
+ // 问题列表
|
|
|
|
+ List<BaikeProductQuestionPo> questionList = baikeProductMapper.getQuestionList(productId);
|
|
|
|
+ baikeProduct.setQuestionList(questionList);
|
|
|
|
+ return ResponseJson.success(baikeProduct);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public ResponseJson<PageInfo<BaikeProductListVo>> getBaikeProductList(BaikeProductDto baikeProductDto, int pageNum, int pageSize) {
|
|
|
|
+ if (null == baikeProductDto.getShopId()) {
|
|
|
|
+ return ResponseJson.error("参数异常", null);
|
|
|
|
+ }
|
|
|
|
+ PageHelper.startPage(pageNum, pageSize);
|
|
|
|
+ List<BaikeProductListVo> baikeProductList = baikeProductMapper.getBaikeProductList(baikeProductDto);
|
|
|
|
+ PageInfo<BaikeProductListVo> pageInfo = new PageInfo<>(baikeProductList);
|
|
|
|
+ return ResponseJson.success(pageInfo);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public ResponseJson<Void> updateBaikeProductStatus(BaikeProductDto baikeProductDto) {
|
|
|
|
+ Integer productId = baikeProductDto.getProductId();
|
|
|
|
+ Integer status = baikeProductDto.getStatus();
|
|
|
|
+ if (null == productId || null == status) {
|
|
|
|
+ return ResponseJson.error("参数异常", null);
|
|
|
|
+ }
|
|
|
|
+ baikeProductMapper.updateBaikeProductStatus(productId, status);
|
|
|
|
+ return ResponseJson.success(null);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public ResponseJson<List<BaikeProductTypeVo>> getBaikeProductTypeList(Integer commodityType) {
|
|
|
|
+ List<BaikeProductTypeVo> baikeProductTypeList = baikeProductMapper.getBaikeProductTypeList(commodityType);
|
|
|
|
+ return ResponseJson.success(baikeProductTypeList);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public ResponseJson<Void> deleteBaikeProduct(Integer productId) {
|
|
|
|
+ baikeProductMapper.deleteBaikeProduct(productId);
|
|
|
|
+ return ResponseJson.success(null);
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|