fix:店员
This commit is contained in:
parent
24b6a4a6d4
commit
caaa9cba41
|
@ -104,8 +104,9 @@ func AuthLogin(c *gin.Context) {
|
|||
if err != nil {
|
||||
logger.Error("create user invite record err:", err)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
// 扫码记录
|
||||
inviteRecord := &model.UserInviteRecord{
|
||||
ToUid: user.Uid,
|
||||
FromUid: req.InviteUid,
|
||||
|
@ -120,11 +121,12 @@ func AuthLogin(c *gin.Context) {
|
|||
if err != nil {
|
||||
logger.Error("create user invite record err:", err)
|
||||
}
|
||||
|
||||
// UserInvite 邀请主要
|
||||
var inviteNew model.UserInvite
|
||||
inviteErr := model.NewUserInviteQuerySet(model.DB).ToUidEq(user.Uid).FromUidEq(req.InviteUid).ActionEq(1).
|
||||
SpendTypeEq(1).One(&inviteNew)
|
||||
if inviteErr != nil && inviteErr != model.RecordNotFound {
|
||||
// 是否存在未开通
|
||||
logger.Error("user invite err:", err)
|
||||
}
|
||||
fmt.Println("inviteErr:", inviteErr)
|
||||
|
@ -671,6 +673,112 @@ func UserCodeToCoupon(c *gin.Context) {
|
|||
RespJson(c, status.Unauthorized, nil)
|
||||
return
|
||||
}
|
||||
|
||||
if len(req.Code) == 6 {
|
||||
user := model.GetUserByUid(uc.Uid)
|
||||
if user == nil {
|
||||
logger.Error("user is nil")
|
||||
RespJson(c, status.Unauthorized, nil)
|
||||
return
|
||||
}
|
||||
|
||||
if !user.IsMember() {
|
||||
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 {
|
||||
logger.Error("shopper promotion code err:", err)
|
||||
RespJson(c, status.InternalServerError, nil)
|
||||
return
|
||||
}
|
||||
|
||||
//model.UserCoupon{}
|
||||
|
||||
exist, err := model.QueryRecordExist(fmt.Sprintf(
|
||||
"SELECT * FROM user_coupon WHERE uid=%d AND approach=1 AND activity_id=1 AND state=1 AND promotional_sales=%d ",
|
||||
uc.Uid, shopperPromotionCode.Uid))
|
||||
|
||||
if err != nil {
|
||||
logger.Error("exist err:", err)
|
||||
RespJson(c, status.InternalServerError, nil)
|
||||
return
|
||||
}
|
||||
if exist {
|
||||
logger.Error("coupon received err:", err)
|
||||
RespJson(c, status.CouponReceived, nil)
|
||||
return
|
||||
}
|
||||
|
||||
count, err := model.NewUserCouponQuerySet(model.DB).UidEq(uc.Uid).ActivityIdEq(1).
|
||||
ApproachEq(1).StateEq(1).Count()
|
||||
if err != nil {
|
||||
logger.Error("count user coupon err:", err)
|
||||
RespJson(c, status.InternalServerError, nil)
|
||||
return
|
||||
}
|
||||
if count >= 3 {
|
||||
logger.Error("coupon count gte 3")
|
||||
RespJson(c, status.CouponReceived, nil)
|
||||
return
|
||||
}
|
||||
var userCoupons []model.UserCoupon
|
||||
err = model.NewUserCouponQuerySet(model.DB).UidEq(uc.Uid).ActivityTypeEq(1).
|
||||
StateEq(1).All(&userCoupons)
|
||||
if err != nil {
|
||||
logger.Error("coupons err:", err)
|
||||
RespJson(c, status.InternalServerError, nil)
|
||||
return
|
||||
}
|
||||
userCouponMap := make(map[uint32]int, 0)
|
||||
for i, _ := range userCoupons {
|
||||
userCouponMap[userCoupons[i].CouponId] = i
|
||||
}
|
||||
|
||||
var coupons []model.Coupon
|
||||
err = model.NewCouponQuerySet(model.DB).ActivityIdEq(1).All(&coupons)
|
||||
if err != nil {
|
||||
logger.Error("coupons err:", err)
|
||||
RespJson(c, status.InternalServerError, nil)
|
||||
return
|
||||
}
|
||||
|
||||
for i, _ := range coupons {
|
||||
_, ok := userCouponMap[coupons[i].ID]
|
||||
if ok {
|
||||
continue
|
||||
}
|
||||
|
||||
userCoupon := &model.UserCoupon{
|
||||
Uid: uc.Uid,
|
||||
CouponId: coupons[i].ID,
|
||||
CouponType: coupons[i].CouponType,
|
||||
ActivityType: coupons[i].ActivityType,
|
||||
ActivityId: coupons[i].ActivityId,
|
||||
Value: coupons[i].Value,
|
||||
State: 1,
|
||||
ActiveStart: time.Now(),
|
||||
ActiveEnd: time.Now().AddDate(0, 0, 30),
|
||||
UseTime: time.Time{},
|
||||
MemberLevel: coupons[i].MemberLevel,
|
||||
Approach: 1,
|
||||
PromotionalSales: shopperPromotionCode.Uid,
|
||||
RedeemCode: shopperPromotionCode.Code,
|
||||
}
|
||||
|
||||
err = model.DB.Create(userCoupon).Error
|
||||
if err != nil {
|
||||
logger.Error("user coupon err:", err)
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
RespOK(c, nil)
|
||||
return
|
||||
}
|
||||
var redeemCode model.RedeemCode
|
||||
err := model.NewRedeemCodeQuerySet(model.DB).SerialCodeEq(req.Code).One(&redeemCode)
|
||||
if err != nil {
|
||||
|
|
|
@ -460,11 +460,17 @@ func PushWXPayNotice(c *gin.Context) {
|
|||
AfterMemberLevel: record.MemberLevel,
|
||||
}
|
||||
newTime := time.Now()
|
||||
var spendType uint32
|
||||
var user model.User
|
||||
err = model.NewUserQuerySet(model.DB).UidEq(record.Uid).One(&user)
|
||||
if err != nil {
|
||||
logger.Error("err:", err)
|
||||
return
|
||||
} else {
|
||||
spendType = uint32(2)
|
||||
if !user.OpenMemberTime.IsZero() {
|
||||
spendType = 3
|
||||
}
|
||||
expireTime := newTime.AddDate(1, 0, 0)
|
||||
if user.MemberExpire.After(newTime) {
|
||||
expireTime = user.MemberExpire.AddDate(1, 0, 0)
|
||||
|
@ -507,49 +513,60 @@ func PushWXPayNotice(c *gin.Context) {
|
|||
if err != nil {
|
||||
logger.Error("update user coupon state err:", err)
|
||||
}
|
||||
|
||||
var userCoupon model.UserCoupon
|
||||
err = model.NewUserCouponQuerySet(model.DB).IDEq(record.UserCouponId).One(&userCoupon)
|
||||
if err != nil {
|
||||
logger.Error("user coupon err:", err)
|
||||
} else {
|
||||
if userCoupon.Approach == 1 {
|
||||
err = model.StorePromotion(userCoupon.PromotionalSales, userCoupon.Uid, nil, &user)
|
||||
if err != nil {
|
||||
logger.Error("store promotion err:", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 邀请记录
|
||||
var invite model.UserInvite
|
||||
//err = model.NewUserInviteQuerySet(model.DB).ToUidEq(record.Uid).OrderDescByID().Limit(1).One(&invite)
|
||||
err = model.NewUserInviteQuerySet(model.DB).ToUidEq(record.Uid).OrderDescByCreatedAt().Limit(1).One(&invite)
|
||||
if err != nil && err != model.RecordNotFound {
|
||||
logger.Error("err:", err)
|
||||
} else {
|
||||
if err == model.RecordNotFound {
|
||||
userInvite := &model.UserInvite{
|
||||
FromUid: 0,
|
||||
UserType: 0,
|
||||
StoreId: 0,
|
||||
MemberOpenTime: newTime,
|
||||
MemberType: 2,
|
||||
ToUid: record.Uid,
|
||||
MemberStatus: 2,
|
||||
MemberLevel: record.MemberLevel,
|
||||
Action: 1,
|
||||
SpendType: 1,
|
||||
}
|
||||
err := userInvite.Create(model.DB)
|
||||
if err != nil {
|
||||
logger.Error("err:", err)
|
||||
}
|
||||
err = model.SendUserVm(record.Uid, record.MemberLevel, 100)
|
||||
if err != nil {
|
||||
logger.Error("send user vm err:", err)
|
||||
}
|
||||
}
|
||||
//if err == model.RecordNotFound {
|
||||
// userInvite := &model.UserInvite{
|
||||
// FromUid: 0,
|
||||
// UserType: 0,
|
||||
// StoreId: 0,
|
||||
// MemberOpenTime: newTime,
|
||||
// MemberType: 2,
|
||||
// ToUid: record.Uid,
|
||||
// MemberStatus: 2,
|
||||
// MemberLevel: record.MemberLevel,
|
||||
// Action: 1,
|
||||
// SpendType: 1,
|
||||
// }
|
||||
// err := userInvite.Create(model.DB)
|
||||
// if err != nil {
|
||||
// logger.Error("err:", err)
|
||||
// }
|
||||
// err = model.SendUserVm(record.Uid, record.MemberLevel, 100)
|
||||
// if err != nil {
|
||||
// logger.Error("send user vm err:", err)
|
||||
// }
|
||||
//}
|
||||
|
||||
if err == nil {
|
||||
spendType := uint32(2)
|
||||
if !user.OpenMemberTime.IsZero() {
|
||||
spendType = 3
|
||||
}
|
||||
|
||||
//qs := model.NewUserInviteQuerySet(model.DB).ToUidEq(record.Uid).GetUpdater()
|
||||
if invite.Action != 2 {
|
||||
qs := model.NewUserInviteQuerySet(model.DB).IDEq(invite.ID).GetUpdater()
|
||||
if user.MemberLevel != 2 {
|
||||
qs = qs.SetMemberOpenTime(newTime).SetMemberLevel(record.MemberLevel)
|
||||
}
|
||||
// SpendType 类型
|
||||
//if user.MemberLevel != 2 {
|
||||
// qs = qs.SetMemberOpenTime(newTime).SetMemberLevel(record.MemberLevel)
|
||||
//}
|
||||
qs = qs.SetMemberOpenTime(newTime).SetMemberLevel(record.MemberLevel)
|
||||
_, err = qs.SetMemberType(2).SetMemberStatus(2).
|
||||
SetAction(2).SetSpendType(spendType).UpdateNum()
|
||||
if err != nil {
|
||||
|
@ -582,10 +599,11 @@ func PushWXPayNotice(c *gin.Context) {
|
|||
}
|
||||
|
||||
userInviteNew := &model.UserInvite{
|
||||
FromUid: invite.FromUid,
|
||||
UserType: invite.UserType,
|
||||
StoreId: invite.StoreId,
|
||||
MemberOpenTime: invite.MemberOpenTime,
|
||||
FromUid: invite.FromUid,
|
||||
UserType: invite.UserType,
|
||||
StoreId: invite.StoreId,
|
||||
//MemberOpenTime: invite.MemberOpenTime,
|
||||
MemberOpenTime: time.Now(),
|
||||
MemberType: 2,
|
||||
MemberStatus: 2,
|
||||
ToUid: invite.ToUid,
|
||||
|
@ -613,9 +631,11 @@ func PushWXPayNotice(c *gin.Context) {
|
|||
}
|
||||
}
|
||||
|
||||
err = model.SendUserVm(user.Uid, record.MemberLevel, 0)
|
||||
if err != nil {
|
||||
logger.Error("send user vm err:", err)
|
||||
if spendType == 2 {
|
||||
err = model.SendUserVm(user.Uid, record.MemberLevel, 0)
|
||||
if err != nil {
|
||||
logger.Error("send user vm err:", err)
|
||||
}
|
||||
}
|
||||
|
||||
openMemberChannel := model.OpenMemberChannelUserInvite
|
||||
|
@ -624,17 +644,18 @@ func PushWXPayNotice(c *gin.Context) {
|
|||
if inviteUser.UserType == 2 {
|
||||
openMemberChannel = model.OpenMemberChannelStorePromotion
|
||||
if !user.OpenMemberTime.IsZero() {
|
||||
userQs = userQs.SetCooperativeBusinessId(inviteUser.CooperativeBusinessId).
|
||||
SetCooperativeName(inviteUser.CooperativeName)
|
||||
|
||||
fmt.Println("用户续费---")
|
||||
model.AddCooperativeMemberRenewal(inviteUser.CooperativeBusinessId,
|
||||
uint32(inviteUser.StoreId), inviteUser.Uid, int(record.MemberLevel))
|
||||
|
||||
} else {
|
||||
fmt.Println("用户开通------")
|
||||
model.AddCooperativeMemberPromotion(inviteUser.CooperativeBusinessId,
|
||||
uint32(inviteUser.StoreId), inviteUser.Uid, int(record.MemberLevel))
|
||||
}
|
||||
|
||||
userQs = userQs.SetCooperativeBusinessId(inviteUser.CooperativeBusinessId).
|
||||
SetCooperativeName(inviteUser.CooperativeName)
|
||||
}
|
||||
|
||||
_, err = userQs.SetOpenMemberChannel(openMemberChannel).UpdateNum()
|
||||
|
@ -656,7 +677,8 @@ func PushWXPayNotice(c *gin.Context) {
|
|||
}()
|
||||
model.CreateUserRentCardByMemberLevel(record.Uid, record.MemberLevel, memberConfig.CardMax)
|
||||
}
|
||||
_, err = model.NewUserOpenMemberRecordQuerySet(model.DB).IDEq(record.ID).GetUpdater().SetState(2).UpdateNum()
|
||||
_, err = model.NewUserOpenMemberRecordQuerySet(model.DB).IDEq(record.ID).
|
||||
GetUpdater().SetState(2).UpdateNum()
|
||||
if err != nil {
|
||||
logger.Error("update user open member record state:err", err)
|
||||
}
|
||||
|
|
|
@ -268,26 +268,29 @@ func OpenMember(c *gin.Context) {
|
|||
coupon.ActivityId == 1 && coupon.State == 1 {
|
||||
totalFee -= coupon.Value
|
||||
|
||||
go func() {
|
||||
action := 0
|
||||
if coupon.MemberLevel == 2 {
|
||||
action = model.UserRenewalLogActionUseGold
|
||||
} else if coupon.MemberLevel == 4 {
|
||||
action = model.UserRenewalLogActionUsePlatinum
|
||||
} else if coupon.MemberLevel == 5 {
|
||||
action = model.UserRenewalLogActionUseBlackGold
|
||||
}
|
||||
renewalLog, _ := model.GetActionUserRenewalLog(uc.Uid, uint32(action))
|
||||
userLog := &model.UserRenewalLog{
|
||||
Uid: uc.Uid,
|
||||
Action: uint32(action),
|
||||
MemberExpire: user.MemberExpire,
|
||||
Type: 1,
|
||||
RenewalNum: renewalLog.RenewalNum + 1,
|
||||
Serial: uint32(user.MemberExpire.Unix()),
|
||||
}
|
||||
_ = userLog.Add()
|
||||
}()
|
||||
if coupon.RedeemCode == "" {
|
||||
go func() {
|
||||
action := 0
|
||||
if coupon.MemberLevel == 2 {
|
||||
action = model.UserRenewalLogActionUseGold
|
||||
} else if coupon.MemberLevel == 4 {
|
||||
action = model.UserRenewalLogActionUsePlatinum
|
||||
} else if coupon.MemberLevel == 5 {
|
||||
action = model.UserRenewalLogActionUseBlackGold
|
||||
}
|
||||
renewalLog, _ := model.GetActionUserRenewalLog(uc.Uid, uint32(action))
|
||||
userLog := &model.UserRenewalLog{
|
||||
Uid: uc.Uid,
|
||||
Action: uint32(action),
|
||||
MemberExpire: user.MemberExpire,
|
||||
Type: 1,
|
||||
RenewalNum: renewalLog.RenewalNum + 1,
|
||||
Serial: uint32(user.MemberExpire.Unix()),
|
||||
}
|
||||
_ = userLog.Add()
|
||||
}()
|
||||
}
|
||||
|
||||
} else if coupon.State == 1 && coupon.ActivityType == 2 {
|
||||
totalFee -= coupon.Value
|
||||
} else {
|
||||
|
|
|
@ -104,8 +104,10 @@ const (
|
|||
StateNotCancel = 500521 // 状态不能取消
|
||||
UserFocusHasCoupon = 500522 // 用户已经领取了兑换券
|
||||
UserApplyDepositRefund = 500523 // 你有退保证金申请,不能借卡
|
||||
|
||||
ToastErr = 600 // 报错
|
||||
UserNotMember = 500524 // 仅开通过会员的用户可兑换
|
||||
CouponReceived = 500525 // 你已兑换过该券
|
||||
CouponPromotionalUnused = 500526 // 您有未使用的专属续费券
|
||||
ToastErr = 600 // 报错
|
||||
)
|
||||
|
||||
var statusDesc = map[int]string{
|
||||
|
@ -170,10 +172,13 @@ var statusDesc = map[int]string{
|
|||
AwardOffShelves: "奖品已下架",
|
||||
AwardExchangeOut: "奖品已兑完",
|
||||
|
||||
GoodsNotSale: "商品已下架",
|
||||
StateNotCancel: "状态不能取消",
|
||||
UserFocusHasCoupon: "你已经兑换了优惠券",
|
||||
UserApplyDepositRefund: "你有退保证金申请,不能借卡",
|
||||
GoodsNotSale: "商品已下架",
|
||||
StateNotCancel: "状态不能取消",
|
||||
UserFocusHasCoupon: "你已经兑换了优惠券",
|
||||
UserApplyDepositRefund: "你有退保证金申请,不能借卡",
|
||||
UserNotMember: "仅开通过会员的用户可兑换",
|
||||
CouponReceived: "你已兑换过该券",
|
||||
CouponPromotionalUnused: "您有未使用的专属续费券",
|
||||
|
||||
NotMember: "非会员",
|
||||
HadReceiveReward: "已经领取过了",
|
||||
|
@ -243,8 +248,11 @@ var statusMsg = map[int]string{
|
|||
MoneySufficient: "余额不足",
|
||||
UserVmNotEnough: "积分余额不足",
|
||||
|
||||
UserFocusHasCoupon: "你已经兑换了优惠券",
|
||||
UserApplyDepositRefund: "你有退保证金申请,不能借卡",
|
||||
UserFocusHasCoupon: "你已经兑换了优惠券",
|
||||
UserApplyDepositRefund: "你有退保证金申请,不能借卡",
|
||||
UserNotMember: "仅开通过会员的用户可兑换",
|
||||
CouponReceived: "你已兑换过该券",
|
||||
CouponPromotionalUnused: "您有未使用的专属续费券",
|
||||
|
||||
AwardOffShelves: "奖品已下架",
|
||||
AwardExchangeOut: "奖品已兑完",
|
||||
|
|
|
@ -3273,6 +3273,62 @@ func (qs UserCouponQuerySet) All(ret *[]UserCoupon) error {
|
|||
return qs.db.Find(ret).Error
|
||||
}
|
||||
|
||||
// ApproachEq is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs UserCouponQuerySet) ApproachEq(approach uint32) UserCouponQuerySet {
|
||||
return qs.w(qs.db.Where("approach = ?", approach))
|
||||
}
|
||||
|
||||
// ApproachGt is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs UserCouponQuerySet) ApproachGt(approach uint32) UserCouponQuerySet {
|
||||
return qs.w(qs.db.Where("approach > ?", approach))
|
||||
}
|
||||
|
||||
// ApproachGte is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs UserCouponQuerySet) ApproachGte(approach uint32) UserCouponQuerySet {
|
||||
return qs.w(qs.db.Where("approach >= ?", approach))
|
||||
}
|
||||
|
||||
// ApproachIn is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs UserCouponQuerySet) ApproachIn(approach ...uint32) UserCouponQuerySet {
|
||||
if len(approach) == 0 {
|
||||
qs.db.AddError(errors.New("must at least pass one approach in ApproachIn"))
|
||||
return qs.w(qs.db)
|
||||
}
|
||||
return qs.w(qs.db.Where("approach IN (?)", approach))
|
||||
}
|
||||
|
||||
// ApproachLt is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs UserCouponQuerySet) ApproachLt(approach uint32) UserCouponQuerySet {
|
||||
return qs.w(qs.db.Where("approach < ?", approach))
|
||||
}
|
||||
|
||||
// ApproachLte is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs UserCouponQuerySet) ApproachLte(approach uint32) UserCouponQuerySet {
|
||||
return qs.w(qs.db.Where("approach <= ?", approach))
|
||||
}
|
||||
|
||||
// ApproachNe is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs UserCouponQuerySet) ApproachNe(approach uint32) UserCouponQuerySet {
|
||||
return qs.w(qs.db.Where("approach != ?", approach))
|
||||
}
|
||||
|
||||
// ApproachNotIn is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs UserCouponQuerySet) ApproachNotIn(approach ...uint32) UserCouponQuerySet {
|
||||
if len(approach) == 0 {
|
||||
qs.db.AddError(errors.New("must at least pass one approach in ApproachNotIn"))
|
||||
return qs.w(qs.db)
|
||||
}
|
||||
return qs.w(qs.db.Where("approach NOT IN (?)", approach))
|
||||
}
|
||||
|
||||
// Count is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs UserCouponQuerySet) Count() (int, error) {
|
||||
|
@ -3675,6 +3731,12 @@ func (qs UserCouponQuerySet) OrderAscByActivityType() UserCouponQuerySet {
|
|||
return qs.w(qs.db.Order("activity_type ASC"))
|
||||
}
|
||||
|
||||
// OrderAscByApproach is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs UserCouponQuerySet) OrderAscByApproach() UserCouponQuerySet {
|
||||
return qs.w(qs.db.Order("approach ASC"))
|
||||
}
|
||||
|
||||
// OrderAscByCouponId is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs UserCouponQuerySet) OrderAscByCouponId() UserCouponQuerySet {
|
||||
|
@ -3711,6 +3773,18 @@ func (qs UserCouponQuerySet) OrderAscByMemberLevel() UserCouponQuerySet {
|
|||
return qs.w(qs.db.Order("member_level ASC"))
|
||||
}
|
||||
|
||||
// OrderAscByPromotionalSales is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs UserCouponQuerySet) OrderAscByPromotionalSales() UserCouponQuerySet {
|
||||
return qs.w(qs.db.Order("promotional_sales ASC"))
|
||||
}
|
||||
|
||||
// OrderAscByRedeemCode is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs UserCouponQuerySet) OrderAscByRedeemCode() UserCouponQuerySet {
|
||||
return qs.w(qs.db.Order("redeem_code ASC"))
|
||||
}
|
||||
|
||||
// OrderAscByState is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs UserCouponQuerySet) OrderAscByState() UserCouponQuerySet {
|
||||
|
@ -3765,6 +3839,12 @@ func (qs UserCouponQuerySet) OrderDescByActivityType() UserCouponQuerySet {
|
|||
return qs.w(qs.db.Order("activity_type DESC"))
|
||||
}
|
||||
|
||||
// OrderDescByApproach is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs UserCouponQuerySet) OrderDescByApproach() UserCouponQuerySet {
|
||||
return qs.w(qs.db.Order("approach DESC"))
|
||||
}
|
||||
|
||||
// OrderDescByCouponId is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs UserCouponQuerySet) OrderDescByCouponId() UserCouponQuerySet {
|
||||
|
@ -3801,6 +3881,18 @@ func (qs UserCouponQuerySet) OrderDescByMemberLevel() UserCouponQuerySet {
|
|||
return qs.w(qs.db.Order("member_level DESC"))
|
||||
}
|
||||
|
||||
// OrderDescByPromotionalSales is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs UserCouponQuerySet) OrderDescByPromotionalSales() UserCouponQuerySet {
|
||||
return qs.w(qs.db.Order("promotional_sales DESC"))
|
||||
}
|
||||
|
||||
// OrderDescByRedeemCode is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs UserCouponQuerySet) OrderDescByRedeemCode() UserCouponQuerySet {
|
||||
return qs.w(qs.db.Order("redeem_code DESC"))
|
||||
}
|
||||
|
||||
// OrderDescByState is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs UserCouponQuerySet) OrderDescByState() UserCouponQuerySet {
|
||||
|
@ -3831,6 +3923,130 @@ func (qs UserCouponQuerySet) OrderDescByValue() UserCouponQuerySet {
|
|||
return qs.w(qs.db.Order("value DESC"))
|
||||
}
|
||||
|
||||
// PromotionalSalesEq is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs UserCouponQuerySet) PromotionalSalesEq(promotionalSales uint32) UserCouponQuerySet {
|
||||
return qs.w(qs.db.Where("promotional_sales = ?", promotionalSales))
|
||||
}
|
||||
|
||||
// PromotionalSalesGt is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs UserCouponQuerySet) PromotionalSalesGt(promotionalSales uint32) UserCouponQuerySet {
|
||||
return qs.w(qs.db.Where("promotional_sales > ?", promotionalSales))
|
||||
}
|
||||
|
||||
// PromotionalSalesGte is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs UserCouponQuerySet) PromotionalSalesGte(promotionalSales uint32) UserCouponQuerySet {
|
||||
return qs.w(qs.db.Where("promotional_sales >= ?", promotionalSales))
|
||||
}
|
||||
|
||||
// PromotionalSalesIn is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs UserCouponQuerySet) PromotionalSalesIn(promotionalSales ...uint32) UserCouponQuerySet {
|
||||
if len(promotionalSales) == 0 {
|
||||
qs.db.AddError(errors.New("must at least pass one promotionalSales in PromotionalSalesIn"))
|
||||
return qs.w(qs.db)
|
||||
}
|
||||
return qs.w(qs.db.Where("promotional_sales IN (?)", promotionalSales))
|
||||
}
|
||||
|
||||
// PromotionalSalesLt is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs UserCouponQuerySet) PromotionalSalesLt(promotionalSales uint32) UserCouponQuerySet {
|
||||
return qs.w(qs.db.Where("promotional_sales < ?", promotionalSales))
|
||||
}
|
||||
|
||||
// PromotionalSalesLte is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs UserCouponQuerySet) PromotionalSalesLte(promotionalSales uint32) UserCouponQuerySet {
|
||||
return qs.w(qs.db.Where("promotional_sales <= ?", promotionalSales))
|
||||
}
|
||||
|
||||
// PromotionalSalesNe is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs UserCouponQuerySet) PromotionalSalesNe(promotionalSales uint32) UserCouponQuerySet {
|
||||
return qs.w(qs.db.Where("promotional_sales != ?", promotionalSales))
|
||||
}
|
||||
|
||||
// PromotionalSalesNotIn is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs UserCouponQuerySet) PromotionalSalesNotIn(promotionalSales ...uint32) UserCouponQuerySet {
|
||||
if len(promotionalSales) == 0 {
|
||||
qs.db.AddError(errors.New("must at least pass one promotionalSales in PromotionalSalesNotIn"))
|
||||
return qs.w(qs.db)
|
||||
}
|
||||
return qs.w(qs.db.Where("promotional_sales NOT IN (?)", promotionalSales))
|
||||
}
|
||||
|
||||
// RedeemCodeEq is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs UserCouponQuerySet) RedeemCodeEq(redeemCode string) UserCouponQuerySet {
|
||||
return qs.w(qs.db.Where("redeem_code = ?", redeemCode))
|
||||
}
|
||||
|
||||
// RedeemCodeGt is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs UserCouponQuerySet) RedeemCodeGt(redeemCode string) UserCouponQuerySet {
|
||||
return qs.w(qs.db.Where("redeem_code > ?", redeemCode))
|
||||
}
|
||||
|
||||
// RedeemCodeGte is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs UserCouponQuerySet) RedeemCodeGte(redeemCode string) UserCouponQuerySet {
|
||||
return qs.w(qs.db.Where("redeem_code >= ?", redeemCode))
|
||||
}
|
||||
|
||||
// RedeemCodeIn is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs UserCouponQuerySet) RedeemCodeIn(redeemCode ...string) UserCouponQuerySet {
|
||||
if len(redeemCode) == 0 {
|
||||
qs.db.AddError(errors.New("must at least pass one redeemCode in RedeemCodeIn"))
|
||||
return qs.w(qs.db)
|
||||
}
|
||||
return qs.w(qs.db.Where("redeem_code IN (?)", redeemCode))
|
||||
}
|
||||
|
||||
// RedeemCodeLike is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs UserCouponQuerySet) RedeemCodeLike(redeemCode string) UserCouponQuerySet {
|
||||
return qs.w(qs.db.Where("redeem_code LIKE ?", redeemCode))
|
||||
}
|
||||
|
||||
// RedeemCodeLt is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs UserCouponQuerySet) RedeemCodeLt(redeemCode string) UserCouponQuerySet {
|
||||
return qs.w(qs.db.Where("redeem_code < ?", redeemCode))
|
||||
}
|
||||
|
||||
// RedeemCodeLte is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs UserCouponQuerySet) RedeemCodeLte(redeemCode string) UserCouponQuerySet {
|
||||
return qs.w(qs.db.Where("redeem_code <= ?", redeemCode))
|
||||
}
|
||||
|
||||
// RedeemCodeNe is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs UserCouponQuerySet) RedeemCodeNe(redeemCode string) UserCouponQuerySet {
|
||||
return qs.w(qs.db.Where("redeem_code != ?", redeemCode))
|
||||
}
|
||||
|
||||
// RedeemCodeNotIn is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs UserCouponQuerySet) RedeemCodeNotIn(redeemCode ...string) UserCouponQuerySet {
|
||||
if len(redeemCode) == 0 {
|
||||
qs.db.AddError(errors.New("must at least pass one redeemCode in RedeemCodeNotIn"))
|
||||
return qs.w(qs.db)
|
||||
}
|
||||
return qs.w(qs.db.Where("redeem_code NOT IN (?)", redeemCode))
|
||||
}
|
||||
|
||||
// RedeemCodeNotlike is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs UserCouponQuerySet) RedeemCodeNotlike(redeemCode string) UserCouponQuerySet {
|
||||
return qs.w(qs.db.Where("redeem_code NOT LIKE ?", redeemCode))
|
||||
}
|
||||
|
||||
// StateEq is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs UserCouponQuerySet) StateEq(state uint32) UserCouponQuerySet {
|
||||
|
@ -4099,6 +4315,13 @@ func (u UserCouponUpdater) SetActivityType(activityType uint32) UserCouponUpdate
|
|||
return u
|
||||
}
|
||||
|
||||
// SetApproach is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (u UserCouponUpdater) SetApproach(approach uint32) UserCouponUpdater {
|
||||
u.fields[string(UserCouponDBSchema.Approach)] = approach
|
||||
return u
|
||||
}
|
||||
|
||||
// SetCouponId is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (u UserCouponUpdater) SetCouponId(couponId uint32) UserCouponUpdater {
|
||||
|
@ -4141,6 +4364,20 @@ func (u UserCouponUpdater) SetMemberLevel(memberLevel uint32) UserCouponUpdater
|
|||
return u
|
||||
}
|
||||
|
||||
// SetPromotionalSales is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (u UserCouponUpdater) SetPromotionalSales(promotionalSales uint32) UserCouponUpdater {
|
||||
u.fields[string(UserCouponDBSchema.PromotionalSales)] = promotionalSales
|
||||
return u
|
||||
}
|
||||
|
||||
// SetRedeemCode is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (u UserCouponUpdater) SetRedeemCode(redeemCode string) UserCouponUpdater {
|
||||
u.fields[string(UserCouponDBSchema.RedeemCode)] = redeemCode
|
||||
return u
|
||||
}
|
||||
|
||||
// SetState is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (u UserCouponUpdater) SetState(state uint32) UserCouponUpdater {
|
||||
|
@ -4204,59 +4441,68 @@ func (f UserCouponDBSchemaField) String() string {
|
|||
|
||||
// UserCouponDBSchema stores db field names of UserCoupon
|
||||
var UserCouponDBSchema = struct {
|
||||
ID UserCouponDBSchemaField
|
||||
CreatedAt UserCouponDBSchemaField
|
||||
UpdatedAt UserCouponDBSchemaField
|
||||
DeletedAt UserCouponDBSchemaField
|
||||
Uid UserCouponDBSchemaField
|
||||
CouponId UserCouponDBSchemaField
|
||||
CouponType UserCouponDBSchemaField
|
||||
ActivityType UserCouponDBSchemaField
|
||||
ActivityId UserCouponDBSchemaField
|
||||
Value UserCouponDBSchemaField
|
||||
State UserCouponDBSchemaField
|
||||
ActiveStart UserCouponDBSchemaField
|
||||
ActiveEnd UserCouponDBSchemaField
|
||||
UseTime UserCouponDBSchemaField
|
||||
MemberLevel UserCouponDBSchemaField
|
||||
ID UserCouponDBSchemaField
|
||||
CreatedAt UserCouponDBSchemaField
|
||||
UpdatedAt UserCouponDBSchemaField
|
||||
DeletedAt UserCouponDBSchemaField
|
||||
Uid UserCouponDBSchemaField
|
||||
CouponId UserCouponDBSchemaField
|
||||
CouponType UserCouponDBSchemaField
|
||||
ActivityType UserCouponDBSchemaField
|
||||
ActivityId UserCouponDBSchemaField
|
||||
Value UserCouponDBSchemaField
|
||||
State UserCouponDBSchemaField
|
||||
ActiveStart UserCouponDBSchemaField
|
||||
ActiveEnd UserCouponDBSchemaField
|
||||
UseTime UserCouponDBSchemaField
|
||||
MemberLevel UserCouponDBSchemaField
|
||||
Approach UserCouponDBSchemaField
|
||||
PromotionalSales UserCouponDBSchemaField
|
||||
RedeemCode UserCouponDBSchemaField
|
||||
}{
|
||||
|
||||
ID: UserCouponDBSchemaField("id"),
|
||||
CreatedAt: UserCouponDBSchemaField("created_at"),
|
||||
UpdatedAt: UserCouponDBSchemaField("updated_at"),
|
||||
DeletedAt: UserCouponDBSchemaField("deleted_at"),
|
||||
Uid: UserCouponDBSchemaField("uid"),
|
||||
CouponId: UserCouponDBSchemaField("coupon_id"),
|
||||
CouponType: UserCouponDBSchemaField("coupon_type"),
|
||||
ActivityType: UserCouponDBSchemaField("activity_type"),
|
||||
ActivityId: UserCouponDBSchemaField("activity_id"),
|
||||
Value: UserCouponDBSchemaField("value"),
|
||||
State: UserCouponDBSchemaField("state"),
|
||||
ActiveStart: UserCouponDBSchemaField("active_start"),
|
||||
ActiveEnd: UserCouponDBSchemaField("active_end"),
|
||||
UseTime: UserCouponDBSchemaField("use_time"),
|
||||
MemberLevel: UserCouponDBSchemaField("member_level"),
|
||||
ID: UserCouponDBSchemaField("id"),
|
||||
CreatedAt: UserCouponDBSchemaField("created_at"),
|
||||
UpdatedAt: UserCouponDBSchemaField("updated_at"),
|
||||
DeletedAt: UserCouponDBSchemaField("deleted_at"),
|
||||
Uid: UserCouponDBSchemaField("uid"),
|
||||
CouponId: UserCouponDBSchemaField("coupon_id"),
|
||||
CouponType: UserCouponDBSchemaField("coupon_type"),
|
||||
ActivityType: UserCouponDBSchemaField("activity_type"),
|
||||
ActivityId: UserCouponDBSchemaField("activity_id"),
|
||||
Value: UserCouponDBSchemaField("value"),
|
||||
State: UserCouponDBSchemaField("state"),
|
||||
ActiveStart: UserCouponDBSchemaField("active_start"),
|
||||
ActiveEnd: UserCouponDBSchemaField("active_end"),
|
||||
UseTime: UserCouponDBSchemaField("use_time"),
|
||||
MemberLevel: UserCouponDBSchemaField("member_level"),
|
||||
Approach: UserCouponDBSchemaField("approach"),
|
||||
PromotionalSales: UserCouponDBSchemaField("promotional_sales"),
|
||||
RedeemCode: UserCouponDBSchemaField("redeem_code"),
|
||||
}
|
||||
|
||||
// Update updates UserCoupon fields by primary key
|
||||
// nolint: dupl
|
||||
func (o *UserCoupon) Update(db *gorm.DB, fields ...UserCouponDBSchemaField) error {
|
||||
dbNameToFieldName := map[string]interface{}{
|
||||
"id": o.ID,
|
||||
"created_at": o.CreatedAt,
|
||||
"updated_at": o.UpdatedAt,
|
||||
"deleted_at": o.DeletedAt,
|
||||
"uid": o.Uid,
|
||||
"coupon_id": o.CouponId,
|
||||
"coupon_type": o.CouponType,
|
||||
"activity_type": o.ActivityType,
|
||||
"activity_id": o.ActivityId,
|
||||
"value": o.Value,
|
||||
"state": o.State,
|
||||
"active_start": o.ActiveStart,
|
||||
"active_end": o.ActiveEnd,
|
||||
"use_time": o.UseTime,
|
||||
"member_level": o.MemberLevel,
|
||||
"id": o.ID,
|
||||
"created_at": o.CreatedAt,
|
||||
"updated_at": o.UpdatedAt,
|
||||
"deleted_at": o.DeletedAt,
|
||||
"uid": o.Uid,
|
||||
"coupon_id": o.CouponId,
|
||||
"coupon_type": o.CouponType,
|
||||
"activity_type": o.ActivityType,
|
||||
"activity_id": o.ActivityId,
|
||||
"value": o.Value,
|
||||
"state": o.State,
|
||||
"active_start": o.ActiveStart,
|
||||
"active_end": o.ActiveEnd,
|
||||
"use_time": o.UseTime,
|
||||
"member_level": o.MemberLevel,
|
||||
"approach": o.Approach,
|
||||
"promotional_sales": o.PromotionalSales,
|
||||
"redeem_code": o.RedeemCode,
|
||||
}
|
||||
u := map[string]interface{}{}
|
||||
for _, f := range fields {
|
||||
|
|
|
@ -6884,6 +6884,768 @@ func NewOperationLogUpdater(db *gorm.DB) OperationLogUpdater {
|
|||
|
||||
// ===== END of OperationLog modifiers
|
||||
|
||||
// ===== BEGIN of query set ShopperPromotionCodeQuerySet
|
||||
|
||||
// ShopperPromotionCodeQuerySet is an queryset type for ShopperPromotionCode
|
||||
type ShopperPromotionCodeQuerySet struct {
|
||||
db *gorm.DB
|
||||
}
|
||||
|
||||
// NewShopperPromotionCodeQuerySet constructs new ShopperPromotionCodeQuerySet
|
||||
func NewShopperPromotionCodeQuerySet(db *gorm.DB) ShopperPromotionCodeQuerySet {
|
||||
return ShopperPromotionCodeQuerySet{
|
||||
db: db.Model(&ShopperPromotionCode{}),
|
||||
}
|
||||
}
|
||||
|
||||
func (qs ShopperPromotionCodeQuerySet) w(db *gorm.DB) ShopperPromotionCodeQuerySet {
|
||||
return NewShopperPromotionCodeQuerySet(db)
|
||||
}
|
||||
|
||||
func (qs ShopperPromotionCodeQuerySet) Select(fields ...ShopperPromotionCodeDBSchemaField) ShopperPromotionCodeQuerySet {
|
||||
names := []string{}
|
||||
for _, f := range fields {
|
||||
names = append(names, f.String())
|
||||
}
|
||||
|
||||
return qs.w(qs.db.Select(strings.Join(names, ",")))
|
||||
}
|
||||
|
||||
// Create is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (o *ShopperPromotionCode) Create(db *gorm.DB) error {
|
||||
return db.Create(o).Error
|
||||
}
|
||||
|
||||
// Delete is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (o *ShopperPromotionCode) Delete(db *gorm.DB) error {
|
||||
return db.Delete(o).Error
|
||||
}
|
||||
|
||||
// All is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs ShopperPromotionCodeQuerySet) All(ret *[]ShopperPromotionCode) error {
|
||||
return qs.db.Find(ret).Error
|
||||
}
|
||||
|
||||
// CodeEq is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs ShopperPromotionCodeQuerySet) CodeEq(code string) ShopperPromotionCodeQuerySet {
|
||||
return qs.w(qs.db.Where("code = ?", code))
|
||||
}
|
||||
|
||||
// CodeGt is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs ShopperPromotionCodeQuerySet) CodeGt(code string) ShopperPromotionCodeQuerySet {
|
||||
return qs.w(qs.db.Where("code > ?", code))
|
||||
}
|
||||
|
||||
// CodeGte is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs ShopperPromotionCodeQuerySet) CodeGte(code string) ShopperPromotionCodeQuerySet {
|
||||
return qs.w(qs.db.Where("code >= ?", code))
|
||||
}
|
||||
|
||||
// CodeIn is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs ShopperPromotionCodeQuerySet) CodeIn(code ...string) ShopperPromotionCodeQuerySet {
|
||||
if len(code) == 0 {
|
||||
qs.db.AddError(errors.New("must at least pass one code in CodeIn"))
|
||||
return qs.w(qs.db)
|
||||
}
|
||||
return qs.w(qs.db.Where("code IN (?)", code))
|
||||
}
|
||||
|
||||
// CodeLike is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs ShopperPromotionCodeQuerySet) CodeLike(code string) ShopperPromotionCodeQuerySet {
|
||||
return qs.w(qs.db.Where("code LIKE ?", code))
|
||||
}
|
||||
|
||||
// CodeLt is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs ShopperPromotionCodeQuerySet) CodeLt(code string) ShopperPromotionCodeQuerySet {
|
||||
return qs.w(qs.db.Where("code < ?", code))
|
||||
}
|
||||
|
||||
// CodeLte is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs ShopperPromotionCodeQuerySet) CodeLte(code string) ShopperPromotionCodeQuerySet {
|
||||
return qs.w(qs.db.Where("code <= ?", code))
|
||||
}
|
||||
|
||||
// CodeNe is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs ShopperPromotionCodeQuerySet) CodeNe(code string) ShopperPromotionCodeQuerySet {
|
||||
return qs.w(qs.db.Where("code != ?", code))
|
||||
}
|
||||
|
||||
// CodeNotIn is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs ShopperPromotionCodeQuerySet) CodeNotIn(code ...string) ShopperPromotionCodeQuerySet {
|
||||
if len(code) == 0 {
|
||||
qs.db.AddError(errors.New("must at least pass one code in CodeNotIn"))
|
||||
return qs.w(qs.db)
|
||||
}
|
||||
return qs.w(qs.db.Where("code NOT IN (?)", code))
|
||||
}
|
||||
|
||||
// CodeNotlike is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs ShopperPromotionCodeQuerySet) CodeNotlike(code string) ShopperPromotionCodeQuerySet {
|
||||
return qs.w(qs.db.Where("code NOT LIKE ?", code))
|
||||
}
|
||||
|
||||
// Count is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs ShopperPromotionCodeQuerySet) Count() (int, error) {
|
||||
var count int
|
||||
err := qs.db.Count(&count).Error
|
||||
return count, err
|
||||
}
|
||||
|
||||
// CreatedAtEq is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs ShopperPromotionCodeQuerySet) CreatedAtEq(createdAt time.Time) ShopperPromotionCodeQuerySet {
|
||||
return qs.w(qs.db.Where("created_at = ?", createdAt))
|
||||
}
|
||||
|
||||
// CreatedAtGt is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs ShopperPromotionCodeQuerySet) CreatedAtGt(createdAt time.Time) ShopperPromotionCodeQuerySet {
|
||||
return qs.w(qs.db.Where("created_at > ?", createdAt))
|
||||
}
|
||||
|
||||
// CreatedAtGte is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs ShopperPromotionCodeQuerySet) CreatedAtGte(createdAt time.Time) ShopperPromotionCodeQuerySet {
|
||||
return qs.w(qs.db.Where("created_at >= ?", createdAt))
|
||||
}
|
||||
|
||||
// CreatedAtLt is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs ShopperPromotionCodeQuerySet) CreatedAtLt(createdAt time.Time) ShopperPromotionCodeQuerySet {
|
||||
return qs.w(qs.db.Where("created_at < ?", createdAt))
|
||||
}
|
||||
|
||||
// CreatedAtLte is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs ShopperPromotionCodeQuerySet) CreatedAtLte(createdAt time.Time) ShopperPromotionCodeQuerySet {
|
||||
return qs.w(qs.db.Where("created_at <= ?", createdAt))
|
||||
}
|
||||
|
||||
// CreatedAtNe is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs ShopperPromotionCodeQuerySet) CreatedAtNe(createdAt time.Time) ShopperPromotionCodeQuerySet {
|
||||
return qs.w(qs.db.Where("created_at != ?", createdAt))
|
||||
}
|
||||
|
||||
// Delete is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs ShopperPromotionCodeQuerySet) Delete() error {
|
||||
return qs.db.Delete(ShopperPromotionCode{}).Error
|
||||
}
|
||||
|
||||
// DeleteNum is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs ShopperPromotionCodeQuerySet) DeleteNum() (int64, error) {
|
||||
db := qs.db.Delete(ShopperPromotionCode{})
|
||||
return db.RowsAffected, db.Error
|
||||
}
|
||||
|
||||
// DeleteNumUnscoped is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs ShopperPromotionCodeQuerySet) DeleteNumUnscoped() (int64, error) {
|
||||
db := qs.db.Unscoped().Delete(ShopperPromotionCode{})
|
||||
return db.RowsAffected, db.Error
|
||||
}
|
||||
|
||||
// DeletedAtEq is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs ShopperPromotionCodeQuerySet) DeletedAtEq(deletedAt time.Time) ShopperPromotionCodeQuerySet {
|
||||
return qs.w(qs.db.Where("deleted_at = ?", deletedAt))
|
||||
}
|
||||
|
||||
// DeletedAtGt is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs ShopperPromotionCodeQuerySet) DeletedAtGt(deletedAt time.Time) ShopperPromotionCodeQuerySet {
|
||||
return qs.w(qs.db.Where("deleted_at > ?", deletedAt))
|
||||
}
|
||||
|
||||
// DeletedAtGte is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs ShopperPromotionCodeQuerySet) DeletedAtGte(deletedAt time.Time) ShopperPromotionCodeQuerySet {
|
||||
return qs.w(qs.db.Where("deleted_at >= ?", deletedAt))
|
||||
}
|
||||
|
||||
// DeletedAtIsNotNull is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs ShopperPromotionCodeQuerySet) DeletedAtIsNotNull() ShopperPromotionCodeQuerySet {
|
||||
return qs.w(qs.db.Where("deleted_at IS NOT NULL"))
|
||||
}
|
||||
|
||||
// DeletedAtIsNull is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs ShopperPromotionCodeQuerySet) DeletedAtIsNull() ShopperPromotionCodeQuerySet {
|
||||
return qs.w(qs.db.Where("deleted_at IS NULL"))
|
||||
}
|
||||
|
||||
// DeletedAtLt is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs ShopperPromotionCodeQuerySet) DeletedAtLt(deletedAt time.Time) ShopperPromotionCodeQuerySet {
|
||||
return qs.w(qs.db.Where("deleted_at < ?", deletedAt))
|
||||
}
|
||||
|
||||
// DeletedAtLte is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs ShopperPromotionCodeQuerySet) DeletedAtLte(deletedAt time.Time) ShopperPromotionCodeQuerySet {
|
||||
return qs.w(qs.db.Where("deleted_at <= ?", deletedAt))
|
||||
}
|
||||
|
||||
// DeletedAtNe is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs ShopperPromotionCodeQuerySet) DeletedAtNe(deletedAt time.Time) ShopperPromotionCodeQuerySet {
|
||||
return qs.w(qs.db.Where("deleted_at != ?", deletedAt))
|
||||
}
|
||||
|
||||
// GetDB is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs ShopperPromotionCodeQuerySet) GetDB() *gorm.DB {
|
||||
return qs.db
|
||||
}
|
||||
|
||||
// GetUpdater is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs ShopperPromotionCodeQuerySet) GetUpdater() ShopperPromotionCodeUpdater {
|
||||
return NewShopperPromotionCodeUpdater(qs.db)
|
||||
}
|
||||
|
||||
// IDEq is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs ShopperPromotionCodeQuerySet) IDEq(ID uint32) ShopperPromotionCodeQuerySet {
|
||||
return qs.w(qs.db.Where("id = ?", ID))
|
||||
}
|
||||
|
||||
// IDGt is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs ShopperPromotionCodeQuerySet) IDGt(ID uint32) ShopperPromotionCodeQuerySet {
|
||||
return qs.w(qs.db.Where("id > ?", ID))
|
||||
}
|
||||
|
||||
// IDGte is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs ShopperPromotionCodeQuerySet) IDGte(ID uint32) ShopperPromotionCodeQuerySet {
|
||||
return qs.w(qs.db.Where("id >= ?", ID))
|
||||
}
|
||||
|
||||
// IDIn is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs ShopperPromotionCodeQuerySet) IDIn(ID ...uint32) ShopperPromotionCodeQuerySet {
|
||||
if len(ID) == 0 {
|
||||
qs.db.AddError(errors.New("must at least pass one ID in IDIn"))
|
||||
return qs.w(qs.db)
|
||||
}
|
||||
return qs.w(qs.db.Where("id IN (?)", ID))
|
||||
}
|
||||
|
||||
// IDLt is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs ShopperPromotionCodeQuerySet) IDLt(ID uint32) ShopperPromotionCodeQuerySet {
|
||||
return qs.w(qs.db.Where("id < ?", ID))
|
||||
}
|
||||
|
||||
// IDLte is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs ShopperPromotionCodeQuerySet) IDLte(ID uint32) ShopperPromotionCodeQuerySet {
|
||||
return qs.w(qs.db.Where("id <= ?", ID))
|
||||
}
|
||||
|
||||
// IDNe is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs ShopperPromotionCodeQuerySet) IDNe(ID uint32) ShopperPromotionCodeQuerySet {
|
||||
return qs.w(qs.db.Where("id != ?", ID))
|
||||
}
|
||||
|
||||
// IDNotIn is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs ShopperPromotionCodeQuerySet) IDNotIn(ID ...uint32) ShopperPromotionCodeQuerySet {
|
||||
if len(ID) == 0 {
|
||||
qs.db.AddError(errors.New("must at least pass one ID in IDNotIn"))
|
||||
return qs.w(qs.db)
|
||||
}
|
||||
return qs.w(qs.db.Where("id NOT IN (?)", ID))
|
||||
}
|
||||
|
||||
// Limit is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs ShopperPromotionCodeQuerySet) Limit(limit int) ShopperPromotionCodeQuerySet {
|
||||
return qs.w(qs.db.Limit(limit))
|
||||
}
|
||||
|
||||
// Offset is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs ShopperPromotionCodeQuerySet) Offset(offset int) ShopperPromotionCodeQuerySet {
|
||||
return qs.w(qs.db.Offset(offset))
|
||||
}
|
||||
|
||||
// One is used to retrieve one result. It returns gorm.ErrRecordNotFound
|
||||
// if nothing was fetched
|
||||
func (qs ShopperPromotionCodeQuerySet) One(ret *ShopperPromotionCode) error {
|
||||
return qs.db.First(ret).Error
|
||||
}
|
||||
|
||||
// OrderAscByCode is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs ShopperPromotionCodeQuerySet) OrderAscByCode() ShopperPromotionCodeQuerySet {
|
||||
return qs.w(qs.db.Order("code ASC"))
|
||||
}
|
||||
|
||||
// OrderAscByCreatedAt is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs ShopperPromotionCodeQuerySet) OrderAscByCreatedAt() ShopperPromotionCodeQuerySet {
|
||||
return qs.w(qs.db.Order("created_at ASC"))
|
||||
}
|
||||
|
||||
// OrderAscByDeletedAt is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs ShopperPromotionCodeQuerySet) OrderAscByDeletedAt() ShopperPromotionCodeQuerySet {
|
||||
return qs.w(qs.db.Order("deleted_at ASC"))
|
||||
}
|
||||
|
||||
// OrderAscByID is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs ShopperPromotionCodeQuerySet) OrderAscByID() ShopperPromotionCodeQuerySet {
|
||||
return qs.w(qs.db.Order("id ASC"))
|
||||
}
|
||||
|
||||
// OrderAscByState is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs ShopperPromotionCodeQuerySet) OrderAscByState() ShopperPromotionCodeQuerySet {
|
||||
return qs.w(qs.db.Order("state ASC"))
|
||||
}
|
||||
|
||||
// OrderAscByStoreId is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs ShopperPromotionCodeQuerySet) OrderAscByStoreId() ShopperPromotionCodeQuerySet {
|
||||
return qs.w(qs.db.Order("store_id ASC"))
|
||||
}
|
||||
|
||||
// OrderAscByUid is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs ShopperPromotionCodeQuerySet) OrderAscByUid() ShopperPromotionCodeQuerySet {
|
||||
return qs.w(qs.db.Order("uid ASC"))
|
||||
}
|
||||
|
||||
// OrderAscByUpdatedAt is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs ShopperPromotionCodeQuerySet) OrderAscByUpdatedAt() ShopperPromotionCodeQuerySet {
|
||||
return qs.w(qs.db.Order("updated_at ASC"))
|
||||
}
|
||||
|
||||
// OrderDescByCode is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs ShopperPromotionCodeQuerySet) OrderDescByCode() ShopperPromotionCodeQuerySet {
|
||||
return qs.w(qs.db.Order("code DESC"))
|
||||
}
|
||||
|
||||
// OrderDescByCreatedAt is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs ShopperPromotionCodeQuerySet) OrderDescByCreatedAt() ShopperPromotionCodeQuerySet {
|
||||
return qs.w(qs.db.Order("created_at DESC"))
|
||||
}
|
||||
|
||||
// OrderDescByDeletedAt is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs ShopperPromotionCodeQuerySet) OrderDescByDeletedAt() ShopperPromotionCodeQuerySet {
|
||||
return qs.w(qs.db.Order("deleted_at DESC"))
|
||||
}
|
||||
|
||||
// OrderDescByID is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs ShopperPromotionCodeQuerySet) OrderDescByID() ShopperPromotionCodeQuerySet {
|
||||
return qs.w(qs.db.Order("id DESC"))
|
||||
}
|
||||
|
||||
// OrderDescByState is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs ShopperPromotionCodeQuerySet) OrderDescByState() ShopperPromotionCodeQuerySet {
|
||||
return qs.w(qs.db.Order("state DESC"))
|
||||
}
|
||||
|
||||
// OrderDescByStoreId is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs ShopperPromotionCodeQuerySet) OrderDescByStoreId() ShopperPromotionCodeQuerySet {
|
||||
return qs.w(qs.db.Order("store_id DESC"))
|
||||
}
|
||||
|
||||
// OrderDescByUid is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs ShopperPromotionCodeQuerySet) OrderDescByUid() ShopperPromotionCodeQuerySet {
|
||||
return qs.w(qs.db.Order("uid DESC"))
|
||||
}
|
||||
|
||||
// OrderDescByUpdatedAt is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs ShopperPromotionCodeQuerySet) OrderDescByUpdatedAt() ShopperPromotionCodeQuerySet {
|
||||
return qs.w(qs.db.Order("updated_at DESC"))
|
||||
}
|
||||
|
||||
// StateEq is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs ShopperPromotionCodeQuerySet) StateEq(state uint32) ShopperPromotionCodeQuerySet {
|
||||
return qs.w(qs.db.Where("state = ?", state))
|
||||
}
|
||||
|
||||
// StateGt is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs ShopperPromotionCodeQuerySet) StateGt(state uint32) ShopperPromotionCodeQuerySet {
|
||||
return qs.w(qs.db.Where("state > ?", state))
|
||||
}
|
||||
|
||||
// StateGte is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs ShopperPromotionCodeQuerySet) StateGte(state uint32) ShopperPromotionCodeQuerySet {
|
||||
return qs.w(qs.db.Where("state >= ?", state))
|
||||
}
|
||||
|
||||
// StateIn is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs ShopperPromotionCodeQuerySet) StateIn(state ...uint32) ShopperPromotionCodeQuerySet {
|
||||
if len(state) == 0 {
|
||||
qs.db.AddError(errors.New("must at least pass one state in StateIn"))
|
||||
return qs.w(qs.db)
|
||||
}
|
||||
return qs.w(qs.db.Where("state IN (?)", state))
|
||||
}
|
||||
|
||||
// StateLt is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs ShopperPromotionCodeQuerySet) StateLt(state uint32) ShopperPromotionCodeQuerySet {
|
||||
return qs.w(qs.db.Where("state < ?", state))
|
||||
}
|
||||
|
||||
// StateLte is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs ShopperPromotionCodeQuerySet) StateLte(state uint32) ShopperPromotionCodeQuerySet {
|
||||
return qs.w(qs.db.Where("state <= ?", state))
|
||||
}
|
||||
|
||||
// StateNe is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs ShopperPromotionCodeQuerySet) StateNe(state uint32) ShopperPromotionCodeQuerySet {
|
||||
return qs.w(qs.db.Where("state != ?", state))
|
||||
}
|
||||
|
||||
// StateNotIn is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs ShopperPromotionCodeQuerySet) StateNotIn(state ...uint32) ShopperPromotionCodeQuerySet {
|
||||
if len(state) == 0 {
|
||||
qs.db.AddError(errors.New("must at least pass one state in StateNotIn"))
|
||||
return qs.w(qs.db)
|
||||
}
|
||||
return qs.w(qs.db.Where("state NOT IN (?)", state))
|
||||
}
|
||||
|
||||
// StoreIdEq is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs ShopperPromotionCodeQuerySet) StoreIdEq(storeId uint32) ShopperPromotionCodeQuerySet {
|
||||
return qs.w(qs.db.Where("store_id = ?", storeId))
|
||||
}
|
||||
|
||||
// StoreIdGt is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs ShopperPromotionCodeQuerySet) StoreIdGt(storeId uint32) ShopperPromotionCodeQuerySet {
|
||||
return qs.w(qs.db.Where("store_id > ?", storeId))
|
||||
}
|
||||
|
||||
// StoreIdGte is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs ShopperPromotionCodeQuerySet) StoreIdGte(storeId uint32) ShopperPromotionCodeQuerySet {
|
||||
return qs.w(qs.db.Where("store_id >= ?", storeId))
|
||||
}
|
||||
|
||||
// StoreIdIn is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs ShopperPromotionCodeQuerySet) StoreIdIn(storeId ...uint32) ShopperPromotionCodeQuerySet {
|
||||
if len(storeId) == 0 {
|
||||
qs.db.AddError(errors.New("must at least pass one storeId in StoreIdIn"))
|
||||
return qs.w(qs.db)
|
||||
}
|
||||
return qs.w(qs.db.Where("store_id IN (?)", storeId))
|
||||
}
|
||||
|
||||
// StoreIdLt is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs ShopperPromotionCodeQuerySet) StoreIdLt(storeId uint32) ShopperPromotionCodeQuerySet {
|
||||
return qs.w(qs.db.Where("store_id < ?", storeId))
|
||||
}
|
||||
|
||||
// StoreIdLte is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs ShopperPromotionCodeQuerySet) StoreIdLte(storeId uint32) ShopperPromotionCodeQuerySet {
|
||||
return qs.w(qs.db.Where("store_id <= ?", storeId))
|
||||
}
|
||||
|
||||
// StoreIdNe is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs ShopperPromotionCodeQuerySet) StoreIdNe(storeId uint32) ShopperPromotionCodeQuerySet {
|
||||
return qs.w(qs.db.Where("store_id != ?", storeId))
|
||||
}
|
||||
|
||||
// StoreIdNotIn is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs ShopperPromotionCodeQuerySet) StoreIdNotIn(storeId ...uint32) ShopperPromotionCodeQuerySet {
|
||||
if len(storeId) == 0 {
|
||||
qs.db.AddError(errors.New("must at least pass one storeId in StoreIdNotIn"))
|
||||
return qs.w(qs.db)
|
||||
}
|
||||
return qs.w(qs.db.Where("store_id NOT IN (?)", storeId))
|
||||
}
|
||||
|
||||
// UidEq is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs ShopperPromotionCodeQuerySet) UidEq(uid uint32) ShopperPromotionCodeQuerySet {
|
||||
return qs.w(qs.db.Where("uid = ?", uid))
|
||||
}
|
||||
|
||||
// UidGt is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs ShopperPromotionCodeQuerySet) UidGt(uid uint32) ShopperPromotionCodeQuerySet {
|
||||
return qs.w(qs.db.Where("uid > ?", uid))
|
||||
}
|
||||
|
||||
// UidGte is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs ShopperPromotionCodeQuerySet) UidGte(uid uint32) ShopperPromotionCodeQuerySet {
|
||||
return qs.w(qs.db.Where("uid >= ?", uid))
|
||||
}
|
||||
|
||||
// UidIn is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs ShopperPromotionCodeQuerySet) UidIn(uid ...uint32) ShopperPromotionCodeQuerySet {
|
||||
if len(uid) == 0 {
|
||||
qs.db.AddError(errors.New("must at least pass one uid in UidIn"))
|
||||
return qs.w(qs.db)
|
||||
}
|
||||
return qs.w(qs.db.Where("uid IN (?)", uid))
|
||||
}
|
||||
|
||||
// UidLt is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs ShopperPromotionCodeQuerySet) UidLt(uid uint32) ShopperPromotionCodeQuerySet {
|
||||
return qs.w(qs.db.Where("uid < ?", uid))
|
||||
}
|
||||
|
||||
// UidLte is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs ShopperPromotionCodeQuerySet) UidLte(uid uint32) ShopperPromotionCodeQuerySet {
|
||||
return qs.w(qs.db.Where("uid <= ?", uid))
|
||||
}
|
||||
|
||||
// UidNe is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs ShopperPromotionCodeQuerySet) UidNe(uid uint32) ShopperPromotionCodeQuerySet {
|
||||
return qs.w(qs.db.Where("uid != ?", uid))
|
||||
}
|
||||
|
||||
// UidNotIn is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs ShopperPromotionCodeQuerySet) UidNotIn(uid ...uint32) ShopperPromotionCodeQuerySet {
|
||||
if len(uid) == 0 {
|
||||
qs.db.AddError(errors.New("must at least pass one uid in UidNotIn"))
|
||||
return qs.w(qs.db)
|
||||
}
|
||||
return qs.w(qs.db.Where("uid NOT IN (?)", uid))
|
||||
}
|
||||
|
||||
// UpdatedAtEq is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs ShopperPromotionCodeQuerySet) UpdatedAtEq(updatedAt time.Time) ShopperPromotionCodeQuerySet {
|
||||
return qs.w(qs.db.Where("updated_at = ?", updatedAt))
|
||||
}
|
||||
|
||||
// UpdatedAtGt is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs ShopperPromotionCodeQuerySet) UpdatedAtGt(updatedAt time.Time) ShopperPromotionCodeQuerySet {
|
||||
return qs.w(qs.db.Where("updated_at > ?", updatedAt))
|
||||
}
|
||||
|
||||
// UpdatedAtGte is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs ShopperPromotionCodeQuerySet) UpdatedAtGte(updatedAt time.Time) ShopperPromotionCodeQuerySet {
|
||||
return qs.w(qs.db.Where("updated_at >= ?", updatedAt))
|
||||
}
|
||||
|
||||
// UpdatedAtLt is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs ShopperPromotionCodeQuerySet) UpdatedAtLt(updatedAt time.Time) ShopperPromotionCodeQuerySet {
|
||||
return qs.w(qs.db.Where("updated_at < ?", updatedAt))
|
||||
}
|
||||
|
||||
// UpdatedAtLte is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs ShopperPromotionCodeQuerySet) UpdatedAtLte(updatedAt time.Time) ShopperPromotionCodeQuerySet {
|
||||
return qs.w(qs.db.Where("updated_at <= ?", updatedAt))
|
||||
}
|
||||
|
||||
// UpdatedAtNe is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (qs ShopperPromotionCodeQuerySet) UpdatedAtNe(updatedAt time.Time) ShopperPromotionCodeQuerySet {
|
||||
return qs.w(qs.db.Where("updated_at != ?", updatedAt))
|
||||
}
|
||||
|
||||
// SetCode is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (u ShopperPromotionCodeUpdater) SetCode(code string) ShopperPromotionCodeUpdater {
|
||||
u.fields[string(ShopperPromotionCodeDBSchema.Code)] = code
|
||||
return u
|
||||
}
|
||||
|
||||
// SetCreatedAt is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (u ShopperPromotionCodeUpdater) SetCreatedAt(createdAt time.Time) ShopperPromotionCodeUpdater {
|
||||
u.fields[string(ShopperPromotionCodeDBSchema.CreatedAt)] = createdAt
|
||||
return u
|
||||
}
|
||||
|
||||
// SetDeletedAt is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (u ShopperPromotionCodeUpdater) SetDeletedAt(deletedAt *time.Time) ShopperPromotionCodeUpdater {
|
||||
u.fields[string(ShopperPromotionCodeDBSchema.DeletedAt)] = deletedAt
|
||||
return u
|
||||
}
|
||||
|
||||
// SetID is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (u ShopperPromotionCodeUpdater) SetID(ID uint32) ShopperPromotionCodeUpdater {
|
||||
u.fields[string(ShopperPromotionCodeDBSchema.ID)] = ID
|
||||
return u
|
||||
}
|
||||
|
||||
// SetState is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (u ShopperPromotionCodeUpdater) SetState(state uint32) ShopperPromotionCodeUpdater {
|
||||
u.fields[string(ShopperPromotionCodeDBSchema.State)] = state
|
||||
return u
|
||||
}
|
||||
|
||||
// SetStoreId is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (u ShopperPromotionCodeUpdater) SetStoreId(storeId uint32) ShopperPromotionCodeUpdater {
|
||||
u.fields[string(ShopperPromotionCodeDBSchema.StoreId)] = storeId
|
||||
return u
|
||||
}
|
||||
|
||||
// SetUid is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (u ShopperPromotionCodeUpdater) SetUid(uid uint32) ShopperPromotionCodeUpdater {
|
||||
u.fields[string(ShopperPromotionCodeDBSchema.Uid)] = uid
|
||||
return u
|
||||
}
|
||||
|
||||
// SetUpdatedAt is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (u ShopperPromotionCodeUpdater) SetUpdatedAt(updatedAt time.Time) ShopperPromotionCodeUpdater {
|
||||
u.fields[string(ShopperPromotionCodeDBSchema.UpdatedAt)] = updatedAt
|
||||
return u
|
||||
}
|
||||
|
||||
// Update is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (u ShopperPromotionCodeUpdater) Update() error {
|
||||
return u.db.Updates(u.fields).Error
|
||||
}
|
||||
|
||||
// UpdateNum is an autogenerated method
|
||||
// nolint: dupl
|
||||
func (u ShopperPromotionCodeUpdater) UpdateNum() (int64, error) {
|
||||
db := u.db.Updates(u.fields)
|
||||
return db.RowsAffected, db.Error
|
||||
}
|
||||
|
||||
// ===== END of query set ShopperPromotionCodeQuerySet
|
||||
|
||||
// ===== BEGIN of ShopperPromotionCode modifiers
|
||||
|
||||
// ShopperPromotionCodeDBSchemaField describes database schema field. It requires for method 'Update'
|
||||
type ShopperPromotionCodeDBSchemaField string
|
||||
|
||||
// String method returns string representation of field.
|
||||
// nolint: dupl
|
||||
func (f ShopperPromotionCodeDBSchemaField) String() string {
|
||||
return string(f)
|
||||
}
|
||||
|
||||
// ShopperPromotionCodeDBSchema stores db field names of ShopperPromotionCode
|
||||
var ShopperPromotionCodeDBSchema = struct {
|
||||
ID ShopperPromotionCodeDBSchemaField
|
||||
CreatedAt ShopperPromotionCodeDBSchemaField
|
||||
UpdatedAt ShopperPromotionCodeDBSchemaField
|
||||
DeletedAt ShopperPromotionCodeDBSchemaField
|
||||
Uid ShopperPromotionCodeDBSchemaField
|
||||
State ShopperPromotionCodeDBSchemaField
|
||||
Code ShopperPromotionCodeDBSchemaField
|
||||
StoreId ShopperPromotionCodeDBSchemaField
|
||||
}{
|
||||
|
||||
ID: ShopperPromotionCodeDBSchemaField("id"),
|
||||
CreatedAt: ShopperPromotionCodeDBSchemaField("created_at"),
|
||||
UpdatedAt: ShopperPromotionCodeDBSchemaField("updated_at"),
|
||||
DeletedAt: ShopperPromotionCodeDBSchemaField("deleted_at"),
|
||||
Uid: ShopperPromotionCodeDBSchemaField("uid"),
|
||||
State: ShopperPromotionCodeDBSchemaField("state"),
|
||||
Code: ShopperPromotionCodeDBSchemaField("code"),
|
||||
StoreId: ShopperPromotionCodeDBSchemaField("store_id"),
|
||||
}
|
||||
|
||||
// Update updates ShopperPromotionCode fields by primary key
|
||||
// nolint: dupl
|
||||
func (o *ShopperPromotionCode) Update(db *gorm.DB, fields ...ShopperPromotionCodeDBSchemaField) error {
|
||||
dbNameToFieldName := map[string]interface{}{
|
||||
"id": o.ID,
|
||||
"created_at": o.CreatedAt,
|
||||
"updated_at": o.UpdatedAt,
|
||||
"deleted_at": o.DeletedAt,
|
||||
"uid": o.Uid,
|
||||
"state": o.State,
|
||||
"code": o.Code,
|
||||
"store_id": o.StoreId,
|
||||
}
|
||||
u := map[string]interface{}{}
|
||||
for _, f := range fields {
|
||||
fs := f.String()
|
||||
u[fs] = dbNameToFieldName[fs]
|
||||
}
|
||||
if err := db.Model(o).Updates(u).Error; err != nil {
|
||||
if err == gorm.ErrRecordNotFound {
|
||||
return err
|
||||
}
|
||||
|
||||
return fmt.Errorf("can't update ShopperPromotionCode %v fields %v: %s",
|
||||
o, fields, err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// ShopperPromotionCodeUpdater is an ShopperPromotionCode updates manager
|
||||
type ShopperPromotionCodeUpdater struct {
|
||||
fields map[string]interface{}
|
||||
db *gorm.DB
|
||||
}
|
||||
|
||||
// NewShopperPromotionCodeUpdater creates new ShopperPromotionCode updater
|
||||
// nolint: dupl
|
||||
func NewShopperPromotionCodeUpdater(db *gorm.DB) ShopperPromotionCodeUpdater {
|
||||
return ShopperPromotionCodeUpdater{
|
||||
fields: map[string]interface{}{},
|
||||
db: db.Model(&ShopperPromotionCode{}),
|
||||
}
|
||||
}
|
||||
|
||||
// ===== END of ShopperPromotionCode modifiers
|
||||
|
||||
// ===== BEGIN of query set UserInviteQuerySet
|
||||
|
||||
// UserInviteQuerySet is an queryset type for UserInvite
|
||||
|
|
|
@ -70,6 +70,45 @@ func TestMemberVmConfig(t *testing.T) {
|
|||
fmt.Println("list:", string(bytes))
|
||||
}
|
||||
|
||||
func TestImportPromotionalSales(t *testing.T) {
|
||||
InitTestDB()
|
||||
ImportPromotionalSales()
|
||||
}
|
||||
|
||||
func ImportPromotionalSales() {
|
||||
NewStoreQuerySet(DBDev).NameLike("万象")
|
||||
names := []string{"林浩斌", "刘恭德", "李家栗", "张永威", "张彬", "黄泽岚", "曾小娜", "王迈", "成福", "马盛豪", "詹若慧", "陈泽锐"}
|
||||
codes := []string{"666666", "181818", "000000", "888888", "588888", "131313", "123456", "161616", "777777", "168168", "333333", "434343"}
|
||||
storeIds := []uint32{26, 23, 23, 23, 19, 19, 19, 18, 18, 13, 13, 13}
|
||||
var users []User
|
||||
err := NewUserQuerySet(DBDev).ShopAssistantNameIn(names...).All(&users)
|
||||
if err != nil {
|
||||
fmt.Println("err:", err)
|
||||
}
|
||||
userMap := make(map[string]User, 0)
|
||||
for i, _ := range users {
|
||||
userMap[users[i].ShopAssistantName] = users[i]
|
||||
}
|
||||
for i, _ := range codes {
|
||||
v, ok := userMap[names[i]]
|
||||
if ok {
|
||||
promotionCode := &ShopperPromotionCode{
|
||||
Uid: v.Uid,
|
||||
State: 2,
|
||||
Code: codes[i],
|
||||
StoreId: storeIds[i],
|
||||
}
|
||||
|
||||
err := DBDev.Create(promotionCode).Error
|
||||
if err != nil {
|
||||
fmt.Println("err", err)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//黄金会员 1500(开通)、3000(邀新)
|
||||
//白金会员 2000(开通)、4000(邀新)
|
||||
//黑金会员 3000(开通)、6000(邀新)
|
||||
|
|
|
@ -40,18 +40,21 @@ type Coupon struct {
|
|||
type UserCoupon struct {
|
||||
Model
|
||||
|
||||
Uid uint32 `json:"uid" gorm:"index"`
|
||||
CouponId uint32 `json:"coupon_id" gorm:"index"`
|
||||
CouponType string `json:"coupon_type"`
|
||||
ActivityType uint32 `json:"activity_type"` // 活动类型 1-会员续费 2-关注公众号 3-运费包
|
||||
ActivityId uint32 `json:"activity_id" gorm:"index"`
|
||||
Value uint32 `json:"value"`
|
||||
State uint32 `json:"state"` // 1-未使用 2-已使用 3-已过期
|
||||
ActiveStart time.Time `json:"active_start"` // 有效期开始
|
||||
ActiveEnd time.Time `json:"active_end"` // 有效期结束 零值永不结束
|
||||
UseTime time.Time `json:"use_time"` //
|
||||
MemberLevel uint32 `json:"member_level"` // 会员等级 1-用户 2-会员
|
||||
Coupon *Coupon `json:"coupon" gorm:"-"`
|
||||
Uid uint32 `json:"uid" gorm:"index"`
|
||||
CouponId uint32 `json:"coupon_id" gorm:"index"`
|
||||
CouponType string `json:"coupon_type"`
|
||||
ActivityType uint32 `json:"activity_type"` // 活动类型 1-会员续费 2-关注公众号 3-运费包
|
||||
ActivityId uint32 `json:"activity_id" gorm:"index"`
|
||||
Value uint32 `json:"value"`
|
||||
State uint32 `json:"state"` // 1-未使用 2-已使用 3-已过期
|
||||
ActiveStart time.Time `json:"active_start"` // 有效期开始
|
||||
ActiveEnd time.Time `json:"active_end"` // 有效期结束 零值永不结束
|
||||
UseTime time.Time `json:"use_time"` //
|
||||
MemberLevel uint32 `json:"member_level"` // 会员等级 1-用户 2-会员
|
||||
Approach uint32 `json:"approach"` // 获取途径:
|
||||
PromotionalSales uint32 `json:"promotional_sales"`
|
||||
RedeemCode string `json:"redeem_code"`
|
||||
Coupon *Coupon `json:"coupon" gorm:"-"`
|
||||
}
|
||||
|
||||
// gen:qs
|
||||
|
|
|
@ -153,6 +153,8 @@ func InitTestDB() {
|
|||
&UserMemberDurationRecord{},
|
||||
&Statistic{},
|
||||
&UserActionLog{},
|
||||
&UserCoupon{},
|
||||
&ShopperPromotionCode{},
|
||||
)
|
||||
|
||||
fmt.Println("DB init success")
|
||||
|
@ -192,11 +194,14 @@ func InitDBProd() {
|
|||
//&RedeemCode{},
|
||||
//&PublicRecord{},
|
||||
|
||||
&Order{},
|
||||
&OrderCard{},
|
||||
&UserMemberDurationRecord{},
|
||||
&Statistic{},
|
||||
&UserActionLog{},
|
||||
//&Order{},
|
||||
//&OrderCard{},
|
||||
//&UserMemberDurationRecord{},
|
||||
//&Statistic{},
|
||||
//&UserActionLog{},
|
||||
|
||||
&ShopperPromotionCode{},
|
||||
&UserCoupon{},
|
||||
)
|
||||
|
||||
if err := DBProd.DB().Ping(); err != nil {
|
||||
|
@ -1878,3 +1883,180 @@ func PushWXPayNoticeInfo() {
|
|||
logger.Debug("微信推动支付通知")
|
||||
|
||||
}
|
||||
|
||||
func TestUserRedeemCodeConvert(t *testing.T) {
|
||||
|
||||
UserRedeemCodeConvert(45168343, "MC302F140B2D675674C1F6C")
|
||||
}
|
||||
|
||||
func TestNameScanInvite(t *testing.T) {
|
||||
InitTestDB()
|
||||
DB = DBDev
|
||||
|
||||
InviteUid := uint32(63192613)
|
||||
Uid := uint32(45321263)
|
||||
|
||||
inviteUser := GetUserByUid(InviteUid)
|
||||
user := GetUserByUid(Uid)
|
||||
|
||||
nowTime := time.Now()
|
||||
if Uid != 0 {
|
||||
exist, err := QueryRecordExist(
|
||||
fmt.Sprintf("SELECT * FROM user_invite_record WHERE to_uid = %d AND from_uid = %d ",
|
||||
Uid, InviteUid))
|
||||
if err != nil {
|
||||
logger.Error("query err:", err)
|
||||
return
|
||||
}
|
||||
if !exist {
|
||||
firstInviteRecord := &UserInviteRecord{
|
||||
ToUid: Uid,
|
||||
FromUid: InviteUid,
|
||||
Action: 2,
|
||||
SpendType: 1,
|
||||
MemberLevel: 0,
|
||||
First: 1,
|
||||
Scan: 1,
|
||||
ActionTime: nowTime,
|
||||
}
|
||||
err = DB.Create(firstInviteRecord).Error
|
||||
if err != nil {
|
||||
logger.Error("create user invite record err:", err)
|
||||
}
|
||||
}
|
||||
|
||||
inviteRecord := &UserInviteRecord{
|
||||
ToUid: Uid,
|
||||
FromUid: InviteUid,
|
||||
Action: 1,
|
||||
SpendType: 1,
|
||||
MemberLevel: 0,
|
||||
First: 0,
|
||||
Scan: 1,
|
||||
ActionTime: nowTime,
|
||||
}
|
||||
err = DB.Create(inviteRecord).Error
|
||||
if err != nil {
|
||||
logger.Error("create user invite record err:", err)
|
||||
}
|
||||
|
||||
var inviteNew UserInvite
|
||||
inviteErr := NewUserInviteQuerySet(DB).ToUidEq(Uid).FromUidEq(InviteUid).ActionEq(1).
|
||||
SpendTypeEq(1).One(&inviteNew)
|
||||
if inviteErr != nil && inviteErr != RecordNotFound {
|
||||
logger.Error("user invite err:", err)
|
||||
}
|
||||
fmt.Println("inviteErr:", inviteErr)
|
||||
fmt.Printf("inviteNew:%#v \n", inviteNew)
|
||||
if inviteErr == RecordNotFound {
|
||||
memberLevel := user.MemberLevel
|
||||
if memberLevel == 0 {
|
||||
memberLevel = MemberTypeConsumer
|
||||
}
|
||||
invite := &UserInvite{
|
||||
FromUid: InviteUid,
|
||||
UserType: inviteUser.UserType,
|
||||
StoreId: inviteUser.StoreId,
|
||||
MemberOpenTime: time.Now(),
|
||||
MemberType: memberLevel,
|
||||
MemberStatus: 1,
|
||||
ToUid: user.Uid,
|
||||
Action: 1,
|
||||
SpendType: 1,
|
||||
UserInviteRecordId: inviteRecord.ID,
|
||||
FirstInvite: 0, // TODO
|
||||
Scan: 1,
|
||||
}
|
||||
fmt.Println("创建邀请:", invite)
|
||||
//count, err := model.NewUserInviteQuerySet(model.DB).FromUidEq(req.InviteUid).ToUidEq(user.Uid).Count()
|
||||
//if err != nil {
|
||||
// logger.Error(err)
|
||||
// RespJson(c, status.InternalServerError, nil)
|
||||
// return
|
||||
//}
|
||||
//if count == 0 {
|
||||
//}
|
||||
if err := invite.Create(DB); err != nil {
|
||||
logger.Error(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if inviteErr == nil {
|
||||
//err = model.NewUserInviteQuerySet(model.DB).IDEq(inviteNew.ID).GetUpdater().
|
||||
// SetFromUid(req.InviteUid).SetStoreId(inviteUser.StoreId).SetUserInviteRecordId(inviteRecord.ID).Update()
|
||||
err = NewUserInviteQuerySet(DB).IDEq(inviteNew.ID).GetUpdater().SetCreatedAt(nowTime).
|
||||
SetUserInviteRecordId(inviteRecord.ID).Update()
|
||||
if err != nil {
|
||||
logger.Error("from uid update user invite err:", err, InviteUid)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestNewUser(t *testing.T) {
|
||||
InitTestDB()
|
||||
DB = DBDev
|
||||
|
||||
InviteUid := uint32(63192613)
|
||||
Uid := uint32(45321263)
|
||||
user := GetUserByUid(Uid)
|
||||
nowTime := time.Now()
|
||||
|
||||
if InviteUid != 0 {
|
||||
inviteRecordFirst := &UserInviteRecord{
|
||||
ToUid: Uid,
|
||||
FromUid: InviteUid,
|
||||
Action: 2,
|
||||
SpendType: 1,
|
||||
MemberLevel: 0,
|
||||
First: 1,
|
||||
Scan: 1,
|
||||
ActionTime: nowTime,
|
||||
}
|
||||
err := DB.Create(inviteRecordFirst).Error
|
||||
if err != nil {
|
||||
logger.Error("create user invite record err:", err)
|
||||
}
|
||||
|
||||
inviteRecord := &UserInviteRecord{
|
||||
ToUid: Uid,
|
||||
FromUid: InviteUid,
|
||||
Action: 1,
|
||||
SpendType: 1,
|
||||
MemberLevel: 0,
|
||||
First: 0,
|
||||
Scan: 1,
|
||||
ActionTime: nowTime,
|
||||
}
|
||||
err = DB.Create(inviteRecord).Error
|
||||
if err != nil {
|
||||
logger.Error("create user invite record err:", err)
|
||||
}
|
||||
|
||||
inviteUser := GetUserByUid(InviteUid)
|
||||
user.StoreId = inviteUser.StoreId
|
||||
user.UserType = UserTypeConsumer
|
||||
user.CooperativeBusinessId = inviteUser.CooperativeBusinessId
|
||||
user.CooperativeName = inviteUser.CooperativeName
|
||||
|
||||
invite := &UserInvite{
|
||||
FromUid: InviteUid,
|
||||
UserType: inviteUser.UserType,
|
||||
StoreId: inviteUser.StoreId,
|
||||
MemberType: MemberTypeConsumer,
|
||||
ToUid: user.Uid,
|
||||
MemberStatus: 1,
|
||||
Action: 1,
|
||||
SpendType: 1,
|
||||
UserInviteRecordId: inviteRecord.ID,
|
||||
Scan: 1,
|
||||
}
|
||||
|
||||
if err := invite.Create(DB); err != nil {
|
||||
logger.Error(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -108,6 +108,7 @@ func UserRedeemCodeList(uid uint32) ([]UserRedeemCode, error) {
|
|||
return append(holdList, usedList...), nil
|
||||
}
|
||||
|
||||
// 会员兑换码兑换
|
||||
func UserRedeemCodeConvert(uid uint32, serialCode string) error {
|
||||
var userRedeem UserRedeemCode
|
||||
err := NewUserRedeemCodeQuerySet(DB).UidEq(uid).SerialCodeEq(serialCode).One(&userRedeem)
|
||||
|
@ -296,3 +297,18 @@ func SendUserVm(uid, memberLevel, inviteLevel uint32) error {
|
|||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func GetUserRenewalCouponIds() ([]uint32, error) {
|
||||
ids := make([]uint32, 0)
|
||||
var coupons []Coupon
|
||||
err := NewCouponQuerySet(DB).ActivityIdEq(1).All(&coupons)
|
||||
if err != nil {
|
||||
logger.Error("coupons err:", err)
|
||||
return ids, err
|
||||
}
|
||||
for i, _ := range coupons {
|
||||
ids = append(ids, coupons[i].ID)
|
||||
}
|
||||
|
||||
return ids, nil
|
||||
}
|
||||
|
|
162
model/user.go
162
model/user.go
|
@ -206,6 +206,17 @@ type XcxRole struct {
|
|||
DeptIds []int `json:"deptIds" gorm:"-"`
|
||||
}
|
||||
|
||||
// gen:qs
|
||||
type ShopperPromotionCode struct {
|
||||
Model
|
||||
|
||||
Uid uint32 `json:"uid" gorm:"column:uid;index"`
|
||||
State uint32 `json:"state"` // 1-停用 2-使用
|
||||
Code string `json:"code" gorm:"index"`
|
||||
StoreId uint32 `json:"store_id"` // 门店id
|
||||
// shopper_promotion_code
|
||||
}
|
||||
|
||||
func GetUserByUid(uid uint32) *User {
|
||||
user := new(User)
|
||||
if err := NewUserQuerySet(DB).UidEq(uid).One(user); err != nil {
|
||||
|
@ -563,13 +574,20 @@ func (m *UserInviteListReq) InviteUserList() (*UserInviteListResp, error) {
|
|||
m.PageSize = 10
|
||||
}
|
||||
|
||||
qs := NewUserInviteQuerySet(DB).FromUidEq(m.Uid)
|
||||
qs := NewUserInviteQuerySet(DB).FromUidEq(m.Uid).ActionEq(2)
|
||||
if m.MemberType != 0 {
|
||||
qs = qs.MemberTypeEq(uint32(m.MemberType))
|
||||
if m.MemberType == 2 {
|
||||
user := GetUserByUid(m.Uid)
|
||||
//qs = qs.FirstInviteNe(1).SpendTypeEq(2)
|
||||
//qs = qs.SpendTypeEq(2)
|
||||
qs = qs.SpendTypeNotIn([]uint32{3, 4}...)
|
||||
//qs = qs.SpendTypeNotIn([]uint32{3, 4}...)
|
||||
if user.CooperativeBusinessId == 1 {
|
||||
qs = qs.SpendTypeIn([]uint32{2, 3}...)
|
||||
} else {
|
||||
qs = qs.SpendTypeNotIn([]uint32{3, 4}...)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
if m.StartTime != "" {
|
||||
|
@ -1081,3 +1099,143 @@ type MemberStatisticDaily struct {
|
|||
Net uint32 `json:"net"`
|
||||
Accumulative uint32 `json:"accumulative"`
|
||||
}
|
||||
|
||||
func StorePromotion(inviteUid, uid uint32, inviteUser, user *User) error {
|
||||
//inviteUid := uint32(0)
|
||||
//uid := uint32(0)
|
||||
if inviteUser == nil {
|
||||
inviteUser = GetUserByUid(inviteUid)
|
||||
}
|
||||
if user == nil {
|
||||
user = GetUserByUid(uid)
|
||||
}
|
||||
|
||||
if user == nil || inviteUser == nil {
|
||||
logger.Error("user inviteUser is nil")
|
||||
return errors.New("user inviteUser is nil")
|
||||
}
|
||||
nowTime := time.Now()
|
||||
|
||||
if inviteUser.UserType == 2 && user.Uid != 0 {
|
||||
exist, err := QueryRecordExist(
|
||||
fmt.Sprintf("SELECT * FROM user_invite_record WHERE to_uid = %d AND from_uid = %d ",
|
||||
user.Uid, inviteUid))
|
||||
if err != nil {
|
||||
logger.Error("query err:", err)
|
||||
return err
|
||||
}
|
||||
if !exist {
|
||||
firstInviteRecord := &UserInviteRecord{
|
||||
ToUid: user.Uid,
|
||||
FromUid: inviteUid,
|
||||
Action: 2,
|
||||
SpendType: 1,
|
||||
MemberLevel: 0,
|
||||
First: 1,
|
||||
Scan: 1,
|
||||
ActionTime: nowTime,
|
||||
}
|
||||
err = DB.Create(firstInviteRecord).Error
|
||||
if err != nil {
|
||||
logger.Error("create user invite record err:", err)
|
||||
}
|
||||
// 添加首次扫码
|
||||
}
|
||||
// 扫码记录
|
||||
inviteRecord := &UserInviteRecord{
|
||||
ToUid: user.Uid,
|
||||
FromUid: inviteUid,
|
||||
Action: 1,
|
||||
SpendType: 1,
|
||||
MemberLevel: 0,
|
||||
First: 0,
|
||||
Scan: 1,
|
||||
ActionTime: nowTime,
|
||||
}
|
||||
err = DB.Create(inviteRecord).Error
|
||||
if err != nil {
|
||||
logger.Error("create user invite record err:", err)
|
||||
}
|
||||
// UserInvite 邀请主要
|
||||
var inviteNew UserInvite
|
||||
inviteErr := NewUserInviteQuerySet(DB).ToUidEq(user.Uid).FromUidEq(inviteUid).ActionEq(1).
|
||||
SpendTypeEq(1).One(&inviteNew)
|
||||
if inviteErr != nil && inviteErr != RecordNotFound {
|
||||
// 是否存在未开通
|
||||
logger.Error("user invite err:", err)
|
||||
}
|
||||
//fmt.Println("inviteErr:", inviteErr)
|
||||
//fmt.Printf("inviteNew:%#v \n", inviteNew)
|
||||
if inviteErr == RecordNotFound {
|
||||
memberLevel := user.MemberLevel
|
||||
if memberLevel == 0 {
|
||||
memberLevel = MemberTypeConsumer
|
||||
}
|
||||
invite := &UserInvite{
|
||||
FromUid: inviteUid,
|
||||
UserType: inviteUser.UserType,
|
||||
StoreId: inviteUser.StoreId,
|
||||
MemberOpenTime: nowTime,
|
||||
MemberType: memberLevel,
|
||||
MemberStatus: 1,
|
||||
ToUid: user.Uid,
|
||||
Action: 1,
|
||||
SpendType: 1,
|
||||
UserInviteRecordId: inviteRecord.ID,
|
||||
FirstInvite: 0, // TODO
|
||||
Scan: 1,
|
||||
}
|
||||
fmt.Println("创建邀请:", invite)
|
||||
if err := invite.Create(DB); err != nil {
|
||||
logger.Error(err)
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if inviteErr == nil {
|
||||
err = NewUserInviteQuerySet(DB).IDEq(inviteNew.ID).GetUpdater().SetCreatedAt(nowTime).
|
||||
SetUserInviteRecordId(inviteRecord.ID).Update()
|
||||
if err != nil {
|
||||
logger.Error("from uid update user invite err:", err, inviteUid)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
//// todo
|
||||
//var userCoupon model.UserCoupon
|
||||
//err := model.NewUserCouponQuerySet(model.DB).IDEq(record.UserCouponId).One(&userCoupon)
|
||||
//if err != nil {
|
||||
//logger.Error("user coupon err:", err)
|
||||
//}
|
||||
// // UserInviteRecord
|
||||
// // user_invite
|
||||
// if userCoupon.PromotionalSales == 0 {
|
||||
// logger.Error("promotional sales is null")
|
||||
// } else {
|
||||
// inviteCouponUser := model.GetUserByUid(userCoupon.PromotionalSales)
|
||||
// if inviteCouponUser != nil {
|
||||
// userCouponInvite := &model.UserInvite{
|
||||
// FromUid: userCoupon.PromotionalSales,
|
||||
// UserType: inviteCouponUser.UserType, // user.UserType
|
||||
// StoreId: inviteCouponUser.StoreId,
|
||||
// MemberOpenTime: newTime,
|
||||
// MemberType: 2,
|
||||
// MemberStatus: 2,
|
||||
// ToUid: user.Uid,
|
||||
// StoreType: inviteCouponUser.StoreType,
|
||||
// Action: 1,
|
||||
// SpendType: spendType,
|
||||
// MemberLevel: record.MemberLevel,
|
||||
// UserInviteRecordId: 0,
|
||||
// FirstInvite: 1,
|
||||
// }
|
||||
//
|
||||
// err = userCouponInvite.Create(model.DB)
|
||||
// if err != nil {
|
||||
// logger.Error("create user coupon invite err:", err)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
|
Loading…
Reference in New Issue
Block a user