Merge branch 'develop' of https://gitee.com/fusenpack/fusenapi into develop
This commit is contained in:
commit
7d386237fb
|
@ -5,3 +5,6 @@ const DEFAULT_PAGE = 1
|
|||
|
||||
// 默认每页数量
|
||||
const DEFAULT_PAGE_SIZE = 20
|
||||
|
||||
// 最大每页显示数量
|
||||
const MAX_PAGE_SIZE = 300
|
||||
|
|
|
@ -1,2 +1,13 @@
|
|||
package gmodel
|
||||
// TODO: 使用model的属性做你想做的
|
||||
|
||||
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
|
||||
}
|
||||
|
|
|
@ -49,3 +49,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
|
||||
}
|
||||
|
|
78
server/inventory/internal/handler/getpickuplisthandler.go
Normal file
78
server/inventory/internal/handler/getpickuplisthandler.go
Normal file
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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),
|
||||
},
|
||||
},
|
||||
)
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
@ -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 {
|
||||
|
@ -256,11 +254,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,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
|
279
server/inventory/internal/logic/getpickuplistlogic.go
Normal file
279
server/inventory/internal/logic/getpickuplistlogic.go
Normal file
|
@ -0,0 +1,279 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"fusenapi/constants"
|
||||
"fusenapi/model/gmodel"
|
||||
"fusenapi/utils/auth"
|
||||
"fusenapi/utils/basic"
|
||||
"gorm.io/gorm"
|
||||
"math"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"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) {
|
||||
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")
|
||||
}
|
||||
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))
|
||||
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,
|
||||
},
|
||||
})
|
||||
}
|
|
@ -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")
|
||||
}
|
||||
|
|
|
@ -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"`
|
||||
}
|
||||
|
||||
|
@ -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 {
|
||||
|
@ -63,6 +63,53 @@ type SupplementRsp struct {
|
|||
Sn string `json:"sn"`
|
||||
}
|
||||
|
||||
type GetPickupListReq struct {
|
||||
Status int64 `form:"status,options=-1|1|2|3|4"`
|
||||
Page int `form:"page"`
|
||||
PageSize int `form:"page_size"`
|
||||
Size int `form:"size"`
|
||||
}
|
||||
|
||||
type GetPickupListRsp struct {
|
||||
PickupList []PickupItem `json:"items"`
|
||||
Meta Meta `json:"_meta"`
|
||||
}
|
||||
|
||||
type PickupItem struct {
|
||||
Id int64 `json:"id"`
|
||||
UserId int64 `json:"user_id"`
|
||||
TrackNum string `json:"track_num"`
|
||||
Ctime string `json:"ctime"`
|
||||
Status int64 `json:"status"`
|
||||
UpsSn string `json:"ups_sn"`
|
||||
Address string `json:"address"`
|
||||
ProductList []Product `json:"productList"`
|
||||
Pcs int64 `json:"pcs"`
|
||||
PcsBox int64 `json:"pcs_box"`
|
||||
LogisticsStatus int64 `json:"logistics_status"`
|
||||
StatusTimes []StatusTimesItem `json:"status_times"`
|
||||
}
|
||||
|
||||
type Product struct {
|
||||
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 int64 `json:"pcs"`
|
||||
PcsBox int64 `json:"pcs_box"`
|
||||
Cover string `json:"cover"`
|
||||
Size string `json:"size"`
|
||||
Fitting string `json:"fitting"`
|
||||
}
|
||||
|
||||
type StatusTimesItem struct {
|
||||
Key int64 `json:"key"`
|
||||
Time string `json:"time"`
|
||||
}
|
||||
|
||||
type Request struct {
|
||||
}
|
||||
|
||||
|
@ -78,11 +125,11 @@ type Auth struct {
|
|||
RefreshAfter int64 `json:"refreshAfter"`
|
||||
}
|
||||
|
||||
type Pagnation struct {
|
||||
TotalCount int64 `json:"total_count"`
|
||||
TotalPage int64 `json:"total_page"`
|
||||
CurPage int64 `json:"cur_page"`
|
||||
PageSize int64 `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值
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,22 @@ 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{
|
||||
Num: 1,
|
||||
Price: 0,
|
||||
})
|
||||
priceList = []types.PriceObj{
|
||||
{Num: 1, Price: 0},
|
||||
{Num: 1, Price: 0},
|
||||
{Num: 1, Price: 0},
|
||||
}
|
||||
childrenObjList = append(childrenObjList, &types.ChildrenObj{
|
||||
childrenObjList = append(childrenObjList, types.ChildrenObj{
|
||||
Id: productSize.Id,
|
||||
Name: *productSize.Capacity,
|
||||
PriceList: priceList,
|
||||
|
@ -171,14 +170,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,
|
||||
|
|
|
@ -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{
|
||||
|
|
|
@ -26,10 +26,9 @@ type Auth {
|
|||
}
|
||||
|
||||
// 统一分页
|
||||
type Pagnation{
|
||||
TotalCount int64 `json:"total_count"`
|
||||
TotalPage int64 `json:"total_page"`
|
||||
CurPage int64 `json:"cur_page"`
|
||||
PageSize int64 `json:"page_size"`
|
||||
}
|
||||
|
||||
type Meta struct {
|
||||
TotalCount int64 `json:"totalCount"`
|
||||
PageCount int64 `json:"pageCount"`
|
||||
CurrentPage int `json:"currentPage"`
|
||||
PerPage int `json:"perPage"`
|
||||
}
|
|
@ -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 {
|
||||
|
@ -40,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"`
|
||||
|
@ -73,4 +76,48 @@ type SupplementReq {
|
|||
}
|
||||
type SupplementRsp {
|
||||
Sn string `json:"sn"`
|
||||
}
|
||||
|
||||
//提货列表
|
||||
type GetPickupListReq {
|
||||
Status int64 `form:"status,options=-1|1|2|3|4"`
|
||||
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 int64 `json:"id"`
|
||||
UserId int64 `json:"user_id"`
|
||||
TrackNum string `json:"track_num"`
|
||||
Ctime string `json:"ctime"`
|
||||
Status int64 `json:"status"`
|
||||
UpsSn string `json:"ups_sn"`
|
||||
Address string `json:"address"`
|
||||
ProductList []Product `json:"productList"`
|
||||
Pcs int64 `json:"pcs"`
|
||||
PcsBox int64 `json:"pcs_box"`
|
||||
LogisticsStatus int64 `json:"logistics_status"`
|
||||
StatusTimes []StatusTimesItem `json:"status_times"`
|
||||
}
|
||||
type Product {
|
||||
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 int64 `json:"pcs"`
|
||||
PcsBox int64 `json:"pcs_box"`
|
||||
Cover string `json:"cover"`
|
||||
Size string `json:"size"`
|
||||
Fitting string `json:"fitting"`
|
||||
}
|
||||
type StatusTimesItem {
|
||||
Key int64 `json:"key"`
|
||||
Time string `json:"time"`
|
||||
}
|
|
@ -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"`
|
||||
|
|
Loading…
Reference in New Issue
Block a user