From 8e3c3f451c77345239e1fba373c0dd14c907d8bd Mon Sep 17 00:00:00 2001 From: yuanye <418471657@qq.com> Date: Thu, 12 Sep 2024 18:05:12 +0800 Subject: [PATCH] 1 --- .../com/hfkj/controller/goodsController.java | 141 ++++++++++++++++++ .../main/java/com/hfkj/model/CouponModel.java | 5 + .../java/com/hfkj/model/GoodsInfoModel.java | 39 +++++ .../main/java/com/hfkj/model/GoodsModel.java | 56 +------ .../java/com/hfkj/model/IncomeInfoModel.java | 22 +++ .../hfkj/model/MorePromotionListModel.java | 36 +++++ .../hfkj/model/PricePromotionInfoModel.java | 29 ++++ .../java/com/hfkj/model/PublishInfoModel.java | 26 ++++ 8 files changed, 304 insertions(+), 50 deletions(-) create mode 100644 service/src/main/java/com/hfkj/model/GoodsInfoModel.java create mode 100644 service/src/main/java/com/hfkj/model/IncomeInfoModel.java create mode 100644 service/src/main/java/com/hfkj/model/MorePromotionListModel.java create mode 100644 service/src/main/java/com/hfkj/model/PricePromotionInfoModel.java create mode 100644 service/src/main/java/com/hfkj/model/PublishInfoModel.java diff --git a/cweb/src/main/java/com/hfkj/controller/goodsController.java b/cweb/src/main/java/com/hfkj/controller/goodsController.java index adf6ec7..d314b06 100644 --- a/cweb/src/main/java/com/hfkj/controller/goodsController.java +++ b/cweb/src/main/java/com/hfkj/controller/goodsController.java @@ -1,4 +1,145 @@ package com.hfkj.controller; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.hfkj.common.exception.ErrorCode; +import com.hfkj.common.exception.ErrorHelp; +import com.hfkj.common.exception.SysCode; +import com.hfkj.common.utils.ResponseMsgUtil; +import com.hfkj.model.*; +import com.hfkj.service.taobao.TaoBaoService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.License; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.ResponseBody; + +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; + +@Controller +@RequestMapping(value="/goods") +@Api(value="商品") public class goodsController { + + private static Logger log = LoggerFactory.getLogger(goodsController.class); + + @RequestMapping(value="/goodsList",method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "查询商品列表") + public ResponseData goodsList(@RequestParam(value = "title" , required = false) String title, + @RequestParam(value = "type" , required = true) Integer type, + @RequestParam(value = "pageNo" , required = false) Long pageNo, + @RequestParam(value = "pageSize" , required = false) Long pageSize + ) { + try { + + // 定义数据列表 + List goodsModelList = new ArrayList<>(); + GoodsModel goodsModel; + // 淘客推广信息 + PublishInfoModel publishInfoModel; + // 价格促销信息 + PricePromotionInfoModel pricePromotionInfoModel; + // 基础信息 + GoodsInfoModel goodsInfoModel; + // 商品佣金信息 + IncomeInfoModel incomeInfoModel; + // 更多活动优惠 + MorePromotionListModel morePromotionListModel; + + // 1:淘宝 2:拼多多 +// if (type == 1) { +// JSONObject jsonObject = TaoBaoService.material(title , pageNo , pageSize); +// +// if (jsonObject.getBoolean("success")) { +// return ResponseMsgUtil.success(jsonObject.getJSONArray("result_list")); +// } else { +// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请求失败!"); +// } +// +// JSONArray data = jsonObject.getJSONArray("result_list"); +// +// for (Object o : data) { +// goodsModel = new GoodsModel(); +// JSONObject object = (JSONObject) o; +// JSONObject publish_info = object.getJSONObject("publish_info"); +// 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"); +// JSONObject more_promotion_list = price_promotion_info.getJSONObject("more_promotion_list"); +// JSONObject final_promotion_path_list = price_promotion_info.getJSONObject("final_promotion_path_list"); +// +// // 淘客推广信息 +// // 商品佣金信息 +// incomeInfoModel = new IncomeInfoModel(); +// publishInfoModel = new PublishInfoModel(); +// publishInfoModel.setClickUrl(publish_info.getString("click_url")); +// publishInfoModel.setCouponShareUrl(publish_info.getString("coupon_share_url")); +// incomeInfoModel.setCommissionAmount(income_info.getBigDecimal("commission_amount")); +// incomeInfoModel.setCommissionRate(income_info.getString("commission_rate")); +// // 插入商品佣金信息 +// publishInfoModel.setIncomeInfo(incomeInfoModel); +// // 插入淘客推广信息 +// goodsModel.setPublishInfo(publishInfoModel); +// // 商品基础信息 +// goodsInfoModel = new GoodsInfoModel(); +// goodsInfoModel.setIngot(incomeInfoModel.getCommissionAmount().multiply(new BigDecimal(100))); +// goodsInfoModel.setProvCity(item_basic_info.getString("prov_city")); +// goodsInfoModel.setTitle(item_basic_info.getString("title")); +// 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)); +// goodsInfoModel.setShopTitle(item_basic_info.getString("shop_title")); +// // 插入商品基础信息 +// goodsModel.setGoodsInfo(goodsInfoModel); +// // 价格促销信息 +// pricePromotionInfoModel = new PricePromotionInfoModel(); +// 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")); +// // 更多活动优惠 +// morePromotionListModel = new MorePromotionListModel(); +// morePromotionListModel.setPromotionDesc(more_promotion_list.getString("promotion_desc")); +// morePromotionListModel.setPromotionFee(final_promotion_path_list.getBigDecimal("promotion_fee")); +// } +// +// +// } + return ResponseMsgUtil.success("121"); + + + } catch (Exception e) { + log.error("error!",e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value="/createCommand",method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "淘口令生成 ") + public ResponseData createCommand(@RequestParam(value = "url" , required = false) String url + ) { + try { + + JSONObject jsonObject = TaoBaoService.createCommand("https:" + url); + + if (jsonObject.getBoolean("success")) { + return ResponseMsgUtil.success(jsonObject.getJSONObject("data")); + } else { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请求失败!"); + } + + } catch (Exception e) { + log.error("error!",e); + return ResponseMsgUtil.exception(e); + } + } } diff --git a/service/src/main/java/com/hfkj/model/CouponModel.java b/service/src/main/java/com/hfkj/model/CouponModel.java index 9c6b648..2090534 100644 --- a/service/src/main/java/com/hfkj/model/CouponModel.java +++ b/service/src/main/java/com/hfkj/model/CouponModel.java @@ -1,4 +1,9 @@ package com.hfkj.model; public class CouponModel { + + /** + * 标题 + */ + String title; } diff --git a/service/src/main/java/com/hfkj/model/GoodsInfoModel.java b/service/src/main/java/com/hfkj/model/GoodsInfoModel.java new file mode 100644 index 0000000..74065f9 --- /dev/null +++ b/service/src/main/java/com/hfkj/model/GoodsInfoModel.java @@ -0,0 +1,39 @@ +package com.hfkj.model; + +import lombok.Data; + +import java.math.BigDecimal; +import java.util.List; + +@Data +public class GoodsInfoModel { + /** + * 商品标题 + */ + String title; + /** + * 商品短标题 + */ + String shortTitle; + /** + * 商品主图 + */ + String pictUrl; + /** + * 店铺信息 + */ + String shopTitle; + /** + * 商品小图列表 + */ + List smallImages; + /** + * 地区 + */ + String provCity; + + /** + * 元宝数量 + */ + BigDecimal ingot; +} diff --git a/service/src/main/java/com/hfkj/model/GoodsModel.java b/service/src/main/java/com/hfkj/model/GoodsModel.java index 904dcae..177e4be 100644 --- a/service/src/main/java/com/hfkj/model/GoodsModel.java +++ b/service/src/main/java/com/hfkj/model/GoodsModel.java @@ -2,64 +2,20 @@ package com.hfkj.model; import lombok.Data; -import java.math.BigDecimal; -import java.util.List; @Data public class GoodsModel { - - /** - * 标题 - */ - String title; - /** - * 售卖价格 - */ - BigDecimal salePrice; - /** - * 原价 - */ - BigDecimal originalPrice; - /** - * 优惠券价格 - */ - BigDecimal couponPrice; - /** - * 元宝数量 - */ - BigDecimal ingot; - /** - * 售卖数量 - */ - String saleNum; - /** - * 分类名称 - */ - String categoryName; - /** - * 列表图片 - */ - String listImg; - /** - * 轮播图列表 + * 淘客推广信息 */ - List bannerImg; - - /** - * 门店名称 - */ - String merName; - + PublishInfoModel publishInfo; /** - * 卡券 + * 价格促销信息 */ - List coupons; - + PricePromotionInfoModel pricePromotionInfo; /** - * 价格集合 + * 基础信息 */ - GoodsPriceModel goodsPrice; - + GoodsInfoModel goodsInfo; } diff --git a/service/src/main/java/com/hfkj/model/IncomeInfoModel.java b/service/src/main/java/com/hfkj/model/IncomeInfoModel.java new file mode 100644 index 0000000..b206fbb --- /dev/null +++ b/service/src/main/java/com/hfkj/model/IncomeInfoModel.java @@ -0,0 +1,22 @@ +package com.hfkj.model; + +import lombok.Data; + +import java.math.BigDecimal; + +/** + * 商品佣金信息 + */ +@Data +public class IncomeInfoModel { + + /** + * 商品佣金比率 + */ + String commissionRate; + + /** + * 商品佣金金额 + */ + BigDecimal commissionAmount; +} diff --git a/service/src/main/java/com/hfkj/model/MorePromotionListModel.java b/service/src/main/java/com/hfkj/model/MorePromotionListModel.java new file mode 100644 index 0000000..b976cf3 --- /dev/null +++ b/service/src/main/java/com/hfkj/model/MorePromotionListModel.java @@ -0,0 +1,36 @@ +package com.hfkj.model; + +import lombok.Data; + +import java.math.BigDecimal; + +/** + * 更多活动优惠 + */ +@Data +public class MorePromotionListModel { + /** + * 优惠名称 + */ + String promotionTitle; + /** + * 优惠利益点文案 + */ + String promotionDesc; + /** + * 优惠开始时间 + */ + String promotionStartTime; + /** + * 优惠结束时间 + */ + String promotionEndTime; + /** + * 实际优惠金额(元) + */ + BigDecimal promotionFee; + /** + * 优惠ID + */ + String promotionId; +} diff --git a/service/src/main/java/com/hfkj/model/PricePromotionInfoModel.java b/service/src/main/java/com/hfkj/model/PricePromotionInfoModel.java new file mode 100644 index 0000000..3cc177e --- /dev/null +++ b/service/src/main/java/com/hfkj/model/PricePromotionInfoModel.java @@ -0,0 +1,29 @@ +package com.hfkj.model; + +import lombok.Data; + +import java.math.BigDecimal; + +/** + * 价格促销信息 + */ +@Data +public class PricePromotionInfoModel { + /** + * 一口价通常显示为划线价 + */ + BigDecimal reservePrice; + /** + * 预估到手价(元)。若属于预售商品,付定金时间内,预估到手价价=定金+尾款的预估到手价 + */ + BigDecimal finalPromotionPrice; + /** + * 销售价格,无促销时等于一口价,有促销时为促销价。若属于预售商品,付定金时间内,在线售卖价=预售价 + */ + BigDecimal zkFinalPrice; + /** + * 更多活动优惠 + */ + MorePromotionListModel morePromotionList; + +} diff --git a/service/src/main/java/com/hfkj/model/PublishInfoModel.java b/service/src/main/java/com/hfkj/model/PublishInfoModel.java new file mode 100644 index 0000000..4853962 --- /dev/null +++ b/service/src/main/java/com/hfkj/model/PublishInfoModel.java @@ -0,0 +1,26 @@ +package com.hfkj.model; + +import lombok.Data; + +/** + * 淘客推广信息 + */ +@Data +public class PublishInfoModel { + + /** + * 宝贝推广链接 + */ + String clickUrl; + + /** + * 宝贝+券二合一页面链接 + */ + String couponShareUrl; + + /** + * 商品佣金信息 + */ + IncomeInfoModel incomeInfo; + +}