fix:
This commit is contained in:
parent
e62abdad31
commit
e030c825ca
|
@ -682,18 +682,18 @@ func UserCodeToCoupon(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
//if !user.IsMember() {
|
||||
// logger.Error("user is not member")
|
||||
// RespJson(c, status.UserNotMember, nil)
|
||||
// return
|
||||
//}
|
||||
|
||||
if user.OpenMemberTime.IsZero() {
|
||||
if !user.IsMember() {
|
||||
logger.Error("user is not member")
|
||||
RespJson(c, status.UserNotMember, nil)
|
||||
return
|
||||
}
|
||||
|
||||
//if user.OpenMemberTime.IsZero() {
|
||||
// logger.Error("user is not member")
|
||||
// RespJson(c, status.UserNotMember, nil)
|
||||
// return
|
||||
//}
|
||||
|
||||
var shopperPromotionCode model.ShopperPromotionCode
|
||||
err := model.NewShopperPromotionCodeQuerySet(model.DB).CodeEq(req.Code).One(&shopperPromotionCode)
|
||||
if err != nil {
|
||||
|
|
|
@ -434,7 +434,12 @@ func UserCouponList(c *gin.Context) {
|
|||
RespJson(c, status.Unauthorized, nil)
|
||||
return
|
||||
}
|
||||
//uc = &auth.UserClaims{Uid: 87564738}
|
||||
user := model.GetUserByUid(uc.Uid)
|
||||
if user == nil {
|
||||
logger.Error("user err")
|
||||
RespJson(c, status.InternalServerError, nil)
|
||||
return
|
||||
}
|
||||
|
||||
page := req.PageIdx - 1
|
||||
if page < 0 {
|
||||
|
@ -464,6 +469,13 @@ func UserCouponList(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
for i, _ := range coupons {
|
||||
if !user.IsMember() && coupons[i].ActivityType == 1 {
|
||||
coupons[i].Availability = 1
|
||||
} else {
|
||||
coupons[i].Availability = 2
|
||||
}
|
||||
}
|
||||
ret := map[string]interface{}{
|
||||
"list": coupons,
|
||||
"total_page": totalPage,
|
||||
|
@ -530,6 +542,13 @@ func MemberRenewalUserCouponList(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
user := model.GetUserByUid(uc.Uid)
|
||||
if user == nil {
|
||||
logger.Error("user err:")
|
||||
RespJson(c, status.InternalServerError, nil)
|
||||
return
|
||||
}
|
||||
|
||||
page := req.PageIdx - 1
|
||||
if page < 0 {
|
||||
page = 0
|
||||
|
@ -565,6 +584,14 @@ func MemberRenewalUserCouponList(c *gin.Context) {
|
|||
}
|
||||
}
|
||||
|
||||
list := make([]model.UserCoupon, 0, len(coupons))
|
||||
for i, _ := range coupons {
|
||||
if !user.IsMember() && coupons[i].ActivityType == 1 {
|
||||
continue
|
||||
}
|
||||
list = append(list, coupons[i])
|
||||
}
|
||||
|
||||
if len(ids) > 0 {
|
||||
err = model.NewUserCouponQuerySet(model.DB).IDIn(ids...).GetUpdater().SetState(3).Update()
|
||||
if err != nil {
|
||||
|
@ -572,7 +599,7 @@ func MemberRenewalUserCouponList(c *gin.Context) {
|
|||
}
|
||||
}
|
||||
ret := map[string]interface{}{
|
||||
"list": coupons,
|
||||
"list": list,
|
||||
"total_page": totalPage,
|
||||
"page_idx": req.PageIdx,
|
||||
}
|
||||
|
|
|
@ -54,6 +54,7 @@ type UserCoupon struct {
|
|||
Approach uint32 `json:"approach"` // 获取途径:
|
||||
PromotionalSales uint32 `json:"promotional_sales"`
|
||||
RedeemCode string `json:"redeem_code"`
|
||||
Availability uint32 `json:"availability" gorm:"-"` // 1-不可用 2-可用
|
||||
Coupon *Coupon `json:"coupon" gorm:"-"`
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user