From 58d02d0d50d7b6b56e1432f2c6b2b17ac5cd54a0 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Thu, 29 Jun 2023 11:15:42 +0800 Subject: [PATCH 1/7] fix --- .../internal/handler/getpickuplisthandler.go | 78 +++++++++++++++++++ server/inventory/internal/handler/routes.go | 5 ++ .../internal/logic/getpickuplistlogic.go | 34 ++++++++ server/inventory/internal/types/types.go | 15 +++- server_api/basic.api | 4 +- server_api/inventory.api | 15 +++- 6 files changed, 143 insertions(+), 8 deletions(-) create mode 100644 server/inventory/internal/handler/getpickuplisthandler.go create mode 100644 server/inventory/internal/logic/getpickuplistlogic.go diff --git a/server/inventory/internal/handler/getpickuplisthandler.go b/server/inventory/internal/handler/getpickuplisthandler.go new file mode 100644 index 00000000..93caf33a --- /dev/null +++ b/server/inventory/internal/handler/getpickuplisthandler.go @@ -0,0 +1,78 @@ +package handler + +import ( + "errors" + "net/http" + + "github.com/zeromicro/go-zero/core/logx" + "github.com/zeromicro/go-zero/rest/httpx" + + "fusenapi/utils/auth" + "fusenapi/utils/basic" + + "fusenapi/server/inventory/internal/logic" + "fusenapi/server/inventory/internal/svc" + "fusenapi/server/inventory/internal/types" +) + +func GetPickupListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + + var ( + // 定义错误变量 + err error + // 定义用户信息变量 + userinfo *auth.UserInfo + ) + // 解析JWT token,并对空用户进行判断 + claims, err := svcCtx.ParseJwtToken(r) + // 如果解析JWT token出错,则返回未授权的JSON响应并记录错误消息 + if err != nil { + httpx.OkJsonCtx(r.Context(), w, &basic.Response{ + Code: 401, // 返回401状态码,表示未授权 + Message: "unauthorized", // 返回未授权信息 + }) + logx.Info("unauthorized:", err.Error()) // 记录错误日志 + return + } + + if claims != nil { + // 从token中获取对应的用户信息 + userinfo, err = auth.GetUserInfoFormMapClaims(claims) + // 如果获取用户信息出错,则返回未授权的JSON响应并记录错误消息 + if err != nil { + httpx.OkJsonCtx(r.Context(), w, &basic.Response{ + Code: 401, + Message: "unauthorized", + }) + logx.Info("unauthorized:", err.Error()) + return + } + } else { + // 如果claims为nil,则认为用户身份为白板用户 + userinfo = &auth.UserInfo{UserId: 0, GuestId: 0} + } + + var req types.GetPickupListReq + // 如果端点有请求结构体,则使用httpx.Parse方法从HTTP请求体中解析请求数据 + if err := httpx.Parse(r, &req); err != nil { + httpx.OkJsonCtx(r.Context(), w, &basic.Response{ + Code: 510, + Message: "parameter error", + }) + logx.Info(err) + return + } + // 创建一个业务逻辑层实例 + l := logic.NewGetPickupListLogic(r.Context(), svcCtx) + resp := l.GetPickupList(&req, userinfo) + // 如果响应不为nil,则使用httpx.OkJsonCtx方法返回JSON响应; + if resp != nil { + httpx.OkJsonCtx(r.Context(), w, resp) + } else { + err := errors.New("server logic is error, resp must not be nil") + httpx.ErrorCtx(r.Context(), w, err) + logx.Error(err) + } + } +} diff --git a/server/inventory/internal/handler/routes.go b/server/inventory/internal/handler/routes.go index 1eca32bb..ac11f0b2 100644 --- a/server/inventory/internal/handler/routes.go +++ b/server/inventory/internal/handler/routes.go @@ -27,6 +27,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { Path: "/inventory/supplement", Handler: SupplementHandler(serverCtx), }, + { + Method: http.MethodGet, + Path: "/inventory/pick-up-list", + Handler: GetPickupListHandler(serverCtx), + }, }, ) } diff --git a/server/inventory/internal/logic/getpickuplistlogic.go b/server/inventory/internal/logic/getpickuplistlogic.go new file mode 100644 index 00000000..fff544ee --- /dev/null +++ b/server/inventory/internal/logic/getpickuplistlogic.go @@ -0,0 +1,34 @@ +package logic + +import ( + "fusenapi/utils/auth" + "fusenapi/utils/basic" + + "context" + + "fusenapi/server/inventory/internal/svc" + "fusenapi/server/inventory/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type GetPickupListLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewGetPickupListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetPickupListLogic { + return &GetPickupListLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *GetPickupListLogic) GetPickupList(req *types.GetPickupListReq, userinfo *auth.UserInfo) (resp *basic.Response) { + // 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data) + // userinfo 传入值时, 一定不为null + + return resp.SetStatus(basic.CodeOK) +} diff --git a/server/inventory/internal/types/types.go b/server/inventory/internal/types/types.go index fccafa7c..7b9a7b94 100644 --- a/server/inventory/internal/types/types.go +++ b/server/inventory/internal/types/types.go @@ -16,8 +16,8 @@ type TakeForm struct { } type GetCloudListReq struct { - Page int64 `form:"page"` - PageSize int64 `form:"page_size"` + Page int `form:"page"` + PageSize int `form:"page_size"` Size int64 `form:"size"` } @@ -63,6 +63,13 @@ type SupplementRsp struct { Sn string `json:"sn"` } +type GetPickupListReq struct { + Status int64 `form:"status,options=0|1|2|3|4"` + Page int `form:"page"` + PageSize int `form:"page_size"` + Size int `form:"size"` +} + type Request struct { } @@ -81,8 +88,8 @@ type Auth struct { type Pagnation struct { TotalCount int64 `json:"total_count"` TotalPage int64 `json:"total_page"` - CurPage int64 `json:"cur_page"` - PageSize int64 `json:"page_size"` + CurPage int `json:"cur_page"` + PageSize int `json:"page_size"` } // Set 设置Response的Code和Message值 diff --git a/server_api/basic.api b/server_api/basic.api index a827855d..13658fad 100644 --- a/server_api/basic.api +++ b/server_api/basic.api @@ -29,7 +29,7 @@ type Auth { type Pagnation{ TotalCount int64 `json:"total_count"` TotalPage int64 `json:"total_page"` - CurPage int64 `json:"cur_page"` - PageSize int64 `json:"page_size"` + CurPage int `json:"cur_page"` + PageSize int `json:"page_size"` } diff --git a/server_api/inventory.api b/server_api/inventory.api index eca56923..efd43195 100644 --- a/server_api/inventory.api +++ b/server_api/inventory.api @@ -18,6 +18,9 @@ service inventory { //云仓补货 @handler SupplementHandler post /inventory/supplement(SupplementReq) returns (response); + //提货列表 + @handler GetPickupListHandler + get /inventory/pick-up-list(GetPickupListReq) returns (response); } //提取云仓货物 @@ -31,8 +34,8 @@ type TakeForm { } //获取云仓库存列表 type GetCloudListReq { - Page int64 `form:"page"` - PageSize int64 `form:"page_size"` + Page int `form:"page"` + PageSize int `form:"page_size"` Size int64 `form:"size"` } type GetCloudListRsp { @@ -73,4 +76,12 @@ type SupplementReq { } type SupplementRsp { Sn string `json:"sn"` +} + +//提货列表 +type GetPickupListReq { + Status int64 `form:"status,options=0|1|2|3|4"` + Page int `form:"page"` + PageSize int `form:"page_size"` + Size int `form:"size"` } \ No newline at end of file From 02c41a506942704c683cc2f7edecab99ccc2f9e1 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Thu, 29 Jun 2023 11:38:38 +0800 Subject: [PATCH 2/7] fix --- .../inventory/internal/logic/getcloudlistlogic.go | 10 +++++----- server/inventory/internal/types/types.go | 12 ++++++------ server_api/basic.api | 13 ++++++------- server_api/inventory.api | 2 +- 4 files changed, 18 insertions(+), 19 deletions(-) diff --git a/server/inventory/internal/logic/getcloudlistlogic.go b/server/inventory/internal/logic/getcloudlistlogic.go index 81e58acc..82c06abf 100644 --- a/server/inventory/internal/logic/getcloudlistlogic.go +++ b/server/inventory/internal/logic/getcloudlistlogic.go @@ -256,11 +256,11 @@ func (l *GetCloudListLogic) GetCloudList(req *types.GetCloudListReq, userinfo *a TransitBoxes: transitBoxes, MinTakeNum: 3, ListData: listDataRsp, - Pagnation: types.Pagnation{ - TotalCount: total, - TotalPage: int64(math.Ceil(float64(total) / float64(req.PageSize))), - CurPage: req.Page, - PageSize: req.PageSize, + Meta: types.Meta{ + TotalCount: total, + PageCount: int64(math.Ceil(float64(total) / float64(req.PageSize))), + CurrentPage: req.Page, + PerPage: req.PageSize, }, }) } diff --git a/server/inventory/internal/types/types.go b/server/inventory/internal/types/types.go index 7b9a7b94..40d7272c 100644 --- a/server/inventory/internal/types/types.go +++ b/server/inventory/internal/types/types.go @@ -26,7 +26,7 @@ type GetCloudListRsp struct { TransitBoxes int64 `json:"transit_boxes"` MinTakeNum int64 `json:"minTakeNum"` ListData []ListDataItem `json:"listData"` - Pagnation Pagnation `json:"pagnation"` + Meta Meta `json:"_meta"` } type ListDataItem struct { @@ -85,11 +85,11 @@ type Auth struct { RefreshAfter int64 `json:"refreshAfter"` } -type Pagnation struct { - TotalCount int64 `json:"total_count"` - TotalPage int64 `json:"total_page"` - CurPage int `json:"cur_page"` - PageSize int `json:"page_size"` +type Meta struct { + TotalCount int64 `json:"totalCount"` + PageCount int64 `json:"pageCount"` + CurrentPage int `json:"currentPage"` + PerPage int `json:"perPage"` } // Set 设置Response的Code和Message值 diff --git a/server_api/basic.api b/server_api/basic.api index 13658fad..e05b76d5 100644 --- a/server_api/basic.api +++ b/server_api/basic.api @@ -26,10 +26,9 @@ type Auth { } // 统一分页 -type Pagnation{ - TotalCount int64 `json:"total_count"` - TotalPage int64 `json:"total_page"` - CurPage int `json:"cur_page"` - PageSize int `json:"page_size"` -} - +type Meta struct { + TotalCount int64 `json:"totalCount"` + PageCount int64 `json:"pageCount"` + CurrentPage int `json:"currentPage"` + PerPage int `json:"perPage"` +} \ No newline at end of file diff --git a/server_api/inventory.api b/server_api/inventory.api index efd43195..803b1041 100644 --- a/server_api/inventory.api +++ b/server_api/inventory.api @@ -43,7 +43,7 @@ type GetCloudListRsp { TransitBoxes int64 `json:"transit_boxes"` MinTakeNum int64 `json:"minTakeNum"` ListData []ListDataItem `json:"listData"` - Pagnation Pagnation `json:"pagnation"` + Meta Meta `json:"_meta"` } type ListDataItem { Id int64 `json:"id"` From 519d9952e0f7df7ef07837aa032b639b7ee9bf20 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Thu, 29 Jun 2023 11:43:07 +0800 Subject: [PATCH 3/7] fix --- .../internal/logic/getproductlistlogic.go | 4 +- .../internal/logic/getsizebyproductlogic.go | 20 +++---- server/product/internal/types/types.go | 57 +++++++------------ server_api/product.api | 37 ++++-------- 4 files changed, 46 insertions(+), 72 deletions(-) diff --git a/server/product/internal/logic/getproductlistlogic.go b/server/product/internal/logic/getproductlistlogic.go index 134fdc42..5d680cf0 100644 --- a/server/product/internal/logic/getproductlistlogic.go +++ b/server/product/internal/logic/getproductlistlogic.go @@ -130,7 +130,7 @@ func (l *GetProductListLogic) GetProductList(req *types.GetProductListReq, useri return resp.SetStatusWithMessage(basic.CodeServiceErr, "get product size count err") } //拼接返回 - itemList := make([]*types.Items, 0, productLen) + itemList := make([]types.Items, 0, productLen) for _, v := range productList { minPrice, ok := mapProductMinPrice[v.Id] _, tmpOk := mapProductTemplate[v.Id] @@ -138,7 +138,7 @@ func (l *GetProductListLogic) GetProductList(req *types.GetProductListReq, useri if !ok || !tmpOk { continue } - item := &types.Items{ + item := types.Items{ Id: v.Id, Sn: *v.Sn, Title: *v.Title, diff --git a/server/product/internal/logic/getsizebyproductlogic.go b/server/product/internal/logic/getsizebyproductlogic.go index 2e87334c..cf8333e0 100644 --- a/server/product/internal/logic/getsizebyproductlogic.go +++ b/server/product/internal/logic/getsizebyproductlogic.go @@ -103,8 +103,8 @@ func (l *GetSizeByProductLogic) GetSizeByProduct(userinfo *auth.UserInfo) (resp } // 第一层子层 -func (l *GetSizeByProductLogic) GetFirstChildrenList(tag gmodel.FsTags, productList []gmodel.FsProduct, productSizeList []gmodel.FsProductSize, mapProductPrice map[int64]gmodel.FsProductPrice) (childrenList []*types.Children, err error) { - childrenList = make([]*types.Children, 0, len(productList)) +func (l *GetSizeByProductLogic) GetFirstChildrenList(tag gmodel.FsTags, productList []gmodel.FsProduct, productSizeList []gmodel.FsProductSize, mapProductPrice map[int64]gmodel.FsProductPrice) (childrenList []types.Children, err error) { + childrenList = make([]types.Children, 0, len(productList)) for _, product := range productList { if *product.Type != tag.Id { continue @@ -114,7 +114,7 @@ func (l *GetSizeByProductLogic) GetFirstChildrenList(tag gmodel.FsTags, productL return nil, err } //获取第二层子类 - data := &types.Children{ + data := types.Children{ Id: product.Id, Name: *product.Title, Cycle: int(*product.DeliveryDays + *product.ProduceDays), @@ -126,23 +126,23 @@ func (l *GetSizeByProductLogic) GetFirstChildrenList(tag gmodel.FsTags, productL } // 第2层子层 -func (l *GetSizeByProductLogic) GetSecondChildrenList(product gmodel.FsProduct, productSizeList []gmodel.FsProductSize, mapProductPrice map[int64]gmodel.FsProductPrice) (childrenObjList []*types.ChildrenObj, err error) { - childrenObjList = make([]*types.ChildrenObj, 0, len(productSizeList)) +func (l *GetSizeByProductLogic) GetSecondChildrenList(product gmodel.FsProduct, productSizeList []gmodel.FsProductSize, mapProductPrice map[int64]gmodel.FsProductPrice) (childrenObjList []types.ChildrenObj, err error) { + childrenObjList = make([]types.ChildrenObj, 0, len(productSizeList)) for _, productSize := range productSizeList { if product.Id != *productSize.ProductId { continue } - priceList := make([]*types.PriceObj, 0, len(productSizeList)) + priceList := make([]types.PriceObj, 0, len(productSizeList)) price, ok := mapProductPrice[productSize.Id] //无对应尺寸价格 if !ok { for i := 0; i < 3; i++ { - priceList = append(priceList, &types.PriceObj{ + priceList = append(priceList, types.PriceObj{ Num: 1, Price: 0, }) } - childrenObjList = append(childrenObjList, &types.ChildrenObj{ + childrenObjList = append(childrenObjList, types.ChildrenObj{ Id: productSize.Id, Name: *productSize.Capacity, PriceList: priceList, @@ -171,14 +171,14 @@ func (l *GetSizeByProductLogic) GetSecondChildrenList(product gmodel.FsProduct, index := 0 // 最小购买数量小于 最大阶梯数量+5 for int(*price.MinBuyNum) < (stepNum[len(stepNum)-1]+5) && index < 3 { - priceList = append(priceList, &types.PriceObj{ + priceList = append(priceList, types.PriceObj{ Num: int(*price.MinBuyNum * *price.EachBoxNum), Price: step_price.GetStepPrice(int(*price.MinBuyNum), stepNum, stepPrice), }) *price.MinBuyNum++ index++ } - data := &types.ChildrenObj{ + data := types.ChildrenObj{ Id: productSize.Id, Name: *productSize.Capacity, PriceList: priceList, diff --git a/server/product/internal/types/types.go b/server/product/internal/types/types.go index a56d6ddf..04901fbb 100644 --- a/server/product/internal/types/types.go +++ b/server/product/internal/types/types.go @@ -19,23 +19,8 @@ type GetProductListRsp struct { } type Ob struct { - Items []*Items `json:"items"` - Links *Links `json:"_links"` - Meta *Meta `json:"_meta"` -} - -type Meta struct { - TotalCount int32 `json:"totalCount"` - PageCount int32 `json:"pageCount"` - CurrentPage int32 `json:"currentPage"` - PerPage int32 `json:"perPage"` -} - -type Links struct { - Self HrefUrl `json:"self"` - First HrefUrl `json:"first"` - Last HrefUrl `json:"last"` - Next HrefUrl `json:"next"` + Items []Items `json:"items"` + Meta Meta `json:"_meta"` } type HrefUrl struct { @@ -73,22 +58,22 @@ type GetSuccessRecommandRsp struct { } type GetSizeByProductRsp struct { - Id int64 `json:"id"` - Name string `json:"name"` - Children []*Children `json:"children"` + Id int64 `json:"id"` + Name string `json:"name"` + Children []Children `json:"children"` } type Children struct { - Id int64 `json:"id"` - Name string `json:"name"` - Cycle int `json:"cycle"` - ChildrenList []*ChildrenObj `json:"children"` + Id int64 `json:"id"` + Name string `json:"name"` + Cycle int `json:"cycle"` + ChildrenList []ChildrenObj `json:"children"` } type ChildrenObj struct { - Id int64 `json:"id"` - Name string `json:"name"` - PriceList []*PriceObj `json:"price_list"` + Id int64 `json:"id"` + Name string `json:"name"` + PriceList []PriceObj `json:"price_list"` } type PriceObj struct { @@ -110,26 +95,28 @@ type GetProductDesignRsp struct { Info string `json:"info"` } +type Request struct { +} + type Response struct { Code int `json:"code"` Message string `json:"msg"` Data interface{} `json:"data"` } -type ResponseJwt struct { - Code int `json:"code"` - Message string `json:"msg"` - Data interface{} `json:"data"` - AccessSecret string `json:"accessSecret"` - AccessExpire int64 `json:"accessExpire"` -} - type Auth struct { AccessSecret string `json:"accessSecret"` AccessExpire int64 `json:"accessExpire"` RefreshAfter int64 `json:"refreshAfter"` } +type Meta struct { + TotalCount int64 `json:"totalCount"` + PageCount int64 `json:"pageCount"` + CurrentPage int `json:"currentPage"` + PerPage int `json:"perPage"` +} + // Set 设置Response的Code和Message值 func (resp *Response) Set(Code int, Message string) *Response { return &Response{ diff --git a/server_api/product.api b/server_api/product.api index be17adc3..f016a52c 100644 --- a/server_api/product.api +++ b/server_api/product.api @@ -37,21 +37,8 @@ type GetProductListRsp { Description string `json:"description"` } type Ob { - Items []*Items `json:"items"` - Links *Links `json:"_links"` - Meta *Meta `json:"_meta"` -} -type Meta { - TotalCount int32 `json:"totalCount"` - PageCount int32 `json:"pageCount"` - CurrentPage int32 `json:"currentPage"` - PerPage int32 `json:"perPage"` -} -type Links { - Self HrefUrl `json:"self"` - First HrefUrl `json:"first"` - Last HrefUrl `json:"last"` - Next HrefUrl `json:"next"` + Items []Items `json:"items"` + Meta Meta `json:"_meta"` } type HrefUrl { Href string `json:"href"` @@ -87,20 +74,20 @@ type GetSuccessRecommandRsp { //获取分类下的产品以及尺寸 type GetSizeByProductRsp { - Id int64 `json:"id"` - Name string `json:"name"` - Children []*Children `json:"children"` + Id int64 `json:"id"` + Name string `json:"name"` + Children []Children `json:"children"` } type Children { - Id int64 `json:"id"` - Name string `json:"name"` - Cycle int `json:"cycle"` - ChildrenList []*ChildrenObj `json:"children"` + Id int64 `json:"id"` + Name string `json:"name"` + Cycle int `json:"cycle"` + ChildrenList []ChildrenObj `json:"children"` } type ChildrenObj { - Id int64 `json:"id"` - Name string `json:"name"` - PriceList []*PriceObj `json:"price_list"` + Id int64 `json:"id"` + Name string `json:"name"` + PriceList []PriceObj `json:"price_list"` } type PriceObj { Num int `json:"num"` From 543308ddbc58100f7d0ecec5e86b59cd35cc861b Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Thu, 29 Jun 2023 11:46:04 +0800 Subject: [PATCH 4/7] fix --- .../internal/logic/getpickuplistlogic.go | 5 ++- server/inventory/internal/types/types.go | 40 +++++++++++++++++++ server_api/inventory.api | 36 +++++++++++++++++ 3 files changed, 79 insertions(+), 2 deletions(-) diff --git a/server/inventory/internal/logic/getpickuplistlogic.go b/server/inventory/internal/logic/getpickuplistlogic.go index fff544ee..28d20a81 100644 --- a/server/inventory/internal/logic/getpickuplistlogic.go +++ b/server/inventory/internal/logic/getpickuplistlogic.go @@ -27,8 +27,9 @@ func NewGetPickupListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Get } func (l *GetPickupListLogic) GetPickupList(req *types.GetPickupListReq, userinfo *auth.UserInfo) (resp *basic.Response) { - // 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data) - // userinfo 传入值时, 一定不为null + if userinfo.GetIdType() != auth.IDTYPE_User { + return resp.SetStatusWithMessage(basic.CodeServiceErr, "please login first") + } return resp.SetStatus(basic.CodeOK) } diff --git a/server/inventory/internal/types/types.go b/server/inventory/internal/types/types.go index 40d7272c..338666eb 100644 --- a/server/inventory/internal/types/types.go +++ b/server/inventory/internal/types/types.go @@ -70,6 +70,46 @@ type GetPickupListReq struct { Size int `form:"size"` } +type GetPickupListRsp struct { + PickupList []PickupItem `json:"items"` + Meta Meta `json:"_meta"` +} + +type PickupItem struct { + Id int `json:"id"` + UserId int `json:"user_id"` + TrackNum string `json:"track_num"` + Ctime string `json:"ctime"` + Status int `json:"status"` + UpsSn string `json:"ups_sn"` + Address string `json:"address"` + ProductList []Product `json:"productList"` + Pcs int `json:"pcs"` + PcsBox int `json:"pcs_box"` + LogisticsStatus int `json:"logistics_status"` + StatusTimes []StatusTimesItem `json:"status_times"` +} + +type Product struct { + Id int `json:"id"` + PickId int `json:"pick_id"` + StockId int `json:"stock_id"` + Num int `json:"num"` + Boxes int `json:"boxes"` + Ctime int `json:"ctime"` + ProductName string `json:"product_name"` + Pcs int `json:"pcs"` + PcsBox int `json:"pcs_box"` + Cover string `json:"cover"` + Size string `json:"size"` + Fitting string `json:"fitting"` +} + +type StatusTimesItem struct { + Key int `json:"key"` + Time string `json:"time"` +} + type Request struct { } diff --git a/server_api/inventory.api b/server_api/inventory.api index 803b1041..38047062 100644 --- a/server_api/inventory.api +++ b/server_api/inventory.api @@ -84,4 +84,40 @@ type GetPickupListReq { Page int `form:"page"` PageSize int `form:"page_size"` Size int `form:"size"` +} +type GetPickupListRsp { + PickupList []PickupItem `json:"items"` + Meta Meta `json:"_meta"` +} +type PickupItem { + Id int `json:"id"` + UserId int `json:"user_id"` + TrackNum string `json:"track_num"` + Ctime string `json:"ctime"` + Status int `json:"status"` + UpsSn string `json:"ups_sn"` + Address string `json:"address"` + ProductList []Product `json:"productList"` + Pcs int `json:"pcs"` + PcsBox int `json:"pcs_box"` + LogisticsStatus int `json:"logistics_status"` + StatusTimes []StatusTimesItem `json:"status_times"` +} +type Product { + Id int `json:"id"` + PickId int `json:"pick_id"` + StockId int `json:"stock_id"` + Num int `json:"num"` + Boxes int `json:"boxes"` + Ctime int `json:"ctime"` + ProductName string `json:"product_name"` + Pcs int `json:"pcs"` + PcsBox int `json:"pcs_box"` + Cover string `json:"cover"` + Size string `json:"size"` + Fitting string `json:"fitting"` +} +type StatusTimesItem { + Key int `json:"key"` + Time string `json:"time"` } \ No newline at end of file From f09e1b8f9340cc749dd9db064f6ebaec90784416 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Thu, 29 Jun 2023 13:59:55 +0800 Subject: [PATCH 5/7] fix --- constants/paging.go | 3 ++ model/gmodel/fs_cloud_pick_up_detail_logic.go | 13 ++++++- model/gmodel/fs_cloud_pick_up_logic.go | 29 ++++++++++++++ .../internal/logic/getcloudlistlogic.go | 2 +- .../internal/logic/getpickuplistlogic.go | 38 ++++++++++++++++++- server/inventory/internal/types/types.go | 2 +- server_api/inventory.api | 2 +- 7 files changed, 84 insertions(+), 5 deletions(-) diff --git a/constants/paging.go b/constants/paging.go index 001a1923..638a38de 100644 --- a/constants/paging.go +++ b/constants/paging.go @@ -5,3 +5,6 @@ const DEFAULT_PAGE = 1 // 默认每页数量 const DEFAULT_PAGE_SIZE = 20 + +// 最大每页显示数量 +const MAX_PAGE_SIZE = 300 diff --git a/model/gmodel/fs_cloud_pick_up_detail_logic.go b/model/gmodel/fs_cloud_pick_up_detail_logic.go index e68225aa..3f8ccf13 100644 --- a/model/gmodel/fs_cloud_pick_up_detail_logic.go +++ b/model/gmodel/fs_cloud_pick_up_detail_logic.go @@ -1,2 +1,13 @@ package gmodel -// TODO: 使用model的属性做你想做的 \ No newline at end of file + +import "context" + +// TODO: 使用model的属性做你想做的 + +func (p *FsCloudPickUpDetailModel) GetAllByIds(ctx context.Context, ids []int64) (resp []FsCloudPickUpDetail, err error) { + if len(ids) == 0 { + return + } + err = p.db.WithContext(ctx).Model(&FsCloudPickUpDetail{}).Where("`id` in (?)", ids).Find(&resp).Error + return resp, err +} diff --git a/model/gmodel/fs_cloud_pick_up_logic.go b/model/gmodel/fs_cloud_pick_up_logic.go index c6fd862b..e9f1d70e 100644 --- a/model/gmodel/fs_cloud_pick_up_logic.go +++ b/model/gmodel/fs_cloud_pick_up_logic.go @@ -35,3 +35,32 @@ func (p *FsCloudPickUpModel) GetCloudPickUpByIDAndUserID(ctx context.Context, us return cloudOrder, err } + +type GetPickupListByParamReq struct { + UserId *int64 + Status *int64 + Ids []int64 + Page int + Limit int +} + +func (p *FsCloudPickUpModel) GetPickupListByParam(ctx context.Context, req GetPickupListByParamReq) (resp []FsCloudPickUp, total int64, err error) { + db := p.db.WithContext(ctx).Model(&FsCloudPickUp{}) + if req.UserId != nil { + db = db.Where("`user_id` = ?", *req.UserId) + } + if req.Status != nil { + db = db.Where("`status` = ?", *req.Status) + } + if len(req.Ids) > 0 { + db = db.Where("`id` in (?)", req.Ids) + } + if err = db.Limit(1).Count(&total).Error; err != nil { + return nil, 0, err + } + offset := (req.Page - 1) * req.Limit + if err = db.Offset(offset).Limit(req.Limit).Order("id desc").Find(&resp).Error; err != nil { + return nil, 0, err + } + return +} diff --git a/server/inventory/internal/logic/getcloudlistlogic.go b/server/inventory/internal/logic/getcloudlistlogic.go index 82c06abf..450c327c 100644 --- a/server/inventory/internal/logic/getcloudlistlogic.go +++ b/server/inventory/internal/logic/getcloudlistlogic.go @@ -41,7 +41,7 @@ func (l *GetCloudListLogic) GetCloudList(req *types.GetCloudListReq, userinfo *a if req.Page <= 0 { req.Page = constants.DEFAULT_PAGE } - if req.PageSize <= 0 || req.PageSize > 200 { + if req.PageSize <= 0 || req.PageSize > constants.MAX_PAGE_SIZE { req.PageSize = constants.DEFAULT_PAGE_SIZE } sizeFlag := false diff --git a/server/inventory/internal/logic/getpickuplistlogic.go b/server/inventory/internal/logic/getpickuplistlogic.go index 28d20a81..8b4ec004 100644 --- a/server/inventory/internal/logic/getpickuplistlogic.go +++ b/server/inventory/internal/logic/getpickuplistlogic.go @@ -1,6 +1,8 @@ package logic import ( + "fusenapi/constants" + "fusenapi/model/gmodel" "fusenapi/utils/auth" "fusenapi/utils/basic" @@ -30,6 +32,40 @@ func (l *GetPickupListLogic) GetPickupList(req *types.GetPickupListReq, userinfo if userinfo.GetIdType() != auth.IDTYPE_User { return resp.SetStatusWithMessage(basic.CodeServiceErr, "please login first") } - + if req.Page <= 0 { + req.Page = constants.DEFAULT_PAGE + } + if req.PageSize <= 0 || req.PageSize > constants.MAX_PAGE_SIZE { + req.PageSize = constants.DEFAULT_PAGE_SIZE + } + //获取列表 + pickListReq := gmodel.GetPickupListByParamReq{ + UserId: &userinfo.UserId, + Page: req.Page, + Limit: req.PageSize, + } + //状态筛选 + if req.Status != -1 { + pickListReq.Status = &req.Status + } + pickupList, total, err := l.svcCtx.AllModels.FsCloudPickUp.GetPickupListByParam(l.ctx, pickListReq) + if err != nil { + logx.Error(err) + return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get pickup list") + } + if len(pickupList) == 0 { + return resp.SetStatus(basic.CodeOK) + } + pickupIds := make([]int64, 0, len(pickupList)) + for _, v := range pickupList { + pickupIds = append(pickupIds, v.Id) + } + //获取详情数据 + pickupDetailList, err := l.svcCtx.AllModels.FsCloudPickUpDetail.GetAllByIds(l.ctx, pickupIds) + if err != nil { + logx.Error(err) + return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get pickup detail list") + } + stockIds := make([]int64, 0, len(pickupList)) return resp.SetStatus(basic.CodeOK) } diff --git a/server/inventory/internal/types/types.go b/server/inventory/internal/types/types.go index 338666eb..d2178002 100644 --- a/server/inventory/internal/types/types.go +++ b/server/inventory/internal/types/types.go @@ -64,7 +64,7 @@ type SupplementRsp struct { } type GetPickupListReq struct { - Status int64 `form:"status,options=0|1|2|3|4"` + Status int64 `form:"status,options=-1|1|2|3|4"` Page int `form:"page"` PageSize int `form:"page_size"` Size int `form:"size"` diff --git a/server_api/inventory.api b/server_api/inventory.api index 38047062..3e10eb7c 100644 --- a/server_api/inventory.api +++ b/server_api/inventory.api @@ -80,7 +80,7 @@ type SupplementRsp { //提货列表 type GetPickupListReq { - Status int64 `form:"status,options=0|1|2|3|4"` + Status int64 `form:"status,options=-1|1|2|3|4"` Page int `form:"page"` PageSize int `form:"page_size"` Size int `form:"size"` From 81a64b2129f2803bb091c927d36f19a1524851f5 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Thu, 29 Jun 2023 17:25:34 +0800 Subject: [PATCH 6/7] fix --- .../internal/logic/getcloudlistlogic.go | 4 +- .../internal/logic/getpickuplistlogic.go | 220 +++++++++++++++++- server/inventory/internal/logic/takelogic.go | 2 +- server/inventory/internal/types/types.go | 30 +-- server_api/inventory.api | 30 +-- 5 files changed, 246 insertions(+), 40 deletions(-) diff --git a/server/inventory/internal/logic/getcloudlistlogic.go b/server/inventory/internal/logic/getcloudlistlogic.go index 450c327c..4889a83b 100644 --- a/server/inventory/internal/logic/getcloudlistlogic.go +++ b/server/inventory/internal/logic/getcloudlistlogic.go @@ -62,9 +62,7 @@ func (l *GetCloudListLogic) GetCloudList(req *types.GetCloudListReq, userinfo *a return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get user stock list") } if len(stockList) == 0 { - return resp.SetStatusWithMessage(basic.CodeOK, "success", types.GetCloudListRsp{ - ListData: []types.ListDataItem{}, - }) + return resp.SetStatusWithMessage(basic.CodeOK, "success") } designIds := make([]int64, 0, len(stockList)) for _, v := range stockList { diff --git a/server/inventory/internal/logic/getpickuplistlogic.go b/server/inventory/internal/logic/getpickuplistlogic.go index 8b4ec004..e84378d8 100644 --- a/server/inventory/internal/logic/getpickuplistlogic.go +++ b/server/inventory/internal/logic/getpickuplistlogic.go @@ -1,12 +1,18 @@ package logic import ( + "context" + "encoding/json" + "errors" + "fmt" "fusenapi/constants" "fusenapi/model/gmodel" "fusenapi/utils/auth" "fusenapi/utils/basic" - - "context" + "gorm.io/gorm" + "math" + "strconv" + "time" "fusenapi/server/inventory/internal/svc" "fusenapi/server/inventory/internal/types" @@ -48,14 +54,12 @@ func (l *GetPickupListLogic) GetPickupList(req *types.GetPickupListReq, userinfo if req.Status != -1 { pickListReq.Status = &req.Status } + //空的就返回 pickupList, total, err := l.svcCtx.AllModels.FsCloudPickUp.GetPickupListByParam(l.ctx, pickListReq) if err != nil { logx.Error(err) return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get pickup list") } - if len(pickupList) == 0 { - return resp.SetStatus(basic.CodeOK) - } pickupIds := make([]int64, 0, len(pickupList)) for _, v := range pickupList { pickupIds = append(pickupIds, v.Id) @@ -67,5 +71,209 @@ func (l *GetPickupListLogic) GetPickupList(req *types.GetPickupListReq, userinfo return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get pickup detail list") } stockIds := make([]int64, 0, len(pickupList)) - return resp.SetStatus(basic.CodeOK) + for _, v := range pickupDetailList { + stockIds = append(stockIds, *v.StockId) + } + stockList, _, err := l.svcCtx.AllModels.FsUserStock.GetStockList(l.ctx, gmodel.GetStockListReq{ + UserId: userinfo.UserId, + Ids: stockIds, + Page: 1, + Limit: len(stockIds), + }) + if err != nil { + logx.Error(err) + return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get stock list") + } + designIds := make([]int64, 0, len(stockList)) + mapStock := make(map[int64]int) + for k, v := range stockList { + designIds = append(designIds, *v.DesignId) + mapStock[v.Id] = k + } + //获取设计列表 + designList, err := l.svcCtx.AllModels.FsProductDesign.GetAllByIdsWithoutStatus(l.ctx, designIds) + if err != nil { + logx.Error(err) + return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get design list") + } + productIds := make([]int64, 0, len(designList)) + sizeIds := make([]int64, 0, len(designList)) + optionalIds := make([]int64, 0, len(designList)) + mapDesign := make(map[int64]int) + for k, v := range designList { + productIds = append(productIds, *v.ProductId) + sizeIds = append(sizeIds, *v.SizeId) + optionalIds = append(optionalIds, *v.OptionalId) + mapDesign[v.Id] = k + } + //获取产品信息 + productList, err := l.svcCtx.AllModels.FsProduct.GetProductListByIdsWithoutStatus(l.ctx, productIds, "") + if err != nil { + logx.Error(err) + return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get product list ") + } + mapProduct := make(map[int64]int) + for k, v := range productList { + mapProduct[v.Id] = k + } + //获取尺寸信息 + sizeList, err := l.svcCtx.AllModels.FsProductSize.GetAllByIdsWithoutStatus(l.ctx, sizeIds, "") + if err != nil { + logx.Error(err) + return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get product size list ") + } + mapSize := make(map[int64]int) + for k, v := range sizeList { + mapSize[v.Id] = k + } + //获取配件信息 + model3dList, err := l.svcCtx.AllModels.FsProductModel3d.GetAllByIdsWithoutStatus(l.ctx, optionalIds) + if err != nil { + logx.Error(err) + return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get product 3d model list ") + } + mapModel3d := make(map[int64]int) + for k, v := range model3dList { + mapModel3d[v.Id] = k + } + //获取时间配置 + var ( + factoryDeliverDay int64 = 2 + deliverUpsDay int64 = 35 + upsTransDay int64 = 5 + ) + if timeSetting, err := l.svcCtx.AllModels.FsWebSet.FindValueByKey(l.ctx, "time_info"); err != nil { + if !errors.Is(err, gorm.ErrRecordNotFound) { + logx.Error(err) + return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get web setting:time_info") + } + } else { //存在记录 + if timeSetting.Value != nil { + var timeInfo map[string]string + if err = json.Unmarshal([]byte(*timeSetting.Value), &timeInfo); err != nil { + logx.Error(err) + return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to parse time_info ") + } + factoryDeliverDay, _ = strconv.ParseInt(timeInfo["factory_deliver_day"], 10, 64) + deliverUpsDay, _ = strconv.ParseInt(timeInfo["deliver_ups_day"], 10, 64) + upsTransDay, _ = strconv.ParseInt(timeInfo["ups_trans_day"], 10, 64) + } + } + //处理提货单列表详情数据 + type mapPickupProductItem struct { + List []types.Product + PickNum int64 + PickBoxes int64 + } + mapPickupProduct := make(map[int64]*mapPickupProductItem) + for _, v := range pickupDetailList { + stockIndex, ok := mapStock[*v.StockId] + if !ok { + continue + } + designIndex, ok := mapDesign[*stockList[stockIndex].DesignId] + if !ok { + continue + } + designInfo := designList[designIndex] + productIndex, ok := mapProduct[*designInfo.ProductId] + if !ok { + continue + } + productInfo := productList[productIndex] + sizeIndex, ok := mapSize[*designInfo.SizeId] + if !ok { + continue + } + sizeInfo := sizeList[sizeIndex] + fitting := "" + if model3dIndex, ok := mapModel3d[*designInfo.OptionalId]; ok { + fitting = *model3dList[model3dIndex].Title + } + productItem := types.Product{ + Id: v.Id, + PickId: *v.PickId, + StockId: *v.StockId, + Num: *v.Num, + Boxes: *v.Boxes, + Ctime: *v.Ctime, + ProductName: *productInfo.Title, + Pcs: *v.Num, + PcsBox: *v.Boxes, + Cover: *designInfo.Cover, + Size: *sizeInfo.Capacity, + Fitting: fitting, + } + //已经存在 + if _, ok := mapPickupProduct[*v.PickId]; ok { + mapPickupProduct[*v.PickId].List = append(mapPickupProduct[*v.PickId].List, productItem) + mapPickupProduct[*v.PickId].PickNum += *v.Num + mapPickupProduct[*v.PickId].PickBoxes += *v.Boxes + } else { //不存在 + mapPickupProduct[*v.PickId] = &mapPickupProductItem{ + List: []types.Product{productItem}, + PickNum: *v.Num, + PickBoxes: *v.Boxes, + } + } + } + //处理提货单数据 + listRsp := make([]types.PickupItem, 0, len(pickupList)) + for _, v := range pickupList { + //地址处理 + address := "" + if *v.AddressInfo != "" { + var addressInfo map[string]interface{} + if err = json.Unmarshal([]byte(*v.AddressInfo), &addressInfo); err != nil { + logx.Error(err) + return resp.SetStatusWithMessage(basic.CodeServiceErr, fmt.Sprintf("failed to parse address,pickup_id = %d", v.Id)) + } + address += addressInfo["street"].(string) + " " + addressInfo["suite"].(string) + "," + address += addressInfo["city"].(string) + "," + addressInfo["state"].(string) + " " + addressInfo["zip_code"].(string) + } + if *v.Status < int64(constants.STATUS_SHIPPING) { + *v.ShippingTime = *v.Ctime + factoryDeliverDay*24*3600 + } + if *v.Status < int64(constants.STATUS_PICK_UP) { + *v.UpsTime = *v.ShippingTime + deliverUpsDay*24*3600 + } + if *v.Status < int64(constants.STATUS_ARRIVAL) { + *v.ArrivalTime = *v.UpsTime + upsTransDay*24*3600 + } + d := types.PickupItem{ + Id: v.Id, + UserId: *v.UserId, + TrackNum: *v.TrackNum, + Ctime: time.Unix(*v.Ctime, 0).Format("2006-01-02 15:04:05"), + Status: *v.Status, + UpsSn: *v.UpsSn, + Address: address, + ProductList: nil, + Pcs: 0, + PcsBox: 0, + LogisticsStatus: *v.Status, + StatusTimes: []types.StatusTimesItem{ + {Key: int64(constants.STATUS_ORDERD), Time: ""}, + {Key: int64(constants.STATUS_SHIPPING), Time: time.Unix(*v.ShippingTime, 0).Format("2006-01-02 15:04:05")}, + {Key: int64(constants.STATUS_PICK_UP), Time: time.Unix(*v.UpsTime, 0).Format("2006-01-02 15:04:05")}, + {Key: int64(constants.STATUS_ARRIVAL), Time: time.Unix(*v.ArrivalTime, 0).Format("2006-01-02 15:04:05")}, + }, + } + if pickupProduct, ok := mapPickupProduct[v.Id]; ok { + d.ProductList = pickupProduct.List + d.Pcs = pickupProduct.PickNum + d.PcsBox = pickupProduct.PickBoxes + } + + listRsp = append(listRsp, d) + } + return resp.SetStatusWithMessage(basic.CodeOK, "success", types.GetPickupListRsp{ + PickupList: listRsp, + Meta: types.Meta{ + TotalCount: total, + PageCount: int64(math.Ceil(float64(total) / float64(req.PageSize))), + CurrentPage: req.Page, + PerPage: req.PageSize, + }, + }) } diff --git a/server/inventory/internal/logic/takelogic.go b/server/inventory/internal/logic/takelogic.go index 2abbceee..c623c717 100644 --- a/server/inventory/internal/logic/takelogic.go +++ b/server/inventory/internal/logic/takelogic.go @@ -125,5 +125,5 @@ func (l *TakeLogic) Take(req *types.TakeReq, userinfo *auth.UserInfo) (resp *bas logx.Error(err) return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to take your goods") } - return resp.SetStatusWithMessage(basic.CodeOK, "success", []int64{}) + return resp.SetStatusWithMessage(basic.CodeOK, "success") } diff --git a/server/inventory/internal/types/types.go b/server/inventory/internal/types/types.go index d2178002..b4599a41 100644 --- a/server/inventory/internal/types/types.go +++ b/server/inventory/internal/types/types.go @@ -76,37 +76,37 @@ type GetPickupListRsp struct { } type PickupItem struct { - Id int `json:"id"` - UserId int `json:"user_id"` + Id int64 `json:"id"` + UserId int64 `json:"user_id"` TrackNum string `json:"track_num"` Ctime string `json:"ctime"` - Status int `json:"status"` + Status int64 `json:"status"` UpsSn string `json:"ups_sn"` Address string `json:"address"` ProductList []Product `json:"productList"` - Pcs int `json:"pcs"` - PcsBox int `json:"pcs_box"` - LogisticsStatus int `json:"logistics_status"` + Pcs int64 `json:"pcs"` + PcsBox int64 `json:"pcs_box"` + LogisticsStatus int64 `json:"logistics_status"` StatusTimes []StatusTimesItem `json:"status_times"` } type Product struct { - Id int `json:"id"` - PickId int `json:"pick_id"` - StockId int `json:"stock_id"` - Num int `json:"num"` - Boxes int `json:"boxes"` - Ctime int `json:"ctime"` + Id int64 `json:"id"` + PickId int64 `json:"pick_id"` + StockId int64 `json:"stock_id"` + Num int64 `json:"num"` + Boxes int64 `json:"boxes"` + Ctime int64 `json:"ctime"` ProductName string `json:"product_name"` - Pcs int `json:"pcs"` - PcsBox int `json:"pcs_box"` + Pcs int64 `json:"pcs"` + PcsBox int64 `json:"pcs_box"` Cover string `json:"cover"` Size string `json:"size"` Fitting string `json:"fitting"` } type StatusTimesItem struct { - Key int `json:"key"` + Key int64 `json:"key"` Time string `json:"time"` } diff --git a/server_api/inventory.api b/server_api/inventory.api index 3e10eb7c..8907928e 100644 --- a/server_api/inventory.api +++ b/server_api/inventory.api @@ -90,34 +90,34 @@ type GetPickupListRsp { Meta Meta `json:"_meta"` } type PickupItem { - Id int `json:"id"` - UserId int `json:"user_id"` + Id int64 `json:"id"` + UserId int64 `json:"user_id"` TrackNum string `json:"track_num"` Ctime string `json:"ctime"` - Status int `json:"status"` + Status int64 `json:"status"` UpsSn string `json:"ups_sn"` Address string `json:"address"` ProductList []Product `json:"productList"` - Pcs int `json:"pcs"` - PcsBox int `json:"pcs_box"` - LogisticsStatus int `json:"logistics_status"` + Pcs int64 `json:"pcs"` + PcsBox int64 `json:"pcs_box"` + LogisticsStatus int64 `json:"logistics_status"` StatusTimes []StatusTimesItem `json:"status_times"` } type Product { - Id int `json:"id"` - PickId int `json:"pick_id"` - StockId int `json:"stock_id"` - Num int `json:"num"` - Boxes int `json:"boxes"` - Ctime int `json:"ctime"` + Id int64 `json:"id"` + PickId int64 `json:"pick_id"` + StockId int64 `json:"stock_id"` + Num int64 `json:"num"` + Boxes int64 `json:"boxes"` + Ctime int64 `json:"ctime"` ProductName string `json:"product_name"` - Pcs int `json:"pcs"` - PcsBox int `json:"pcs_box"` + Pcs int64 `json:"pcs"` + PcsBox int64 `json:"pcs_box"` Cover string `json:"cover"` Size string `json:"size"` Fitting string `json:"fitting"` } type StatusTimesItem { - Key int `json:"key"` + Key int64 `json:"key"` Time string `json:"time"` } \ No newline at end of file From 9f865eb1c5abfa675fc82fe2453774e720842ce2 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Thu, 29 Jun 2023 17:48:07 +0800 Subject: [PATCH 7/7] fix --- server/product/internal/logic/getsizebyproductlogic.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/server/product/internal/logic/getsizebyproductlogic.go b/server/product/internal/logic/getsizebyproductlogic.go index cf8333e0..644c7f94 100644 --- a/server/product/internal/logic/getsizebyproductlogic.go +++ b/server/product/internal/logic/getsizebyproductlogic.go @@ -136,11 +136,10 @@ func (l *GetSizeByProductLogic) GetSecondChildrenList(product gmodel.FsProduct, price, ok := mapProductPrice[productSize.Id] //无对应尺寸价格 if !ok { - for i := 0; i < 3; i++ { - priceList = append(priceList, types.PriceObj{ - Num: 1, - Price: 0, - }) + priceList = []types.PriceObj{ + {Num: 1, Price: 0}, + {Num: 1, Price: 0}, + {Num: 1, Price: 0}, } childrenObjList = append(childrenObjList, types.ChildrenObj{ Id: productSize.Id,