diff --git a/internal/api/mobile/goods/common_list.go b/internal/api/mobile/goods/common_list.go index aa3b0fc..5ace035 100755 --- a/internal/api/mobile/goods/common_list.go +++ b/internal/api/mobile/goods/common_list.go @@ -406,13 +406,13 @@ func GetGoodsRespByInfoList(goodsList []goods.Information, userID uint) []QueryC "MIN(commission) AS commission,"+ "MIN(coupon) AS coupon").Group("goods_id"). First(&sku, "goods_id = ?", v.ID) - var inventory uint - var percent uint + //var inventory uint + //var percent uint var startTime = formatime.Second{} var endTime = formatime.Second{} - inventory = sku.Inventory //sku库存,这个其实用不到的 + inventory := sku.Inventory //sku库存,这个其实用不到的 salesVolume := v.SalesVolume //这个用主产品的已卖 discountPrice := sku.DiscountPrice //sku 价格 commission := sku.Commission //sku佣金 @@ -423,14 +423,12 @@ func GetGoodsRespByInfoList(goodsList []goods.Information, userID uint) []QueryC dbc.DB.Select("id, promotion_name, start_time, end_time").First(&promotionGoods, "goods_id = ? AND start_time <= ? AND end_time >= ?", v.ID, now, now) if promotionGoods.ID > 0 { var promotionSku promotion.Sku - dbc.DB.Select("SUM(inventory) AS inventory, SUM(sales_volume) AS sales_volume, discount_price,commission").First(&promotionSku, "promotion_goods_id = ?", promotionGoods.ID) + dbc.DB.Select("SUM(inventory) AS inventory, SUM(sales_volume) AS sales_volume, discount_price,commission"). + Group("promotion_goods_id").First(&promotionSku, "promotion_goods_id = ?", promotionGoods.ID) discountPrice = promotionSku.DiscountPrice //活动的价格 commission = promotionSku.Commission //活动的佣金 inventory = promotionSku.Inventory //活动的库存 - //salesVolume = promotionSku.SalesVolume //活动的销量 - //计算% - //percent = uint(promotionSku.SalesVolume / (inventory + promotionSku.SalesVolume) * 100) startTime = promotionGoods.StartTime endTime = promotionGoods.EndTime // 打上特卖标签 @@ -440,16 +438,9 @@ func GetGoodsRespByInfoList(goodsList []goods.Information, userID uint) []QueryC if promotionGoods.ID > 0 { var promotionSku promotion.Sku dbc.DB.Select("MIN(discount_price) AS discount_price, MIN(commission) AS commission").Find(&promotionSku, "promotion_goods_id = ?", promotionGoods.ID) - - //inventory = promotionSku.Inventory //活动的库存 - //salesVolume = promotionSku.SalesVolume //活动的销量 - //discountPrice = promotionSku.DiscountPrice //活动的价格 - //commission = promotionSku.Commission //活动的佣金 startTime = promotionGoods.StartTime endTime = promotionGoods.EndTime - } - } // 查看是否是 新人特惠 商品 @@ -481,7 +472,7 @@ func GetGoodsRespByInfoList(goodsList []goods.Information, userID uint) []QueryC DiscountPrice: discountPrice, Commission: commission, Tags: tags, - Percent: percent, //百分比,-1不显示 + Percent: 0, //百分比,-1不显示 StartTime: startTime, EndTime: endTime, Coupon: sku.Coupon, diff --git a/internal/api/mobile/goods/promotion_list.go b/internal/api/mobile/goods/promotion_list.go index 5579fc0..67fc2ca 100755 --- a/internal/api/mobile/goods/promotion_list.go +++ b/internal/api/mobile/goods/promotion_list.go @@ -9,6 +9,7 @@ import ( "recook/internal/model/goods" "recook/internal/model/promotion" goods2 "recook/internal/v2/model/recook/goods" + user2 "recook/internal/v2/model/recook/user" "recook/internal/v2/model/special_sale" "recook/tools" "strconv" @@ -21,6 +22,7 @@ import ( type queryPromotionGoodsParam struct { TimeItemID uint `json:"timeItemID" validate:"required"` + UserID uint `json:"user_id"` } type promotionTimeItemResp struct { @@ -256,6 +258,17 @@ func QueryPromotionGoodsList(c *gin.Context) { back.Fail(c, err.Error()) return } + var u user2.RecookUserInfoModel + dbc.DB.First(&u, "id = ?", p.UserID) + rate := decimal.Zero + { + switch u.Level { + case 1: + rate = decimal.NewFromFloat(0.4) + case 2: + rate = decimal.NewFromFloat(0.7) + } + } //p.TimeItemID=1275 var promotionGoodsList []promotion.Goods @@ -349,7 +362,7 @@ func QueryPromotionGoodsList(c *gin.Context) { Price: goodsSku.DiscountPrice, //打折 PrimePrice: goodsSku.OriginalPrice, //卷后 PriceDesc: goodsSku.DiscountPrice.String(), - Commission: goodsSku.Commission, + Commission: goodsSku.DiscountPrice.Sub(goodsSku.PurchasePrice).Mul(rate), CommissionDesc: "赚" + goodsSku.Commission.String(), Picture: pic, Inventory: inventory, @@ -387,15 +400,15 @@ func QueryPromotionGoodsList(c *gin.Context) { 在原有的gList上查询该goodsId是否在直播,有就添加直播表示 */ - for i, k := range gList { - var vo live - dbc.DB.Table("recook_live_live_item").Where("main_goods_id=?", k.GoodsID).Select("status").Order("id desc").First(&vo) - if vo.Status == 1 { - gList[i].Living.Status = 1 - gList[i].Living.RoomId = vo.RoomId - } - - } + //for i, k := range gList { + // var vo live + // dbc.DB.Table("recook_live_live_item").Where("main_goods_id=?", k.GoodsID).Select("status").Order("id desc").First(&vo) + // if vo.Status == 1 { + // gList[i].Living.Status = 1 + // gList[i].Living.RoomId = vo.RoomId + // } + // + //} /* 新增:前五条新增特外图标,该功能暂时关闭 */ @@ -443,11 +456,6 @@ func QueryPromotionGoodsList(c *gin.Context) { gList[i].SpecialSale = spList } - fmt.Println(promotionList{ - GoodsList: gList, - ActivityList: aList, - }) - back.Suc(c, "", &promotionList{ GoodsList: gList, ActivityList: aList,