|
|
|
@ -2,12 +2,6 @@ package goods
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"fmt"
|
|
|
|
|
mysql2 "git.oa00.com/go/mysql"
|
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
|
"github.com/golangkit/formatime"
|
|
|
|
|
"github.com/shopspring/decimal"
|
|
|
|
|
gorm2 "gorm.io/gorm"
|
|
|
|
|
"gorm.io/gorm/clause"
|
|
|
|
|
"recook/internal/back"
|
|
|
|
|
"recook/internal/cache"
|
|
|
|
|
"recook/internal/dbc"
|
|
|
|
@ -20,7 +14,15 @@ import (
|
|
|
|
|
"recook/internal/v2/model/recook/user"
|
|
|
|
|
"recook/tools"
|
|
|
|
|
"strconv"
|
|
|
|
|
"strings"
|
|
|
|
|
"time"
|
|
|
|
|
|
|
|
|
|
mysql2 "git.oa00.com/go/mysql"
|
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
|
"github.com/golangkit/formatime"
|
|
|
|
|
"github.com/shopspring/decimal"
|
|
|
|
|
gorm2 "gorm.io/gorm"
|
|
|
|
|
"gorm.io/gorm/clause"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type queryOrderGoodsListParam struct {
|
|
|
|
@ -190,12 +192,6 @@ func QueryGoodsListByComprehension(c *gin.Context) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
findByKeyWord(q3, p.Keyword, &goodsList)
|
|
|
|
|
//if p.Kind == 0 {
|
|
|
|
|
// if len(goodsList) < 20 && p.Page == 0 && p.Keyword != "" {
|
|
|
|
|
// goodsList = getFillList(c, goodsList, "")
|
|
|
|
|
// }
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
back.Suc(c, "", GetGoodsRespByInfoList(goodsList, p.UserId))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -380,15 +376,7 @@ func QueryGoodsListByDiscountPrice(c *gin.Context) {
|
|
|
|
|
|
|
|
|
|
// GetGoodsRespByInfoList ==============================================================
|
|
|
|
|
func GetGoodsRespByInfoList(goodsList []goods.Information, userID uint) []QueryCategoryGoodsListResp {
|
|
|
|
|
list := make([]QueryCategoryGoodsListResp, 0, 0)
|
|
|
|
|
//新增进口专区国家图标
|
|
|
|
|
var iconList []goods2.RecookAbroadCountryModel
|
|
|
|
|
dbc.DB.Table((&goods2.RecookAbroadCountryModel{}).TableName()).Find(&iconList)
|
|
|
|
|
var countryMap = make(map[uint]string)
|
|
|
|
|
countryMap[0] = ""
|
|
|
|
|
for _, v := range iconList {
|
|
|
|
|
countryMap[v.ID] = v.Icon
|
|
|
|
|
}
|
|
|
|
|
list := make([]QueryCategoryGoodsListResp, 0)
|
|
|
|
|
var u user.RecookUserInfoModel
|
|
|
|
|
mysql2.Db.First(&u, "id = ?", userID)
|
|
|
|
|
//国家图标放入map结束
|
|
|
|
@ -398,7 +386,9 @@ func GetGoodsRespByInfoList(goodsList []goods.Information, userID uint) []QueryC
|
|
|
|
|
gb := goods.Brand{}
|
|
|
|
|
dbc.DB.First(&gb, "id = ?", v.BrandID)
|
|
|
|
|
var sku goods.Sku
|
|
|
|
|
mysql2.Db.Select("SUM(inventory) AS inventory, "+
|
|
|
|
|
mysql2.Db.Select(
|
|
|
|
|
"MIN(name), "+
|
|
|
|
|
"SUM(inventory) AS inventory, "+
|
|
|
|
|
"SUM(sales_volume) AS sales_volume, "+
|
|
|
|
|
"MIN(purchase_price) AS purchase_price,"+
|
|
|
|
|
"MIN(original_price) AS original_price, "+
|
|
|
|
@ -464,9 +454,10 @@ func GetGoodsRespByInfoList(goodsList []goods.Information, userID uint) []QueryC
|
|
|
|
|
commission = sku.DiscountPrice.Sub(sku.PurchasePrice).Mul(rate)
|
|
|
|
|
|
|
|
|
|
recookGoodsInfoModel := &goods2.RecookGoodsInfoModel{}
|
|
|
|
|
space := " "
|
|
|
|
|
list = append(list, QueryCategoryGoodsListResp{
|
|
|
|
|
ID: v.ID,
|
|
|
|
|
GoodsName: v.GoodsName,
|
|
|
|
|
GoodsName: strings.Join([]string{v.GoodsName, strings.Replace(sku.Name, "+", space, -1)},space),
|
|
|
|
|
BrandName: gb.Name + "品牌馆",
|
|
|
|
|
BrandImg: gb.LogoURL,
|
|
|
|
|
BrandId: gb.ID,
|
|
|
|
@ -489,7 +480,7 @@ func GetGoodsRespByInfoList(goodsList []goods.Information, userID uint) []QueryC
|
|
|
|
|
HasCoin: recookGoodsInfoModel.HasCoin(v.Storehouse),
|
|
|
|
|
HasBalance: recookGoodsInfoModel.HasBalance(v.Storehouse),
|
|
|
|
|
GysId: v.VendorID,
|
|
|
|
|
CountryIcon: countryMap[v.Country],
|
|
|
|
|
CountryIcon: ,
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|