You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
721 B

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
})
}