animeic 2 лет назад
Родитель
Сommit
012f582f57

+ 11 - 3
3dshow-supplier/api/order.go

@@ -67,7 +67,7 @@ func OrderList(c *gin.Context, apictx *ApiSession) (interface{}, error) {
 // 发货
 type OrderDeliveryReq struct {
 	Id        primitive.ObjectID `json:"id"`
-	ProductId primitive.ObjectID `json:"productId"`
+	UniqueId  primitive.ObjectID `json:"uniqueId"`
 	ExpressNo string             `json:"expressNo"`
 }
 
@@ -98,7 +98,7 @@ func OrderDelivery(c *gin.Context, apictx *ApiSession) (interface{}, error) {
 	result, err := repo.RepoDocArrayOneUpdate(apictx.CreateRepoCtx(), &repo.ArrayOneUpdateOption{
 		CollectName: repo.CollectionOrder,
 		Id:          form.Id.Hex(),
-		Query:       repo.Map{"products.id": form.ProductId},
+		Query:       repo.Map{"products.id": form.UniqueId},
 		Set:         repo.Map{"status": 1, "expressNo": form.ExpressNo},
 	})
 	if err != nil {
@@ -106,10 +106,18 @@ func OrderDelivery(c *gin.Context, apictx *ApiSession) (interface{}, error) {
 	}
 
 	if result.ModifiedCount > 0 {
+
+		// 查询更改后的订单
+		order1 := model.Order{}
+		repo.RepoSeachDoc(apictx.CreateRepoCtx(), &repo.DocSearchOptions{
+			CollectName: repo.CollectionOrder,
+			Query:       repo.Map{"_id": form.Id},
+		}, &order1)
+
 		// 查询其中产品 判断订单状态
 		// 该订单产品有多少种状态 在此时订单只有-1,1两种状态
 		statusMap := make(map[int]struct{})
-		for _, v := range order.Products {
+		for _, v := range order1.Products {
 			statusMap[v.Status] = struct{}{}
 		}
 		status := order.Status

+ 3 - 2
3dshow-supplier/db/model/order.go

@@ -22,8 +22,9 @@ type Order struct {
 }
 
 type OrderProduct struct {
-	Id        primitive.ObjectID `bson:"id,omitempty" json:"id"`             // 对应产品id
-	SupplyId  primitive.ObjectID `bson:"supplyId,omitempty" json:"supplyId"` // 供应链id
+	Id        primitive.ObjectID `bson:"id,omitempty" json:"id"`               // uniqueId
+	ProductId primitive.ObjectID `bson:"productId,omitempty" json:"productId"` // 对应产品id
+	SupplyId  primitive.ObjectID `bson:"supplyId,omitempty" json:"supplyId"`   // 供应链id
 	Name      string             `bson:"name,omitempty" json:"name"`
 	Size      int                `bson:"size,omitempty" json:"size"`           // 下单选定的尺寸
 	Color     string             `bson:"color,omitempty" json:"color"`         // 下单选定的颜色

+ 2 - 1
3dshow-supplier/db/model/product.go

@@ -12,7 +12,8 @@ type Product struct {
 	SupplyId   primitive.ObjectID `bson:"supplyId,omitempty" json:"supplyId"`
 	SenceId    primitive.ObjectID `bson:"senceId,omitempty" json:"senceId"` // 场景id,3d展示
 	Name       string             `bson:"name,omitempty" json:"name"`
-	Type       string             `bson:"type,omitempty" json:"type"` // 类型
+	Link       string             `bson:"link,omitempty" json:"link"`
+	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"` // 封面图