|
@@ -3,6 +3,7 @@ package com.fjhx.item.service.product.impl;
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.dynamic.datasource.annotation.DS;
|
|
|
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
|
|
@@ -269,8 +270,36 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
|
|
|
|
|
|
@Override
|
|
|
public ProductInfoVo detail(Long id) {
|
|
|
- ProductInfo ProductInfo = this.getById(id);
|
|
|
- ProductInfoVo result = BeanUtil.toBean(ProductInfo, ProductInfoVo.class);
|
|
|
+ ProductInfo productInfo = this.getById(id);
|
|
|
+ ProductInfoVo result = BeanUtil.toBean(productInfo, ProductInfoVo.class);
|
|
|
+ //赋值维多利亚组合产品信息
|
|
|
+ JSONObject json = JSONObject.parseObject(result.getVictoriatouristJson());
|
|
|
+ List<Long> ids = new ArrayList<>();
|
|
|
+ if(ObjectUtil.isNotEmpty(json)){
|
|
|
+ JSONArray productCombinationList = json.getJSONArray("productCombinationList");
|
|
|
+ for (int i=0;i<productCombinationList.size();i++) {
|
|
|
+ JSONObject item = productCombinationList.getJSONObject(i);
|
|
|
+ ids.add(item.getLong("linkProductId"));
|
|
|
+ }
|
|
|
+ if(ObjectUtil.isNotEmpty(ids)){
|
|
|
+ List<ProductInfo> productInfoList = this.listByIds(ids);
|
|
|
+ Map<Long, ProductInfo> productInfoMap = productInfoList.stream().collect(Collectors.toMap(ProductInfo::getId, Function.identity()));
|
|
|
+ JSONArray jsonArray = new JSONArray();
|
|
|
+ for (int i=0;i<productCombinationList.size();i++) {
|
|
|
+ JSONObject item = productCombinationList.getJSONObject(i);
|
|
|
+ ProductInfo productInfo1 = productInfoMap.get(item.getLong("linkProductId"));
|
|
|
+ if(ObjectUtil.isNotEmpty(productInfo1)) {
|
|
|
+ item.put("code",productInfo1.getCode());
|
|
|
+ item.put("customCode",productInfo1.getCustomCode());
|
|
|
+ item.put("name",productInfo1.getName());
|
|
|
+ }
|
|
|
+ jsonArray.add(item);
|
|
|
+ }
|
|
|
+ json.put("productCombinationList",jsonArray);
|
|
|
+ result.setVictoriatouristJson(JSONObject.toJSONString(json));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ result.getVictoriatouristJson();
|
|
|
return result;
|
|
|
}
|
|
|
|