order_info_controlller.go
20.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
package controllers
import (
"errors"
"fmt"
"regexp"
"strconv"
"strings"
"time"
"unicode/utf8"
"github.com/astaxie/beego/logs"
orderCmd "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/application/orderinfo/command"
orderQuery "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/application/orderinfo/query"
orderService "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/application/orderinfo/service"
"gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/domain"
"gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/lib"
)
type OrderInfoController struct {
BaseController
}
////Prepare 重写 BaseController 的Prepare方法
func (c *OrderInfoController) Prepare() {
c.BaseController.Prepare()
return
if ok := c.ValidJWTToken(); !ok {
return
}
if ok := c.ValidAdminPermission(domain.PERMISSION_ORDER); !ok {
return
}
}
//PageListOrderPurpose 分页获取意向订单列表
func (c *OrderInfoController) PageListOrderPurpose() {
type Parameter struct {
SearchText string `json:"searchText"`
Partner int64 `json:"partner"`
PageSize int `json:"pageSize"`
PageNumber int `json:"pageNumber"`
}
var (
param Parameter
err error
)
if err = c.BindJsonData(¶m); err != nil {
logs.Error(err)
c.ResponseError(errors.New("json数据解析失败"))
return
}
if param.PageNumber == 0 {
param.PageNumber = 1
}
if param.PageSize == 0 {
param.PageSize = 20
}
companyId := c.GetUserCompany()
orderSrv := orderService.NewOrderInfoService(nil)
orderinfos, cnt, err := orderSrv.PageListOrderBase(orderQuery.ListOrderBaseQuery{
PartnerId: param.Partner,
OrderCode: param.SearchText,
OrderType: domain.OrderIntention,
Limit: param.PageSize,
Offset: (param.PageNumber - 1) * param.PageSize,
CompanyId: companyId,
})
if err != nil {
c.ResponseError(err)
return
}
rsp := []map[string]interface{}{}
for i := range orderinfos {
orderinfo := orderinfos[i]
m := map[string]interface{}{
"createTime": orderinfo.CreateTime.Local().Format("2006-01-02 15:04:05"),
"updateTime": orderinfo.UpdateTime.Local().Format("2006-01-02 15:04:05"),
"buyer": orderinfo.Buyer.BuyerName,
"id": orderinfo.Id,
"orderId": orderinfo.OrderCode,
"partner": orderinfo.PartnerInfo.PartnerName,
"orderNum": orderinfo.OrderCompute.PlanOrderCount,
"orderPrice": orderinfo.OrderCompute.PlanOrderAmount,
"orderDist": orderinfo.RegionInfo.RegionName,
}
rsp = append(rsp, m)
}
c.ResponsePageList(rsp, cnt, param.PageNumber)
}
//GetOrderPurpose 获取意向订单详情
func (c *OrderInfoController) GetOrderPurpose() {
type Parameter struct {
Id string `json:"id"`
}
var (
param Parameter
err error
)
if err = c.BindJsonData(¶m); err != nil {
logs.Error(err)
c.ResponseError(errors.New("json数据解析失败"))
return
}
orderid, _ := strconv.ParseInt(param.Id, 10, 64)
companyId := c.GetUserCompany()
orderSrv := orderService.NewOrderInfoService(nil)
orderinfo, err := orderSrv.GetOrderDetail(orderQuery.GetOrderQuery{
OrderId: orderid,
CompanyId: companyId,
})
if err != nil {
c.ResponseError(err)
return
}
if orderinfo.OrderType != domain.OrderIntention {
c.ResponseError(errors.New("参数错误"))
return
}
allGoods := []map[string]interface{}{}
for _, v := range orderinfo.Goods {
m := map[string]interface{}{
"id": v.Id,
"productName": v.GoodName,
"orderNum": v.PlanGoodNumber,
"univalence": v.Price,
"partnerRatio": v.PartnerBonusPercent,
"orderPrice": v.GoodCompute.PlanAmount,
}
allGoods = append(allGoods, m)
}
rsp := map[string]interface{}{
"buyer": orderinfo.Buyer.BuyerName,
"id": orderinfo.Id,
"partnerID": orderinfo.PartnerInfo.Id,
"partner": orderinfo.PartnerInfo.PartnerName,
"orderDist": orderinfo.RegionInfo.RegionName,
"orderId": orderinfo.OrderCode,
"product": allGoods,
"commissionProportion": orderinfo.SalesmanBonusPercent,
"orderNumCount": orderinfo.OrderCompute.PlanOrderCount,
"orderAmountAdjustmentCount": orderinfo.OrderCompute.PlanOrderAmount,
}
c.ResponseData(rsp)
}
//RemoveOrderPurpose 删除意向订单
func (c *OrderInfoController) RemoveOrderPurpose() {
type Parameter struct {
Id int64 `json:"id"`
}
var (
param Parameter
err error
)
if err = c.BindJsonData(¶m); err != nil {
logs.Error(err)
c.ResponseError(errors.New("json数据解析失败"))
return
}
companyId := c.GetUserCompany()
orderSrv := orderService.NewOrderInfoService(nil)
err = orderSrv.DeleteOrder(param.Id, companyId)
if err != nil {
c.ResponseError(err)
return
}
c.ResponseData(nil)
}
//postPurposeOrderDetail 请求添加/更新的订单数据
type postPurposeOrderDetail struct {
Id int64 `json:"id"`
//订单编号
OrderId string `json:"orderId"`
//买家姓名
BuyerName string `json:"buyer"`
//对应合伙人 id
PartnerId int64 `json:"partnerID"`
//业务员抽成比例
CommissionProportion float64 `json:"commissionProportion"`
//订单区域
OrderDist string `json:"orderDist"`
//商品
Product []postOrderGood `json:"product"`
}
func (postData *postPurposeOrderDetail) Valid() error {
postData.OrderId = strings.TrimSpace(postData.OrderId)
postData.BuyerName = strings.TrimSpace(postData.BuyerName)
postData.OrderDist = strings.TrimSpace(postData.OrderDist)
if len(postData.OrderId) == 0 {
return lib.ThrowError(lib.ARG_ERROR, "订单编号必填")
}
if len(postData.BuyerName) == 0 {
return lib.ThrowError(lib.ARG_ERROR, "买家信息必填")
}
if postData.PartnerId == 0 {
return lib.ThrowError(lib.ARG_ERROR, "合伙人信息必填")
}
if len(postData.OrderDist) == 0 {
return lib.ThrowError(lib.ARG_ERROR, "订单区域必填")
}
if len(postData.Product) == 0 {
return lib.ThrowError(lib.ARG_ERROR, "货品列表必填")
}
if len(postData.Product) > 50 {
return lib.ThrowError(lib.ARG_ERROR, "货品列表最多50项")
}
for i := range postData.Product {
if err := postData.Product[i].Valid(); err != nil {
return err
}
}
return nil
}
//PostPurposeOrderGood 请求添加/更新订单中的货品
type postOrderGood struct {
Id int64 `json:"id"`
ProductName string `json:"productName"`
OrderNum int `json:"orderNum"`
Univalence float64 `json:"univalence"`
PartnerRatio float64 `json:"partnerRatio"`
}
func (postData *postOrderGood) Valid() error {
postData.ProductName = strings.TrimSpace(postData.ProductName)
lenProductName := utf8.RuneCountInString(postData.ProductName)
if lenProductName == 0 {
return lib.ThrowError(lib.ARG_ERROR, "商品名称必填")
}
if lenProductName > 50 {
return lib.ThrowError(lib.ARG_ERROR, "商品名称最多50位")
}
if postData.OrderNum >= 1e16 {
return lib.ThrowError(lib.ARG_ERROR, "商品数量最多16位")
}
if postData.Univalence >= 1e16 {
return lib.ThrowError(lib.ARG_ERROR, "商品单价最多16位")
}
if postData.PartnerRatio > 100 {
return lib.ThrowError(lib.ARG_ERROR, "合伙人分红比例超额")
}
partnerRatio := fmt.Sprint(postData.PartnerRatio)
regexpStr := `^(100|[1-9]\d|\d)(.\d{1,2})?$`
ok := regexp.MustCompile(regexpStr).MatchString(partnerRatio)
if !ok {
return lib.ThrowError(lib.ARG_ERROR, "合伙人分红比例精确到小数点2位")
}
return nil
}
//UpdateOrderPurpose 更新意向订单
func (c *OrderInfoController) UpdateOrderPurpose() {
//用与适配前端定义的数据结构
var (
param postPurposeOrderDetail
err error
)
if err = c.BindJsonData(¶m); err != nil {
logs.Error(err)
c.ResponseError(errors.New("json数据解析失败"))
return
}
if err := param.Valid(); err != nil {
c.ResponseError(err)
return
}
if param.Id == 0 {
err = c.addOrderPurpose(param)
} else {
err = c.editOrderPurpose(param)
}
if err != nil {
c.ResponseError(err)
}
c.ResponseData(nil)
return
}
func (c *OrderInfoController) addOrderPurpose(param postPurposeOrderDetail) error {
newGoods := []orderCmd.OrderGoodData{}
for _, v := range param.Product {
g := orderCmd.OrderGoodData{
GoodName: v.ProductName,
PlanGoodNumber: v.OrderNum,
Price: v.Univalence,
PartnerBonusPercent: v.PartnerRatio,
}
newGoods = append(newGoods, g)
}
companyId := c.GetUserCompany()
createcmd := orderCmd.CreateOrderCommand{
OrderType: domain.OrderIntention,
OrderCode: param.OrderId,
DeliveryCode: "",
BuyerName: param.BuyerName,
OrderRegion: param.OrderDist,
PartnerId: param.PartnerId,
SalesmanBonusPercent: param.CommissionProportion,
Goods: newGoods,
CompanyId: companyId,
}
orderSrv := orderService.NewOrderInfoService(nil)
_, err := orderSrv.CreateNewOrder(createcmd)
return err
}
func (c *OrderInfoController) editOrderPurpose(param postPurposeOrderDetail) error {
orderSrv := orderService.NewOrderInfoService(nil)
newGoods := []orderCmd.OrderGoodData{}
for _, v := range param.Product {
g := orderCmd.OrderGoodData{
GoodName: v.ProductName,
PlanGoodNumber: v.OrderNum,
Price: v.Univalence,
PartnerBonusPercent: v.PartnerRatio,
}
newGoods = append(newGoods, g)
}
companyId := c.GetUserCompany()
updatecmd := orderCmd.UpdateOrderCommand{
Id: param.Id,
OrderType: domain.OrderIntention,
OrderCode: param.OrderId,
DeliveryCode: "",
BuyerName: param.BuyerName,
OrderRegion: param.OrderDist,
PartnerId: param.PartnerId,
SalesmanBonusPercent: param.CommissionProportion,
Goods: newGoods,
CompanyId: companyId,
}
_, err := orderSrv.UpdateOrderData(updatecmd)
return err
}
type postOrderPurposeDelivery struct {
ShipmentsId string `json:"shipmentsId"` //发货单号
Id string `json:"id"` //订单id
ProductDetail []postOrderGood `json:"productDetail"`
}
func (postData *postOrderPurposeDelivery) Valid() error {
postData.ShipmentsId = strings.TrimSpace(postData.ShipmentsId)
lenShipmentsId := utf8.RuneCountInString(postData.ShipmentsId)
if lenShipmentsId == 0 {
return lib.ThrowError(lib.ARG_ERROR, "发货单号必填")
}
if lenShipmentsId > 50 {
return lib.ThrowError(lib.ARG_ERROR, "发货单号最多50位")
}
for i := range postData.ProductDetail {
if err := postData.ProductDetail[i].Valid(); err != nil {
return err
}
}
return nil
}
//OrderPurposeDelivery 发货 意向订单转实发单
func (c *OrderInfoController) OrderPurposeDelivery() {
//用与适配前端定义的数据结构
var (
param postOrderPurposeDelivery
err error
)
if err = c.BindJsonData(¶m); err != nil {
logs.Error(err)
c.ResponseError(errors.New("json数据解析失败"))
return
}
orderid, _ := strconv.ParseInt(param.Id, 10, 64)
if orderid <= 0 {
c.ResponseError(errors.New("参数错误"))
return
}
if err = param.Valid(); err != nil {
c.ResponseError(err)
return
}
goods := []orderCmd.OrderGoodData{}
for _, v := range param.ProductDetail {
g := orderCmd.OrderGoodData{
Id: v.Id, GoodName: v.ProductName, PlanGoodNumber: v.OrderNum,
Price: v.Univalence, PartnerBonusPercent: v.PartnerRatio,
}
goods = append(goods, g)
}
companyId := c.GetUserCompany()
deliveryCommand := orderCmd.OrderDeliveryCommand{
OrderId: orderid, DeliveryCode: param.ShipmentsId,
DeliveryTime: time.Now(), Goods: goods, CompanyId: companyId,
}
orderSrv := orderService.NewOrderInfoService(nil)
err = orderSrv.Delivery(deliveryCommand)
if err != nil {
c.ResponseError(err)
}
c.ResponseData(nil)
return
}
//PageListOrderReal 获取实发订单列表
func (c *OrderInfoController) PageListOrderReal() {
type Parameter struct {
SearchText string `json:"searchText"`
Partner int64 `json:"partner"`
PageSize int `json:"pageSize"`
PageNumber int `json:"pageNumber"`
}
var (
param Parameter
err error
)
if err = c.BindJsonData(¶m); err != nil {
logs.Error(err)
c.ResponseError(errors.New("json数据解析失败"))
return
}
if param.PageNumber == 0 {
param.PageNumber = 1
}
if param.PageSize == 0 {
param.PageSize = 20
}
companyId := c.GetUserCompany()
orderSrv := orderService.NewOrderInfoService(nil)
orderinfos, cnt, err := orderSrv.PageListOrderBase(orderQuery.ListOrderBaseQuery{
PartnerId: param.Partner,
DeliveryCode: param.SearchText,
OrderType: domain.OrderReal,
Limit: param.PageSize,
Offset: (param.PageNumber - 1) * param.PageSize,
CompanyId: companyId,
})
if err != nil {
c.ResponseError(err)
return
}
rsp := []map[string]interface{}{}
for i := range orderinfos {
orderinfo := orderinfos[i]
m := map[string]interface{}{
"createTime": orderinfo.CreateTime.Local().Format("2006-01-02 15:04:05"),
"updateTime": orderinfo.UpdateTime.Local().Format("2006-01-02 15:04:05"),
"buyer": orderinfo.Buyer.BuyerName,
"id": orderinfo.Id,
"orderId": orderinfo.OrderCode,
"shipmentsId": orderinfo.DeliveryCode,
"partner": orderinfo.PartnerInfo.PartnerName,
"orderNum": orderinfo.OrderCompute.PlanOrderCount,
"orderPrice": orderinfo.OrderCompute.PlanOrderAmount,
"orderDist": orderinfo.RegionInfo.RegionName,
"quantityControl": "",
"priceControl": "",
"status": orderinfo.IsDisable,
}
if orderinfo.OrderCompute.UseOrderCount >= 0 {
m["quantityControl"] = fmt.Sprint(orderinfo.OrderCompute.UseOrderCount)
}
if orderinfo.OrderCompute.UseOrderAmount >= 0 {
m["priceControl"] = fmt.Sprint(orderinfo.OrderCompute.UseOrderAmount)
}
rsp = append(rsp, m)
}
c.ResponsePageList(rsp, cnt, param.PageNumber)
return
}
//GetOrderReal 获取实发订单详情
func (c *OrderInfoController) GetOrderReal() {
type Parameter struct {
Id string `json:"id"`
}
var (
param Parameter
err error
)
if err = c.BindJsonData(¶m); err != nil {
logs.Error(err)
c.ResponseError(errors.New("json数据解析失败"))
return
}
orderid, _ := strconv.ParseInt(param.Id, 10, 64)
if orderid == 0 {
c.ResponseError(errors.New("参数错误"))
return
}
companyId := c.GetUserCompany()
orderSrv := orderService.NewOrderInfoService(nil)
orderinfo, err := orderSrv.GetOrderDetail(orderQuery.GetOrderQuery{
OrderId: orderid,
CompanyId: companyId,
})
if err != nil {
c.ResponseError(err)
return
}
if orderinfo.OrderType != domain.OrderReal {
c.ResponseError(errors.New("参数错误"))
return
}
allGoods := []map[string]interface{}{}
for _, v := range orderinfo.Goods {
m := map[string]interface{}{
"id": v.Id,
"productName": v.GoodName,
"orderNum": v.PlanGoodNumber,
"univalence": v.Price,
"partnerRatio": v.PartnerBonusPercent,
"orderPrice": v.GoodCompute.PlanAmount,
"quantityControl": "",
"priceControl": "",
}
if v.GoodCompute.UseAmount >= 0 {
m["priceControl"] = fmt.Sprint(v.GoodCompute.UseAmount)
}
if v.UseGoodNumber >= 0 {
m["quantityControl"] = fmt.Sprint(v.UseGoodNumber)
}
allGoods = append(allGoods, m)
}
rsp := map[string]interface{}{
"buyer": orderinfo.Buyer.BuyerName,
"id": orderinfo.Id,
"partnerID": orderinfo.PartnerInfo.Id,
"partner": orderinfo.PartnerInfo.PartnerName,
"orderDist": orderinfo.RegionInfo.RegionName,
"orderId": orderinfo.OrderCode,
"shipmentsId": orderinfo.DeliveryCode,
"commissionProportion": orderinfo.SalesmanBonusPercent,
"orderNumCount": orderinfo.OrderCompute.PlanOrderCount,
"orderAmountAdjustmentCount": orderinfo.OrderCompute.PlanOrderAmount,
"orderNumCountControl": "",
"orderAmountAdjustmentCountControl": "",
"product": allGoods,
"create_time": orderinfo.CreateTime.Local().Format("2006-01-02 15:04:06"),
"update_time": orderinfo.UpdateTime.Local().Format("2006-01-02 15:04:06"),
}
if orderinfo.OrderCompute.UseOrderAmount >= 0 {
rsp["orderNumCountControl"] = fmt.Sprint(orderinfo.OrderCompute.UseOrderCount)
}
if orderinfo.OrderCompute.UseOrderCount >= 0 {
rsp["orderAmountAdjustmentCountControl"] = fmt.Sprint(orderinfo.OrderCompute.UseOrderAmount)
}
c.ResponseData(rsp)
return
}
//实际订单
type postRealOrderDetail struct {
postPurposeOrderDetail
ShipmentsId string `json:"shipmentsId"` //发货单号
}
func (postData *postRealOrderDetail) Valid() error {
postData.ShipmentsId = strings.TrimSpace(postData.ShipmentsId)
if len(postData.ShipmentsId) == 0 {
return lib.ThrowError(lib.ARG_ERROR, "订单的发货单号必填")
}
if err := postData.postPurposeOrderDetail.Valid(); err != nil {
return err
}
return nil
}
//UpdateOrderReal 编辑实际订单
func (c *OrderInfoController) UpdateOrderReal() {
//用与适配前端定义的数据结构
var (
param postRealOrderDetail
err error
)
if err = c.BindJsonData(¶m); err != nil {
logs.Error(err)
c.ResponseError(errors.New("json数据解析失败"))
return
}
if err := param.Valid(); err != nil {
c.ResponseError(err)
return
}
if param.Id == 0 {
err = c.addOrderReal(param)
} else {
err = c.editOrderReal(param)
}
if err != nil {
c.ResponseError(err)
}
c.ResponseData(nil)
return
}
func (c *OrderInfoController) addOrderReal(param postRealOrderDetail) error {
orderSrv := orderService.NewOrderInfoService(nil)
newGoods := []orderCmd.OrderGoodData{}
for _, v := range param.Product {
g := orderCmd.OrderGoodData{
GoodName: v.ProductName,
PlanGoodNumber: v.OrderNum,
Price: v.Univalence,
PartnerBonusPercent: v.PartnerRatio,
}
newGoods = append(newGoods, g)
}
companyId := c.GetUserCompany()
createcmd := orderCmd.CreateOrderCommand{
OrderType: domain.OrderReal,
OrderCode: param.OrderId,
DeliveryCode: param.ShipmentsId,
BuyerName: param.BuyerName,
OrderRegion: param.OrderDist,
PartnerId: param.PartnerId,
SalesmanBonusPercent: param.CommissionProportion,
Goods: newGoods,
CompanyId: companyId,
}
_, err := orderSrv.CreateNewOrder(createcmd)
return err
}
func (c *OrderInfoController) editOrderReal(param postRealOrderDetail) error {
newGoods := []orderCmd.OrderGoodData{}
for _, v := range param.Product {
g := orderCmd.OrderGoodData{
GoodName: v.ProductName,
PlanGoodNumber: v.OrderNum,
Price: v.Univalence,
PartnerBonusPercent: v.PartnerRatio,
}
newGoods = append(newGoods, g)
}
companyId := c.GetUserCompany()
updatecmd := orderCmd.UpdateOrderCommand{
Id: param.Id,
OrderType: domain.OrderReal,
OrderCode: param.OrderId,
DeliveryCode: param.ShipmentsId,
BuyerName: param.BuyerName,
OrderRegion: param.OrderDist,
PartnerId: param.PartnerId,
SalesmanBonusPercent: param.CommissionProportion,
Goods: newGoods,
CompanyId: companyId,
}
orderSrv := orderService.NewOrderInfoService(nil)
_, err := orderSrv.UpdateOrderData(updatecmd)
return err
}
//OrderDisable 关闭开启订单,限实发订单可操作
func (c *OrderInfoController) OrderDisable() {
//用与适配前端定义的数据结构
type PostParameter struct {
Id string `json:"id"`
Status int `json:"status"`
}
var (
param PostParameter
err error
)
if err = c.BindJsonData(¶m); err != nil {
logs.Error(err)
c.ResponseError(errors.New("json数据解析失败"))
return
}
orderId, _ := strconv.ParseInt(param.Id, 10, 64)
if orderId == 0 {
c.ResponseError(errors.New("参数错误"))
return
}
if !(param.Status == domain.OrderDisableNot || param.Status == domain.OrderDisableYes) {
c.ResponseError(errors.New("参数错误"))
return
}
companyId := c.GetUserCompany()
cmd := orderCmd.DisableOrderCommand{
OrderId: orderId,
IsDisable: param.Status,
OrderType: domain.OrderReal,
CompanyId: companyId,
}
orderSrv := orderService.NewOrderInfoService(nil)
err = orderSrv.DisableOrEnable(cmd)
if err != nil {
c.ResponseError(err)
}
c.ResponseData(nil)
return
}
//RemoveOrderReal 删除意向订单
func (c *OrderInfoController) RemoveOrderReal() {
type Parameter struct {
Id int64 `json:"id"`
}
var (
param Parameter
err error
)
if err = c.BindJsonData(¶m); err != nil {
logs.Error(err)
c.ResponseError(errors.New("json数据解析失败"))
return
}
companyId := c.GetUserCompany()
orderSrv := orderService.NewOrderInfoService(nil)
err = orderSrv.DeleteOrder(param.Id, companyId)
if err != nil {
c.ResponseError(err)
return
}
c.ResponseData(nil)
}