|
@@ -8,8 +8,10 @@ import com.cdf.common.ResultCode;
|
|
|
import com.cdf.entity.HotRelation;
|
|
|
import com.cdf.entity.NumRegion;
|
|
|
import com.cdf.entity.ProductHk;
|
|
|
+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.client.FdkkClient;
|
|
|
import com.cdf.httpClient.request.FdkkHotData;
|
|
|
import com.cdf.httpClient.request.FdkkHotRequest;
|
|
@@ -20,6 +22,7 @@ import com.cdf.httpClient.response.cdf.*;
|
|
|
import com.cdf.service.IFdkkUserService;
|
|
|
import com.cdf.service.IHotRelationService;
|
|
|
import com.cdf.service.IProductHkService;
|
|
|
+import com.cdf.service.IProductSourceService;
|
|
|
import com.cdf.util.*;
|
|
|
import com.google.zxing.client.j2se.MatrixToImageWriter;
|
|
|
import com.google.zxing.common.BitMatrix;
|
|
@@ -37,6 +40,7 @@ import javax.servlet.http.HttpServletResponse;
|
|
|
import java.io.File;
|
|
|
import java.io.IOException;
|
|
|
import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
|
@Slf4j
|
|
@@ -58,7 +62,7 @@ public class FdkkSceneEditService {
|
|
|
@Resource
|
|
|
private FdkkClient fdkkClient;
|
|
|
@Resource
|
|
|
- private CdfClient cdfClient;
|
|
|
+ private CdfHKClient cdfHKClient;
|
|
|
@Autowired
|
|
|
private IHotRelationService hotRelationService;
|
|
|
@Autowired
|
|
@@ -69,6 +73,8 @@ public class FdkkSceneEditService {
|
|
|
IProductHkService productHkService;
|
|
|
@Autowired
|
|
|
IFdkkUserService fdkkUserService;
|
|
|
+ @Autowired
|
|
|
+ IProductSourceService productSourceService;
|
|
|
|
|
|
|
|
|
public JSONObject getAuth(String num, String token) {
|
|
@@ -104,6 +110,10 @@ public class FdkkSceneEditService {
|
|
|
if(hotRelation == null){
|
|
|
hotRelation = new HotRelation();
|
|
|
update = false;
|
|
|
+ }else {
|
|
|
+ if(!hotRelation.getProductSourceId().equals(fdkkHotData.getProductSourceId())){
|
|
|
+ throw new BusinessException(ResultCode.HOT_PRODUCT_SOURCE_ERROR);
|
|
|
+ }
|
|
|
}
|
|
|
hotRelation.setHotId(sid);
|
|
|
hotRelation.setHotType(type);
|
|
@@ -114,6 +124,7 @@ public class FdkkSceneEditService {
|
|
|
}
|
|
|
hotRelation.setNum(fdkkHotRequest.getNum());
|
|
|
hotRelation.setContent(fdkkHotData.getHotContent());
|
|
|
+ hotRelation.setProductSourceId(fdkkHotData.getProductSourceId());
|
|
|
if(update){
|
|
|
hotRelationService.updateById(hotRelation);
|
|
|
}else {
|
|
@@ -269,6 +280,7 @@ public class FdkkSceneEditService {
|
|
|
|
|
|
List<String> sidsList = new ArrayList<>();
|
|
|
HashMap<String,HotRelation> hotRelationMap = new HashMap<>();
|
|
|
+ HashMap<Integer,ProductSource> productSourceMap = new HashMap<>();
|
|
|
for (Object obj : tags) {
|
|
|
JSONObject tag = (JSONObject) obj;
|
|
|
String sid = tag.getString("sid");
|
|
@@ -278,6 +290,12 @@ public class FdkkSceneEditService {
|
|
|
for (HotRelation hotRelation : hotRelations) {
|
|
|
hotRelationMap.put(hotRelation.getHotId(),hotRelation);
|
|
|
}
|
|
|
+ Set<Integer> productSourceIds = hotRelations.stream().map(HotRelation::getProductSourceId).collect(Collectors.toSet());
|
|
|
+ List<ProductSource> productSources = productSourceService.listByIds(productSourceIds);
|
|
|
+ for (ProductSource productSource : productSources) {
|
|
|
+ productSourceMap.put(productSource.getId(),productSource);
|
|
|
+ }
|
|
|
+
|
|
|
for (Object obj : tags) {
|
|
|
JSONObject tag = (JSONObject) obj;
|
|
|
String sid = tag.getString("sid");
|
|
@@ -302,6 +320,9 @@ public class FdkkSceneEditService {
|
|
|
if(jsonArray == null || jsonArray.size() <=0){
|
|
|
continue;
|
|
|
}
|
|
|
+ if(hotRelation.getProductSourceId() != null){
|
|
|
+ tag.put("productSource",productSourceMap.get(hotRelation.getProductSourceId()));
|
|
|
+ }
|
|
|
resultMap.put(sid,jsonArray);
|
|
|
requestArray.addAll(jsonArray);
|
|
|
}
|
|
@@ -309,35 +330,45 @@ public class FdkkSceneEditService {
|
|
|
return tags;
|
|
|
}
|
|
|
|
|
|
- if(pType.equals("AM")){
|
|
|
- CdfProductListByIdsRequest param = new CdfProductListByIdsRequest(requestArray);
|
|
|
- CdfProductListByIdsVo vos = cdfClient.getProductListByIds(param);
|
|
|
- if(vos.getProductCardList()!=null && vos.getProductCardList().size() >0){
|
|
|
- for (CdfProduct cdfProduct : vos.getProductCardList()) {
|
|
|
- productMap.put(cdfProduct.getId(),cdfProduct);
|
|
|
+ for (ProductSource productSource : productSources) {
|
|
|
+ if(productSource.getMchType() == 1){
|
|
|
+ List<ProductHk> list = productHkService.getListByIds(requestArray);
|
|
|
+ List<CdfProduct> convert = productHkService.convert(list, language);
|
|
|
+ for (CdfProduct cdfProduct : convert) {
|
|
|
+ productMap.put(productSource.getId() + "_"+ cdfProduct.getId(),cdfProduct);
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- if(pType.equals("HK")){
|
|
|
- List<ProductHk> list = productHkService.getListByIds(requestArray);
|
|
|
- List<CdfProduct> convert = productHkService.convert(list, language);
|
|
|
- for (CdfProduct cdfProduct : convert) {
|
|
|
- productMap.put(cdfProduct.getId(),cdfProduct);
|
|
|
+ if(productSource.getMchType() == 0){
|
|
|
+ CdfProductListByIdsRequest param = new CdfProductListByIdsRequest(requestArray);
|
|
|
+ CdfProductListByIdsVo vos = cdfHKClient.getProductListByIds(productSource.getCdfHost(),productSource.getCdfMchId(),param);
|
|
|
+ if(vos.getProductCardList()!=null && vos.getProductCardList().size() >0){
|
|
|
+ for (CdfProduct cdfProduct : vos.getProductCardList()) {
|
|
|
+ productMap.put(productSource.getId() + "_"+ cdfProduct.getId(),cdfProduct);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
|
|
|
for (Object obj : tags) {
|
|
|
JSONObject tag = (JSONObject) obj;
|
|
|
String sid = tag.getString("sid");
|
|
|
+ JSONObject productSource = tag.getJSONObject("productSource");
|
|
|
+ String keyPre = "";
|
|
|
+ if(productSource != null){
|
|
|
+ Integer id = productSource.getInteger("id");
|
|
|
+ keyPre = id +"_";
|
|
|
+ }
|
|
|
+
|
|
|
JSONArray jsonArray = resultMap.get(sid);
|
|
|
if(jsonArray==null || jsonArray.size()<=0){
|
|
|
continue;
|
|
|
}
|
|
|
List<CdfProduct> cdfProductList = new ArrayList<>();
|
|
|
for (Object o : jsonArray) {
|
|
|
- String key = o.toString();
|
|
|
- if(productMap.get(key)!=null){
|
|
|
- cdfProductList.add(productMap.get(key));
|
|
|
+ String key = keyPre + o.toString();
|
|
|
+ if(productMap.get( key)!=null){
|
|
|
+ cdfProductList.add(productMap.get( key));
|
|
|
}
|
|
|
}
|
|
|
if(cdfProductList.size() >0){
|