作者 陈志颖
提交者 yangfu

feat:完善代码

正在显示 37 个修改的文件 包含 256 行增加266 行删除
1 version: v1 1 version: v1
2 kind: Attribute 2 kind: Attribute
3 metadata: 3 metadata:
4 - name: goodsDetail 4 + name: goodDetail
5 description: 商品详情 5 description: 商品详情
6 type: 6 type:
7 - schema: goodsDetail 7 + schema: goodDetail
1 version: v1 1 version: v1
2 kind: Attribute 2 kind: Attribute
3 metadata: 3 metadata:
4 - name: goodsDividend 4 + name: goodDividend
5 description: 商品分红支付信息 5 description: 商品分红支付信息
6 type: 6 type:
7 schema: dividend 7 schema: dividend
1 version: v1 1 version: v1
2 kind: Attribute 2 kind: Attribute
3 metadata: 3 metadata:
4 - name: goodsDividendStatus 4 + name: goodDividendStatus
5 description: 商品分红支付状态 5 description: 商品分红支付状态
6 type: 6 type:
7 primitive: int 7 primitive: int
1 version: v1 1 version: v1
2 kind: Attribute 2 kind: Attribute
3 metadata: 3 metadata:
4 - name: goodsId 4 + name: goodId
5 description: 商品id 5 description: 商品id
6 type: 6 type:
7 primitive: int64 7 primitive: int64
1 version: v1 1 version: v1
2 kind: Attribute 2 kind: Attribute
3 metadata: 3 metadata:
4 - name: goodsName 4 + name: goodName
5 description: 商品名称 5 description: 商品名称
6 type: 6 type:
7 primitive: string 7 primitive: string
1 version: v1 1 version: v1
2 kind: Attribute 2 kind: Attribute
3 metadata: 3 metadata:
4 - name: goodsNum 4 + name: goodNum
5 description: 预定的货品数量 5 description: 预定的货品数量
6 type: 6 type:
7 primitive: int 7 primitive: int
1 version: v1 1 version: v1
2 kind: Attribute 2 kind: Attribute
3 metadata: 3 metadata:
4 - name: goodsTotalPrice 4 + name: goodTotalPrice
5 description: 商品单价 5 description: 商品单价
6 type: 6 type:
7 primitive: float64 7 primitive: float64
1 version: v1 1 version: v1
2 kind: Attribute 2 kind: Attribute
3 metadata: 3 metadata:
4 - name: actualNumber 4 + name: actualNum
5 description: 调整后的实际货品数量 5 description: 调整后的实际货品数量
6 type: 6 type:
7 primitive: int 7 primitive: int
1 version: v1 1 version: v1
2 kind: Attribute 2 kind: Attribute
3 metadata: 3 metadata:
4 - name: goodsDetailId 4 + name: goodDetailId
5 description: 商品详情id 5 description: 商品详情id
6 type: 6 type:
7 primitive: int64 7 primitive: int64
@@ -4,4 +4,4 @@ metadata: @@ -4,4 +4,4 @@ metadata:
4 name: orderGoods 4 name: orderGoods
5 description: 订单货品 5 description: 订单货品
6 type: 6 type:
7 - array: goods 7 + array: good
1 version: v1 1 version: v1
2 kind: Schema 2 kind: Schema
3 metadata: 3 metadata:
4 - name: goods 4 + name: good
5 description: 订单商品实体 5 description: 订单商品实体
6 attributes: 6 attributes:
7 - - ref: goodsId 7 + - ref: goodId
8 required: true 8 required: true
9 - - ref: goodsNum 9 + - ref: goodNum
10 required: true 10 required: true
11 - - ref: goodsDividend 11 + - ref: goodDividend
12 required: true 12 required: true
13 - - ref: goodsDividendStatus 13 + - ref: goodDividendStatus
14 required: true 14 required: true
15 - - ref: goodsName 15 + - ref: goodName
16 required: true 16 required: true
17 - - ref: goodsTotalPrice 17 + - ref: goodTotalPrice
18 required: true 18 required: true
19 - ref: remarks 19 - ref: remarks
20 required: true 20 required: true
21 - ref: orderNo 21 - ref: orderNo
22 required: true 22 required: true
23 - - name: goodsDetail 23 + - name: goodDetail
24 required: true 24 required: true
25 - ref: createAt 25 - ref: createAt
26 required: true 26 required: true
1 version: v1 1 version: v1
2 kind: Schema 2 kind: Schema
3 metadata: 3 metadata:
4 - name: goodsDetail 4 + name: goodDetail
5 description: 商品详情值对象 5 description: 商品详情值对象
6 attributes: 6 attributes:
7 - - ref: goodsDetailId 7 + - ref: goodDetailId
8 required: true 8 required: true
9 - ref: adjustedNum 9 - ref: adjustedNum
10 required: true 10 required: true
@@ -10,7 +10,7 @@ metadata: @@ -10,7 +10,7 @@ metadata:
10 required: true 10 required: true
11 - ref: companyId 11 - ref: companyId
12 required: true 12 required: true
13 - - ref: partnerId 13 + - ref: userId
14 required: true 14 required: true
15 - ref: deliveryCode 15 - ref: deliveryCode
16 required: true 16 required: true
1 -version: v1  
2 -kind: Schema  
3 -metadata:  
4 - name: partner  
5 - description: 合伙人实体  
6 - attributes:  
7 - - ref: partnerId  
8 - required: true  
9 - - ref: cooperateTime  
10 - required: true  
11 - - ref: partnerCategory  
12 - required: true  
13 - - ref: partnerCategoryInfos  
14 - required: true  
15 - - ref: partnerInfo  
16 - required: true  
17 - - ref: salesman  
18 - required: true  
19 - - ref: status  
20 - required: true  
@@ -38,7 +38,7 @@ func CreateOrderRepository(options map[string]interface{}) (domain.OrderReposito @@ -38,7 +38,7 @@ func CreateOrderRepository(options map[string]interface{}) (domain.OrderReposito
38 return repository.NewOrderRepository(transactionContext) 38 return repository.NewOrderRepository(transactionContext)
39 } 39 }
40 40
41 -func CreateGoodsRepository(options map[string]interface{}) (domain.GoodsRepository, error) { 41 +func CreateGoodsRepository(options map[string]interface{}) (domain.GoodRepository, error) {
42 var transactionContext *pg.TransactionContext 42 var transactionContext *pg.TransactionContext
43 if value, ok := options["transactionContext"]; ok { 43 if value, ok := options["transactionContext"]; ok {
44 transactionContext = value.(*pg.TransactionContext) 44 transactionContext = value.(*pg.TransactionContext)
@@ -7,6 +7,8 @@ import ( @@ -7,6 +7,8 @@ import (
7 ) 7 )
8 8
9 type CreateOrderCommand struct { 9 type CreateOrderCommand struct {
  10 + // 订单ID
  11 + OrderId int64 `json:"orderId"`
10 // 订单编号 12 // 订单编号
11 OrderNo string `json:"orderNo" valid:"Required"` 13 OrderNo string `json:"orderNo" valid:"Required"`
12 // 公司Id 14 // 公司Id
@@ -15,16 +17,24 @@ type CreateOrderCommand struct { @@ -15,16 +17,24 @@ type CreateOrderCommand struct {
15 BuyerName string `json:"buyerName,omitempty"` 17 BuyerName string `json:"buyerName,omitempty"`
16 // 联系信息 18 // 联系信息
17 ContactInfo string `json:"contactInfo,omitempty"` 19 ContactInfo string `json:"contactInfo,omitempty"`
18 - // 货地址 20 + // 货地址
19 ShippingAddress string `json:"shippingAddress,omitempty"` 21 ShippingAddress string `json:"shippingAddress,omitempty"`
  22 + // 买家备注
  23 + Remarks string `json:"remarks,omitempty"`
20 // 订单商品总数 24 // 订单商品总数
21 OrderNum int64 `json:"orderNum" valid:"Required"` 25 OrderNum int64 `json:"orderNum" valid:"Required"`
22 // 订单总价 26 // 订单总价
23 TotalPrice float64 `json:"totalPrice" valid:"Required"` 27 TotalPrice float64 `json:"totalPrice" valid:"Required"`
  28 + // 订单合伙人ID
  29 + PartnerId int64 `json:"partnerId"`
  30 + // 订单状态
  31 + OrderStatus int `json:"orderStatus"`
  32 + // 订单类型
  33 + OrderType int `json:"orderType"`
24 } 34 }
25 35
26 func (createOrderCommand *CreateOrderCommand) Valid(validation *validation.Validation) { 36 func (createOrderCommand *CreateOrderCommand) Valid(validation *validation.Validation) {
27 - validation.SetError("CustomValid", "未实现的自定义认证") 37 + //validation.SetError("CustomValid", "未实现的自定义认证")
28 } 38 }
29 39
30 func (createOrderCommand *CreateOrderCommand) ValidateCommand() error { 40 func (createOrderCommand *CreateOrderCommand) ValidateCommand() error {
@@ -14,7 +14,7 @@ type DrawDividendsCommand struct { @@ -14,7 +14,7 @@ type DrawDividendsCommand struct {
14 } 14 }
15 15
16 func (drawDividendsCommand *DrawDividendsCommand) Valid(validation *validation.Validation) { 16 func (drawDividendsCommand *DrawDividendsCommand) Valid(validation *validation.Validation) {
17 - validation.SetError("CustomValid", "未实现的自定义认证") 17 + //validation.SetError("CustomValid", "未实现的自定义认证")
18 } 18 }
19 19
20 func (drawDividendsCommand *DrawDividendsCommand) ValidateCommand() error { 20 func (drawDividendsCommand *DrawDividendsCommand) ValidateCommand() error {
@@ -2,40 +2,16 @@ package command @@ -2,40 +2,16 @@ package command
2 2
3 import ( 3 import (
4 "fmt" 4 "fmt"
5 - "time"  
6 -  
7 "github.com/beego/beego/v2/core/validation" 5 "github.com/beego/beego/v2/core/validation"
8 ) 6 )
9 7
10 type ReturnGoodsCommand struct { 8 type ReturnGoodsCommand struct {
  9 + // 订单ID
  10 + OrderId int64 `json:"orderId" valid:"Required"`
11 // 订单号 11 // 订单号
12 OrderNo string `json:"orderNo" valid:"Required"` 12 OrderNo string `json:"orderNo" valid:"Required"`
13 - // 是否是公司负责人  
14 - IsPrincipal bool `json:"isPrincipal" valid:"Required"`  
15 // 统一用户id 13 // 统一用户id
16 Uid int64 `json:"uid" valid:"Required"` 14 Uid int64 `json:"uid" valid:"Required"`
17 - // 用户账号  
18 - UserAccount string `json:"userAccount" valid:"Required"`  
19 - // 用户头像URL  
20 - UserAvatarUrl string `json:"userAvatarUrl" valid:"Required"`  
21 - // 用户名称  
22 - UserName string `json:"userName" valid:"Required"`  
23 - // 邮件地址  
24 - Email string `json:"email" valid:"Required"`  
25 - // 性别  
26 - Gender int `json:"gender" valid:"Required"`  
27 - // 入职时间  
28 - EntryTime time.Time `json:"entryTime" valid:"Required"`  
29 - // 分机  
30 - Extension string `json:"extension" valid:"Required"`  
31 - // 工作地  
32 - Workplace string `json:"workplace" valid:"Required"`  
33 - // 私人电话  
34 - PrivateNumber string `json:"privateNumber" valid:"Required"`  
35 - // 工号  
36 - JobNumber string `json:"jobNumber" valid:"Required"`  
37 - // 公司id  
38 - CompanyId int64 `json:"companyId" valid:"Required"`  
39 } 15 }
40 16
41 func (returnGoodsCommand *ReturnGoodsCommand) Valid(validation *validation.Validation) { 17 func (returnGoodsCommand *ReturnGoodsCommand) Valid(validation *validation.Validation) {
@@ -9,10 +9,18 @@ import ( @@ -9,10 +9,18 @@ import (
9 type UpdateOrderCommand struct { 9 type UpdateOrderCommand struct {
10 // 订单id 10 // 订单id
11 OrderId int64 `json:"orderId" valid:"Required"` 11 OrderId int64 `json:"orderId" valid:"Required"`
  12 + // 发货地址
  13 + BuyerName string `json:"buyerName"`
  14 + // 订单商品总数
  15 + OrderNum string `json:"orderNum"`
  16 + // 订单总价
  17 + TotalPrice float64 `json:"totalPrice"`
  18 + // 收货地址
  19 + ShippingAddress string `json:"shippingAddress" valid:"omitempty"`
12 } 20 }
13 21
14 func (updateOrderCommand *UpdateOrderCommand) Valid(validation *validation.Validation) { 22 func (updateOrderCommand *UpdateOrderCommand) Valid(validation *validation.Validation) {
15 - validation.SetError("CustomValid", "未实现的自定义认证") 23 + //validation.SetError("CustomValid", "未实现的自定义认证")
16 } 24 }
17 25
18 func (updateOrderCommand *UpdateOrderCommand) ValidateCommand() error { 26 func (updateOrderCommand *UpdateOrderCommand) ValidateCommand() error {
@@ -8,4 +8,6 @@ type BuyerInfo struct { @@ -8,4 +8,6 @@ type BuyerInfo struct {
8 ContactInfo string `json:"contactInfo"` 8 ContactInfo string `json:"contactInfo"`
9 // 发货地址 9 // 发货地址
10 ShippingAddress string `json:"shippingAddress"` 10 ShippingAddress string `json:"shippingAddress"`
  11 + // 买家备注
  12 + Remarks string `json:"remarks"`
11 } 13 }
@@ -3,24 +3,25 @@ package domain @@ -3,24 +3,25 @@ package domain
3 import "time" 3 import "time"
4 4
5 // 订单商品实体 5 // 订单商品实体
6 -type Goods struct { 6 +type Good struct {
7 // 商品id 7 // 商品id
8 - GoodsId int64 `json:"goodsId"` 8 + GoodId int64 `json:"goodId"`
9 // 预定的货品数量 9 // 预定的货品数量
10 - GoodsNum int `json:"goodsNum"` 10 + GoodNum int `json:"goodNum"`
11 // 商品分红支付信息 11 // 商品分红支付信息
12 - GoodsDividend *Dividend `json:"goodsDividend"` 12 + GoodDividend *Dividend `json:"goodDividend"`
13 // 商品分红支付状态 13 // 商品分红支付状态
14 - GoodsDividendStatus int `json:"goodsDividendStatus"` 14 + GoodDividendStatus int `json:"goodDividendStatus"`
15 // 商品名称 15 // 商品名称
16 - GoodsName string `json:"goodsName"` 16 + GoodName string `json:"goodName"`
17 // 商品单价 17 // 商品单价
18 - GoodsTotalPrice float64 `json:"goodsTotalPrice"` 18 + GoodTotalPrice float64 `json:"goodTotalPrice"`
19 // 备注 19 // 备注
20 Remarks string `json:"remarks"` 20 Remarks string `json:"remarks"`
21 // 订单编号 21 // 订单编号
22 - OrderNo string `json:"orderNo"`  
23 - GoodsDetail string `json:"goodsDetail"` 22 + OrderNo string `json:"orderNo"`
  23 + // 商品详情
  24 + GoodDetail string `json:"goodDetail"`
24 // 创建时间 25 // 创建时间
25 CreateAt time.Time `json:"createAt"` 26 CreateAt time.Time `json:"createAt"`
26 // 更新时间 27 // 更新时间
@@ -29,80 +30,80 @@ type Goods struct { @@ -29,80 +30,80 @@ type Goods struct {
29 DeleteAt time.Time `json:"deleteAt"` 30 DeleteAt time.Time `json:"deleteAt"`
30 } 31 }
31 32
32 -type GoodsRepository interface {  
33 - Save(goods *Goods) (*Goods, error)  
34 - Remove(goods *Goods) (*Goods, error)  
35 - FindOne(queryOptions map[string]interface{}) (*Goods, error)  
36 - Find(queryOptions map[string]interface{}) (int64, []*Goods, error) 33 +type GoodRepository interface {
  34 + Save(good *Good) (*Good, error)
  35 + Remove(good *Good) (*Good, error)
  36 + FindOne(queryOptions map[string]interface{}) (*Good, error)
  37 + Find(queryOptions map[string]interface{}) (int64, []*Good, error)
37 } 38 }
38 39
39 -func (goods *Goods) Identify() interface{} {  
40 - if goods.GoodsId == 0 { 40 +func (good *Good) Identify() interface{} {
  41 + if good.GoodId == 0 {
41 return nil 42 return nil
42 } 43 }
43 - return goods.GoodsId 44 + return good.GoodId
44 } 45 }
45 46
46 -func (goods *Goods) Update(data map[string]interface{}) error {  
47 - if goodsId, ok := data["goodsId"]; ok {  
48 - goods.GoodsId = goodsId.(int64) 47 +func (good *Good) Update(data map[string]interface{}) error {
  48 + if goodId, ok := data["goodId"]; ok {
  49 + good.GoodId = goodId.(int64)
49 } 50 }
50 - if goodsNum, ok := data["goodsNum"]; ok {  
51 - goods.GoodsNum = goodsNum.(int) 51 + if goodNum, ok := data["goodNum"]; ok {
  52 + good.GoodNum = goodNum.(int)
52 } 53 }
53 if planBonus, ok := data["planBonus"]; ok { 54 if planBonus, ok := data["planBonus"]; ok {
54 - goods.GoodsDividend.PlanBonus = planBonus.(float64) 55 + good.GoodDividend.PlanBonus = planBonus.(float64)
55 } 56 }
56 if useBonus, ok := data["useBonus"]; ok { 57 if useBonus, ok := data["useBonus"]; ok {
57 - goods.GoodsDividend.UseBonus = useBonus.(float64) 58 + good.GoodDividend.UseBonus = useBonus.(float64)
58 } 59 }
59 if bonusHas, ok := data["bonusHas"]; ok { 60 if bonusHas, ok := data["bonusHas"]; ok {
60 - goods.GoodsDividend.BonusHas = bonusHas.(float64) 61 + good.GoodDividend.BonusHas = bonusHas.(float64)
61 } 62 }
62 if bonusNot, ok := data["bonusNot"]; ok { 63 if bonusNot, ok := data["bonusNot"]; ok {
63 - goods.GoodsDividend.BonusNot = bonusNot.(float64) 64 + good.GoodDividend.BonusNot = bonusNot.(float64)
64 } 65 }
65 if bonusExpense, ok := data["bonusExpense"]; ok { 66 if bonusExpense, ok := data["bonusExpense"]; ok {
66 - goods.GoodsDividend.BonusExpense = bonusExpense.(float64) 67 + good.GoodDividend.BonusExpense = bonusExpense.(float64)
67 } 68 }
68 if bonusStatus, ok := data["bonusStatus"]; ok { 69 if bonusStatus, ok := data["bonusStatus"]; ok {
69 - goods.GoodsDividend.BonusStatus = bonusStatus.(int) 70 + good.GoodDividend.BonusStatus = bonusStatus.(int)
70 } 71 }
71 if partnerBonusPercent, ok := data["partnerBonusPercent"]; ok { 72 if partnerBonusPercent, ok := data["partnerBonusPercent"]; ok {
72 - goods.GoodsDividend.PartnerBonusPercent = partnerBonusPercent.(float64) 73 + good.GoodDividend.PartnerBonusPercent = partnerBonusPercent.(float64)
73 } 74 }
74 if salesmanBonusPercent, ok := data["salesmanBonusPercent"]; ok { 75 if salesmanBonusPercent, ok := data["salesmanBonusPercent"]; ok {
75 - goods.GoodsDividend.SalesmanBonusPercent = salesmanBonusPercent.(float64) 76 + good.GoodDividend.SalesmanBonusPercent = salesmanBonusPercent.(float64)
76 } 77 }
77 if salesmanBonus, ok := data["salesmanBonus"]; ok { 78 if salesmanBonus, ok := data["salesmanBonus"]; ok {
78 - goods.GoodsDividend.SalesmanBonus = salesmanBonus.(float64) 79 + good.GoodDividend.SalesmanBonus = salesmanBonus.(float64)
79 } 80 }
80 - if goodsDividendStatus, ok := data["goodsDividendStatus"]; ok {  
81 - goods.GoodsDividendStatus = goodsDividendStatus.(int) 81 + if goodDividendStatus, ok := data["goodDividendStatus"]; ok {
  82 + good.GoodDividendStatus = goodDividendStatus.(int)
82 } 83 }
83 - if goodsName, ok := data["goodsName"]; ok {  
84 - goods.GoodsName = goodsName.(string) 84 + if goodName, ok := data["goodName"]; ok {
  85 + good.GoodName = goodName.(string)
85 } 86 }
86 - if goodsTotalPrice, ok := data["goodsTotalPrice"]; ok {  
87 - goods.GoodsTotalPrice = goodsTotalPrice.(float64) 87 + if goodTotalPrice, ok := data["goodTotalPrice"]; ok {
  88 + good.GoodTotalPrice = goodTotalPrice.(float64)
88 } 89 }
89 if remarks, ok := data["remarks"]; ok { 90 if remarks, ok := data["remarks"]; ok {
90 - goods.Remarks = remarks.(string) 91 + good.Remarks = remarks.(string)
91 } 92 }
92 if orderNo, ok := data["orderNo"]; ok { 93 if orderNo, ok := data["orderNo"]; ok {
93 - goods.OrderNo = orderNo.(string) 94 + good.OrderNo = orderNo.(string)
94 } 95 }
95 - if goodsDetail, ok := data["goodsDetail"]; ok {  
96 - goods.GoodsDetail = goodsDetail.(string) 96 + if goodDetail, ok := data["goodDetail"]; ok {
  97 + good.GoodDetail = goodDetail.(string)
97 } 98 }
98 if createAt, ok := data["createAt"]; ok { 99 if createAt, ok := data["createAt"]; ok {
99 - goods.CreateAt = createAt.(time.Time) 100 + good.CreateAt = createAt.(time.Time)
100 } 101 }
101 if updateAt, ok := data["updateAt"]; ok { 102 if updateAt, ok := data["updateAt"]; ok {
102 - goods.UpdateAt = updateAt.(time.Time) 103 + good.UpdateAt = updateAt.(time.Time)
103 } 104 }
104 if deleteAt, ok := data["deleteAt"]; ok { 105 if deleteAt, ok := data["deleteAt"]; ok {
105 - goods.DeleteAt = deleteAt.(time.Time) 106 + good.DeleteAt = deleteAt.(time.Time)
106 } 107 }
107 return nil 108 return nil
108 } 109 }
@@ -38,7 +38,7 @@ type Order struct { @@ -38,7 +38,7 @@ type Order struct {
38 // 发货时间 38 // 发货时间
39 DeliveryTime time.Time `json:"deliveryTime"` 39 DeliveryTime time.Time `json:"deliveryTime"`
40 // 是否关闭订单标志 40 // 是否关闭订单标志
41 - IsDisable int `json:"isDisable"` 41 + IsDisable bool `json:"isDisable"`
42 // 订单编号 42 // 订单编号
43 OrderNo string `json:"orderNo"` 43 OrderNo string `json:"orderNo"`
44 // 订单详情 44 // 订单详情
@@ -48,7 +48,7 @@ type Order struct { @@ -48,7 +48,7 @@ type Order struct {
48 // 订单分红支付状态 48 // 订单分红支付状态
49 OrderDividendStatus int `json:"orderDividendStatus"` 49 OrderDividendStatus int `json:"orderDividendStatus"`
50 // 订单货品 50 // 订单货品
51 - OrderGoods []*Goods `json:"orderGoods"` 51 + OrderGoods []*Good `json:"orderGoods"`
52 // 订单数据来源 52 // 订单数据来源
53 OrderSource *OrderSource `json:"orderSource"` 53 OrderSource *OrderSource `json:"orderSource"`
54 // 订单类型(1.实际订单;2.意向订单) 54 // 订单类型(1.实际订单;2.意向订单)
@@ -108,7 +108,7 @@ func (status *UnShippedStatus) Update(order *Order, data map[string]interface{}) @@ -108,7 +108,7 @@ func (status *UnShippedStatus) Update(order *Order, data map[string]interface{})
108 order.DeliveryCode = deliveryCode.(string) 108 order.DeliveryCode = deliveryCode.(string)
109 } 109 }
110 if isDisable, ok := data["isDisable"]; ok { 110 if isDisable, ok := data["isDisable"]; ok {
111 - order.IsDisable = isDisable.(int) 111 + order.IsDisable = isDisable.(bool)
112 } 112 }
113 if orderNo, ok := data["orderNo"]; ok { 113 if orderNo, ok := data["orderNo"]; ok {
114 order.OrderNo = orderNo.(string) 114 order.OrderNo = orderNo.(string)
@@ -162,7 +162,7 @@ func (status *UnShippedStatus) Update(order *Order, data map[string]interface{}) @@ -162,7 +162,7 @@ func (status *UnShippedStatus) Update(order *Order, data map[string]interface{})
162 order.OrderDividendStatus = orderDividendStatus.(int) 162 order.OrderDividendStatus = orderDividendStatus.(int)
163 } 163 }
164 if orderGoods, ok := data["orderGoods"]; ok { 164 if orderGoods, ok := data["orderGoods"]; ok {
165 - order.OrderGoods = orderGoods.([]*Goods) 165 + order.OrderGoods = orderGoods.([]*Good)
166 } 166 }
167 if dataSourceId, ok := data["dataSourceId"]; ok { 167 if dataSourceId, ok := data["dataSourceId"]; ok {
168 order.OrderSource.DataSourceId = dataSourceId.(int64) 168 order.OrderSource.DataSourceId = dataSourceId.(int64)
@@ -211,7 +211,7 @@ func (status *UnShippedStatus) Shipping(order *Order) error { @@ -211,7 +211,7 @@ func (status *UnShippedStatus) Shipping(order *Order) error {
211 return nil 211 return nil
212 } 212 }
213 213
214 -// 退货 214 +// 待发货订单不能退货
215 func (status *UnShippedStatus) Return(order *Order) error { 215 func (status *UnShippedStatus) Return(order *Order) error {
216 return fmt.Errorf("待发货订单不能退货") 216 return fmt.Errorf("待发货订单不能退货")
217 } 217 }
@@ -222,7 +222,7 @@ func (status *UnShippedStatus) Cancel(order *Order) error { @@ -222,7 +222,7 @@ func (status *UnShippedStatus) Cancel(order *Order) error {
222 return nil 222 return nil
223 } 223 }
224 224
225 -// 收货 225 +// 待发货订单不能收货
226 func (status *UnShippedStatus) Receive(order *Order) error { 226 func (status *UnShippedStatus) Receive(order *Order) error {
227 return fmt.Errorf("待发货订单不能收货") 227 return fmt.Errorf("待发货订单不能收货")
228 } 228 }
@@ -293,6 +293,7 @@ func (status *ReceivedStatus) Receive(order *Order) error { @@ -293,6 +293,7 @@ func (status *ReceivedStatus) Receive(order *Order) error {
293 293
294 // 关闭订单 294 // 关闭订单
295 func (status *ReceivedStatus) Close(order *Order) error { 295 func (status *ReceivedStatus) Close(order *Order) error {
  296 + order.IsDisable = true
296 order.CurrentStatus = &ClosedStatus{} 297 order.CurrentStatus = &ClosedStatus{}
297 return nil 298 return nil
298 } 299 }
@@ -327,6 +328,7 @@ func (status *ReturnedStatus) Receive(order *Order) error { @@ -327,6 +328,7 @@ func (status *ReturnedStatus) Receive(order *Order) error {
327 328
328 // 关闭已退货订单 329 // 关闭已退货订单
329 func (status *ReturnedStatus) Close(order *Order) error { 330 func (status *ReturnedStatus) Close(order *Order) error {
  331 + order.IsDisable = true
330 order.CurrentStatus = &ClosedStatus{} 332 order.CurrentStatus = &ClosedStatus{}
331 return nil 333 return nil
332 } 334 }
@@ -361,6 +363,7 @@ func (status *CanceledStatus) Receive(order *Order) error { @@ -361,6 +363,7 @@ func (status *CanceledStatus) Receive(order *Order) error {
361 363
362 // 关闭订单 364 // 关闭订单
363 func (status *CanceledStatus) Close(order *Order) error { 365 func (status *CanceledStatus) Close(order *Order) error {
  366 + order.IsDisable = true
364 order.CurrentStatus = &ClosedStatus{} 367 order.CurrentStatus = &ClosedStatus{}
365 return nil 368 return nil
366 } 369 }
@@ -425,6 +428,7 @@ func (status *CompletedStatus) Receive(order *Order) error { @@ -425,6 +428,7 @@ func (status *CompletedStatus) Receive(order *Order) error {
425 428
426 // 关闭已完成订单 429 // 关闭已完成订单
427 func (status *CompletedStatus) Close(order *Order) error { 430 func (status *CompletedStatus) Close(order *Order) error {
  431 + order.IsDisable = true
428 order.CurrentStatus = &ClosedStatus{} 432 order.CurrentStatus = &ClosedStatus{}
429 return nil 433 return nil
430 } 434 }
@@ -15,7 +15,7 @@ type PartnerInfo struct { @@ -15,7 +15,7 @@ type PartnerInfo struct {
15 // 合伙时间 15 // 合伙时间
16 CooperateTime time.Time `json:"cooperateTime"` 16 CooperateTime time.Time `json:"cooperateTime"`
17 // 业务员 17 // 业务员
18 - Salesmans []*Salesman `json:"salesmans"` 18 + Salesmen []*Salesman `json:"salesmen"`
19 // 合伙人类型 19 // 合伙人类型
20 - PartnerCategorys []*PartnerCategory `json:"partnerCategorys"` 20 + PartnerCategories []*PartnerCategory `json:"partnerCategories"`
21 } 21 }
@@ -29,7 +29,7 @@ func init() { @@ -29,7 +29,7 @@ func init() {
29 &models.Permission{}, 29 &models.Permission{},
30 &models.PartnerCategory{}, 30 &models.PartnerCategory{},
31 &models.UserAuth{}, 31 &models.UserAuth{},
32 - &models.Goods{}, 32 + &models.Good{},
33 &models.Order{}, 33 &models.Order{},
34 &models.User{}, 34 &models.User{},
35 &models.Company{}, 35 &models.Company{},
@@ -5,30 +5,30 @@ import ( @@ -5,30 +5,30 @@ import (
5 "time" 5 "time"
6 ) 6 )
7 7
8 -type Goods struct {  
9 - tableName string `pg:"goodss,alias:goods"` 8 +type Good struct {
  9 + tableName string `pg:"goods,alias:good"`
10 // 商品id 10 // 商品id
11 - GoodsId int64 11 + GoodId int64 `pg:",pk"`
12 // 预定的货品数量 12 // 预定的货品数量
13 - GoodsNum int 13 + GoodNum int
14 // 商品分红支付信息 14 // 商品分红支付信息
15 - GoodsDividend *domain.Dividend 15 + GoodDividend *domain.Dividend
16 // 商品分红支付状态 16 // 商品分红支付状态
17 - GoodsDividendStatus int 17 + GoodDividendStatus int
18 // 商品名称 18 // 商品名称
19 - GoodsName string 19 + GoodName string
20 // 商品单价 20 // 商品单价
21 - GoodsTotalPrice float64 21 + GoodTotalPrice float64
22 // 备注 22 // 备注
23 Remarks string 23 Remarks string
24 // 订单编号 24 // 订单编号
25 - OrderNo string 25 + OrderNo string
26 // 商品详情 26 // 商品详情
27 - GoodsDetail string 27 + GoodDetail string
28 // 创建时间 28 // 创建时间
29 CreateAt time.Time 29 CreateAt time.Time
30 // 更新时间 30 // 更新时间
31 UpdateAt time.Time 31 UpdateAt time.Time
32 // 删除时间 32 // 删除时间
33 - DeleteAt time.Time 33 + DeleteAt time.Time `pg:",soft_delete"`
34 } 34 }
@@ -8,7 +8,7 @@ import ( @@ -8,7 +8,7 @@ import (
8 type Order struct { 8 type Order struct {
9 tableName string `pg:"orders,alias:order"` 9 tableName string `pg:"orders,alias:order"`
10 // 订单id 10 // 订单id
11 - OrderId int64 11 + OrderId int64 `pg:",pk"`
12 // 买家信息 12 // 买家信息
13 Buyer *domain.BuyerInfo 13 Buyer *domain.BuyerInfo
14 // 公司Id 14 // 公司Id
@@ -18,7 +18,7 @@ type Order struct { @@ -18,7 +18,7 @@ type Order struct {
18 // 发货单号 18 // 发货单号
19 DeliveryCode string 19 DeliveryCode string
20 // 是否关闭订单标志 20 // 是否关闭订单标志
21 - IsDisable int 21 + IsDisable bool
22 // 订单编号 22 // 订单编号
23 OrderNo string 23 OrderNo string
24 // 订单详情 24 // 订单详情
@@ -28,7 +28,7 @@ type Order struct { @@ -28,7 +28,7 @@ type Order struct {
28 // 订单分红支付状态 28 // 订单分红支付状态
29 OrderDividendStatus int 29 OrderDividendStatus int
30 // 订单货品 30 // 订单货品
31 - OrderGoods []*domain.Goods 31 + OrderGoods []*domain.Good
32 // 订单数据来源 32 // 订单数据来源
33 OrderSource *domain.OrderSource 33 OrderSource *domain.OrderSource
34 // 订单类型(1.实际订单;2.意向订单) 34 // 订单类型(1.实际订单;2.意向订单)
@@ -46,5 +46,5 @@ type Order struct { @@ -46,5 +46,5 @@ type Order struct {
46 // 更新时间 46 // 更新时间
47 UpdateAt time.Time 47 UpdateAt time.Time
48 // 软删 48 // 软删
49 - DeleteAt time.Time 49 + DeleteAt time.Time `pg:",soft_delete"`
50 } 50 }
@@ -32,5 +32,5 @@ type User struct { @@ -32,5 +32,5 @@ type User struct {
32 // 更新时间 32 // 更新时间
33 UpdateAt time.Time 33 UpdateAt time.Time
34 // 删除时间 34 // 删除时间
35 - DeleteAt time.Time 35 + DeleteAt time.Time `pg:",soft_delete"`
36 } 36 }
  1 +package transform
  2 +
  3 +import (
  4 + "gitlab.fjmaimaimai.com/mmm-go-pp/partner01/pkg/domain"
  5 + "gitlab.fjmaimaimai.com/mmm-go-pp/partner01/pkg/infrastructure/pg/models"
  6 +)
  7 +
  8 +func TransformToGoodDomainModelFromPgModels(goodModel *models.Good) (*domain.Good, error) {
  9 + return &domain.Good{
  10 + GoodId: goodModel.GoodId,
  11 + GoodNum: goodModel.GoodNum,
  12 + GoodDividend: goodModel.GoodDividend,
  13 + GoodDividendStatus: goodModel.GoodDividendStatus,
  14 + GoodName: goodModel.GoodName,
  15 + GoodTotalPrice: goodModel.GoodTotalPrice,
  16 + Remarks: goodModel.Remarks,
  17 + OrderNo: goodModel.OrderNo,
  18 + GoodDetail: goodModel.GoodDetail,
  19 + CreateAt: goodModel.CreateAt,
  20 + UpdateAt: goodModel.UpdateAt,
  21 + DeleteAt: goodModel.DeleteAt,
  22 + }, nil
  23 +}
1 -package transform  
2 -  
3 -import (  
4 - "gitlab.fjmaimaimai.com/mmm-go-pp/partner01/pkg/domain"  
5 - "gitlab.fjmaimaimai.com/mmm-go-pp/partner01/pkg/infrastructure/pg/models"  
6 -)  
7 -  
8 -func TransformToGoodsDomainModelFromPgModels(goodsModel *models.Goods) (*domain.Goods, error) {  
9 - return &domain.Goods{  
10 - GoodsId: goodsModel.GoodsId,  
11 - GoodsNum: goodsModel.GoodsNum,  
12 - GoodsDividend: goodsModel.GoodsDividend,  
13 - GoodsDividendStatus: goodsModel.GoodsDividendStatus,  
14 - GoodsName: goodsModel.GoodsName,  
15 - GoodsTotalPrice: goodsModel.GoodsTotalPrice,  
16 - Remarks: goodsModel.Remarks,  
17 - OrderNo: goodsModel.OrderNo,  
18 - GoodsDetail: goodsModel.GoodsDetail,  
19 - CreateAt: goodsModel.CreateAt,  
20 - UpdateAt: goodsModel.UpdateAt,  
21 - DeleteAt: goodsModel.DeleteAt,  
22 - }, nil  
23 -}  
@@ -12,11 +12,11 @@ import ( @@ -12,11 +12,11 @@ import (
12 "gitlab.fjmaimaimai.com/mmm-go-pp/partner01/pkg/infrastructure/pg/transform" 12 "gitlab.fjmaimaimai.com/mmm-go-pp/partner01/pkg/infrastructure/pg/transform"
13 ) 13 )
14 14
15 -type GoodsRepository struct { 15 +type GoodRepository struct {
16 transactionContext *pgTransaction.TransactionContext 16 transactionContext *pgTransaction.TransactionContext
17 } 17 }
18 18
19 -func (repository *GoodsRepository) nextIdentify() (int64, error) { 19 +func (repository *GoodRepository) nextIdentify() (int64, error) {
20 IdWorker, err := snowflake.NewIdWorker(1) 20 IdWorker, err := snowflake.NewIdWorker(1)
21 if err != nil { 21 if err != nil {
22 return 0, err 22 return 0, err
@@ -24,17 +24,17 @@ func (repository *GoodsRepository) nextIdentify() (int64, error) { @@ -24,17 +24,17 @@ func (repository *GoodsRepository) nextIdentify() (int64, error) {
24 id, err := IdWorker.NextId() 24 id, err := IdWorker.NextId()
25 return id, err 25 return id, err
26 } 26 }
27 -func (repository *GoodsRepository) Save(goods *domain.Goods) (*domain.Goods, error) { 27 +func (repository *GoodRepository) Save(good *domain.Good) (*domain.Good, error) {
28 sqlBuildFields := []string{ 28 sqlBuildFields := []string{
29 - "goods_id",  
30 - "goods_num",  
31 - "goods_dividend",  
32 - "goods_dividend_status",  
33 - "goods_name",  
34 - "goods_total_price", 29 + "good_id",
  30 + "good_num",
  31 + "good_dividend",
  32 + "good_dividend_status",
  33 + "good_name",
  34 + "good_total_price",
35 "remarks", 35 "remarks",
36 "order_no", 36 "order_no",
37 - "goods_detail", 37 + "good_detail",
38 "create_at", 38 "create_at",
39 "update_at", 39 "update_at",
40 "delete_at", 40 "delete_at",
@@ -45,94 +45,94 @@ func (repository *GoodsRepository) Save(goods *domain.Goods) (*domain.Goods, err @@ -45,94 +45,94 @@ func (repository *GoodsRepository) Save(goods *domain.Goods) (*domain.Goods, err
45 updateFields := sqlbuilder.RemoveSqlFields(sqlBuildFields, "goods_id") 45 updateFields := sqlbuilder.RemoveSqlFields(sqlBuildFields, "goods_id")
46 updateFieldsSnippet := sqlbuilder.SqlUpdateFieldsSnippet(updateFields) 46 updateFieldsSnippet := sqlbuilder.SqlUpdateFieldsSnippet(updateFields)
47 tx := repository.transactionContext.PgTx 47 tx := repository.transactionContext.PgTx
48 - if goods.Identify() == nil {  
49 - goodsId, err := repository.nextIdentify() 48 + if good.Identify() == nil {
  49 + goodId, err := repository.nextIdentify()
50 if err != nil { 50 if err != nil {
51 - return goods, err 51 + return good, err
52 } else { 52 } else {
53 - goods.GoodsId = goodsId 53 + good.GoodId = goodId
54 } 54 }
55 if _, err := tx.QueryOne( 55 if _, err := tx.QueryOne(
56 pg.Scan( 56 pg.Scan(
57 - &goods.GoodsId,  
58 - &goods.GoodsNum,  
59 - &goods.GoodsDividend,  
60 - &goods.GoodsDividendStatus,  
61 - &goods.GoodsName,  
62 - &goods.GoodsTotalPrice,  
63 - &goods.Remarks,  
64 - &goods.OrderNo,  
65 - &goods.GoodsDetail,  
66 - &goods.CreateAt,  
67 - &goods.UpdateAt,  
68 - &goods.DeleteAt, 57 + &good.GoodId,
  58 + &good.GoodNum,
  59 + &good.GoodDividend,
  60 + &good.GoodDividendStatus,
  61 + &good.GoodName,
  62 + &good.GoodTotalPrice,
  63 + &good.Remarks,
  64 + &good.OrderNo,
  65 + &good.GoodDetail,
  66 + &good.CreateAt,
  67 + &good.UpdateAt,
  68 + &good.DeleteAt,
69 ), 69 ),
70 - fmt.Sprintf("INSERT INTO goodss (%s) VALUES (%s) RETURNING %s", insertFieldsSnippet, insertPlaceHoldersSnippet, returningFieldsSnippet),  
71 - goods.GoodsId,  
72 - goods.GoodsNum,  
73 - goods.GoodsDividend,  
74 - goods.GoodsDividendStatus,  
75 - goods.GoodsName,  
76 - goods.GoodsTotalPrice,  
77 - goods.Remarks,  
78 - goods.OrderNo,  
79 - goods.GoodsDetail,  
80 - goods.CreateAt,  
81 - goods.UpdateAt,  
82 - goods.DeleteAt, 70 + fmt.Sprintf("INSERT INTO good (%s) VALUES (%s) RETURNING %s", insertFieldsSnippet, insertPlaceHoldersSnippet, returningFieldsSnippet),
  71 + good.GoodId,
  72 + good.GoodNum,
  73 + good.GoodDividend,
  74 + good.GoodDividendStatus,
  75 + good.GoodName,
  76 + good.GoodTotalPrice,
  77 + good.Remarks,
  78 + good.OrderNo,
  79 + good.GoodDetail,
  80 + good.CreateAt,
  81 + good.UpdateAt,
  82 + good.DeleteAt,
83 ); err != nil { 83 ); err != nil {
84 - return goods, err 84 + return good, err
85 } 85 }
86 } else { 86 } else {
87 if _, err := tx.QueryOne( 87 if _, err := tx.QueryOne(
88 pg.Scan( 88 pg.Scan(
89 - &goods.GoodsId,  
90 - &goods.GoodsNum,  
91 - &goods.GoodsDividend,  
92 - &goods.GoodsDividendStatus,  
93 - &goods.GoodsName,  
94 - &goods.GoodsTotalPrice,  
95 - &goods.Remarks,  
96 - &goods.OrderNo,  
97 - &goods.GoodsDetail,  
98 - &goods.CreateAt,  
99 - &goods.UpdateAt,  
100 - &goods.DeleteAt, 89 + &good.GoodId,
  90 + &good.GoodNum,
  91 + &good.GoodDividend,
  92 + &good.GoodDividendStatus,
  93 + &good.GoodName,
  94 + &good.GoodTotalPrice,
  95 + &good.Remarks,
  96 + &good.OrderNo,
  97 + &good.GoodDetail,
  98 + &good.CreateAt,
  99 + &good.UpdateAt,
  100 + &good.DeleteAt,
101 ), 101 ),
102 - fmt.Sprintf("UPDATE goodss SET %s WHERE goods_id=? RETURNING %s", updateFieldsSnippet, returningFieldsSnippet),  
103 - goods.GoodsId,  
104 - goods.GoodsNum,  
105 - goods.GoodsDividend,  
106 - goods.GoodsDividendStatus,  
107 - goods.GoodsName,  
108 - goods.GoodsTotalPrice,  
109 - goods.Remarks,  
110 - goods.OrderNo,  
111 - goods.GoodsDetail,  
112 - goods.CreateAt,  
113 - goods.UpdateAt,  
114 - goods.DeleteAt,  
115 - goods.Identify(), 102 + fmt.Sprintf("UPDATE good SET %s WHERE goods_id=? RETURNING %s", updateFieldsSnippet, returningFieldsSnippet),
  103 + good.GoodId,
  104 + good.GoodNum,
  105 + good.GoodDividend,
  106 + good.GoodDividendStatus,
  107 + good.GoodName,
  108 + good.GoodTotalPrice,
  109 + good.Remarks,
  110 + good.OrderNo,
  111 + good.GoodDetail,
  112 + good.CreateAt,
  113 + good.UpdateAt,
  114 + good.DeleteAt,
  115 + good.Identify(),
116 ); err != nil { 116 ); err != nil {
117 - return goods, err 117 + return good, err
118 } 118 }
119 } 119 }
120 - return goods, nil 120 + return good, nil
121 } 121 }
122 -func (repository *GoodsRepository) Remove(goods *domain.Goods) (*domain.Goods, error) { 122 +func (repository *GoodRepository) Remove(good *domain.Good) (*domain.Good, error) {
123 tx := repository.transactionContext.PgTx 123 tx := repository.transactionContext.PgTx
124 - goodsModel := new(models.Goods)  
125 - goodsModel.GoodsId = goods.Identify().(int64)  
126 - if _, err := tx.Model(goodsModel).WherePK().Delete(); err != nil {  
127 - return goods, err 124 + goodModel := new(models.Good)
  125 + goodModel.GoodId = good.Identify().(int64)
  126 + if _, err := tx.Model(goodModel).WherePK().Delete(); err != nil {
  127 + return good, err
128 } 128 }
129 - return goods, nil 129 + return good, nil
130 } 130 }
131 -func (repository *GoodsRepository) FindOne(queryOptions map[string]interface{}) (*domain.Goods, error) { 131 +func (repository *GoodRepository) FindOne(queryOptions map[string]interface{}) (*domain.Good, error) {
132 tx := repository.transactionContext.PgTx 132 tx := repository.transactionContext.PgTx
133 - goodsModel := new(models.Goods)  
134 - query := sqlbuilder.BuildQuery(tx.Model(goodsModel), queryOptions)  
135 - query.SetWhereByQueryOption("goods.goods_id = ?", "goodsId") 133 + goodModel := new(models.Good)
  134 + query := sqlbuilder.BuildQuery(tx.Model(goodModel), queryOptions)
  135 + query.SetWhereByQueryOption("good.goods_id = ?", "goodsId")
136 if err := query.First(); err != nil { 136 if err := query.First(); err != nil {
137 if err.Error() == "pg: no rows in result set" { 137 if err.Error() == "pg: no rows in result set" {
138 return nil, fmt.Errorf("没有此资源") 138 return nil, fmt.Errorf("没有此资源")
@@ -140,37 +140,37 @@ func (repository *GoodsRepository) FindOne(queryOptions map[string]interface{}) @@ -140,37 +140,37 @@ func (repository *GoodsRepository) FindOne(queryOptions map[string]interface{})
140 return nil, err 140 return nil, err
141 } 141 }
142 } 142 }
143 - if goodsModel.GoodsId == 0 { 143 + if goodModel.GoodId == 0 {
144 return nil, nil 144 return nil, nil
145 } else { 145 } else {
146 - return transform.TransformToGoodsDomainModelFromPgModels(goodsModel) 146 + return transform.TransformToGoodDomainModelFromPgModels(goodModel)
147 } 147 }
148 } 148 }
149 -func (repository *GoodsRepository) Find(queryOptions map[string]interface{}) (int64, []*domain.Goods, error) { 149 +func (repository *GoodRepository) Find(queryOptions map[string]interface{}) (int64, []*domain.Good, error) {
150 tx := repository.transactionContext.PgTx 150 tx := repository.transactionContext.PgTx
151 - var goodsModels []*models.Goods  
152 - goodss := make([]*domain.Goods, 0)  
153 - query := sqlbuilder.BuildQuery(tx.Model(&goodsModels), queryOptions) 151 + var goodModels []*models.Good
  152 + goods := make([]*domain.Good, 0)
  153 + query := sqlbuilder.BuildQuery(tx.Model(&goodModels), queryOptions)
154 query.SetOffsetAndLimit(20) 154 query.SetOffsetAndLimit(20)
155 query.SetOrderDirect("goods_id", "DESC") 155 query.SetOrderDirect("goods_id", "DESC")
156 if count, err := query.SelectAndCount(); err != nil { 156 if count, err := query.SelectAndCount(); err != nil {
157 - return 0, goodss, err 157 + return 0, goods, err
158 } else { 158 } else {
159 - for _, goodsModel := range goodsModels {  
160 - if goods, err := transform.TransformToGoodsDomainModelFromPgModels(goodsModel); err != nil {  
161 - return 0, goodss, err 159 + for _, goodModel := range goodModels {
  160 + if good, err := transform.TransformToGoodDomainModelFromPgModels(goodModel); err != nil {
  161 + return 0, goods, err
162 } else { 162 } else {
163 - goodss = append(goodss, goods) 163 + goods = append(goods, good)
164 } 164 }
165 } 165 }
166 - return int64(count), goodss, nil 166 + return int64(count), goods, nil
167 } 167 }
168 } 168 }
169 -func NewGoodsRepository(transactionContext *pgTransaction.TransactionContext) (*GoodsRepository, error) { 169 +func NewGoodsRepository(transactionContext *pgTransaction.TransactionContext) (*GoodRepository, error) {
170 if transactionContext == nil { 170 if transactionContext == nil {
171 return nil, fmt.Errorf("transactionContext参数不能为nil") 171 return nil, fmt.Errorf("transactionContext参数不能为nil")
172 } else { 172 } else {
173 - return &GoodsRepository{ 173 + return &GoodRepository{
174 transactionContext: transactionContext, 174 transactionContext: transactionContext,
175 }, nil 175 }, nil
176 } 176 }
@@ -14,7 +14,7 @@ type OrderController struct { @@ -14,7 +14,7 @@ type OrderController struct {
14 func (controller *OrderController) CreateOrder() { 14 func (controller *OrderController) CreateOrder() {
15 orderService := service.NewOrderService(nil) 15 orderService := service.NewOrderService(nil)
16 createOrderCommand := &command.CreateOrderCommand{} 16 createOrderCommand := &command.CreateOrderCommand{}
17 - controller.Unmarshal(createOrderCommand) 17 + _ = controller.Unmarshal(createOrderCommand)
18 data, err := orderService.CreateOrder(createOrderCommand) 18 data, err := orderService.CreateOrder(createOrderCommand)
19 controller.Response(data, err) 19 controller.Response(data, err)
20 } 20 }
@@ -16,12 +16,13 @@ var _ = FDescribe("创建订单增删改查", func() { @@ -16,12 +16,13 @@ var _ = FDescribe("创建订单增删改查", func() {
16 httpExpect := httpexpect.New(GinkgoT(), server.URL) 16 httpExpect := httpexpect.New(GinkgoT(), server.URL)
17 body := map[string]interface{}{ 17 body := map[string]interface{}{
18 "orderNo": "string", 18 "orderNo": "string",
19 - "companyId": "int64", 19 + "companyId": 1,
20 "buyerName": "string", 20 "buyerName": "string",
21 "contactInfo": "string", 21 "contactInfo": "string",
22 "shippingAddress": "string", 22 "shippingAddress": "string",
23 - "orderNum": "int64",  
24 - "totalPrice": "float64", 23 + "orderNum": 10,
  24 + "totalPrice": 10,
  25 + "partnerId": "1213",
25 } 26 }
26 httpExpect.POST("/orders/"). 27 httpExpect.POST("/orders/").
27 WithJSON(body). 28 WithJSON(body).
@@ -10,14 +10,21 @@ import ( @@ -10,14 +10,21 @@ import (
10 pG "gitlab.fjmaimaimai.com/mmm-go-pp/partner01/pkg/infrastructure/pg" 10 pG "gitlab.fjmaimaimai.com/mmm-go-pp/partner01/pkg/infrastructure/pg"
11 ) 11 )
12 12
13 -var _ = Describe("返回订单增删改查", func() { 13 +var _ = FDescribe("返回订单增删改查", func() {
14 var orderId int64 14 var orderId int64
15 BeforeEach(func() { 15 BeforeEach(func() {
16 - _, err := pG.DB.QueryOne( 16 + // 新增合伙人测试数据
  17 + _, err1 := pG.DB.QueryOne(
  18 + pg.Scan(),
  19 + "",
  20 + "")
  21 + Expect(err1).NotTo(HaveOccurred())
  22 + // 新增订单测试数据
  23 + _, err2 := pG.DB.QueryOne(
17 pg.Scan(&orderId), 24 pg.Scan(&orderId),
18 - "INSERT INTO orders (order_id, buyer, company_id, partner_id, delivery_code, is_disable, order_no, order_detail, order_dividend, order_dividend_status, order_goods, order_source, order_type, order_status, total_price, region_info, remarks, create_at, update_at, delete_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING order_id",  
19 - "testOrderId", "testBuyer", "testCompanyId", "testPartnerId", "testDeliveryCode", "testIsDisable", "testOrderNo", "testOrderDetail", "testOrderDividend", "testOrderDividendStatus", "testOrderGoods", "testOrderSource", "testOrderType", "testOrderStatus", "testTotalPrice", "testRegionInfo", "testRemarks", "testCreateAt", "testUpdateAt", "testDeleteAt")  
20 - Expect(err).NotTo(HaveOccurred()) 25 + "INSERT INTO orders ( buyer, company_id, partner_id, delivery_code, is_disable, order_no, order_detail, order_dividend, order_dividend_status, order_goods, order_source, order_type, order_status, total_price, region_info, remarks, create_at, update_at, delete_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING order_id",
  26 + "testBuyer", 1, "testPartnerId", "testDeliveryCode", false, "testOrderNo", "testOrderDetail", "testOrderDividend", "testOrderDividendStatus", "testOrderGoods", "testOrderSource", "testOrderType", "testOrderStatus", "testTotalPrice", "testRegionInfo", "testRemarks", "testCreateAt", "testUpdateAt", "testDeleteAt")
  27 + Expect(err2).NotTo(HaveOccurred())
21 }) 28 })
22 Describe("根据orderId参数返回订单实体", func() { 29 Describe("根据orderId参数返回订单实体", func() {
23 Context("传入有效的orderId", func() { 30 Context("传入有效的orderId", func() {