Jelajahi Sumber

SProjectBillList

Xingyu Xian 2 bulan lalu
induk
melakukan
89f19eb77e
2 mengubah file dengan 72 tambahan dan 8 penghapusan
  1. 22 4
      model/http_model/full_s_project_bill_list.go
  2. 50 4
      service/s_project.go

+ 22 - 4
model/http_model/full_s_project_bill_list.go

@@ -1,7 +1,5 @@
 package http_model
 
-import "youngee_b_api/model/gorm_model"
-
 type FullSProjectBillListRequest struct {
 	ProjectPlatform int    `json:"project_platform"` // 种草任务平台,1-7分别代表小红书、抖音、微博、快手、b站、大众点评、知乎
 	SupplierId      int    `json:"supplier_id"`      // 服务商ID
@@ -13,8 +11,28 @@ type FullSProjectBillListRequest struct {
 }
 
 type FullSProjectBillData struct {
-	SProjectList []*gorm_model.SProjectInfo `json:"s_project_info"` // 服务商加入商单的种草任务信息
-	Total        int64                      `json:"total"`          // 数量
+	SProjectList []*FullSProjectBillListData `json:"s_project_info"` // 服务商加入商单的种草任务信息
+	Total        int64                       `json:"total"`          // 数量
+}
+
+type FullSProjectBillListData struct {
+	SProjectId          int     `json:"s_project_id"`          // 服务商加入商单后的种草任务ID
+	ProjectId           string  `json:"project_id"`            // 被服务商加入商单的原种草任务ID
+	ProjectPlatform     int64   `json:"project_platform"`      // 种草任务平台,1-7分别代表小红书、抖音、微博、快手、b站、大众点评、知乎
+	ProjectForm         int64   `json:"project_form"`          // 任务形式,1-3分别代表商品寄拍、素材分发、虚拟产品测评
+	ContentType         int64   `json:"content_type"`          // 内容形式,1代表图文,2代表视频
+	ProjectStatus       int64   `json:"project_status"`        // 种草任务状态
+	EnterpriseId        string  `json:"enterprise_id"`         // 所属企业ID
+	SupplierId          int     `json:"supplier_id"`           // 所属服务商ID
+	SubAccountId        int     `json:"sub_account_id"`        // 所属子账号ID
+	ServiceChargeActual float64 `json:"service_charge_actual"` // 服务商实际可赚服务费
+	ServiceChargeSettle float64 `json:"service_charge_settle"` // 已结算服务费
+	ProductPhotoUrl     string  `json:"product_photo_url"`     // 商品主图URL
+	ProductPhotoSymbol  int64   `json:"product_photo_symbol"`  // 标志位
+	ProductPhotoUid     string  `json:"product_photo_uid"`     // uid
+	ProductName         string  `json:"product_name"`          // 商品名称
+	ProductId           int64   `json:"product_id"`            // 商品ID
+	ProductPrice        float64 `json:"product_price"`         // 商品售价
 }
 
 func NewFullSProjectBillRequest() *FullSProjectBillListRequest {

+ 50 - 4
service/s_project.go

@@ -491,14 +491,60 @@ func (*sProject) CreateSpecialStrategy(ctx context.Context, request *http_model.
 
 // FullSProjectBillList 种草任务账单列表
 func (*sProject) FullSProjectBillList(ctx context.Context, request *http_model.FullSProjectBillListRequest) (*http_model.FullSProjectBillData, error) {
+	var currSProjectBillData *http_model.FullSProjectBillData
+	currSProjectBillData = &http_model.FullSProjectBillData{}
+
 	// 1. 根据SupplierId和账单状态查询数据
 	fullSProjectBillData, total, err := db.GetFullSProjectBillList(ctx, request.SupplierId, request.ProjectPlatform, request.ProjectStatus, request.PageSize, request.PageNum)
 	if err != nil {
 		return nil, err
 	}
-	var currSProjectBillData *http_model.FullSProjectBillData
-	currSProjectBillData = &http_model.FullSProjectBillData{}
-	currSProjectBillData.SProjectList = fullSProjectBillData
-	currSProjectBillData.Total = total
+	if fullSProjectBillData != nil {
+		currSProjectBillData.Total = total
+		for _, b := range fullSProjectBillData {
+			var billData *http_model.FullSProjectBillListData
+			billData = &http_model.FullSProjectBillListData{}
+			billData.SProjectId = b.SProjectId
+			billData.ProjectId = b.ProjectId
+			billData.ProjectPlatform = b.ProjectPlatform
+			billData.ProjectForm = b.ProjectForm
+			billData.ContentType = b.ContentType
+			billData.ProjectStatus = b.ProjectStatus
+			billData.EnterpriseId = b.EnterpriseId
+			billData.SupplierId = b.SupplierId
+			billData.SubAccountId = b.SubAccountId
+			billData.ServiceChargeActual = b.ServiceChargeActual
+			billData.ServiceChargeSettle = b.ServiceChargeSettle
+
+			// 1.2. 补充商品信息
+			productInfo, productErr := db.GetProductByID(ctx, b.ProductId)
+			if productErr != nil {
+				return nil, productErr
+			}
+			if productInfo != nil {
+				billData.ProductId = productInfo.ProductID
+				billData.ProductPrice = productInfo.ProductPrice
+				billData.ProductName = productInfo.ProductName
+			}
+
+			// 1.3. 商品图片信息
+			productPhotoInfo, productPhotoErr := db.GetProductPhotoByProductID(ctx, b.ProductId)
+			if productPhotoErr != nil {
+				return nil, productPhotoErr
+			}
+			if productPhotoInfo != nil {
+				for _, photo := range productPhotoInfo {
+					fmt.Println(photo)
+					if photo.Symbol == 1 {
+						billData.ProductPhotoSymbol = 1
+						billData.ProductPhotoUrl = photo.PhotoUrl
+						billData.ProductPhotoUid = photo.PhotoUid
+					}
+				}
+			}
+			currSProjectBillData.SProjectList = append(currSProjectBillData.SProjectList, billData)
+		}
+	}
+
 	return currSProjectBillData, nil
 }