优惠券相关逻辑
This commit is contained in:
parent
39aa34f6c2
commit
e112772826
|
|
@ -73,19 +73,30 @@ func (p DefParty) login() web_iris.Party {
|
|||
database.Instance().Model(&models.User{}).Where("open_id = ?", info.Openid).Find(&userInfo)
|
||||
if userInfo.Id == 0 {
|
||||
newUser := models.User{
|
||||
NickName: loginRequest.NickName,
|
||||
HeadImgUrl: loginRequest.HeadImgUrl,
|
||||
Amount: 0,
|
||||
OpenId: info.Openid,
|
||||
UnionId: info.Unionid,
|
||||
UserType: 0,
|
||||
Mobile: "",
|
||||
Role: 0,
|
||||
Status: 1,
|
||||
NickName: loginRequest.NickName,
|
||||
HeadImgUrl: loginRequest.HeadImgUrl,
|
||||
Amount: 0,
|
||||
OpenId: info.Openid,
|
||||
UnionId: info.Unionid,
|
||||
UserType: 0,
|
||||
Mobile: "",
|
||||
Role: 0,
|
||||
Status: 1,
|
||||
InviteUserId: loginRequest.InviteUserId,
|
||||
}
|
||||
err := database.Instance().Create(&newUser).Error
|
||||
zap_server.ZAPLOG.Info("create", zap.Any("err", err))
|
||||
userInfo = newUser
|
||||
for _, coupons := range CouponsMap {
|
||||
if coupons.SendStatus == 2 {
|
||||
//新注册用户下发优惠券
|
||||
newUserCoupons := models.UserCoupons{
|
||||
Uid: userInfo.Id,
|
||||
Cid: coupons.Id,
|
||||
}
|
||||
database.Instance().Create(&newUserCoupons)
|
||||
}
|
||||
}
|
||||
}
|
||||
token := genToken(userInfo.Id)
|
||||
response := LoginResponse{
|
||||
|
|
|
|||
|
|
@ -220,6 +220,18 @@ func (p DefParty) carServiceProcess() web_iris.Party {
|
|||
"LastServiceDate": pet.PetInfo.LastServiceDate,
|
||||
}
|
||||
database.Instance().Model(&pet.PetInfo).Updates(&updateValues)
|
||||
if orderUserInfo.InviteUserId > 0 {
|
||||
for _, coupons := range CouponsMap {
|
||||
if coupons.SendStatus == 3 {
|
||||
//完成订单给邀请用户发送优惠券
|
||||
newUserCoupons := models.UserCoupons{
|
||||
Uid: orderUserInfo.InviteUserId,
|
||||
Cid: coupons.Id,
|
||||
}
|
||||
database.Instance().Create(&newUserCoupons)
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if carServiceProcessRequest.Type == 3 {
|
||||
subOrderInfo.PayRemark = carServiceProcessRequest.PayRemark
|
||||
database.Instance().Save(&subOrderInfo)
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ func (p DefParty) getUserCouponsList() web_iris.Party {
|
|||
}
|
||||
|
||||
var coupons []models.Coupons
|
||||
database.Instance().Model(&models.Coupons{}).Joins("JOIN user_coupons on coupons.id = user_coupons.cid and coupons.expire_time > ?", time.Now().UnixNano()/int64(time.Millisecond)).Where(" user_coupons.coupons_status = ? and user_coupons.uid = ?", getUserCouponsListRequest.Status, headerInfo.Uid).Find(&coupons)
|
||||
database.Instance().Model(&models.Coupons{}).Joins("JOIN user_coupons on coupons.id = user_coupons.cid and coupons.expire_time > ? and coupons.send_status = 1", time.Now().UnixNano()/int64(time.Millisecond)).Where(" user_coupons.coupons_status = ? and user_coupons.uid = ?", getUserCouponsListRequest.Status, headerInfo.Uid).Find(&coupons)
|
||||
for index, coupon := range coupons {
|
||||
coupons[index].PeriodInfo = strings.Split(coupon.Period, ",")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -285,6 +285,7 @@ type Coupons struct {
|
|||
CreateTime time.Time `gorm:"type:timestamp;default:CURRENT_TIMESTAMP" json:"createTime"` //创建时间
|
||||
UpdateTime time.Time `gorm:"type:timestamp;default:CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP" json:"-"` //更新时间
|
||||
Status int `gorm:"default:1" json:"-"` //数据状态
|
||||
SendStatus int `gorm:"not null" json:"-"` //下发类型 1领取 2新用户注册赠送 3邀请新用户赠送
|
||||
}
|
||||
|
||||
type UserCoupons struct {
|
||||
|
|
|
|||
Loading…
Reference in New Issue