k.zhang пре 4 година
родитељ
комит
3d73bbd2a9
2 измењених фајлова са 57 додато и 49 уклоњено
  1. 4 0
      apis/pdd/pdd.ddk.goods.detail.go
  2. 53 49
      models/pdd/pdd.ddk.goods.detail.go

+ 4 - 0
apis/pdd/pdd.ddk.goods.detail.go

@@ -7,6 +7,7 @@ import (
 	"duoduo/tools/app"
 	"fmt"
 	"github.com/gin-gonic/gin"
+	"github.com/shopspring/decimal"
 	"time"
 )
 
@@ -64,5 +65,8 @@ func PddDdkGoodsDetail(c *gin.Context) {
 		return
 	}
 
+	outData.GoodsDetailResponse.GoodsDetails[0].MinAmount = decimal.NewFromInt(outData.GoodsDetailResponse.GoodsDetails[0].MinGroupPrice).Sub(decimal.NewFromInt(outData.GoodsDetailResponse.GoodsDetails[0].CouponDiscount)).Div(decimal.NewFromInt(100)).Round(2)
+	outData.GoodsDetailResponse.GoodsDetails[0].Rebate = outData.GoodsDetailResponse.GoodsDetails[0].MinAmount.Mul(decimal.NewFromInt(outData.GoodsDetailResponse.GoodsDetails[0].PromotionRate)).Div(decimal.NewFromInt(1000)).Mul(decimal.NewFromFloat(0.55)).Round(2)
+
 	app.OK(c, outData, app.Success)
 }

+ 53 - 49
models/pdd/pdd.ddk.goods.detail.go

@@ -1,5 +1,7 @@
 package pdd
 
+import "github.com/shopspring/decimal"
+
 type PddDdkGoodsDetailRequest struct {
 	PddDdkBase
 	GoodsSign string `json:"goods_sign"`
@@ -11,55 +13,57 @@ type PddDdkGoodsDetailResponse struct {
 	GoodsDetailResponse GoodsDetailResponse `json:"goods_detail_response"`
 }
 type GoodsDetails struct {
-	CategoryName                string        `json:"category_name"`
-	CouponRemainQuantity        int           `json:"coupon_remain_quantity"`
-	PromotionRate               int           `json:"promotion_rate"`
-	ServiceTags                 []int         `json:"service_tags"`
-	MallID                      int           `json:"mall_id"`
-	MallName                    string        `json:"mall_name"`
-	MallCouponEndTime           int           `json:"mall_coupon_end_time"`
-	LgstTxt                     string        `json:"lgst_txt"`
-	GoodsName                   string        `json:"goods_name"`
-	GoodsGalleryUrls            []string      `json:"goods_gallery_urls"`
-	GoodsID                     int64         `json:"goods_id"`
-	BrandName                   string        `json:"brand_name"`
-	PredictPromotionRate        int           `json:"predict_promotion_rate"`
-	GoodsDesc                   string        `json:"goods_desc"`
-	OptName                     string        `json:"opt_name"`
-	ShareRate                   int           `json:"share_rate"`
-	OptIds                      []int         `json:"opt_ids"`
-	GoodsImageURL               string        `json:"goods_image_url"`
-	MallImgURL                  string        `json:"mall_img_url"`
-	HasMallCoupon               bool          `json:"has_mall_coupon"`
-	UnifiedTags                 []string      `json:"unified_tags"`
-	VideoUrls                   []interface{} `json:"video_urls"`
-	CouponStartTime             int           `json:"coupon_start_time"`
-	MinGroupPrice               int           `json:"min_group_price"`
-	CouponDiscount              int           `json:"coupon_discount"`
-	CouponEndTime               int           `json:"coupon_end_time"`
-	ZsDuoID                     int           `json:"zs_duo_id"`
-	MallCouponRemainQuantity    int           `json:"mall_coupon_remain_quantity"`
-	PlanType                    int           `json:"plan_type"`
-	CatIds                      []int         `json:"cat_ids"`
-	CouponMinOrderAmount        int           `json:"coupon_min_order_amount"`
-	CategoryID                  int           `json:"category_id"`
-	MallCouponDiscountPct       int           `json:"mall_coupon_discount_pct"`
-	CouponTotalQuantity         int           `json:"coupon_total_quantity"`
-	MallCouponMinOrderAmount    int           `json:"mall_coupon_min_order_amount"`
-	MerchantType                int           `json:"merchant_type"`
-	SalesTip                    string        `json:"sales_tip"`
-	OnlySceneAuth               bool          `json:"only_scene_auth"`
-	DescTxt                     string        `json:"desc_txt"`
-	GoodsThumbnailURL           string        `json:"goods_thumbnail_url"`
-	OptID                       int           `json:"opt_id"`
-	HasCoupon                   bool          `json:"has_coupon"`
-	MinNormalPrice              int           `json:"min_normal_price"`
-	MallCouponStartTime         int           `json:"mall_coupon_start_time"`
-	ServTxt                     string        `json:"serv_txt"`
-	MallCouponTotalQuantity     int           `json:"mall_coupon_total_quantity"`
-	MallCouponMaxDiscountAmount int           `json:"mall_coupon_max_discount_amount"`
-	MallCps                     int           `json:"mall_cps"`
-	GoodsSign                   string        `json:"goods_sign"`
+	CategoryName                string          `json:"category_name"`
+	CouponRemainQuantity        int             `json:"coupon_remain_quantity"`
+	PromotionRate               int64           `json:"promotion_rate"`
+	ServiceTags                 []int           `json:"service_tags"`
+	MallID                      int             `json:"mall_id"`
+	MallName                    string          `json:"mall_name"`
+	MallCouponEndTime           int             `json:"mall_coupon_end_time"`
+	LgstTxt                     string          `json:"lgst_txt"`
+	GoodsName                   string          `json:"goods_name"`
+	GoodsGalleryUrls            []string        `json:"goods_gallery_urls"`
+	GoodsID                     int64           `json:"goods_id"`
+	BrandName                   string          `json:"brand_name"`
+	PredictPromotionRate        int             `json:"predict_promotion_rate"`
+	GoodsDesc                   string          `json:"goods_desc"`
+	OptName                     string          `json:"opt_name"`
+	ShareRate                   int             `json:"share_rate"`
+	OptIds                      []int           `json:"opt_ids"`
+	GoodsImageURL               string          `json:"goods_image_url"`
+	MallImgURL                  string          `json:"mall_img_url"`
+	HasMallCoupon               bool            `json:"has_mall_coupon"`
+	UnifiedTags                 []string        `json:"unified_tags"`
+	VideoUrls                   []interface{}   `json:"video_urls"`
+	CouponStartTime             int             `json:"coupon_start_time"`
+	MinGroupPrice               int64           `json:"min_group_price"`
+	CouponDiscount              int64           `json:"coupon_discount"`
+	CouponEndTime               int             `json:"coupon_end_time"`
+	ZsDuoID                     int             `json:"zs_duo_id"`
+	MallCouponRemainQuantity    int             `json:"mall_coupon_remain_quantity"`
+	PlanType                    int             `json:"plan_type"`
+	CatIds                      []int           `json:"cat_ids"`
+	CouponMinOrderAmount        int             `json:"coupon_min_order_amount"`
+	CategoryID                  int             `json:"category_id"`
+	MallCouponDiscountPct       int             `json:"mall_coupon_discount_pct"`
+	CouponTotalQuantity         int             `json:"coupon_total_quantity"`
+	MallCouponMinOrderAmount    int             `json:"mall_coupon_min_order_amount"`
+	MerchantType                int             `json:"merchant_type"`
+	SalesTip                    string          `json:"sales_tip"`
+	OnlySceneAuth               bool            `json:"only_scene_auth"`
+	DescTxt                     string          `json:"desc_txt"`
+	GoodsThumbnailURL           string          `json:"goods_thumbnail_url"`
+	OptID                       int             `json:"opt_id"`
+	HasCoupon                   bool            `json:"has_coupon"`
+	MinNormalPrice              int             `json:"min_normal_price"`
+	MallCouponStartTime         int             `json:"mall_coupon_start_time"`
+	ServTxt                     string          `json:"serv_txt"`
+	MallCouponTotalQuantity     int             `json:"mall_coupon_total_quantity"`
+	MallCouponMaxDiscountAmount int             `json:"mall_coupon_max_discount_amount"`
+	MallCps                     int             `json:"mall_cps"`
+	GoodsSign                   string          `json:"goods_sign"`
+	MinAmount                   decimal.Decimal `json:"min_amount"`
+	Rebate                      decimal.Decimal `json:"rebate"`
 }
 type GoodsDetailResponse struct {
 	GoodsDetails []GoodsDetails `json:"goods_details"`