作者 陈志颖

合并分支 'dev' 到 'test'

fix:修改今日实发订单统计



查看合并请求 !52
@@ -120,6 +120,13 @@ func orderTotalStatic(order *domain.OrderBase) interface{} { @@ -120,6 +120,13 @@ func orderTotalStatic(order *domain.OrderBase) interface{} {
120 return item 120 return item
121 } 121 }
122 122
  123 +/**
  124 + * @Author SteveChan
  125 + * @Description //TODO 订单统计
  126 + * @Date 18:14 2021/1/28
  127 + * @Param
  128 + * @return
  129 + **/
123 // 订单统计 130 // 订单统计
124 func Statistics(header *protocol.RequestHeader, request *protocol.OrderStatisticsRequest) (rsp *protocol.OrderStatisticsResponse, err error) { 131 func Statistics(header *protocol.RequestHeader, request *protocol.OrderStatisticsRequest) (rsp *protocol.OrderStatisticsResponse, err error) {
125 var ( 132 var (
@@ -127,15 +134,18 @@ func Statistics(header *protocol.RequestHeader, request *protocol.OrderStatistic @@ -127,15 +134,18 @@ func Statistics(header *protocol.RequestHeader, request *protocol.OrderStatistic
127 OrderDao, _ = factory.CreateOrderBaseDao(transactionContext) 134 OrderDao, _ = factory.CreateOrderBaseDao(transactionContext)
128 BusinessBonusRepository, _ = factory.CreateBusinessBonusRepository(transactionContext) 135 BusinessBonusRepository, _ = factory.CreateBusinessBonusRepository(transactionContext)
129 ) 136 )
  137 +
130 if err = transactionContext.StartTransaction(); err != nil { 138 if err = transactionContext.StartTransaction(); err != nil {
131 return nil, err 139 return nil, err
132 } 140 }
  141 +
133 defer func() { 142 defer func() {
134 transactionContext.RollbackTransaction() 143 transactionContext.RollbackTransaction()
135 }() 144 }()
  145 +
136 rsp = &protocol.OrderStatisticsResponse{Statistics: &protocol.OrderStatics{}} 146 rsp = &protocol.OrderStatisticsResponse{Statistics: &protocol.OrderStatics{}}
137 147
138 - // 当天订单/累计订单 148 + // 今日新增实发订单
139 if rsp.Statistics.TodayRealQuantity, rsp.Statistics.TodayRealMoney, err = OrderDao.OrderStatics(&domain.OrderStaticQuery{ 149 if rsp.Statistics.TodayRealQuantity, rsp.Statistics.TodayRealMoney, err = OrderDao.OrderStatics(&domain.OrderStaticQuery{
140 BeginTime: utils.GetDayBegin().Unix() * 1000, 150 BeginTime: utils.GetDayBegin().Unix() * 1000,
141 EndTime: utils.GetDayEnd().Unix() * 1000, 151 EndTime: utils.GetDayEnd().Unix() * 1000,
@@ -144,6 +154,8 @@ func Statistics(header *protocol.RequestHeader, request *protocol.OrderStatistic @@ -144,6 +154,8 @@ func Statistics(header *protocol.RequestHeader, request *protocol.OrderStatistic
144 }); err != nil { 154 }); err != nil {
145 return 155 return
146 } 156 }
  157 +
  158 + // 累计实发订单
147 if rsp.Statistics.CumulativeQuantity, rsp.Statistics.CumulativeMoney, err = OrderDao.OrderStatics(&domain.OrderStaticQuery{ 159 if rsp.Statistics.CumulativeQuantity, rsp.Statistics.CumulativeMoney, err = OrderDao.OrderStatics(&domain.OrderStaticQuery{
148 EndTime: time.Now().Unix() * 1000, 160 EndTime: time.Now().Unix() * 1000,
149 OrderTypes: domain.UserOrderTypes(domain.Career), 161 OrderTypes: domain.UserOrderTypes(domain.Career),
@@ -151,6 +163,7 @@ func Statistics(header *protocol.RequestHeader, request *protocol.OrderStatistic @@ -151,6 +163,7 @@ func Statistics(header *protocol.RequestHeader, request *protocol.OrderStatistic
151 }); err != nil { 163 }); err != nil {
152 return 164 return
153 } 165 }
  166 +
154 rsp.Statistics.TodayRealMoney = utils.Decimal(rsp.Statistics.TodayRealMoney) 167 rsp.Statistics.TodayRealMoney = utils.Decimal(rsp.Statistics.TodayRealMoney)
155 rsp.Statistics.CumulativeMoney = utils.Decimal(rsp.Statistics.CumulativeMoney) 168 rsp.Statistics.CumulativeMoney = utils.Decimal(rsp.Statistics.CumulativeMoney)
156 169
@@ -206,7 +219,7 @@ func List(header *protocol.RequestHeader, request *protocol.OrderListRequest) (r @@ -206,7 +219,7 @@ func List(header *protocol.RequestHeader, request *protocol.OrderListRequest) (r
206 OrderType: request.OrderType, 219 OrderType: request.OrderType,
207 OrderTypes: request.OrderTypes, 220 OrderTypes: request.OrderTypes,
208 } 221 }
209 - // 当月累计订单 222 + // 当月累计实发订单
210 d := time.Now() 223 d := time.Now()
211 if request.StartTime > 0 { 224 if request.StartTime > 0 {
212 queryOption.BeginTime = time.Unix(request.StartTime/1000, 0) 225 queryOption.BeginTime = time.Unix(request.StartTime/1000, 0)
@@ -218,7 +231,8 @@ func List(header *protocol.RequestHeader, request *protocol.OrderListRequest) (r @@ -218,7 +231,8 @@ func List(header *protocol.RequestHeader, request *protocol.OrderListRequest) (r
218 } else { 231 } else {
219 queryOption.EndTime = utils.GetLastDateOfMonth(d) 232 queryOption.EndTime = utils.GetLastDateOfMonth(d)
220 } 233 }
221 - // 今日订单 234 +
  235 + // 今日新增实发订单
222 if request.IsToday { 236 if request.IsToday {
223 queryOption.BeginTime = utils.GetZeroTime(d) 237 queryOption.BeginTime = utils.GetZeroTime(d)
224 queryOption.EndTime = utils.GetEndTime(d) 238 queryOption.EndTime = utils.GetEndTime(d)
@@ -235,7 +249,7 @@ func List(header *protocol.RequestHeader, request *protocol.OrderListRequest) (r @@ -235,7 +249,7 @@ func List(header *protocol.RequestHeader, request *protocol.OrderListRequest) (r
235 } 249 }
236 } 250 }
237 251
238 - // 【特殊处理1】 查询第0页时,需要查询累计实发订单数 252 + // 【特殊处理1】 查询第0页时,需要查询累计实发订单数,并下发时间戳
239 if request.PageIndex == 0 { 253 if request.PageIndex == 0 {
240 var ( 254 var (
241 cumulativeQuantity int 255 cumulativeQuantity int
@@ -257,6 +271,22 @@ func List(header *protocol.RequestHeader, request *protocol.OrderListRequest) (r @@ -257,6 +271,22 @@ func List(header *protocol.RequestHeader, request *protocol.OrderListRequest) (r
257 } 271 }
258 } 272 }
259 273
  274 + // 【特殊处理3】今日新增实发订单统计
  275 + if request.IsToday {
  276 + var (
  277 + todayQuantity int
  278 + )
  279 + todayQuantity, _, err = OrderDao.OrderStatics(&domain.OrderStaticQuery{
  280 + BeginTime: queryOption.BeginTime.Unix() * 1000,
  281 + //EndTime: time.Now().Unix() * 1000,
  282 + EndTime: queryOption.EndTime.Unix() * 1000,
  283 + OrderTypes: domain.UserOrderTypes(domain.Career),
  284 + PartnerId: request.PartnerId,
  285 + PartnerCategoryId: request.JoinWay,
  286 + })
  287 + rsp.Total = todayQuantity
  288 + }
  289 +
260 err = transactionContext.CommitTransaction() 290 err = transactionContext.CommitTransaction()
261 return 291 return
262 } 292 }
@@ -4,9 +4,9 @@ import "os" @@ -4,9 +4,9 @@ import "os"
4 4
5 var POSTGRESQL_DB_NAME = "partner_test" //partner_test/partner_dev 5 var POSTGRESQL_DB_NAME = "partner_test" //partner_test/partner_dev
6 var POSTGRESQL_USER = "postgres" //postgres 6 var POSTGRESQL_USER = "postgres" //postgres
7 -var POSTGRESQL_PASSWORD = "eagle1010" //pgsql@123/1993618jack  
8 -var POSTGRESQL_HOST = "114.55.200.59" //127.0.0.1/114.55.200.59  
9 -var POSTGRESQL_PORT = "31543" //5432/31543 7 +var POSTGRESQL_PASSWORD = "1993618jack" //pgsql@123/1993618jack/eagle1010
  8 +var POSTGRESQL_HOST = "127.0.0.1" //127.0.0.1/114.55.200.59
  9 +var POSTGRESQL_PORT = "5432" //5432/31543
10 var DISABLE_CREATE_TABLE = true 10 var DISABLE_CREATE_TABLE = true
11 var DISABLE_SQL_GENERATE_PRINT = false 11 var DISABLE_SQL_GENERATE_PRINT = false
12 12