Преглед на файлове

fix:修改创建wa群发任务字段

jimmyyem преди 1 месец
родител
ревизия
5c75753f58

+ 0 - 2
crontask/send_msg.go

@@ -137,7 +137,6 @@ func (l *CronTask) sendMsg() {
 							SetMsgtype(int32(msgItem.Type)).
 							SetNotNilMsg(&msgItem.Content).
 							SetStatus(0).
-							SetCtype(1).
 							SetNotNilBatchNo(&batch.BatchNo)
 
 						msgs = append(msgs, msgRow)
@@ -184,7 +183,6 @@ func (l *CronTask) sendMsg() {
 		msglist, err := l.svcCtx.DB.Msg.Query().Where(
 			msg.BatchNoEQ(batch.BatchNo),
 			msg.StatusEQ(0),
-			msg.Ctype(1),
 		).All(l.ctx)
 		if err != nil {
 			l.Logger.Errorf("msglist err: %v", err)

+ 2 - 0
desc/wechat/batch_msg.api

@@ -118,6 +118,8 @@ type (
 	WhatsappBatchMsgHistoryReq {
 		PageInfo
 		IDReq
+		Status *uint8 `json:"status,optional"`
+		Phone *string `json:"phone,optional"`
 	}
 	WhatsappBatchMsgHistoryResp {
 		BaseDataInfo

+ 0 - 1
ent/migrate/schema.go

@@ -583,7 +583,6 @@ var (
 		{Name: "msgtype", Type: field.TypeInt32, Nullable: true, Comment: "消息类型"},
 		{Name: "msg", Type: field.TypeString, Nullable: true, Comment: "消息"},
 		{Name: "batch_no", Type: field.TypeString, Nullable: true, Comment: "批次号"},
-		{Name: "ctype", Type: field.TypeUint64, Comment: "内容类型:1-微信 2-whatsapp", Default: 1},
 		{Name: "cc", Type: field.TypeString, Comment: "国家区号", Default: ""},
 		{Name: "phone", Type: field.TypeString, Comment: "手机号", Default: ""},
 	}

+ 1 - 12
ent/msg.go

@@ -35,8 +35,6 @@ type Msg struct {
 	Msg string `json:"msg,omitempty"`
 	// 批次号
 	BatchNo string `json:"batch_no,omitempty"`
-	// 内容类型:1-微信 2-whatsapp
-	Ctype uint64 `json:"ctype,omitempty"`
 	// 国家区号
 	Cc string `json:"cc,omitempty"`
 	// 手机号
@@ -49,7 +47,7 @@ func (*Msg) scanValues(columns []string) ([]any, error) {
 	values := make([]any, len(columns))
 	for i := range columns {
 		switch columns[i] {
-		case msg.FieldID, msg.FieldStatus, msg.FieldMsgtype, msg.FieldCtype:
+		case msg.FieldID, msg.FieldStatus, msg.FieldMsgtype:
 			values[i] = new(sql.NullInt64)
 		case msg.FieldFromwxid, msg.FieldToid, msg.FieldMsg, msg.FieldBatchNo, msg.FieldCc, msg.FieldPhone:
 			values[i] = new(sql.NullString)
@@ -130,12 +128,6 @@ func (m *Msg) assignValues(columns []string, values []any) error {
 			} else if value.Valid {
 				m.BatchNo = value.String
 			}
-		case msg.FieldCtype:
-			if value, ok := values[i].(*sql.NullInt64); !ok {
-				return fmt.Errorf("unexpected type %T for field ctype", values[i])
-			} else if value.Valid {
-				m.Ctype = uint64(value.Int64)
-			}
 		case msg.FieldCc:
 			if value, ok := values[i].(*sql.NullString); !ok {
 				return fmt.Errorf("unexpected type %T for field cc", values[i])
@@ -211,9 +203,6 @@ func (m *Msg) String() string {
 	builder.WriteString("batch_no=")
 	builder.WriteString(m.BatchNo)
 	builder.WriteString(", ")
-	builder.WriteString("ctype=")
-	builder.WriteString(fmt.Sprintf("%v", m.Ctype))
-	builder.WriteString(", ")
 	builder.WriteString("cc=")
 	builder.WriteString(m.Cc)
 	builder.WriteString(", ")

+ 0 - 10
ent/msg/msg.go

@@ -32,8 +32,6 @@ const (
 	FieldMsg = "msg"
 	// FieldBatchNo holds the string denoting the batch_no field in the database.
 	FieldBatchNo = "batch_no"
-	// FieldCtype holds the string denoting the ctype field in the database.
-	FieldCtype = "ctype"
 	// FieldCc holds the string denoting the cc field in the database.
 	FieldCc = "cc"
 	// FieldPhone holds the string denoting the phone field in the database.
@@ -54,7 +52,6 @@ var Columns = []string{
 	FieldMsgtype,
 	FieldMsg,
 	FieldBatchNo,
-	FieldCtype,
 	FieldCc,
 	FieldPhone,
 }
@@ -83,8 +80,6 @@ var (
 	DefaultUpdatedAt func() time.Time
 	// UpdateDefaultUpdatedAt holds the default value on update for the "updated_at" field.
 	UpdateDefaultUpdatedAt func() time.Time
-	// DefaultCtype holds the default value on creation for the "ctype" field.
-	DefaultCtype uint64
 	// DefaultCc holds the default value on creation for the "cc" field.
 	DefaultCc string
 	// DefaultPhone holds the default value on creation for the "phone" field.
@@ -144,11 +139,6 @@ func ByBatchNo(opts ...sql.OrderTermOption) OrderOption {
 	return sql.OrderByField(FieldBatchNo, opts...).ToFunc()
 }
 
-// ByCtype orders the results by the ctype field.
-func ByCtype(opts ...sql.OrderTermOption) OrderOption {
-	return sql.OrderByField(FieldCtype, opts...).ToFunc()
-}
-
 // ByCc orders the results by the cc field.
 func ByCc(opts ...sql.OrderTermOption) OrderOption {
 	return sql.OrderByField(FieldCc, opts...).ToFunc()

+ 0 - 45
ent/msg/where.go

@@ -99,11 +99,6 @@ func BatchNo(v string) predicate.Msg {
 	return predicate.Msg(sql.FieldEQ(FieldBatchNo, v))
 }
 
-// Ctype applies equality check predicate on the "ctype" field. It's identical to CtypeEQ.
-func Ctype(v uint64) predicate.Msg {
-	return predicate.Msg(sql.FieldEQ(FieldCtype, v))
-}
-
 // Cc applies equality check predicate on the "cc" field. It's identical to CcEQ.
 func Cc(v string) predicate.Msg {
 	return predicate.Msg(sql.FieldEQ(FieldCc, v))
@@ -644,46 +639,6 @@ func BatchNoContainsFold(v string) predicate.Msg {
 	return predicate.Msg(sql.FieldContainsFold(FieldBatchNo, v))
 }
 
-// CtypeEQ applies the EQ predicate on the "ctype" field.
-func CtypeEQ(v uint64) predicate.Msg {
-	return predicate.Msg(sql.FieldEQ(FieldCtype, v))
-}
-
-// CtypeNEQ applies the NEQ predicate on the "ctype" field.
-func CtypeNEQ(v uint64) predicate.Msg {
-	return predicate.Msg(sql.FieldNEQ(FieldCtype, v))
-}
-
-// CtypeIn applies the In predicate on the "ctype" field.
-func CtypeIn(vs ...uint64) predicate.Msg {
-	return predicate.Msg(sql.FieldIn(FieldCtype, vs...))
-}
-
-// CtypeNotIn applies the NotIn predicate on the "ctype" field.
-func CtypeNotIn(vs ...uint64) predicate.Msg {
-	return predicate.Msg(sql.FieldNotIn(FieldCtype, vs...))
-}
-
-// CtypeGT applies the GT predicate on the "ctype" field.
-func CtypeGT(v uint64) predicate.Msg {
-	return predicate.Msg(sql.FieldGT(FieldCtype, v))
-}
-
-// CtypeGTE applies the GTE predicate on the "ctype" field.
-func CtypeGTE(v uint64) predicate.Msg {
-	return predicate.Msg(sql.FieldGTE(FieldCtype, v))
-}
-
-// CtypeLT applies the LT predicate on the "ctype" field.
-func CtypeLT(v uint64) predicate.Msg {
-	return predicate.Msg(sql.FieldLT(FieldCtype, v))
-}
-
-// CtypeLTE applies the LTE predicate on the "ctype" field.
-func CtypeLTE(v uint64) predicate.Msg {
-	return predicate.Msg(sql.FieldLTE(FieldCtype, v))
-}
-
 // CcEQ applies the EQ predicate on the "cc" field.
 func CcEQ(v string) predicate.Msg {
 	return predicate.Msg(sql.FieldEQ(FieldCc, v))

+ 0 - 85
ent/msg_create.go

@@ -148,20 +148,6 @@ func (mc *MsgCreate) SetNillableBatchNo(s *string) *MsgCreate {
 	return mc
 }
 
-// SetCtype sets the "ctype" field.
-func (mc *MsgCreate) SetCtype(u uint64) *MsgCreate {
-	mc.mutation.SetCtype(u)
-	return mc
-}
-
-// SetNillableCtype sets the "ctype" field if the given value is not nil.
-func (mc *MsgCreate) SetNillableCtype(u *uint64) *MsgCreate {
-	if u != nil {
-		mc.SetCtype(*u)
-	}
-	return mc
-}
-
 // SetCc sets the "cc" field.
 func (mc *MsgCreate) SetCc(s string) *MsgCreate {
 	mc.mutation.SetCc(s)
@@ -247,10 +233,6 @@ func (mc *MsgCreate) defaults() error {
 		v := msg.DefaultUpdatedAt()
 		mc.mutation.SetUpdatedAt(v)
 	}
-	if _, ok := mc.mutation.Ctype(); !ok {
-		v := msg.DefaultCtype
-		mc.mutation.SetCtype(v)
-	}
 	if _, ok := mc.mutation.Cc(); !ok {
 		v := msg.DefaultCc
 		mc.mutation.SetCc(v)
@@ -270,9 +252,6 @@ func (mc *MsgCreate) check() error {
 	if _, ok := mc.mutation.UpdatedAt(); !ok {
 		return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "Msg.updated_at"`)}
 	}
-	if _, ok := mc.mutation.Ctype(); !ok {
-		return &ValidationError{Name: "ctype", err: errors.New(`ent: missing required field "Msg.ctype"`)}
-	}
 	if _, ok := mc.mutation.Cc(); !ok {
 		return &ValidationError{Name: "cc", err: errors.New(`ent: missing required field "Msg.cc"`)}
 	}
@@ -348,10 +327,6 @@ func (mc *MsgCreate) createSpec() (*Msg, *sqlgraph.CreateSpec) {
 		_spec.SetField(msg.FieldBatchNo, field.TypeString, value)
 		_node.BatchNo = value
 	}
-	if value, ok := mc.mutation.Ctype(); ok {
-		_spec.SetField(msg.FieldCtype, field.TypeUint64, value)
-		_node.Ctype = value
-	}
 	if value, ok := mc.mutation.Cc(); ok {
 		_spec.SetField(msg.FieldCc, field.TypeString, value)
 		_node.Cc = value
@@ -562,24 +537,6 @@ func (u *MsgUpsert) ClearBatchNo() *MsgUpsert {
 	return u
 }
 
-// SetCtype sets the "ctype" field.
-func (u *MsgUpsert) SetCtype(v uint64) *MsgUpsert {
-	u.Set(msg.FieldCtype, v)
-	return u
-}
-
-// UpdateCtype sets the "ctype" field to the value that was provided on create.
-func (u *MsgUpsert) UpdateCtype() *MsgUpsert {
-	u.SetExcluded(msg.FieldCtype)
-	return u
-}
-
-// AddCtype adds v to the "ctype" field.
-func (u *MsgUpsert) AddCtype(v uint64) *MsgUpsert {
-	u.Add(msg.FieldCtype, v)
-	return u
-}
-
 // SetCc sets the "cc" field.
 func (u *MsgUpsert) SetCc(v string) *MsgUpsert {
 	u.Set(msg.FieldCc, v)
@@ -830,27 +787,6 @@ func (u *MsgUpsertOne) ClearBatchNo() *MsgUpsertOne {
 	})
 }
 
-// SetCtype sets the "ctype" field.
-func (u *MsgUpsertOne) SetCtype(v uint64) *MsgUpsertOne {
-	return u.Update(func(s *MsgUpsert) {
-		s.SetCtype(v)
-	})
-}
-
-// AddCtype adds v to the "ctype" field.
-func (u *MsgUpsertOne) AddCtype(v uint64) *MsgUpsertOne {
-	return u.Update(func(s *MsgUpsert) {
-		s.AddCtype(v)
-	})
-}
-
-// UpdateCtype sets the "ctype" field to the value that was provided on create.
-func (u *MsgUpsertOne) UpdateCtype() *MsgUpsertOne {
-	return u.Update(func(s *MsgUpsert) {
-		s.UpdateCtype()
-	})
-}
-
 // SetCc sets the "cc" field.
 func (u *MsgUpsertOne) SetCc(v string) *MsgUpsertOne {
 	return u.Update(func(s *MsgUpsert) {
@@ -1271,27 +1207,6 @@ func (u *MsgUpsertBulk) ClearBatchNo() *MsgUpsertBulk {
 	})
 }
 
-// SetCtype sets the "ctype" field.
-func (u *MsgUpsertBulk) SetCtype(v uint64) *MsgUpsertBulk {
-	return u.Update(func(s *MsgUpsert) {
-		s.SetCtype(v)
-	})
-}
-
-// AddCtype adds v to the "ctype" field.
-func (u *MsgUpsertBulk) AddCtype(v uint64) *MsgUpsertBulk {
-	return u.Update(func(s *MsgUpsert) {
-		s.AddCtype(v)
-	})
-}
-
-// UpdateCtype sets the "ctype" field to the value that was provided on create.
-func (u *MsgUpsertBulk) UpdateCtype() *MsgUpsertBulk {
-	return u.Update(func(s *MsgUpsert) {
-		s.UpdateCtype()
-	})
-}
-
 // SetCc sets the "cc" field.
 func (u *MsgUpsertBulk) SetCc(v string) *MsgUpsertBulk {
 	return u.Update(func(s *MsgUpsert) {

+ 0 - 54
ent/msg_update.go

@@ -188,27 +188,6 @@ func (mu *MsgUpdate) ClearBatchNo() *MsgUpdate {
 	return mu
 }
 
-// SetCtype sets the "ctype" field.
-func (mu *MsgUpdate) SetCtype(u uint64) *MsgUpdate {
-	mu.mutation.ResetCtype()
-	mu.mutation.SetCtype(u)
-	return mu
-}
-
-// SetNillableCtype sets the "ctype" field if the given value is not nil.
-func (mu *MsgUpdate) SetNillableCtype(u *uint64) *MsgUpdate {
-	if u != nil {
-		mu.SetCtype(*u)
-	}
-	return mu
-}
-
-// AddCtype adds u to the "ctype" field.
-func (mu *MsgUpdate) AddCtype(u int64) *MsgUpdate {
-	mu.mutation.AddCtype(u)
-	return mu
-}
-
 // SetCc sets the "cc" field.
 func (mu *MsgUpdate) SetCc(s string) *MsgUpdate {
 	mu.mutation.SetCc(s)
@@ -344,12 +323,6 @@ func (mu *MsgUpdate) sqlSave(ctx context.Context) (n int, err error) {
 	if mu.mutation.BatchNoCleared() {
 		_spec.ClearField(msg.FieldBatchNo, field.TypeString)
 	}
-	if value, ok := mu.mutation.Ctype(); ok {
-		_spec.SetField(msg.FieldCtype, field.TypeUint64, value)
-	}
-	if value, ok := mu.mutation.AddedCtype(); ok {
-		_spec.AddField(msg.FieldCtype, field.TypeUint64, value)
-	}
 	if value, ok := mu.mutation.Cc(); ok {
 		_spec.SetField(msg.FieldCc, field.TypeString, value)
 	}
@@ -536,27 +509,6 @@ func (muo *MsgUpdateOne) ClearBatchNo() *MsgUpdateOne {
 	return muo
 }
 
-// SetCtype sets the "ctype" field.
-func (muo *MsgUpdateOne) SetCtype(u uint64) *MsgUpdateOne {
-	muo.mutation.ResetCtype()
-	muo.mutation.SetCtype(u)
-	return muo
-}
-
-// SetNillableCtype sets the "ctype" field if the given value is not nil.
-func (muo *MsgUpdateOne) SetNillableCtype(u *uint64) *MsgUpdateOne {
-	if u != nil {
-		muo.SetCtype(*u)
-	}
-	return muo
-}
-
-// AddCtype adds u to the "ctype" field.
-func (muo *MsgUpdateOne) AddCtype(u int64) *MsgUpdateOne {
-	muo.mutation.AddCtype(u)
-	return muo
-}
-
 // SetCc sets the "cc" field.
 func (muo *MsgUpdateOne) SetCc(s string) *MsgUpdateOne {
 	muo.mutation.SetCc(s)
@@ -722,12 +674,6 @@ func (muo *MsgUpdateOne) sqlSave(ctx context.Context) (_node *Msg, err error) {
 	if muo.mutation.BatchNoCleared() {
 		_spec.ClearField(msg.FieldBatchNo, field.TypeString)
 	}
-	if value, ok := muo.mutation.Ctype(); ok {
-		_spec.SetField(msg.FieldCtype, field.TypeUint64, value)
-	}
-	if value, ok := muo.mutation.AddedCtype(); ok {
-		_spec.AddField(msg.FieldCtype, field.TypeUint64, value)
-	}
 	if value, ok := muo.mutation.Cc(); ok {
 		_spec.SetField(msg.FieldCc, field.TypeString, value)
 	}

+ 1 - 88
ent/mutation.go

@@ -20782,8 +20782,6 @@ type MsgMutation struct {
 	addmsgtype    *int32
 	msg           *string
 	batch_no      *string
-	ctype         *uint64
-	addctype      *int64
 	cc            *string
 	phone         *string
 	clearedFields map[string]struct{}
@@ -21353,62 +21351,6 @@ func (m *MsgMutation) ResetBatchNo() {
 	delete(m.clearedFields, msg.FieldBatchNo)
 }
 
-// SetCtype sets the "ctype" field.
-func (m *MsgMutation) SetCtype(u uint64) {
-	m.ctype = &u
-	m.addctype = nil
-}
-
-// Ctype returns the value of the "ctype" field in the mutation.
-func (m *MsgMutation) Ctype() (r uint64, exists bool) {
-	v := m.ctype
-	if v == nil {
-		return
-	}
-	return *v, true
-}
-
-// OldCtype returns the old "ctype" field's value of the Msg entity.
-// If the Msg 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 *MsgMutation) OldCtype(ctx context.Context) (v uint64, err error) {
-	if !m.op.Is(OpUpdateOne) {
-		return v, errors.New("OldCtype is only allowed on UpdateOne operations")
-	}
-	if m.id == nil || m.oldValue == nil {
-		return v, errors.New("OldCtype requires an ID field in the mutation")
-	}
-	oldValue, err := m.oldValue(ctx)
-	if err != nil {
-		return v, fmt.Errorf("querying old value for OldCtype: %w", err)
-	}
-	return oldValue.Ctype, nil
-}
-
-// AddCtype adds u to the "ctype" field.
-func (m *MsgMutation) AddCtype(u int64) {
-	if m.addctype != nil {
-		*m.addctype += u
-	} else {
-		m.addctype = &u
-	}
-}
-
-// AddedCtype returns the value that was added to the "ctype" field in this mutation.
-func (m *MsgMutation) AddedCtype() (r int64, exists bool) {
-	v := m.addctype
-	if v == nil {
-		return
-	}
-	return *v, true
-}
-
-// ResetCtype resets all changes to the "ctype" field.
-func (m *MsgMutation) ResetCtype() {
-	m.ctype = nil
-	m.addctype = nil
-}
-
 // SetCc sets the "cc" field.
 func (m *MsgMutation) SetCc(s string) {
 	m.cc = &s
@@ -21515,7 +21457,7 @@ func (m *MsgMutation) Type() string {
 // order to get all numeric fields that were incremented/decremented, call
 // AddedFields().
 func (m *MsgMutation) Fields() []string {
-	fields := make([]string, 0, 12)
+	fields := make([]string, 0, 11)
 	if m.created_at != nil {
 		fields = append(fields, msg.FieldCreatedAt)
 	}
@@ -21543,9 +21485,6 @@ func (m *MsgMutation) Fields() []string {
 	if m.batch_no != nil {
 		fields = append(fields, msg.FieldBatchNo)
 	}
-	if m.ctype != nil {
-		fields = append(fields, msg.FieldCtype)
-	}
 	if m.cc != nil {
 		fields = append(fields, msg.FieldCc)
 	}
@@ -21578,8 +21517,6 @@ func (m *MsgMutation) Field(name string) (ent.Value, bool) {
 		return m.Msg()
 	case msg.FieldBatchNo:
 		return m.BatchNo()
-	case msg.FieldCtype:
-		return m.Ctype()
 	case msg.FieldCc:
 		return m.Cc()
 	case msg.FieldPhone:
@@ -21611,8 +21548,6 @@ func (m *MsgMutation) OldField(ctx context.Context, name string) (ent.Value, err
 		return m.OldMsg(ctx)
 	case msg.FieldBatchNo:
 		return m.OldBatchNo(ctx)
-	case msg.FieldCtype:
-		return m.OldCtype(ctx)
 	case msg.FieldCc:
 		return m.OldCc(ctx)
 	case msg.FieldPhone:
@@ -21689,13 +21624,6 @@ func (m *MsgMutation) SetField(name string, value ent.Value) error {
 		}
 		m.SetBatchNo(v)
 		return nil
-	case msg.FieldCtype:
-		v, ok := value.(uint64)
-		if !ok {
-			return fmt.Errorf("unexpected type %T for field %s", value, name)
-		}
-		m.SetCtype(v)
-		return nil
 	case msg.FieldCc:
 		v, ok := value.(string)
 		if !ok {
@@ -21724,9 +21652,6 @@ func (m *MsgMutation) AddedFields() []string {
 	if m.addmsgtype != nil {
 		fields = append(fields, msg.FieldMsgtype)
 	}
-	if m.addctype != nil {
-		fields = append(fields, msg.FieldCtype)
-	}
 	return fields
 }
 
@@ -21739,8 +21664,6 @@ func (m *MsgMutation) AddedField(name string) (ent.Value, bool) {
 		return m.AddedStatus()
 	case msg.FieldMsgtype:
 		return m.AddedMsgtype()
-	case msg.FieldCtype:
-		return m.AddedCtype()
 	}
 	return nil, false
 }
@@ -21764,13 +21687,6 @@ func (m *MsgMutation) AddField(name string, value ent.Value) error {
 		}
 		m.AddMsgtype(v)
 		return nil
-	case msg.FieldCtype:
-		v, ok := value.(int64)
-		if !ok {
-			return fmt.Errorf("unexpected type %T for field %s", value, name)
-		}
-		m.AddCtype(v)
-		return nil
 	}
 	return fmt.Errorf("unknown Msg numeric field %s", name)
 }
@@ -21870,9 +21786,6 @@ func (m *MsgMutation) ResetField(name string) error {
 	case msg.FieldBatchNo:
 		m.ResetBatchNo()
 		return nil
-	case msg.FieldCtype:
-		m.ResetCtype()
-		return nil
 	case msg.FieldCc:
 		m.ResetCc()
 		return nil

+ 2 - 6
ent/runtime/runtime.go

@@ -862,16 +862,12 @@ func init() {
 	msg.DefaultUpdatedAt = msgDescUpdatedAt.Default.(func() time.Time)
 	// msg.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field.
 	msg.UpdateDefaultUpdatedAt = msgDescUpdatedAt.UpdateDefault.(func() time.Time)
-	// msgDescCtype is the schema descriptor for ctype field.
-	msgDescCtype := msgFields[6].Descriptor()
-	// msg.DefaultCtype holds the default value on creation for the ctype field.
-	msg.DefaultCtype = msgDescCtype.Default.(uint64)
 	// msgDescCc is the schema descriptor for cc field.
-	msgDescCc := msgFields[7].Descriptor()
+	msgDescCc := msgFields[6].Descriptor()
 	// msg.DefaultCc holds the default value on creation for the cc field.
 	msg.DefaultCc = msgDescCc.Default.(string)
 	// msgDescPhone is the schema descriptor for phone field.
-	msgDescPhone := msgFields[8].Descriptor()
+	msgDescPhone := msgFields[7].Descriptor()
 	// msg.DefaultPhone holds the default value on creation for the phone field.
 	msg.DefaultPhone = msgDescPhone.Default.(string)
 	payrechargeMixin := schema.PayRecharge{}.Mixin()

+ 0 - 1
ent/schema/msg.go

@@ -23,7 +23,6 @@ func (Msg) Fields() []ent.Field {
 		field.Int32("msgtype").Optional().Comment("消息类型"),
 		field.String("msg").Optional().Comment("消息"),
 		field.String("batch_no").Optional().Comment("批次号"),
-		field.Uint64("ctype").Default(1).Comment("内容类型:1-微信 2-whatsapp"),
 		field.String("cc").Default("").Comment("国家区号"),
 		field.String("phone").Default("").Comment("手机号"),
 	}

+ 0 - 24
ent/set_not_nil.go

@@ -4688,30 +4688,6 @@ func (m *MsgCreate) SetNotNilBatchNo(value *string) *MsgCreate {
 }
 
 // set field if value's pointer is not nil.
-func (m *MsgUpdate) SetNotNilCtype(value *uint64) *MsgUpdate {
-	if value != nil {
-		return m.SetCtype(*value)
-	}
-	return m
-}
-
-// set field if value's pointer is not nil.
-func (m *MsgUpdateOne) SetNotNilCtype(value *uint64) *MsgUpdateOne {
-	if value != nil {
-		return m.SetCtype(*value)
-	}
-	return m
-}
-
-// set field if value's pointer is not nil.
-func (m *MsgCreate) SetNotNilCtype(value *uint64) *MsgCreate {
-	if value != nil {
-		return m.SetCtype(*value)
-	}
-	return m
-}
-
-// set field if value's pointer is not nil.
 func (m *MsgUpdate) SetNotNilCc(value *string) *MsgUpdate {
 	if value != nil {
 		return m.SetCc(*value)

+ 6 - 5
internal/logic/batch_msg/create_whatcapp_batch_msg_logic.go

@@ -6,7 +6,6 @@ import (
 	"errors"
 	"github.com/suyuan32/simple-admin-common/msg/errormsg"
 	"github.com/suyuan32/simple-admin-common/utils/uuidx"
-	"github.com/zeromicro/go-zero/core/errorx"
 	"strings"
 	"time"
 	"wechat-api/ent"
@@ -261,10 +260,12 @@ func (l *CreateWhatcappBatchMsgLogic) addBatchMsg(userList []*ent.Contact, tx *e
 	}
 	fromPhone := *req.Cc + *req.Phone
 	result, err := aliyun.SendBatchChatappMessage(*req.TemplateCode, *req.Lang, fromPhone, sto)
+	l.Logger.Infof("send_batch_chatapp_message result=%v\n", result)
+
+	var status uint8 = 1
 	if err != nil {
-		return errorx.NewInvalidArgumentError(err.Error())
+		status = 2
 	}
-	l.Logger.Infof("send_batch_chatapp_message result=%v\n", result)
 
 	msgs := make([]*ent.MsgCreate, 0, l.MaxNumber)
 	for _, user := range userList {
@@ -274,8 +275,8 @@ func (l *CreateWhatcappBatchMsgLogic) addBatchMsg(userList []*ent.Contact, tx *e
 			SetNotNilPhone(req.Phone).
 			SetNotNilToid(&phone).
 			SetMsgtype(int32(1)).
-			SetNotNilMsg(req.Msg).
-			SetStatus(1).
+			//SetNotNilMsg(req.Msg).
+			SetStatus(status).
 			SetNotNilBatchNo(&batchNo)
 
 		msgs = append(msgs, msgRow)

+ 13 - 1
internal/logic/batch_msg/get_whatcapp_batch_msg_history_logic.go

@@ -5,6 +5,7 @@ import (
 	"github.com/suyuan32/simple-admin-common/utils/pointy"
 	"wechat-api/ent/batchmsg"
 	"wechat-api/ent/msg"
+	"wechat-api/ent/predicate"
 	"wechat-api/internal/utils/dberrorhandler"
 
 	"wechat-api/internal/svc"
@@ -33,7 +34,18 @@ func (l *GetWhatcappBatchMsgHistoryLogic) GetWhatcappBatchMsgHistory(req *types.
 	if err != nil {
 		return nil, dberrorhandler.DefaultEntError(l.Logger, err, req)
 	}
-	data, err := l.svcCtx.DB.Msg.Query().Where(msg.BatchNo(batch_msg.BatchNo)).Page(l.ctx, req.Page, req.PageSize)
+
+	var predicates []predicate.Msg
+	predicates = append(predicates, msg.BatchNo(batch_msg.BatchNo))
+
+	if req.Status != nil {
+		predicates = append(predicates, msg.StatusEQ(*req.Status))
+	}
+	if req.Phone != nil {
+		predicates = append(predicates, msg.PhoneContains(*req.Phone))
+	}
+
+	data, err := l.svcCtx.DB.Msg.Query().Where(predicates...).Page(l.ctx, req.Page, req.PageSize)
 	if err != nil {
 		return nil, dberrorhandler.DefaultEntError(l.Logger, err, req)
 	}

+ 2 - 0
internal/types/types.go

@@ -1982,6 +1982,8 @@ type WhatsappBatchMsgListReq struct {
 type WhatsappBatchMsgHistoryReq struct {
 	PageInfo
 	IDReq
+	Status *uint8  `json:"status,optional"`
+	Phone  *string `json:"phone,optional"`
 }
 
 // swagger:model WhatsappBatchMsgHistoryResp