Xingyu Xian 2 일 전
부모
커밋
b81d152637
4개의 변경된 파일30개의 추가작업 그리고 15개의 파일을 삭제
  1. 24 10
      db/s_t_cooperate.go
  2. 1 0
      handler/withdraw_payment_info.go
  3. 1 1
      model/http_model/talent_list.go
  4. 4 4
      service/supplier.go

+ 24 - 10
db/s_t_cooperate.go

@@ -51,28 +51,42 @@ func UpdateSTCooperateInfo(ctx context.Context, supplierId int, platformUserId i
 // GetSTCooperateInfo 查找合作列表
 func GetSTCooperateInfo(ctx context.Context, supplierId int, taskType int, platform int, nickname string, pageSize, pageNum int64) ([]*gorm_model.SupplierTalentCooperate, int64, error) {
 	db := GetReadDB(ctx)
-	whereCondition := gorm_model.SupplierTalentCooperate{
-		SupplierId: supplierId,
-		Platform:   platform,
-		TaskType:   taskType,
-	}
 
-	// 1. 按条件过滤
-	db = db.Debug().Model(gorm_model.SupplierTalentCooperate{}).Where(whereCondition)
+	// 1. 按条件过滤 - 必填条件
+	db = db.Debug().Model(gorm_model.SupplierTalentCooperate{}).
+		Where("supplier_id = ?", supplierId).
+		Where("task_type = ?", taskType)
+
+	// 可选条件
+	if platform != 0 {
+		db = db.Where("platform = ?", platform)
+	}
+	// if nickname != "" {
+	// 	db = db.Where("nickname LIKE ?", "%"+nickname+"%") // 假设是模糊查询
+	// }
 
 	// 2. 返回当前页数据并统计总数
 	var total int64
-	var cooperateInfp []*gorm_model.SupplierTalentCooperate
+	var cooperateInfo []*gorm_model.SupplierTalentCooperate
+
+	// 先统计总数
 	if err := db.Count(&total).Error; err != nil {
 		logrus.WithContext(ctx).Errorf("[GetCooperateInfoByIds] error query mysql total, err:%+v", err)
 		return nil, 0, err
 	}
+
+	// 再查询分页数据
 	limit := pageSize
 	offset := pageSize * pageNum // assert pageNum start with 0
-	err := db.Order("supplier_id desc").Limit(int(limit)).Offset(int(offset)).Find(&cooperateInfp).Error
+	err := db.Order("supplier_id desc").
+		Limit(int(limit)).
+		Offset(int(offset)).
+		Find(&cooperateInfo).Error
+
 	if err != nil {
 		logrus.WithContext(ctx).Errorf("[GetCooperateInfoByIds] error query mysql total, err:%+v", err)
 		return nil, 0, err
 	}
-	return cooperateInfp, total, nil
+
+	return cooperateInfo, total, nil
 }

+ 1 - 0
handler/withdraw_payment_info.go

@@ -41,6 +41,7 @@ func (h *WithdrawPaymentInfoHandler) run() {
 		h.resp.Message = err.Error()
 		return
 	}
+	h.resp.Status = 20000
 	h.resp.Data = amount
 	h.resp.Message = "ok"
 }

+ 1 - 1
model/http_model/talent_list.go

@@ -2,7 +2,7 @@ package http_model
 
 type TalentListRequest struct {
 	PageSize   int64  `json:"page_size"`
-	PageNum    int64  `json:"page_num"`
+	PageNum    int64  `json:"page"`
 	SupplierId int    `json:"supplier_id"` // 服务商ID
 	Platform   int    `json:"platform"`    // 平台,1-7分别代表小红书、抖音、微博、快手、b站、大众点评、知乎
 	Type       int    `json:"type"`        // 达人库达人类型,1种草,2本地

+ 4 - 4
service/supplier.go

@@ -839,7 +839,7 @@ func (*supplier) CreateSupplierWithdraw(ctx context.Context, req *http_model.Cre
 			if supplierPaymentErr != nil {
 				return supplierPaymentErr
 			}
-			if supplierPaymentInfo != nil {
+			if supplierPaymentInfo != nil && supplierPaymentInfo.PaymentInfoID != 0 {
 				for _, withdrawInfo := range req.IncomeIds {
 					var supplierWithdrawInfo *gorm_model.YounggeeSupplierWithdraw
 					supplierWithdrawInfo = &gorm_model.YounggeeSupplierWithdraw{}
@@ -876,7 +876,7 @@ func (*supplier) CreateSupplierWithdraw(ctx context.Context, req *http_model.Cre
 			if supplierPaymentErr != nil {
 				return supplierPaymentErr
 			}
-			if supplierPaymentInfo != nil {
+			if supplierPaymentInfo != nil && supplierPaymentInfo.PaymentInfoID != 0 {
 				for _, withdrawInfo := range req.InvoiceIds {
 					var supplierWithdrawInfo *gorm_model.YounggeeSupplierWithdraw
 					supplierWithdrawInfo = &gorm_model.YounggeeSupplierWithdraw{}
@@ -1266,7 +1266,7 @@ func (*supplier) GetWithdrawPaymentInfo(ctx context.Context, req *http_model.Wit
 		if supplierPaymentErr != nil {
 			return nil, supplierPaymentErr
 		}
-		if supplierPaymentInfo != nil {
+		if supplierPaymentInfo != nil && supplierPaymentInfo.PaymentInfoID != 0 {
 			paymentInfo.Tag = 2
 			paymentInfo.Phone = supplierPaymentInfo.Phone
 			paymentInfo.SupplierType = supplierPaymentInfo.SupplierType
@@ -1291,7 +1291,7 @@ func (*supplier) GetWithdrawPaymentInfo(ctx context.Context, req *http_model.Wit
 		if supplierPaymentErr != nil {
 			return nil, supplierPaymentErr
 		}
-		if supplierPaymentInfo != nil {
+		if supplierPaymentInfo != nil && supplierPaymentInfo.PaymentInfoID != 0 {
 			paymentInfo.Tag = 2
 			paymentInfo.PaymentInfoID = supplierPaymentInfo.PaymentInfoID
 			paymentInfo.SupplierType = supplierPaymentInfo.SupplierType