|
@@ -1,6 +1,9 @@
|
|
|
package org.dromara.external.service.impl;
|
|
package org.dromara.external.service.impl;
|
|
|
|
|
|
|
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
|
+import org.apache.dubbo.config.annotation.DubboReference;
|
|
|
import org.dromara.common.core.utils.MapstructUtils;
|
|
import org.dromara.common.core.utils.MapstructUtils;
|
|
|
import org.dromara.common.core.utils.StringUtils;
|
|
import org.dromara.common.core.utils.StringUtils;
|
|
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
|
@@ -10,6 +13,8 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
+import org.dromara.product.api.RemoteProductService;
|
|
|
|
|
+import org.dromara.product.api.domain.ProductVo;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.dromara.external.domain.bo.ExternalProductBo;
|
|
import org.dromara.external.domain.bo.ExternalProductBo;
|
|
|
import org.dromara.external.domain.vo.ExternalProductVo;
|
|
import org.dromara.external.domain.vo.ExternalProductVo;
|
|
@@ -34,6 +39,9 @@ public class ExternalProductServiceImpl extends ServiceImpl<ExternalProductMapp
|
|
|
|
|
|
|
|
private final ExternalProductMapper baseMapper;
|
|
private final ExternalProductMapper baseMapper;
|
|
|
|
|
|
|
|
|
|
+ @DubboReference
|
|
|
|
|
+ private RemoteProductService remoteProductService;
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 查询对外部推送商品
|
|
* 查询对外部推送商品
|
|
|
*
|
|
*
|
|
@@ -78,7 +86,6 @@ public class ExternalProductServiceImpl extends ServiceImpl<ExternalProductMapp
|
|
|
lqw.eq(bo.getProductId() != null, ExternalProduct::getProductId, bo.getProductId());
|
|
lqw.eq(bo.getProductId() != null, ExternalProduct::getProductId, bo.getProductId());
|
|
|
lqw.eq(bo.getItemId() != null, ExternalProduct::getItemId, bo.getItemId());
|
|
lqw.eq(bo.getItemId() != null, ExternalProduct::getItemId, bo.getItemId());
|
|
|
lqw.eq(bo.getCategoryId() != null, ExternalProduct::getCategoryId, bo.getCategoryId());
|
|
lqw.eq(bo.getCategoryId() != null, ExternalProduct::getCategoryId, bo.getCategoryId());
|
|
|
- lqw.eq(bo.getExternlCategoryId() != null, ExternalProduct::getExternlCategoryId, bo.getExternlCategoryId());
|
|
|
|
|
lqw.eq(bo.getPushStatus() != null, ExternalProduct::getPushStatus, bo.getPushStatus());
|
|
lqw.eq(bo.getPushStatus() != null, ExternalProduct::getPushStatus, bo.getPushStatus());
|
|
|
lqw.eq(StringUtils.isNotBlank(bo.getPlatformCode()), ExternalProduct::getPlatformCode, bo.getPlatformCode());
|
|
lqw.eq(StringUtils.isNotBlank(bo.getPlatformCode()), ExternalProduct::getPlatformCode, bo.getPlatformCode());
|
|
|
return lqw;
|
|
return lqw;
|
|
@@ -135,4 +142,55 @@ public class ExternalProductServiceImpl extends ServiceImpl<ExternalProductMapp
|
|
|
}
|
|
}
|
|
|
return baseMapper.deleteByIds(ids) > 0;
|
|
return baseMapper.deleteByIds(ids) > 0;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 获取第三方商品列表
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param bo 查询条件
|
|
|
|
|
+ * @param pageQuery 分页参数
|
|
|
|
|
+ * @return 第三方商品列表
|
|
|
|
|
+ */
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public TableDataInfo<ExternalProductVo> getThirdProductPage(ExternalProductBo bo, PageQuery pageQuery) {
|
|
|
|
|
+ LambdaQueryWrapper<ExternalProduct> lambdaQueryWrapper = buildQueryWrapper(bo);
|
|
|
|
|
+ Page<ExternalProductVo> result = baseMapper.selectVoPage(pageQuery.build(),lambdaQueryWrapper );
|
|
|
|
|
+ result.getRecords().forEach(item -> {
|
|
|
|
|
+ ExternalProductVo externalProductVo = BeanUtil.toBean(item, ExternalProductVo.class);
|
|
|
|
|
+ ProductVo productDetail = remoteProductService.getProductDetail(item.getProductId());
|
|
|
|
|
+ BeanUtil.copyProperties(productDetail, item);
|
|
|
|
|
+ item.setId(externalProductVo.getId());
|
|
|
|
|
+ item.setProductStatus(externalProductVo.getProductStatus());
|
|
|
|
|
+ });
|
|
|
|
|
+ return TableDataInfo.build( result);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 批量推送商品
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param ids 商品id
|
|
|
|
|
+ * @return 推送成功数量
|
|
|
|
|
+ */
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public int batchPush(Long[] ids) {
|
|
|
|
|
+ List<ExternalProduct> externalProducts = baseMapper.selectList(new LambdaQueryWrapper<ExternalProduct>().eq(ExternalProduct::getPushStatus, 0).in(ExternalProduct::getId, ids));
|
|
|
|
|
+ if (CollUtil.isNotEmpty(externalProducts)) {
|
|
|
|
|
+ }
|
|
|
|
|
+ return baseMapper.update(Wrappers.lambdaUpdate(ExternalProduct.class)
|
|
|
|
|
+ .set(ExternalProduct::getPushStatus, 1)
|
|
|
|
|
+ .in(ExternalProduct::getId, ids));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 商品上下架
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param bo
|
|
|
|
|
+ */
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public Boolean shelfReview(ExternalProductBo bo) {
|
|
|
|
|
+ return baseMapper.update(Wrappers.lambdaUpdate(ExternalProduct.class)
|
|
|
|
|
+ .set(ExternalProduct::getProductStatus, bo.getProductStatus())
|
|
|
|
|
+ .eq(ExternalProduct::getId, bo.getId())
|
|
|
|
|
+ )>0;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|