refactor:limit=>num

master
howell 3 years ago
parent 6ced74135d
commit 3ac25bca7d

@ -10,7 +10,6 @@ import (
"recook/internal/model/goods"
"recook/internal/model/promotion"
"recook/internal/model/shopping_trolley"
"recook/internal/v2/model/flashsale"
goods2 "recook/internal/v2/model/recook/goods"
"recook/internal/v2/model/recook/user"
"recook/tools"
@ -27,6 +26,7 @@ import (
type summaryParam struct {
UserID uint `json:"userID"`
GoodsID int64 `json:"goodsID" validate:"required"`
IsSale bool `json:"is_sale"`
}
type detailParam struct {
@ -66,6 +66,8 @@ type allPrice struct {
DiscountPrice decimal.Decimal `gorm:"column:discount_price" json:"discountPrice"`
Commission decimal.Decimal `gorm:"column:commission" json:"commission"`
PurchasePrice decimal.Decimal `gorm:"column:purchase_price" json:"purchasePrice"`
MinNum uint `gorm:"column:min_num" json:"min"`
LimitNum uint `gorm:"column:limit_num" json:"limit"`
}
type recommend struct {
@ -75,32 +77,11 @@ type recommend struct {
MainPhotoURL string `json:"mainPhotoUrl"`
}
type summaryResponse struct {
goods.Information
Inventory uint `gorm:"column:inventory" json:"inventory"`
SalesVolume uint `gorm:"column:sales_volume" json:"salesVolume"`
Price priceBorderSub `json:"price"`
Video *goods.Video `json:"video"`
Recommends []recommend `json:"recommends"`
MainPhotos []goods.MainPhoto `gorm:"column:mainPhotos" json:"mainPhotos"`
Attributes []attributeSub `gorm:"column:attributes" json:"attributes"`
Sku []goods.Sku `gorm:"column:sku" json:"sku"`
Promotion *promotion.Goods `gorm:"column:promotion" json:"promotion"`
Brand goods.Brand `gorm:"column:brand" json:"brand"`
Evaluations evaluationSub `gorm:"column:evaluations" json:"evaluations"`
Coupons []coupon.Information `gorm:"column:coupons" json:"coupons"`
IsFavorite bool `json:"isFavorite"`
ShoppingTrolleyCount int64 `gorm:"column:shopping_trolley_count" json:"shoppingTrolleyCount"`
Notice Notice `json:"notice"`
IsAllow bool `json:"isAllow"`
CountryIcon string `json:"country_icon"`
Live live `json:"living"`
SecKill SecKillDetail `json:"sec_kill"`
}
type summaryResponseNew struct {
goods.Information
Inventory uint `gorm:"column:inventory" json:"inventory"`
SalesVolume uint `gorm:"column:sales_volume" json:"salesVolume"`
SaleInventory uint `json:"sale_inventory"`
Price priceBorderSub `json:"price"`
Video *goods.Video `json:"video"`
Recommends []recommend `json:"recommends"`
@ -147,8 +128,9 @@ type momentsCopyResponse struct {
}
type salesInventory struct {
Inventory uint `gorm:"column:inventory" json:"inventory"`
SalesVolume uint `gorm:"column:sales_volume" json:"salesVolume"`
Inventory uint `gorm:"column:inventory" json:"inventory"`
SalesVolume uint `gorm:"column:sales_volume" json:"salesVolume"`
SaleInventory uint `gorm:"column:sale_inventory" json:"sale_inventory"`
}
type Goods struct {
@ -158,259 +140,6 @@ type Goods struct {
Price decimal.Decimal `json:"price"`
}
func QueryGoodsDetail(c *gin.Context) {
var p summaryParam
err := tools.ParseParams(&p, c)
if err != nil {
back.Fail(c, err.Error())
return
}
var summary summaryResponse
dbc.DB.Table((&goods.Information{}).TableName()).First(&summary, p.GoodsID)
///*
// 新增内容:商品下架则不显示
//*/
//if summary.PublishStatus == 0 {
// back.Fail(c, "您好,该商品已下架!")
// return
//}
var sv salesInventory
dbc.DB.Table((&goods.Sku{}).TableName()).Select("SUM(inventory) AS inventory, SUM(sales_volume) AS sales_volume").First(&sv, "goods_id = ?", p.GoodsID)
summary.SalesVolume = sv.SalesVolume
summary.Inventory = sv.Inventory
var minAllPrice allPrice
selectMinPriceStr := "MIN(original_price) AS original_price, " +
"MIN(discount_price) AS discount_price, " +
"MIN(commission) AS commission, " +
"MIN(purchase_price) AS purchase_price "
dbc.DB.Table((&goods.Sku{}).TableName()).Select(selectMinPriceStr).First(&minAllPrice, "goods_id = ?", p.GoodsID)
var maxAllPrice allPrice
selectMaxPriceStr := "MAX(original_price) AS original_price, " +
"MAX(discount_price) AS discount_price, " +
"MAX(commission) AS commission, " +
"MAX(purchase_price) AS purchase_price "
dbc.DB.Table((&goods.Sku{}).TableName()).Select(selectMaxPriceStr).First(&maxAllPrice, "goods_id = ?", p.GoodsID)
summary.Price = priceBorderSub{
priceSub{
OriginalPrice: minAllPrice.OriginalPrice,
DiscountPrice: minAllPrice.DiscountPrice,
Commission: minAllPrice.Commission,
},
priceSub{
OriginalPrice: maxAllPrice.OriginalPrice,
DiscountPrice: maxAllPrice.DiscountPrice,
Commission: maxAllPrice.Commission,
},
}
if summary.IsFerme == goods2.RecookGoodsInfoIsFermeTrue {
summary.Price.Min.Ferme = minAllPrice.PurchasePrice.Mul(decimal.NewFromFloat(1.2)).Mul(decimal.NewFromFloat(0.091)).Truncate(2)
summary.Price.Max.Ferme = maxAllPrice.PurchasePrice.Mul(decimal.NewFromFloat(1.2)).Mul(decimal.NewFromFloat(0.091)).Truncate(2)
}
summary.Recommends = fetchRecommends(p.GoodsID, summary.BrandID)
var video goods.Video
dbc.DB.Table((&goods.Video{}).TableName()).First(&(video), "goods_id = ?", p.GoodsID)
if video.ID > 0 {
summary.Video = &video
}
dbc.DB.Table((&goods.MainPhoto{}).TableName()).Order("order_no asc, is_master desc").Find(&(summary.MainPhotos), "goods_id = ? and is_master = 0", p.GoodsID)
dbc.DB.Table((&goods.Sku{}).TableName()).Find(&(summary.Sku), "goods_id = ?", p.GoodsID)
now := time.Now()
var promotionGoods promotion.Goods
dbc.DB.First(&promotionGoods, "goods_id = ? AND start_time <= ? AND end_time >= ?", p.GoodsID, now, now)
if promotionGoods.ID == 0 { //
dbc.DB.First(&promotionGoods, "goods_id = ? AND start_time >= ?", p.GoodsID, now)
}
// 排除活动商品的影响
// if promotionGoods.ID > 0 {
// var minPromSku promotion.Sku
// dbc.DB.Select("MIN(discount_price) AS discount_price, MIN(commission) AS commission").First(&minPromSku, "promotion_goods_id = ?", promotionGoods.ID)
// var maxPromSku promotion.Sku
// dbc.DB.Select("MAX(discount_price) AS discount_price, MAX(commission) AS commission").First(&maxPromSku, "promotion_goods_id = ?", promotionGoods.ID)
// summary.Promotion = &promotionGoods
// summary.Price.Min.DiscountPrice = minPromSku.DiscountPrice
// summary.Price.Min.Commission = minPromSku.Commission
// summary.Price.Max.DiscountPrice = maxPromSku.DiscountPrice
// summary.Price.Max.Commission = maxPromSku.Commission
// summary.SalesVolume = 0
// summary.Inventory = 0
// var promotionSku []promotion.Sku
// dbc.DB.Find(&promotionSku, "promotion_goods_id = ?", promotionGoods.ID)
// for i1, v1 := range summary.Sku {
// for _, v2 := range promotionSku {
// if v1.ID == v2.SkuID {
// summary.Sku[i1].DiscountPrice = v2.DiscountPrice
// summary.Sku[i1].Inventory = v2.Inventory
// summary.Sku[i1].SalesVolume = v2.SalesVolume
// summary.Sku[i1].Commission = v2.Commission
// summary.SalesVolume += v2.SalesVolume
// summary.Inventory += v2.Inventory
// }
// }
// }
// summary.Description = promotionGoods.Subtitle
// }
var gc goods.Category
dbc.DB.Table(gc.TableName()).First(&gc, "id = ?", summary.SecondCategoryID)
summary.IsAllow = gc.IsAllow
dbc.DB.Table((&goods.Brand{}).TableName()).First(&(summary.Brand), "id = ?", summary.BrandID)
var brandGoodsCount uint
// 品牌所有的商品种类数量, 需要过滤下架的类型
dbc.DB.Model(&goods.Information{}).Where("brand_id = ?", summary.BrandID).Where("publish_status = ?", 1).Count(&brandGoodsCount)
summary.Brand.GoodsCount = brandGoodsCount
var country goods2.RecookAbroadCountryModel
dbc.DB.Table(country.TableName()).First(&country, "id = ?", summary.Country)
summary.CountryIcon = country.Icon
var vo live
dbc.DB.Table("recook_live_live_item").Where("main_goods_id=?", summary.ID).Select("status,id as item_id").Order("id desc").First(&vo)
summary.Live = live{
Status: vo.Status,
RoomId: vo.RoomId,
}
dbc.DB.Table((&goods.Evaluation{}).TableName()).Where("goods_id = ? and pass=?", p.GoodsID, 1).Count(&(summary.Evaluations.Total))
dbc.DB.Table((&goods.Evaluation{}).TableName()).Limit(5).Find(&(summary.Evaluations.Children), "goods_id = ? and pass=?", p.GoodsID, 1)
dbc.DB.Table((&goods.Attribute{}).TableName()).Select("name").Group("name").Find(&(summary.Attributes), "goods_id = ?", p.GoodsID)
for i, v := range summary.Attributes {
dbc.DB.Table((&goods.Attribute{}).TableName()).Select("id, value").Find(&(summary.Attributes[i].Children), "goods_id = ? AND name = ?", p.GoodsID, v.Name)
}
// 找优惠券
dbc.DB.Table((&coupon.Information{}).TableName()).Limit(2).Order("id desc").Find(&(summary.Coupons), "((scope = ?) OR (scope = ? AND brand_id = ?)) AND end_time > ?", define.CouponScopeUniversal, define.CouponScopeBrand, summary.BrandID, now)
if p.UserID > 0 {
var f goods.Favorites
dbc.DB.First(&f, "user_id = ? AND goods_id = ?", p.UserID, p.GoodsID)
summary.IsFavorite = f.ID > 0
type cnt struct {
ShoppingTrolleyCount int64 `gorm:"column:shopping_trolley_count" json:"shoppingTrolleyCount"`
}
var cntStruct cnt
dbc.DB.Table((&shopping_trolley.Information{}).TableName()).Select("SUM(quantity) AS shopping_trolley_count").Where("user_id = ?", p.UserID).First(&cntStruct)
summary.ShoppingTrolleyCount = cntStruct.ShoppingTrolleyCount
}
recookGoodsNoticeGoodsModel := &goods2.RecookGoodsNoticeGoodsModel{}
noticeGoods := recookGoodsNoticeGoodsModel.FindByGoodsId(summary.ID)
if noticeGoods.Id > 0 {
recookGoodsNoticeModel := &goods2.RecookGoodsNoticeModel{}
noticeInfo := recookGoodsNoticeModel.FindById(noticeGoods.NoticeId)
now := time.Now().Unix()
if noticeInfo.Id > 0 && now > noticeInfo.StartTime.Time.Unix() && now < noticeInfo.EndTime.Time.Unix() {
summary.Notice.Title = noticeInfo.Title
summary.Notice.Img = noticeInfo.Img
summary.Notice.Type = noticeInfo.Type
}
}
//新增秒杀模块拦截判断
var seckill flashsale.RecookSecKillModel
mysql2.Db.Table(seckill.TableName()).Where("activity_start_time<?", now).Where("activity_end_time>?", now).Where("status=2").First(&seckill)
//获取当前时间段的商品
now2 := time.Date(0, 1, 1, now.Hour(), now.Minute(), now.Second(), 0, time.Local)
var secgoods []flashsale.RecookSecKillSortModel
mysql2.Db.Table((&flashsale.RecookSecKillSortModel{}).TableName()).Where("show_time_start<?", now2).Where("show_time_end>?", now2).Where("sec_kill_activity_id=?", seckill.Id).Where("goods_id=?", summary.ID).Find(&secgoods)
//若该商品在秒杀中,则,重新赋值
if len(secgoods) > 0 {
//秒杀价格
var mp = make(map[uint]flashsale.RecookSecKillGoodsModel)
var sl []flashsale.RecookSecKillGoodsModel
mysql2.Db.Table((&flashsale.RecookSecKillGoodsModel{}).TableName()).Where("sec_kill_activity_id=?", seckill.Id).Where("goods_id=?", summary.ID).Find(&sl)
for _, v := range sl {
mp[v.GoodsSkuId] = v
}
for i, sku := range summary.Sku {
if _, ok := mp[sku.ID]; ok {
summary.Sku[i].DiscountPrice = mp[sku.ID].SecKillDiscountPrice
summary.Sku[i].Commission = mp[sku.ID].SecKillDiscountPrice.Mul(mp[sku.ID].SecKillCommissionRate).Truncate(2)
} else {
summary.Sku[i] = goods.Sku{}
}
}
summary.SecKill.SecKill = 1
summary.SecKill.SecKillEndTime = secgoods[0].ShowTimeEnd.Format("15:04:05")
var newsku []goods.Sku
minPrice := summary.Sku[0].DiscountPrice
maxCom := summary.Sku[0].Commission
for _, v := range summary.Sku {
if v.ID > 0 {
newsku = append(newsku, v)
if v.DiscountPrice.LessThan(minPrice) {
minPrice = v.DiscountPrice
}
if v.Commission.GreaterThan(maxCom) {
maxCom = v.Commission
}
} else {
continue
}
}
summary.SecKill.SecKillCommission = maxCom
summary.SecKill.SecKillMinPrice = minPrice
summary.Sku = newsku
for i, v := range summary.Attributes {
for i2, j := range v.Children {
if _, ok := mp[j.ID]; ok {
} else {
summary.Attributes[i].Children[i2] = goods.Attribute{}
}
}
}
var newat []attributeSub
for _, v := range summary.Attributes {
var newattri []goods.Attribute
for _, j := range v.Children {
if j.ID > 0 {
newattri = append(newattri, j)
} else {
continue
}
}
newat = append(newat, attributeSub{
Name: v.Name,
Children: newattri,
})
}
summary.Attributes = newat
//判断结束
}
back.Suc(c, "操作成功", &summary)
rankings := goods.HotSellRankings{
GoodsId: uint(p.GoodsID),
FirstCategoryID: summary.FirstCategoryID,
SecondCategoryID: summary.SecondCategoryID,
Date: formatime.NewDateNow(),
}
dbc.DB.FirstOrCreate(&rankings, "date = ? AND goods_id = ?", now.Format("2006-01-02"), p.GoodsID)
dbc.DB.Model(&rankings).Updates(goods.HotSellRankings{
Clicks: rankings.Clicks + 1,
})
dbc.DB.Table("recook_app_user_history").Create(&user.RecookAppUserHistory{
GoodsID: p.GoodsID,
UserID: p.UserID,
})
}
func fetchRecommends(goodsId int64, brandId uint) []recommend {
var goodsList []goods.Information
sql := fmt.Sprintf(" SELECT `id`,`goods_name` FROM `recook_goods_info` WHERE id >= (SELECT floor(RAND() * (SELECT MAX(id) FROM `recook_goods_info` WHERE brand_id = %d))) ORDER BY id LIMIT 7;", brandId)
@ -459,7 +188,7 @@ func fetchRecommends(goodsId int64, brandId uint) []recommend {
return list
}
type GoodsDetailImg struct {
type DetailImg struct {
List []goods.DetailPhoto `json:"list"`
Brand goods.Brand `json:"brand"`
}
@ -492,7 +221,7 @@ func QueryGoodsPhotosDetail(c *gin.Context) {
back.Err(c, err.Error())
return
}
var gd = GoodsDetailImg{
var gd = DetailImg{
List: list,
Brand: brand,
}
@ -546,6 +275,7 @@ func QueryGoodsMomentsCopy(c *gin.Context) {
back.Suc(c, "操作成功", &list)
}
func QueryGoodsDetailNew(c *gin.Context) {
var p summaryParam
err := tools.ParseParams(&p, c)
@ -573,22 +303,28 @@ func QueryGoodsDetailNew(c *gin.Context) {
dbc.DB.Table((&goods.Information{}).TableName()).First(&summary, p.GoodsID)
var sv salesInventory
dbc.DB.Table((&goods.Sku{}).TableName()).Select("SUM(inventory) AS inventory, SUM(sales_volume) AS sales_volume").First(&sv, "goods_id = ?", p.GoodsID)
dbc.DB.Table((&goods.Sku{}).TableName()).Select("SUM(inventory) AS inventory, SUM(sales_volume) AS sales_volume, SUM(sale_inventory) AS sale_inventory").
First(&sv, "goods_id = ?", p.GoodsID)
summary.SalesVolume = sv.SalesVolume
summary.Inventory = sv.Inventory
summary.SaleInventory = sv.SaleInventory
var minAllPrice allPrice
selectMinPriceStr := "MIN(original_price) AS original_price, " +
"MIN(discount_price) AS discount_price, " +
"MIN(commission) AS commission, " +
"MIN(purchase_price) AS purchase_price "
"MIN(purchase_price) AS purchase_price " +
"MIN(min_num) AS min_num " +
"MIN(limit_num) AS limit_num "
dbc.DB.Table((&goods.Sku{}).TableName()).Select(selectMinPriceStr).First(&minAllPrice, "goods_id = ?", p.GoodsID)
var maxAllPrice allPrice
selectMaxPriceStr := "MAX(original_price) AS original_price, " +
"MAX(discount_price) AS discount_price, " +
"MAX(commission) AS commission, " +
"MAX(purchase_price) AS purchase_price "
"MAX(purchase_price) AS purchase_price " +
"MAX(min_num) AS min_num " +
"MAX(limit_num) AS limit_num "
dbc.DB.Table((&goods.Sku{}).TableName()).Select(selectMaxPriceStr).First(&maxAllPrice, "goods_id = ?", p.GoodsID)
minCost := minAllPrice.PurchasePrice.Mul(decimal.NewFromFloat(1.03))
@ -615,11 +351,13 @@ func QueryGoodsDetailNew(c *gin.Context) {
Commission: maxCommission1.Add(maxCommission2).Add(maxCommission3),
},
}
if summary.IsFerme == goods2.RecookGoodsInfoIsFermeTrue {
summary.Price.Min.Ferme = minAllPrice.PurchasePrice.Mul(decimal.NewFromFloat(1.2)).Mul(decimal.NewFromFloat(0.091)).Truncate(2)
summary.Price.Max.Ferme = maxAllPrice.PurchasePrice.Mul(decimal.NewFromFloat(1.2)).Mul(decimal.NewFromFloat(0.091)).Truncate(2)
//if summary.IsFerme == goods2.RecookGoodsInfoIsFermeTrue {
// summary.Price.Min.Ferme = minAllPrice.PurchasePrice.Mul(decimal.NewFromFloat(1.2)).Mul(decimal.NewFromFloat(0.091)).Truncate(2)
// summary.Price.Max.Ferme = maxAllPrice.PurchasePrice.Mul(decimal.NewFromFloat(1.2)).Mul(decimal.NewFromFloat(0.091)).Truncate(2)
//}
if !p.IsSale {
summary.Recommends = fetchRecommends(p.GoodsID, summary.BrandID)
}
summary.Recommends = fetchRecommends(p.GoodsID, summary.BrandID)
var video goods.Video
dbc.DB.Table((&goods.Video{}).TableName()).First(&(video), "goods_id = ?", p.GoodsID)
@ -654,26 +392,26 @@ func QueryGoodsDetailNew(c *gin.Context) {
dbc.DB.Model(&goods.Information{}).Where("brand_id = ?", summary.BrandID).Where("publish_status = ?", 1).Count(&brandGoodsCount)
summary.Brand.GoodsCount = brandGoodsCount
var country goods2.RecookAbroadCountryModel
dbc.DB.Table(country.TableName()).First(&country, "id = ?", summary.Country)
summary.CountryIcon = country.Icon
//var country goods2.RecookAbroadCountryModel
//dbc.DB.Table(country.TableName()).First(&country, "id = ?", summary.Country)
//summary.CountryIcon = country.Icon
var vo live
dbc.DB.Table("recook_live_live_item").Where("main_goods_id=?", summary.ID).Select("status,id as item_id").Order("id desc").First(&vo)
summary.Live = live{
Status: vo.Status,
RoomId: vo.RoomId,
}
//var vo live
//dbc.DB.Table("recook_live_live_item").Where("main_goods_id=?", summary.ID).Select("status,id as item_id").Order("id desc").First(&vo)
//summary.Live = live{
// Status: vo.Status,
// RoomId: vo.RoomId,
//}
dbc.DB.Table((&goods.Evaluation{}).TableName()).Where("goods_id = ? and pass=?", p.GoodsID, 1).Count(&(summary.Evaluations.Total))
dbc.DB.Table((&goods.Evaluation{}).TableName()).Limit(5).Find(&(summary.Evaluations.Children), "goods_id = ? and pass=?", p.GoodsID, 1)
//dbc.DB.Table((&goods.Evaluation{}).TableName()).Where("goods_id = ? and pass=?", p.GoodsID, 1).Count(&(summary.Evaluations.Total))
//dbc.DB.Table((&goods.Evaluation{}).TableName()).Limit(5).Find(&(summary.Evaluations.Children), "goods_id = ? and pass=?", p.GoodsID, 1)
dbc.DB.Table((&goods.Attribute{}).TableName()).Select("name").Group("name").Find(&(summary.Attributes), "goods_id = ?", p.GoodsID)
for i, v := range summary.Attributes {
dbc.DB.Table((&goods.Attribute{}).TableName()).Select("id, value").Find(&(summary.Attributes[i].Children), "goods_id = ? AND name = ?", p.GoodsID, v.Name)
}
// 找优惠券
dbc.DB.Table((&coupon.Information{}).TableName()).Limit(2).Order("id desc").Find(&(summary.Coupons), "((scope = ?) OR (scope = ? AND brand_id = ?)) AND end_time > ?", define.CouponScopeUniversal, define.CouponScopeBrand, summary.BrandID, now)
//dbc.DB.Table((&coupon.Information{}).TableName()).Limit(2).Order("id desc").Find(&(summary.Coupons), "((scope = ?) OR (scope = ? AND brand_id = ?)) AND end_time > ?", define.CouponScopeUniversal, define.CouponScopeBrand, summary.BrandID, now)
if p.UserID > 0 {
var f goods.Favorites
@ -703,79 +441,6 @@ func QueryGoodsDetailNew(c *gin.Context) {
}
}
//新增秒杀模块拦截判断
//var seckill flashsale.RecookSecKillModel
//mysql2.Db.Table(seckill.TableName()).Where("activity_start_time<?", now).Where("activity_end_time>?", now).Where("status=2").First(&seckill)
//获取当前时间段的商品
//now2 := time.Date(0, 1, 1, now.Hour(), now.Minute(), now.Second(), 0, time.Local)
//var secgoods []flashsale.RecookSecKillSortModel
//mysql2.Db.Table((&flashsale.RecookSecKillSortModel{}).TableName()).Where("show_time_start<?", now2).Where("show_time_end>?", now2).Where("sec_kill_activity_id=?", seckill.Id).Where("goods_id=?", summary.ID).Find(&secgoods)
//若该商品在秒杀中,则,重新赋值
//if len(secgoods) > 0 {
// //秒杀价格
// var mp = make(map[uint]flashsale.RecookSecKillGoodsModel)
// var sl []flashsale.RecookSecKillGoodsModel
// mysql2.Db.Table((&flashsale.RecookSecKillGoodsModel{}).TableName()).Where("sec_kill_activity_id=?", seckill.Id).Where("goods_id=?", summary.ID).Find(&sl)
// for _, v := range sl {
// mp[v.GoodsSkuId] = v
// }
// for i, sku := range summary.Sku {
// if _, ok := mp[sku.ID]; ok {
// summary.Sku[i].DiscountPrice = mp[sku.ID].SecKillDiscountPrice
// summary.Sku[i].Commission = mp[sku.ID].SecKillDiscountPrice.Mul(mp[sku.ID].SecKillCommissionRate).Truncate(2)
// } else {
// summary.Sku[i] = goods.Sku{}
// }
//
// }
// summary.SecKill.SecKill = 1
// summary.SecKill.SecKillEndTime = secgoods[0].ShowTimeEnd.Format("15:04:05")
// var newsku []goods.Sku
// minPrice := summary.Sku[0].DiscountPrice
// maxCom := summary.Sku[0].Commission
// for _, v := range summary.Sku {
// if v.ID > 0 {
// newsku = append(newsku, v)
// if v.DiscountPrice.LessThan(minPrice) {
// minPrice = v.DiscountPrice
// }
// if v.Commission.GreaterThan(maxCom) {
// maxCom = v.Commission
// }
// } else {
// continue
// }
// }
// summary.SecKill.SecKillCommission = maxCom
// summary.SecKill.SecKillMinPrice = minPrice
// summary.Sku = newsku
// for i, v := range summary.Attributes {
// for i2, j := range v.Children {
// if _, ok := mp[j.ID]; ok {
// } else {
// summary.Attributes[i].Children[i2] = goods.Attribute{}
// }
// }
// }
// var newat []attributeSub
// for _, v := range summary.Attributes {
// var newattri []goods.Attribute
// for _, j := range v.Children {
// if j.ID > 0 {
// newattri = append(newattri, j)
// } else {
// continue
// }
// }
// newat = append(newat, attributeSub{
// Name: v.Name,
// Children: newattri,
// })
// }
// summary.Attributes = newat
// //判断结束
//}
back.Suc(c, "操作成功", &summary)
rankings := goods.HotSellRankings{
GoodsId: uint(p.GoodsID),

@ -249,7 +249,7 @@ func SetupRouter(v1 *gin.RouterGroup) {
goodsR.POST("/digital/list", goods.QueryDigital)
goodsR.POST("/home_live/list", goods.QueryHomeLive)
goodsR.POST("/detail/summary", goods.QueryGoodsDetail) // 获取商品基本信息详情
//goodsR.POST("/detail/summary", goods.QueryGoodsDetail) // 获取商品基本信息详情
goodsR.POST("/detail/summary_new", goods.QueryGoodsDetailNew) // 获取商品基本信息详情_new
goodsR.POST("/detail/photo", goods.QueryGoodsPhotosDetail) // 获取商品图片详情
goodsR.POST("/detail/moments_copy/list", goods.QueryGoodsMomentsCopy) // 获取商品发圈文案列表

@ -23,8 +23,8 @@ func (o logic) UpdateSale(args ArgsSaleUpdate) error {
for _, v := range args.SkuList {
if err := tx.Table((&goods.RecookGoodsSkuModel{}).TableName()).Where("id = ?", v.SkuID).Updates(goods.RecookGoodsSkuModel{
SaleInventory: v.Inventory,
Min: int(v.Min),
Limit: int(v.Limit),
MinNum: int(v.Min),
LimitNum: int(v.Limit),
}).Error; err != nil {
return err
}

@ -47,8 +47,8 @@ type RecookGoodsSkuModel struct {
Width float64 `json:"width"`
Height float64 `json:"height"`
Weight float64 `json:"weight"`
Limit int `json:"limie"`
Min int `json:"min"`
LimitNum int `json:"limit_num"`
MinNum int `json:"min_num"`
SaleInventory uint `json:"sale_inventory"`
}

Loading…
Cancel
Save