正在显示
1 个修改的文件
包含
26 行增加
和
8 行删除
@@ -298,16 +298,30 @@ func (c *OrderInfoController) editOrderPurpose(param postPurposeOrderDetail) err | @@ -298,16 +298,30 @@ func (c *OrderInfoController) editOrderPurpose(param postPurposeOrderDetail) err | ||
298 | return err | 298 | return err |
299 | } | 299 | } |
300 | 300 | ||
301 | +type postOrderPurposeDelivery struct { | ||
302 | + ShipmentsId string `json:"shipmentsId"` //发货单号 | ||
303 | + Id string `json:"id"` //订单id | ||
304 | + ProductDetail []postOrderGood `json:"productDetail"` | ||
305 | +} | ||
306 | + | ||
307 | +func (postData postOrderPurposeDelivery) Valid() error { | ||
308 | + if len(postData.ShipmentsId) == 0 { | ||
309 | + return lib.ThrowError(lib.ARG_ERROR, "发货单号必填") | ||
310 | + } | ||
311 | + for i := range postData.ProductDetail { | ||
312 | + if err := postData.ProductDetail[i].Valid(); err != nil { | ||
313 | + return err | ||
314 | + } | ||
315 | + } | ||
316 | + return nil | ||
317 | +} | ||
318 | + | ||
301 | //OrderPurposeDelivery 发货 意向订单转实发单 | 319 | //OrderPurposeDelivery 发货 意向订单转实发单 |
302 | func (c *OrderInfoController) OrderPurposeDelivery() { | 320 | func (c *OrderInfoController) OrderPurposeDelivery() { |
303 | //用与适配前端定义的数据结构 | 321 | //用与适配前端定义的数据结构 |
304 | - type PostParameter struct { | ||
305 | - ShipmentsId string `json:"shipmentsId"` //发货单号 | ||
306 | - Id string `json:"id"` //订单id | ||
307 | - ProductDetail []postOrderGood `json:"productDetail"` | ||
308 | - } | 322 | + |
309 | var ( | 323 | var ( |
310 | - param PostParameter | 324 | + param postOrderPurposeDelivery |
311 | err error | 325 | err error |
312 | ) | 326 | ) |
313 | if err = c.BindJsonData(¶m); err != nil { | 327 | if err = c.BindJsonData(¶m); err != nil { |
@@ -315,13 +329,16 @@ func (c *OrderInfoController) OrderPurposeDelivery() { | @@ -315,13 +329,16 @@ func (c *OrderInfoController) OrderPurposeDelivery() { | ||
315 | c.ResponseError(errors.New("json数据解析失败")) | 329 | c.ResponseError(errors.New("json数据解析失败")) |
316 | return | 330 | return |
317 | } | 331 | } |
318 | - orderSrv := orderService.NewOrderInfoService(nil) | ||
319 | 332 | ||
320 | orderid, _ := strconv.ParseInt(param.Id, 10, 64) | 333 | orderid, _ := strconv.ParseInt(param.Id, 10, 64) |
321 | if orderid <= 0 { | 334 | if orderid <= 0 { |
322 | c.ResponseError(errors.New("参数错误")) | 335 | c.ResponseError(errors.New("参数错误")) |
323 | return | 336 | return |
324 | } | 337 | } |
338 | + if err = param.Valid(); err != nil { | ||
339 | + c.ResponseError(err) | ||
340 | + return | ||
341 | + } | ||
325 | goods := []orderCmd.OrderGoodData{} | 342 | goods := []orderCmd.OrderGoodData{} |
326 | for _, v := range param.ProductDetail { | 343 | for _, v := range param.ProductDetail { |
327 | g := orderCmd.OrderGoodData{ | 344 | g := orderCmd.OrderGoodData{ |
@@ -334,6 +351,7 @@ func (c *OrderInfoController) OrderPurposeDelivery() { | @@ -334,6 +351,7 @@ func (c *OrderInfoController) OrderPurposeDelivery() { | ||
334 | OrderId: orderid, DeliveryCode: param.ShipmentsId, | 351 | OrderId: orderid, DeliveryCode: param.ShipmentsId, |
335 | DeliveryTime: time.Now(), Goods: goods, | 352 | DeliveryTime: time.Now(), Goods: goods, |
336 | } | 353 | } |
354 | + orderSrv := orderService.NewOrderInfoService(nil) | ||
337 | err = orderSrv.Delivery(deliveryCommand) | 355 | err = orderSrv.Delivery(deliveryCommand) |
338 | if err != nil { | 356 | if err != nil { |
339 | c.ResponseError(err) | 357 | c.ResponseError(err) |
@@ -564,7 +582,7 @@ func (c *OrderInfoController) editOrderReal(param postRealOrderDetail) error { | @@ -564,7 +582,7 @@ func (c *OrderInfoController) editOrderReal(param postRealOrderDetail) error { | ||
564 | } | 582 | } |
565 | updatecmd := orderCmd.UpdateOrderCommand{ | 583 | updatecmd := orderCmd.UpdateOrderCommand{ |
566 | Id: param.Id, | 584 | Id: param.Id, |
567 | - OrderType: domain.OrderIntention, | 585 | + OrderType: domain.OrderReal, |
568 | OrderCode: param.OrderId, | 586 | OrderCode: param.OrderId, |
569 | DeliveryCode: param.ShipmentsId, | 587 | DeliveryCode: param.ShipmentsId, |
570 | BuyerName: param.BuyerName, | 588 | BuyerName: param.BuyerName, |
-
请 注册 或 登录 后发表评论