浏览代码

Merge branch 'develop' of k.zhang/duoduo into test

k.zhang 4 年之前
父节点
当前提交
611eb4e230
共有 2 个文件被更改,包括 69 次插入59 次删除
  1. 6 0
      apis/pdd/pdd.ddk.goods.search.go
  2. 63 59
      models/pdd/pdd.ddk.goods.search.go

+ 6 - 0
apis/pdd/pdd.ddk.goods.search.go

@@ -7,6 +7,7 @@ import (
 	"duoduo/tools/app"
 	"fmt"
 	"github.com/gin-gonic/gin"
+	"github.com/shopspring/decimal"
 
 	"time"
 )
@@ -64,6 +65,11 @@ func PddDdkGoodsSearch(c *gin.Context) {
 		return
 	}
 
+	for i := 0; i < len(outData.GoodsSearchResponse.GoodsList); i++ {
+		outData.GoodsSearchResponse.GoodsList[i].MinAmount = decimal.NewFromInt(outData.GoodsSearchResponse.GoodsList[i].MinGroupPrice).Sub(decimal.NewFromInt(outData.GoodsSearchResponse.GoodsList[i].CouponDiscount)).Div(decimal.NewFromInt(100)).Round(2)
+		outData.GoodsSearchResponse.GoodsList[i].Rebate = outData.GoodsSearchResponse.GoodsList[i].MinAmount.Mul(decimal.NewFromInt(outData.GoodsSearchResponse.GoodsList[i].PromotionRate)).Div(decimal.NewFromInt(1000)).Mul(decimal.NewFromFloat(0.6)).Round(2)
+	}
+
 	app.OK(c, outData, app.Success)
 
 }

+ 63 - 59
models/pdd/pdd.ddk.goods.search.go

@@ -1,5 +1,7 @@
 package pdd
 
+import "github.com/shopspring/decimal"
+
 type PddDdkGoodsSearchRequest struct {
 	ClientId     string `json:"client_id"`
 	Page         string `json:"page"`
@@ -19,65 +21,67 @@ type PddDdkGoodsSearchResponse struct {
 	GoodsSearchResponse GoodsSearchResponse `json:"goods_search_response"`
 }
 type GoodsList struct {
-	ActivityPromotionRate       int      `json:"activity_promotion_rate"`
-	ActivityTags                []int    `json:"activity_tags"`
-	ActivityType                int      `json:"activity_type"`
-	BrandName                   string   `json:"brand_name"`
-	CatIds                      []int    `json:"cat_ids"`
-	CltCpnBatchSn               string   `json:"clt_cpn_batch_sn"`
-	CltCpnDiscount              int      `json:"clt_cpn_discount"`
-	CltCpnEndTime               int      `json:"clt_cpn_end_time"`
-	CltCpnMinAmt                int      `json:"clt_cpn_min_amt"`
-	CltCpnQuantity              int      `json:"clt_cpn_quantity"`
-	CltCpnRemainQuantity        int      `json:"clt_cpn_remain_quantity"`
-	CltCpnStartTime             int      `json:"clt_cpn_start_time"`
-	CouponDiscount              int      `json:"coupon_discount"`
-	CouponEndTime               int      `json:"coupon_end_time"`
-	CouponMinOrderAmount        int      `json:"coupon_min_order_amount"`
-	CouponRemainQuantity        int      `json:"coupon_remain_quantity"`
-	CouponStartTime             int      `json:"coupon_start_time"`
-	CouponTotalQuantity         int      `json:"coupon_total_quantity"`
-	CreateAt                    int      `json:"create_at"`
-	DescTxt                     string   `json:"desc_txt"`
-	ExtraCouponAmount           int      `json:"extra_coupon_amount"`
-	GoodsDesc                   string   `json:"goods_desc"`
-	GoodsImageURL               string   `json:"goods_image_url"`
-	GoodsLabels                 []int    `json:"goods_labels"`
-	GoodsName                   string   `json:"goods_name"`
-	GoodsSign                   string   `json:"goods_sign"`
-	GoodsThumbnailURL           string   `json:"goods_thumbnail_url"`
-	HasCoupon                   bool     `json:"has_coupon"`
-	HasMallCoupon               bool     `json:"has_mall_coupon"`
-	LgstTxt                     string   `json:"lgst_txt"`
-	MallCouponDiscountPct       int      `json:"mall_coupon_discount_pct"`
-	MallCouponEndTime           int      `json:"mall_coupon_end_time"`
-	MallCouponID                int      `json:"mall_coupon_id"`
-	MallCouponMaxDiscountAmount int      `json:"mall_coupon_max_discount_amount"`
-	MallCouponMinOrderAmount    int      `json:"mall_coupon_min_order_amount"`
-	MallCouponRemainQuantity    int      `json:"mall_coupon_remain_quantity"`
-	MallCouponStartTime         int      `json:"mall_coupon_start_time"`
-	MallCouponTotalQuantity     int      `json:"mall_coupon_total_quantity"`
-	MallCps                     int      `json:"mall_cps"`
-	MallID                      int      `json:"mall_id"`
-	MallName                    string   `json:"mall_name"`
-	MerchantType                int      `json:"merchant_type"`
-	MinGroupPrice               int      `json:"min_group_price"`
-	MinNormalPrice              int      `json:"min_normal_price"`
-	OnlySceneAuth               bool     `json:"only_scene_auth"`
-	OptID                       int      `json:"opt_id"`
-	OptIds                      []int    `json:"opt_ids"`
-	OptName                     string   `json:"opt_name"`
-	PlanType                    int      `json:"plan_type"`
-	PredictPromotionRate        int      `json:"predict_promotion_rate"`
-	PromotionRate               int      `json:"promotion_rate"`
-	SalesTip                    string   `json:"sales_tip"`
-	SearchID                    string   `json:"search_id"`
-	ServTxt                     string   `json:"serv_txt"`
-	ServiceTags                 []int    `json:"service_tags"`
-	ShareRate                   int      `json:"share_rate"`
-	SubsidyAmount               int      `json:"subsidy_amount"`
-	UnifiedTags                 []string `json:"unified_tags"`
-	ZsDuoID                     int      `json:"zs_duo_id"`
+	ActivityPromotionRate       int             `json:"activity_promotion_rate"`
+	ActivityTags                []int           `json:"activity_tags"`
+	ActivityType                int             `json:"activity_type"`
+	BrandName                   string          `json:"brand_name"`
+	CatIds                      []int           `json:"cat_ids"`
+	CltCpnBatchSn               string          `json:"clt_cpn_batch_sn"`
+	CltCpnDiscount              int             `json:"clt_cpn_discount"`
+	CltCpnEndTime               int             `json:"clt_cpn_end_time"`
+	CltCpnMinAmt                int             `json:"clt_cpn_min_amt"`
+	CltCpnQuantity              int             `json:"clt_cpn_quantity"`
+	CltCpnRemainQuantity        int             `json:"clt_cpn_remain_quantity"`
+	CltCpnStartTime             int             `json:"clt_cpn_start_time"`
+	CouponDiscount              int64           `json:"coupon_discount"`
+	CouponEndTime               int             `json:"coupon_end_time"`
+	CouponMinOrderAmount        int             `json:"coupon_min_order_amount"`
+	CouponRemainQuantity        int             `json:"coupon_remain_quantity"`
+	CouponStartTime             int             `json:"coupon_start_time"`
+	CouponTotalQuantity         int             `json:"coupon_total_quantity"`
+	CreateAt                    int             `json:"create_at"`
+	DescTxt                     string          `json:"desc_txt"`
+	ExtraCouponAmount           int             `json:"extra_coupon_amount"`
+	GoodsDesc                   string          `json:"goods_desc"`
+	GoodsImageURL               string          `json:"goods_image_url"`
+	GoodsLabels                 []int           `json:"goods_labels"`
+	GoodsName                   string          `json:"goods_name"`
+	GoodsSign                   string          `json:"goods_sign"`
+	GoodsThumbnailURL           string          `json:"goods_thumbnail_url"`
+	HasCoupon                   bool            `json:"has_coupon"`
+	HasMallCoupon               bool            `json:"has_mall_coupon"`
+	LgstTxt                     string          `json:"lgst_txt"`
+	MallCouponDiscountPct       int             `json:"mall_coupon_discount_pct"`
+	MallCouponEndTime           int             `json:"mall_coupon_end_time"`
+	MallCouponID                int             `json:"mall_coupon_id"`
+	MallCouponMaxDiscountAmount int             `json:"mall_coupon_max_discount_amount"`
+	MallCouponMinOrderAmount    int             `json:"mall_coupon_min_order_amount"`
+	MallCouponRemainQuantity    int             `json:"mall_coupon_remain_quantity"`
+	MallCouponStartTime         int             `json:"mall_coupon_start_time"`
+	MallCouponTotalQuantity     int             `json:"mall_coupon_total_quantity"`
+	MallCps                     int             `json:"mall_cps"`
+	MallID                      int             `json:"mall_id"`
+	MallName                    string          `json:"mall_name"`
+	MerchantType                int             `json:"merchant_type"`
+	MinGroupPrice               int64           `json:"min_group_price"`
+	MinNormalPrice              int             `json:"min_normal_price"`
+	OnlySceneAuth               bool            `json:"only_scene_auth"`
+	OptID                       int             `json:"opt_id"`
+	OptIds                      []int           `json:"opt_ids"`
+	OptName                     string          `json:"opt_name"`
+	PlanType                    int             `json:"plan_type"`
+	PredictPromotionRate        int             `json:"predict_promotion_rate"`
+	PromotionRate               int64           `json:"promotion_rate"`
+	SalesTip                    string          `json:"sales_tip"`
+	SearchID                    string          `json:"search_id"`
+	ServTxt                     string          `json:"serv_txt"`
+	ServiceTags                 []int           `json:"service_tags"`
+	ShareRate                   int             `json:"share_rate"`
+	SubsidyAmount               int             `json:"subsidy_amount"`
+	UnifiedTags                 []string        `json:"unified_tags"`
+	ZsDuoID                     int             `json:"zs_duo_id"`
+	MinAmount                   decimal.Decimal `json:"min_amount"`
+	Rebate                      decimal.Decimal `json:"rebate"`
 }
 type GoodsSearchResponse struct {
 	GoodsList  []GoodsList `json:"goods_list"`