@ -125,6 +125,8 @@ type salesInventory struct {
SalesVolume uint ` gorm:"column:sales_volume" json:"salesVolume" `
SaleInventory uint ` gorm:"column:sale_inventory" json:"sale_inventory" `
SalesVolumeInc uint ` gorm:"column:sales_volume_inc" json:"sales_volume_inc" `
SaleVolume2 uint ` gorm:"column:sale_volume2" json:"salesVolume2" `
SaleVolumeInc2 uint ` gorm:"column:sale_volume_inc2" json:"sales_volume_inc2" `
}
type Goods struct {
@ -279,27 +281,17 @@ func QueryGoodsDetailNew(c *gin.Context) {
}
var u1 user . RecookUserInfoModel
mysql2 . Db . Find ( & u1 , "id = ?" , p . UserID )
//rate1 := decimal.Zero
//rate2 := decimal.Zero
//rate3 := decimal.Zero
//
//if u1.Level == 1 {
// rate1 = decimal.NewFromFloat32(0.4)
// rate2 = decimal.NewFromFloat32(0.1)
//}
//if u1.Level == 2 {
// rate1 = decimal.NewFromFloat32(0.4)
// rate2 = decimal.NewFromFloat32(0.1)
// rate3 = decimal.NewFromFloat(0.2)
//}
var summary summaryResponseNew
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, SUM(sales_volume_inc) AS sales_volume_inc,SUM(sale_inventory) AS sale_inventory") .
dbc . DB . Table ( ( & goods . Sku { } ) . TableName ( ) ) . Select ( "SUM(inventory) AS inventory, SUM(sales_volume) AS sales_volume, SUM(sale_volume2) AS sale_volume2, SUM(sale_volume_inc2) AS sale_volume_inc2, SUM(sales_volume_inc) AS sales_volume_inc,SUM(sale_inventory) AS sale_inventory" ) .
First ( & sv , "goods_id = ?" , p . GoodsID )
summary . SalesVolume = sv . SalesVolume + sv . SalesVolumeInc
if p . IsSale {
summary . SalesVolume = sv . SaleVolume2 + sv . SaleVolumeInc2
}
summary . Inventory = sv . Inventory
summary . SaleInventory = sv . SaleInventory
@ -325,26 +317,6 @@ func QueryGoodsDetailNew(c *gin.Context) {
dbc . DB . Table ( ( & goods . Sku { } ) . TableName ( ) ) . Select ( selectMaxPriceStr ) . First ( & maxAllPrice , "goods_id = ?" , p . GoodsID )
maxAllPrice . SalePrice = maxAllPrice . GetSalePrice ( u1 . Level )
// minCost := minAllPrice.PurchasePrice.Mul(decimal.NewFromFloat(1.03))
// minBase := minAllPrice.DiscountPrice.Sub(minCost).Mul(decimal.NewFromFloat(define.Coefficient)).Round(2)
//minBase := minAllPrice.Commission
//
//minCommission1 := minBase.Mul(rate1).Round(2)
//minCommission2 := minBase.Mul(rate2).Round(2)
//minCommission3 := minBase.Mul(rate3).Round(2)
// maxBase := maxAllPrice.DiscountPrice.Sub(minCost).Mul(decimal.NewFromFloat(define.Coefficient)).Round(2)
//maxBase := maxAllPrice.Commission
//maxCommission1 := maxBase.Mul(rate1).Round(2)
//maxCommission2 := maxBase.Mul(rate2).Round(2)
//maxCommission3 := maxBase.Mul(rate3).Round(2)
//minCommission := minAllPrice.GetSelfProfit(u1.Level)
//maxCommission := maxAllPrice.GetSelfProfit(u1.Level)
//if u1.Level == 10 {
// minCommission = minAllPrice.DiscountPrice.Sub(minAllPrice.PurchasePrice.Mul(decimal.NewFromFloat(1.03))).Mul(decimal.NewFromFloat(define.Coefficient)).Round(2)
// maxCommission = maxAllPrice.DiscountPrice.Sub(maxAllPrice.PurchasePrice.Mul(decimal.NewFromFloat(1.03))).Mul(decimal.NewFromFloat(define.Coefficient)).Round(2)
//}
minCommission := minAllPrice . GetSelfProfit ( u1 . Level )
maxCommission := maxAllPrice . GetSelfProfit ( u1 . Level )
@ -366,10 +338,7 @@ func QueryGoodsDetailNew(c *gin.Context) {
Limit : minAllPrice . Limit ,
} ,
}
//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 )
}
@ -384,23 +353,15 @@ func QueryGoodsDetailNew(c *gin.Context) {
dbc . DB . Table ( ( & goods . Sku { } ) . TableName ( ) ) . Find ( & ( summary . Sku ) , "goods_id = ?" , p . GoodsID )
for index , v := range summary . Sku {
//skb := v.GetBase()
//sc1 := skb.Mul(rate1).Round(2)
//sc2 := skb.Mul(rate2).Round(2)
//sc3 := skb.Mul(rate3).Round(2)
summary . Sku [ index ] . Commission = v . GetSelfProfit ( u1 . Level )
//if u1.Level == 10 {
// commission := v.DiscountPrice.Sub(v.PurchasePrice.Mul(decimal.NewFromFloat(1.03))).Mul(decimal.NewFromFloat(define.Coefficient)).Round(2)
// summary.Sku[index].Commission = commission
//}
summary . Sku [ index ] . SalePrice = v . GetSalePrice ( u1 . Level )
}
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 )
}
//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)
//}
var gc goods . Category
dbc . DB . Table ( gc . TableName ( ) ) . First ( & gc , "id = ?" , summary . SecondCategoryID )