作者 唐旭辉

更新

@@ -19,4 +19,6 @@ type CreateOrderCommand struct { @@ -19,4 +19,6 @@ type CreateOrderCommand struct {
19 //货品 19 //货品
20 Goods []OrderGoodData `json:"goods"` 20 Goods []OrderGoodData `json:"goods"`
21 CompanyId int64 `json:"companyId"` 21 CompanyId int64 `json:"companyId"`
  22 +
  23 + PartnerCategory int64 `json:"partner_category"`
22 } 24 }
@@ -20,4 +20,6 @@ type UpdateOrderCommand struct { @@ -20,4 +20,6 @@ type UpdateOrderCommand struct {
20 //货品 20 //货品
21 Goods []OrderGoodData `json:"goods"` 21 Goods []OrderGoodData `json:"goods"`
22 CompanyId int64 `json:"companyId"` 22 CompanyId int64 `json:"companyId"`
  23 +
  24 + PartnerCategory int64 `json:"partner_category"`
23 } 25 }
@@ -229,6 +229,16 @@ func (service OrderInfoService) CreateNewOrder(cmd command.CreateOrderCommand) ( @@ -229,6 +229,16 @@ func (service OrderInfoService) CreateNewOrder(cmd command.CreateOrderCommand) (
229 SalesmanBonusPercent: cmd.SalesmanBonusPercent, 229 SalesmanBonusPercent: cmd.SalesmanBonusPercent,
230 CompanyId: cmd.CompanyId, 230 CompanyId: cmd.CompanyId,
231 } 231 }
  232 + var cmdPartnerCategoryOk bool
  233 + for _, v := range partnerData.PartnerCategoryInfos {
  234 + if v.Id == cmd.PartnerCategory {
  235 + newOrder.PartnerCategory = v
  236 + cmdPartnerCategoryOk = true
  237 + }
  238 + }
  239 + if !cmdPartnerCategoryOk {
  240 + return nil, lib.ThrowError(lib.BUSINESS_ERROR, "合伙人类型选择错误")
  241 + }
232 var orderGoods []domain.OrderGood 242 var orderGoods []domain.OrderGood
233 for _, good := range cmd.Goods { 243 for _, good := range cmd.Goods {
234 m := domain.NewOrderGood() 244 m := domain.NewOrderGood()
@@ -384,7 +394,7 @@ func (service OrderInfoService) UpdateOrderData(cmd command.UpdateOrderCommand) @@ -384,7 +394,7 @@ func (service OrderInfoService) UpdateOrderData(cmd command.UpdateOrderCommand)
384 // return nil, lib.ThrowError(lib.BUSINESS_ERROR, "订单号已存在") 394 // return nil, lib.ThrowError(lib.BUSINESS_ERROR, "订单号已存在")
385 // } 395 // }
386 //检查delivery_code是否重复 396 //检查delivery_code是否重复
387 - if len(cmd.DeliveryCode) > 0 { 397 + if cmd.DeliveryCode != oldOrderData.DeliveryCode {
388 if ok, err := orderBaseDao.DeliveryCodeExist(cmd.DeliveryCode, cmd.CompanyId, cmd.Id); err != nil { 398 if ok, err := orderBaseDao.DeliveryCodeExist(cmd.DeliveryCode, cmd.CompanyId, cmd.Id); err != nil {
389 return nil, lib.ThrowError(lib.TRANSACTION_ERROR, err.Error()) 399 return nil, lib.ThrowError(lib.TRANSACTION_ERROR, err.Error())
390 } else if ok { 400 } else if ok {
@@ -418,6 +428,16 @@ func (service OrderInfoService) UpdateOrderData(cmd command.UpdateOrderCommand) @@ -418,6 +428,16 @@ func (service OrderInfoService) UpdateOrderData(cmd command.UpdateOrderCommand)
418 } 428 }
419 newOrderGoods = append(newOrderGoods, m) 429 newOrderGoods = append(newOrderGoods, m)
420 } 430 }
  431 + var cmdPartnerCategoryOk bool
  432 + for _, v := range partnerData.PartnerCategoryInfos {
  433 + if v.Id == cmd.PartnerCategory {
  434 + oldOrderData.PartnerCategory = v
  435 + cmdPartnerCategoryOk = true
  436 + }
  437 + }
  438 + if !cmdPartnerCategoryOk {
  439 + return nil, lib.ThrowError(lib.BUSINESS_ERROR, "合伙人类型选择错误")
  440 + }
421 oldOrderData.OrderCode = cmd.OrderCode 441 oldOrderData.OrderCode = cmd.OrderCode
422 oldOrderData.DeliveryCode = cmd.DeliveryCode 442 oldOrderData.DeliveryCode = cmd.DeliveryCode
423 oldOrderData.Buyer.BuyerName = cmd.BuyerName 443 oldOrderData.Buyer.BuyerName = cmd.BuyerName
@@ -44,6 +44,7 @@ func (reponsitory OrderBaseRepository) transformPgModelToDomainModel(orderModel @@ -44,6 +44,7 @@ func (reponsitory OrderBaseRepository) transformPgModelToDomainModel(orderModel
44 CompanyId: orderModel.CompanyId, 44 CompanyId: orderModel.CompanyId,
45 DataFrom: orderModel.DataFrom, 45 DataFrom: orderModel.DataFrom,
46 Remark: orderModel.Remark, 46 Remark: orderModel.Remark,
  47 + PartnerCategory: orderModel.PartnerCategory,
47 } 48 }
48 return order, nil 49 return order, nil
49 } 50 }
@@ -65,7 +66,7 @@ func (repository OrderBaseRepository) Save(orderInfo *domain.OrderBase) error { @@ -65,7 +66,7 @@ func (repository OrderBaseRepository) Save(orderInfo *domain.OrderBase) error {
65 PartnerBonusExpense: orderInfo.OrderCompute.PartnerBonusExpense, IsDisable: orderInfo.IsDisable, 66 PartnerBonusExpense: orderInfo.OrderCompute.PartnerBonusExpense, IsDisable: orderInfo.IsDisable,
66 CreateTime: orderInfo.CreateTime, BonusStatus: orderInfo.BonusStatus, 67 CreateTime: orderInfo.CreateTime, BonusStatus: orderInfo.BonusStatus,
67 CompanyId: orderInfo.CompanyId, DataFrom: orderInfo.DataFrom, 68 CompanyId: orderInfo.CompanyId, DataFrom: orderInfo.DataFrom,
68 - Remark: orderInfo.Remark, 69 + Remark: orderInfo.Remark, PartnerCategory: orderInfo.PartnerCategory,
69 } 70 }
70 if m.Id == 0 { 71 if m.Id == 0 {
71 _, err = tx.Model(m). 72 _, err = tx.Model(m).
@@ -280,63 +280,63 @@ func (postData *postOrderGood) Valid() error { @@ -280,63 +280,63 @@ func (postData *postOrderGood) Valid() error {
280 // return 280 // return
281 // } 281 // }
282 282
283 -func (c *OrderInfoController) addOrderPurpose(param postPurposeOrderDetail) error { 283 +// func (c *OrderInfoController) addOrderPurpose(param postPurposeOrderDetail) error {
284 284
285 - newGoods := []orderCmd.OrderGoodData{}  
286 - for _, v := range param.Product {  
287 - g := orderCmd.OrderGoodData{  
288 - GoodName: v.ProductName,  
289 - PlanGoodNumber: v.OrderNum,  
290 - Price: v.Univalence,  
291 - PartnerBonusPercent: v.PartnerRatio,  
292 - }  
293 - newGoods = append(newGoods, g)  
294 - }  
295 - companyId := c.GetUserCompany()  
296 - createcmd := orderCmd.CreateOrderCommand{  
297 - OrderType: domain.OrderIntention,  
298 - OrderCode: param.OrderId,  
299 - DeliveryCode: "",  
300 - BuyerName: param.BuyerName,  
301 - OrderRegion: param.OrderDist,  
302 - PartnerId: param.PartnerId,  
303 - SalesmanBonusPercent: param.CommissionProportion,  
304 - Goods: newGoods,  
305 - CompanyId: companyId,  
306 - }  
307 - orderSrv := orderService.NewOrderInfoService(nil)  
308 - _, err := orderSrv.CreateNewOrder(createcmd)  
309 - return err  
310 -} 285 +// newGoods := []orderCmd.OrderGoodData{}
  286 +// for _, v := range param.Product {
  287 +// g := orderCmd.OrderGoodData{
  288 +// GoodName: v.ProductName,
  289 +// PlanGoodNumber: v.OrderNum,
  290 +// Price: v.Univalence,
  291 +// PartnerBonusPercent: v.PartnerRatio,
  292 +// }
  293 +// newGoods = append(newGoods, g)
  294 +// }
  295 +// companyId := c.GetUserCompany()
  296 +// createcmd := orderCmd.CreateOrderCommand{
  297 +// OrderType: domain.OrderIntention,
  298 +// OrderCode: param.OrderId,
  299 +// DeliveryCode: "",
  300 +// BuyerName: param.BuyerName,
  301 +// OrderRegion: param.OrderDist,
  302 +// PartnerId: param.PartnerId,
  303 +// SalesmanBonusPercent: param.CommissionProportion,
  304 +// Goods: newGoods,
  305 +// CompanyId: companyId,
  306 +// }
  307 +// orderSrv := orderService.NewOrderInfoService(nil)
  308 +// _, err := orderSrv.CreateNewOrder(createcmd)
  309 +// return err
  310 +// }
311 311
312 -func (c *OrderInfoController) editOrderPurpose(param postPurposeOrderDetail) error {  
313 - orderSrv := orderService.NewOrderInfoService(nil)  
314 - newGoods := []orderCmd.OrderGoodData{}  
315 - for _, v := range param.Product {  
316 - g := orderCmd.OrderGoodData{  
317 - GoodName: v.ProductName,  
318 - PlanGoodNumber: v.OrderNum,  
319 - Price: v.Univalence,  
320 - PartnerBonusPercent: v.PartnerRatio,  
321 - }  
322 - newGoods = append(newGoods, g)  
323 - }  
324 - companyId := c.GetUserCompany()  
325 - updatecmd := orderCmd.UpdateOrderCommand{  
326 - Id: param.Id,  
327 - OrderType: domain.OrderIntention,  
328 - OrderCode: param.OrderId,  
329 - DeliveryCode: "",  
330 - BuyerName: param.BuyerName,  
331 - OrderRegion: param.OrderDist,  
332 - PartnerId: param.PartnerId,  
333 - SalesmanBonusPercent: param.CommissionProportion,  
334 - Goods: newGoods,  
335 - CompanyId: companyId,  
336 - }  
337 - _, err := orderSrv.UpdateOrderData(updatecmd)  
338 - return err  
339 -} 312 +// func (c *OrderInfoController) editOrderPurpose(param postPurposeOrderDetail) error {
  313 +// orderSrv := orderService.NewOrderInfoService(nil)
  314 +// newGoods := []orderCmd.OrderGoodData{}
  315 +// for _, v := range param.Product {
  316 +// g := orderCmd.OrderGoodData{
  317 +// GoodName: v.ProductName,
  318 +// PlanGoodNumber: v.OrderNum,
  319 +// Price: v.Univalence,
  320 +// PartnerBonusPercent: v.PartnerRatio,
  321 +// }
  322 +// newGoods = append(newGoods, g)
  323 +// }
  324 +// companyId := c.GetUserCompany()
  325 +// updatecmd := orderCmd.UpdateOrderCommand{
  326 +// Id: param.Id,
  327 +// OrderType: domain.OrderIntention,
  328 +// OrderCode: param.OrderId,
  329 +// DeliveryCode: "",
  330 +// BuyerName: param.BuyerName,
  331 +// OrderRegion: param.OrderDist,
  332 +// PartnerId: param.PartnerId,
  333 +// SalesmanBonusPercent: param.CommissionProportion,
  334 +// Goods: newGoods,
  335 +// CompanyId: companyId,
  336 +// }
  337 +// _, err := orderSrv.UpdateOrderData(updatecmd)
  338 +// return err
  339 +// }
340 340
341 type postOrderPurposeDelivery struct { 341 type postOrderPurposeDelivery struct {
342 ShipmentsId string `json:"shipmentsId"` //发货单号 342 ShipmentsId string `json:"shipmentsId"` //发货单号
@@ -543,6 +543,8 @@ func (c *OrderInfoController) GetOrderReal() { @@ -543,6 +543,8 @@ func (c *OrderInfoController) GetOrderReal() {
543 "product": allGoods, 543 "product": allGoods,
544 "create_time": orderinfo.CreateTime.Local().Format("2006-01-02 15:04:06"), 544 "create_time": orderinfo.CreateTime.Local().Format("2006-01-02 15:04:06"),
545 "update_time": orderinfo.UpdateTime.Local().Format("2006-01-02 15:04:06"), 545 "update_time": orderinfo.UpdateTime.Local().Format("2006-01-02 15:04:06"),
  546 + "partnerCategoryId": orderinfo.PartnerCategory.Id,
  547 + "partnerCategoryName": orderinfo.PartnerCategory.Name,
546 } 548 }
547 if orderinfo.OrderCompute.UseOrderAmount >= 0 { 549 if orderinfo.OrderCompute.UseOrderAmount >= 0 {
548 rsp["orderNumCountControl"] = fmt.Sprint(orderinfo.OrderCompute.UseOrderCount) 550 rsp["orderNumCountControl"] = fmt.Sprint(orderinfo.OrderCompute.UseOrderCount)
@@ -557,6 +559,7 @@ func (c *OrderInfoController) GetOrderReal() { @@ -557,6 +559,7 @@ func (c *OrderInfoController) GetOrderReal() {
557 //实际订单 559 //实际订单
558 type postRealOrderDetail struct { 560 type postRealOrderDetail struct {
559 postPurposeOrderDetail 561 postPurposeOrderDetail
  562 + PartnerCategory int64 `json:"partner_category"`
560 ShipmentsId string `json:"shipmentsId"` //发货单号 563 ShipmentsId string `json:"shipmentsId"` //发货单号
561 } 564 }
562 565
@@ -622,6 +625,7 @@ func (c *OrderInfoController) addOrderReal(param postRealOrderDetail) error { @@ -622,6 +625,7 @@ func (c *OrderInfoController) addOrderReal(param postRealOrderDetail) error {
622 SalesmanBonusPercent: param.CommissionProportion, 625 SalesmanBonusPercent: param.CommissionProportion,
623 Goods: newGoods, 626 Goods: newGoods,
624 CompanyId: companyId, 627 CompanyId: companyId,
  628 + PartnerCategory: param.PartnerCategory,
625 } 629 }
626 _, err := orderSrv.CreateNewOrder(createcmd) 630 _, err := orderSrv.CreateNewOrder(createcmd)
627 return err 631 return err
@@ -651,6 +655,7 @@ func (c *OrderInfoController) editOrderReal(param postRealOrderDetail) error { @@ -651,6 +655,7 @@ func (c *OrderInfoController) editOrderReal(param postRealOrderDetail) error {
651 SalesmanBonusPercent: param.CommissionProportion, 655 SalesmanBonusPercent: param.CommissionProportion,
652 Goods: newGoods, 656 Goods: newGoods,
653 CompanyId: companyId, 657 CompanyId: companyId,
  658 + PartnerCategory: param.PartnerCategory,
654 } 659 }
655 orderSrv := orderService.NewOrderInfoService(nil) 660 orderSrv := orderService.NewOrderInfoService(nil)
656 _, err := orderSrv.UpdateOrderData(updatecmd) 661 _, err := orderSrv.UpdateOrderData(updatecmd)