新增打包脚本,新增商品基础逻辑
This commit is contained in:
@@ -144,7 +144,7 @@ func DataInit() {
|
||||
database.Instance().Model(&models.PetGoods{}).Find(&petGoodsList)
|
||||
PetGoodsMap = make(map[string][]models.PetGoods)
|
||||
for _, value := range petGoodsList {
|
||||
key := strconv.Itoa(value.Assortment) + strconv.Itoa(value.PetType) + strconv.Itoa(value.Weight)
|
||||
key := strconv.Itoa(value.Assortment) + strconv.Itoa(value.PetType) + strconv.Itoa(value.Weight) + strconv.Itoa(value.Hair)
|
||||
if _, ok := PetGoodsMap[key]; ok {
|
||||
PetGoodsMap[key] = append(PetGoodsMap[key], value)
|
||||
} else {
|
||||
|
||||
+34
-3
@@ -4,8 +4,10 @@ import (
|
||||
"encoding/json"
|
||||
"github.com/kataras/iris/v12"
|
||||
"github.com/kataras/iris/v12/context"
|
||||
"go.uber.org/zap"
|
||||
"io"
|
||||
"pet-house.com/core/server/web/web_iris"
|
||||
"pet-house.com/core/server/zap_server"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
@@ -44,11 +46,40 @@ func (p DefParty) goodsList() web_iris.Party {
|
||||
return
|
||||
}
|
||||
//先取默认的商品
|
||||
key := "0" + strconv.Itoa(userPetInfo.PetBaseInfo.PetType) + strconv.Itoa(userPetInfo.PetBaseInfo.Size)
|
||||
key := "0" + strconv.Itoa(userPetInfo.PetBaseInfo.PetType) + "0" + "0"
|
||||
goodsList := getPetGoodsList(key)
|
||||
key1 := strconv.Itoa(userPetInfo.PetBaseInfo.Id) + strconv.Itoa(userPetInfo.PetBaseInfo.PetType) + strconv.Itoa(userPetInfo.PetInfo.Weight)
|
||||
key1 := strconv.Itoa(userPetInfo.PetBaseInfo.Id) + strconv.Itoa(userPetInfo.PetBaseInfo.PetType) + strconv.Itoa(userPetInfo.PetInfo.Weight) + "0"
|
||||
goodsList = append(goodsList, getPetGoodsList(key1)...)
|
||||
Success(ctx, goodsListRequest, GoodsListResponse{goodsList})
|
||||
key2 := strconv.Itoa(userPetInfo.PetBaseInfo.Id) + strconv.Itoa(userPetInfo.PetBaseInfo.PetType) + strconv.Itoa(userPetInfo.PetInfo.Weight) + strconv.Itoa(userPetInfo.PetBaseInfo.Hair)
|
||||
goodsList = append(goodsList, getPetGoodsList(key2)...)
|
||||
key3 := "0" + strconv.Itoa(userPetInfo.PetBaseInfo.PetType) + strconv.Itoa(userPetInfo.PetInfo.Weight) + strconv.Itoa(userPetInfo.PetBaseInfo.Hair)
|
||||
goodsList = append(goodsList, getPetGoodsList(key3)...)
|
||||
key4 := "0" + strconv.Itoa(userPetInfo.PetBaseInfo.PetType) + strconv.Itoa(userPetInfo.PetInfo.Weight) + "0"
|
||||
goodsList = append(goodsList, getPetGoodsList(key4)...)
|
||||
var goodsT1 []GoodsDetail
|
||||
var goodsT2 []GoodsDetail
|
||||
var goodsT3 []GoodsDetail
|
||||
for _, value := range goodsList {
|
||||
if value.GoodsType == 3 {
|
||||
goodsT3 = append(goodsT3, value)
|
||||
}
|
||||
if value.GoodsType == 2 {
|
||||
goodsT2 = append(goodsT2, value)
|
||||
}
|
||||
if value.GoodsType == 1 {
|
||||
goodsT1 = append(goodsT1, value)
|
||||
}
|
||||
}
|
||||
for index, t2 := range goodsT2 {
|
||||
t2.GoodsSubList = goodsT3
|
||||
goodsT2[index] = t2
|
||||
}
|
||||
for index, t1 := range goodsT1 {
|
||||
t1.GoodsSubList = goodsT2
|
||||
goodsT1[index] = t1
|
||||
}
|
||||
zap_server.ZAPLOG.Info("key", zap.Any("key1", key), zap.Any("key2", key1), zap.Any("key3", key2), zap.Any("key4", key3), zap.Any("key5", key4))
|
||||
Success(ctx, goodsListRequest, GoodsListResponse{goodsT1})
|
||||
})
|
||||
}}
|
||||
}
|
||||
|
||||
+3
-3
@@ -15,7 +15,7 @@ var CatWeightMap = map[int]string{
|
||||
2: "1.5-3kg",
|
||||
3: "3-5kg",
|
||||
4: "5-8kg",
|
||||
5: "8kg以上",
|
||||
//5: "8kg以上",
|
||||
}
|
||||
var DogWeightMap = map[int]string{
|
||||
1: "0-3kg",
|
||||
@@ -23,8 +23,8 @@ var DogWeightMap = map[int]string{
|
||||
3: "6-9kg",
|
||||
4: "9-13kg",
|
||||
5: "13-18kg",
|
||||
6: "18-22kg",
|
||||
7: "22-30kg",
|
||||
//6: "18-22kg",
|
||||
//7: "22-30kg",
|
||||
}
|
||||
|
||||
type UserPetInfo struct {
|
||||
|
||||
Reference in New Issue
Block a user