瀏覽代碼

fix_商品商库

Ethan 3 月之前
父節點
當前提交
7a910afe95
共有 1 個文件被更改,包括 13 次插入6 次删除
  1. 13 6
      app/service/product_service.go

+ 13 - 6
app/service/product_service.go

@@ -40,16 +40,23 @@ func (p ProductService) GetTaskProductsByUserId(param vo.GetAllProductParam) (vo
 		return result, err
 	}
 	var reProducts []vo.ReProductPreview
-	var creatorName string
 	for _, product := range products {
+		var createrName string
 		photoUrl, e := dao.ProductPhotoDAO{}.GetMainPhotoByProductID(product.ProductID)
-		enterprise, err := dao.EnterpriseDao{}.GetEnterprise(product.EnterpriseID)
-		if err == nil && enterprise != nil {
-			creatorName = enterprise.BusinessName
-		}
 		if e != nil {
 			photoUrl = ""
 		}
+		if product.SubAccountID == 0 {
+			enterprise, err := dao.EnterpriseDao{}.GetEnterprise(product.EnterpriseID)
+			if err == nil && enterprise != nil {
+				createrName = enterprise.BusinessName
+			}
+		} else {
+			subAccount, err := dao.SubAccountDao{}.GetSubAccount(product.SubAccountID)
+			if err == nil && subAccount != nil {
+				createrName = subAccount.SubAccountName
+			}
+		}
 		reProduct := vo.ReProductPreview{
 			ProductID:       product.ProductID,
 			ProductName:     product.ProductName,
@@ -59,7 +66,7 @@ func (p ProductService) GetTaskProductsByUserId(param vo.GetAllProductParam) (vo
 			ProductDetail:   product.ProductDetail,
 			CreatedAt:       product.CreatedAt.Format("2006-01-02 15:04:05"),
 			PhotoUrl:        photoUrl,
-			CreateName:      creatorName,
+			CreateName:      createrName,
 		}
 		reProducts = append(reProducts, reProduct)
 	}