正在显示
5 个修改的文件
包含
96 行增加
和
4 行删除
| @@ -336,7 +336,7 @@ func (service OrderInfoService) UpdateOrderData(cmd command.UpdateOrderCommand) | @@ -336,7 +336,7 @@ func (service OrderInfoService) UpdateOrderData(cmd command.UpdateOrderCommand) | ||
| 336 | } | 336 | } |
| 337 | //判定要求的更新的订单类型 | 337 | //判定要求的更新的订单类型 |
| 338 | if oldOrderData.OrderType != cmd.OrderType { | 338 | if oldOrderData.OrderType != cmd.OrderType { |
| 339 | - return nil, lib.ThrowError(lib.BUSINESS_ERROR, fmt.Sprintf("待更新的订单的类型已变更")) | 339 | + return nil, lib.ThrowError(lib.BUSINESS_ERROR, fmt.Sprintf("操作失败,待更新的订单的类型已变更")) |
| 340 | } | 340 | } |
| 341 | //获取旧的订单中的商品 | 341 | //获取旧的订单中的商品 |
| 342 | oldOrderGoods, _, err = orderGoodRepository.Find(domain.OrderGoodFindQuery{ | 342 | oldOrderGoods, _, err = orderGoodRepository.Find(domain.OrderGoodFindQuery{ |
| @@ -499,3 +499,46 @@ func (service OrderInfoService) Delivery(cmd command.OrderDeliveryCommand) error | @@ -499,3 +499,46 @@ func (service OrderInfoService) Delivery(cmd command.OrderDeliveryCommand) error | ||
| 499 | } | 499 | } |
| 500 | return nil | 500 | return nil |
| 501 | } | 501 | } |
| 502 | + | ||
| 503 | +//DisableOrEnable 开启关闭订单 | ||
| 504 | +func (service OrderInfoService) DisableOrEnable(cmd command.DisableOrderCommand) error { | ||
| 505 | + var ( | ||
| 506 | + transactionContext, _ = factory.CreateTransactionContext(nil) | ||
| 507 | + err error | ||
| 508 | + ) | ||
| 509 | + if err = transactionContext.StartTransaction(); err != nil { | ||
| 510 | + return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 511 | + } | ||
| 512 | + defer func() { | ||
| 513 | + transactionContext.RollbackTransaction() | ||
| 514 | + }() | ||
| 515 | + var ( | ||
| 516 | + orderBaseRepository domain.OrderBaseRepository | ||
| 517 | + oldOrderData *domain.OrderBase | ||
| 518 | + ) | ||
| 519 | + if orderBaseRepository, err = factory.CreateOrderBaseRepository(map[string]interface{}{ | ||
| 520 | + "transactionContext": transactionContext, | ||
| 521 | + }); err != nil { | ||
| 522 | + return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 523 | + } | ||
| 524 | + //获取旧的订单 | ||
| 525 | + oldOrderData, err = orderBaseRepository.FindOne(domain.OrderBaseFindOneQuery{ | ||
| 526 | + OrderId: cmd.OrderId, | ||
| 527 | + }) | ||
| 528 | + if err != nil { | ||
| 529 | + return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, fmt.Sprintf("未找到指定的订单:%s", err)) | ||
| 530 | + } | ||
| 531 | + if oldOrderData.OrderType != cmd.OrderType { | ||
| 532 | + return lib.ThrowError(lib.BUSINESS_ERROR, fmt.Sprintf("操作失败,指定的订单的类型发生变更")) | ||
| 533 | + } | ||
| 534 | + oldOrderData.IsDisable = cmd.IsDisable | ||
| 535 | + err = orderBaseRepository.Save(oldOrderData) | ||
| 536 | + if err != nil { | ||
| 537 | + return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, fmt.Sprintf("保存订单数据失败:%s", err)) | ||
| 538 | + } | ||
| 539 | + err = transactionContext.CommitTransaction() | ||
| 540 | + if err != nil { | ||
| 541 | + return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 542 | + } | ||
| 543 | + return nil | ||
| 544 | +} |
| @@ -58,7 +58,7 @@ func (repository OrderBaseRepository) Save(orderInfo *domain.OrderBase) error { | @@ -58,7 +58,7 @@ func (repository OrderBaseRepository) Save(orderInfo *domain.OrderBase) error { | ||
| 58 | UseOrderAmount: orderInfo.OrderCompute.UseOrderAmount, DeliveryTime: orderInfo.DeliveryTime, | 58 | UseOrderAmount: orderInfo.OrderCompute.UseOrderAmount, DeliveryTime: orderInfo.DeliveryTime, |
| 59 | PlanPartnerBonus: orderInfo.OrderCompute.PlanPartnerBonus, UsePartnerBonus: orderInfo.OrderCompute.UsePartnerBonus, | 59 | PlanPartnerBonus: orderInfo.OrderCompute.PlanPartnerBonus, UsePartnerBonus: orderInfo.OrderCompute.UsePartnerBonus, |
| 60 | PartnerBonusHas: orderInfo.OrderCompute.PartnerBonusHas, PartnerBonusNot: orderInfo.OrderCompute.PartnerBonusNot, | 60 | PartnerBonusHas: orderInfo.OrderCompute.PartnerBonusHas, PartnerBonusNot: orderInfo.OrderCompute.PartnerBonusNot, |
| 61 | - PartnerBonusExpense: orderInfo.OrderCompute.PartnerBonusExpense, | 61 | + PartnerBonusExpense: orderInfo.OrderCompute.PartnerBonusExpense, IsDisable: orderInfo.IsDisable, |
| 62 | } | 62 | } |
| 63 | if m.Id == 0 { | 63 | if m.Id == 0 { |
| 64 | _, err = tx.Model(m). | 64 | _, err = tx.Model(m). |
| @@ -570,7 +570,7 @@ func (c *OrderInfoController) addOrderReal(param postRealOrderDetail) error { | @@ -570,7 +570,7 @@ func (c *OrderInfoController) addOrderReal(param postRealOrderDetail) error { | ||
| 570 | } | 570 | } |
| 571 | 571 | ||
| 572 | func (c *OrderInfoController) editOrderReal(param postRealOrderDetail) error { | 572 | func (c *OrderInfoController) editOrderReal(param postRealOrderDetail) error { |
| 573 | - orderSrv := orderService.NewOrderInfoService(nil) | 573 | + |
| 574 | newGoods := []orderCmd.OrderGoodData{} | 574 | newGoods := []orderCmd.OrderGoodData{} |
| 575 | for _, v := range param.Product { | 575 | for _, v := range param.Product { |
| 576 | g := orderCmd.OrderGoodData{ | 576 | g := orderCmd.OrderGoodData{ |
| @@ -592,6 +592,46 @@ func (c *OrderInfoController) editOrderReal(param postRealOrderDetail) error { | @@ -592,6 +592,46 @@ func (c *OrderInfoController) editOrderReal(param postRealOrderDetail) error { | ||
| 592 | SalesmanBonusPercent: param.CommissionProportion, | 592 | SalesmanBonusPercent: param.CommissionProportion, |
| 593 | Goods: newGoods, | 593 | Goods: newGoods, |
| 594 | } | 594 | } |
| 595 | + orderSrv := orderService.NewOrderInfoService(nil) | ||
| 595 | _, err := orderSrv.UpdateOrderData(updatecmd) | 596 | _, err := orderSrv.UpdateOrderData(updatecmd) |
| 596 | return err | 597 | return err |
| 597 | } | 598 | } |
| 599 | + | ||
| 600 | +//OrderDisable 关闭开启订单,限实发订单可操作 | ||
| 601 | +func (c *OrderInfoController) OrderDisable() { | ||
| 602 | + //用与适配前端定义的数据结构 | ||
| 603 | + type PostParameter struct { | ||
| 604 | + Id string `json:"id"` | ||
| 605 | + Status int `json:"status"` | ||
| 606 | + } | ||
| 607 | + var ( | ||
| 608 | + param PostParameter | ||
| 609 | + err error | ||
| 610 | + ) | ||
| 611 | + if err = c.BindJsonData(¶m); err != nil { | ||
| 612 | + logs.Error(err) | ||
| 613 | + c.ResponseError(errors.New("json数据解析失败")) | ||
| 614 | + return | ||
| 615 | + } | ||
| 616 | + orderId, _ := strconv.ParseInt(param.Id, 10, 64) | ||
| 617 | + if orderId == 0 { | ||
| 618 | + c.ResponseError(errors.New("参数错误")) | ||
| 619 | + return | ||
| 620 | + } | ||
| 621 | + if !(param.Status == domain.OrderDisableNot || param.Status == domain.OrderDisableYes) { | ||
| 622 | + c.ResponseError(errors.New("参数错误")) | ||
| 623 | + return | ||
| 624 | + } | ||
| 625 | + cmd := orderCmd.DisableOrderCommand{ | ||
| 626 | + OrderId: orderId, | ||
| 627 | + IsDisable: param.Status, | ||
| 628 | + OrderType: domain.OrderReal, | ||
| 629 | + } | ||
| 630 | + orderSrv := orderService.NewOrderInfoService(nil) | ||
| 631 | + err = orderSrv.DisableOrEnable(cmd) | ||
| 632 | + if err != nil { | ||
| 633 | + c.ResponseError(err) | ||
| 634 | + } | ||
| 635 | + c.ResponseData(nil) | ||
| 636 | + return | ||
| 637 | +} |
| @@ -47,8 +47,9 @@ func init() { | @@ -47,8 +47,9 @@ func init() { | ||
| 47 | beego.NSRouter("/actual/list", &controllers.OrderInfoController{}, "POST:PageListOrderReal"), | 47 | beego.NSRouter("/actual/list", &controllers.OrderInfoController{}, "POST:PageListOrderReal"), |
| 48 | beego.NSRouter("/actual/detail", &controllers.OrderInfoController{}, "POST:GetOrderReal"), | 48 | beego.NSRouter("/actual/detail", &controllers.OrderInfoController{}, "POST:GetOrderReal"), |
| 49 | beego.NSRouter("/actual/update", &controllers.OrderInfoController{}, "POST:UpdateOrderReal"), | 49 | beego.NSRouter("/actual/update", &controllers.OrderInfoController{}, "POST:UpdateOrderReal"), |
| 50 | + beego.NSRouter("/actual/close", &controllers.OrderInfoController{}, "POST:OrderDisable"), | ||
| 50 | ), | 51 | ), |
| 51 | - | 52 | + |
| 52 | beego.NSNamespace("/common", | 53 | beego.NSNamespace("/common", |
| 53 | beego.NSRouter("/partner", &controllers.CommonController{}, "POST:GetPartnerList"), | 54 | beego.NSRouter("/partner", &controllers.CommonController{}, "POST:GetPartnerList"), |
| 54 | ), | 55 | ), |
-
请 注册 或 登录 后发表评论