diff --git a/cweb/pom.xml b/cweb/pom.xml
index 69db753..882d490 100644
--- a/cweb/pom.xml
+++ b/cweb/pom.xml
@@ -40,6 +40,13 @@
src/main/resources/${env}
false
+
+ ${basedir}/lib
+ BOOT-INF/lib/
+
+ **/*.jar
+
+
diff --git a/cweb/src/main/java/com/hfkj/controller/GoodsController.java b/cweb/src/main/java/com/hfkj/controller/GoodsController.java
index 6244512..42c1c21 100644
--- a/cweb/src/main/java/com/hfkj/controller/GoodsController.java
+++ b/cweb/src/main/java/com/hfkj/controller/GoodsController.java
@@ -43,7 +43,7 @@ public class GoodsController {
) {
try {
- List goodsList = new ArrayList<>();
+ List goodsList;
// 1:淘宝 2:拼多多
if (type == 1) {
@@ -55,11 +55,24 @@ public class GoodsController {
goodsList = goodsDataService.goodsModelTaoBaoList(jsonObject);
} else if (type == 2) {
- if (pageSize < 10) {
- throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR , "pageSize的取值范围是10-100!");
+ JSONObject object = PddService.authority();
+ boolean generateAuthorityUrl = object.getJSONObject("authorityQueryResponse").getInteger("bind") == 0;
+ if (!generateAuthorityUrl && title != null) {
+ goodsList = new ArrayList<>();
+ JSONObject jsonObject = PddService.promotion();
+ JSONObject promotion = jsonObject.getJSONObject("rpPromotionUrlGenerateResponse").getJSONArray("urlList").getJSONObject(0);
+ GoodsModel goodsModel = new GoodsModel();
+ goodsModel.setPddUrl(promotion);
+ goodsList.add(goodsModel);
+
+ } else {
+ if (pageSize < 10) {
+ throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR , "pageSize的取值范围是10-100!");
+ }
+ JSONObject jsonObject = PddService.syncInvoke(title , pageNo , pageSize);
+ goodsList = goodsDataService.goodsModelPddList(jsonObject);
}
- JSONObject jsonObject = PddService.syncInvoke(title , pageNo , pageSize);
- return ResponseMsgUtil.success(jsonObject);
+
} else {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR , "未知类型!");
}
@@ -105,7 +118,7 @@ public class GoodsController {
boolean generateAuthorityUrl = object.getJSONObject("authorityQueryResponse").getInteger("bind") == 0;
JSONObject jsonObject = PddService.promotion(searchId , goodsSign , generateAuthorityUrl);
- return ResponseMsgUtil.success(jsonObject);
+ return ResponseMsgUtil.success(jsonObject.getJSONObject("goodsPromotionUrlGenerateResponse").getJSONArray("goodsPromotionUrlList").getJSONObject(0));
} catch (Exception e) {
log.error("error!",e);
diff --git a/service/src/main/java/com/hfkj/model/GoodsInfoModel.java b/service/src/main/java/com/hfkj/model/GoodsInfoModel.java
index 74065f9..e654e97 100644
--- a/service/src/main/java/com/hfkj/model/GoodsInfoModel.java
+++ b/service/src/main/java/com/hfkj/model/GoodsInfoModel.java
@@ -36,4 +36,9 @@ public class GoodsInfoModel {
* 元宝数量
*/
BigDecimal ingot;
+
+ /**
+ * 库存
+ */
+ String annualVol;
}
diff --git a/service/src/main/java/com/hfkj/model/GoodsModel.java b/service/src/main/java/com/hfkj/model/GoodsModel.java
index 177e4be..e941d72 100644
--- a/service/src/main/java/com/hfkj/model/GoodsModel.java
+++ b/service/src/main/java/com/hfkj/model/GoodsModel.java
@@ -1,5 +1,6 @@
package com.hfkj.model;
+import com.alibaba.fastjson.JSONObject;
import lombok.Data;
@@ -18,4 +19,9 @@ public class GoodsModel {
*/
GoodsInfoModel goodsInfo;
+ /**
+ * 拼多多授权地址
+ */
+ JSONObject pddUrl;
+
}
diff --git a/service/src/main/java/com/hfkj/model/PricePromotionInfoModel.java b/service/src/main/java/com/hfkj/model/PricePromotionInfoModel.java
index 28537a4..5de08b0 100644
--- a/service/src/main/java/com/hfkj/model/PricePromotionInfoModel.java
+++ b/service/src/main/java/com/hfkj/model/PricePromotionInfoModel.java
@@ -18,6 +18,10 @@ public class PricePromotionInfoModel {
* 预估到手价(元)。若属于预售商品,付定金时间内,预估到手价价=定金+尾款的预估到手价
*/
BigDecimal finalPromotionPrice;
+ /**
+ * 优惠券金额
+ */
+ BigDecimal couponPrice;
/**
* 销售价格,无促销时等于一口价,有促销时为促销价。若属于预售商品,付定金时间内,在线售卖价=预售价
*/
diff --git a/service/src/main/java/com/hfkj/service/goods/GoodsDataService.java b/service/src/main/java/com/hfkj/service/goods/GoodsDataService.java
index 0ff8305..328e18e 100644
--- a/service/src/main/java/com/hfkj/service/goods/GoodsDataService.java
+++ b/service/src/main/java/com/hfkj/service/goods/GoodsDataService.java
@@ -23,5 +23,13 @@ public interface GoodsDataService {
*/
List goodsModelTaoBaoList(JSONObject jsonObject);
+ /**
+ * @MethodName goodsModelPddList
+ * @Description: 拼多多数据整理
+ * @param jsonObject
+ * @return: java.util.List
+ * @Author: Sum1Dream
+ * @Date: 2024/9/20 下午2:21
+ */
List goodsModelPddList(JSONObject jsonObject);
}
diff --git a/service/src/main/java/com/hfkj/service/goods/impl/GoodsDataServiceImpl.java b/service/src/main/java/com/hfkj/service/goods/impl/GoodsDataServiceImpl.java
index 0f3b0bf..d240fba 100644
--- a/service/src/main/java/com/hfkj/service/goods/impl/GoodsDataServiceImpl.java
+++ b/service/src/main/java/com/hfkj/service/goods/impl/GoodsDataServiceImpl.java
@@ -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 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();
- goodsInfoModel.setSmallImages(JSONObject.parseArray(small_images,String.class));
+ if (item_basic_info.getJSONArray("small_images") == null) {
+ List 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,10 +113,15 @@ public class GoodsDataServiceImpl implements GoodsDataService {
}
}
+
+ morePromotionModels = morePromotionModels.stream().sorted(Comparator.comparing(MorePromotionModel:: getPromotionFee).reversed()).collect(Collectors.toList());
// 插入更多活动优惠
pricePromotionInfoModel.setMorePromotionList(morePromotionModels);
goodsModel.setPricePromotionInfo(pricePromotionInfoModel);
- goodsModelList.add(goodsModel);
+ 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 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;
}
}
diff --git a/service/src/main/java/com/hfkj/service/pdd/PddService.java b/service/src/main/java/com/hfkj/service/pdd/PddService.java
index 4a67a5a..0f76da5 100644
--- a/service/src/main/java/com/hfkj/service/pdd/PddService.java
+++ b/service/src/main/java/com/hfkj/service/pdd/PddService.java
@@ -8,10 +8,12 @@ import com.pdd.pop.sdk.http.PopHttpClient;
import com.pdd.pop.sdk.http.api.pop.request.PddDdkGoodsPromotionUrlGenerateRequest;
import com.pdd.pop.sdk.http.api.pop.request.PddDdkGoodsSearchRequest;
import com.pdd.pop.sdk.http.api.pop.request.PddDdkMemberAuthorityQueryRequest;
+import com.pdd.pop.sdk.http.api.pop.request.PddDdkRpPromUrlGenerateRequest;
import com.pdd.pop.sdk.http.api.pop.response.PddDdkGoodsPromotionUrlGenerateResponse;
import com.pdd.pop.sdk.http.api.pop.response.PddDdkGoodsSearchResponse;
import com.pdd.pop.sdk.http.api.pop.response.PddDdkMemberAuthorityQueryResponse;
+import com.pdd.pop.sdk.http.api.pop.response.PddDdkRpPromUrlGenerateResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -81,6 +83,36 @@ public class PddService {
}
+ /**
+ * @MethodName promotion
+ * @Description: 生成授权地址
+ * @param
+ * @return: com.alibaba.fastjson.JSONObject
+ * @Author: Sum1Dream
+ * @Date: 2024/9/20 下午3:57
+ */
+ public static JSONObject promotion() throws Exception {
+
+ log.info("============ 拼多多请求-START =============");
+ String clientId = "71a050c5d93d4169a237539af44c7c33";
+ String clientSecret = "b96def667dd28660d09f19ba2e9e9f23d810d563";
+ PopClient client = new PopHttpClient(clientId, clientSecret);
+
+ PddDdkRpPromUrlGenerateRequest request = new PddDdkRpPromUrlGenerateRequest();
+ List pIdList = new ArrayList<>();
+ pIdList.add("41483885_294044603");
+ request.setPIdList(pIdList);
+ request.setChannelType(10);
+ PddDdkRpPromUrlGenerateResponse response = client.syncInvoke(request);
+
+ log.info("请求接口:" + "promotion");
+ log.info("请求参数:" + JSONObject.toJSONString(request));
+ log.info("响应参数:" + JsonUtil.transferToJson(response));
+ log.info("============ 拼多多请求-END ==============");
+ return JSONObject.parseObject(JSON.toJSONString(response));
+
+ }
+
/**
* @MethodName authority
* @Description: 查询是否绑定备案