作者 tangxvhui

新增:意向单发货

@@ -474,6 +474,7 @@ func (service OrderInfoService) Delivery(cmd command.OrderDeliveryCommand) error @@ -474,6 +474,7 @@ func (service OrderInfoService) Delivery(cmd command.OrderDeliveryCommand) error
474 } 474 }
475 oldOrderData.DeliveryCode = cmd.DeliveryCode 475 oldOrderData.DeliveryCode = cmd.DeliveryCode
476 oldOrderData.DeliveryTime = time.Now() 476 oldOrderData.DeliveryTime = time.Now()
  477 + //变更订单类型
477 oldOrderData.OrderType = domain.OrderReal 478 oldOrderData.OrderType = domain.OrderReal
478 err = oldOrderData.Compute() 479 err = oldOrderData.Compute()
479 if err != nil { 480 if err != nil {
@@ -3,6 +3,7 @@ package controllers @@ -3,6 +3,7 @@ package controllers
3 import ( 3 import (
4 "errors" 4 "errors"
5 "strconv" 5 "strconv"
  6 + "time"
6 7
7 "github.com/astaxie/beego/logs" 8 "github.com/astaxie/beego/logs"
8 orderCmd "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/application/orderinfo/command" 9 orderCmd "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/application/orderinfo/command"
@@ -261,8 +262,13 @@ func (c *OrderInfoController) editOrderPurpose(param postPurposeOrderDetail) err @@ -261,8 +262,13 @@ func (c *OrderInfoController) editOrderPurpose(param postPurposeOrderDetail) err
261 //OrderPurposeDelivery 发货 意向订单转实发单 262 //OrderPurposeDelivery 发货 意向订单转实发单
262 func (c *OrderInfoController) OrderPurposeDelivery() { 263 func (c *OrderInfoController) OrderPurposeDelivery() {
263 //用与适配前端定义的数据结构 264 //用与适配前端定义的数据结构
  265 + type PostParameter struct {
  266 + ShipmentsId string `json:"shipmentsId"` //发货单号
  267 + Id string `json:"id"` //订单id
  268 + ProductDetail []postPurposeOrderGood `json:"productDetail"`
  269 + }
264 var ( 270 var (
265 - param orderDetail 271 + param PostParameter
266 err error 272 err error
267 ) 273 )
268 if err = c.BindJsonData(&param); err != nil { 274 if err = c.BindJsonData(&param); err != nil {
@@ -271,7 +277,24 @@ func (c *OrderInfoController) OrderPurposeDelivery() { @@ -271,7 +277,24 @@ func (c *OrderInfoController) OrderPurposeDelivery() {
271 return 277 return
272 } 278 }
273 orderSrv := orderService.NewOrderInfoService(nil) 279 orderSrv := orderService.NewOrderInfoService(nil)
274 - deliveryCommand := orderCmd.OrderDeliveryCommand{} 280 +
  281 + orderid, _ := strconv.ParseInt(param.Id, 10, 64)
  282 + if orderid <= 0 {
  283 + c.ResponseError(errors.New("参数错误"))
  284 + return
  285 + }
  286 + goods := []orderCmd.OrderGoodData{}
  287 + for _, v := range param.ProductDetail {
  288 + g := orderCmd.OrderGoodData{
  289 + Id: v.Id, GoodName: v.ProductName, PlanGoodNumber: v.OrderNum,
  290 + Price: v.Univalence, PartnerBonusPercent: v.PartnerRatio,
  291 + }
  292 + goods = append(goods, g)
  293 + }
  294 + deliveryCommand := orderCmd.OrderDeliveryCommand{
  295 + OrderId: orderid, DeliveryCode: param.ShipmentsId,
  296 + DeliveryTime: time.Now(), Goods: goods,
  297 + }
275 err = orderSrv.Delivery(deliveryCommand) 298 err = orderSrv.Delivery(deliveryCommand)
276 if err != nil { 299 if err != nil {
277 c.ResponseError(err) 300 c.ResponseError(err)
@@ -42,7 +42,7 @@ func init() { @@ -42,7 +42,7 @@ func init() {
42 beego.NSRouter("/purpose/update", &controllers.OrderInfoController{}, "POST:UpdateOrderPurpose"), 42 beego.NSRouter("/purpose/update", &controllers.OrderInfoController{}, "POST:UpdateOrderPurpose"),
43 beego.NSRouter("/purpose/detail", &controllers.OrderInfoController{}, "POST:GetOrderPurpose"), 43 beego.NSRouter("/purpose/detail", &controllers.OrderInfoController{}, "POST:GetOrderPurpose"),
44 beego.NSRouter("/purpose/del", &controllers.OrderInfoController{}, "POST:RemoveOrderPurpose"), 44 beego.NSRouter("/purpose/del", &controllers.OrderInfoController{}, "POST:RemoveOrderPurpose"),
45 - beego.NSRouter("/purpose/convert", &controllers.OrderInfoController{}, "POST:OrderPurposeDelivery"), 45 + beego.NSRouter("/purpose/sendout", &controllers.OrderInfoController{}, "POST:OrderPurposeDelivery"),
46 46
47 beego.NSRouter("/actual/list", &controllers.OrderController{}, "POST:PageListOrderReal"), 47 beego.NSRouter("/actual/list", &controllers.OrderController{}, "POST:PageListOrderReal"),
48 beego.NSRouter("/actual/update", &controllers.OrderController{}, "POST:UpdateOrderReal"), 48 beego.NSRouter("/actual/update", &controllers.OrderController{}, "POST:UpdateOrderReal"),