作者 陈志颖

fix:修复营销年,过滤订单

@@ -29,16 +29,37 @@ func Statistics(header *protocol.RequestHeader, request *protocol.DividendStatis @@ -29,16 +29,37 @@ func Statistics(header *protocol.RequestHeader, request *protocol.DividendStatis
29 if e != nil { 29 if e != nil {
30 log.Error(e) 30 log.Error(e)
31 } 31 }
  32 +
  33 + //获取营销年
32 t := time.Now() 34 t := time.Now()
  35 + var last time.Time
  36 + var first time.Time
  37 + boundDate := time.Date(t.Year(), time.March, 31, 23, 59, 59, 0, time.Local) // 营销年界限
  38 + fmt.Println("营销年界限:", boundDate)
  39 + if t.Before(boundDate) || t.Equal(boundDate) {
  40 + first = time.Date(t.Year()-1, time.April, 1, 0, 0, 0, 0, time.Local)
  41 + last = time.Date(t.Year(), time.March, 31, 23, 59, 59, 0, time.Local)
  42 + } else if t.After(boundDate) {
  43 + first = time.Date(t.Year(), time.April, 1, 0, 0, 0, 0, time.Local)
  44 + last = time.Date(t.Year()+1, time.March, 31, 23, 59, 59, 0, time.Local)
  45 + }
  46 + fmt.Println("当前营销年起始:", first, last)
33 //last := time.Date(t.Year(), time.December, 31, 23, 59, 59, 0, time.Local) 47 //last := time.Date(t.Year(), time.December, 31, 23, 59, 59, 0, time.Local)
34 - first := time.Date(t.Year(), time.January, 1, 0, 0, 0, 0, time.Local)  
35 - last := first.AddDate(1, 0, 0) 48 +
  49 + //first := time.Date(t.Year(), time.January, 1, 0, 0, 0, 0, time.Local)
  50 + //last := first.AddDate(1, 0, 0)
  51 +
  52 + //last := time.Date(t.Year(), t.Month(), t.Day(), t.Hour(), t.Minute(), t.Second(), t.Nanosecond(), time.Local)
  53 + //last := utils.GetDayEnd()
36 if request.StartTime == 0 { 54 if request.StartTime == 0 {
37 request.StartTime = first.Unix() * 1000 55 request.StartTime = first.Unix() * 1000
38 } 56 }
39 if request.EndTime == 0 { 57 if request.EndTime == 0 {
40 request.EndTime = last.Unix() * 1000 58 request.EndTime = last.Unix() * 1000
41 } 59 }
  60 + //if request.EndTime > last.Unix()*1000 {
  61 + // request.EndTime = last.Unix() * 1000
  62 + //}
42 fmt.Print("StartTime: ", request.StartTime, "\n") 63 fmt.Print("StartTime: ", request.StartTime, "\n")
43 fmt.Print("EndTime: ", request.EndTime, "\n") 64 fmt.Print("EndTime: ", request.EndTime, "\n")
44 var orderBetween []*domain.OrderBase 65 var orderBetween []*domain.OrderBase
@@ -138,15 +159,18 @@ func OrderList(header *protocol.RequestHeader, request *protocol.DividendOrdersR @@ -138,15 +159,18 @@ func OrderList(header *protocol.RequestHeader, request *protocol.DividendOrdersR
138 }() 159 }()
139 rsp = &protocol.DividendOrdersResponse{List: make([]*protocol.DividendOrderListItem, 0)} 160 rsp = &protocol.DividendOrdersResponse{List: make([]*protocol.DividendOrderListItem, 0)}
140 161
  162 + endTime := utils.GetDayEnd().Unix() * 1000
  163 +
141 count, orders, err = OrderDao.DividendOrders(&domain.DividendOrdersQueryOption{ 164 count, orders, err = OrderDao.DividendOrders(&domain.DividendOrdersQueryOption{
142 OrderTypes: domain.UserOrderTypes(domain.Career), 165 OrderTypes: domain.UserOrderTypes(domain.Career),
143 PartnerId: request.PartnerId, 166 PartnerId: request.PartnerId,
144 DetailAction: request.DetailAction, 167 DetailAction: request.DetailAction,
145 DividendAction: request.DividendAction, 168 DividendAction: request.DividendAction,
146 StartTime: request.StartTime, 169 StartTime: request.StartTime,
147 - EndTime: request.EndTime,  
148 - Offset: request.PageIndex * request.PageSize,  
149 - Limit: request.PageSize, 170 + //EndTime: request.EndTime,
  171 + EndTime: endTime,
  172 + Offset: request.PageIndex * request.PageSize,
  173 + Limit: request.PageSize,
150 //SortByUpdateTime: domain.DESC, 174 //SortByUpdateTime: domain.DESC,
151 //SortByCreateTime: domain.DESC, 175 //SortByCreateTime: domain.DESC,
152 SortBySalesTime: domain.DESC, 176 SortBySalesTime: domain.DESC,
@@ -227,11 +227,13 @@ func List(header *protocol.RequestHeader, request *protocol.OrderListRequest) (r @@ -227,11 +227,13 @@ func List(header *protocol.RequestHeader, request *protocol.OrderListRequest) (r
227 } else { 227 } else {
228 queryOption.BeginTime = utils.GetFirstDateOfMonth(d) 228 queryOption.BeginTime = utils.GetFirstDateOfMonth(d)
229 } 229 }
230 - if request.EndTime > 0 {  
231 - queryOption.EndTime = time.Unix(request.EndTime/1000, 0)  
232 - } else {  
233 - queryOption.EndTime = utils.GetNextMonthFirstDay(d)  
234 - } 230 + //if request.EndTime > 0 {
  231 + // queryOption.EndTime = time.Unix(request.EndTime/1000, 0)
  232 + //} else {
  233 + // queryOption.EndTime = utils.GetNextMonthFirstDay(d)
  234 + //}
  235 +
  236 + queryOption.EndTime = utils.GetDayEnd()
235 237
236 // 今日新增实发订单 238 // 今日新增实发订单
237 if request.IsToday { 239 if request.IsToday {