作者 唐旭辉

订单管理 数据 多公司支持完成

@@ -16,5 +16,6 @@ type CreateOrderCommand struct { @@ -16,5 +16,6 @@ type CreateOrderCommand struct {
16 //业务员抽成比例 16 //业务员抽成比例
17 SalesmanBonusPercent float64 `json:"salesmanBonusPercent"` 17 SalesmanBonusPercent float64 `json:"salesmanBonusPercent"`
18 //货品 18 //货品
19 - Goods []OrderGoodData `json:"goods"` 19 + Goods []OrderGoodData `json:"goods"`
  20 + CompanyId int64 `json:"companyId"`
20 } 21 }
@@ -5,4 +5,5 @@ type DisableOrderCommand struct { @@ -5,4 +5,5 @@ type DisableOrderCommand struct {
5 OrderId int64 `json:"orderId"` 5 OrderId int64 `json:"orderId"`
6 IsDisable int `json:"isDisable"` 6 IsDisable int `json:"isDisable"`
7 OrderType int `json:"orderType"` 7 OrderType int `json:"orderType"`
  8 + CompanyId int64 `json:"companyId"`
8 } 9 }
@@ -7,4 +7,5 @@ type OrderDeliveryCommand struct { @@ -7,4 +7,5 @@ type OrderDeliveryCommand struct {
7 DeliveryTime time.Time `json:"deliveryTime"` 7 DeliveryTime time.Time `json:"deliveryTime"`
8 DeliveryCode string `json:"deliveryCode"` 8 DeliveryCode string `json:"deliveryCode"`
9 Goods []OrderGoodData `json:"goods"` 9 Goods []OrderGoodData `json:"goods"`
  10 + CompanyId int64
10 } 11 }
@@ -4,6 +4,7 @@ package command @@ -4,6 +4,7 @@ package command
4 type UpdateGoodBouns struct { 4 type UpdateGoodBouns struct {
5 Id int64 `json:"id"` //订单id 5 Id int64 `json:"id"` //订单id
6 GoodBouns []GoodBouns `json:"goodBouns"` 6 GoodBouns []GoodBouns `json:"goodBouns"`
  7 + CompanyId int64 `json:"companyId"`
7 } 8 }
8 9
9 //GoodBoun 商品数量调整 10 //GoodBoun 商品数量调整
@@ -18,5 +18,6 @@ type UpdateOrderCommand struct { @@ -18,5 +18,6 @@ type UpdateOrderCommand struct {
18 //订单类型 18 //订单类型
19 OrderType int `json:"orderType"` 19 OrderType int `json:"orderType"`
20 //货品 20 //货品
21 - Goods []OrderGoodData `json:"goods"` 21 + Goods []OrderGoodData `json:"goods"`
  22 + CompanyId int64 `json:"companyId"`
22 } 23 }
@@ -2,5 +2,6 @@ package query @@ -2,5 +2,6 @@ package query
2 2
3 //GetOrderQuery 获取订单详情 3 //GetOrderQuery 获取订单详情
4 type GetOrderQuery struct { 4 type GetOrderQuery struct {
5 - OrderId int64 `json:"orderId"` 5 + OrderId int64 `json:"orderId"`
  6 + CompanyId int64 `json:"companyId"`
6 } 7 }
@@ -14,4 +14,5 @@ type ListOrderBaseQuery struct { @@ -14,4 +14,5 @@ type ListOrderBaseQuery struct {
14 OrderType int `json:"orderType"` 14 OrderType int `json:"orderType"`
15 //发货单号 15 //发货单号
16 DeliveryCode string `json:"deliveryCode"` 16 DeliveryCode string `json:"deliveryCode"`
  17 + CompanyId int64 `json:"companyId"`
17 } 18 }
@@ -46,6 +46,7 @@ func (service OrderInfoService) PageListOrderBase(listOrderQuery query.ListOrder @@ -46,6 +46,7 @@ func (service OrderInfoService) PageListOrderBase(listOrderQuery query.ListOrder
46 Limit: listOrderQuery.Limit, 46 Limit: listOrderQuery.Limit,
47 OrderType: listOrderQuery.OrderType, 47 OrderType: listOrderQuery.OrderType,
48 DeliveryCode: listOrderQuery.DeliveryCode, 48 DeliveryCode: listOrderQuery.DeliveryCode,
  49 + CompanyId: listOrderQuery.CompanyId,
49 } 50 }
50 orders, cnt, err = orderRepository.Find(query) 51 orders, cnt, err = orderRepository.Find(query)
51 if err != nil { 52 if err != nil {
@@ -79,7 +80,7 @@ func (service OrderInfoService) GetOrderDetail(getOrderQuery query.GetOrderQuery @@ -79,7 +80,7 @@ func (service OrderInfoService) GetOrderDetail(getOrderQuery query.GetOrderQuery
79 } 80 }
80 var ( 81 var (
81 orderBaseRepository domain.OrderBaseRepository 82 orderBaseRepository domain.OrderBaseRepository
82 - PartnerInfoRepository domain.PartnerInfoRepository 83 + partnerInfoRepository domain.PartnerInfoRepository
83 orderGoodRepository domain.OrderGoodRepository 84 orderGoodRepository domain.OrderGoodRepository
84 order *domain.OrderBase 85 order *domain.OrderBase
85 ) 86 )
@@ -89,14 +90,12 @@ func (service OrderInfoService) GetOrderDetail(getOrderQuery query.GetOrderQuery @@ -89,14 +90,12 @@ func (service OrderInfoService) GetOrderDetail(getOrderQuery query.GetOrderQuery
89 defer func() { 90 defer func() {
90 transactionContext.RollbackTransaction() 91 transactionContext.RollbackTransaction()
91 }() 92 }()
92 - if value, err := factory.CreateOrderBaseRepository(map[string]interface{}{ 93 + if orderBaseRepository, err = factory.CreateOrderBaseRepository(map[string]interface{}{
93 "transactionContext": transactionContext, 94 "transactionContext": transactionContext,
94 }); err != nil { 95 }); err != nil {
95 return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) 96 return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
96 - } else {  
97 - orderBaseRepository = value  
98 } 97 }
99 - if PartnerInfoRepository, err = factory.CreatePartnerInfoRepository(map[string]interface{}{ 98 + if partnerInfoRepository, err = factory.CreatePartnerInfoRepository(map[string]interface{}{
100 "transactionContext": transactionContext, 99 "transactionContext": transactionContext,
101 }); err != nil { 100 }); err != nil {
102 return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) 101 return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
@@ -107,7 +106,8 @@ func (service OrderInfoService) GetOrderDetail(getOrderQuery query.GetOrderQuery @@ -107,7 +106,8 @@ func (service OrderInfoService) GetOrderDetail(getOrderQuery query.GetOrderQuery
107 return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) 106 return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
108 } 107 }
109 order, err = orderBaseRepository.FindOne(domain.OrderBaseFindOneQuery{ 108 order, err = orderBaseRepository.FindOne(domain.OrderBaseFindOneQuery{
110 - OrderId: getOrderQuery.OrderId, 109 + OrderId: getOrderQuery.OrderId,
  110 + CompanyId: getOrderQuery.CompanyId,
111 }) 111 })
112 if err != nil { 112 if err != nil {
113 return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, fmt.Sprintf("获取订单数据失败:%s", err)) 113 return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, fmt.Sprintf("获取订单数据失败:%s", err))
@@ -117,13 +117,17 @@ func (service OrderInfoService) GetOrderDetail(getOrderQuery query.GetOrderQuery @@ -117,13 +117,17 @@ func (service OrderInfoService) GetOrderDetail(getOrderQuery query.GetOrderQuery
117 goods []domain.OrderGood 117 goods []domain.OrderGood
118 ) 118 )
119 119
120 - partnerData, err = PartnerInfoRepository.FindOne(domain.PartnerFindOneQuery{UserId: order.PartnerId}) 120 + partnerData, err = partnerInfoRepository.FindOne(domain.PartnerFindOneQuery{
  121 + UserId: order.PartnerId,
  122 + CompanyId: getOrderQuery.CompanyId,
  123 + })
121 if err != nil { 124 if err != nil {
122 return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, fmt.Sprintf("检索合伙人数据失败:%s", err)) 125 return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, fmt.Sprintf("检索合伙人数据失败:%s", err))
123 } 126 }
124 order.PartnerInfo = partnerData.Partner 127 order.PartnerInfo = partnerData.Partner
125 goods, _, err = orderGoodRepository.Find(domain.OrderGoodFindQuery{ 128 goods, _, err = orderGoodRepository.Find(domain.OrderGoodFindQuery{
126 - OrderId: order.Id, 129 + OrderId: order.Id,
  130 + CompanyId: getOrderQuery.CompanyId,
127 }) 131 })
128 if err != nil { 132 if err != nil {
129 return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, fmt.Sprintf("获取订单中的商品列表失败:%s", err)) 133 return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, fmt.Sprintf("获取订单中的商品列表失败:%s", err))
@@ -188,7 +192,7 @@ func (service OrderInfoService) CreateNewOrder(cmd command.CreateOrderCommand) ( @@ -188,7 +192,7 @@ func (service OrderInfoService) CreateNewOrder(cmd command.CreateOrderCommand) (
188 // } 192 // }
189 //检查delivery_code是否重复 193 //检查delivery_code是否重复
190 if len(cmd.DeliveryCode) > 0 { 194 if len(cmd.DeliveryCode) > 0 {
191 - if ok, err := orderBaseDao.DeliveryCodeExist(cmd.DeliveryCode); err != nil { 195 + if ok, err := orderBaseDao.DeliveryCodeExist(cmd.DeliveryCode, cmd.CompanyId); err != nil {
192 return nil, lib.ThrowError(lib.TRANSACTION_ERROR, err.Error()) 196 return nil, lib.ThrowError(lib.TRANSACTION_ERROR, err.Error())
193 } else if ok { 197 } else if ok {
194 return nil, lib.ThrowError(lib.BUSINESS_ERROR, "发货号已存在") 198 return nil, lib.ThrowError(lib.BUSINESS_ERROR, "发货号已存在")
@@ -206,6 +210,7 @@ func (service OrderInfoService) CreateNewOrder(cmd command.CreateOrderCommand) ( @@ -206,6 +210,7 @@ func (service OrderInfoService) CreateNewOrder(cmd command.CreateOrderCommand) (
206 PartnerId: cmd.PartnerId, 210 PartnerId: cmd.PartnerId,
207 PartnerInfo: partnerData.Partner, 211 PartnerInfo: partnerData.Partner,
208 SalesmanBonusPercent: cmd.SalesmanBonusPercent, 212 SalesmanBonusPercent: cmd.SalesmanBonusPercent,
  213 + CompanyId: cmd.CompanyId,
209 } 214 }
210 var orderGoods []domain.OrderGood 215 var orderGoods []domain.OrderGood
211 for _, good := range cmd.Goods { 216 for _, good := range cmd.Goods {
@@ -216,6 +221,7 @@ func (service OrderInfoService) CreateNewOrder(cmd command.CreateOrderCommand) ( @@ -216,6 +221,7 @@ func (service OrderInfoService) CreateNewOrder(cmd command.CreateOrderCommand) (
216 m.Price = good.Price 221 m.Price = good.Price
217 m.PartnerBonusPercent = good.PartnerBonusPercent 222 m.PartnerBonusPercent = good.PartnerBonusPercent
218 m.Remark = good.Remark 223 m.Remark = good.Remark
  224 + m.CompanyId = cmd.CompanyId
219 err = m.Compute() 225 err = m.Compute()
220 if err != nil { 226 if err != nil {
221 return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, fmt.Sprintf("核算订单中商品的数值失败:%s", err)) 227 return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, fmt.Sprintf("核算订单中商品的数值失败:%s", err))
@@ -251,7 +257,7 @@ func (service OrderInfoService) CreateNewOrder(cmd command.CreateOrderCommand) ( @@ -251,7 +257,7 @@ func (service OrderInfoService) CreateNewOrder(cmd command.CreateOrderCommand) (
251 } 257 }
252 258
253 //DeleteOrder 删除订单 259 //DeleteOrder 删除订单
254 -func (service OrderInfoService) DeleteOrder(orderId int64) error { 260 +func (service OrderInfoService) DeleteOrder(orderId int64, companyId int64) error {
255 var ( 261 var (
256 transactionContext, _ = factory.CreateTransactionContext(nil) 262 transactionContext, _ = factory.CreateTransactionContext(nil)
257 err error 263 err error
@@ -276,11 +282,11 @@ func (service OrderInfoService) DeleteOrder(orderId int64) error { @@ -276,11 +282,11 @@ func (service OrderInfoService) DeleteOrder(orderId int64) error {
276 }); err != nil { 282 }); err != nil {
277 return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) 283 return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
278 } 284 }
279 - err = orderBaseRepository.Remove(orderId) 285 + err = orderBaseRepository.Remove(orderId, companyId)
280 if err != nil { 286 if err != nil {
281 return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, fmt.Sprintf("删除订单数据失败:%s", err)) 287 return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, fmt.Sprintf("删除订单数据失败:%s", err))
282 } 288 }
283 - err = orderGoodRepository.Remove(orderId) 289 + err = orderGoodRepository.Remove(orderId, companyId)
284 if err != nil { 290 if err != nil {
285 return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, fmt.Sprintf("删除订单中商品数据失败:%s", err)) 291 return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, fmt.Sprintf("删除订单中商品数据失败:%s", err))
286 } 292 }
@@ -312,7 +318,9 @@ func (service OrderInfoService) UpdateOrderData(cmd command.UpdateOrderCommand) @@ -312,7 +318,9 @@ func (service OrderInfoService) UpdateOrderData(cmd command.UpdateOrderCommand)
312 return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) 318 return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
313 } 319 }
314 var partnerData *domain.PartnerInfo 320 var partnerData *domain.PartnerInfo
315 - partnerData, err = PartnerInfoRepository.FindOne(domain.PartnerFindOneQuery{UserId: cmd.PartnerId}) 321 + partnerData, err = PartnerInfoRepository.FindOne(domain.PartnerFindOneQuery{
  322 + UserId: cmd.PartnerId, CompanyId: cmd.CompanyId,
  323 + })
316 if err != nil { 324 if err != nil {
317 return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, fmt.Sprintf("检索合伙人数据失败")) 325 return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, fmt.Sprintf("检索合伙人数据失败"))
318 } 326 }
@@ -337,7 +345,8 @@ func (service OrderInfoService) UpdateOrderData(cmd command.UpdateOrderCommand) @@ -337,7 +345,8 @@ func (service OrderInfoService) UpdateOrderData(cmd command.UpdateOrderCommand)
337 } 345 }
338 //获取旧的订单 346 //获取旧的订单
339 oldOrderData, err = orderBaseRepository.FindOne(domain.OrderBaseFindOneQuery{ 347 oldOrderData, err = orderBaseRepository.FindOne(domain.OrderBaseFindOneQuery{
340 - OrderId: cmd.Id, 348 + OrderId: cmd.Id,
  349 + CompanyId: cmd.CompanyId,
341 }) 350 })
342 if err != nil { 351 if err != nil {
343 return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, fmt.Sprintf("未找到指定的订单:%s", err)) 352 return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, fmt.Sprintf("未找到指定的订单:%s", err))
@@ -359,7 +368,7 @@ func (service OrderInfoService) UpdateOrderData(cmd command.UpdateOrderCommand) @@ -359,7 +368,7 @@ func (service OrderInfoService) UpdateOrderData(cmd command.UpdateOrderCommand)
359 // } 368 // }
360 //检查delivery_code是否重复 369 //检查delivery_code是否重复
361 if len(cmd.DeliveryCode) > 0 { 370 if len(cmd.DeliveryCode) > 0 {
362 - if ok, err := orderBaseDao.DeliveryCodeExist(cmd.DeliveryCode, cmd.Id); err != nil { 371 + if ok, err := orderBaseDao.DeliveryCodeExist(cmd.DeliveryCode, cmd.CompanyId, cmd.Id); err != nil {
363 return nil, lib.ThrowError(lib.TRANSACTION_ERROR, err.Error()) 372 return nil, lib.ThrowError(lib.TRANSACTION_ERROR, err.Error())
364 } else if ok { 373 } else if ok {
365 return nil, lib.ThrowError(lib.BUSINESS_ERROR, "发货号已存在") 374 return nil, lib.ThrowError(lib.BUSINESS_ERROR, "发货号已存在")
@@ -367,7 +376,8 @@ func (service OrderInfoService) UpdateOrderData(cmd command.UpdateOrderCommand) @@ -367,7 +376,8 @@ func (service OrderInfoService) UpdateOrderData(cmd command.UpdateOrderCommand)
367 } 376 }
368 //获取旧的订单中的商品 377 //获取旧的订单中的商品
369 oldOrderGoods, _, err = orderGoodRepository.Find(domain.OrderGoodFindQuery{ 378 oldOrderGoods, _, err = orderGoodRepository.Find(domain.OrderGoodFindQuery{
370 - OrderId: cmd.Id, 379 + OrderId: cmd.Id,
  380 + CompanyId: cmd.CompanyId,
371 }) 381 })
372 if err != nil { 382 if err != nil {
373 return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, fmt.Sprintf("未找到指定的订单中的商品列表失败:%s", err)) 383 return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, fmt.Sprintf("未找到指定的订单中的商品列表失败:%s", err))
@@ -380,6 +390,7 @@ func (service OrderInfoService) UpdateOrderData(cmd command.UpdateOrderCommand) @@ -380,6 +390,7 @@ func (service OrderInfoService) UpdateOrderData(cmd command.UpdateOrderCommand)
380 m.Price = good.Price 390 m.Price = good.Price
381 m.PartnerBonusPercent = good.PartnerBonusPercent 391 m.PartnerBonusPercent = good.PartnerBonusPercent
382 m.Remark = good.Remark 392 m.Remark = good.Remark
  393 + m.CompanyId = cmd.CompanyId
383 err = m.Compute() 394 err = m.Compute()
384 if err != nil { 395 if err != nil {
385 return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, fmt.Sprintf("核算订单中商品的数值失败:%s", err)) 396 return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, fmt.Sprintf("核算订单中商品的数值失败:%s", err))
@@ -414,7 +425,7 @@ func (service OrderInfoService) UpdateOrderData(cmd command.UpdateOrderCommand) @@ -414,7 +425,7 @@ func (service OrderInfoService) UpdateOrderData(cmd command.UpdateOrderCommand)
414 oldOrderData.Goods = newOrderGoods 425 oldOrderData.Goods = newOrderGoods
415 //删不需要的订单总不需要的商品 426 //删不需要的订单总不需要的商品
416 delGoods = service.deleteOldOrderGoods(newOrderGoods, oldOrderGoods) 427 delGoods = service.deleteOldOrderGoods(newOrderGoods, oldOrderGoods)
417 - err = orderGoodRepository.Remove(oldOrderData.Id, delGoods...) 428 + err = orderGoodRepository.Remove(oldOrderData.Id, cmd.CompanyId, delGoods...)
418 if err != nil { 429 if err != nil {
419 return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, fmt.Sprintf("删除订单中的商品数据失败:%s", err)) 430 return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, fmt.Sprintf("删除订单中的商品数据失败:%s", err))
420 } 431 }
@@ -474,7 +485,8 @@ func (service OrderInfoService) Delivery(cmd command.OrderDeliveryCommand) error @@ -474,7 +485,8 @@ func (service OrderInfoService) Delivery(cmd command.OrderDeliveryCommand) error
474 } 485 }
475 //获取旧的订单 486 //获取旧的订单
476 oldOrderData, err = orderBaseRepository.FindOne(domain.OrderBaseFindOneQuery{ 487 oldOrderData, err = orderBaseRepository.FindOne(domain.OrderBaseFindOneQuery{
477 - OrderId: cmd.OrderId, 488 + CompanyId: cmd.CompanyId,
  489 + OrderId: cmd.OrderId,
478 }) 490 })
479 if err != nil { 491 if err != nil {
480 return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, fmt.Sprintf("未找到指定的订单:%s", err)) 492 return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, fmt.Sprintf("未找到指定的订单:%s", err))
@@ -495,7 +507,8 @@ func (service OrderInfoService) Delivery(cmd command.OrderDeliveryCommand) error @@ -495,7 +507,8 @@ func (service OrderInfoService) Delivery(cmd command.OrderDeliveryCommand) error
495 } 507 }
496 //获取旧的订单中的商品 508 //获取旧的订单中的商品
497 oldOrderGoods, _, err = orderGoodRepository.Find(domain.OrderGoodFindQuery{ 509 oldOrderGoods, _, err = orderGoodRepository.Find(domain.OrderGoodFindQuery{
498 - OrderId: cmd.OrderId, 510 + OrderId: cmd.OrderId,
  511 + CompanyId: cmd.CompanyId,
499 }) 512 })
500 if err != nil { 513 if err != nil {
501 return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, fmt.Sprintf("未找到指定的订单中的商品列表失败:%s", err)) 514 return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, fmt.Sprintf("未找到指定的订单中的商品列表失败:%s", err))
@@ -567,7 +580,8 @@ func (service OrderInfoService) DisableOrEnable(cmd command.DisableOrderCommand) @@ -567,7 +580,8 @@ func (service OrderInfoService) DisableOrEnable(cmd command.DisableOrderCommand)
567 } 580 }
568 //获取旧的订单 581 //获取旧的订单
569 oldOrderData, err = orderBaseRepository.FindOne(domain.OrderBaseFindOneQuery{ 582 oldOrderData, err = orderBaseRepository.FindOne(domain.OrderBaseFindOneQuery{
570 - OrderId: cmd.OrderId, 583 + OrderId: cmd.OrderId,
  584 + CompanyId: cmd.CompanyId,
571 }) 585 })
572 if err != nil { 586 if err != nil {
573 return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, fmt.Sprintf("未找到指定的订单:%s", err)) 587 return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, fmt.Sprintf("未找到指定的订单:%s", err))
@@ -617,7 +631,8 @@ func (service OrderInfoService) UpdateGoodBouns(cmd command.UpdateGoodBouns) err @@ -617,7 +631,8 @@ func (service OrderInfoService) UpdateGoodBouns(cmd command.UpdateGoodBouns) err
617 } 631 }
618 //获取旧的订单 632 //获取旧的订单
619 oldOrderData, err = orderBaseRepository.FindOne(domain.OrderBaseFindOneQuery{ 633 oldOrderData, err = orderBaseRepository.FindOne(domain.OrderBaseFindOneQuery{
620 - OrderId: cmd.Id, 634 + OrderId: cmd.Id,
  635 + CompanyId: cmd.CompanyId,
621 }) 636 })
622 if err != nil { 637 if err != nil {
623 return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, fmt.Sprintf("未找到指定的订单:%s", err)) 638 return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, fmt.Sprintf("未找到指定的订单:%s", err))
@@ -59,6 +59,8 @@ type OrderBase struct { @@ -59,6 +59,8 @@ type OrderBase struct {
59 IsDisable int `json:"isDisable"` 59 IsDisable int `json:"isDisable"`
60 //分红支付状态 60 //分红支付状态
61 BonusStatus int `json:"bonusStatus"` 61 BonusStatus int `json:"bonusStatus"`
  62 + //公司
  63 + CompanyId int64 `json:"companyId"`
62 } 64 }
63 65
64 type OrderCompute struct { 66 type OrderCompute struct {
@@ -178,7 +180,8 @@ func (order *OrderBase) Compute() error { @@ -178,7 +180,8 @@ func (order *OrderBase) Compute() error {
178 } 180 }
179 181
180 type OrderBaseFindOneQuery struct { 182 type OrderBaseFindOneQuery struct {
181 - OrderId int64 183 + OrderId int64
  184 + CompanyId int64
182 } 185 }
183 186
184 type OrderBaseFindQuery struct { 187 type OrderBaseFindQuery struct {
@@ -188,11 +191,12 @@ type OrderBaseFindQuery struct { @@ -188,11 +191,12 @@ type OrderBaseFindQuery struct {
188 Offset int 191 Offset int
189 Limit int 192 Limit int
190 OrderType int 193 OrderType int
  194 + CompanyId int64
191 } 195 }
192 196
193 type OrderBaseRepository interface { 197 type OrderBaseRepository interface {
194 Save(order *OrderBase) error 198 Save(order *OrderBase) error
195 FindOne(qureyOptions OrderBaseFindOneQuery) (*OrderBase, error) 199 FindOne(qureyOptions OrderBaseFindOneQuery) (*OrderBase, error)
196 Find(queryOptions OrderBaseFindQuery) ([]OrderBase, int, error) 200 Find(queryOptions OrderBaseFindQuery) ([]OrderBase, int, error)
197 - Remove(id int64) error 201 + Remove(id int64, companyId int64) error
198 } 202 }
@@ -48,6 +48,8 @@ type OrderGood struct { @@ -48,6 +48,8 @@ type OrderGood struct {
48 CurrentBonusStatus OrderGoodBonusStatus `json:"-"` 48 CurrentBonusStatus OrderGoodBonusStatus `json:"-"`
49 ///核算订单相关数据 49 ///核算订单相关数据
50 GoodCompute GoodCompute `json:"goodCompute"` 50 GoodCompute GoodCompute `json:"goodCompute"`
  51 + //公司
  52 + CompanyId int64
51 } 53 }
52 54
53 type GoodCompute struct { 55 type GoodCompute struct {
@@ -170,13 +172,14 @@ func (good *OrderGood) Compute() error { @@ -170,13 +172,14 @@ func (good *OrderGood) Compute() error {
170 } 172 }
171 173
172 type OrderGoodFindQuery struct { 174 type OrderGoodFindQuery struct {
173 - OrderId int64  
174 - Offset int  
175 - Limit int 175 + OrderId int64
  176 + Offset int
  177 + Limit int
  178 + CompanyId int64
176 } 179 }
177 180
178 type OrderGoodRepository interface { 181 type OrderGoodRepository interface {
179 Save(order []OrderGood) error 182 Save(order []OrderGood) error
180 Find(queryOptions OrderGoodFindQuery) ([]OrderGood, int, error) 183 Find(queryOptions OrderGoodFindQuery) ([]OrderGood, int, error)
181 - Remove(orderid int64, ids ...int64) error 184 + Remove(orderid int64, companyId int64, ids ...int64) error
182 } 185 }
@@ -32,10 +32,10 @@ func (dao OrderBaseDao) OrderCodeExist(code string, notId ...int64) (bool, error @@ -32,10 +32,10 @@ func (dao OrderBaseDao) OrderCodeExist(code string, notId ...int64) (bool, error
32 return ok, err 32 return ok, err
33 } 33 }
34 34
35 -func (dao OrderBaseDao) DeliveryCodeExist(code string, notId ...int64) (bool, error) { 35 +func (dao OrderBaseDao) DeliveryCodeExist(code string, companyId int64, notId ...int64) (bool, error) {
36 tx := dao.transactionContext.PgDd 36 tx := dao.transactionContext.PgDd
37 m := &models.OrderBase{} 37 m := &models.OrderBase{}
38 - query := tx.Model(m).Where("delivery_code=?", code) 38 + query := tx.Model(m).Where("delivery_code=?", code).Where("company_id=?", companyId)
39 if len(notId) > 0 { 39 if len(notId) > 0 {
40 query = query.WhereIn("id not in(?)", notId) 40 query = query.WhereIn("id not in(?)", notId)
41 } 41 }
1 -package models  
2 -  
3 -import (  
4 - "context"  
5 - "time"  
6 -  
7 - "github.com/go-pg/pg/v10"  
8 - "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/domain"  
9 -)  
10 -  
11 -type Order struct {  
12 - tableName struct{} `pg:"order"`  
13 - //id  
14 - Id int64 `pg:",pk"`  
15 - //订单类型 1:实际订单 2:意向订单  
16 - OrderType int `pg:",notnull,default:1"`  
17 - //订单编号  
18 - OrderCode string `pg:",unique,notnull`  
19 - //订单名称  
20 - OrderName string  
21 - //订单状态  
22 - OrderStatus int `pg:",notnull,default:1"`  
23 - //订单数量  
24 - OrderCount int  
25 - //实际订单数量  
26 - OrderActualCount int  
27 - //订单金额  
28 - OrderAmount float64  
29 - //订单实际金额  
30 - OrderActualAmount float64  
31 - //订单已支付金额(货款)  
32 - OrderPaymentAmount float64 `pg:",use_zero"`  
33 - //最后分红状态  
34 - BonusStatus int `pg:",default:1"`  
35 - //订单区域信息  
36 - OrderRegionInfo domain.RegionInfo  
37 -  
38 - Buyer domain.Buyer  
39 - //合伙人编号  
40 - PartnerId int64  
41 - PartnerInfo PartnerInfo `pg:"fk:partner_id"`  
42 - //合伙人分红百分比  
43 - PartnerBonusPercent float64  
44 - //业务员分红百分比  
45 - SalesmanBonusPercent float64  
46 -  
47 - //创建时间  
48 - CreateAt time.Time  
49 - //更新时间  
50 - UpdateAt time.Time  
51 -  
52 - //上一次查看时间 已读情况  
53 - LastViewTime time.Time  
54 - //理由  
55 - Reason string  
56 -}  
57 -  
58 -var _ pg.BeforeUpdateHook = (*Order)(nil)  
59 -  
60 -func (or *Order) BeforeUpdate(ctx context.Context) (context.Context, error) {  
61 - or.UpdateAt = time.Now()  
62 - return ctx, nil  
63 -}  
64 -  
65 -var _ pg.BeforeInsertHook = (*Order)(nil)  
66 -  
67 -func (or *Order) BeforeInsert(ctx context.Context) (context.Context, error) {  
68 - or.CreateAt = time.Now()  
69 - or.UpdateAt = time.Now()  
70 - return ctx, nil  
71 -}  
@@ -62,6 +62,7 @@ type OrderBase struct { @@ -62,6 +62,7 @@ type OrderBase struct {
62 IsDisable int `pg:",use_zero"` 62 IsDisable int `pg:",use_zero"`
63 //分红支付状态 63 //分红支付状态
64 BonusStatus int 64 BonusStatus int
  65 + CompanyId int64
65 } 66 }
66 67
67 var _ pg.BeforeUpdateHook = (*OrderBase)(nil) 68 var _ pg.BeforeUpdateHook = (*OrderBase)(nil)
@@ -36,5 +36,6 @@ type OrderGood struct { @@ -36,5 +36,6 @@ type OrderGood struct {
36 //分红状态 36 //分红状态
37 BonusStatus int 37 BonusStatus int
38 //备注信息 38 //备注信息
39 - Remark string 39 + Remark string
  40 + CompanyId int64
40 } 41 }
1 -package models  
2 -  
3 -import "time"  
4 -  
5 -type OrderPayment struct {  
6 - tableName struct{} `pg:"order_payment"`  
7 - //编号  
8 - Id int64 `pg:",pk"`  
9 - //订单编号  
10 - OrderId int64  
11 - //合伙人编号  
12 - PartnerId int64  
13 - //支付货款  
14 - PaymentAmount float64 `pg:",notnull,default:0"`  
15 - //分红金额  
16 - BonusAmount float64  
17 - //分红状态 1.等待支付分红 2.已支付分红  
18 - BonusStatus int `pg:",notnull,default:1"`  
19 - //创建时间  
20 - CreateAt time.Time  
21 - //更新时间  
22 - UpdateAt time.Time  
23 -}  
@@ -41,6 +41,7 @@ func (reponsitory OrderBaseRepository) transformPgModelToDomainModel(orderModel @@ -41,6 +41,7 @@ func (reponsitory OrderBaseRepository) transformPgModelToDomainModel(orderModel
41 Id: orderModel.PartnerId, 41 Id: orderModel.PartnerId,
42 }, 42 },
43 BonusStatus: orderModel.BonusStatus, 43 BonusStatus: orderModel.BonusStatus,
  44 + CompanyId: orderModel.CompanyId,
44 } 45 }
45 return order, nil 46 return order, nil
46 } 47 }
@@ -61,6 +62,7 @@ func (repository OrderBaseRepository) Save(orderInfo *domain.OrderBase) error { @@ -61,6 +62,7 @@ func (repository OrderBaseRepository) Save(orderInfo *domain.OrderBase) error {
61 PartnerBonusHas: orderInfo.OrderCompute.PartnerBonusHas, PartnerBonusNot: orderInfo.OrderCompute.PartnerBonusNot, 62 PartnerBonusHas: orderInfo.OrderCompute.PartnerBonusHas, PartnerBonusNot: orderInfo.OrderCompute.PartnerBonusNot,
62 PartnerBonusExpense: orderInfo.OrderCompute.PartnerBonusExpense, IsDisable: orderInfo.IsDisable, 63 PartnerBonusExpense: orderInfo.OrderCompute.PartnerBonusExpense, IsDisable: orderInfo.IsDisable,
63 CreateTime: orderInfo.CreateTime, BonusStatus: orderInfo.BonusStatus, 64 CreateTime: orderInfo.CreateTime, BonusStatus: orderInfo.BonusStatus,
  65 + CompanyId: orderInfo.CompanyId,
64 } 66 }
65 if m.Id == 0 { 67 if m.Id == 0 {
66 _, err = tx.Model(m). 68 _, err = tx.Model(m).
@@ -95,6 +97,9 @@ func (repository OrderBaseRepository) Find(queryOption domain.OrderBaseFindQuery @@ -95,6 +97,9 @@ func (repository OrderBaseRepository) Find(queryOption domain.OrderBaseFindQuery
95 if queryOption.OrderType > 0 { 97 if queryOption.OrderType > 0 {
96 query = query.Where("order_type=?", queryOption.OrderType) 98 query = query.Where("order_type=?", queryOption.OrderType)
97 } 99 }
  100 + if queryOption.CompanyId > 0 {
  101 + query = query.Where("company_id=?", queryOption.CompanyId)
  102 + }
98 if queryOption.Offset > -1 { 103 if queryOption.Offset > -1 {
99 query = query.Offset(queryOption.Offset) 104 query = query.Offset(queryOption.Offset)
100 } 105 }
@@ -138,7 +143,7 @@ func (repository OrderBaseRepository) FindOne(qureyOptions domain.OrderBaseFindO @@ -138,7 +143,7 @@ func (repository OrderBaseRepository) FindOne(qureyOptions domain.OrderBaseFindO
138 return &result, err 143 return &result, err
139 } 144 }
140 145
141 -func (repository OrderBaseRepository) Remove(id int64) error { 146 +func (repository OrderBaseRepository) Remove(id int64, companyId int64) error {
142 var ( 147 var (
143 err error 148 err error
144 tx = repository.transactionContext.PgTx 149 tx = repository.transactionContext.PgTx
@@ -146,6 +151,9 @@ func (repository OrderBaseRepository) Remove(id int64) error { @@ -146,6 +151,9 @@ func (repository OrderBaseRepository) Remove(id int64) error {
146 m := &models.OrderBase{ 151 m := &models.OrderBase{
147 Id: id, 152 Id: id,
148 } 153 }
149 - _, err = tx.Model(m).WherePK().Delete() 154 + _, err = tx.Model(m).
  155 + Where("id=?", id).
  156 + Where("company_id=?", companyId).
  157 + Delete()
150 return err 158 return err
151 } 159 }
@@ -38,6 +38,7 @@ func (reponsitory OrderGoodRepository) transformPgModelToDomainModel(orderModel @@ -38,6 +38,7 @@ func (reponsitory OrderGoodRepository) transformPgModelToDomainModel(orderModel
38 PartnerBonusNot: orderModel.PartnerBonusNot, 38 PartnerBonusNot: orderModel.PartnerBonusNot,
39 PartnerBonusExpense: orderModel.PartnerBonusExpense, 39 PartnerBonusExpense: orderModel.PartnerBonusExpense,
40 }, 40 },
  41 + CompanyId: orderModel.CompanyId,
41 } 42 }
42 switch orderModel.BonusStatus { 43 switch orderModel.BonusStatus {
43 case domain.OrderGoodWaitPay: 44 case domain.OrderGoodWaitPay:
@@ -62,7 +63,8 @@ func (repository OrderGoodRepository) Save(data []domain.OrderGood) error { @@ -62,7 +63,8 @@ func (repository OrderGoodRepository) Save(data []domain.OrderGood) error {
62 PlanPartnerBonus: v.GoodCompute.PlanPartnerBonus, UsePartnerBonus: v.GoodCompute.UsePartnerBonus, 63 PlanPartnerBonus: v.GoodCompute.PlanPartnerBonus, UsePartnerBonus: v.GoodCompute.UsePartnerBonus,
63 PartnerBonusHas: v.GoodCompute.PartnerBonusHas, PartnerBonusNot: v.GoodCompute.PartnerBonusNot, 64 PartnerBonusHas: v.GoodCompute.PartnerBonusHas, PartnerBonusNot: v.GoodCompute.PartnerBonusNot,
64 PartnerBonusExpense: v.GoodCompute.PartnerBonusExpense, BonusStatus: v.BonusStatus, 65 PartnerBonusExpense: v.GoodCompute.PartnerBonusExpense, BonusStatus: v.BonusStatus,
65 - Remark: v.Remark, 66 + Remark: v.Remark,
  67 + CompanyId: v.CompanyId,
66 } 68 }
67 if v.Id == 0 { 69 if v.Id == 0 {
68 _, err = tx.Model(m). 70 _, err = tx.Model(m).
@@ -91,6 +93,9 @@ func (repository OrderGoodRepository) Find(queryOption domain.OrderGoodFindQuery @@ -91,6 +93,9 @@ func (repository OrderGoodRepository) Find(queryOption domain.OrderGoodFindQuery
91 if queryOption.OrderId > 0 { 93 if queryOption.OrderId > 0 {
92 query = query.Where("order_id=?", queryOption.OrderId) 94 query = query.Where("order_id=?", queryOption.OrderId)
93 } 95 }
  96 + if queryOption.CompanyId > 0 {
  97 + query = query.Where("company_id=?", queryOption.CompanyId)
  98 + }
94 if queryOption.Offset > -1 { 99 if queryOption.Offset > -1 {
95 query = query.Offset(queryOption.Offset) 100 query = query.Offset(queryOption.Offset)
96 } 101 }
@@ -118,13 +123,15 @@ func (repository OrderGoodRepository) Find(queryOption domain.OrderGoodFindQuery @@ -118,13 +123,15 @@ func (repository OrderGoodRepository) Find(queryOption domain.OrderGoodFindQuery
118 return orderGoods, count, nil 123 return orderGoods, count, nil
119 } 124 }
120 125
121 -func (repository OrderGoodRepository) Remove(orderId int64, goodids ...int64) error { 126 +func (repository OrderGoodRepository) Remove(orderId int64, companyId int64, goodids ...int64) error {
122 var ( 127 var (
123 err error 128 err error
124 tx = repository.transactionContext.PgTx 129 tx = repository.transactionContext.PgTx
125 ) 130 )
126 m := &models.OrderGood{} 131 m := &models.OrderGood{}
127 - query := tx.Model(m).Where("order_id=?", orderId) 132 + query := tx.Model(m).
  133 + Where("order_id=?", orderId).
  134 + Where("company_id=?", companyId)
128 if len(goodids) > 0 { 135 if len(goodids) > 0 {
129 query = query.WhereIn("id in(?)", goodids) 136 query = query.WhereIn("id in(?)", goodids)
130 } 137 }
@@ -21,9 +21,11 @@ func (c *CommonController) Prepare() { @@ -21,9 +21,11 @@ func (c *CommonController) Prepare() {
21 21
22 // GetPartnerList 下拉选项数据通用接口,获取合伙人列表 22 // GetPartnerList 下拉选项数据通用接口,获取合伙人列表
23 func (c *CommonController) GetPartnerList() { 23 func (c *CommonController) GetPartnerList() {
  24 + companyId := c.GetUserCompany()
24 query := partnerQuery.ListPartnerInfoQuery{ 25 query := partnerQuery.ListPartnerInfoQuery{
25 - Limit: 5000,  
26 - Offset: 0, 26 + Limit: 1000,
  27 + Offset: 0,
  28 + CompanyId: companyId,
27 } 29 }
28 newPartnerService := partnerInfoService.NewPartnerInfoService(nil) 30 newPartnerService := partnerInfoService.NewPartnerInfoService(nil)
29 _, partners, err := newPartnerService.ListPartnerInfo(&query) 31 _, partners, err := newPartnerService.ListPartnerInfo(&query)
@@ -56,7 +56,7 @@ func (c *OrderInfoController) PageListOrderPurpose() { @@ -56,7 +56,7 @@ func (c *OrderInfoController) PageListOrderPurpose() {
56 if param.PageSize == 0 { 56 if param.PageSize == 0 {
57 param.PageSize = 20 57 param.PageSize = 20
58 } 58 }
59 - 59 + companyId := c.GetUserCompany()
60 orderSrv := orderService.NewOrderInfoService(nil) 60 orderSrv := orderService.NewOrderInfoService(nil)
61 orderinfos, cnt, err := orderSrv.PageListOrderBase(orderQuery.ListOrderBaseQuery{ 61 orderinfos, cnt, err := orderSrv.PageListOrderBase(orderQuery.ListOrderBaseQuery{
62 PartnerId: param.Partner, 62 PartnerId: param.Partner,
@@ -64,6 +64,7 @@ func (c *OrderInfoController) PageListOrderPurpose() { @@ -64,6 +64,7 @@ func (c *OrderInfoController) PageListOrderPurpose() {
64 OrderType: domain.OrderIntention, 64 OrderType: domain.OrderIntention,
65 Limit: param.PageSize, 65 Limit: param.PageSize,
66 Offset: (param.PageNumber - 1) * param.PageSize, 66 Offset: (param.PageNumber - 1) * param.PageSize,
  67 + CompanyId: companyId,
67 }) 68 })
68 if err != nil { 69 if err != nil {
69 c.ResponseError(err) 70 c.ResponseError(err)
@@ -103,9 +104,11 @@ func (c *OrderInfoController) GetOrderPurpose() { @@ -103,9 +104,11 @@ func (c *OrderInfoController) GetOrderPurpose() {
103 return 104 return
104 } 105 }
105 orderid, _ := strconv.ParseInt(param.Id, 10, 64) 106 orderid, _ := strconv.ParseInt(param.Id, 10, 64)
  107 + companyId := c.GetUserCompany()
106 orderSrv := orderService.NewOrderInfoService(nil) 108 orderSrv := orderService.NewOrderInfoService(nil)
107 orderinfo, err := orderSrv.GetOrderDetail(orderQuery.GetOrderQuery{ 109 orderinfo, err := orderSrv.GetOrderDetail(orderQuery.GetOrderQuery{
108 - OrderId: orderid, 110 + OrderId: orderid,
  111 + CompanyId: companyId,
109 }) 112 })
110 if err != nil { 113 if err != nil {
111 c.ResponseError(err) 114 c.ResponseError(err)
@@ -156,8 +159,9 @@ func (c *OrderInfoController) RemoveOrderPurpose() { @@ -156,8 +159,9 @@ func (c *OrderInfoController) RemoveOrderPurpose() {
156 c.ResponseError(errors.New("json数据解析失败")) 159 c.ResponseError(errors.New("json数据解析失败"))
157 return 160 return
158 } 161 }
  162 + companyId := c.GetUserCompany()
159 orderSrv := orderService.NewOrderInfoService(nil) 163 orderSrv := orderService.NewOrderInfoService(nil)
160 - err = orderSrv.DeleteOrder(param.Id) 164 + err = orderSrv.DeleteOrder(param.Id, companyId)
161 if err != nil { 165 if err != nil {
162 c.ResponseError(err) 166 c.ResponseError(err)
163 return 167 return
@@ -290,6 +294,7 @@ func (c *OrderInfoController) addOrderPurpose(param postPurposeOrderDetail) erro @@ -290,6 +294,7 @@ func (c *OrderInfoController) addOrderPurpose(param postPurposeOrderDetail) erro
290 } 294 }
291 newGoods = append(newGoods, g) 295 newGoods = append(newGoods, g)
292 } 296 }
  297 + companyId := c.GetUserCompany()
293 createcmd := orderCmd.CreateOrderCommand{ 298 createcmd := orderCmd.CreateOrderCommand{
294 OrderType: domain.OrderIntention, 299 OrderType: domain.OrderIntention,
295 OrderCode: param.OrderId, 300 OrderCode: param.OrderId,
@@ -299,6 +304,7 @@ func (c *OrderInfoController) addOrderPurpose(param postPurposeOrderDetail) erro @@ -299,6 +304,7 @@ func (c *OrderInfoController) addOrderPurpose(param postPurposeOrderDetail) erro
299 PartnerId: param.PartnerId, 304 PartnerId: param.PartnerId,
300 SalesmanBonusPercent: param.CommissionProportion, 305 SalesmanBonusPercent: param.CommissionProportion,
301 Goods: newGoods, 306 Goods: newGoods,
  307 + CompanyId: companyId,
302 } 308 }
303 orderSrv := orderService.NewOrderInfoService(nil) 309 orderSrv := orderService.NewOrderInfoService(nil)
304 _, err := orderSrv.CreateNewOrder(createcmd) 310 _, err := orderSrv.CreateNewOrder(createcmd)
@@ -317,6 +323,7 @@ func (c *OrderInfoController) editOrderPurpose(param postPurposeOrderDetail) err @@ -317,6 +323,7 @@ func (c *OrderInfoController) editOrderPurpose(param postPurposeOrderDetail) err
317 } 323 }
318 newGoods = append(newGoods, g) 324 newGoods = append(newGoods, g)
319 } 325 }
  326 + companyId := c.GetUserCompany()
320 updatecmd := orderCmd.UpdateOrderCommand{ 327 updatecmd := orderCmd.UpdateOrderCommand{
321 Id: param.Id, 328 Id: param.Id,
322 OrderType: domain.OrderIntention, 329 OrderType: domain.OrderIntention,
@@ -327,6 +334,7 @@ func (c *OrderInfoController) editOrderPurpose(param postPurposeOrderDetail) err @@ -327,6 +334,7 @@ func (c *OrderInfoController) editOrderPurpose(param postPurposeOrderDetail) err
327 PartnerId: param.PartnerId, 334 PartnerId: param.PartnerId,
328 SalesmanBonusPercent: param.CommissionProportion, 335 SalesmanBonusPercent: param.CommissionProportion,
329 Goods: newGoods, 336 Goods: newGoods,
  337 + CompanyId: companyId,
330 } 338 }
331 _, err := orderSrv.UpdateOrderData(updatecmd) 339 _, err := orderSrv.UpdateOrderData(updatecmd)
332 return err 340 return err
@@ -387,9 +395,10 @@ func (c *OrderInfoController) OrderPurposeDelivery() { @@ -387,9 +395,10 @@ func (c *OrderInfoController) OrderPurposeDelivery() {
387 } 395 }
388 goods = append(goods, g) 396 goods = append(goods, g)
389 } 397 }
  398 + companyId := c.GetUserCompany()
390 deliveryCommand := orderCmd.OrderDeliveryCommand{ 399 deliveryCommand := orderCmd.OrderDeliveryCommand{
391 OrderId: orderid, DeliveryCode: param.ShipmentsId, 400 OrderId: orderid, DeliveryCode: param.ShipmentsId,
392 - DeliveryTime: time.Now(), Goods: goods, 401 + DeliveryTime: time.Now(), Goods: goods, CompanyId: companyId,
393 } 402 }
394 orderSrv := orderService.NewOrderInfoService(nil) 403 orderSrv := orderService.NewOrderInfoService(nil)
395 err = orderSrv.Delivery(deliveryCommand) 404 err = orderSrv.Delivery(deliveryCommand)
@@ -423,7 +432,7 @@ func (c *OrderInfoController) PageListOrderReal() { @@ -423,7 +432,7 @@ func (c *OrderInfoController) PageListOrderReal() {
423 if param.PageSize == 0 { 432 if param.PageSize == 0 {
424 param.PageSize = 20 433 param.PageSize = 20
425 } 434 }
426 - 435 + companyId := c.GetUserCompany()
427 orderSrv := orderService.NewOrderInfoService(nil) 436 orderSrv := orderService.NewOrderInfoService(nil)
428 orderinfos, cnt, err := orderSrv.PageListOrderBase(orderQuery.ListOrderBaseQuery{ 437 orderinfos, cnt, err := orderSrv.PageListOrderBase(orderQuery.ListOrderBaseQuery{
429 PartnerId: param.Partner, 438 PartnerId: param.Partner,
@@ -431,6 +440,7 @@ func (c *OrderInfoController) PageListOrderReal() { @@ -431,6 +440,7 @@ func (c *OrderInfoController) PageListOrderReal() {
431 OrderType: domain.OrderReal, 440 OrderType: domain.OrderReal,
432 Limit: param.PageSize, 441 Limit: param.PageSize,
433 Offset: (param.PageNumber - 1) * param.PageSize, 442 Offset: (param.PageNumber - 1) * param.PageSize,
  443 + CompanyId: companyId,
434 }) 444 })
435 if err != nil { 445 if err != nil {
436 c.ResponseError(err) 446 c.ResponseError(err)
@@ -485,9 +495,11 @@ func (c *OrderInfoController) GetOrderReal() { @@ -485,9 +495,11 @@ func (c *OrderInfoController) GetOrderReal() {
485 c.ResponseError(errors.New("参数错误")) 495 c.ResponseError(errors.New("参数错误"))
486 return 496 return
487 } 497 }
  498 + companyId := c.GetUserCompany()
488 orderSrv := orderService.NewOrderInfoService(nil) 499 orderSrv := orderService.NewOrderInfoService(nil)
489 orderinfo, err := orderSrv.GetOrderDetail(orderQuery.GetOrderQuery{ 500 orderinfo, err := orderSrv.GetOrderDetail(orderQuery.GetOrderQuery{
490 - OrderId: orderid, 501 + OrderId: orderid,
  502 + CompanyId: companyId,
491 }) 503 })
492 if err != nil { 504 if err != nil {
493 c.ResponseError(err) 505 c.ResponseError(err)
@@ -601,6 +613,7 @@ func (c *OrderInfoController) addOrderReal(param postRealOrderDetail) error { @@ -601,6 +613,7 @@ func (c *OrderInfoController) addOrderReal(param postRealOrderDetail) error {
601 } 613 }
602 newGoods = append(newGoods, g) 614 newGoods = append(newGoods, g)
603 } 615 }
  616 + companyId := c.GetUserCompany()
604 createcmd := orderCmd.CreateOrderCommand{ 617 createcmd := orderCmd.CreateOrderCommand{
605 OrderType: domain.OrderReal, 618 OrderType: domain.OrderReal,
606 OrderCode: param.OrderId, 619 OrderCode: param.OrderId,
@@ -610,6 +623,7 @@ func (c *OrderInfoController) addOrderReal(param postRealOrderDetail) error { @@ -610,6 +623,7 @@ func (c *OrderInfoController) addOrderReal(param postRealOrderDetail) error {
610 PartnerId: param.PartnerId, 623 PartnerId: param.PartnerId,
611 SalesmanBonusPercent: param.CommissionProportion, 624 SalesmanBonusPercent: param.CommissionProportion,
612 Goods: newGoods, 625 Goods: newGoods,
  626 + CompanyId: companyId,
613 } 627 }
614 _, err := orderSrv.CreateNewOrder(createcmd) 628 _, err := orderSrv.CreateNewOrder(createcmd)
615 return err 629 return err
@@ -627,6 +641,7 @@ func (c *OrderInfoController) editOrderReal(param postRealOrderDetail) error { @@ -627,6 +641,7 @@ func (c *OrderInfoController) editOrderReal(param postRealOrderDetail) error {
627 } 641 }
628 newGoods = append(newGoods, g) 642 newGoods = append(newGoods, g)
629 } 643 }
  644 + companyId := c.GetUserCompany()
630 updatecmd := orderCmd.UpdateOrderCommand{ 645 updatecmd := orderCmd.UpdateOrderCommand{
631 Id: param.Id, 646 Id: param.Id,
632 OrderType: domain.OrderReal, 647 OrderType: domain.OrderReal,
@@ -637,6 +652,7 @@ func (c *OrderInfoController) editOrderReal(param postRealOrderDetail) error { @@ -637,6 +652,7 @@ func (c *OrderInfoController) editOrderReal(param postRealOrderDetail) error {
637 PartnerId: param.PartnerId, 652 PartnerId: param.PartnerId,
638 SalesmanBonusPercent: param.CommissionProportion, 653 SalesmanBonusPercent: param.CommissionProportion,
639 Goods: newGoods, 654 Goods: newGoods,
  655 + CompanyId: companyId,
640 } 656 }
641 orderSrv := orderService.NewOrderInfoService(nil) 657 orderSrv := orderService.NewOrderInfoService(nil)
642 _, err := orderSrv.UpdateOrderData(updatecmd) 658 _, err := orderSrv.UpdateOrderData(updatecmd)
@@ -668,10 +684,12 @@ func (c *OrderInfoController) OrderDisable() { @@ -668,10 +684,12 @@ func (c *OrderInfoController) OrderDisable() {
668 c.ResponseError(errors.New("参数错误")) 684 c.ResponseError(errors.New("参数错误"))
669 return 685 return
670 } 686 }
  687 + companyId := c.GetUserCompany()
671 cmd := orderCmd.DisableOrderCommand{ 688 cmd := orderCmd.DisableOrderCommand{
672 OrderId: orderId, 689 OrderId: orderId,
673 IsDisable: param.Status, 690 IsDisable: param.Status,
674 OrderType: domain.OrderReal, 691 OrderType: domain.OrderReal,
  692 + CompanyId: companyId,
675 } 693 }
676 orderSrv := orderService.NewOrderInfoService(nil) 694 orderSrv := orderService.NewOrderInfoService(nil)
677 err = orderSrv.DisableOrEnable(cmd) 695 err = orderSrv.DisableOrEnable(cmd)
@@ -696,8 +714,9 @@ func (c *OrderInfoController) RemoveOrderReal() { @@ -696,8 +714,9 @@ func (c *OrderInfoController) RemoveOrderReal() {
696 c.ResponseError(errors.New("json数据解析失败")) 714 c.ResponseError(errors.New("json数据解析失败"))
697 return 715 return
698 } 716 }
  717 + companyId := c.GetUserCompany()
699 orderSrv := orderService.NewOrderInfoService(nil) 718 orderSrv := orderService.NewOrderInfoService(nil)
700 - err = orderSrv.DeleteOrder(param.Id) 719 + err = orderSrv.DeleteOrder(param.Id, companyId)
701 if err != nil { 720 if err != nil {
702 c.ResponseError(err) 721 c.ResponseError(err)
703 return 722 return