package jyy import ( "recook/internal/model/order" "git.oa00.com/go/mysql" "github.com/shopspring/decimal" "gorm.io/gorm" ) type ArgsLogisticsFee struct { ID int `json:"order_id" validate:"required"` Fee *decimal.Decimal `json:"fee"` } func (o logic) SetFee(args ArgsLogisticsFee) error { return mysql.Db.Transaction(func(tx *gorm.DB) error { if e := tx.Table((&order.Information{}).TableName()). Where("id = ?", args.ID). Where("can_pay = 0").Updates(map[string]interface{}{ "can_pay": true, "express_total_fee": args.Fee.Abs(), "actual_total_amount": gorm.Expr("actual_total_amount + ?", args.Fee.Abs()), }).Error; e != nil { return e } return nil }) }