فهرست منبع

add product assetinfo && product selectTime

animeic 2 سال پیش
والد
کامیت
82abd45362
4فایلهای تغییر یافته به همراه74 افزوده شده و 12 حذف شده
  1. 26 4
      3dshow-customer/api/product.go
  2. 45 0
      3dshow-customer/db/model/asset.go
  3. 2 8
      3dshow-customer/db/model/product.go
  4. 1 0
      3dshow-customer/db/repo/repo.go

+ 26 - 4
3dshow-customer/api/product.go

@@ -6,9 +6,11 @@ import (
 	"3dshow-customer/log"
 	"errors"
 	"fmt"
+	"strings"
 	"time"
 
 	"github.com/gin-gonic/gin"
+	"go.mongodb.org/mongo-driver/bson"
 	"go.mongodb.org/mongo-driver/bson/primitive"
 )
 
@@ -59,6 +61,17 @@ func ProductList(c *gin.Context, apictx *ApiSession) (interface{}, error) {
 		delete(query, "sort")
 	}
 
+	// selectTime
+	selectTime := time.Now().Format("2006-01")
+	if _, ok := query["selectTime"]; ok {
+		timeSlice := strings.Split(query["selectTime"].(string), ".")
+		selectTime = strings.Join(timeSlice, "-")
+		delete(query, "selectTime")
+	}
+	timeStr := fmt.Sprintf("%s%s", selectTime, "-01 00:00:00")
+	formatTime, _ := time.ParseInLocation("2006-01-02 15:04:05", timeStr, time.Local)
+	query["onsaleTime"] = bson.M{"$lte": formatTime}
+
 	// 查询数据
 	if _, ok := query["supplyId"]; !ok {
 		return nil, errors.New("供应链id不能为空")
@@ -118,8 +131,9 @@ func ProductList(c *gin.Context, apictx *ApiSession) (interface{}, error) {
 // 产品信息
 type ProudctDetailRes struct {
 	model.Product
-	IsCollect bool   `json:"isCollect"`
-	CollectId string `json:"collectId"`
+	IsCollect bool                 `json:"isCollect"`
+	CollectId string               `json:"collectId"`
+	Asset     model.Asset360Fake3d `json:"asset"`
 }
 
 func ProductDetail(c *gin.Context, apictx *ApiSession) (interface{}, error) {
@@ -141,6 +155,14 @@ func ProductDetail(c *gin.Context, apictx *ApiSession) (interface{}, error) {
 		log.Info(err)
 		return nil, errors.New("数据未找到")
 	}
+
+	// 素材
+	asset := model.Asset360Fake3d{}
+	repo.RepoSeachDoc(apictx.CreateRepoCtx(), &repo.DocSearchOptions{
+		CollectName: repo.CollectionAssets,
+		Query:       repo.Map{"assetId": product.AssetId},
+	}, &asset)
+
 	// 用户登录状态 是否收藏
 	if apictx.User != nil {
 		_userId := apictx.User.ID
@@ -151,8 +173,8 @@ func ProductDetail(c *gin.Context, apictx *ApiSession) (interface{}, error) {
 			CollectName: repo.CollectionCollect,
 			Query:       repo.Map{"userId": userId, "productId": productId},
 		}, &collect)
-		return ProudctDetailRes{Product: product, IsCollect: found, CollectId: collect.Id.Hex()}, nil
+		return ProudctDetailRes{Product: product, IsCollect: found, CollectId: collect.Id.Hex(), Asset: asset}, nil
 	}
 
-	return product, nil
+	return ProudctDetailRes{Product: product, Asset: asset}, nil
 }

+ 45 - 0
3dshow-customer/db/model/asset.go

@@ -0,0 +1,45 @@
+package model
+
+import (
+	"time"
+
+	"go.mongodb.org/mongo-driver/bson/primitive"
+)
+
+const (
+	GROUPSTATE_UNSET   = "unset"
+	GROUPSTATE_ADDED   = "added"
+	GROUPSTATE_CROPING = "croping"
+	GROUPSTATE_SUCC    = "succ"
+	GROUPSTATE_FAIL    = "fail"
+)
+
+// 一套360度图片
+type Asset360Group struct {
+	Id        string `bson:"id,omitempty" json:"id"`
+	GroupName string `bson:"groupName,omitempty" json:"groupName"` //白色
+	Name      string `bson:"name,omitempty" json:"name"`           //正视
+
+	//36张图片信息
+	ImagesPath  string `bson:"imagesPath,omitempty" json:"imagesPath"`   //https://oss.xxx/id/
+	ImageWidth  int    `bson:"imageWidth,omitempty" json:"imageWidth"`   //1944,
+	ImageHeight int    `bson:"imageHeight,omitempty" json:"imageHeight"` //2592,
+
+	Url string `bson:"url,omitempty" json:"url"` //http://192.168.110.115:8082/scene/Id/index.html?assetPath="https:/xxx/xx"
+
+	//已创建 / 后台处理中 / 后台处理失败 / 处理成功
+	//created/croping/fail/succ
+	State string `bson:"state,omitempty" json:"state"`
+}
+
+type Asset360Fake3d struct {
+	Id       primitive.ObjectID `bson:"_id,omitempty" json:"_id"`
+	SupplyId primitive.ObjectID `bson:"supplyId,omitempty" json:"supplyId"`
+
+	//鞋子型号
+	Name       string    `bson:"name,omitempty" json:"name"`
+	CreateTime time.Time `bson:"createTime,omitempty" json:"createTime"`
+	Thumbnail  string    `bson:"thumbnail,omitempty" json:"thumbnail"`
+
+	Groups []*Asset360Group `bson:"groups,omitempty" json:"groups"`
+}

+ 2 - 8
3dshow-customer/db/model/product.go

@@ -10,13 +10,13 @@ import (
 type Product struct {
 	Id         primitive.ObjectID `bson:"_id,omitempty" json:"_id"`
 	SupplyId   primitive.ObjectID `bson:"supplyId,omitempty" json:"supplyId"`
-	SenceId    primitive.ObjectID `bson:"senceId,omitempty" json:"senceId"` // 场景id,3d展示
+	AssetId    primitive.ObjectID `bson:"assetId,omitempty" json:"assetId"`
 	Name       string             `bson:"name,omitempty" json:"name"`
 	Type       string             `bson:"type,omitempty" json:"type"` // 类型 单鞋:shoes 凉鞋:sandals 靴子:boots
 	Unit       string             `bson:"unit,omitempty" json:"unit"` // 型号
 	Price      float64            `bson:"price,omitempty" json:"price"`
 	Cover      string             `bson:"cover,omitempty" json:"cover"` // 封面图
-	Colors     []*ColorObj        `bson:"colors,omitempty" json:"colors"`
+	Color      []string           `bson:"color,omitempty" json:"color"`
 	Size       []int              `bson:"size,omitempty" json:"size"`                 // 尺寸
 	Thumbnail  []string           `bson:"thumbnail,omitempty" json:"thumbnail"`       // 缩略图集合
 	Status     int                `bson:"status,omitempty" json:"status"`             // -1:下架 1:上架
@@ -24,9 +24,3 @@ type Product struct {
 	CreateTime time.Time          `bson:"createTime,omitempty" json:"createTime"`
 	UpdateTime time.Time          `bson:"updateTime,omitempty" json:"updateTime"`
 }
-
-type ColorObj struct {
-	ColorStr string `bson:"colorStr,omitempty" json:"colorStr"`
-	DevLink  string `bson:"devLink,omitempty" json:"devLink"`
-	ProdLink string `bson:"prodLink,omitempty" json:"prodLink"`
-}

+ 1 - 0
3dshow-customer/db/repo/repo.go

@@ -24,6 +24,7 @@ const (
 	CollectionAddress  = "address"
 	CollectionOrder    = "order"
 	CollectionShopCart = "shopCart"
+	CollectionAssets   = "assets"
 )
 
 type Map map[string]interface{}