作者 唐旭辉

bug 修复

@@ -63,7 +63,7 @@ spec: @@ -63,7 +63,7 @@ spec:
63 - name: POSTGRESQL_PORT 63 - name: POSTGRESQL_PORT
64 value: "15432" 64 value: "15432"
65 - name: LOG_LEVEL 65 - name: LOG_LEVEL
66 - value: "debug" 66 + value: "info"
67 - name: ERROR_BASE_CODE 67 - name: ERROR_BASE_CODE
68 value: "1" 68 value: "1"
69 - name: ERROR_BASE_CODE_MULTIPLE 69 - name: ERROR_BASE_CODE_MULTIPLE
@@ -717,7 +717,7 @@ func (service OrderInfoService) UpdateGoodBouns(cmd command.UpdateGoodBouns) err @@ -717,7 +717,7 @@ func (service OrderInfoService) UpdateGoodBouns(cmd command.UpdateGoodBouns) err
717 } 717 }
718 718
719 //PageListOrderBouns 获取订单的分红列表 719 //PageListOrderBouns 获取订单的分红列表
720 -func (service OrderInfoService) PageListOrderBonus(listOrderQuery query.ListOrderBonusQuery) ([]domain.OrderBase, int, error) { 720 +func (service OrderInfoService) PageListOrderBonus(listOrderQuery query.ListOrderBonusQuery) ([]map[string]interface{}, int, error) {
721 transactionContext, err := factory.CreateTransactionContext(nil) 721 transactionContext, err := factory.CreateTransactionContext(nil)
722 if err != nil { 722 if err != nil {
723 return nil, 0, lib.ThrowError(lib.TRANSACTION_ERROR, err.Error()) 723 return nil, 0, lib.ThrowError(lib.TRANSACTION_ERROR, err.Error())
@@ -769,12 +769,21 @@ func (service OrderInfoService) PageListOrderBonus(listOrderQuery query.ListOrde @@ -769,12 +769,21 @@ func (service OrderInfoService) PageListOrderBonus(listOrderQuery query.ListOrde
769 } 769 }
770 orders = append(orders, order) 770 orders = append(orders, order)
771 } 771 }
772 - var PartnerInfoRepository domain.PartnerInfoRepository 772 + var (
  773 + PartnerInfoRepository domain.PartnerInfoRepository
  774 + orderGoodRepository domain.OrderGoodRepository
  775 + )
773 if PartnerInfoRepository, err = factory.CreatePartnerInfoRepository(map[string]interface{}{ 776 if PartnerInfoRepository, err = factory.CreatePartnerInfoRepository(map[string]interface{}{
774 "transactionContext": transactionContext, 777 "transactionContext": transactionContext,
775 }); err != nil { 778 }); err != nil {
776 return nil, 0, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) 779 return nil, 0, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
777 } 780 }
  781 + if orderGoodRepository, err = factory.CreateOrderGoodRepository(map[string]interface{}{
  782 + "transactionContext": transactionContext,
  783 + }); err != nil {
  784 + return nil, 0, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
  785 + }
  786 + var resp []map[string]interface{}
778 for i := range orders { 787 for i := range orders {
779 partnerData := &domain.PartnerInfo{} 788 partnerData := &domain.PartnerInfo{}
780 partnerData, err = PartnerInfoRepository.FindOne(domain.PartnerFindOneQuery{ 789 partnerData, err = PartnerInfoRepository.FindOne(domain.PartnerFindOneQuery{
@@ -785,12 +794,43 @@ func (service OrderInfoService) PageListOrderBonus(listOrderQuery query.ListOrde @@ -785,12 +794,43 @@ func (service OrderInfoService) PageListOrderBonus(listOrderQuery query.ListOrde
785 } else { 794 } else {
786 orders[i].PartnerInfo = partnerData.Partner 795 orders[i].PartnerInfo = partnerData.Partner
787 } 796 }
  797 + var (
  798 + goods []domain.OrderGood
  799 + hasBonusPercent bool
  800 + )
  801 + goods, _, err = orderGoodRepository.Find(domain.OrderGoodFindQuery{OrderId: orders[i].Id})
  802 + for ii := range goods {
  803 + if goods[ii].PartnerBonusPercent > 0 {
  804 + hasBonusPercent = true
  805 + }
  806 + }
  807 + listItem := map[string]interface{}{
  808 + "updateTime": orders[i].UpdateTime.Local().Format("2006-01-02 15:04:05"),
  809 + "id": orders[i].Id,
  810 + "shipmentsId": orders[i].DeliveryCode,
  811 + "partner": orders[i].PartnerInfo.PartnerName,
  812 + "dividendsReceivable": fmt.Sprint(orders[i].GetCurrentPartnerBonus()),
  813 + "dividendSpending": fmt.Sprint(orders[i].OrderCompute.PartnerBonusExpense),
  814 + "receiveDividends": fmt.Sprint(orders[i].OrderCompute.PartnerBonusHas),
  815 + "uncollectedDividends": fmt.Sprint(orders[i].OrderCompute.PartnerBonusNot),
  816 + "stateOfPayment": orders[i].BonusStatus,
  817 + "orderType": orders[i].OrderType,
  818 + "orderTypeName": domain.GetOrderBaseTypeName(orders[i].OrderType),
  819 + "orderNumber": orders[i].OrderCode,
  820 + }
  821 + if !hasBonusPercent {
  822 + listItem["receiveDividends"] = "-"
  823 + listItem["dividendsReceivable"] = "-"
  824 + listItem["dividendSpending"] = "-"
  825 + listItem["uncollectedDividends"] = "-"
  826 + }
  827 + resp = append(resp, listItem)
788 } 828 }
789 err = transactionContext.CommitTransaction() 829 err = transactionContext.CommitTransaction()
790 if err != nil { 830 if err != nil {
791 - return orders, cnt, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) 831 + return resp, cnt, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
792 } 832 }
793 - return orders, cnt, nil 833 + return resp, cnt, nil
794 } 834 }
795 835
796 //GetOrderBestshopInfo 获取来源于xiangmi订单的详情以及分红数据 836 //GetOrderBestshopInfo 获取来源于xiangmi订单的详情以及分红数据
@@ -76,11 +76,11 @@ func (s SyncOrderService) SyncOrderFromBestshop(cmd command.CreateOrderFromBests @@ -76,11 +76,11 @@ func (s SyncOrderService) SyncOrderFromBestshop(cmd command.CreateOrderFromBests
76 return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) 76 return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
77 } 77 }
78 if orderExist { 78 if orderExist {
79 - err = s.UpdateOrderFromBestshop(cmd) 79 + //
  80 + logs.Warning("订单数据已存在:order_code=%s", cmd.OrderCode)
80 } else { 81 } else {
81 err = s.CreateOrderFromBestshop(cmd) 82 err = s.CreateOrderFromBestshop(cmd)
82 } 83 }
83 -  
84 return err 84 return err
85 } 85 }
86 86
1 package domain 1 package domain
2 2
3 -import "errors" 3 +import (
  4 + "errors"
  5 + "fmt"
  6 +)
4 7
5 //类型为(orderType=OrderTypeBestShop) 海鲜干货的订单分红 8 //类型为(orderType=OrderTypeBestShop) 海鲜干货的订单分红
6 //因页面上的对于该类型的订单分红状态处理方式 有别于原有的其他类型(OrderReal),所以单独提取出来 9 //因页面上的对于该类型的订单分红状态处理方式 有别于原有的其他类型(OrderReal),所以单独提取出来
@@ -19,6 +22,9 @@ type OrderGoodWithBestshop struct { @@ -19,6 +22,9 @@ type OrderGoodWithBestshop struct {
19 22
20 func (o *OrderGoodWithBestshop) UpdateBonusByGoodNumber(good *OrderGood, number int) error { 23 func (o *OrderGoodWithBestshop) UpdateBonusByGoodNumber(good *OrderGood, number int) error {
21 o.reset(good) 24 o.reset(good)
  25 + if good.PlanGoodNumber < number {
  26 + return fmt.Errorf("修改商品数量的值不能大于初始值%d", good.PlanGoodNumber)
  27 + }
22 err := o.currentBonusStatus.UpdateOrderGoodNumber(good, number) 28 err := o.currentBonusStatus.UpdateOrderGoodNumber(good, number)
23 return err 29 return err
24 } 30 }
@@ -59,7 +59,7 @@ func (c *OrderDividendController) PageListOrderDividend() { @@ -59,7 +59,7 @@ func (c *OrderDividendController) PageListOrderDividend() {
59 } 59 }
60 companyId := c.GetUserCompany() 60 companyId := c.GetUserCompany()
61 orderSrv := orderService.NewOrderInfoService(nil) 61 orderSrv := orderService.NewOrderInfoService(nil)
62 - orderinfos, cnt, err := orderSrv.PageListOrderBonus(orderQuery.ListOrderBonusQuery{ 62 + resp, cnt, err := orderSrv.PageListOrderBonus(orderQuery.ListOrderBonusQuery{
63 OrderType: param.OrderType, 63 OrderType: param.OrderType,
64 PartnerOrCode: param.SearchWord, 64 PartnerOrCode: param.SearchWord,
65 Limit: param.PageSize, 65 Limit: param.PageSize,
@@ -70,27 +70,7 @@ func (c *OrderDividendController) PageListOrderDividend() { @@ -70,27 +70,7 @@ func (c *OrderDividendController) PageListOrderDividend() {
70 c.ResponseError(err) 70 c.ResponseError(err)
71 return 71 return
72 } 72 }
73 - //适配数据输出  
74 - rsp := []map[string]interface{}{}  
75 - for i := range orderinfos {  
76 - orderinfo := orderinfos[i]  
77 - m := map[string]interface{}{  
78 - "updateTime": orderinfo.UpdateTime.Local().Format("2006-01-02 15:04:05"),  
79 - "id": orderinfo.Id,  
80 - "shipmentsId": orderinfo.DeliveryCode,  
81 - "partner": orderinfo.PartnerInfo.PartnerName,  
82 - "dividendsReceivable": orderinfo.GetCurrentPartnerBonus(),  
83 - "dividendSpending": orderinfo.OrderCompute.PartnerBonusExpense,  
84 - "receiveDividends": orderinfo.OrderCompute.PartnerBonusHas,  
85 - "uncollectedDividends": orderinfo.OrderCompute.PartnerBonusNot,  
86 - "stateOfPayment": orderinfo.BonusStatus,  
87 - "orderType": orderinfo.OrderType,  
88 - "orderTypeName": domain.GetOrderBaseTypeName(orderinfo.OrderType),  
89 - "orderNumber": orderinfo.OrderCode,  
90 - }  
91 - rsp = append(rsp, m)  
92 - }  
93 - c.ResponsePageList(rsp, cnt, param.PageNumber) 73 + c.ResponsePageList(resp, cnt, param.PageNumber)
94 return 74 return
95 } 75 }
96 76