From dce321cdbb835c23cc38bee0ce3052396b9cd084 Mon Sep 17 00:00:00 2001 From: taxus Date: Fri, 17 Nov 2017 18:27:37 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=A2=E5=8D=95=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app_test.go | 65 +- config/mysql.go | 32 + controllers/controller.go | 7 + controllers/goods_controller.go | 1 + controllers/order_controller.go | 118 +++ controllers/user_controller.go | 66 -- model/ad_test.go | 21 +- model/cart.go | 6 +- model/cart_test.go | 55 +- model/goods_spec.go | 2 +- model/goods_test.go | 146 ++- model/order.go | 72 +- model/order_goods.go | 6 +- model/order_test.go | 23 +- model/price_calculator.go | 4 +- model/schema.go | 1 + proto/order/order.js | 1690 +++++++++++++++++++++++++++++++ proto/order/order.pb.go | 174 ++++ proto/order/order.proto | 50 + router/route.go | 10 +- web/pages/order-list/index.js | 36 +- web/pages/order-list/index.wxml | 42 +- web/pages/order-list/index.wxss | 61 +- web/pages/to-pay-order/index.js | 54 +- web/proto/order.js | 1690 +++++++++++++++++++++++++++++++ 25 files changed, 4155 insertions(+), 277 deletions(-) create mode 100644 controllers/order_controller.go create mode 100644 proto/order/order.js create mode 100644 proto/order/order.pb.go create mode 100644 proto/order/order.proto create mode 100644 web/proto/order.js diff --git a/app_test.go b/app_test.go index abb0198..c77ccf8 100644 --- a/app_test.go +++ b/app_test.go @@ -8,7 +8,8 @@ import ( // pcategory "fresh/proto/category" // pgoods "fresh/proto/goods" // pcart "fresh/proto/cart" - paddress "fresh/proto/address" + // paddress "fresh/proto/address" + porder "fresh/proto/order" "github.com/golang/protobuf/proto" "github.com/kataras/iris/httptest" @@ -174,26 +175,60 @@ var app = newApp() // log.Printf("[%s] %v", "TestCartRemoveSelected", data) // } -func TestLoadUserDefatultAddress(t *testing.T) { - e := httptest.New(t, app) +// func TestLoadUserDefatultAddress(t *testing.T) { +// e := httptest.New(t, app) +// +// body := e.GET("/user/address/default").WithHeader("token", "00a1c0366b96e5c3bfff8bd1d85fa557").Expect().Status(httptest.StatusOK).Body() +// bytes, _ := base64.StdEncoding.DecodeString(body.Raw()) +// data := &paddress.Address{} +// if err := proto.Unmarshal([]byte(bytes), data); err != nil { +// panic(err) +// } +// log.Printf("[TestLoadUserDefatultAddress] %v", data) +// } +// +// func TestLoadUserAllAddress(t *testing.T) { +// e := httptest.New(t, app) +// +// body := e.GET("/user/address/all").WithHeader("token", "00a1c0366b96e5c3bfff8bd1d85fa557").Expect().Status(httptest.StatusOK).Body() +// bytes, _ := base64.StdEncoding.DecodeString(body.Raw()) +// data := &paddress.AllAddress{} +// if err := proto.Unmarshal([]byte(bytes), data); err != nil { +// panic(err) +// } +// log.Printf("[TestLoadUserAllAddress] %v", data) +// } - body := e.GET("/user/address/default").WithHeader("token", "00a1c0366b96e5c3bfff8bd1d85fa557").Expect().Status(httptest.StatusOK).Body() - bytes, _ := base64.StdEncoding.DecodeString(body.Raw()) - data := &paddress.Address{} - if err := proto.Unmarshal([]byte(bytes), data); err != nil { - panic(err) - } - log.Printf("[TestLoadUserDefatultAddress] %v", data) -} +// func TestCreateOrder(t *testing.T) { +// e := httptest.New(t, app) +// +// param := &porder.CreateParam{AddressID: 814} +// src, err := proto.Marshal(param) +// if err != nil { +// panic(err) +// } +// +// dst := make([]byte, base64.StdEncoding.EncodedLen(len(src))) +// base64.StdEncoding.Encode(dst, src) +// body := e.POST("/order/create").WithBytes(dst).WithHeader("token", "00a1c0366b96e5c3bfff8bd1d85fa557").Expect().Status(httptest.StatusOK).Body() +// bytes, _ := base64.StdEncoding.DecodeString(body.Raw()) +// data := &porder.Order{} +// if err := proto.Unmarshal([]byte(bytes), data); err != nil { +// panic(err) +// } +// log.Printf("[TestCreateOrder] %v", data) +// } -func TestLoadUserAllAddress(t *testing.T) { +func TestLoadOrderList(t *testing.T) { e := httptest.New(t, app) - body := e.GET("/user/address/all").WithHeader("token", "00a1c0366b96e5c3bfff8bd1d85fa557").Expect().Status(httptest.StatusOK).Body() + body := e.GET("/order/list").WithHeader("token", "00a1c0366b96e5c3bfff8bd1d85fa557").Expect().Status(httptest.StatusOK).Body() bytes, _ := base64.StdEncoding.DecodeString(body.Raw()) - data := &paddress.AllAddress{} + data := &porder.List{} if err := proto.Unmarshal([]byte(bytes), data); err != nil { panic(err) } - log.Printf("[TestLoadUserAllAddress] %v", data) + for _, v := range data.GetOrders() { + log.Printf("[TestLoadOrderList] %v", v) + } } diff --git a/config/mysql.go b/config/mysql.go index b9ea093..4c13f5c 100644 --- a/config/mysql.go +++ b/config/mysql.go @@ -290,3 +290,35 @@ func (m *Mysql) ConvBool(bo sql.NullBool) sql.NullBool { } return bo } + +// SafeString 转换sql.NullString +func (m *Mysql) SafeString(str sql.NullString) string { + if !str.Valid { + return "" + } + return str.String +} + +// SafeInt64 转换sql.NullInt64 +func (m *Mysql) SafeInt64(i64 sql.NullInt64) int64 { + if !i64.Valid { + return 0 + } + return i64.Int64 +} + +// SafeFloat64 转换sql.NullFloat64 +func (m *Mysql) SafeFloat64(f64 sql.NullFloat64) float64 { + if !f64.Valid { + return 0.0 + } + return f64.Float64 +} + +// SafeBool 转换sql.NullBool +func (m *Mysql) SafeBool(bo sql.NullBool) bool { + if !bo.Valid { + return false + } + return bo.Bool +} diff --git a/controllers/controller.go b/controllers/controller.go index f006374..318bcca 100644 --- a/controllers/controller.go +++ b/controllers/controller.go @@ -63,6 +63,12 @@ var ( // CartController 购物车 CartController *cartController + + // AddressController 收货地址 + AddressController *addressController + + // OrderController 订单 + OrderController *orderController ) // InitControllers 初始化 @@ -71,4 +77,5 @@ func InitControllers() { UserController = &userController{} GoodsController = &goodsController{} CartController = &cartController{} + OrderController = &orderController{} } diff --git a/controllers/goods_controller.go b/controllers/goods_controller.go index 7245c29..70a131b 100644 --- a/controllers/goods_controller.go +++ b/controllers/goods_controller.go @@ -35,6 +35,7 @@ func (c *goodsController) Recommend(ctx iris.Context) { ctx.Text(err.Error()) return } + pgs := make([]*pgoods.Recommend, len(gs)) for i, g := range gs { pgs[i] = &pgoods.Recommend{ diff --git a/controllers/order_controller.go b/controllers/order_controller.go new file mode 100644 index 0000000..613591c --- /dev/null +++ b/controllers/order_controller.go @@ -0,0 +1,118 @@ +package controllers + +import ( + "fresh/model" + porder "fresh/proto/order" + "log" + + "github.com/kataras/iris" +) + +type orderController struct { + *controller +} + +// Create 创建订单 +func (c *orderController) Create(ctx iris.Context) { + params := &porder.CreateParam{} + if err := c.ReadProto(ctx, params); err != nil { + ctx.Text(err.Error()) + return + } + + u, err := model.LoadUserBy(ctx.GetHeader("token")) + if err != nil { + ctx.Text(err.Error()) + return + } + + cs, err := model.LoadSelectedCarts(u.ID) + if err != nil { + ctx.Text(err.Error()) + return + } + + ua, err := model.LoadShippingAddress(params.AddressID) + if err != nil { + ctx.Text(err.Error()) + return + } + + s, err := model.LoadShippingBy("sto_express") + if err != nil { + ctx.Text(err.Error()) + return + } + + o := model.NewOrder() + log.Println(o) + if err := o.Create(cs, ua, params.Remark, s, u.ID); err != nil { + ctx.Text(err.Error()) + log.Println(err) + return + } + + result := &porder.Order{ + ID: o.ID, + OrderSN: o.OrderSN, + TotalAmount: o.TotalAmount, + } + c.WriteProto(ctx, result) +} + +// List 订单列表 +func (c *orderController) List(ctx iris.Context) { + u, err := model.LoadUserBy(ctx.GetHeader("token")) + if err != nil { + ctx.Text(err.Error()) + return + } + + owgs, err := model.LoadOrderList(u.ID) + if err != nil { + ctx.Text(err.Error()) + return + } + + presult := &porder.List{} + powgs := make([]*porder.List_OrderWithGoods, len(owgs)) + for i, v := range owgs { + powg := &porder.List_OrderWithGoods{ + Order: &porder.List_OrderWithGoods_Order{ + ID: v.Order.ID, + OrderState: uint32(v.Order.OrderState), + OrderSN: v.Order.OrderSN, + ShippingState: uint32(v.Order.ShippingState), + PayState: uint32(v.Order.PayState), + GoodsPrice: v.Order.GoodsPrice, + ShippingPrice: v.Order.ShippingPrice, + OrderAmount: v.Order.OrderAmount, + TotalAmount: v.Order.TotalAmount, + AddTime: v.Order.AddTime, + UserNote: v.Order.UserNote, + AdminNote: v.Order.AdminNote, + }, + } + + pogs := make([]*porder.List_OrderWithGoods_OrderGoods, len(v.OrderGoodses)) + for j, v1 := range v.OrderGoodses { + pog := &porder.List_OrderWithGoods_OrderGoods{ + ID: v1.ID, + OrderID: v1.OrderID, + GoodsID: v1.GoodsID, + GoodsName: v1.GoodsName, + GoodsNum: uint32(v1.GoodsNum), + GoodsPrice: v1.GoodsPrice, + CostPrice: v1.CostPrice, + SpecKeyName: v1.SpecKeyName, + } + pogs[j] = pog + } + + powg.OrderGoodses = pogs + powgs[i] = powg + } + presult.Orders = powgs + + c.WriteProto(ctx, presult) +} diff --git a/controllers/user_controller.go b/controllers/user_controller.go index eb0a396..bfcc0c2 100755 --- a/controllers/user_controller.go +++ b/controllers/user_controller.go @@ -1,74 +1,8 @@ package controllers -import ( - "fresh/model" - puser "fresh/proto/user" - - "github.com/kataras/iris" -) - type userController struct { *controller } func (c *userController) Get() { } - -// AllAddress 用户所有地址 -func (c *userController) AllAddress(ctx iris.Context) { - u, err := model.LoadUserBy(ctx.GetHeader("token")) - if err != nil { - ctx.Text(err.Error()) - return - } - - as, err := model.LoadUserAddress(u.ID) - if err != nil { - ctx.Text(err.Error()) - return - } - c.WriteProto(ctx, c.convAddresses(as)) -} - -// DefatultAddress 默认收货地址 -func (c *userController) DefatultAddress(ctx iris.Context) { - u, err := model.LoadUserBy(ctx.GetHeader("token")) - if err != nil { - ctx.Text(err.Error()) - return - } - - a, err := model.LoadDefaultAddress(u.ID) - if err != nil { - ctx.Text(err.Error()) - return - } - - c.WriteProto(ctx, c.convAddress(a)) -} - -func (c *userController) convAddresses(as []*model.UserAddress) *puser.AllAddress { - plist := &puser.AllAddress{} - list := make([]*puser.Address, len(as)) - for i, v := range as { - list[i] = c.convAddress(v) - } - plist.Addresses = list - return plist -} - -func (c *userController) convAddress(a *model.UserAddress) *puser.Address { - return &puser.Address{ - ID: a.ID, - Consignee: a.Consignee, - Country: a.Country, - Province: a.Province, - City: a.City, - District: a.District, - Twon: a.Twon, - Address: a.Address, - Zipcode: a.Zipcode, - Mobile: a.Mobile, - IsDefault: a.IsDefault, - } -} diff --git a/model/ad_test.go b/model/ad_test.go index 86d7320..4f0fe16 100644 --- a/model/ad_test.go +++ b/model/ad_test.go @@ -1,15 +1,10 @@ package model -import ( - "log" - "testing" -) - -func TestLoadAd(t *testing.T) { - ads, err := LoadAds(9) - checkErr(err) - - for _, v := range *ads { - log.Printf("获取广告: %v \n", v) - } -} +// func TestLoadAd(t *testing.T) { +// ads, err := LoadAds(9) +// checkErr(err) +// +// for _, v := range *ads { +// log.Printf("获取广告: %v \n", v) +// } +// } diff --git a/model/cart.go b/model/cart.go index 62d3ff5..69909c6 100644 --- a/model/cart.go +++ b/model/cart.go @@ -96,7 +96,7 @@ func CountUserCarts(userID uint32) (int32, error) { } // LoadSelectedCarts 获取购物车中选中的商品 -func LoadSelectedCarts(userID uint32) (*Carts, error) { +func LoadSelectedCarts(userID uint32) (Carts, error) { var cs Carts query := ` SELECT c.*, g.cost_price FROM tp_cart c LEFT JOIN tp_goods g ON c.goods_id = g.goods_id @@ -114,10 +114,10 @@ func LoadSelectedCarts(userID uint32) (*Carts, error) { return nil } err := DataSource.QueryMore(query, f, userID) - if err != nil && err != sql.ErrNoRows { + if err != nil { err = fmt.Errorf("[LoadSelectedCarts] %v", err) } - return &cs, err + return cs, err } // Remove 删除购物车 diff --git a/model/cart_test.go b/model/cart_test.go index cb03442..e2afd4b 100644 --- a/model/cart_test.go +++ b/model/cart_test.go @@ -1,29 +1,24 @@ package model -import ( - "log" - "testing" -) - // import ( // "log" // "testing" // ) // -func TestAddCart(t *testing.T) { - u, err := LoadUserBy("00a1c0366b96e5c3bfff8bd1d85fa557") - checkErr(err) - - sg, err := LoadSpecGoods(46, 70) - checkErr(err) - - sid := "xxxxx" - c := NewCart() - err = c.Add(u, sg, 1, sid) - checkErr(err) - - log.Printf("[TestAddCart] 添加商品到购物车成功: %d", c.ID) -} +// func TestAddCart(t *testing.T) { +// u, err := LoadUserBy("00a1c0366b96e5c3bfff8bd1d85fa557") +// checkErr(err) +// +// sg, err := LoadSpecGoods(46, 70) +// checkErr(err) +// +// sid := "xxxxx" +// c := NewCart() +// err = c.Add(u, sg, 1, sid) +// checkErr(err) +// +// log.Printf("[TestAddCart] 添加商品到购物车成功: %d", c.ID) +// } // // func TestModifyCart(t *testing.T) { @@ -42,14 +37,14 @@ func TestAddCart(t *testing.T) { // log.Println("删除购物车成功") // -func TestLoadUserCarts(t *testing.T) { - u, err := LoadUserBy("00a1c0366b96e5c3bfff8bd1d85fa557") - checkErr(err) - - cs, err := LoadUserCarts(u.ID) - checkErr(err) - - for _, v := range cs { - log.Printf("[%s] %v", "TestLoadUserCarts", v) - } -} +// func TestLoadUserCarts(t *testing.T) { +// u, err := LoadUserBy("00a1c0366b96e5c3bfff8bd1d85fa557") +// checkErr(err) +// +// cs, err := LoadUserCarts(u.ID) +// checkErr(err) +// +// for _, v := range cs { +// log.Printf("[%s] %v", "TestLoadUserCarts", v) +// } +// } diff --git a/model/goods_spec.go b/model/goods_spec.go index ed505af..605443b 100644 --- a/model/goods_spec.go +++ b/model/goods_spec.go @@ -131,8 +131,8 @@ func (g *Goods) LoadSpec(ids []uint32) ([]*GoodsSpec, error) { gs = &GoodsSpec{SpecName: DataSource.ConvString(name).String} gs.SpecList = append(gs.SpecList, s) gss = append(gss, gs) + i++ } - i++ } return nil } diff --git a/model/goods_test.go b/model/goods_test.go index f1310c0..d546eca 100644 --- a/model/goods_test.go +++ b/model/goods_test.go @@ -1,78 +1,72 @@ package model -import ( - "fmt" - "log" - "testing" -) - -var gid uint32 - -func TestLoadNewGoods(t *testing.T) { - gs, err := LoadNewGoods() - checkErr(err) - - for _, g := range gs { - log.Println(g) - gid = g.ID - } -} - -func TestLoadGoodsBy(t *testing.T) { - g, err := LoadGoodsBy(gid) - checkErr(err) - - log.Printf("[TestLoadGoodsBy]%v", g) -} - -func TestGoodsClick(t *testing.T) { - g, err := LoadGoodsBy(gid) - checkErr(err) - - checkErr(g.Click()) - - click := g.ClickCount - g, err = LoadGoodsBy(gid) - checkErr(err) - - if click+1 != g.ClickCount { - panic(fmt.Errorf("测试商品点击错误,原值=%d, 期望=%d, 实际=%d", click, click+1, g.ClickCount)) - } - log.Printf("测试商品点击,原值=%d, 期望=%d", click, g.ClickCount) -} - -var items []uint32 - -func TestLoadGoodsSpecPrice(t *testing.T) { - g := &Goods{ID: gid} - gss, err := g.LoadSpecPrice() - checkErr(err) - for _, gs := range gss { - log.Println(*gs) - } - items = gss.GetSpecItem() - log.Println(items) -} - -func TestLoadGoodsSpec(t *testing.T) { - g := &Goods{ID: gid} - gss, err := g.LoadSpec(items) - checkErr(err) - - for _, gs := range gss { - log.Printf("%v", gs.SpecName) - for _, v := range gs.SpecList { - log.Printf("%v", v) - } - } -} - -func TestLoadComments(t *testing.T) { - g := &Goods{ID: gid} - cs, err := g.LoadComments() - checkErr(err) - - for _, c := range cs { - log.Printf("%v", c) - } -} +// var gid uint32 +// +// func TestLoadNewGoods(t *testing.T) { +// gs, err := LoadNewGoods() +// checkErr(err) +// +// for _, g := range gs { +// log.Println(g) +// gid = g.ID +// } +// } +// +// func TestLoadGoodsBy(t *testing.T) { +// g, err := LoadGoodsBy(gid) +// checkErr(err) +// +// log.Printf("[TestLoadGoodsBy]%v", g) +// } +// +// func TestGoodsClick(t *testing.T) { +// g, err := LoadGoodsBy(gid) +// checkErr(err) +// +// checkErr(g.Click()) +// +// click := g.ClickCount +// g, err = LoadGoodsBy(gid) +// checkErr(err) +// +// if click+1 != g.ClickCount { +// panic(fmt.Errorf("测试商品点击错误,原值=%d, 期望=%d, 实际=%d", click, click+1, g.ClickCount)) +// } +// log.Printf("测试商品点击,原值=%d, 期望=%d", click, g.ClickCount) +// } +// +// var items []uint32 +// +// func TestLoadGoodsSpecPrice(t *testing.T) { +// g := &Goods{ID: gid} +// gss, err := g.LoadSpecPrice() +// checkErr(err) +// for _, gs := range gss { +// log.Println(*gs) +// } +// items = gss.GetSpecItem() +// log.Println(items) +// } +// +// func TestLoadGoodsSpec(t *testing.T) { +// g := &Goods{ID: gid} +// gss, err := g.LoadSpec(items) +// checkErr(err) +// +// for _, gs := range gss { +// log.Printf("%v", gs.SpecName) +// for _, v := range gs.SpecList { +// log.Printf("%v", v) +// } +// } +// } +// +// func TestLoadComments(t *testing.T) { +// g := &Goods{ID: gid} +// cs, err := g.LoadComments() +// checkErr(err) +// +// for _, c := range cs { +// log.Printf("%v", c) +// } +// } diff --git a/model/order.go b/model/order.go index 3752d37..edd3f56 100644 --- a/model/order.go +++ b/model/order.go @@ -70,7 +70,7 @@ func NewOrder() *Order { } // Create 创建订单 -func (o *Order) Create(cs *Carts, ua *UserAddress, s *Shipping, userID uint32) error { +func (o *Order) Create(cs Carts, ua *UserAddress, note string, s *Shipping, userID uint32) error { o.UserID = userID o.Consignee = ua.Consignee o.Country = ua.Country @@ -84,6 +84,7 @@ func (o *Order) Create(cs *Carts, ua *UserAddress, s *Shipping, userID uint32) e o.Email = ua.Email o.ShippingCode = s.ShippingCode o.ShippingName = s.ShippingName + o.UserNote = note pc := NewPriceCalculator(cs) o.GoodsPrice = pc.GetGoodsPrice() @@ -92,7 +93,7 @@ func (o *Order) Create(cs *Carts, ua *UserAddress, s *Shipping, userID uint32) e return o.saveRelative(cs) } -func (o *Order) saveRelative(cs *Carts) error { +func (o *Order) saveRelative(cs Carts) error { return DataSource.TxExec(func(tx *sql.Tx) error { if err := o.insert(tx); err != nil { return err @@ -121,6 +122,72 @@ func (o *Order) insert(tx *sql.Tx) error { return nil } +// OrderWithGoods 订单和对应的订单商品 +type OrderWithGoods struct { + Order *Order + OrderGoodses []*OrderGoods +} + +// LoadOrderList 获取用户所有订单 +func LoadOrderList(userID uint32) ([]*OrderWithGoods, error) { + var orderID, orderStatus, shippingStatus, payStatus, addTime, recID, goodsID, goodsNum sql.NullInt64 + var orderGoodsPrice, goodsPrice, shippingPrice, orderAmount, totalAmount sql.NullFloat64 + var orderSN, userNote, adminNote, goodsName, specKeyName sql.NullString + var err error + query := ` + SELECT o.order_id, o.order_status, o.order_sn, o.shipping_status, o.pay_status, o.goods_price, o.shipping_price, o.order_amount, + o.total_amount, o.add_time, o.user_note, o.admin_note,rec_id,goods_id,goods_name,goods_num, og.goods_price,spec_key_name + FROM tp_order o LEFT JOIN tp_order_goods og ON o.order_id = og.order_id + WHERE o.deleted = 0 AND o.user_id = ? + ` + owgs, i, m := []*OrderWithGoods{}, 0, map[uint32]int{} + f := func(rs *sql.Rows) error { + for rs.Next() { + if err = rs.Scan(&orderID, &orderStatus, &orderSN, &shippingStatus, &payStatus, &orderGoodsPrice, &shippingPrice, &orderAmount, &totalAmount, &addTime, &userNote, &adminNote, &recID, &goodsID, &goodsName, &goodsNum, &goodsPrice, &specKeyName); err != nil { + return err + } + var owg *OrderWithGoods + og := &OrderGoods{ + ID: uint32(DataSource.SafeInt64(recID)), + OrderID: uint32(DataSource.SafeInt64(orderID)), + GoodsID: uint32(DataSource.SafeInt64(goodsID)), + GoodsName: DataSource.SafeString(goodsName), + GoodsNum: uint16(DataSource.SafeInt64(goodsNum)), + GoodsPrice: float32(DataSource.SafeFloat64(goodsPrice)), + SpecKeyName: DataSource.SafeString(specKeyName), + } + if v, ok := m[og.OrderID]; ok { + owg = owgs[v] + owg.OrderGoodses = append(owg.OrderGoodses, og) + } else { + m[og.OrderID] = i + owg = &OrderWithGoods{ + Order: &Order{ + ID: uint32(DataSource.SafeInt64(orderID)), + OrderState: uint(DataSource.SafeInt64(orderStatus)), + OrderSN: DataSource.SafeString(orderSN), + ShippingState: uint(DataSource.SafeInt64(shippingStatus)), + PayState: uint(DataSource.SafeInt64(payStatus)), + GoodsPrice: float32(DataSource.SafeFloat64(goodsPrice)), + ShippingPrice: float32(DataSource.SafeFloat64(shippingPrice)), + OrderAmount: float32(DataSource.SafeFloat64(orderAmount)), + TotalAmount: float32(DataSource.SafeFloat64(totalAmount)), + AddTime: DataSource.SafeInt64(addTime), + UserNote: DataSource.SafeString(userNote), + AdminNote: DataSource.SafeString(adminNote), + }, + } + owg.OrderGoodses = append(owg.OrderGoodses, og) + owgs = append(owgs, owg) + i++ + } + } + return nil + } + err = DataSource.QueryMorePrepare(query, f, userID) + return owgs, err +} + func (o *Order) Values() []interface{} { return []interface{}{ &o.OrderSN, @@ -147,5 +214,6 @@ func (o *Order) Values() []interface{} { &o.TotalAmount, &o.AddTime, &o.Deleted, + &o.UserNote, } } diff --git a/model/order_goods.go b/model/order_goods.go index 2a22ded..4a17c12 100644 --- a/model/order_goods.go +++ b/model/order_goods.go @@ -33,9 +33,9 @@ type OrderGoods struct { type OrderGoodses []*OrderGoods // NewOrderGoodses 订单商品 -func NewOrderGoodses(cs *Carts) *OrderGoodses { - goodses := make(OrderGoodses, len(*cs)) - for i, v := range *cs { +func NewOrderGoodses(cs Carts) *OrderGoodses { + goodses := make(OrderGoodses, len(cs)) + for i, v := range cs { goods := &OrderGoods{ GoodsID: v.GoodsID, GoodsName: v.GoodsName, diff --git a/model/order_test.go b/model/order_test.go index 1b87f6d..3a1cad6 100644 --- a/model/order_test.go +++ b/model/order_test.go @@ -1,12 +1,20 @@ package model +import ( + "log" + "testing" +) + // func TestCreateOrder(t *testing.T) { // var userID uint32 = 1 // cs, err := LoadSelectedCarts(userID) // checkErr(err) -// if len(*cs) == 0 { +// if len(cs) == 0 { // panic("您购物车中没有选中商品") // } +// for _, v := range cs { +// log.Printf("TestCreateOrder %v", v) +// } // // ua, err := LoadShippingAddress(814) // checkErr(err) @@ -19,3 +27,16 @@ package model // // log.Printf("下订单成功, id=%d, pay_state = %d \n", o.ID, o.PayState) // } + +func TestLoadOrderList(t *testing.T) { + var userID uint32 = 1 + owgs, err := LoadOrderList(userID) + checkErr(err) + for _, v := range owgs { + log.Printf("[TestLoadOrderList] %v", v.Order) + for _, v1 := range v.OrderGoodses { + log.Printf("%v", v1) + } + } + +} diff --git a/model/price_calculator.go b/model/price_calculator.go index 8fdc055..4e98793 100644 --- a/model/price_calculator.go +++ b/model/price_calculator.go @@ -9,9 +9,9 @@ type PriceCalculator struct { } // NewPriceCalculator 新建价格计算器 -func NewPriceCalculator(cs *Carts) *PriceCalculator { +func NewPriceCalculator(cs Carts) *PriceCalculator { pc := &PriceCalculator{} - for _, c := range *cs { + for _, c := range cs { pc.goodsPrice = pc.goodsPrice + c.GoodsPrice*float32(c.GoodsNum) } pc.amount = pc.goodsPrice diff --git a/model/schema.go b/model/schema.go index c5050c3..927a079 100644 --- a/model/schema.go +++ b/model/schema.go @@ -47,6 +47,7 @@ var OrderCols = []string{ "total_amount", "add_time", "deleted", + "user_note", } // OrderActionCols 订单操作记录 diff --git a/proto/order/order.js b/proto/order/order.js new file mode 100644 index 0000000..4d495cd --- /dev/null +++ b/proto/order/order.js @@ -0,0 +1,1690 @@ +/*eslint-disable block-scoped-var, no-redeclare, no-control-regex, no-prototype-builtins*/ +"use strict"; + +var $protobuf = require("protobufjs/minimal"); + +// Common aliases +var $Reader = $protobuf.Reader, $Writer = $protobuf.Writer, $util = $protobuf.util; + +// Exported root namespace +var $root = $protobuf.roots["default"] || ($protobuf.roots["default"] = {}); + +$root.order = (function() { + + /** + * Namespace order. + * @exports order + * @namespace + */ + var order = {}; + + order.CreateParam = (function() { + + /** + * Properties of a CreateParam. + * @memberof order + * @interface ICreateParam + * @property {number} [addressID] CreateParam addressID + * @property {string} [remark] CreateParam remark + */ + + /** + * Constructs a new CreateParam. + * @memberof order + * @classdesc Represents a CreateParam. + * @constructor + * @param {order.ICreateParam=} [properties] Properties to set + */ + function CreateParam(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * CreateParam addressID. + * @member {number}addressID + * @memberof order.CreateParam + * @instance + */ + CreateParam.prototype.addressID = 0; + + /** + * CreateParam remark. + * @member {string}remark + * @memberof order.CreateParam + * @instance + */ + CreateParam.prototype.remark = ""; + + /** + * Creates a new CreateParam instance using the specified properties. + * @function create + * @memberof order.CreateParam + * @static + * @param {order.ICreateParam=} [properties] Properties to set + * @returns {order.CreateParam} CreateParam instance + */ + CreateParam.create = function create(properties) { + return new CreateParam(properties); + }; + + /** + * Encodes the specified CreateParam message. Does not implicitly {@link order.CreateParam.verify|verify} messages. + * @function encode + * @memberof order.CreateParam + * @static + * @param {order.ICreateParam} message CreateParam message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CreateParam.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.addressID != null && message.hasOwnProperty("addressID")) + writer.uint32(/* id 1, wireType 0 =*/8).uint32(message.addressID); + if (message.remark != null && message.hasOwnProperty("remark")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.remark); + return writer; + }; + + /** + * Encodes the specified CreateParam message, length delimited. Does not implicitly {@link order.CreateParam.verify|verify} messages. + * @function encodeDelimited + * @memberof order.CreateParam + * @static + * @param {order.ICreateParam} message CreateParam message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CreateParam.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a CreateParam message from the specified reader or buffer. + * @function decode + * @memberof order.CreateParam + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {order.CreateParam} CreateParam + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CreateParam.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.order.CreateParam(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.addressID = reader.uint32(); + break; + case 2: + message.remark = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a CreateParam message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof order.CreateParam + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {order.CreateParam} CreateParam + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CreateParam.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a CreateParam message. + * @function verify + * @memberof order.CreateParam + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + CreateParam.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.addressID != null && message.hasOwnProperty("addressID")) + if (!$util.isInteger(message.addressID)) + return "addressID: integer expected"; + if (message.remark != null && message.hasOwnProperty("remark")) + if (!$util.isString(message.remark)) + return "remark: string expected"; + return null; + }; + + /** + * Creates a CreateParam message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof order.CreateParam + * @static + * @param {Object.} object Plain object + * @returns {order.CreateParam} CreateParam + */ + CreateParam.fromObject = function fromObject(object) { + if (object instanceof $root.order.CreateParam) + return object; + var message = new $root.order.CreateParam(); + if (object.addressID != null) + message.addressID = object.addressID >>> 0; + if (object.remark != null) + message.remark = String(object.remark); + return message; + }; + + /** + * Creates a plain object from a CreateParam message. Also converts values to other types if specified. + * @function toObject + * @memberof order.CreateParam + * @static + * @param {order.CreateParam} message CreateParam + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + CreateParam.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.addressID = 0; + object.remark = ""; + } + if (message.addressID != null && message.hasOwnProperty("addressID")) + object.addressID = message.addressID; + if (message.remark != null && message.hasOwnProperty("remark")) + object.remark = message.remark; + return object; + }; + + /** + * Converts this CreateParam to JSON. + * @function toJSON + * @memberof order.CreateParam + * @instance + * @returns {Object.} JSON object + */ + CreateParam.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return CreateParam; + })(); + + order.Order = (function() { + + /** + * Properties of an Order. + * @memberof order + * @interface IOrder + * @property {number} [ID] Order ID + * @property {string} [orderSN] Order orderSN + * @property {number} [totalAmount] Order totalAmount + */ + + /** + * Constructs a new Order. + * @memberof order + * @classdesc Represents an Order. + * @constructor + * @param {order.IOrder=} [properties] Properties to set + */ + function Order(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Order ID. + * @member {number}ID + * @memberof order.Order + * @instance + */ + Order.prototype.ID = 0; + + /** + * Order orderSN. + * @member {string}orderSN + * @memberof order.Order + * @instance + */ + Order.prototype.orderSN = ""; + + /** + * Order totalAmount. + * @member {number}totalAmount + * @memberof order.Order + * @instance + */ + Order.prototype.totalAmount = 0; + + /** + * Creates a new Order instance using the specified properties. + * @function create + * @memberof order.Order + * @static + * @param {order.IOrder=} [properties] Properties to set + * @returns {order.Order} Order instance + */ + Order.create = function create(properties) { + return new Order(properties); + }; + + /** + * Encodes the specified Order message. Does not implicitly {@link order.Order.verify|verify} messages. + * @function encode + * @memberof order.Order + * @static + * @param {order.IOrder} message Order message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Order.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.ID != null && message.hasOwnProperty("ID")) + writer.uint32(/* id 1, wireType 0 =*/8).uint32(message.ID); + if (message.orderSN != null && message.hasOwnProperty("orderSN")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.orderSN); + if (message.totalAmount != null && message.hasOwnProperty("totalAmount")) + writer.uint32(/* id 3, wireType 5 =*/29).float(message.totalAmount); + return writer; + }; + + /** + * Encodes the specified Order message, length delimited. Does not implicitly {@link order.Order.verify|verify} messages. + * @function encodeDelimited + * @memberof order.Order + * @static + * @param {order.IOrder} message Order message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Order.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an Order message from the specified reader or buffer. + * @function decode + * @memberof order.Order + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {order.Order} Order + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Order.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.order.Order(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.ID = reader.uint32(); + break; + case 2: + message.orderSN = reader.string(); + break; + case 3: + message.totalAmount = reader.float(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an Order message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof order.Order + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {order.Order} Order + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Order.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an Order message. + * @function verify + * @memberof order.Order + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Order.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.ID != null && message.hasOwnProperty("ID")) + if (!$util.isInteger(message.ID)) + return "ID: integer expected"; + if (message.orderSN != null && message.hasOwnProperty("orderSN")) + if (!$util.isString(message.orderSN)) + return "orderSN: string expected"; + if (message.totalAmount != null && message.hasOwnProperty("totalAmount")) + if (typeof message.totalAmount !== "number") + return "totalAmount: number expected"; + return null; + }; + + /** + * Creates an Order message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof order.Order + * @static + * @param {Object.} object Plain object + * @returns {order.Order} Order + */ + Order.fromObject = function fromObject(object) { + if (object instanceof $root.order.Order) + return object; + var message = new $root.order.Order(); + if (object.ID != null) + message.ID = object.ID >>> 0; + if (object.orderSN != null) + message.orderSN = String(object.orderSN); + if (object.totalAmount != null) + message.totalAmount = Number(object.totalAmount); + return message; + }; + + /** + * Creates a plain object from an Order message. Also converts values to other types if specified. + * @function toObject + * @memberof order.Order + * @static + * @param {order.Order} message Order + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Order.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.ID = 0; + object.orderSN = ""; + object.totalAmount = 0; + } + if (message.ID != null && message.hasOwnProperty("ID")) + object.ID = message.ID; + if (message.orderSN != null && message.hasOwnProperty("orderSN")) + object.orderSN = message.orderSN; + if (message.totalAmount != null && message.hasOwnProperty("totalAmount")) + object.totalAmount = options.json && !isFinite(message.totalAmount) ? String(message.totalAmount) : message.totalAmount; + return object; + }; + + /** + * Converts this Order to JSON. + * @function toJSON + * @memberof order.Order + * @instance + * @returns {Object.} JSON object + */ + Order.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return Order; + })(); + + order.List = (function() { + + /** + * Properties of a List. + * @memberof order + * @interface IList + * @property {Array.} [orders] List orders + */ + + /** + * Constructs a new List. + * @memberof order + * @classdesc Represents a List. + * @constructor + * @param {order.IList=} [properties] Properties to set + */ + function List(properties) { + this.orders = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * List orders. + * @member {Array.}orders + * @memberof order.List + * @instance + */ + List.prototype.orders = $util.emptyArray; + + /** + * Creates a new List instance using the specified properties. + * @function create + * @memberof order.List + * @static + * @param {order.IList=} [properties] Properties to set + * @returns {order.List} List instance + */ + List.create = function create(properties) { + return new List(properties); + }; + + /** + * Encodes the specified List message. Does not implicitly {@link order.List.verify|verify} messages. + * @function encode + * @memberof order.List + * @static + * @param {order.IList} message List message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + List.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.orders != null && message.orders.length) + for (var i = 0; i < message.orders.length; ++i) + $root.order.List.OrderWithGoods.encode(message.orders[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified List message, length delimited. Does not implicitly {@link order.List.verify|verify} messages. + * @function encodeDelimited + * @memberof order.List + * @static + * @param {order.IList} message List message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + List.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a List message from the specified reader or buffer. + * @function decode + * @memberof order.List + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {order.List} List + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + List.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.order.List(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (!(message.orders && message.orders.length)) + message.orders = []; + message.orders.push($root.order.List.OrderWithGoods.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a List message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof order.List + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {order.List} List + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + List.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a List message. + * @function verify + * @memberof order.List + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + List.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.orders != null && message.hasOwnProperty("orders")) { + if (!Array.isArray(message.orders)) + return "orders: array expected"; + for (var i = 0; i < message.orders.length; ++i) { + var error = $root.order.List.OrderWithGoods.verify(message.orders[i]); + if (error) + return "orders." + error; + } + } + return null; + }; + + /** + * Creates a List message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof order.List + * @static + * @param {Object.} object Plain object + * @returns {order.List} List + */ + List.fromObject = function fromObject(object) { + if (object instanceof $root.order.List) + return object; + var message = new $root.order.List(); + if (object.orders) { + if (!Array.isArray(object.orders)) + throw TypeError(".order.List.orders: array expected"); + message.orders = []; + for (var i = 0; i < object.orders.length; ++i) { + if (typeof object.orders[i] !== "object") + throw TypeError(".order.List.orders: object expected"); + message.orders[i] = $root.order.List.OrderWithGoods.fromObject(object.orders[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a List message. Also converts values to other types if specified. + * @function toObject + * @memberof order.List + * @static + * @param {order.List} message List + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + List.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.orders = []; + if (message.orders && message.orders.length) { + object.orders = []; + for (var j = 0; j < message.orders.length; ++j) + object.orders[j] = $root.order.List.OrderWithGoods.toObject(message.orders[j], options); + } + return object; + }; + + /** + * Converts this List to JSON. + * @function toJSON + * @memberof order.List + * @instance + * @returns {Object.} JSON object + */ + List.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + List.OrderWithGoods = (function() { + + /** + * Properties of an OrderWithGoods. + * @memberof order.List + * @interface IOrderWithGoods + * @property {order.List.OrderWithGoods.IOrder} [order] OrderWithGoods order + * @property {Array.} [orderGoodses] OrderWithGoods orderGoodses + */ + + /** + * Constructs a new OrderWithGoods. + * @memberof order.List + * @classdesc Represents an OrderWithGoods. + * @constructor + * @param {order.List.IOrderWithGoods=} [properties] Properties to set + */ + function OrderWithGoods(properties) { + this.orderGoodses = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * OrderWithGoods order. + * @member {(order.List.OrderWithGoods.IOrder|null|undefined)}order + * @memberof order.List.OrderWithGoods + * @instance + */ + OrderWithGoods.prototype.order = null; + + /** + * OrderWithGoods orderGoodses. + * @member {Array.}orderGoodses + * @memberof order.List.OrderWithGoods + * @instance + */ + OrderWithGoods.prototype.orderGoodses = $util.emptyArray; + + /** + * Creates a new OrderWithGoods instance using the specified properties. + * @function create + * @memberof order.List.OrderWithGoods + * @static + * @param {order.List.IOrderWithGoods=} [properties] Properties to set + * @returns {order.List.OrderWithGoods} OrderWithGoods instance + */ + OrderWithGoods.create = function create(properties) { + return new OrderWithGoods(properties); + }; + + /** + * Encodes the specified OrderWithGoods message. Does not implicitly {@link order.List.OrderWithGoods.verify|verify} messages. + * @function encode + * @memberof order.List.OrderWithGoods + * @static + * @param {order.List.IOrderWithGoods} message OrderWithGoods message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + OrderWithGoods.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.order != null && message.hasOwnProperty("order")) + $root.order.List.OrderWithGoods.Order.encode(message.order, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.orderGoodses != null && message.orderGoodses.length) + for (var i = 0; i < message.orderGoodses.length; ++i) + $root.order.List.OrderWithGoods.OrderGoods.encode(message.orderGoodses[i], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified OrderWithGoods message, length delimited. Does not implicitly {@link order.List.OrderWithGoods.verify|verify} messages. + * @function encodeDelimited + * @memberof order.List.OrderWithGoods + * @static + * @param {order.List.IOrderWithGoods} message OrderWithGoods message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + OrderWithGoods.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an OrderWithGoods message from the specified reader or buffer. + * @function decode + * @memberof order.List.OrderWithGoods + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {order.List.OrderWithGoods} OrderWithGoods + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + OrderWithGoods.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.order.List.OrderWithGoods(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.order = $root.order.List.OrderWithGoods.Order.decode(reader, reader.uint32()); + break; + case 2: + if (!(message.orderGoodses && message.orderGoodses.length)) + message.orderGoodses = []; + message.orderGoodses.push($root.order.List.OrderWithGoods.OrderGoods.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an OrderWithGoods message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof order.List.OrderWithGoods + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {order.List.OrderWithGoods} OrderWithGoods + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + OrderWithGoods.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an OrderWithGoods message. + * @function verify + * @memberof order.List.OrderWithGoods + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + OrderWithGoods.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.order != null && message.hasOwnProperty("order")) { + var error = $root.order.List.OrderWithGoods.Order.verify(message.order); + if (error) + return "order." + error; + } + if (message.orderGoodses != null && message.hasOwnProperty("orderGoodses")) { + if (!Array.isArray(message.orderGoodses)) + return "orderGoodses: array expected"; + for (var i = 0; i < message.orderGoodses.length; ++i) { + error = $root.order.List.OrderWithGoods.OrderGoods.verify(message.orderGoodses[i]); + if (error) + return "orderGoodses." + error; + } + } + return null; + }; + + /** + * Creates an OrderWithGoods message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof order.List.OrderWithGoods + * @static + * @param {Object.} object Plain object + * @returns {order.List.OrderWithGoods} OrderWithGoods + */ + OrderWithGoods.fromObject = function fromObject(object) { + if (object instanceof $root.order.List.OrderWithGoods) + return object; + var message = new $root.order.List.OrderWithGoods(); + if (object.order != null) { + if (typeof object.order !== "object") + throw TypeError(".order.List.OrderWithGoods.order: object expected"); + message.order = $root.order.List.OrderWithGoods.Order.fromObject(object.order); + } + if (object.orderGoodses) { + if (!Array.isArray(object.orderGoodses)) + throw TypeError(".order.List.OrderWithGoods.orderGoodses: array expected"); + message.orderGoodses = []; + for (var i = 0; i < object.orderGoodses.length; ++i) { + if (typeof object.orderGoodses[i] !== "object") + throw TypeError(".order.List.OrderWithGoods.orderGoodses: object expected"); + message.orderGoodses[i] = $root.order.List.OrderWithGoods.OrderGoods.fromObject(object.orderGoodses[i]); + } + } + return message; + }; + + /** + * Creates a plain object from an OrderWithGoods message. Also converts values to other types if specified. + * @function toObject + * @memberof order.List.OrderWithGoods + * @static + * @param {order.List.OrderWithGoods} message OrderWithGoods + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + OrderWithGoods.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.orderGoodses = []; + if (options.defaults) + object.order = null; + if (message.order != null && message.hasOwnProperty("order")) + object.order = $root.order.List.OrderWithGoods.Order.toObject(message.order, options); + if (message.orderGoodses && message.orderGoodses.length) { + object.orderGoodses = []; + for (var j = 0; j < message.orderGoodses.length; ++j) + object.orderGoodses[j] = $root.order.List.OrderWithGoods.OrderGoods.toObject(message.orderGoodses[j], options); + } + return object; + }; + + /** + * Converts this OrderWithGoods to JSON. + * @function toJSON + * @memberof order.List.OrderWithGoods + * @instance + * @returns {Object.} JSON object + */ + OrderWithGoods.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + OrderWithGoods.Order = (function() { + + /** + * Properties of an Order. + * @memberof order.List.OrderWithGoods + * @interface IOrder + * @property {number} [ID] Order ID + * @property {number} [orderState] Order orderState + * @property {string} [orderSN] Order orderSN + * @property {number} [shippingState] Order shippingState + * @property {number} [payState] Order payState + * @property {number} [goodsPrice] Order goodsPrice + * @property {number} [shippingPrice] Order shippingPrice + * @property {number} [orderAmount] Order orderAmount + * @property {number} [totalAmount] Order totalAmount + * @property {number|Long} [addTime] Order addTime + * @property {string} [userNote] Order userNote + * @property {string} [adminNote] Order adminNote + */ + + /** + * Constructs a new Order. + * @memberof order.List.OrderWithGoods + * @classdesc Represents an Order. + * @constructor + * @param {order.List.OrderWithGoods.IOrder=} [properties] Properties to set + */ + function Order(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Order ID. + * @member {number}ID + * @memberof order.List.OrderWithGoods.Order + * @instance + */ + Order.prototype.ID = 0; + + /** + * Order orderState. + * @member {number}orderState + * @memberof order.List.OrderWithGoods.Order + * @instance + */ + Order.prototype.orderState = 0; + + /** + * Order orderSN. + * @member {string}orderSN + * @memberof order.List.OrderWithGoods.Order + * @instance + */ + Order.prototype.orderSN = ""; + + /** + * Order shippingState. + * @member {number}shippingState + * @memberof order.List.OrderWithGoods.Order + * @instance + */ + Order.prototype.shippingState = 0; + + /** + * Order payState. + * @member {number}payState + * @memberof order.List.OrderWithGoods.Order + * @instance + */ + Order.prototype.payState = 0; + + /** + * Order goodsPrice. + * @member {number}goodsPrice + * @memberof order.List.OrderWithGoods.Order + * @instance + */ + Order.prototype.goodsPrice = 0; + + /** + * Order shippingPrice. + * @member {number}shippingPrice + * @memberof order.List.OrderWithGoods.Order + * @instance + */ + Order.prototype.shippingPrice = 0; + + /** + * Order orderAmount. + * @member {number}orderAmount + * @memberof order.List.OrderWithGoods.Order + * @instance + */ + Order.prototype.orderAmount = 0; + + /** + * Order totalAmount. + * @member {number}totalAmount + * @memberof order.List.OrderWithGoods.Order + * @instance + */ + Order.prototype.totalAmount = 0; + + /** + * Order addTime. + * @member {number|Long}addTime + * @memberof order.List.OrderWithGoods.Order + * @instance + */ + Order.prototype.addTime = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * Order userNote. + * @member {string}userNote + * @memberof order.List.OrderWithGoods.Order + * @instance + */ + Order.prototype.userNote = ""; + + /** + * Order adminNote. + * @member {string}adminNote + * @memberof order.List.OrderWithGoods.Order + * @instance + */ + Order.prototype.adminNote = ""; + + /** + * Creates a new Order instance using the specified properties. + * @function create + * @memberof order.List.OrderWithGoods.Order + * @static + * @param {order.List.OrderWithGoods.IOrder=} [properties] Properties to set + * @returns {order.List.OrderWithGoods.Order} Order instance + */ + Order.create = function create(properties) { + return new Order(properties); + }; + + /** + * Encodes the specified Order message. Does not implicitly {@link order.List.OrderWithGoods.Order.verify|verify} messages. + * @function encode + * @memberof order.List.OrderWithGoods.Order + * @static + * @param {order.List.OrderWithGoods.IOrder} message Order message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Order.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.ID != null && message.hasOwnProperty("ID")) + writer.uint32(/* id 1, wireType 0 =*/8).uint32(message.ID); + if (message.orderState != null && message.hasOwnProperty("orderState")) + writer.uint32(/* id 2, wireType 0 =*/16).uint32(message.orderState); + if (message.orderSN != null && message.hasOwnProperty("orderSN")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.orderSN); + if (message.shippingState != null && message.hasOwnProperty("shippingState")) + writer.uint32(/* id 4, wireType 0 =*/32).uint32(message.shippingState); + if (message.payState != null && message.hasOwnProperty("payState")) + writer.uint32(/* id 5, wireType 0 =*/40).uint32(message.payState); + if (message.goodsPrice != null && message.hasOwnProperty("goodsPrice")) + writer.uint32(/* id 6, wireType 5 =*/53).float(message.goodsPrice); + if (message.shippingPrice != null && message.hasOwnProperty("shippingPrice")) + writer.uint32(/* id 7, wireType 5 =*/61).float(message.shippingPrice); + if (message.orderAmount != null && message.hasOwnProperty("orderAmount")) + writer.uint32(/* id 8, wireType 5 =*/69).float(message.orderAmount); + if (message.totalAmount != null && message.hasOwnProperty("totalAmount")) + writer.uint32(/* id 9, wireType 5 =*/77).float(message.totalAmount); + if (message.addTime != null && message.hasOwnProperty("addTime")) + writer.uint32(/* id 10, wireType 0 =*/80).int64(message.addTime); + if (message.userNote != null && message.hasOwnProperty("userNote")) + writer.uint32(/* id 11, wireType 2 =*/90).string(message.userNote); + if (message.adminNote != null && message.hasOwnProperty("adminNote")) + writer.uint32(/* id 12, wireType 2 =*/98).string(message.adminNote); + return writer; + }; + + /** + * Encodes the specified Order message, length delimited. Does not implicitly {@link order.List.OrderWithGoods.Order.verify|verify} messages. + * @function encodeDelimited + * @memberof order.List.OrderWithGoods.Order + * @static + * @param {order.List.OrderWithGoods.IOrder} message Order message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Order.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an Order message from the specified reader or buffer. + * @function decode + * @memberof order.List.OrderWithGoods.Order + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {order.List.OrderWithGoods.Order} Order + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Order.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.order.List.OrderWithGoods.Order(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.ID = reader.uint32(); + break; + case 2: + message.orderState = reader.uint32(); + break; + case 3: + message.orderSN = reader.string(); + break; + case 4: + message.shippingState = reader.uint32(); + break; + case 5: + message.payState = reader.uint32(); + break; + case 6: + message.goodsPrice = reader.float(); + break; + case 7: + message.shippingPrice = reader.float(); + break; + case 8: + message.orderAmount = reader.float(); + break; + case 9: + message.totalAmount = reader.float(); + break; + case 10: + message.addTime = reader.int64(); + break; + case 11: + message.userNote = reader.string(); + break; + case 12: + message.adminNote = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an Order message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof order.List.OrderWithGoods.Order + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {order.List.OrderWithGoods.Order} Order + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Order.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an Order message. + * @function verify + * @memberof order.List.OrderWithGoods.Order + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Order.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.ID != null && message.hasOwnProperty("ID")) + if (!$util.isInteger(message.ID)) + return "ID: integer expected"; + if (message.orderState != null && message.hasOwnProperty("orderState")) + if (!$util.isInteger(message.orderState)) + return "orderState: integer expected"; + if (message.orderSN != null && message.hasOwnProperty("orderSN")) + if (!$util.isString(message.orderSN)) + return "orderSN: string expected"; + if (message.shippingState != null && message.hasOwnProperty("shippingState")) + if (!$util.isInteger(message.shippingState)) + return "shippingState: integer expected"; + if (message.payState != null && message.hasOwnProperty("payState")) + if (!$util.isInteger(message.payState)) + return "payState: integer expected"; + if (message.goodsPrice != null && message.hasOwnProperty("goodsPrice")) + if (typeof message.goodsPrice !== "number") + return "goodsPrice: number expected"; + if (message.shippingPrice != null && message.hasOwnProperty("shippingPrice")) + if (typeof message.shippingPrice !== "number") + return "shippingPrice: number expected"; + if (message.orderAmount != null && message.hasOwnProperty("orderAmount")) + if (typeof message.orderAmount !== "number") + return "orderAmount: number expected"; + if (message.totalAmount != null && message.hasOwnProperty("totalAmount")) + if (typeof message.totalAmount !== "number") + return "totalAmount: number expected"; + if (message.addTime != null && message.hasOwnProperty("addTime")) + if (!$util.isInteger(message.addTime) && !(message.addTime && $util.isInteger(message.addTime.low) && $util.isInteger(message.addTime.high))) + return "addTime: integer|Long expected"; + if (message.userNote != null && message.hasOwnProperty("userNote")) + if (!$util.isString(message.userNote)) + return "userNote: string expected"; + if (message.adminNote != null && message.hasOwnProperty("adminNote")) + if (!$util.isString(message.adminNote)) + return "adminNote: string expected"; + return null; + }; + + /** + * Creates an Order message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof order.List.OrderWithGoods.Order + * @static + * @param {Object.} object Plain object + * @returns {order.List.OrderWithGoods.Order} Order + */ + Order.fromObject = function fromObject(object) { + if (object instanceof $root.order.List.OrderWithGoods.Order) + return object; + var message = new $root.order.List.OrderWithGoods.Order(); + if (object.ID != null) + message.ID = object.ID >>> 0; + if (object.orderState != null) + message.orderState = object.orderState >>> 0; + if (object.orderSN != null) + message.orderSN = String(object.orderSN); + if (object.shippingState != null) + message.shippingState = object.shippingState >>> 0; + if (object.payState != null) + message.payState = object.payState >>> 0; + if (object.goodsPrice != null) + message.goodsPrice = Number(object.goodsPrice); + if (object.shippingPrice != null) + message.shippingPrice = Number(object.shippingPrice); + if (object.orderAmount != null) + message.orderAmount = Number(object.orderAmount); + if (object.totalAmount != null) + message.totalAmount = Number(object.totalAmount); + if (object.addTime != null) + if ($util.Long) + (message.addTime = $util.Long.fromValue(object.addTime)).unsigned = false; + else if (typeof object.addTime === "string") + message.addTime = parseInt(object.addTime, 10); + else if (typeof object.addTime === "number") + message.addTime = object.addTime; + else if (typeof object.addTime === "object") + message.addTime = new $util.LongBits(object.addTime.low >>> 0, object.addTime.high >>> 0).toNumber(); + if (object.userNote != null) + message.userNote = String(object.userNote); + if (object.adminNote != null) + message.adminNote = String(object.adminNote); + return message; + }; + + /** + * Creates a plain object from an Order message. Also converts values to other types if specified. + * @function toObject + * @memberof order.List.OrderWithGoods.Order + * @static + * @param {order.List.OrderWithGoods.Order} message Order + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Order.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.ID = 0; + object.orderState = 0; + object.orderSN = ""; + object.shippingState = 0; + object.payState = 0; + object.goodsPrice = 0; + object.shippingPrice = 0; + object.orderAmount = 0; + object.totalAmount = 0; + if ($util.Long) { + var long = new $util.Long(0, 0, false); + object.addTime = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.addTime = options.longs === String ? "0" : 0; + object.userNote = ""; + object.adminNote = ""; + } + if (message.ID != null && message.hasOwnProperty("ID")) + object.ID = message.ID; + if (message.orderState != null && message.hasOwnProperty("orderState")) + object.orderState = message.orderState; + if (message.orderSN != null && message.hasOwnProperty("orderSN")) + object.orderSN = message.orderSN; + if (message.shippingState != null && message.hasOwnProperty("shippingState")) + object.shippingState = message.shippingState; + if (message.payState != null && message.hasOwnProperty("payState")) + object.payState = message.payState; + if (message.goodsPrice != null && message.hasOwnProperty("goodsPrice")) + object.goodsPrice = options.json && !isFinite(message.goodsPrice) ? String(message.goodsPrice) : message.goodsPrice; + if (message.shippingPrice != null && message.hasOwnProperty("shippingPrice")) + object.shippingPrice = options.json && !isFinite(message.shippingPrice) ? String(message.shippingPrice) : message.shippingPrice; + if (message.orderAmount != null && message.hasOwnProperty("orderAmount")) + object.orderAmount = options.json && !isFinite(message.orderAmount) ? String(message.orderAmount) : message.orderAmount; + if (message.totalAmount != null && message.hasOwnProperty("totalAmount")) + object.totalAmount = options.json && !isFinite(message.totalAmount) ? String(message.totalAmount) : message.totalAmount; + if (message.addTime != null && message.hasOwnProperty("addTime")) + if (typeof message.addTime === "number") + object.addTime = options.longs === String ? String(message.addTime) : message.addTime; + else + object.addTime = options.longs === String ? $util.Long.prototype.toString.call(message.addTime) : options.longs === Number ? new $util.LongBits(message.addTime.low >>> 0, message.addTime.high >>> 0).toNumber() : message.addTime; + if (message.userNote != null && message.hasOwnProperty("userNote")) + object.userNote = message.userNote; + if (message.adminNote != null && message.hasOwnProperty("adminNote")) + object.adminNote = message.adminNote; + return object; + }; + + /** + * Converts this Order to JSON. + * @function toJSON + * @memberof order.List.OrderWithGoods.Order + * @instance + * @returns {Object.} JSON object + */ + Order.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return Order; + })(); + + OrderWithGoods.OrderGoods = (function() { + + /** + * Properties of an OrderGoods. + * @memberof order.List.OrderWithGoods + * @interface IOrderGoods + * @property {number} [ID] OrderGoods ID + * @property {number} [orderID] OrderGoods orderID + * @property {number} [goodsID] OrderGoods goodsID + * @property {string} [goodsName] OrderGoods goodsName + * @property {number} [goodsNum] OrderGoods goodsNum + * @property {number} [goodsPrice] OrderGoods goodsPrice + * @property {number} [costPrice] OrderGoods costPrice + * @property {string} [specKeyName] OrderGoods specKeyName + */ + + /** + * Constructs a new OrderGoods. + * @memberof order.List.OrderWithGoods + * @classdesc Represents an OrderGoods. + * @constructor + * @param {order.List.OrderWithGoods.IOrderGoods=} [properties] Properties to set + */ + function OrderGoods(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * OrderGoods ID. + * @member {number}ID + * @memberof order.List.OrderWithGoods.OrderGoods + * @instance + */ + OrderGoods.prototype.ID = 0; + + /** + * OrderGoods orderID. + * @member {number}orderID + * @memberof order.List.OrderWithGoods.OrderGoods + * @instance + */ + OrderGoods.prototype.orderID = 0; + + /** + * OrderGoods goodsID. + * @member {number}goodsID + * @memberof order.List.OrderWithGoods.OrderGoods + * @instance + */ + OrderGoods.prototype.goodsID = 0; + + /** + * OrderGoods goodsName. + * @member {string}goodsName + * @memberof order.List.OrderWithGoods.OrderGoods + * @instance + */ + OrderGoods.prototype.goodsName = ""; + + /** + * OrderGoods goodsNum. + * @member {number}goodsNum + * @memberof order.List.OrderWithGoods.OrderGoods + * @instance + */ + OrderGoods.prototype.goodsNum = 0; + + /** + * OrderGoods goodsPrice. + * @member {number}goodsPrice + * @memberof order.List.OrderWithGoods.OrderGoods + * @instance + */ + OrderGoods.prototype.goodsPrice = 0; + + /** + * OrderGoods costPrice. + * @member {number}costPrice + * @memberof order.List.OrderWithGoods.OrderGoods + * @instance + */ + OrderGoods.prototype.costPrice = 0; + + /** + * OrderGoods specKeyName. + * @member {string}specKeyName + * @memberof order.List.OrderWithGoods.OrderGoods + * @instance + */ + OrderGoods.prototype.specKeyName = ""; + + /** + * Creates a new OrderGoods instance using the specified properties. + * @function create + * @memberof order.List.OrderWithGoods.OrderGoods + * @static + * @param {order.List.OrderWithGoods.IOrderGoods=} [properties] Properties to set + * @returns {order.List.OrderWithGoods.OrderGoods} OrderGoods instance + */ + OrderGoods.create = function create(properties) { + return new OrderGoods(properties); + }; + + /** + * Encodes the specified OrderGoods message. Does not implicitly {@link order.List.OrderWithGoods.OrderGoods.verify|verify} messages. + * @function encode + * @memberof order.List.OrderWithGoods.OrderGoods + * @static + * @param {order.List.OrderWithGoods.IOrderGoods} message OrderGoods message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + OrderGoods.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.ID != null && message.hasOwnProperty("ID")) + writer.uint32(/* id 1, wireType 0 =*/8).uint32(message.ID); + if (message.orderID != null && message.hasOwnProperty("orderID")) + writer.uint32(/* id 2, wireType 0 =*/16).uint32(message.orderID); + if (message.goodsID != null && message.hasOwnProperty("goodsID")) + writer.uint32(/* id 3, wireType 0 =*/24).uint32(message.goodsID); + if (message.goodsName != null && message.hasOwnProperty("goodsName")) + writer.uint32(/* id 4, wireType 2 =*/34).string(message.goodsName); + if (message.goodsNum != null && message.hasOwnProperty("goodsNum")) + writer.uint32(/* id 5, wireType 0 =*/40).uint32(message.goodsNum); + if (message.goodsPrice != null && message.hasOwnProperty("goodsPrice")) + writer.uint32(/* id 6, wireType 5 =*/53).float(message.goodsPrice); + if (message.costPrice != null && message.hasOwnProperty("costPrice")) + writer.uint32(/* id 7, wireType 5 =*/61).float(message.costPrice); + if (message.specKeyName != null && message.hasOwnProperty("specKeyName")) + writer.uint32(/* id 8, wireType 2 =*/66).string(message.specKeyName); + return writer; + }; + + /** + * Encodes the specified OrderGoods message, length delimited. Does not implicitly {@link order.List.OrderWithGoods.OrderGoods.verify|verify} messages. + * @function encodeDelimited + * @memberof order.List.OrderWithGoods.OrderGoods + * @static + * @param {order.List.OrderWithGoods.IOrderGoods} message OrderGoods message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + OrderGoods.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an OrderGoods message from the specified reader or buffer. + * @function decode + * @memberof order.List.OrderWithGoods.OrderGoods + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {order.List.OrderWithGoods.OrderGoods} OrderGoods + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + OrderGoods.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.order.List.OrderWithGoods.OrderGoods(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.ID = reader.uint32(); + break; + case 2: + message.orderID = reader.uint32(); + break; + case 3: + message.goodsID = reader.uint32(); + break; + case 4: + message.goodsName = reader.string(); + break; + case 5: + message.goodsNum = reader.uint32(); + break; + case 6: + message.goodsPrice = reader.float(); + break; + case 7: + message.costPrice = reader.float(); + break; + case 8: + message.specKeyName = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an OrderGoods message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof order.List.OrderWithGoods.OrderGoods + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {order.List.OrderWithGoods.OrderGoods} OrderGoods + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + OrderGoods.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an OrderGoods message. + * @function verify + * @memberof order.List.OrderWithGoods.OrderGoods + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + OrderGoods.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.ID != null && message.hasOwnProperty("ID")) + if (!$util.isInteger(message.ID)) + return "ID: integer expected"; + if (message.orderID != null && message.hasOwnProperty("orderID")) + if (!$util.isInteger(message.orderID)) + return "orderID: integer expected"; + if (message.goodsID != null && message.hasOwnProperty("goodsID")) + if (!$util.isInteger(message.goodsID)) + return "goodsID: integer expected"; + if (message.goodsName != null && message.hasOwnProperty("goodsName")) + if (!$util.isString(message.goodsName)) + return "goodsName: string expected"; + if (message.goodsNum != null && message.hasOwnProperty("goodsNum")) + if (!$util.isInteger(message.goodsNum)) + return "goodsNum: integer expected"; + if (message.goodsPrice != null && message.hasOwnProperty("goodsPrice")) + if (typeof message.goodsPrice !== "number") + return "goodsPrice: number expected"; + if (message.costPrice != null && message.hasOwnProperty("costPrice")) + if (typeof message.costPrice !== "number") + return "costPrice: number expected"; + if (message.specKeyName != null && message.hasOwnProperty("specKeyName")) + if (!$util.isString(message.specKeyName)) + return "specKeyName: string expected"; + return null; + }; + + /** + * Creates an OrderGoods message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof order.List.OrderWithGoods.OrderGoods + * @static + * @param {Object.} object Plain object + * @returns {order.List.OrderWithGoods.OrderGoods} OrderGoods + */ + OrderGoods.fromObject = function fromObject(object) { + if (object instanceof $root.order.List.OrderWithGoods.OrderGoods) + return object; + var message = new $root.order.List.OrderWithGoods.OrderGoods(); + if (object.ID != null) + message.ID = object.ID >>> 0; + if (object.orderID != null) + message.orderID = object.orderID >>> 0; + if (object.goodsID != null) + message.goodsID = object.goodsID >>> 0; + if (object.goodsName != null) + message.goodsName = String(object.goodsName); + if (object.goodsNum != null) + message.goodsNum = object.goodsNum >>> 0; + if (object.goodsPrice != null) + message.goodsPrice = Number(object.goodsPrice); + if (object.costPrice != null) + message.costPrice = Number(object.costPrice); + if (object.specKeyName != null) + message.specKeyName = String(object.specKeyName); + return message; + }; + + /** + * Creates a plain object from an OrderGoods message. Also converts values to other types if specified. + * @function toObject + * @memberof order.List.OrderWithGoods.OrderGoods + * @static + * @param {order.List.OrderWithGoods.OrderGoods} message OrderGoods + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + OrderGoods.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.ID = 0; + object.orderID = 0; + object.goodsID = 0; + object.goodsName = ""; + object.goodsNum = 0; + object.goodsPrice = 0; + object.costPrice = 0; + object.specKeyName = ""; + } + if (message.ID != null && message.hasOwnProperty("ID")) + object.ID = message.ID; + if (message.orderID != null && message.hasOwnProperty("orderID")) + object.orderID = message.orderID; + if (message.goodsID != null && message.hasOwnProperty("goodsID")) + object.goodsID = message.goodsID; + if (message.goodsName != null && message.hasOwnProperty("goodsName")) + object.goodsName = message.goodsName; + if (message.goodsNum != null && message.hasOwnProperty("goodsNum")) + object.goodsNum = message.goodsNum; + if (message.goodsPrice != null && message.hasOwnProperty("goodsPrice")) + object.goodsPrice = options.json && !isFinite(message.goodsPrice) ? String(message.goodsPrice) : message.goodsPrice; + if (message.costPrice != null && message.hasOwnProperty("costPrice")) + object.costPrice = options.json && !isFinite(message.costPrice) ? String(message.costPrice) : message.costPrice; + if (message.specKeyName != null && message.hasOwnProperty("specKeyName")) + object.specKeyName = message.specKeyName; + return object; + }; + + /** + * Converts this OrderGoods to JSON. + * @function toJSON + * @memberof order.List.OrderWithGoods.OrderGoods + * @instance + * @returns {Object.} JSON object + */ + OrderGoods.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return OrderGoods; + })(); + + return OrderWithGoods; + })(); + + return List; + })(); + + return order; +})(); + +module.exports = $root; diff --git a/proto/order/order.pb.go b/proto/order/order.pb.go new file mode 100644 index 0000000..ad7a061 --- /dev/null +++ b/proto/order/order.pb.go @@ -0,0 +1,174 @@ +// Code generated by protoc-gen-go. +// source: order.proto +// DO NOT EDIT! + +/* +Package order is a generated protocol buffer package. + +It is generated from these files: + order.proto + +It has these top-level messages: + CreateParam + Order + List +*/ +package order + +import proto "github.com/golang/protobuf/proto" +import fmt "fmt" +import math "math" + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package + +type CreateParam struct { + AddressID uint32 `protobuf:"varint,1,opt,name=addressID" json:"addressID,omitempty"` + Remark string `protobuf:"bytes,2,opt,name=remark" json:"remark,omitempty"` +} + +func (m *CreateParam) Reset() { *m = CreateParam{} } +func (m *CreateParam) String() string { return proto.CompactTextString(m) } +func (*CreateParam) ProtoMessage() {} +func (*CreateParam) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} } + +// Order 订单 +type Order struct { + ID uint32 `protobuf:"varint,1,opt,name=ID" json:"ID,omitempty"` + OrderSN string `protobuf:"bytes,2,opt,name=orderSN" json:"orderSN,omitempty"` + TotalAmount float32 `protobuf:"fixed32,3,opt,name=totalAmount" json:"totalAmount,omitempty"` +} + +func (m *Order) Reset() { *m = Order{} } +func (m *Order) String() string { return proto.CompactTextString(m) } +func (*Order) ProtoMessage() {} +func (*Order) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} } + +type List struct { + Orders []*List_OrderWithGoods `protobuf:"bytes,1,rep,name=orders" json:"orders,omitempty"` +} + +func (m *List) Reset() { *m = List{} } +func (m *List) String() string { return proto.CompactTextString(m) } +func (*List) ProtoMessage() {} +func (*List) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{2} } + +func (m *List) GetOrders() []*List_OrderWithGoods { + if m != nil { + return m.Orders + } + return nil +} + +type List_OrderWithGoods struct { + Order *List_OrderWithGoods_Order `protobuf:"bytes,1,opt,name=order" json:"order,omitempty"` + OrderGoodses []*List_OrderWithGoods_OrderGoods `protobuf:"bytes,2,rep,name=orderGoodses" json:"orderGoodses,omitempty"` +} + +func (m *List_OrderWithGoods) Reset() { *m = List_OrderWithGoods{} } +func (m *List_OrderWithGoods) String() string { return proto.CompactTextString(m) } +func (*List_OrderWithGoods) ProtoMessage() {} +func (*List_OrderWithGoods) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{2, 0} } + +func (m *List_OrderWithGoods) GetOrder() *List_OrderWithGoods_Order { + if m != nil { + return m.Order + } + return nil +} + +func (m *List_OrderWithGoods) GetOrderGoodses() []*List_OrderWithGoods_OrderGoods { + if m != nil { + return m.OrderGoodses + } + return nil +} + +type List_OrderWithGoods_Order struct { + ID uint32 `protobuf:"varint,1,opt,name=ID" json:"ID,omitempty"` + OrderState uint32 `protobuf:"varint,2,opt,name=orderState" json:"orderState,omitempty"` + OrderSN string `protobuf:"bytes,3,opt,name=orderSN" json:"orderSN,omitempty"` + ShippingState uint32 `protobuf:"varint,4,opt,name=shippingState" json:"shippingState,omitempty"` + PayState uint32 `protobuf:"varint,5,opt,name=payState" json:"payState,omitempty"` + GoodsPrice float32 `protobuf:"fixed32,6,opt,name=goodsPrice" json:"goodsPrice,omitempty"` + ShippingPrice float32 `protobuf:"fixed32,7,opt,name=shippingPrice" json:"shippingPrice,omitempty"` + OrderAmount float32 `protobuf:"fixed32,8,opt,name=orderAmount" json:"orderAmount,omitempty"` + TotalAmount float32 `protobuf:"fixed32,9,opt,name=totalAmount" json:"totalAmount,omitempty"` + AddTime int64 `protobuf:"varint,10,opt,name=addTime" json:"addTime,omitempty"` + UserNote string `protobuf:"bytes,11,opt,name=userNote" json:"userNote,omitempty"` + AdminNote string `protobuf:"bytes,12,opt,name=adminNote" json:"adminNote,omitempty"` +} + +func (m *List_OrderWithGoods_Order) Reset() { *m = List_OrderWithGoods_Order{} } +func (m *List_OrderWithGoods_Order) String() string { return proto.CompactTextString(m) } +func (*List_OrderWithGoods_Order) ProtoMessage() {} +func (*List_OrderWithGoods_Order) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{2, 0, 0} } + +type List_OrderWithGoods_OrderGoods struct { + ID uint32 `protobuf:"varint,1,opt,name=ID" json:"ID,omitempty"` + OrderID uint32 `protobuf:"varint,2,opt,name=orderID" json:"orderID,omitempty"` + GoodsID uint32 `protobuf:"varint,3,opt,name=goodsID" json:"goodsID,omitempty"` + GoodsName string `protobuf:"bytes,4,opt,name=goodsName" json:"goodsName,omitempty"` + GoodsNum uint32 `protobuf:"varint,5,opt,name=goodsNum" json:"goodsNum,omitempty"` + GoodsPrice float32 `protobuf:"fixed32,6,opt,name=goodsPrice" json:"goodsPrice,omitempty"` + CostPrice float32 `protobuf:"fixed32,7,opt,name=costPrice" json:"costPrice,omitempty"` + SpecKeyName string `protobuf:"bytes,8,opt,name=specKeyName" json:"specKeyName,omitempty"` +} + +func (m *List_OrderWithGoods_OrderGoods) Reset() { *m = List_OrderWithGoods_OrderGoods{} } +func (m *List_OrderWithGoods_OrderGoods) String() string { return proto.CompactTextString(m) } +func (*List_OrderWithGoods_OrderGoods) ProtoMessage() {} +func (*List_OrderWithGoods_OrderGoods) Descriptor() ([]byte, []int) { + return fileDescriptor0, []int{2, 0, 1} +} + +func init() { + proto.RegisterType((*CreateParam)(nil), "order.CreateParam") + proto.RegisterType((*Order)(nil), "order.Order") + proto.RegisterType((*List)(nil), "order.List") + proto.RegisterType((*List_OrderWithGoods)(nil), "order.List.OrderWithGoods") + proto.RegisterType((*List_OrderWithGoods_Order)(nil), "order.List.OrderWithGoods.Order") + proto.RegisterType((*List_OrderWithGoods_OrderGoods)(nil), "order.List.OrderWithGoods.OrderGoods") +} + +func init() { proto.RegisterFile("order.proto", fileDescriptor0) } + +var fileDescriptor0 = []byte{ + // 441 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x84, 0x93, 0xc1, 0x6a, 0xdc, 0x30, + 0x10, 0x86, 0xb1, 0x1d, 0x3b, 0xeb, 0x71, 0x9c, 0x83, 0x0e, 0x45, 0x98, 0x50, 0xcc, 0xd2, 0x82, + 0x4f, 0x7b, 0xd8, 0x42, 0xef, 0x25, 0x86, 0x62, 0x5a, 0xb6, 0x41, 0x29, 0xf4, 0xac, 0xae, 0x45, + 0x62, 0x5a, 0xaf, 0x8c, 0xa4, 0x3d, 0xe4, 0xb1, 0xfa, 0x5a, 0xbd, 0x15, 0xfa, 0x00, 0x45, 0x23, + 0x7b, 0x2d, 0x37, 0x2c, 0xb9, 0xf9, 0xff, 0x67, 0x46, 0x33, 0xfa, 0x46, 0x86, 0x4c, 0xaa, 0x56, + 0xa8, 0xcd, 0xa0, 0xa4, 0x91, 0x24, 0x46, 0xb1, 0xbe, 0x85, 0xec, 0x56, 0x09, 0x6e, 0xc4, 0x1d, + 0x57, 0xbc, 0x27, 0x37, 0x90, 0xf2, 0xb6, 0x55, 0x42, 0xeb, 0xa6, 0xa6, 0x41, 0x19, 0x54, 0x39, + 0x9b, 0x0d, 0xf2, 0x0a, 0x12, 0x25, 0x7a, 0xae, 0x7e, 0xd0, 0xb0, 0x0c, 0xaa, 0x94, 0x8d, 0x6a, + 0x7d, 0x0f, 0xf1, 0x17, 0x7b, 0x1a, 0xb9, 0x86, 0xf0, 0x54, 0x17, 0x36, 0x35, 0xa1, 0x70, 0x89, + 0x6d, 0xee, 0x77, 0x63, 0xc5, 0x24, 0x49, 0x09, 0x99, 0x91, 0x86, 0xff, 0xfc, 0xd0, 0xcb, 0xe3, + 0xc1, 0xd0, 0xa8, 0x0c, 0xaa, 0x90, 0xf9, 0xd6, 0xfa, 0x57, 0x02, 0x17, 0x9f, 0x3b, 0x6d, 0xc8, + 0x16, 0x12, 0xac, 0xd2, 0x34, 0x28, 0xa3, 0x2a, 0xdb, 0x16, 0x1b, 0x77, 0x0f, 0x1b, 0xdc, 0x60, + 0xdf, 0x6f, 0x9d, 0x79, 0xfc, 0x28, 0x65, 0xab, 0xd9, 0x98, 0x59, 0xfc, 0x8d, 0xe1, 0x7a, 0x19, + 0x22, 0xef, 0xc1, 0x5d, 0x19, 0xc7, 0xcb, 0xb6, 0xe5, 0xf9, 0x53, 0x9c, 0x64, 0x2e, 0x9d, 0x34, + 0x70, 0x85, 0x1f, 0x18, 0x12, 0x9a, 0x86, 0x38, 0xc4, 0xdb, 0x97, 0xca, 0xdd, 0x3c, 0x8b, 0xd2, + 0xe2, 0x4f, 0x78, 0x0e, 0xd4, 0x6b, 0x00, 0x47, 0xc6, 0x70, 0x23, 0x90, 0x55, 0xce, 0x3c, 0xc7, + 0x07, 0x19, 0x2d, 0x41, 0xbe, 0x81, 0x5c, 0x3f, 0x76, 0xc3, 0xd0, 0x1d, 0x1e, 0x5c, 0xf1, 0x05, + 0x16, 0x2f, 0x4d, 0x52, 0xc0, 0x6a, 0xe0, 0x4f, 0x2e, 0x21, 0xc6, 0x84, 0x93, 0xb6, 0xbd, 0x1f, + 0xec, 0x80, 0x77, 0xaa, 0xdb, 0x0b, 0x9a, 0xe0, 0x26, 0x3c, 0xc7, 0xef, 0xe0, 0x52, 0x2e, 0x31, + 0x65, 0x69, 0xda, 0x85, 0xe2, 0x48, 0xe3, 0x42, 0x57, 0x6e, 0xa1, 0x9e, 0xf5, 0xff, 0xca, 0xd3, + 0x67, 0x2b, 0xb7, 0xb7, 0xe4, 0x6d, 0xfb, 0xb5, 0xeb, 0x05, 0x85, 0x32, 0xa8, 0x22, 0x36, 0x49, + 0x3b, 0xff, 0x51, 0x0b, 0xb5, 0x93, 0x46, 0xd0, 0x0c, 0x01, 0x9c, 0xb4, 0x7b, 0xb3, 0x7d, 0x77, + 0xc0, 0xe0, 0x15, 0x06, 0x67, 0xa3, 0xf8, 0x1d, 0x00, 0xcc, 0x0b, 0x39, 0xfb, 0x42, 0x9b, 0x7a, + 0xa4, 0x3e, 0x49, 0x1b, 0x41, 0x08, 0x4d, 0x8d, 0xc8, 0x73, 0x36, 0x49, 0xdb, 0x10, 0x3f, 0x77, + 0xbc, 0x77, 0xb8, 0x53, 0x36, 0x1b, 0x76, 0x54, 0x27, 0x8e, 0xfd, 0x84, 0x7a, 0xd2, 0x2f, 0xa2, + 0xbe, 0x81, 0x74, 0x2f, 0xb5, 0xf1, 0x31, 0xcf, 0x86, 0x05, 0xa8, 0x07, 0xb1, 0xff, 0x24, 0x9e, + 0xb0, 0xf3, 0x0a, 0x3b, 0xfb, 0xd6, 0xf7, 0x04, 0xff, 0xed, 0x77, 0xff, 0x02, 0x00, 0x00, 0xff, + 0xff, 0xc3, 0x20, 0x78, 0x56, 0xea, 0x03, 0x00, 0x00, +} diff --git a/proto/order/order.proto b/proto/order/order.proto new file mode 100644 index 0000000..19f2573 --- /dev/null +++ b/proto/order/order.proto @@ -0,0 +1,50 @@ +syntax = "proto3"; + +package order; + +message CreateParam { + uint32 addressID = 1; + string remark = 2; +} + +// Order 订单 +message Order { + uint32 ID = 1; // 表id mediumint(8) + string orderSN = 2; // 订单编号 varchar(20) + float totalAmount = 3; // 订单总价 decimal(10,2 +} + +message List { + message OrderWithGoods { + message Order { + uint32 ID = 1; + uint32 orderState = 2; + string orderSN = 3; + uint32 shippingState = 4; + uint32 payState = 5; + float goodsPrice = 6; + float shippingPrice = 7; + float orderAmount = 8; + float totalAmount = 9; + int64 addTime = 10; + string userNote = 11; + string adminNote = 12; + } + Order order = 1; + + message OrderGoods { + uint32 ID = 1; + uint32 orderID = 2; + uint32 goodsID = 3; + string goodsName = 4; + uint32 goodsNum = 5; + float goodsPrice = 6; + float costPrice = 7; + string specKeyName = 8; + } + + repeated OrderGoods orderGoodses = 2; + } + + repeated OrderWithGoods orders = 1; +} diff --git a/router/route.go b/router/route.go index 60358bd..6fb1890 100755 --- a/router/route.go +++ b/router/route.go @@ -21,9 +21,9 @@ func (r *Route) Init(app *iris.Application) { // iris.Post("/", controller.WechatCtr.Validate, controller.WechatCtr.Message) address := app.Party("/address") - address.Get("/default", ctr.UserController.DefatultAddress) - address.Get("/all", ctr.UserController.AllAddress) - address.Get("/{id:int}", ctr.UserController.AllAddress) + address.Get("/default", ctr.AddressController.DefatultAddress) + address.Get("/all", ctr.AddressController.AllAddress) + address.Get("/{id:int}", ctr.AddressController.Detail) goods := app.Party("/goods") goods.Get("/new", ctr.GoodsController.NewGoods) @@ -40,4 +40,8 @@ func (r *Route) Init(app *iris.Application) { cart.Patch("/{id:int}/modify", ctr.CartController.Modify) cart.Patch("/modify/all", ctr.CartController.ModifyAll) cart.Delete("/delete/selected", ctr.CartController.RemoveSelected) + + order := app.Party("/order") + order.Post("/create", ctr.OrderController.Create) + order.Get("/list", ctr.OrderController.List) } diff --git a/web/pages/order-list/index.js b/web/pages/order-list/index.js index 22b5f59..9f6d401 100644 --- a/web/pages/order-list/index.js +++ b/web/pages/order-list/index.js @@ -1,8 +1,11 @@ var wxpay = require('../../utils/pay.js') +var util = require('../../utils/util.js') +var porder = require('../../proto/order.js').order + var app = getApp() Page({ data:{ - statusType: ["待付款", "待发货", "待收货", "待评价", "已完成"], + statusType: ["全部", "待付款", "待发货", "待收货", "待评价"], currentType:0, tabClass: ["", "", "", "", ""] }, @@ -53,11 +56,11 @@ Page({ }, onLoad:function(options){ // 生命周期函数--监听页面加载 - + }, onReady:function(){ // 生命周期函数--监听页面初次渲染完成 - + }, getOrderStatistics : function () { var that = this; @@ -111,15 +114,18 @@ Page({ postData.status = that.data.currentType; this.getOrderStatistics(); wx.request({ - url: 'https://api.it120.cc/' + app.globalData.subDomain + '/order/list', - data: postData, + url: app.globalData.domain + '/order/list', + method: "GET", + header: {token: "00a1c0366b96e5c3bfff8bd1d85fa557"}, success: (res) => { wx.hideLoading(); - if (res.data.code == 0) { + if (res.statusCode == 200) { + var result = util.convResult(res.data, porder.List); + console.log(result); that.setData({ - orderList: res.data.data.orderList, - logisticsMap : res.data.data.logisticsMap, - goodsMap : res.data.data.goodsMap + orderList: result.orders, + // logisticsMap : res.data.data.logisticsMap, + // goodsMap : res.data.data.goodsMap }); } else { this.setData({ @@ -130,22 +136,22 @@ Page({ } } }) - + }, onHide:function(){ // 生命周期函数--监听页面隐藏 - + }, onUnload:function(){ // 生命周期函数--监听页面卸载 - + }, onPullDownRefresh: function() { // 页面相关事件处理函数--监听用户下拉动作 - + }, onReachBottom: function() { // 页面上拉触底事件的处理函数 - + } -}) \ No newline at end of file +}) diff --git a/web/pages/order-list/index.wxml b/web/pages/order-list/index.wxml index 7226724..6128c4b 100644 --- a/web/pages/order-list/index.wxml +++ b/web/pages/order-list/index.wxml @@ -10,30 +10,40 @@ 暂无订单 \ No newline at end of file + diff --git a/web/pages/order-list/index.wxss b/web/pages/order-list/index.wxss index 66bb9a0..abbfe67 100644 --- a/web/pages/order-list/index.wxss +++ b/web/pages/order-list/index.wxss @@ -82,8 +82,6 @@ border-top: 1rpx solid #eee; border-bottom: 1rpx solid #eee; padding: 30rpx 0; - display: flex; - align-items: center; } .goods-info .img-box{ width: 120rpx; @@ -152,4 +150,61 @@ .a-order .price-box .topay-btn{ border:1px solid #e64340; color: #e64340; -} \ No newline at end of file +} + +.goods-info{ + border-bottom: 1px solid #eee; + display: flex; + justify-content:space-between; + padding: 30rpx 0 30rpx 70rpx; + width: 720rpx; + box-sizing: border-box; +} +.goods-info .img-box{ + width: 160rpx; + height:160rpx; + overflow: hidden; + margin-right: 20rpx; + background-color: #d8d8d8; + float: left; +} +.goods-info .text-box{ + width: 410rpx; + position: relative; + float: left; +} +.goods-info .text-box .goods-title{ + font-size: 28rpx; + color:#000; + text-overflow: ellipsis; + overflow: hidden; + padding: 0 0 5rpx 0; + width: 400rpx; +} +.goods-info .text-box .goods-label{ + font-size: 26rpx; + color:#999; + height: 38rpx; + line-height: 38rpx; + margin: 8rpx 0 25rpx 0; +} +.goods-info .text-box .goods-price{ + font-size: 26rpx; + color:#e64340; +} +.goods-info .buy-num{ + line-height: 48rpx; + right: 30rpx; + bottom: 0; + /*justify-content: space-between;*/ + font-size: 26rpx; + text-align: center; + margin-right: 30rpx; + display: block; + float: left; +} + +.goods-info .img-box .img{ + width: 160rpx; + height:160rpx; +} diff --git a/web/pages/to-pay-order/index.js b/web/pages/to-pay-order/index.js index e1063b9..d634dbe 100644 --- a/web/pages/to-pay-order/index.js +++ b/web/pages/to-pay-order/index.js @@ -3,6 +3,7 @@ var app = getApp() var util = require('../../utils/util.js') var paddress = require('../../proto/address.js').address +var porder = require('../../proto/order.js').order Page({ data: { @@ -158,17 +159,17 @@ Page({ postData.calculate = "true"; } - + var params = porder.CreateParam.create({addressID: self.data.curAddressData.ID, remark: remark}); + console.log(params); + var buf = porder.CreateParam.encode(params).finish(); wx.request({ - url: 'https://api.it120.cc/'+ app.globalData.subDomain +'/order/create', - method:'POST', - header: { - 'content-type': 'application/x-www-form-urlencoded' - }, - data: postData, // 设置请求的 参数 + url: app.globalData.domain + '/order/create', + method: "POST", + header: {token: "00a1c0366b96e5c3bfff8bd1d85fa557"}, + data: wx.arrayBufferToBase64(buf), success: (res) =>{ wx.hideLoading(); - if (res.data.code != 0) { + if (res.statusCode != 200) { wx.showModal({ title: '错误', content: res.data.msg, @@ -177,10 +178,7 @@ Page({ return; } - if (e && "buyNow" != self.data.orderType) { - // 清空购物车数据 - wx.removeStorageSync('shopCarInfo'); - } + wx.removeStorageSync('shopCarInfo'); if (!e) { self.setData({ isNeedLogistics: res.data.data.isNeedLogistics, @@ -192,22 +190,22 @@ Page({ return; } // 配置模板消息推送 - var postJsonString = {}; - postJsonString.keyword1 = { value: res.data.data.dateAdd, color: '#173177' } - postJsonString.keyword2 = { value: res.data.data.amountReal + '元', color: '#173177' } - postJsonString.keyword3 = { value: res.data.data.orderNumber, color: '#173177' } - postJsonString.keyword4 = { value: '订单已关闭', color: '#173177' } - postJsonString.keyword5 = { value: '您可以重新下单,请在30分钟内完成支付', color:'#173177'} - app.sendTempleMsg(res.data.data.id, -1, - 'uJQMNVoVnpjRm18Yc6HSchn_aIFfpBn1CZRntI685zY', e.detail.formId, - 'pages/index/index', JSON.stringify(postJsonString)); - postJsonString = {}; - postJsonString.keyword1 = { value: '您的订单已发货,请注意查收', color: '#173177' } - postJsonString.keyword2 = { value: res.data.data.orderNumber, color: '#173177' } - postJsonString.keyword3 = { value: res.data.data.dateAdd, color: '#173177' } - app.sendTempleMsg(res.data.data.id, 2, - 'GeZutJFGEWzavh69savy_KgtfGj4lHqlP7Zi1w8AOwo', e.detail.formId, - 'pages/order-details/index?id=' + res.data.data.id, JSON.stringify(postJsonString)); + // var postJsonString = {}; + // postJsonString.keyword1 = { value: res.data.data.dateAdd, color: '#173177' } + // postJsonString.keyword2 = { value: res.data.data.amountReal + '元', color: '#173177' } + // postJsonString.keyword3 = { value: res.data.data.orderNumber, color: '#173177' } + // postJsonString.keyword4 = { value: '订单已关闭', color: '#173177' } + // postJsonString.keyword5 = { value: '您可以重新下单,请在30分钟内完成支付', color:'#173177'} + // app.sendTempleMsg(res.data.data.id, -1, + // 'uJQMNVoVnpjRm18Yc6HSchn_aIFfpBn1CZRntI685zY', e.detail.formId, + // 'pages/index/index', JSON.stringify(postJsonString)); + // postJsonString = {}; + // postJsonString.keyword1 = { value: '您的订单已发货,请注意查收', color: '#173177' } + // postJsonString.keyword2 = { value: res.data.data.orderNumber, color: '#173177' } + // postJsonString.keyword3 = { value: res.data.data.dateAdd, color: '#173177' } + // app.sendTempleMsg(res.data.data.id, 2, + // 'GeZutJFGEWzavh69savy_KgtfGj4lHqlP7Zi1w8AOwo', e.detail.formId, + // 'pages/order-details/index?id=' + res.data.data.id, JSON.stringify(postJsonString)); // 下单成功,跳转到订单管理界面 wx.redirectTo({ url: "/pages/order-list/index" diff --git a/web/proto/order.js b/web/proto/order.js new file mode 100644 index 0000000..7b06061 --- /dev/null +++ b/web/proto/order.js @@ -0,0 +1,1690 @@ +/*eslint-disable block-scoped-var, no-redeclare, no-control-regex, no-prototype-builtins*/ +"use strict"; + +var $protobuf = require("protobuf.min"); + +// Common aliases +var $Reader = $protobuf.Reader, $Writer = $protobuf.Writer, $util = $protobuf.util; + +// Exported root namespace +var $root = $protobuf.roots["default"] || ($protobuf.roots["default"] = {}); + +$root.order = (function() { + + /** + * Namespace order. + * @exports order + * @namespace + */ + var order = {}; + + order.CreateParam = (function() { + + /** + * Properties of a CreateParam. + * @memberof order + * @interface ICreateParam + * @property {number} [addressID] CreateParam addressID + * @property {string} [remark] CreateParam remark + */ + + /** + * Constructs a new CreateParam. + * @memberof order + * @classdesc Represents a CreateParam. + * @constructor + * @param {order.ICreateParam=} [properties] Properties to set + */ + function CreateParam(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * CreateParam addressID. + * @member {number}addressID + * @memberof order.CreateParam + * @instance + */ + CreateParam.prototype.addressID = 0; + + /** + * CreateParam remark. + * @member {string}remark + * @memberof order.CreateParam + * @instance + */ + CreateParam.prototype.remark = ""; + + /** + * Creates a new CreateParam instance using the specified properties. + * @function create + * @memberof order.CreateParam + * @static + * @param {order.ICreateParam=} [properties] Properties to set + * @returns {order.CreateParam} CreateParam instance + */ + CreateParam.create = function create(properties) { + return new CreateParam(properties); + }; + + /** + * Encodes the specified CreateParam message. Does not implicitly {@link order.CreateParam.verify|verify} messages. + * @function encode + * @memberof order.CreateParam + * @static + * @param {order.ICreateParam} message CreateParam message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CreateParam.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.addressID != null && message.hasOwnProperty("addressID")) + writer.uint32(/* id 1, wireType 0 =*/8).uint32(message.addressID); + if (message.remark != null && message.hasOwnProperty("remark")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.remark); + return writer; + }; + + /** + * Encodes the specified CreateParam message, length delimited. Does not implicitly {@link order.CreateParam.verify|verify} messages. + * @function encodeDelimited + * @memberof order.CreateParam + * @static + * @param {order.ICreateParam} message CreateParam message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CreateParam.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a CreateParam message from the specified reader or buffer. + * @function decode + * @memberof order.CreateParam + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {order.CreateParam} CreateParam + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CreateParam.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.order.CreateParam(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.addressID = reader.uint32(); + break; + case 2: + message.remark = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a CreateParam message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof order.CreateParam + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {order.CreateParam} CreateParam + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CreateParam.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a CreateParam message. + * @function verify + * @memberof order.CreateParam + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + CreateParam.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.addressID != null && message.hasOwnProperty("addressID")) + if (!$util.isInteger(message.addressID)) + return "addressID: integer expected"; + if (message.remark != null && message.hasOwnProperty("remark")) + if (!$util.isString(message.remark)) + return "remark: string expected"; + return null; + }; + + /** + * Creates a CreateParam message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof order.CreateParam + * @static + * @param {Object.} object Plain object + * @returns {order.CreateParam} CreateParam + */ + CreateParam.fromObject = function fromObject(object) { + if (object instanceof $root.order.CreateParam) + return object; + var message = new $root.order.CreateParam(); + if (object.addressID != null) + message.addressID = object.addressID >>> 0; + if (object.remark != null) + message.remark = String(object.remark); + return message; + }; + + /** + * Creates a plain object from a CreateParam message. Also converts values to other types if specified. + * @function toObject + * @memberof order.CreateParam + * @static + * @param {order.CreateParam} message CreateParam + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + CreateParam.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.addressID = 0; + object.remark = ""; + } + if (message.addressID != null && message.hasOwnProperty("addressID")) + object.addressID = message.addressID; + if (message.remark != null && message.hasOwnProperty("remark")) + object.remark = message.remark; + return object; + }; + + /** + * Converts this CreateParam to JSON. + * @function toJSON + * @memberof order.CreateParam + * @instance + * @returns {Object.} JSON object + */ + CreateParam.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return CreateParam; + })(); + + order.Order = (function() { + + /** + * Properties of an Order. + * @memberof order + * @interface IOrder + * @property {number} [ID] Order ID + * @property {string} [orderSN] Order orderSN + * @property {number} [totalAmount] Order totalAmount + */ + + /** + * Constructs a new Order. + * @memberof order + * @classdesc Represents an Order. + * @constructor + * @param {order.IOrder=} [properties] Properties to set + */ + function Order(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Order ID. + * @member {number}ID + * @memberof order.Order + * @instance + */ + Order.prototype.ID = 0; + + /** + * Order orderSN. + * @member {string}orderSN + * @memberof order.Order + * @instance + */ + Order.prototype.orderSN = ""; + + /** + * Order totalAmount. + * @member {number}totalAmount + * @memberof order.Order + * @instance + */ + Order.prototype.totalAmount = 0; + + /** + * Creates a new Order instance using the specified properties. + * @function create + * @memberof order.Order + * @static + * @param {order.IOrder=} [properties] Properties to set + * @returns {order.Order} Order instance + */ + Order.create = function create(properties) { + return new Order(properties); + }; + + /** + * Encodes the specified Order message. Does not implicitly {@link order.Order.verify|verify} messages. + * @function encode + * @memberof order.Order + * @static + * @param {order.IOrder} message Order message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Order.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.ID != null && message.hasOwnProperty("ID")) + writer.uint32(/* id 1, wireType 0 =*/8).uint32(message.ID); + if (message.orderSN != null && message.hasOwnProperty("orderSN")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.orderSN); + if (message.totalAmount != null && message.hasOwnProperty("totalAmount")) + writer.uint32(/* id 3, wireType 5 =*/29).float(message.totalAmount); + return writer; + }; + + /** + * Encodes the specified Order message, length delimited. Does not implicitly {@link order.Order.verify|verify} messages. + * @function encodeDelimited + * @memberof order.Order + * @static + * @param {order.IOrder} message Order message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Order.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an Order message from the specified reader or buffer. + * @function decode + * @memberof order.Order + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {order.Order} Order + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Order.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.order.Order(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.ID = reader.uint32(); + break; + case 2: + message.orderSN = reader.string(); + break; + case 3: + message.totalAmount = reader.float(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an Order message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof order.Order + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {order.Order} Order + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Order.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an Order message. + * @function verify + * @memberof order.Order + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Order.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.ID != null && message.hasOwnProperty("ID")) + if (!$util.isInteger(message.ID)) + return "ID: integer expected"; + if (message.orderSN != null && message.hasOwnProperty("orderSN")) + if (!$util.isString(message.orderSN)) + return "orderSN: string expected"; + if (message.totalAmount != null && message.hasOwnProperty("totalAmount")) + if (typeof message.totalAmount !== "number") + return "totalAmount: number expected"; + return null; + }; + + /** + * Creates an Order message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof order.Order + * @static + * @param {Object.} object Plain object + * @returns {order.Order} Order + */ + Order.fromObject = function fromObject(object) { + if (object instanceof $root.order.Order) + return object; + var message = new $root.order.Order(); + if (object.ID != null) + message.ID = object.ID >>> 0; + if (object.orderSN != null) + message.orderSN = String(object.orderSN); + if (object.totalAmount != null) + message.totalAmount = Number(object.totalAmount); + return message; + }; + + /** + * Creates a plain object from an Order message. Also converts values to other types if specified. + * @function toObject + * @memberof order.Order + * @static + * @param {order.Order} message Order + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Order.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.ID = 0; + object.orderSN = ""; + object.totalAmount = 0; + } + if (message.ID != null && message.hasOwnProperty("ID")) + object.ID = message.ID; + if (message.orderSN != null && message.hasOwnProperty("orderSN")) + object.orderSN = message.orderSN; + if (message.totalAmount != null && message.hasOwnProperty("totalAmount")) + object.totalAmount = options.json && !isFinite(message.totalAmount) ? String(message.totalAmount) : message.totalAmount; + return object; + }; + + /** + * Converts this Order to JSON. + * @function toJSON + * @memberof order.Order + * @instance + * @returns {Object.} JSON object + */ + Order.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return Order; + })(); + + order.List = (function() { + + /** + * Properties of a List. + * @memberof order + * @interface IList + * @property {Array.} [orders] List orders + */ + + /** + * Constructs a new List. + * @memberof order + * @classdesc Represents a List. + * @constructor + * @param {order.IList=} [properties] Properties to set + */ + function List(properties) { + this.orders = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * List orders. + * @member {Array.}orders + * @memberof order.List + * @instance + */ + List.prototype.orders = $util.emptyArray; + + /** + * Creates a new List instance using the specified properties. + * @function create + * @memberof order.List + * @static + * @param {order.IList=} [properties] Properties to set + * @returns {order.List} List instance + */ + List.create = function create(properties) { + return new List(properties); + }; + + /** + * Encodes the specified List message. Does not implicitly {@link order.List.verify|verify} messages. + * @function encode + * @memberof order.List + * @static + * @param {order.IList} message List message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + List.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.orders != null && message.orders.length) + for (var i = 0; i < message.orders.length; ++i) + $root.order.List.OrderWithGoods.encode(message.orders[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified List message, length delimited. Does not implicitly {@link order.List.verify|verify} messages. + * @function encodeDelimited + * @memberof order.List + * @static + * @param {order.IList} message List message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + List.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a List message from the specified reader or buffer. + * @function decode + * @memberof order.List + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {order.List} List + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + List.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.order.List(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (!(message.orders && message.orders.length)) + message.orders = []; + message.orders.push($root.order.List.OrderWithGoods.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a List message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof order.List + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {order.List} List + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + List.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a List message. + * @function verify + * @memberof order.List + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + List.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.orders != null && message.hasOwnProperty("orders")) { + if (!Array.isArray(message.orders)) + return "orders: array expected"; + for (var i = 0; i < message.orders.length; ++i) { + var error = $root.order.List.OrderWithGoods.verify(message.orders[i]); + if (error) + return "orders." + error; + } + } + return null; + }; + + /** + * Creates a List message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof order.List + * @static + * @param {Object.} object Plain object + * @returns {order.List} List + */ + List.fromObject = function fromObject(object) { + if (object instanceof $root.order.List) + return object; + var message = new $root.order.List(); + if (object.orders) { + if (!Array.isArray(object.orders)) + throw TypeError(".order.List.orders: array expected"); + message.orders = []; + for (var i = 0; i < object.orders.length; ++i) { + if (typeof object.orders[i] !== "object") + throw TypeError(".order.List.orders: object expected"); + message.orders[i] = $root.order.List.OrderWithGoods.fromObject(object.orders[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a List message. Also converts values to other types if specified. + * @function toObject + * @memberof order.List + * @static + * @param {order.List} message List + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + List.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.orders = []; + if (message.orders && message.orders.length) { + object.orders = []; + for (var j = 0; j < message.orders.length; ++j) + object.orders[j] = $root.order.List.OrderWithGoods.toObject(message.orders[j], options); + } + return object; + }; + + /** + * Converts this List to JSON. + * @function toJSON + * @memberof order.List + * @instance + * @returns {Object.} JSON object + */ + List.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + List.OrderWithGoods = (function() { + + /** + * Properties of an OrderWithGoods. + * @memberof order.List + * @interface IOrderWithGoods + * @property {order.List.OrderWithGoods.IOrder} [order] OrderWithGoods order + * @property {Array.} [orderGoodses] OrderWithGoods orderGoodses + */ + + /** + * Constructs a new OrderWithGoods. + * @memberof order.List + * @classdesc Represents an OrderWithGoods. + * @constructor + * @param {order.List.IOrderWithGoods=} [properties] Properties to set + */ + function OrderWithGoods(properties) { + this.orderGoodses = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * OrderWithGoods order. + * @member {(order.List.OrderWithGoods.IOrder|null|undefined)}order + * @memberof order.List.OrderWithGoods + * @instance + */ + OrderWithGoods.prototype.order = null; + + /** + * OrderWithGoods orderGoodses. + * @member {Array.}orderGoodses + * @memberof order.List.OrderWithGoods + * @instance + */ + OrderWithGoods.prototype.orderGoodses = $util.emptyArray; + + /** + * Creates a new OrderWithGoods instance using the specified properties. + * @function create + * @memberof order.List.OrderWithGoods + * @static + * @param {order.List.IOrderWithGoods=} [properties] Properties to set + * @returns {order.List.OrderWithGoods} OrderWithGoods instance + */ + OrderWithGoods.create = function create(properties) { + return new OrderWithGoods(properties); + }; + + /** + * Encodes the specified OrderWithGoods message. Does not implicitly {@link order.List.OrderWithGoods.verify|verify} messages. + * @function encode + * @memberof order.List.OrderWithGoods + * @static + * @param {order.List.IOrderWithGoods} message OrderWithGoods message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + OrderWithGoods.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.order != null && message.hasOwnProperty("order")) + $root.order.List.OrderWithGoods.Order.encode(message.order, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.orderGoodses != null && message.orderGoodses.length) + for (var i = 0; i < message.orderGoodses.length; ++i) + $root.order.List.OrderWithGoods.OrderGoods.encode(message.orderGoodses[i], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified OrderWithGoods message, length delimited. Does not implicitly {@link order.List.OrderWithGoods.verify|verify} messages. + * @function encodeDelimited + * @memberof order.List.OrderWithGoods + * @static + * @param {order.List.IOrderWithGoods} message OrderWithGoods message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + OrderWithGoods.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an OrderWithGoods message from the specified reader or buffer. + * @function decode + * @memberof order.List.OrderWithGoods + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {order.List.OrderWithGoods} OrderWithGoods + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + OrderWithGoods.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.order.List.OrderWithGoods(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.order = $root.order.List.OrderWithGoods.Order.decode(reader, reader.uint32()); + break; + case 2: + if (!(message.orderGoodses && message.orderGoodses.length)) + message.orderGoodses = []; + message.orderGoodses.push($root.order.List.OrderWithGoods.OrderGoods.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an OrderWithGoods message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof order.List.OrderWithGoods + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {order.List.OrderWithGoods} OrderWithGoods + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + OrderWithGoods.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an OrderWithGoods message. + * @function verify + * @memberof order.List.OrderWithGoods + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + OrderWithGoods.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.order != null && message.hasOwnProperty("order")) { + var error = $root.order.List.OrderWithGoods.Order.verify(message.order); + if (error) + return "order." + error; + } + if (message.orderGoodses != null && message.hasOwnProperty("orderGoodses")) { + if (!Array.isArray(message.orderGoodses)) + return "orderGoodses: array expected"; + for (var i = 0; i < message.orderGoodses.length; ++i) { + error = $root.order.List.OrderWithGoods.OrderGoods.verify(message.orderGoodses[i]); + if (error) + return "orderGoodses." + error; + } + } + return null; + }; + + /** + * Creates an OrderWithGoods message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof order.List.OrderWithGoods + * @static + * @param {Object.} object Plain object + * @returns {order.List.OrderWithGoods} OrderWithGoods + */ + OrderWithGoods.fromObject = function fromObject(object) { + if (object instanceof $root.order.List.OrderWithGoods) + return object; + var message = new $root.order.List.OrderWithGoods(); + if (object.order != null) { + if (typeof object.order !== "object") + throw TypeError(".order.List.OrderWithGoods.order: object expected"); + message.order = $root.order.List.OrderWithGoods.Order.fromObject(object.order); + } + if (object.orderGoodses) { + if (!Array.isArray(object.orderGoodses)) + throw TypeError(".order.List.OrderWithGoods.orderGoodses: array expected"); + message.orderGoodses = []; + for (var i = 0; i < object.orderGoodses.length; ++i) { + if (typeof object.orderGoodses[i] !== "object") + throw TypeError(".order.List.OrderWithGoods.orderGoodses: object expected"); + message.orderGoodses[i] = $root.order.List.OrderWithGoods.OrderGoods.fromObject(object.orderGoodses[i]); + } + } + return message; + }; + + /** + * Creates a plain object from an OrderWithGoods message. Also converts values to other types if specified. + * @function toObject + * @memberof order.List.OrderWithGoods + * @static + * @param {order.List.OrderWithGoods} message OrderWithGoods + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + OrderWithGoods.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.orderGoodses = []; + if (options.defaults) + object.order = null; + if (message.order != null && message.hasOwnProperty("order")) + object.order = $root.order.List.OrderWithGoods.Order.toObject(message.order, options); + if (message.orderGoodses && message.orderGoodses.length) { + object.orderGoodses = []; + for (var j = 0; j < message.orderGoodses.length; ++j) + object.orderGoodses[j] = $root.order.List.OrderWithGoods.OrderGoods.toObject(message.orderGoodses[j], options); + } + return object; + }; + + /** + * Converts this OrderWithGoods to JSON. + * @function toJSON + * @memberof order.List.OrderWithGoods + * @instance + * @returns {Object.} JSON object + */ + OrderWithGoods.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + OrderWithGoods.Order = (function() { + + /** + * Properties of an Order. + * @memberof order.List.OrderWithGoods + * @interface IOrder + * @property {number} [ID] Order ID + * @property {number} [orderState] Order orderState + * @property {string} [orderSN] Order orderSN + * @property {number} [shippingState] Order shippingState + * @property {number} [payState] Order payState + * @property {number} [goodsPrice] Order goodsPrice + * @property {number} [shippingPrice] Order shippingPrice + * @property {number} [orderAmount] Order orderAmount + * @property {number} [totalAmount] Order totalAmount + * @property {number|Long} [addTime] Order addTime + * @property {string} [userNote] Order userNote + * @property {string} [adminNote] Order adminNote + */ + + /** + * Constructs a new Order. + * @memberof order.List.OrderWithGoods + * @classdesc Represents an Order. + * @constructor + * @param {order.List.OrderWithGoods.IOrder=} [properties] Properties to set + */ + function Order(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Order ID. + * @member {number}ID + * @memberof order.List.OrderWithGoods.Order + * @instance + */ + Order.prototype.ID = 0; + + /** + * Order orderState. + * @member {number}orderState + * @memberof order.List.OrderWithGoods.Order + * @instance + */ + Order.prototype.orderState = 0; + + /** + * Order orderSN. + * @member {string}orderSN + * @memberof order.List.OrderWithGoods.Order + * @instance + */ + Order.prototype.orderSN = ""; + + /** + * Order shippingState. + * @member {number}shippingState + * @memberof order.List.OrderWithGoods.Order + * @instance + */ + Order.prototype.shippingState = 0; + + /** + * Order payState. + * @member {number}payState + * @memberof order.List.OrderWithGoods.Order + * @instance + */ + Order.prototype.payState = 0; + + /** + * Order goodsPrice. + * @member {number}goodsPrice + * @memberof order.List.OrderWithGoods.Order + * @instance + */ + Order.prototype.goodsPrice = 0; + + /** + * Order shippingPrice. + * @member {number}shippingPrice + * @memberof order.List.OrderWithGoods.Order + * @instance + */ + Order.prototype.shippingPrice = 0; + + /** + * Order orderAmount. + * @member {number}orderAmount + * @memberof order.List.OrderWithGoods.Order + * @instance + */ + Order.prototype.orderAmount = 0; + + /** + * Order totalAmount. + * @member {number}totalAmount + * @memberof order.List.OrderWithGoods.Order + * @instance + */ + Order.prototype.totalAmount = 0; + + /** + * Order addTime. + * @member {number|Long}addTime + * @memberof order.List.OrderWithGoods.Order + * @instance + */ + Order.prototype.addTime = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * Order userNote. + * @member {string}userNote + * @memberof order.List.OrderWithGoods.Order + * @instance + */ + Order.prototype.userNote = ""; + + /** + * Order adminNote. + * @member {string}adminNote + * @memberof order.List.OrderWithGoods.Order + * @instance + */ + Order.prototype.adminNote = ""; + + /** + * Creates a new Order instance using the specified properties. + * @function create + * @memberof order.List.OrderWithGoods.Order + * @static + * @param {order.List.OrderWithGoods.IOrder=} [properties] Properties to set + * @returns {order.List.OrderWithGoods.Order} Order instance + */ + Order.create = function create(properties) { + return new Order(properties); + }; + + /** + * Encodes the specified Order message. Does not implicitly {@link order.List.OrderWithGoods.Order.verify|verify} messages. + * @function encode + * @memberof order.List.OrderWithGoods.Order + * @static + * @param {order.List.OrderWithGoods.IOrder} message Order message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Order.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.ID != null && message.hasOwnProperty("ID")) + writer.uint32(/* id 1, wireType 0 =*/8).uint32(message.ID); + if (message.orderState != null && message.hasOwnProperty("orderState")) + writer.uint32(/* id 2, wireType 0 =*/16).uint32(message.orderState); + if (message.orderSN != null && message.hasOwnProperty("orderSN")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.orderSN); + if (message.shippingState != null && message.hasOwnProperty("shippingState")) + writer.uint32(/* id 4, wireType 0 =*/32).uint32(message.shippingState); + if (message.payState != null && message.hasOwnProperty("payState")) + writer.uint32(/* id 5, wireType 0 =*/40).uint32(message.payState); + if (message.goodsPrice != null && message.hasOwnProperty("goodsPrice")) + writer.uint32(/* id 6, wireType 5 =*/53).float(message.goodsPrice); + if (message.shippingPrice != null && message.hasOwnProperty("shippingPrice")) + writer.uint32(/* id 7, wireType 5 =*/61).float(message.shippingPrice); + if (message.orderAmount != null && message.hasOwnProperty("orderAmount")) + writer.uint32(/* id 8, wireType 5 =*/69).float(message.orderAmount); + if (message.totalAmount != null && message.hasOwnProperty("totalAmount")) + writer.uint32(/* id 9, wireType 5 =*/77).float(message.totalAmount); + if (message.addTime != null && message.hasOwnProperty("addTime")) + writer.uint32(/* id 10, wireType 0 =*/80).int64(message.addTime); + if (message.userNote != null && message.hasOwnProperty("userNote")) + writer.uint32(/* id 11, wireType 2 =*/90).string(message.userNote); + if (message.adminNote != null && message.hasOwnProperty("adminNote")) + writer.uint32(/* id 12, wireType 2 =*/98).string(message.adminNote); + return writer; + }; + + /** + * Encodes the specified Order message, length delimited. Does not implicitly {@link order.List.OrderWithGoods.Order.verify|verify} messages. + * @function encodeDelimited + * @memberof order.List.OrderWithGoods.Order + * @static + * @param {order.List.OrderWithGoods.IOrder} message Order message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Order.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an Order message from the specified reader or buffer. + * @function decode + * @memberof order.List.OrderWithGoods.Order + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {order.List.OrderWithGoods.Order} Order + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Order.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.order.List.OrderWithGoods.Order(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.ID = reader.uint32(); + break; + case 2: + message.orderState = reader.uint32(); + break; + case 3: + message.orderSN = reader.string(); + break; + case 4: + message.shippingState = reader.uint32(); + break; + case 5: + message.payState = reader.uint32(); + break; + case 6: + message.goodsPrice = reader.float(); + break; + case 7: + message.shippingPrice = reader.float(); + break; + case 8: + message.orderAmount = reader.float(); + break; + case 9: + message.totalAmount = reader.float(); + break; + case 10: + message.addTime = reader.int64(); + break; + case 11: + message.userNote = reader.string(); + break; + case 12: + message.adminNote = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an Order message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof order.List.OrderWithGoods.Order + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {order.List.OrderWithGoods.Order} Order + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Order.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an Order message. + * @function verify + * @memberof order.List.OrderWithGoods.Order + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Order.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.ID != null && message.hasOwnProperty("ID")) + if (!$util.isInteger(message.ID)) + return "ID: integer expected"; + if (message.orderState != null && message.hasOwnProperty("orderState")) + if (!$util.isInteger(message.orderState)) + return "orderState: integer expected"; + if (message.orderSN != null && message.hasOwnProperty("orderSN")) + if (!$util.isString(message.orderSN)) + return "orderSN: string expected"; + if (message.shippingState != null && message.hasOwnProperty("shippingState")) + if (!$util.isInteger(message.shippingState)) + return "shippingState: integer expected"; + if (message.payState != null && message.hasOwnProperty("payState")) + if (!$util.isInteger(message.payState)) + return "payState: integer expected"; + if (message.goodsPrice != null && message.hasOwnProperty("goodsPrice")) + if (typeof message.goodsPrice !== "number") + return "goodsPrice: number expected"; + if (message.shippingPrice != null && message.hasOwnProperty("shippingPrice")) + if (typeof message.shippingPrice !== "number") + return "shippingPrice: number expected"; + if (message.orderAmount != null && message.hasOwnProperty("orderAmount")) + if (typeof message.orderAmount !== "number") + return "orderAmount: number expected"; + if (message.totalAmount != null && message.hasOwnProperty("totalAmount")) + if (typeof message.totalAmount !== "number") + return "totalAmount: number expected"; + if (message.addTime != null && message.hasOwnProperty("addTime")) + if (!$util.isInteger(message.addTime) && !(message.addTime && $util.isInteger(message.addTime.low) && $util.isInteger(message.addTime.high))) + return "addTime: integer|Long expected"; + if (message.userNote != null && message.hasOwnProperty("userNote")) + if (!$util.isString(message.userNote)) + return "userNote: string expected"; + if (message.adminNote != null && message.hasOwnProperty("adminNote")) + if (!$util.isString(message.adminNote)) + return "adminNote: string expected"; + return null; + }; + + /** + * Creates an Order message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof order.List.OrderWithGoods.Order + * @static + * @param {Object.} object Plain object + * @returns {order.List.OrderWithGoods.Order} Order + */ + Order.fromObject = function fromObject(object) { + if (object instanceof $root.order.List.OrderWithGoods.Order) + return object; + var message = new $root.order.List.OrderWithGoods.Order(); + if (object.ID != null) + message.ID = object.ID >>> 0; + if (object.orderState != null) + message.orderState = object.orderState >>> 0; + if (object.orderSN != null) + message.orderSN = String(object.orderSN); + if (object.shippingState != null) + message.shippingState = object.shippingState >>> 0; + if (object.payState != null) + message.payState = object.payState >>> 0; + if (object.goodsPrice != null) + message.goodsPrice = Number(object.goodsPrice); + if (object.shippingPrice != null) + message.shippingPrice = Number(object.shippingPrice); + if (object.orderAmount != null) + message.orderAmount = Number(object.orderAmount); + if (object.totalAmount != null) + message.totalAmount = Number(object.totalAmount); + if (object.addTime != null) + if ($util.Long) + (message.addTime = $util.Long.fromValue(object.addTime)).unsigned = false; + else if (typeof object.addTime === "string") + message.addTime = parseInt(object.addTime, 10); + else if (typeof object.addTime === "number") + message.addTime = object.addTime; + else if (typeof object.addTime === "object") + message.addTime = new $util.LongBits(object.addTime.low >>> 0, object.addTime.high >>> 0).toNumber(); + if (object.userNote != null) + message.userNote = String(object.userNote); + if (object.adminNote != null) + message.adminNote = String(object.adminNote); + return message; + }; + + /** + * Creates a plain object from an Order message. Also converts values to other types if specified. + * @function toObject + * @memberof order.List.OrderWithGoods.Order + * @static + * @param {order.List.OrderWithGoods.Order} message Order + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Order.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.ID = 0; + object.orderState = 0; + object.orderSN = ""; + object.shippingState = 0; + object.payState = 0; + object.goodsPrice = 0; + object.shippingPrice = 0; + object.orderAmount = 0; + object.totalAmount = 0; + if ($util.Long) { + var long = new $util.Long(0, 0, false); + object.addTime = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.addTime = options.longs === String ? "0" : 0; + object.userNote = ""; + object.adminNote = ""; + } + if (message.ID != null && message.hasOwnProperty("ID")) + object.ID = message.ID; + if (message.orderState != null && message.hasOwnProperty("orderState")) + object.orderState = message.orderState; + if (message.orderSN != null && message.hasOwnProperty("orderSN")) + object.orderSN = message.orderSN; + if (message.shippingState != null && message.hasOwnProperty("shippingState")) + object.shippingState = message.shippingState; + if (message.payState != null && message.hasOwnProperty("payState")) + object.payState = message.payState; + if (message.goodsPrice != null && message.hasOwnProperty("goodsPrice")) + object.goodsPrice = options.json && !isFinite(message.goodsPrice) ? String(message.goodsPrice) : message.goodsPrice; + if (message.shippingPrice != null && message.hasOwnProperty("shippingPrice")) + object.shippingPrice = options.json && !isFinite(message.shippingPrice) ? String(message.shippingPrice) : message.shippingPrice; + if (message.orderAmount != null && message.hasOwnProperty("orderAmount")) + object.orderAmount = options.json && !isFinite(message.orderAmount) ? String(message.orderAmount) : message.orderAmount; + if (message.totalAmount != null && message.hasOwnProperty("totalAmount")) + object.totalAmount = options.json && !isFinite(message.totalAmount) ? String(message.totalAmount) : message.totalAmount; + if (message.addTime != null && message.hasOwnProperty("addTime")) + if (typeof message.addTime === "number") + object.addTime = options.longs === String ? String(message.addTime) : message.addTime; + else + object.addTime = options.longs === String ? $util.Long.prototype.toString.call(message.addTime) : options.longs === Number ? new $util.LongBits(message.addTime.low >>> 0, message.addTime.high >>> 0).toNumber() : message.addTime; + if (message.userNote != null && message.hasOwnProperty("userNote")) + object.userNote = message.userNote; + if (message.adminNote != null && message.hasOwnProperty("adminNote")) + object.adminNote = message.adminNote; + return object; + }; + + /** + * Converts this Order to JSON. + * @function toJSON + * @memberof order.List.OrderWithGoods.Order + * @instance + * @returns {Object.} JSON object + */ + Order.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return Order; + })(); + + OrderWithGoods.OrderGoods = (function() { + + /** + * Properties of an OrderGoods. + * @memberof order.List.OrderWithGoods + * @interface IOrderGoods + * @property {number} [ID] OrderGoods ID + * @property {number} [orderID] OrderGoods orderID + * @property {number} [goodsID] OrderGoods goodsID + * @property {string} [goodsName] OrderGoods goodsName + * @property {number} [goodsNum] OrderGoods goodsNum + * @property {number} [goodsPrice] OrderGoods goodsPrice + * @property {number} [costPrice] OrderGoods costPrice + * @property {string} [specKeyName] OrderGoods specKeyName + */ + + /** + * Constructs a new OrderGoods. + * @memberof order.List.OrderWithGoods + * @classdesc Represents an OrderGoods. + * @constructor + * @param {order.List.OrderWithGoods.IOrderGoods=} [properties] Properties to set + */ + function OrderGoods(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * OrderGoods ID. + * @member {number}ID + * @memberof order.List.OrderWithGoods.OrderGoods + * @instance + */ + OrderGoods.prototype.ID = 0; + + /** + * OrderGoods orderID. + * @member {number}orderID + * @memberof order.List.OrderWithGoods.OrderGoods + * @instance + */ + OrderGoods.prototype.orderID = 0; + + /** + * OrderGoods goodsID. + * @member {number}goodsID + * @memberof order.List.OrderWithGoods.OrderGoods + * @instance + */ + OrderGoods.prototype.goodsID = 0; + + /** + * OrderGoods goodsName. + * @member {string}goodsName + * @memberof order.List.OrderWithGoods.OrderGoods + * @instance + */ + OrderGoods.prototype.goodsName = ""; + + /** + * OrderGoods goodsNum. + * @member {number}goodsNum + * @memberof order.List.OrderWithGoods.OrderGoods + * @instance + */ + OrderGoods.prototype.goodsNum = 0; + + /** + * OrderGoods goodsPrice. + * @member {number}goodsPrice + * @memberof order.List.OrderWithGoods.OrderGoods + * @instance + */ + OrderGoods.prototype.goodsPrice = 0; + + /** + * OrderGoods costPrice. + * @member {number}costPrice + * @memberof order.List.OrderWithGoods.OrderGoods + * @instance + */ + OrderGoods.prototype.costPrice = 0; + + /** + * OrderGoods specKeyName. + * @member {string}specKeyName + * @memberof order.List.OrderWithGoods.OrderGoods + * @instance + */ + OrderGoods.prototype.specKeyName = ""; + + /** + * Creates a new OrderGoods instance using the specified properties. + * @function create + * @memberof order.List.OrderWithGoods.OrderGoods + * @static + * @param {order.List.OrderWithGoods.IOrderGoods=} [properties] Properties to set + * @returns {order.List.OrderWithGoods.OrderGoods} OrderGoods instance + */ + OrderGoods.create = function create(properties) { + return new OrderGoods(properties); + }; + + /** + * Encodes the specified OrderGoods message. Does not implicitly {@link order.List.OrderWithGoods.OrderGoods.verify|verify} messages. + * @function encode + * @memberof order.List.OrderWithGoods.OrderGoods + * @static + * @param {order.List.OrderWithGoods.IOrderGoods} message OrderGoods message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + OrderGoods.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.ID != null && message.hasOwnProperty("ID")) + writer.uint32(/* id 1, wireType 0 =*/8).uint32(message.ID); + if (message.orderID != null && message.hasOwnProperty("orderID")) + writer.uint32(/* id 2, wireType 0 =*/16).uint32(message.orderID); + if (message.goodsID != null && message.hasOwnProperty("goodsID")) + writer.uint32(/* id 3, wireType 0 =*/24).uint32(message.goodsID); + if (message.goodsName != null && message.hasOwnProperty("goodsName")) + writer.uint32(/* id 4, wireType 2 =*/34).string(message.goodsName); + if (message.goodsNum != null && message.hasOwnProperty("goodsNum")) + writer.uint32(/* id 5, wireType 0 =*/40).uint32(message.goodsNum); + if (message.goodsPrice != null && message.hasOwnProperty("goodsPrice")) + writer.uint32(/* id 6, wireType 5 =*/53).float(message.goodsPrice); + if (message.costPrice != null && message.hasOwnProperty("costPrice")) + writer.uint32(/* id 7, wireType 5 =*/61).float(message.costPrice); + if (message.specKeyName != null && message.hasOwnProperty("specKeyName")) + writer.uint32(/* id 8, wireType 2 =*/66).string(message.specKeyName); + return writer; + }; + + /** + * Encodes the specified OrderGoods message, length delimited. Does not implicitly {@link order.List.OrderWithGoods.OrderGoods.verify|verify} messages. + * @function encodeDelimited + * @memberof order.List.OrderWithGoods.OrderGoods + * @static + * @param {order.List.OrderWithGoods.IOrderGoods} message OrderGoods message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + OrderGoods.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an OrderGoods message from the specified reader or buffer. + * @function decode + * @memberof order.List.OrderWithGoods.OrderGoods + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {order.List.OrderWithGoods.OrderGoods} OrderGoods + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + OrderGoods.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.order.List.OrderWithGoods.OrderGoods(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.ID = reader.uint32(); + break; + case 2: + message.orderID = reader.uint32(); + break; + case 3: + message.goodsID = reader.uint32(); + break; + case 4: + message.goodsName = reader.string(); + break; + case 5: + message.goodsNum = reader.uint32(); + break; + case 6: + message.goodsPrice = reader.float(); + break; + case 7: + message.costPrice = reader.float(); + break; + case 8: + message.specKeyName = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an OrderGoods message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof order.List.OrderWithGoods.OrderGoods + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {order.List.OrderWithGoods.OrderGoods} OrderGoods + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + OrderGoods.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an OrderGoods message. + * @function verify + * @memberof order.List.OrderWithGoods.OrderGoods + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + OrderGoods.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.ID != null && message.hasOwnProperty("ID")) + if (!$util.isInteger(message.ID)) + return "ID: integer expected"; + if (message.orderID != null && message.hasOwnProperty("orderID")) + if (!$util.isInteger(message.orderID)) + return "orderID: integer expected"; + if (message.goodsID != null && message.hasOwnProperty("goodsID")) + if (!$util.isInteger(message.goodsID)) + return "goodsID: integer expected"; + if (message.goodsName != null && message.hasOwnProperty("goodsName")) + if (!$util.isString(message.goodsName)) + return "goodsName: string expected"; + if (message.goodsNum != null && message.hasOwnProperty("goodsNum")) + if (!$util.isInteger(message.goodsNum)) + return "goodsNum: integer expected"; + if (message.goodsPrice != null && message.hasOwnProperty("goodsPrice")) + if (typeof message.goodsPrice !== "number") + return "goodsPrice: number expected"; + if (message.costPrice != null && message.hasOwnProperty("costPrice")) + if (typeof message.costPrice !== "number") + return "costPrice: number expected"; + if (message.specKeyName != null && message.hasOwnProperty("specKeyName")) + if (!$util.isString(message.specKeyName)) + return "specKeyName: string expected"; + return null; + }; + + /** + * Creates an OrderGoods message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof order.List.OrderWithGoods.OrderGoods + * @static + * @param {Object.} object Plain object + * @returns {order.List.OrderWithGoods.OrderGoods} OrderGoods + */ + OrderGoods.fromObject = function fromObject(object) { + if (object instanceof $root.order.List.OrderWithGoods.OrderGoods) + return object; + var message = new $root.order.List.OrderWithGoods.OrderGoods(); + if (object.ID != null) + message.ID = object.ID >>> 0; + if (object.orderID != null) + message.orderID = object.orderID >>> 0; + if (object.goodsID != null) + message.goodsID = object.goodsID >>> 0; + if (object.goodsName != null) + message.goodsName = String(object.goodsName); + if (object.goodsNum != null) + message.goodsNum = object.goodsNum >>> 0; + if (object.goodsPrice != null) + message.goodsPrice = Number(object.goodsPrice); + if (object.costPrice != null) + message.costPrice = Number(object.costPrice); + if (object.specKeyName != null) + message.specKeyName = String(object.specKeyName); + return message; + }; + + /** + * Creates a plain object from an OrderGoods message. Also converts values to other types if specified. + * @function toObject + * @memberof order.List.OrderWithGoods.OrderGoods + * @static + * @param {order.List.OrderWithGoods.OrderGoods} message OrderGoods + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + OrderGoods.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.ID = 0; + object.orderID = 0; + object.goodsID = 0; + object.goodsName = ""; + object.goodsNum = 0; + object.goodsPrice = 0; + object.costPrice = 0; + object.specKeyName = ""; + } + if (message.ID != null && message.hasOwnProperty("ID")) + object.ID = message.ID; + if (message.orderID != null && message.hasOwnProperty("orderID")) + object.orderID = message.orderID; + if (message.goodsID != null && message.hasOwnProperty("goodsID")) + object.goodsID = message.goodsID; + if (message.goodsName != null && message.hasOwnProperty("goodsName")) + object.goodsName = message.goodsName; + if (message.goodsNum != null && message.hasOwnProperty("goodsNum")) + object.goodsNum = message.goodsNum; + if (message.goodsPrice != null && message.hasOwnProperty("goodsPrice")) + object.goodsPrice = options.json && !isFinite(message.goodsPrice) ? String(message.goodsPrice) : message.goodsPrice; + if (message.costPrice != null && message.hasOwnProperty("costPrice")) + object.costPrice = options.json && !isFinite(message.costPrice) ? String(message.costPrice) : message.costPrice; + if (message.specKeyName != null && message.hasOwnProperty("specKeyName")) + object.specKeyName = message.specKeyName; + return object; + }; + + /** + * Converts this OrderGoods to JSON. + * @function toJSON + * @memberof order.List.OrderWithGoods.OrderGoods + * @instance + * @returns {Object.} JSON object + */ + OrderGoods.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return OrderGoods; + })(); + + return OrderWithGoods; + })(); + + return List; + })(); + + return order; +})(); + +module.exports = $root;