作者 陈志颖

合并分支 'dev' 到 'test'

fix:修改统计



查看合并请求 !61
@@ -267,6 +267,10 @@ func newQueryOption(request *protocolx.PartnersRequest) map[string]interface{} { @@ -267,6 +267,10 @@ func newQueryOption(request *protocolx.PartnersRequest) map[string]interface{} {
267 queryOption["startTime"] = request.StartTime / 1000 267 queryOption["startTime"] = request.StartTime / 1000
268 } 268 }
269 if request.EndTime > 0 { 269 if request.EndTime > 0 {
  270 + currentDayEnd := utils.GetDayEnd().Unix() * 1000
  271 + if request.EndTime >= currentDayEnd {
  272 + request.EndTime = currentDayEnd
  273 + }
270 queryOption["endTime"] = request.EndTime / 1000 274 queryOption["endTime"] = request.EndTime / 1000
271 } 275 }
272 queryOption["limit"] = request.PageSize 276 queryOption["limit"] = request.PageSize
@@ -110,6 +110,10 @@ func newQueryOptionV2(request *protocolx.PartnersRequest) map[string]interface{} @@ -110,6 +110,10 @@ func newQueryOptionV2(request *protocolx.PartnersRequest) map[string]interface{}
110 queryOption["startTime"] = request.StartTime / 1000 110 queryOption["startTime"] = request.StartTime / 1000
111 } 111 }
112 if request.EndTime > 0 { 112 if request.EndTime > 0 {
  113 + currentDayEnd := utils.GetDayEnd().Unix() * 1000
  114 + if request.EndTime >= currentDayEnd {
  115 + request.EndTime = currentDayEnd
  116 + }
113 queryOption["endTime"] = request.EndTime / 1000 117 queryOption["endTime"] = request.EndTime / 1000
114 } 118 }
115 if request.Keyword != "" { 119 if request.Keyword != "" {
@@ -51,17 +51,24 @@ func Statistics(header *protocol.RequestHeader, request *protocol.DividendStatis @@ -51,17 +51,24 @@ func Statistics(header *protocol.RequestHeader, request *protocol.DividendStatis
51 51
52 //last := time.Date(t.Year(), t.Month(), t.Day(), t.Hour(), t.Minute(), t.Second(), t.Nanosecond(), time.Local) 52 //last := time.Date(t.Year(), t.Month(), t.Day(), t.Hour(), t.Minute(), t.Second(), t.Nanosecond(), time.Local)
53 //last := utils.GetDayEnd() 53 //last := utils.GetDayEnd()
54 - if request.StartTime == 0 { 54 +
  55 + // 请求开始时间和结束时间都为0时,默认从营销年开始统计
  56 + if request.StartTime == 0 && request.EndTime == 0 {
55 request.StartTime = first.Unix() * 1000 57 request.StartTime = first.Unix() * 1000
56 - }  
57 - if request.EndTime == 0 {  
58 request.EndTime = last.Unix() * 1000 58 request.EndTime = last.Unix() * 1000
  59 + } else if request.StartTime > 0 && request.EndTime > 0 { // 判断结束时间是否超过今天,超过今天的结束时间到今天为止
  60 + currentDayEnd := utils.GetDayEnd().Unix() * 1000
  61 + if request.EndTime >= currentDayEnd {
  62 + request.EndTime = currentDayEnd
  63 + }
59 } 64 }
  65 +
60 //if request.EndTime > last.Unix()*1000 { 66 //if request.EndTime > last.Unix()*1000 {
61 // request.EndTime = last.Unix() * 1000 67 // request.EndTime = last.Unix() * 1000
62 //} 68 //}
63 fmt.Print("StartTime: ", request.StartTime, "\n") 69 fmt.Print("StartTime: ", request.StartTime, "\n")
64 fmt.Print("EndTime: ", request.EndTime, "\n") 70 fmt.Print("EndTime: ", request.EndTime, "\n")
  71 +
65 var orderBetween []*domain.OrderBase 72 var orderBetween []*domain.OrderBase
66 for i := range orderAll { 73 for i := range orderAll {
67 if orderAll[i].SaleDate.Unix() >= (request.StartTime/1000) && orderAll[i].SaleDate.Unix() < (request.EndTime/1000) { 74 if orderAll[i].SaleDate.Unix() >= (request.StartTime/1000) && orderAll[i].SaleDate.Unix() < (request.EndTime/1000) {
@@ -159,7 +166,11 @@ func OrderList(header *protocol.RequestHeader, request *protocol.DividendOrdersR @@ -159,7 +166,11 @@ func OrderList(header *protocol.RequestHeader, request *protocol.DividendOrdersR
159 }() 166 }()
160 rsp = &protocol.DividendOrdersResponse{List: make([]*protocol.DividendOrderListItem, 0)} 167 rsp = &protocol.DividendOrdersResponse{List: make([]*protocol.DividendOrderListItem, 0)}
161 168
162 - endTime := utils.GetDayEnd().Unix() * 1000 169 + // 判断时间是否超过今天
  170 + currentDayEnd := utils.GetDayEnd().Unix() * 1000
  171 + if request.EndTime >= currentDayEnd {
  172 + request.EndTime = currentDayEnd
  173 + }
163 174
164 count, orders, err = OrderDao.DividendOrders(&domain.DividendOrdersQueryOption{ 175 count, orders, err = OrderDao.DividendOrders(&domain.DividendOrdersQueryOption{
165 OrderTypes: domain.UserOrderTypes(domain.Career), 176 OrderTypes: domain.UserOrderTypes(domain.Career),
@@ -167,12 +178,9 @@ func OrderList(header *protocol.RequestHeader, request *protocol.DividendOrdersR @@ -167,12 +178,9 @@ func OrderList(header *protocol.RequestHeader, request *protocol.DividendOrdersR
167 DetailAction: request.DetailAction, 178 DetailAction: request.DetailAction,
168 DividendAction: request.DividendAction, 179 DividendAction: request.DividendAction,
169 StartTime: request.StartTime, 180 StartTime: request.StartTime,
170 - //EndTime: request.EndTime,  
171 - EndTime: endTime, 181 + EndTime: request.EndTime,
172 Offset: request.PageIndex * request.PageSize, 182 Offset: request.PageIndex * request.PageSize,
173 Limit: request.PageSize, 183 Limit: request.PageSize,
174 - //SortByUpdateTime: domain.DESC,  
175 - //SortByCreateTime: domain.DESC,  
176 SortBySalesTime: domain.DESC, 184 SortBySalesTime: domain.DESC,
177 JoinWays: request.JoinWays, 185 JoinWays: request.JoinWays,
178 }) 186 })
@@ -122,7 +122,7 @@ func orderTotalStatic(order *domain.OrderBase) interface{} { @@ -122,7 +122,7 @@ func orderTotalStatic(order *domain.OrderBase) interface{} {
122 122
123 /** 123 /**
124 * @Author SteveChan 124 * @Author SteveChan
125 - * @Description //TODO 订单统计 125 + * @Description // 订单统计
126 * @Date 18:14 2021/1/28 126 * @Date 18:14 2021/1/28
127 * @Param 127 * @Param
128 * @return 128 * @return
@@ -222,18 +222,22 @@ func List(header *protocol.RequestHeader, request *protocol.OrderListRequest) (r @@ -222,18 +222,22 @@ func List(header *protocol.RequestHeader, request *protocol.OrderListRequest) (r
222 } 222 }
223 // 当月累计实发订单 223 // 当月累计实发订单
224 d := time.Now() 224 d := time.Now()
225 - if request.StartTime > 0 { 225 + if request.StartTime > 0 { // 开始时间处理
226 queryOption.BeginTime = time.Unix(request.StartTime/1000, 0) 226 queryOption.BeginTime = time.Unix(request.StartTime/1000, 0)
227 - } else { 227 + } else { // 开始时间为0,默认从这个月初开始
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 - //}  
235 230
  231 + if request.EndTime > 0 { // 结束时间处理,判断时间是否超过今天
  232 + currentDayEnd := utils.GetDayEnd().Unix() * 1000
  233 + if request.EndTime >= currentDayEnd {
  234 + request.EndTime = currentDayEnd
  235 + }
  236 + queryOption.EndTime = time.Unix(request.EndTime/1000, 0)
  237 + } else { // 请求结束时间为0,默认到今天结束
  238 + //queryOption.EndTime = utils.GetNextMonthFirstDay(d)
236 queryOption.EndTime = utils.GetDayEnd() 239 queryOption.EndTime = utils.GetDayEnd()
  240 + }
237 241
238 // 今日新增实发订单 242 // 今日新增实发订单
239 if request.IsToday { 243 if request.IsToday {