Merge branch 'mall' into dev_index
# Conflicts: # model/model_test.go
This commit is contained in:
commit
f4280d733d
|
@ -5,6 +5,7 @@ import (
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"mh-server/lib/auth"
|
"mh-server/lib/auth"
|
||||||
"mh-server/lib/status"
|
"mh-server/lib/status"
|
||||||
|
"mh-server/lib/utils"
|
||||||
"mh-server/model"
|
"mh-server/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -48,3 +49,54 @@ func UserConvertRedeemCode(c *gin.Context) {
|
||||||
|
|
||||||
RespOK(c, nil)
|
RespOK(c, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func UserMemberRenewalState(c *gin.Context) {
|
||||||
|
uc := auth.GetCurrentUser(c)
|
||||||
|
if uc == nil {
|
||||||
|
RespJson(c, status.Unauthorized, nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var activityMemberRenewal model.ActivityMemberRenewal
|
||||||
|
err := model.NewActivityMemberRenewalQuerySet(model.DB).UidEq(uc.Uid).StateEq(1).
|
||||||
|
One(&activityMemberRenewal)
|
||||||
|
if err != nil && err != model.RecordNotFound {
|
||||||
|
logger.Error("activity member renewal err:", err)
|
||||||
|
RespJson(c, status.InternalServerError, nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
isPop := true
|
||||||
|
|
||||||
|
if err == model.RecordNotFound {
|
||||||
|
user := model.GetUserByUid(uc.Uid)
|
||||||
|
if user.MemberExpire.After(utils.Now().AddDate(0, -1, 0)) &&
|
||||||
|
user.MemberExpire.Before(utils.Now()) {
|
||||||
|
activityMemberRenewal = model.ActivityMemberRenewal{
|
||||||
|
ActivityId: 1,
|
||||||
|
Uid: uc.Uid,
|
||||||
|
State: 1,
|
||||||
|
StartTime: utils.Now(),
|
||||||
|
IsPop: true,
|
||||||
|
MemberLevel: user.MemberLevel,
|
||||||
|
}
|
||||||
|
|
||||||
|
err = model.DB.Create(&activityMemberRenewal).Error
|
||||||
|
if err != nil {
|
||||||
|
logger.Error("create activity member renewal err:", err)
|
||||||
|
RespJson(c, status.InternalServerError, nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
isPop = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
isMemberRenewal := false
|
||||||
|
if activityMemberRenewal.State == 1 {
|
||||||
|
isMemberRenewal = true
|
||||||
|
}
|
||||||
|
ret := make(map[string]interface{}, 0)
|
||||||
|
ret["is_pop"] = isPop
|
||||||
|
ret["is_member_renewal"] = isMemberRenewal
|
||||||
|
|
||||||
|
RespOK(c, ret)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@ func StoreList(c *gin.Context) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
RespOK(c, stores)
|
RespOK(c, stores)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func DisplayStoreList(c *gin.Context) {
|
func DisplayStoreList(c *gin.Context) {
|
||||||
|
|
3691
model/autogenerated_coupon.go
Normal file
3691
model/autogenerated_coupon.go
Normal file
File diff suppressed because it is too large
Load Diff
|
@ -6,6 +6,12 @@ const (
|
||||||
CouponTypeDeduction = "deduction"
|
CouponTypeDeduction = "deduction"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
CouponTypeMemberRenewal = "member_renewal"
|
||||||
|
)
|
||||||
|
|
||||||
|
//go:generate goqueryset -in coupon.go
|
||||||
|
// gen:qs
|
||||||
type Coupon struct {
|
type Coupon struct {
|
||||||
Model
|
Model
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
|
@ -18,6 +24,7 @@ type Coupon struct {
|
||||||
ActiveEnd time.Time `json:"active_end"` // 有效期结束 零值永不结束
|
ActiveEnd time.Time `json:"active_end"` // 有效期结束 零值永不结束
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// gen:qs
|
||||||
type UserCoupon struct {
|
type UserCoupon struct {
|
||||||
Model
|
Model
|
||||||
|
|
||||||
|
@ -25,7 +32,32 @@ type UserCoupon struct {
|
||||||
CouponId uint32 `json:"coupon_id"`
|
CouponId uint32 `json:"coupon_id"`
|
||||||
CouponType string `json:"coupon_type"`
|
CouponType string `json:"coupon_type"`
|
||||||
Value uint32 `json:"value"`
|
Value uint32 `json:"value"`
|
||||||
State uint32 `json:"state"` //
|
State uint32 `json:"state"` // 1-未使用 2-已使用 3-已过期
|
||||||
ActiveStart time.Time `json:"active_start"` // 有效期开始
|
ActiveStart time.Time `json:"active_start"` // 有效期开始
|
||||||
ActiveEnd time.Time `json:"active_end"` // 有效期结束 零值永不结束
|
ActiveEnd time.Time `json:"active_end"` // 有效期结束 零值永不结束
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// gen:qs
|
||||||
|
type Activity struct {
|
||||||
|
Model
|
||||||
|
|
||||||
|
Name string `json:"name" gorm:"column:name;comment:'活动名称'"` // 活动名称
|
||||||
|
ActivityType uint32 `json:"activity_type" gorm:"column:activity_type;comment:'活动类型'"` // 活动类型 1-会员续费
|
||||||
|
State uint32 `json:"state" gorm:"column:state;comment:'状态'"` // 1-未开启 2-进行中 3-已结束
|
||||||
|
StartTime time.Time `json:"start_time" gorm:"column:start_time;comment:'开始时间'"` // 开始时间
|
||||||
|
EndTime time.Time `json:"end_time" gorm:"column:end_time;comment:'结束时间'"` // 结束时间 零值永不结束
|
||||||
|
}
|
||||||
|
|
||||||
|
// gen:qs
|
||||||
|
type ActivityMemberRenewal struct {
|
||||||
|
Model
|
||||||
|
|
||||||
|
ActivityId uint32 `json:"activity_id"`
|
||||||
|
Uid uint32 `json:"uid"`
|
||||||
|
State uint32 `json:"state" gorm:"column:state;comment:'状态'"` // 1-进行中 2-已完成 3-已过期
|
||||||
|
StartTime time.Time `json:"start_time" gorm:"column:start_time;comment:'开始时间'"` // 开始时间
|
||||||
|
IsPop bool `json:"is_pop" gorm:"column:is_pop;comment:'是否弹窗'"` // 是否弹窗
|
||||||
|
MemberLevel uint32 `json:"member_level" gorm:"column:member_level;comment:'会员等级'"` // 会员等级
|
||||||
|
//StartUseTime time.Time `json:"start_use_time" gorm:"column:start_use_time;comment:'开始使用时间'"` // 开始使用时间
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -118,6 +118,7 @@ func InitTestDB() {
|
||||||
//&DeliverTaskSub{},
|
//&DeliverTaskSub{},
|
||||||
|
|
||||||
&GameCard{},
|
&GameCard{},
|
||||||
|
&ActivityMemberRenewal{},
|
||||||
)
|
)
|
||||||
|
|
||||||
fmt.Println("DB init success")
|
fmt.Println("DB init success")
|
||||||
|
@ -211,6 +212,7 @@ func InitDBProd() {
|
||||||
//&OperationLog{},
|
//&OperationLog{},
|
||||||
//&DeliverTask{},
|
//&DeliverTask{},
|
||||||
//&DeliverTaskSub{},
|
//&DeliverTaskSub{},
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if err := DBProd.DB().Ping(); err != nil {
|
if err := DBProd.DB().Ping(); err != nil {
|
||||||
|
|
|
@ -45,9 +45,11 @@ type User struct {
|
||||||
CooperativeBusinessId uint32 `json:"cooperative_business_id" gorm:"index"` // 合作商id
|
CooperativeBusinessId uint32 `json:"cooperative_business_id" gorm:"index"` // 合作商id
|
||||||
CooperativeName string `json:"cooperative_name"` // 合作商名称
|
CooperativeName string `json:"cooperative_name"` // 合作商名称
|
||||||
ShopAssistantName string `json:"shop_assistant_name"` // 店员名称
|
ShopAssistantName string `json:"shop_assistant_name"` // 店员名称
|
||||||
Version uint32 `json:"-"`
|
Version uint32 `json:"-"` //
|
||||||
UserVm *UserVm `json:"user_vm" gorm:"-"` //
|
UserVm *UserVm `json:"user_vm" gorm:"-"` //
|
||||||
|
|
||||||
//RoleId uint32 `json:"role_id"` // 角色id
|
//RoleId uint32 `json:"role_id"` // 角色id
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *User) TableName() string {
|
func (o *User) TableName() string {
|
||||||
|
@ -154,6 +156,7 @@ type FundRecord struct {
|
||||||
PaymentNo string `json:"payment_no" gorm:"index"` // 付款单号
|
PaymentNo string `json:"payment_no" gorm:"index"` // 付款单号
|
||||||
Status uint32 `json:"status"` // 1-待支付 2-已支付 3-已退款
|
Status uint32 `json:"status"` // 1-待支付 2-已支付 3-已退款
|
||||||
Remark string `json:"remark"` // 备注
|
Remark string `json:"remark"` // 备注
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// gen:qs
|
// gen:qs
|
||||||
|
|
|
@ -162,6 +162,10 @@ func ConfigAppRouter(r gin.IRouter) {
|
||||||
activity.Use(auth.UserAccessAuth)
|
activity.Use(auth.UserAccessAuth)
|
||||||
activity.POST("redeem_code/user_redeem_code/list", controller.UserRedeemCodeList) // 详情
|
activity.POST("redeem_code/user_redeem_code/list", controller.UserRedeemCodeList) // 详情
|
||||||
activity.POST("redeem_code/user/convert", controller.UserConvertRedeemCode) // 会员兑换码
|
activity.POST("redeem_code/user/convert", controller.UserConvertRedeemCode) // 会员兑换码
|
||||||
|
|
||||||
|
// 会员续费
|
||||||
|
activity.POST("member_renewal/state", controller.UserMemberRenewalState)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mall := api.Group("mall")
|
mall := api.Group("mall")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user