|
@@ -1,12 +1,23 @@
|
|
|
package com.cdf.service.impl;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.cdf.common.PageInfo;
|
|
|
+import com.cdf.common.ResultData;
|
|
|
import com.cdf.entity.ProductSource;
|
|
|
+import com.cdf.exception.BusinessException;
|
|
|
+import com.cdf.httpClient.client.CdfClient;
|
|
|
+import com.cdf.httpClient.client.CdfHKClient;
|
|
|
+import com.cdf.httpClient.response.cdf.*;
|
|
|
import com.cdf.mapper.IProductSourceMapper;
|
|
|
import com.cdf.service.IProductSourceService;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Arrays;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
@@ -20,10 +31,35 @@ import java.util.List;
|
|
|
@Service
|
|
|
public class ProductSourceServiceImpl extends ServiceImpl<IProductSourceMapper, ProductSource> implements IProductSourceService {
|
|
|
|
|
|
+ @Resource
|
|
|
+ private CdfHKClient cdfHKClient;
|
|
|
@Override
|
|
|
public List<ProductSource> getProductHk(String type) {
|
|
|
LambdaQueryWrapper<ProductSource> wrapper = new LambdaQueryWrapper<>();
|
|
|
wrapper.eq(ProductSource::getRegion,"HK");
|
|
|
return this.list(wrapper);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Object getBySource(CdfProductListRequest param,ProductSource productSource) {
|
|
|
+ if(StringUtils.isNotBlank(param.getKeyword()) && param.getKeyword().contains(",")){
|
|
|
+ if(param.getPageNum() >1){
|
|
|
+ PageInfo pageInfo = PageInfo.PageInfo(param.getPageIndex(), 20L, 0L, new ArrayList<>());
|
|
|
+ return ResultData.ok(pageInfo);
|
|
|
+ }
|
|
|
+ JSONArray ids = new JSONArray();
|
|
|
+ ids.addAll(Arrays.asList(param.getKeyword().split(",")));
|
|
|
+ CdfProductListByIdsRequest idsRequest = new CdfProductListByIdsRequest(ids);
|
|
|
+ CdfProductListByIdsVo vos = cdfHKClient.getProductListByIds(productSource.getCdfHost(),productSource.getCdfMchId(),idsRequest);
|
|
|
+ List<CdfProduct> productCardList = vos.getProductCardList();
|
|
|
+ PageInfo pageInfo = PageInfo.PageInfo(param.getPageIndex(), (long) productCardList.size(), (long) productCardList.size(), productCardList);
|
|
|
+ return ResultData.ok(pageInfo);
|
|
|
+ }
|
|
|
+ CdfProductListResponse productList = cdfHKClient.getProductList(productSource.getCdfHost(),productSource.getCdfMchId(),param);
|
|
|
+ if(productList.getSearchResult().getType() == 4 ){
|
|
|
+ throw new BusinessException(productList.getSearchResult().getType(),productList.getSearchResult().getDesc());
|
|
|
+ }
|
|
|
+ PageInfo pageInfo = PageInfo.PageInfo(param.getPageIndex(), 20L, productList.getCount()*20, productList.getList());
|
|
|
+ return pageInfo;
|
|
|
+ }
|
|
|
}
|