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)
|
logx.Info("address_id:", addressId, " set default ", isDefault)
|
||||||
now := time.Now().UTC()
|
now := time.Now().UTC()
|
||||||
|
var updates = map[string]interface{}{
|
||||||
|
"ltime": now,
|
||||||
|
"utime": now,
|
||||||
|
}
|
||||||
|
|
||||||
if isDefault == 1 {
|
if isDefault == 1 {
|
||||||
err = tx.Where("`user_id` = ? and `status` = 1 and `ltime` > ? and `address_id` != ?", userId, now.AddDate(10, 0, 0), addressId).
|
err = tx.Where("`user_id` = ? and `status` = 1 and `ltime` > ? and `address_id` != ?", userId, now.AddDate(10, 0, 0), addressId).
|
||||||
UpdateColumn("ltime", now).
|
UpdateColumns(updates).Error
|
||||||
UpdateColumn("utime", now).Error
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
updates["ltime"] = now.AddDate(250, 0, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
tr := tx.Model(&FsAddress{}).Where("`address_id` = ? and `user_id` = ? and `status` = 1", addressId, userId).
|
tr := tx.Model(&FsAddress{}).Where("`address_id` = ? and `user_id` = ? and `status` = 1", addressId, userId).
|
||||||
UpdateColumn("utime", now)
|
UpdateColumns(updates)
|
||||||
if isDefault == 1 {
|
|
||||||
tr.UpdateColumn("ltime", now.AddDate(250, 0, 0))
|
|
||||||
} else {
|
|
||||||
tr.UpdateColumn("ltime", now)
|
|
||||||
}
|
|
||||||
|
|
||||||
err = tr.Error
|
err = tr.Error
|
||||||
if err != nil {
|
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) {
|
func (a *FsAddressModel) DeleteOne(ctx context.Context, addressId int64, userId int64) (err error) {
|
||||||
|
|
||||||
err = a.db.WithContext(ctx).Model(&FsAddress{}).
|
err = a.db.WithContext(ctx).Model(&FsAddress{}).
|
||||||
Where("`address_id` = ? and `user_id` = ? and `status` = 1 ", addressId, userId).
|
Where("`address_id` = ? and `user_id` = ? and `status` = 1 ", addressId, userId).
|
||||||
UpdateColumn("status", 0).Error
|
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 {
|
err = a.db.WithContext(ctx).Model(&FsAddress{}).Transaction(func(tx *gorm.DB) error {
|
||||||
logx.Info("address_id:", addressId, " update used")
|
logx.Info("address_id:", addressId, " update used")
|
||||||
now := time.Now().UTC()
|
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).
|
err = tx.Where("`address_id` = ? and `user_id` = ? and `status` = 1", addressId, userId).
|
||||||
UpdateColumn("utime", now).
|
UpdateColumns(updates).Error
|
||||||
UpdateColumn("ltime", now).Error
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user