info address default
This commit is contained in:
parent
24304b0c85
commit
f8c8c634cb
|
@ -70,23 +70,22 @@ func (a *FsAddressModel) SettingUserDefaultAddress(ctx context.Context, userId i
|
|||
|
||||
logx.Info("address_id:", addressId, " set default ", isDefault)
|
||||
now := time.Now().UTC()
|
||||
var updates = map[string]interface{}{
|
||||
"ltime": now,
|
||||
"utime": now,
|
||||
}
|
||||
|
||||
if isDefault == 1 {
|
||||
err = tx.Where("`user_id` = ? and `status` = 1 and `ltime` > ? and `address_id` != ?", userId, now.AddDate(10, 0, 0), addressId).
|
||||
UpdateColumn("ltime", now).
|
||||
UpdateColumn("utime", now).Error
|
||||
UpdateColumns(updates).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
updates["ltime"] = now.AddDate(250, 0, 0)
|
||||
}
|
||||
|
||||
tr := tx.Model(&FsAddress{}).Where("`address_id` = ? and `user_id` = ? and `status` = 1", addressId, userId).
|
||||
UpdateColumn("utime", now)
|
||||
if isDefault == 1 {
|
||||
tr.UpdateColumn("ltime", now.AddDate(250, 0, 0))
|
||||
} else {
|
||||
tr.UpdateColumn("ltime", now)
|
||||
}
|
||||
UpdateColumns(updates)
|
||||
|
||||
err = tr.Error
|
||||
if err != nil {
|
||||
|
@ -100,6 +99,7 @@ func (a *FsAddressModel) SettingUserDefaultAddress(ctx context.Context, userId i
|
|||
}
|
||||
|
||||
func (a *FsAddressModel) DeleteOne(ctx context.Context, addressId int64, userId int64) (err error) {
|
||||
|
||||
err = a.db.WithContext(ctx).Model(&FsAddress{}).
|
||||
Where("`address_id` = ? and `user_id` = ? and `status` = 1 ", addressId, userId).
|
||||
UpdateColumn("status", 0).Error
|
||||
|
@ -111,9 +111,13 @@ func (a *FsAddressModel) UpdateUsedAddress(ctx context.Context, addressId int64,
|
|||
err = a.db.WithContext(ctx).Model(&FsAddress{}).Transaction(func(tx *gorm.DB) error {
|
||||
logx.Info("address_id:", addressId, " update used")
|
||||
now := time.Now().UTC()
|
||||
var updates = map[string]interface{}{
|
||||
"ltime": now,
|
||||
"utime": now,
|
||||
}
|
||||
|
||||
err = tx.Where("`address_id` = ? and `user_id` = ? and `status` = 1", addressId, userId).
|
||||
UpdateColumn("utime", now).
|
||||
UpdateColumn("ltime", now).Error
|
||||
UpdateColumns(updates).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user