Commit dc465373 authored by hujiebin's avatar hujiebin

feat

parent 70fb5d05
...@@ -14,12 +14,13 @@ import ( ...@@ -14,12 +14,13 @@ import (
) )
type CvHeadwear struct { type CvHeadwear struct {
Id uint64 `json:"id"` Id uint64 `json:"id"`
Using bool `json:"using"` Using bool `json:"using"`
PicUrl mysql.Str `json:"picUrl"` PicUrl mysql.Str `json:"picUrl"`
EffectUrl mysql.Str `json:"effectUrl"` EffectUrl mysql.Str `json:"effectUrl"`
TimeLeft int64 `json:"timeLeft"` // 离到期还有多少秒(过期则是负数) ReverseEffectUrl mysql.Str `json:"reverseEffectUrl"`
HeadwearIcon string `json:"headwearIcon"` TimeLeft int64 `json:"timeLeft"` // 离到期还有多少秒(过期则是负数)
HeadwearIcon string `json:"headwearIcon"`
} }
type CvHeadwearDiamond struct { type CvHeadwearDiamond struct {
...@@ -61,11 +62,12 @@ func GetHeadwearList(db *gorm.DB, userId uint64) ([]CvHeadwear, error) { ...@@ -61,11 +62,12 @@ func GetHeadwearList(db *gorm.DB, userId uint64) ([]CvHeadwear, error) {
// TODO: 没过期并且有设置using的,才算是,因为写入方不维护using状态的更新 // TODO: 没过期并且有设置using的,才算是,因为写入方不维护using状态的更新
isUsing := i.Using == headwear_e.YesUsing && i.EndTime.After(now) isUsing := i.Using == headwear_e.YesUsing && i.EndTime.After(now)
result = append(result, CvHeadwear{ result = append(result, CvHeadwear{
Id: i.HeadwearId, Id: i.HeadwearId,
PicUrl: resHwMap[i.HeadwearId].PicUrl, PicUrl: resHwMap[i.HeadwearId].PicUrl,
EffectUrl: resHwMap[i.HeadwearId].EffectUrl, EffectUrl: resHwMap[i.HeadwearId].EffectUrl,
Using: isUsing, ReverseEffectUrl: resHwMap[i.HeadwearId].ReverseEffectUrl,
TimeLeft: i.EndTime.Unix() - now.Unix(), Using: isUsing,
TimeLeft: i.EndTime.Unix() - now.Unix(),
}) })
if isUsing { if isUsing {
hasUsing = true hasUsing = true
...@@ -100,10 +102,11 @@ func GetCvHeadwear(userId uint64) (*CvHeadwear, error) { ...@@ -100,10 +102,11 @@ func GetCvHeadwear(userId uint64) (*CvHeadwear, error) {
return nil, myerr.WrapErr(err) return nil, myerr.WrapErr(err)
} }
return &CvHeadwear{ return &CvHeadwear{
Id: userHeadwear.HeadwearId, Id: userHeadwear.HeadwearId,
PicUrl: resHeadwear.PicUrl, PicUrl: resHeadwear.PicUrl,
EffectUrl: resHeadwear.EffectUrl, EffectUrl: resHeadwear.EffectUrl,
Using: userHeadwear.Using == headwear_e.YesUsing, ReverseEffectUrl: resHeadwear.ReverseEffectUrl,
Using: userHeadwear.Using == headwear_e.YesUsing,
}, nil }, nil
} }
...@@ -159,11 +162,12 @@ func BatchGetCvHeadwears(userIds []uint64) (map[uint64]CvHeadwear, error) { ...@@ -159,11 +162,12 @@ func BatchGetCvHeadwears(userIds []uint64) (map[uint64]CvHeadwear, error) {
headwear, flag := resHeadwearMap[r.HeadwearId] headwear, flag := resHeadwearMap[r.HeadwearId]
if flag { if flag {
result[r.UserId] = CvHeadwear{ result[r.UserId] = CvHeadwear{
Id: headwear.ID, Id: headwear.ID,
PicUrl: headwear.PicUrl, PicUrl: headwear.PicUrl,
EffectUrl: headwear.EffectUrl, EffectUrl: headwear.EffectUrl,
Using: r.Using == headwear_e.YesUsing, ReverseEffectUrl: headwear.ReverseEffectUrl,
HeadwearIcon: response[r.UserId], Using: r.Using == headwear_e.YesUsing,
HeadwearIcon: response[r.UserId],
} }
} }
......
...@@ -9,10 +9,11 @@ import ( ...@@ -9,10 +9,11 @@ import (
type ResHeadwear struct { type ResHeadwear struct {
mysql.Entity mysql.Entity
*domain.Model `gorm:"-"` *domain.Model `gorm:"-"`
Name mysql.Str Name mysql.Str
PicUrl mysql.Str PicUrl mysql.Str
EffectUrl mysql.Str EffectUrl mysql.Str
ReverseEffectUrl mysql.Str
} }
//矛盾,项目负责人(产品不接受 商品 同上架分开两个数据结构的模式),又在页面上要求头饰同价格在一起展示,修改。 //矛盾,项目负责人(产品不接受 商品 同上架分开两个数据结构的模式),又在页面上要求头饰同价格在一起展示,修改。
...@@ -134,4 +135,4 @@ func GetResHeadwearMap(db *gorm.DB) (map[uint64]ResHeadwear, error) { ...@@ -134,4 +135,4 @@ func GetResHeadwearMap(db *gorm.DB) (map[uint64]ResHeadwear, error) {
result[i.ID] = i result[i.ID] = i
} }
return result, nil return result, nil
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment