正在显示
8 个修改的文件
包含
182 行增加
和
10 行删除
| 1 | package command | 1 | package command |
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | + "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/domain" | ||
| 4 | "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/lib" | 5 | "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/lib" |
| 5 | ) | 6 | ) |
| 6 | 7 | ||
| @@ -33,6 +34,7 @@ type CreateOrderCommand struct { | @@ -33,6 +34,7 @@ type CreateOrderCommand struct { | ||
| 33 | PartnerBonusPercent float64 `json:"partnerBonusPercent"` | 34 | PartnerBonusPercent float64 `json:"partnerBonusPercent"` |
| 34 | //业务员分红百分比 | 35 | //业务员分红百分比 |
| 35 | SalesmanBonusPercent float64 `json:"salesmanBonusPercent"` | 36 | SalesmanBonusPercent float64 `json:"salesmanBonusPercent"` |
| 37 | + //订单类型 | ||
| 36 | OrderType int `json:"orderType"` | 38 | OrderType int `json:"orderType"` |
| 37 | } | 39 | } |
| 38 | 40 | ||
| @@ -49,5 +51,8 @@ func (command CreateOrderCommand) ValidateCommand() error { | @@ -49,5 +51,8 @@ func (command CreateOrderCommand) ValidateCommand() error { | ||
| 49 | if len(command.OrderRegion) == 0 { | 51 | if len(command.OrderRegion) == 0 { |
| 50 | return lib.ThrowError(lib.ARG_ERROR, "订单区域必填") | 52 | return lib.ThrowError(lib.ARG_ERROR, "订单区域必填") |
| 51 | } | 53 | } |
| 54 | + if !(command.OrderType == domain.OrderReal || command.OrderType == domain.OrderIntention) { | ||
| 55 | + return lib.ThrowError(lib.ARG_ERROR, "订单类型错误") | ||
| 56 | + } | ||
| 52 | return nil | 57 | return nil |
| 53 | } | 58 | } |
| 1 | package command | 1 | package command |
| 2 | 2 | ||
| 3 | -import "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/lib" | 3 | +import ( |
| 4 | + "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/domain" | ||
| 5 | + "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/lib" | ||
| 6 | +) | ||
| 4 | 7 | ||
| 5 | type UpdateOrderRealCommand struct { | 8 | type UpdateOrderRealCommand struct { |
| 6 | //id | 9 | //id |
| @@ -43,5 +46,8 @@ func (command UpdateOrderRealCommand) ValidateCommand() error { | @@ -43,5 +46,8 @@ func (command UpdateOrderRealCommand) ValidateCommand() error { | ||
| 43 | if len(command.OrderRegion) == 0 { | 46 | if len(command.OrderRegion) == 0 { |
| 44 | return lib.ThrowError(lib.ARG_ERROR, "订单区域必填") | 47 | return lib.ThrowError(lib.ARG_ERROR, "订单区域必填") |
| 45 | } | 48 | } |
| 49 | + if !(command.OrderStatus == domain.OrderStatusDeliverSome || command.OrderStatus == domain.OrderStatusDeliverAll) { | ||
| 50 | + return lib.ThrowError(lib.ARG_ERROR, "订单状态设置错误") | ||
| 51 | + } | ||
| 46 | return nil | 52 | return nil |
| 47 | } | 53 | } |
| @@ -115,8 +115,8 @@ func (service OrderService) GetOrder(getOrderQuery query.GetOrderQuery) (*domain | @@ -115,8 +115,8 @@ func (service OrderService) GetOrder(getOrderQuery query.GetOrderQuery) (*domain | ||
| 115 | return order, nil | 115 | return order, nil |
| 116 | } | 116 | } |
| 117 | 117 | ||
| 118 | -//CreateOrderPurpose 创建意向单 | ||
| 119 | -func (service OrderService) CreateOrderPurpose(command command.CreateOrderCommand) error { | 118 | +//CreateOrder 创建意向单 |
| 119 | +func (service OrderService) CreateOrder(command command.CreateOrderCommand) error { | ||
| 120 | var ( | 120 | var ( |
| 121 | transactionContext, _ = factory.CreateTransactionContext(nil) | 121 | transactionContext, _ = factory.CreateTransactionContext(nil) |
| 122 | err error | 122 | err error |
| @@ -150,7 +150,7 @@ func (service OrderService) CreateOrderPurpose(command command.CreateOrderComman | @@ -150,7 +150,7 @@ func (service OrderService) CreateOrderPurpose(command command.CreateOrderComman | ||
| 150 | } | 150 | } |
| 151 | newOrder := &domain.Order{ | 151 | newOrder := &domain.Order{ |
| 152 | //订单类型 | 152 | //订单类型 |
| 153 | - OrderType: domain.OrderIntention, | 153 | + OrderType: command.OrderType, |
| 154 | //订单编号 | 154 | //订单编号 |
| 155 | OrderCode: command.OrderCode, | 155 | OrderCode: command.OrderCode, |
| 156 | //订单名称 | 156 | //订单名称 |
| @@ -160,11 +160,11 @@ func (service OrderService) CreateOrderPurpose(command command.CreateOrderComman | @@ -160,11 +160,11 @@ func (service OrderService) CreateOrderPurpose(command command.CreateOrderComman | ||
| 160 | //数量 | 160 | //数量 |
| 161 | OrderCount: command.OrderCount, | 161 | OrderCount: command.OrderCount, |
| 162 | //实际数量 | 162 | //实际数量 |
| 163 | - OrderActualCount: 0, | 163 | + OrderActualCount: command.OrderActualCount, |
| 164 | //订单金额 | 164 | //订单金额 |
| 165 | OrderAmount: command.OrderAmount, | 165 | OrderAmount: command.OrderAmount, |
| 166 | //实际订单金额 | 166 | //实际订单金额 |
| 167 | - OrderActualAmount: 0, | 167 | + OrderActualAmount: command.OrderActualAmount, |
| 168 | //订单已支付分红金额(货款) | 168 | //订单已支付分红金额(货款) |
| 169 | OrderPaymentAmount: 0, | 169 | OrderPaymentAmount: 0, |
| 170 | //订单区域信息 | 170 | //订单区域信息 |
| @@ -224,6 +224,9 @@ func (service OrderService) UpdateOrderPurpose(command command.UpdateOrderComman | @@ -224,6 +224,9 @@ func (service OrderService) UpdateOrderPurpose(command command.UpdateOrderComman | ||
| 224 | if err != nil { | 224 | if err != nil { |
| 225 | return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | 225 | return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) |
| 226 | } | 226 | } |
| 227 | + if orderData.OrderType != domain.OrderIntention { | ||
| 228 | + return lib.ThrowError(lib.BUSINESS_ERROR, "订单不是意向单") | ||
| 229 | + } | ||
| 227 | err = orderData.Update(map[string]interface{}{ | 230 | err = orderData.Update(map[string]interface{}{ |
| 228 | //订单编号 | 231 | //订单编号 |
| 229 | "orderCode": command.OrderCode, | 232 | "orderCode": command.OrderCode, |
| @@ -333,6 +336,7 @@ func (service OrderService) UpdateOrderReal(command command.UpdateOrderRealComma | @@ -333,6 +336,7 @@ func (service OrderService) UpdateOrderReal(command command.UpdateOrderRealComma | ||
| 333 | "partnerBonusPercent": command.PartnerBonusPercent, | 336 | "partnerBonusPercent": command.PartnerBonusPercent, |
| 334 | "salesmanBonusPercent": command.SalesmanBonusPercent, | 337 | "salesmanBonusPercent": command.SalesmanBonusPercent, |
| 335 | "orderStatus": command.OrderStatus, | 338 | "orderStatus": command.OrderStatus, |
| 339 | + "orderType": domain.OrderReal, | ||
| 336 | }) | 340 | }) |
| 337 | if err != nil { | 341 | if err != nil { |
| 338 | return lib.ThrowError(lib.BUSINESS_ERROR, err.Error()) | 342 | return lib.ThrowError(lib.BUSINESS_ERROR, err.Error()) |
| 1 | +package controllers |
| @@ -51,6 +51,8 @@ type orderDetail struct { | @@ -51,6 +51,8 @@ type orderDetail struct { | ||
| 51 | OrderDist string `json:"orderDist"` | 51 | OrderDist string `json:"orderDist"` |
| 52 | //id | 52 | //id |
| 53 | Id int64 `json:"id"` | 53 | Id int64 `json:"id"` |
| 54 | + //订单状态 | ||
| 55 | + OrderStatue int `json:"orderStatue"` | ||
| 54 | } | 56 | } |
| 55 | 57 | ||
| 56 | //UpdateOrderPurpose 更新意向订单 | 58 | //UpdateOrderPurpose 更新意向订单 |
| @@ -102,8 +104,10 @@ func (c *OrderController) addOrderPurpose(param orderDetail) error { | @@ -102,8 +104,10 @@ func (c *OrderController) addOrderPurpose(param orderDetail) error { | ||
| 102 | PartnerBonusPercent: param.PartnerRatio, | 104 | PartnerBonusPercent: param.PartnerRatio, |
| 103 | //业务员分红百分比 | 105 | //业务员分红百分比 |
| 104 | SalesmanBonusPercent: param.SalesmanRatio, | 106 | SalesmanBonusPercent: param.SalesmanRatio, |
| 107 | + //订单类型 | ||
| 108 | + OrderType: domain.OrderIntention, | ||
| 105 | } | 109 | } |
| 106 | - err := orderSrv.CreateOrderPurpose(Createcmd) | 110 | + err := orderSrv.CreateOrder(Createcmd) |
| 107 | return err | 111 | return err |
| 108 | } | 112 | } |
| 109 | 113 | ||
| @@ -308,6 +312,8 @@ func (c *OrderController) PageListOrderReal() { | @@ -308,6 +312,8 @@ func (c *OrderController) PageListOrderReal() { | ||
| 308 | "orderName": orderinfo.OrderName, | 312 | "orderName": orderinfo.OrderName, |
| 309 | "OrderNum": orderinfo.OrderCount, | 313 | "OrderNum": orderinfo.OrderCount, |
| 310 | "orderPrice": orderinfo.OrderAmount, | 314 | "orderPrice": orderinfo.OrderAmount, |
| 315 | + "orderActualNum": orderinfo.OrderActualCount, | ||
| 316 | + "orderActualPrice": orderinfo.OrderActualAmount, | ||
| 311 | "orderDist": orderinfo.OrderRegionInfo.RegionName, | 317 | "orderDist": orderinfo.OrderRegionInfo.RegionName, |
| 312 | "orderStatue": orderinfo.OrderStatus, | 318 | "orderStatue": orderinfo.OrderStatus, |
| 313 | } | 319 | } |
| @@ -328,7 +334,155 @@ func (c *OrderController) OrderPurposeToReal() { | @@ -328,7 +334,155 @@ func (c *OrderController) OrderPurposeToReal() { | ||
| 328 | c.ResponseError(errors.New("json数据解析失败")) | 334 | c.ResponseError(errors.New("json数据解析失败")) |
| 329 | return | 335 | return |
| 330 | } | 336 | } |
| 337 | + cmd := orderCmd.UpdateOrderRealCommand{ | ||
| 338 | + Id: param.Id, | ||
| 339 | + OrderCode: param.OrderId, | ||
| 340 | + OrderName: param.OrderName, | ||
| 341 | + OrderActualCount: param.OrderNum, | ||
| 342 | + OrderActualAmount: param.OrderPrice, | ||
| 343 | + BuyerPhone: param.BuyerPhone, | ||
| 344 | + BuyerAddress: param.Address, | ||
| 345 | + OrderRegion: param.OrderDist, | ||
| 346 | + PartnerBonusPercent: param.PartnerRatio, | ||
| 347 | + SalesmanBonusPercent: param.SalesmanRatio, | ||
| 348 | + OrderStatus: param.OrderStatue, | ||
| 349 | + } | ||
| 350 | + orderSrv := orderService.NewOrderService(nil) | ||
| 351 | + err = orderSrv.UpdateOrderReal(cmd) | ||
| 352 | + if err != nil { | ||
| 353 | + c.ResponseError(err) | ||
| 354 | + return | ||
| 355 | + } | ||
| 356 | + c.ResponseData(nil) | ||
| 357 | + return | ||
| 358 | +} | ||
| 331 | 359 | ||
| 360 | +//GetOrderReal 获取实发单详情 | ||
| 361 | +func (c *OrderController) GetOrderReal() { | ||
| 362 | + type Parameter struct { | ||
| 363 | + Id string `json:"id"` | ||
| 364 | + } | ||
| 365 | + var ( | ||
| 366 | + param Parameter | ||
| 367 | + err error | ||
| 368 | + ) | ||
| 369 | + if err = c.BindJsonData(¶m); err != nil { | ||
| 370 | + logs.Error(err) | ||
| 371 | + c.ResponseError(errors.New("json数据解析失败")) | ||
| 372 | + return | ||
| 373 | + } | ||
| 374 | + orderid, _ := strconv.ParseInt(param.Id, 10, 64) | ||
| 375 | + orderSrv := orderService.NewOrderService(nil) | ||
| 376 | + orderinfo, err := orderSrv.GetOrder(orderQuery.GetOrderQuery{ | ||
| 377 | + OrderId: orderid, | ||
| 378 | + }) | ||
| 379 | + if err != nil { | ||
| 380 | + c.ResponseError(err) | ||
| 381 | + return | ||
| 382 | + } | ||
| 383 | + rsp := map[string]interface{}{ | ||
| 384 | + "createTime": orderinfo.CreateAt.Local().Format("2006-01-02 15:04:05"), | ||
| 385 | + "updateTime": orderinfo.UpdateAt.Local().Format("2006-01-02 15:04:05"), | ||
| 386 | + "buyer": orderinfo.Buyer.BuyerName, | ||
| 387 | + "buyerPhone": orderinfo.Buyer.ContactInfo, | ||
| 388 | + "Address": orderinfo.Buyer.ShippingAddress, | ||
| 389 | + "id": orderinfo.Id, | ||
| 390 | + "partner": orderinfo.PartnerInfo.Id, | ||
| 391 | + "partnerRatio": orderinfo.PartnerBonusPercent, | ||
| 392 | + "salesmanRatio": orderinfo.SalesmanBonusPercent, | ||
| 393 | + "orderId": orderinfo.OrderCode, | ||
| 394 | + "orderName": orderinfo.OrderName, | ||
| 395 | + "OrderNum": orderinfo.OrderActualCount, | ||
| 396 | + "orderPrice": orderinfo.OrderActualAmount, | ||
| 397 | + "orderDist": orderinfo.OrderRegionInfo.RegionName, | ||
| 398 | + "orderStatue": orderinfo.OrderStatus, | ||
| 399 | + } | ||
| 400 | + c.ResponseData(rsp) | ||
| 401 | +} | ||
| 402 | + | ||
| 403 | +//UpdateOrderReal 更新实发订单数据 | ||
| 404 | +func (c *OrderController) UpdateOrderReal() { | ||
| 405 | + //用与适配前端定义的数据结构 | ||
| 406 | + var ( | ||
| 407 | + param orderDetail | ||
| 408 | + err error | ||
| 409 | + ) | ||
| 410 | + if err = c.BindJsonData(¶m); err != nil { | ||
| 411 | + logs.Error(err) | ||
| 412 | + c.ResponseError(errors.New("json数据解析失败")) | ||
| 413 | + return | ||
| 414 | + } | ||
| 415 | + if param.Id == 0 { | ||
| 416 | + err = c.addOrderReal(param) | ||
| 417 | + } else { | ||
| 418 | + err = c.editOrderPurpose(param) | ||
| 419 | + } | ||
| 420 | + if err != nil { | ||
| 421 | + c.ResponseError(err) | ||
| 422 | + } | ||
| 332 | c.ResponseData(nil) | 423 | c.ResponseData(nil) |
| 333 | return | 424 | return |
| 334 | } | 425 | } |
| 426 | + | ||
| 427 | +//addOrderReal 添加实发订单 | ||
| 428 | +func (c *OrderController) addOrderReal(param orderDetail) error { | ||
| 429 | + orderSrv := orderService.NewOrderService(nil) | ||
| 430 | + Createcmd := orderCmd.CreateOrderCommand{ | ||
| 431 | + //订单区域 | ||
| 432 | + OrderRegion: param.OrderDist, | ||
| 433 | + //订单编号 | ||
| 434 | + OrderCode: param.OrderId, | ||
| 435 | + //订单名称 | ||
| 436 | + OrderName: param.OrderName, | ||
| 437 | + //数量 | ||
| 438 | + OrderCount: param.OrderNum, | ||
| 439 | + OrderActualCount: param.OrderNum, | ||
| 440 | + //订单金额 | ||
| 441 | + OrderAmount: param.OrderPrice, | ||
| 442 | + OrderActualAmount: param.OrderPrice, | ||
| 443 | + //买家 | ||
| 444 | + BuyerName: param.Buyer, | ||
| 445 | + //买家电话 | ||
| 446 | + BuyerPhone: param.BuyerPhone, | ||
| 447 | + //地址 | ||
| 448 | + BuyerAddress: param.Address, | ||
| 449 | + //合伙人数据 | ||
| 450 | + PartnerId: param.Partner, | ||
| 451 | + //合伙人分红百分比 | ||
| 452 | + PartnerBonusPercent: param.PartnerRatio, | ||
| 453 | + //业务员分红百分比 | ||
| 454 | + SalesmanBonusPercent: param.SalesmanRatio, | ||
| 455 | + //订单类型 | ||
| 456 | + OrderType: domain.OrderReal, | ||
| 457 | + } | ||
| 458 | + err := orderSrv.CreateOrder(Createcmd) | ||
| 459 | + return err | ||
| 460 | +} | ||
| 461 | + | ||
| 462 | +//editOrderReal 更新实发订单 | ||
| 463 | +func (c *OrderController) editOrderReal(param orderDetail) error { | ||
| 464 | + updateCmd := orderCmd.UpdateOrderRealCommand{ | ||
| 465 | + Id: param.Id, | ||
| 466 | + //订单区域 | ||
| 467 | + OrderRegion: param.OrderDist, | ||
| 468 | + //订单编号 | ||
| 469 | + OrderCode: param.OrderId, | ||
| 470 | + //订单名称 | ||
| 471 | + OrderName: param.OrderName, | ||
| 472 | + //数量 | ||
| 473 | + OrderActualCount: param.OrderNum, | ||
| 474 | + //订单金额 | ||
| 475 | + OrderActualAmount: param.OrderPrice, | ||
| 476 | + //买家电话 | ||
| 477 | + BuyerPhone: param.BuyerPhone, | ||
| 478 | + //地址 | ||
| 479 | + BuyerAddress: param.Address, | ||
| 480 | + //合伙人分红百分比 | ||
| 481 | + PartnerBonusPercent: param.PartnerRatio, | ||
| 482 | + //业务员分红百分比 | ||
| 483 | + SalesmanBonusPercent: param.SalesmanRatio, | ||
| 484 | + } | ||
| 485 | + orderSrv := orderService.NewOrderService(nil) | ||
| 486 | + err := orderSrv.UpdateOrderReal(updateCmd) | ||
| 487 | + return err | ||
| 488 | +} |
| @@ -37,11 +37,13 @@ func init() { | @@ -37,11 +37,13 @@ func init() { | ||
| 37 | beego.NSRouter("/purpose/update", &controllers.OrderController{}, "POST:UpdateOrderPurpose"), | 37 | beego.NSRouter("/purpose/update", &controllers.OrderController{}, "POST:UpdateOrderPurpose"), |
| 38 | beego.NSRouter("/purpose/detail", &controllers.OrderController{}, "POST:GetOrderPurpose"), | 38 | beego.NSRouter("/purpose/detail", &controllers.OrderController{}, "POST:GetOrderPurpose"), |
| 39 | beego.NSRouter("/purpose/del", &controllers.OrderController{}, "POST:RemoveOrderPurpose"), | 39 | beego.NSRouter("/purpose/del", &controllers.OrderController{}, "POST:RemoveOrderPurpose"), |
| 40 | - | 40 | + beego.NSRouter("/purpose/convert", &controllers.OrderController{}, "POST:OrderPurposeToReal"), |
| 41 | beego.NSRouter("/actual/list", &controllers.OrderController{}, "POST:PageListOrderReal"), | 41 | beego.NSRouter("/actual/list", &controllers.OrderController{}, "POST:PageListOrderReal"), |
| 42 | - beego.NSRouter("/actual/update", &controllers.OrderController{}, "POST:UpdateOrderPurpose"), | ||
| 43 | - beego.NSRouter("/actual/detail", &controllers.OrderController{}, "POST:GetOrderPurpose"), | 42 | + beego.NSRouter("/actual/update", &controllers.OrderController{}, "POST:UpdateOrderReal"), |
| 43 | + beego.NSRouter("/actual/detail", &controllers.OrderController{}, "POST:GetOrderReal"), | ||
| 44 | ), | 44 | ), |
| 45 | + beego.NSNamespace("/common"), // beego.NSRouter("/partner", &controllers.OrderController{}, "POST:PageListOrderPurpose"), | ||
| 46 | + | ||
| 45 | ) | 47 | ) |
| 46 | beego.AddNamespace(adminRouter) | 48 | beego.AddNamespace(adminRouter) |
| 47 | } | 49 | } |
-
请 注册 或 登录 后发表评论