Browse Source

fix:修改付款方式

jimmyyem 2 weeks ago
parent
commit
7ea3a9302d

+ 1 - 1
desc/wechat/credit_balance.api

@@ -57,7 +57,7 @@ type (
 		OrganizationId  *uint64 `json:"organizationId,optional"`
 		Number  *float64 `json:"number,optional"`
 		PayNumber *float64 `json:"payNumber,optional"`
-		PayMethod *string `json:"payMethod,optional"`
+		PayMethod *int `json:"payMethod,optional"`
 		Reason *string `json:"reason,optional"`
 	}
 )

+ 1 - 1
desc/wechat/credit_usage.api

@@ -13,7 +13,7 @@ type (
 		BeforeNumber *float64 `json:"beforeNumber,optional"`
 		AfterNumber *float64 `json:"afterNumber,optional"`
 		PayNumber  *float64 `json:"payNumber,optional"`
-		PayMethod *string `json:"payMethod,optional"`
+		PayMethod *int `json:"payMethod,optional"`
 
         // status | 状态 1-正常 2-禁用 
         Status  *int `json:"status,optional"`

+ 6 - 6
ent/creditusage.go

@@ -34,7 +34,7 @@ type CreditUsage struct {
 	// after_number | 变动后金额
 	AfterNumber float64 `json:"after_number,omitempty"`
 	// pay_method | 充值方式
-	PayMethod string `json:"pay_method,omitempty"`
+	PayMethod int `json:"pay_method,omitempty"`
 	// status | 状态 1-正常 2-禁用
 	Status int `json:"status,omitempty"`
 	// ntype | 积分变化类型:1-消耗 2-增加
@@ -59,9 +59,9 @@ func (*CreditUsage) scanValues(columns []string) ([]any, error) {
 		switch columns[i] {
 		case creditusage.FieldNumber, creditusage.FieldPayNumber, creditusage.FieldBeforeNumber, creditusage.FieldAfterNumber:
 			values[i] = new(sql.NullFloat64)
-		case creditusage.FieldID, creditusage.FieldStatus, creditusage.FieldNtype, creditusage.FieldOrganizationID, creditusage.FieldNid:
+		case creditusage.FieldID, creditusage.FieldPayMethod, creditusage.FieldStatus, creditusage.FieldNtype, creditusage.FieldOrganizationID, creditusage.FieldNid:
 			values[i] = new(sql.NullInt64)
-		case creditusage.FieldUserID, creditusage.FieldPayMethod, creditusage.FieldTable, creditusage.FieldReason, creditusage.FieldOperator:
+		case creditusage.FieldUserID, creditusage.FieldTable, creditusage.FieldReason, creditusage.FieldOperator:
 			values[i] = new(sql.NullString)
 		case creditusage.FieldCreatedAt, creditusage.FieldUpdatedAt, creditusage.FieldDeletedAt:
 			values[i] = new(sql.NullTime)
@@ -135,10 +135,10 @@ func (cu *CreditUsage) assignValues(columns []string, values []any) error {
 				cu.AfterNumber = value.Float64
 			}
 		case creditusage.FieldPayMethod:
-			if value, ok := values[i].(*sql.NullString); !ok {
+			if value, ok := values[i].(*sql.NullInt64); !ok {
 				return fmt.Errorf("unexpected type %T for field pay_method", values[i])
 			} else if value.Valid {
-				cu.PayMethod = value.String
+				cu.PayMethod = int(value.Int64)
 			}
 		case creditusage.FieldStatus:
 			if value, ok := values[i].(*sql.NullInt64); !ok {
@@ -243,7 +243,7 @@ func (cu *CreditUsage) String() string {
 	builder.WriteString(fmt.Sprintf("%v", cu.AfterNumber))
 	builder.WriteString(", ")
 	builder.WriteString("pay_method=")
-	builder.WriteString(cu.PayMethod)
+	builder.WriteString(fmt.Sprintf("%v", cu.PayMethod))
 	builder.WriteString(", ")
 	builder.WriteString("status=")
 	builder.WriteString(fmt.Sprintf("%v", cu.Status))

+ 2 - 0
ent/creditusage/creditusage.go

@@ -97,6 +97,8 @@ var (
 	UpdateDefaultUpdatedAt func() time.Time
 	// UserIDValidator is a validator for the "user_id" field. It is called by the builders before save.
 	UserIDValidator func(string) error
+	// DefaultPayMethod holds the default value on creation for the "pay_method" field.
+	DefaultPayMethod int
 	// DefaultStatus holds the default value on creation for the "status" field.
 	DefaultStatus int
 	// StatusValidator is a validator for the "status" field. It is called by the builders before save.

+ 9 - 34
ent/creditusage/where.go

@@ -95,7 +95,7 @@ func AfterNumber(v float64) predicate.CreditUsage {
 }
 
 // PayMethod applies equality check predicate on the "pay_method" field. It's identical to PayMethodEQ.
-func PayMethod(v string) predicate.CreditUsage {
+func PayMethod(v int) predicate.CreditUsage {
 	return predicate.CreditUsage(sql.FieldEQ(FieldPayMethod, v))
 }
 
@@ -525,60 +525,45 @@ func AfterNumberNotNil() predicate.CreditUsage {
 }
 
 // PayMethodEQ applies the EQ predicate on the "pay_method" field.
-func PayMethodEQ(v string) predicate.CreditUsage {
+func PayMethodEQ(v int) predicate.CreditUsage {
 	return predicate.CreditUsage(sql.FieldEQ(FieldPayMethod, v))
 }
 
 // PayMethodNEQ applies the NEQ predicate on the "pay_method" field.
-func PayMethodNEQ(v string) predicate.CreditUsage {
+func PayMethodNEQ(v int) predicate.CreditUsage {
 	return predicate.CreditUsage(sql.FieldNEQ(FieldPayMethod, v))
 }
 
 // PayMethodIn applies the In predicate on the "pay_method" field.
-func PayMethodIn(vs ...string) predicate.CreditUsage {
+func PayMethodIn(vs ...int) predicate.CreditUsage {
 	return predicate.CreditUsage(sql.FieldIn(FieldPayMethod, vs...))
 }
 
 // PayMethodNotIn applies the NotIn predicate on the "pay_method" field.
-func PayMethodNotIn(vs ...string) predicate.CreditUsage {
+func PayMethodNotIn(vs ...int) predicate.CreditUsage {
 	return predicate.CreditUsage(sql.FieldNotIn(FieldPayMethod, vs...))
 }
 
 // PayMethodGT applies the GT predicate on the "pay_method" field.
-func PayMethodGT(v string) predicate.CreditUsage {
+func PayMethodGT(v int) predicate.CreditUsage {
 	return predicate.CreditUsage(sql.FieldGT(FieldPayMethod, v))
 }
 
 // PayMethodGTE applies the GTE predicate on the "pay_method" field.
-func PayMethodGTE(v string) predicate.CreditUsage {
+func PayMethodGTE(v int) predicate.CreditUsage {
 	return predicate.CreditUsage(sql.FieldGTE(FieldPayMethod, v))
 }
 
 // PayMethodLT applies the LT predicate on the "pay_method" field.
-func PayMethodLT(v string) predicate.CreditUsage {
+func PayMethodLT(v int) predicate.CreditUsage {
 	return predicate.CreditUsage(sql.FieldLT(FieldPayMethod, v))
 }
 
 // PayMethodLTE applies the LTE predicate on the "pay_method" field.
-func PayMethodLTE(v string) predicate.CreditUsage {
+func PayMethodLTE(v int) predicate.CreditUsage {
 	return predicate.CreditUsage(sql.FieldLTE(FieldPayMethod, v))
 }
 
-// PayMethodContains applies the Contains predicate on the "pay_method" field.
-func PayMethodContains(v string) predicate.CreditUsage {
-	return predicate.CreditUsage(sql.FieldContains(FieldPayMethod, v))
-}
-
-// PayMethodHasPrefix applies the HasPrefix predicate on the "pay_method" field.
-func PayMethodHasPrefix(v string) predicate.CreditUsage {
-	return predicate.CreditUsage(sql.FieldHasPrefix(FieldPayMethod, v))
-}
-
-// PayMethodHasSuffix applies the HasSuffix predicate on the "pay_method" field.
-func PayMethodHasSuffix(v string) predicate.CreditUsage {
-	return predicate.CreditUsage(sql.FieldHasSuffix(FieldPayMethod, v))
-}
-
 // PayMethodIsNil applies the IsNil predicate on the "pay_method" field.
 func PayMethodIsNil() predicate.CreditUsage {
 	return predicate.CreditUsage(sql.FieldIsNull(FieldPayMethod))
@@ -589,16 +574,6 @@ func PayMethodNotNil() predicate.CreditUsage {
 	return predicate.CreditUsage(sql.FieldNotNull(FieldPayMethod))
 }
 
-// PayMethodEqualFold applies the EqualFold predicate on the "pay_method" field.
-func PayMethodEqualFold(v string) predicate.CreditUsage {
-	return predicate.CreditUsage(sql.FieldEqualFold(FieldPayMethod, v))
-}
-
-// PayMethodContainsFold applies the ContainsFold predicate on the "pay_method" field.
-func PayMethodContainsFold(v string) predicate.CreditUsage {
-	return predicate.CreditUsage(sql.FieldContainsFold(FieldPayMethod, v))
-}
-
 // StatusEQ applies the EQ predicate on the "status" field.
 func StatusEQ(v int) predicate.CreditUsage {
 	return predicate.CreditUsage(sql.FieldEQ(FieldStatus, v))

+ 33 - 9
ent/creditusage_create.go

@@ -127,15 +127,15 @@ func (cuc *CreditUsageCreate) SetNillableAfterNumber(f *float64) *CreditUsageCre
 }
 
 // SetPayMethod sets the "pay_method" field.
-func (cuc *CreditUsageCreate) SetPayMethod(s string) *CreditUsageCreate {
-	cuc.mutation.SetPayMethod(s)
+func (cuc *CreditUsageCreate) SetPayMethod(i int) *CreditUsageCreate {
+	cuc.mutation.SetPayMethod(i)
 	return cuc
 }
 
 // SetNillablePayMethod sets the "pay_method" field if the given value is not nil.
-func (cuc *CreditUsageCreate) SetNillablePayMethod(s *string) *CreditUsageCreate {
-	if s != nil {
-		cuc.SetPayMethod(*s)
+func (cuc *CreditUsageCreate) SetNillablePayMethod(i *int) *CreditUsageCreate {
+	if i != nil {
+		cuc.SetPayMethod(*i)
 	}
 	return cuc
 }
@@ -295,6 +295,10 @@ func (cuc *CreditUsageCreate) defaults() error {
 		v := creditusage.DefaultUpdatedAt()
 		cuc.mutation.SetUpdatedAt(v)
 	}
+	if _, ok := cuc.mutation.PayMethod(); !ok {
+		v := creditusage.DefaultPayMethod
+		cuc.mutation.SetPayMethod(v)
+	}
 	if _, ok := cuc.mutation.Status(); !ok {
 		v := creditusage.DefaultStatus
 		cuc.mutation.SetStatus(v)
@@ -434,7 +438,7 @@ func (cuc *CreditUsageCreate) createSpec() (*CreditUsage, *sqlgraph.CreateSpec)
 		_node.AfterNumber = value
 	}
 	if value, ok := cuc.mutation.PayMethod(); ok {
-		_spec.SetField(creditusage.FieldPayMethod, field.TypeString, value)
+		_spec.SetField(creditusage.FieldPayMethod, field.TypeInt, value)
 		_node.PayMethod = value
 	}
 	if value, ok := cuc.mutation.Status(); ok {
@@ -656,7 +660,7 @@ func (u *CreditUsageUpsert) ClearAfterNumber() *CreditUsageUpsert {
 }
 
 // SetPayMethod sets the "pay_method" field.
-func (u *CreditUsageUpsert) SetPayMethod(v string) *CreditUsageUpsert {
+func (u *CreditUsageUpsert) SetPayMethod(v int) *CreditUsageUpsert {
 	u.Set(creditusage.FieldPayMethod, v)
 	return u
 }
@@ -667,6 +671,12 @@ func (u *CreditUsageUpsert) UpdatePayMethod() *CreditUsageUpsert {
 	return u
 }
 
+// AddPayMethod adds v to the "pay_method" field.
+func (u *CreditUsageUpsert) AddPayMethod(v int) *CreditUsageUpsert {
+	u.Add(creditusage.FieldPayMethod, v)
+	return u
+}
+
 // ClearPayMethod clears the value of the "pay_method" field.
 func (u *CreditUsageUpsert) ClearPayMethod() *CreditUsageUpsert {
 	u.SetNull(creditusage.FieldPayMethod)
@@ -1006,12 +1016,19 @@ func (u *CreditUsageUpsertOne) ClearAfterNumber() *CreditUsageUpsertOne {
 }
 
 // SetPayMethod sets the "pay_method" field.
-func (u *CreditUsageUpsertOne) SetPayMethod(v string) *CreditUsageUpsertOne {
+func (u *CreditUsageUpsertOne) SetPayMethod(v int) *CreditUsageUpsertOne {
 	return u.Update(func(s *CreditUsageUpsert) {
 		s.SetPayMethod(v)
 	})
 }
 
+// AddPayMethod adds v to the "pay_method" field.
+func (u *CreditUsageUpsertOne) AddPayMethod(v int) *CreditUsageUpsertOne {
+	return u.Update(func(s *CreditUsageUpsert) {
+		s.AddPayMethod(v)
+	})
+}
+
 // UpdatePayMethod sets the "pay_method" field to the value that was provided on create.
 func (u *CreditUsageUpsertOne) UpdatePayMethod() *CreditUsageUpsertOne {
 	return u.Update(func(s *CreditUsageUpsert) {
@@ -1545,12 +1562,19 @@ func (u *CreditUsageUpsertBulk) ClearAfterNumber() *CreditUsageUpsertBulk {
 }
 
 // SetPayMethod sets the "pay_method" field.
-func (u *CreditUsageUpsertBulk) SetPayMethod(v string) *CreditUsageUpsertBulk {
+func (u *CreditUsageUpsertBulk) SetPayMethod(v int) *CreditUsageUpsertBulk {
 	return u.Update(func(s *CreditUsageUpsert) {
 		s.SetPayMethod(v)
 	})
 }
 
+// AddPayMethod adds v to the "pay_method" field.
+func (u *CreditUsageUpsertBulk) AddPayMethod(v int) *CreditUsageUpsertBulk {
+	return u.Update(func(s *CreditUsageUpsert) {
+		s.AddPayMethod(v)
+	})
+}
+
 // UpdatePayMethod sets the "pay_method" field to the value that was provided on create.
 func (u *CreditUsageUpsertBulk) UpdatePayMethod() *CreditUsageUpsertBulk {
 	return u.Update(func(s *CreditUsageUpsert) {

+ 34 - 14
ent/creditusage_update.go

@@ -177,19 +177,26 @@ func (cuu *CreditUsageUpdate) ClearAfterNumber() *CreditUsageUpdate {
 }
 
 // SetPayMethod sets the "pay_method" field.
-func (cuu *CreditUsageUpdate) SetPayMethod(s string) *CreditUsageUpdate {
-	cuu.mutation.SetPayMethod(s)
+func (cuu *CreditUsageUpdate) SetPayMethod(i int) *CreditUsageUpdate {
+	cuu.mutation.ResetPayMethod()
+	cuu.mutation.SetPayMethod(i)
 	return cuu
 }
 
 // SetNillablePayMethod sets the "pay_method" field if the given value is not nil.
-func (cuu *CreditUsageUpdate) SetNillablePayMethod(s *string) *CreditUsageUpdate {
-	if s != nil {
-		cuu.SetPayMethod(*s)
+func (cuu *CreditUsageUpdate) SetNillablePayMethod(i *int) *CreditUsageUpdate {
+	if i != nil {
+		cuu.SetPayMethod(*i)
 	}
 	return cuu
 }
 
+// AddPayMethod adds i to the "pay_method" field.
+func (cuu *CreditUsageUpdate) AddPayMethod(i int) *CreditUsageUpdate {
+	cuu.mutation.AddPayMethod(i)
+	return cuu
+}
+
 // ClearPayMethod clears the value of the "pay_method" field.
 func (cuu *CreditUsageUpdate) ClearPayMethod() *CreditUsageUpdate {
 	cuu.mutation.ClearPayMethod()
@@ -467,10 +474,13 @@ func (cuu *CreditUsageUpdate) sqlSave(ctx context.Context) (n int, err error) {
 		_spec.ClearField(creditusage.FieldAfterNumber, field.TypeFloat64)
 	}
 	if value, ok := cuu.mutation.PayMethod(); ok {
-		_spec.SetField(creditusage.FieldPayMethod, field.TypeString, value)
+		_spec.SetField(creditusage.FieldPayMethod, field.TypeInt, value)
+	}
+	if value, ok := cuu.mutation.AddedPayMethod(); ok {
+		_spec.AddField(creditusage.FieldPayMethod, field.TypeInt, value)
 	}
 	if cuu.mutation.PayMethodCleared() {
-		_spec.ClearField(creditusage.FieldPayMethod, field.TypeString)
+		_spec.ClearField(creditusage.FieldPayMethod, field.TypeInt)
 	}
 	if value, ok := cuu.mutation.Status(); ok {
 		_spec.SetField(creditusage.FieldStatus, field.TypeInt, value)
@@ -680,19 +690,26 @@ func (cuuo *CreditUsageUpdateOne) ClearAfterNumber() *CreditUsageUpdateOne {
 }
 
 // SetPayMethod sets the "pay_method" field.
-func (cuuo *CreditUsageUpdateOne) SetPayMethod(s string) *CreditUsageUpdateOne {
-	cuuo.mutation.SetPayMethod(s)
+func (cuuo *CreditUsageUpdateOne) SetPayMethod(i int) *CreditUsageUpdateOne {
+	cuuo.mutation.ResetPayMethod()
+	cuuo.mutation.SetPayMethod(i)
 	return cuuo
 }
 
 // SetNillablePayMethod sets the "pay_method" field if the given value is not nil.
-func (cuuo *CreditUsageUpdateOne) SetNillablePayMethod(s *string) *CreditUsageUpdateOne {
-	if s != nil {
-		cuuo.SetPayMethod(*s)
+func (cuuo *CreditUsageUpdateOne) SetNillablePayMethod(i *int) *CreditUsageUpdateOne {
+	if i != nil {
+		cuuo.SetPayMethod(*i)
 	}
 	return cuuo
 }
 
+// AddPayMethod adds i to the "pay_method" field.
+func (cuuo *CreditUsageUpdateOne) AddPayMethod(i int) *CreditUsageUpdateOne {
+	cuuo.mutation.AddPayMethod(i)
+	return cuuo
+}
+
 // ClearPayMethod clears the value of the "pay_method" field.
 func (cuuo *CreditUsageUpdateOne) ClearPayMethod() *CreditUsageUpdateOne {
 	cuuo.mutation.ClearPayMethod()
@@ -1000,10 +1017,13 @@ func (cuuo *CreditUsageUpdateOne) sqlSave(ctx context.Context) (_node *CreditUsa
 		_spec.ClearField(creditusage.FieldAfterNumber, field.TypeFloat64)
 	}
 	if value, ok := cuuo.mutation.PayMethod(); ok {
-		_spec.SetField(creditusage.FieldPayMethod, field.TypeString, value)
+		_spec.SetField(creditusage.FieldPayMethod, field.TypeInt, value)
+	}
+	if value, ok := cuuo.mutation.AddedPayMethod(); ok {
+		_spec.AddField(creditusage.FieldPayMethod, field.TypeInt, value)
 	}
 	if cuuo.mutation.PayMethodCleared() {
-		_spec.ClearField(creditusage.FieldPayMethod, field.TypeString)
+		_spec.ClearField(creditusage.FieldPayMethod, field.TypeInt)
 	}
 	if value, ok := cuuo.mutation.Status(); ok {
 		_spec.SetField(creditusage.FieldStatus, field.TypeInt, value)

+ 1 - 1
ent/migrate/schema.go

@@ -416,7 +416,7 @@ var (
 		{Name: "pay_number", Type: field.TypeFloat64, Nullable: true, Comment: "pay_number | 充值金额"},
 		{Name: "before_number", Type: field.TypeFloat64, Nullable: true, Comment: "before_number | 变动前金额"},
 		{Name: "after_number", Type: field.TypeFloat64, Nullable: true, Comment: "after_number | 变动后金额"},
-		{Name: "pay_method", Type: field.TypeString, Nullable: true, Comment: "pay_method | 充值方式"},
+		{Name: "pay_method", Type: field.TypeInt, Nullable: true, Comment: "pay_method | 充值方式", Default: 1},
 		{Name: "status", Type: field.TypeInt, Nullable: true, Comment: "status | 状态 1-正常 2-禁用", Default: 1},
 		{Name: "ntype", Type: field.TypeInt, Comment: "ntype | 积分变化类型:1-消耗 2-增加", Default: 1},
 		{Name: "table", Type: field.TypeString, Comment: "table | 积分变化表名", Default: ""},

+ 40 - 6
ent/mutation.go

@@ -15062,7 +15062,8 @@ type CreditUsageMutation struct {
 	addbefore_number   *float64
 	after_number       *float64
 	addafter_number    *float64
-	pay_method         *string
+	pay_method         *int
+	addpay_method      *int
 	status             *int
 	addstatus          *int
 	ntype              *int
@@ -15621,12 +15622,13 @@ func (m *CreditUsageMutation) ResetAfterNumber() {
 }
 
 // SetPayMethod sets the "pay_method" field.
-func (m *CreditUsageMutation) SetPayMethod(s string) {
-	m.pay_method = &s
+func (m *CreditUsageMutation) SetPayMethod(i int) {
+	m.pay_method = &i
+	m.addpay_method = nil
 }
 
 // PayMethod returns the value of the "pay_method" field in the mutation.
-func (m *CreditUsageMutation) PayMethod() (r string, exists bool) {
+func (m *CreditUsageMutation) PayMethod() (r int, exists bool) {
 	v := m.pay_method
 	if v == nil {
 		return
@@ -15637,7 +15639,7 @@ func (m *CreditUsageMutation) PayMethod() (r string, exists bool) {
 // OldPayMethod returns the old "pay_method" field's value of the CreditUsage entity.
 // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
 // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
-func (m *CreditUsageMutation) OldPayMethod(ctx context.Context) (v string, err error) {
+func (m *CreditUsageMutation) OldPayMethod(ctx context.Context) (v int, err error) {
 	if !m.op.Is(OpUpdateOne) {
 		return v, errors.New("OldPayMethod is only allowed on UpdateOne operations")
 	}
@@ -15651,9 +15653,28 @@ func (m *CreditUsageMutation) OldPayMethod(ctx context.Context) (v string, err e
 	return oldValue.PayMethod, nil
 }
 
+// AddPayMethod adds i to the "pay_method" field.
+func (m *CreditUsageMutation) AddPayMethod(i int) {
+	if m.addpay_method != nil {
+		*m.addpay_method += i
+	} else {
+		m.addpay_method = &i
+	}
+}
+
+// AddedPayMethod returns the value that was added to the "pay_method" field in this mutation.
+func (m *CreditUsageMutation) AddedPayMethod() (r int, exists bool) {
+	v := m.addpay_method
+	if v == nil {
+		return
+	}
+	return *v, true
+}
+
 // ClearPayMethod clears the value of the "pay_method" field.
 func (m *CreditUsageMutation) ClearPayMethod() {
 	m.pay_method = nil
+	m.addpay_method = nil
 	m.clearedFields[creditusage.FieldPayMethod] = struct{}{}
 }
 
@@ -15666,6 +15687,7 @@ func (m *CreditUsageMutation) PayMethodCleared() bool {
 // ResetPayMethod resets all changes to the "pay_method" field.
 func (m *CreditUsageMutation) ResetPayMethod() {
 	m.pay_method = nil
+	m.addpay_method = nil
 	delete(m.clearedFields, creditusage.FieldPayMethod)
 }
 
@@ -16259,7 +16281,7 @@ func (m *CreditUsageMutation) SetField(name string, value ent.Value) error {
 		m.SetAfterNumber(v)
 		return nil
 	case creditusage.FieldPayMethod:
-		v, ok := value.(string)
+		v, ok := value.(int)
 		if !ok {
 			return fmt.Errorf("unexpected type %T for field %s", value, name)
 		}
@@ -16334,6 +16356,9 @@ func (m *CreditUsageMutation) AddedFields() []string {
 	if m.addafter_number != nil {
 		fields = append(fields, creditusage.FieldAfterNumber)
 	}
+	if m.addpay_method != nil {
+		fields = append(fields, creditusage.FieldPayMethod)
+	}
 	if m.addstatus != nil {
 		fields = append(fields, creditusage.FieldStatus)
 	}
@@ -16362,6 +16387,8 @@ func (m *CreditUsageMutation) AddedField(name string) (ent.Value, bool) {
 		return m.AddedBeforeNumber()
 	case creditusage.FieldAfterNumber:
 		return m.AddedAfterNumber()
+	case creditusage.FieldPayMethod:
+		return m.AddedPayMethod()
 	case creditusage.FieldStatus:
 		return m.AddedStatus()
 	case creditusage.FieldNtype:
@@ -16407,6 +16434,13 @@ func (m *CreditUsageMutation) AddField(name string, value ent.Value) error {
 		}
 		m.AddAfterNumber(v)
 		return nil
+	case creditusage.FieldPayMethod:
+		v, ok := value.(int)
+		if !ok {
+			return fmt.Errorf("unexpected type %T for field %s", value, name)
+		}
+		m.AddPayMethod(v)
+		return nil
 	case creditusage.FieldStatus:
 		v, ok := value.(int)
 		if !ok {

+ 4 - 0
ent/runtime/runtime.go

@@ -617,6 +617,10 @@ func init() {
 	creditusageDescUserID := creditusageFields[0].Descriptor()
 	// creditusage.UserIDValidator is a validator for the "user_id" field. It is called by the builders before save.
 	creditusage.UserIDValidator = creditusageDescUserID.Validators[0].(func(string) error)
+	// creditusageDescPayMethod is the schema descriptor for pay_method field.
+	creditusageDescPayMethod := creditusageFields[5].Descriptor()
+	// creditusage.DefaultPayMethod holds the default value on creation for the pay_method field.
+	creditusage.DefaultPayMethod = creditusageDescPayMethod.Default.(int)
 	// creditusageDescStatus is the schema descriptor for status field.
 	creditusageDescStatus := creditusageFields[6].Descriptor()
 	// creditusage.DefaultStatus holds the default value on creation for the status field.

+ 1 - 1
ent/schema/credit_usage.go

@@ -22,7 +22,7 @@ func (CreditUsage) Fields() []ent.Field {
 		field.Float("pay_number").Optional().Comment("pay_number | 充值金额"),
 		field.Float("before_number").Optional().Comment("before_number | 变动前金额"),
 		field.Float("after_number").Optional().Comment("after_number | 变动后金额"),
-		field.String("pay_method").Optional().Comment("pay_method | 充值方式"),
+		field.Int("pay_method").Optional().Default(1).Comment("pay_method | 充值方式"),
 		field.Int("status").Optional().Range(1, 2).Default(1).Comment("status | 状态 1-正常 2-禁用"),
 		field.Int("ntype").Default(1).Comment("ntype | 积分变化类型:1-消耗 2-增加"),
 		field.String("table").Default("").Comment("table | 积分变化表名"),

+ 3 - 3
ent/set_not_nil.go

@@ -3368,7 +3368,7 @@ func (cu *CreditUsageCreate) SetNotNilAfterNumber(value *float64) *CreditUsageCr
 }
 
 // set field if value's pointer is not nil.
-func (cu *CreditUsageUpdate) SetNotNilPayMethod(value *string) *CreditUsageUpdate {
+func (cu *CreditUsageUpdate) SetNotNilPayMethod(value *int) *CreditUsageUpdate {
 	if value != nil {
 		return cu.SetPayMethod(*value)
 	}
@@ -3376,7 +3376,7 @@ func (cu *CreditUsageUpdate) SetNotNilPayMethod(value *string) *CreditUsageUpdat
 }
 
 // set field if value's pointer is not nil.
-func (cu *CreditUsageUpdateOne) SetNotNilPayMethod(value *string) *CreditUsageUpdateOne {
+func (cu *CreditUsageUpdateOne) SetNotNilPayMethod(value *int) *CreditUsageUpdateOne {
 	if value != nil {
 		return cu.SetPayMethod(*value)
 	}
@@ -3384,7 +3384,7 @@ func (cu *CreditUsageUpdateOne) SetNotNilPayMethod(value *string) *CreditUsageUp
 }
 
 // set field if value's pointer is not nil.
-func (cu *CreditUsageCreate) SetNotNilPayMethod(value *string) *CreditUsageCreate {
+func (cu *CreditUsageCreate) SetNotNilPayMethod(value *int) *CreditUsageCreate {
 	if value != nil {
 		return cu.SetPayMethod(*value)
 	}

+ 2 - 2
internal/types/types.go

@@ -3643,7 +3643,7 @@ type CreditBalanceOperateReq struct {
 	OrganizationId *uint64  `json:"organizationId,optional"`
 	Number         *float64 `json:"number,optional"`
 	PayNumber      *float64 `json:"payNumber,optional"`
-	PayMethod      *string  `json:"payMethod,optional"`
+	PayMethod      *int     `json:"payMethod,optional"`
 	Reason         *string  `json:"reason,optional"`
 }
 
@@ -3658,7 +3658,7 @@ type CreditUsageInfo struct {
 	BeforeNumber *float64 `json:"beforeNumber,optional"`
 	AfterNumber  *float64 `json:"afterNumber,optional"`
 	PayNumber    *float64 `json:"payNumber,optional"`
-	PayMethod    *string  `json:"payMethod,optional"`
+	PayMethod    *int     `json:"payMethod,optional"`
 	// status | 状态 1-正常 2-禁用
 	Status *int `json:"status,optional"`
 	// ntype | 积分变化类型:1-消耗 2-增加