|
|
|
@ -10,9 +10,12 @@ import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
|
import java.math.BigDecimal; |
|
|
|
|
import java.math.RoundingMode; |
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
import java.util.Collections; |
|
|
|
|
import java.util.Comparator; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
@Service("goodsDataService") |
|
|
|
|
public class GoodsDataServiceImpl implements GoodsDataService { |
|
|
|
@ -38,7 +41,7 @@ public class GoodsDataServiceImpl implements GoodsDataService { |
|
|
|
|
MorePromotionModel morePromotionModel; |
|
|
|
|
List<MorePromotionModel> morePromotionModels; |
|
|
|
|
// 获取元宝的汇率
|
|
|
|
|
SecDictionary dictionary = secDictionaryService.findDictionary("GRADE_EXCHANGE_RATE"); |
|
|
|
|
SecDictionary dictionary = secDictionaryService.findDictionary("GOLD_COIN_EXCHANGE_RATE"); |
|
|
|
|
|
|
|
|
|
JSONArray data = jsonObject.getJSONArray("result_list"); |
|
|
|
|
|
|
|
|
@ -49,7 +52,6 @@ public class GoodsDataServiceImpl implements GoodsDataService { |
|
|
|
|
JSONObject price_promotion_info = object.getJSONObject("price_promotion_info"); |
|
|
|
|
JSONObject item_basic_info = object.getJSONObject("item_basic_info"); |
|
|
|
|
JSONObject income_info = publish_info.getJSONObject("income_info"); |
|
|
|
|
JSONArray more_promotion_list = price_promotion_info.getJSONArray("more_promotion_list"); |
|
|
|
|
JSONArray final_promotion_path_list = price_promotion_info.getJSONArray("final_promotion_path_list"); |
|
|
|
|
|
|
|
|
|
// 淘客推广信息
|
|
|
|
@ -66,15 +68,25 @@ public class GoodsDataServiceImpl implements GoodsDataService { |
|
|
|
|
publishInfoModel.setIncomeInfo(incomeInfoModel); |
|
|
|
|
// 插入淘客推广信息
|
|
|
|
|
goodsModel.setPublishInfo(publishInfoModel); |
|
|
|
|
String small_images; |
|
|
|
|
// 商品基础信息
|
|
|
|
|
goodsInfoModel = new GoodsInfoModel(); |
|
|
|
|
goodsInfoModel.setIngot(incomeInfoModel.getCommissionAmount().multiply(new BigDecimal(dictionary.getCodeValue()))); |
|
|
|
|
goodsInfoModel.setProvCity(item_basic_info.getString("prov_city")); |
|
|
|
|
goodsInfoModel.setTitle(item_basic_info.getString("title")); |
|
|
|
|
goodsInfoModel.setAnnualVol(item_basic_info.getString("annual_vol")); |
|
|
|
|
goodsInfoModel.setPictUrl(item_basic_info.getString("pict_url")); |
|
|
|
|
goodsInfoModel.setShortTitle(item_basic_info.getString("short_title")); |
|
|
|
|
String small_images = item_basic_info.getJSONArray("small_images").toString(); |
|
|
|
|
if (item_basic_info.getJSONArray("small_images") == null) { |
|
|
|
|
List<String> arrayList = new ArrayList<>(); |
|
|
|
|
arrayList.add(item_basic_info.getString("pict_url")); |
|
|
|
|
goodsInfoModel.setSmallImages(arrayList); |
|
|
|
|
} else { |
|
|
|
|
small_images = item_basic_info.getJSONArray("small_images").toString(); |
|
|
|
|
goodsInfoModel.setSmallImages(JSONObject.parseArray(small_images,String.class)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
goodsInfoModel.setShopTitle(item_basic_info.getString("shop_title")); |
|
|
|
|
// 插入商品基础信息
|
|
|
|
|
goodsModel.setGoodsInfo(goodsInfoModel); |
|
|
|
@ -83,20 +95,10 @@ public class GoodsDataServiceImpl implements GoodsDataService { |
|
|
|
|
pricePromotionInfoModel.setReservePrice(price_promotion_info.getBigDecimal("reserve_price")); |
|
|
|
|
pricePromotionInfoModel.setZkFinalPrice(price_promotion_info.getBigDecimal("zk_final_price")); |
|
|
|
|
pricePromotionInfoModel.setFinalPromotionPrice(price_promotion_info.getBigDecimal("final_promotion_price")); |
|
|
|
|
pricePromotionInfoModel.setCouponPrice(pricePromotionInfoModel.getZkFinalPrice().subtract(pricePromotionInfoModel.getFinalPromotionPrice())); |
|
|
|
|
// 更多活动优惠
|
|
|
|
|
morePromotionModels = new ArrayList<>(); |
|
|
|
|
if (more_promotion_list != null && !more_promotion_list.isEmpty()) { |
|
|
|
|
for (Object more_promotion : more_promotion_list) { |
|
|
|
|
JSONObject morePromotion = (JSONObject) more_promotion; |
|
|
|
|
morePromotionModel = new MorePromotionModel(); |
|
|
|
|
morePromotionModel.setPromotionDesc(morePromotion.getString("promotion_desc")); |
|
|
|
|
morePromotionModel.setPromotionTitle(morePromotion.getString("promotion_title")); |
|
|
|
|
morePromotionModel.setPromotionStartTime(morePromotion.getString("promotion_start_time")); |
|
|
|
|
morePromotionModel.setPromotionEndTime(morePromotion.getString("promotion_end_time")); |
|
|
|
|
morePromotionModel.setPromotionId(morePromotion.getString("promotion_id")); |
|
|
|
|
morePromotionModels.add(morePromotionModel); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (final_promotion_path_list != null && !final_promotion_path_list.isEmpty()) { |
|
|
|
|
for (Object final_promotion : final_promotion_path_list) { |
|
|
|
|
JSONObject morePromotion = (JSONObject) final_promotion; |
|
|
|
@ -111,12 +113,17 @@ public class GoodsDataServiceImpl implements GoodsDataService { |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
morePromotionModels = morePromotionModels.stream().sorted(Comparator.comparing(MorePromotionModel:: getPromotionFee).reversed()).collect(Collectors.toList()); |
|
|
|
|
// 插入更多活动优惠
|
|
|
|
|
pricePromotionInfoModel.setMorePromotionList(morePromotionModels); |
|
|
|
|
goodsModel.setPricePromotionInfo(pricePromotionInfoModel); |
|
|
|
|
if (!morePromotionModels.isEmpty()) { |
|
|
|
|
goodsModelList.add(goodsModel); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return goodsModelList; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -131,25 +138,60 @@ public class GoodsDataServiceImpl implements GoodsDataService { |
|
|
|
|
PricePromotionInfoModel pricePromotionInfoModel; |
|
|
|
|
// 基础信息
|
|
|
|
|
GoodsInfoModel goodsInfoModel; |
|
|
|
|
// 商品佣金信息
|
|
|
|
|
IncomeInfoModel incomeInfoModel; |
|
|
|
|
|
|
|
|
|
// 更多活动优惠
|
|
|
|
|
MorePromotionModel morePromotionModel; |
|
|
|
|
List<MorePromotionModel> morePromotionModels; |
|
|
|
|
// 获取元宝的汇率
|
|
|
|
|
SecDictionary dictionary = secDictionaryService.findDictionary("GOLD_COIN_EXCHANGE_RATE"); |
|
|
|
|
|
|
|
|
|
JSONArray array = jsonObject.getJSONObject("goodsSearchResponse").getJSONArray("goodsSearchResponse"); |
|
|
|
|
JSONArray array = jsonObject.getJSONObject("goodsSearchResponse").getJSONArray("goodsList"); |
|
|
|
|
|
|
|
|
|
for (Object object : array) { |
|
|
|
|
JSONObject goods = (JSONObject) object; |
|
|
|
|
goodsModel = new GoodsModel(); |
|
|
|
|
|
|
|
|
|
// 商品基础信息
|
|
|
|
|
goodsInfoModel = new GoodsInfoModel(); |
|
|
|
|
goodsInfoModel.setTitle(goods.getString("goodsName")); |
|
|
|
|
goodsInfoModel.setAnnualVol(goods.getString("salesTip")); |
|
|
|
|
goodsInfoModel.setPictUrl(goods.getString("goodsImageUrl")); |
|
|
|
|
goodsInfoModel.setShopTitle(goods.getString("mallName")); |
|
|
|
|
goodsInfoModel.setIngot( |
|
|
|
|
goods.getBigDecimal("minNormalPrice"). |
|
|
|
|
multiply(goods.getBigDecimal("promotionRate"). |
|
|
|
|
multiply(new BigDecimal(dictionary.getCodeValue()))). |
|
|
|
|
divide(new BigDecimal(100*1000) , 6 , RoundingMode.DOWN) |
|
|
|
|
); |
|
|
|
|
// 插入商品基础信息
|
|
|
|
|
goodsModel.setGoodsInfo(goodsInfoModel); |
|
|
|
|
// 淘客推广信息
|
|
|
|
|
// 商品佣金信息
|
|
|
|
|
incomeInfoModel = new IncomeInfoModel(); |
|
|
|
|
publishInfoModel = new PublishInfoModel(); |
|
|
|
|
publishInfoModel.setGoodsSign(goods.getString("goodsSign")); |
|
|
|
|
publishInfoModel.setSearchId(goods.getString("searchId")); |
|
|
|
|
// 插入淘客推广信息
|
|
|
|
|
goodsModel.setPublishInfo(publishInfoModel); |
|
|
|
|
// 更多活动优惠
|
|
|
|
|
morePromotionModels = new ArrayList<>(); |
|
|
|
|
morePromotionModel = new MorePromotionModel(); |
|
|
|
|
morePromotionModel.setPromotionFee(goods.getBigDecimal("couponDiscount").divide(new BigDecimal(100) , 2 , RoundingMode.DOWN)); |
|
|
|
|
morePromotionModel.setPromotionStartTime(goods.getString("couponStartTime")); |
|
|
|
|
morePromotionModel.setPromotionEndTime(goods.getString("couponEndTime")); |
|
|
|
|
morePromotionModels.add(morePromotionModel); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 价格促销信息
|
|
|
|
|
pricePromotionInfoModel = new PricePromotionInfoModel(); |
|
|
|
|
pricePromotionInfoModel.setReservePrice(goods.getBigDecimal("minNormalPrice").divide(new BigDecimal(100) , 2 , RoundingMode.DOWN)); |
|
|
|
|
pricePromotionInfoModel.setZkFinalPrice(goods.getBigDecimal("minGroupPrice").divide(new BigDecimal(100) , 2 , RoundingMode.DOWN)); |
|
|
|
|
pricePromotionInfoModel.setFinalPromotionPrice(pricePromotionInfoModel.getZkFinalPrice()); |
|
|
|
|
|
|
|
|
|
// 插入更多活动优惠
|
|
|
|
|
pricePromotionInfoModel.setMorePromotionList(morePromotionModels); |
|
|
|
|
goodsModel.setPricePromotionInfo(pricePromotionInfoModel); |
|
|
|
|
goodsModelList.add(goodsModel); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return Collections.emptyList(); |
|
|
|
|
return goodsModelList; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|