作者 陈志颖

合并分支 'dev' 到 'test'

fix:修复订单以及分红统计时间范围



查看合并请求 !54
... ... @@ -230,13 +230,13 @@ func List(header *protocol.RequestHeader, request *protocol.OrderListRequest) (r
if request.EndTime > 0 {
queryOption.EndTime = time.Unix(request.EndTime/1000, 0)
} else {
queryOption.EndTime = utils.GetLastDateOfMonth(d)
queryOption.EndTime = utils.GetNextMonthFirstDay(d)
}
// 今日新增实发订单
if request.IsToday {
queryOption.BeginTime = utils.GetZeroTime(d)
queryOption.EndTime = utils.GetEndTime(d)
queryOption.EndTime = utils.GetNextDayZeroTime(d)
}
total, orders, _ = OrderRepository.Find(utils.ObjectJsonToMap(queryOption))
if len(orders) != 0 {
... ...
... ... @@ -6,7 +6,6 @@ import (
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain"
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/utils"
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/protocol"
"time"
)
// 订单统计
... ... @@ -25,7 +24,7 @@ func StatisticsV2(header *protocol.RequestHeader, request *protocol.OrderStatist
//事业分红/业务分红
var total float64
if bonus, e := OrderDao.OrderBonusStatics(domain.OrderBonusQuery{PartnerId: request.PartnerId, OrderTypes: domain.UserOrderTypes(domain.Career)}); e == nil {
if bonus, e := OrderDao.OrderBonusStatics(domain.OrderBonusQuery{PartnerId: request.PartnerId, OrderTypes: domain.UserOrderTypes(domain.Career), EndTime: utils.GetDayEnd().Unix() * 1000}); e == nil {
total += bonus.Bonus
}
calcOrderStatic := func(catId int, total float64) protocol.OrderStatic {
... ... @@ -37,12 +36,13 @@ func StatisticsV2(header *protocol.RequestHeader, request *protocol.OrderStatist
PartnerCategoryId: catId,
})
cumulativeQuantity, cumulativeMoney, _ := OrderDao.OrderStatics(&domain.OrderStaticQuery{
EndTime: time.Now().Unix() * 1000,
//EndTime: time.Now().Unix() * 1000,
EndTime: utils.GetDayEnd().Unix() * 1000,
OrderTypes: domain.UserOrderTypes(domain.Career),
PartnerId: request.PartnerId,
PartnerCategoryId: catId,
})
bonus, _ := OrderDao.OrderBonusStatics(domain.OrderBonusQuery{PartnerId: request.PartnerId, OrderTypes: domain.UserOrderTypes(domain.Career), PartnerCategoryId: catId})
bonus, _ := OrderDao.OrderBonusStatics(domain.OrderBonusQuery{PartnerId: request.PartnerId, OrderTypes: domain.UserOrderTypes(domain.Career), PartnerCategoryId: catId, EndTime: utils.GetDayEnd().Unix() * 1000})
var percent float64 = 0
if bonus.Bonus != 0 {
percent = utils.DecimalToNumber(bonus.Bonus * 100 / total)
... ...
... ... @@ -32,6 +32,7 @@ type OrderBonusQuery struct {
OrderType int `json:"orderType,omitempty"`
OrderTypes []int `json:"orderTypes,omitempty"`
PartnerCategoryId int `json:"partnerCategoryId,omitempty"` //订单所属类型
EndTime int64 `json:"endTime,omitempty"`
//IsGroupByPartnerCategoryId bool `json:"isGroupByPartnerCategoryId,omitempty"`
}
... ...
... ... @@ -82,6 +82,9 @@ func (dao *OrderBaseDao) OrderBonusStatics(option domain.OrderBonusQuery) (rsp d
if option.PartnerCategoryId > 0 {
q.Where(`"order_base".partner_category @>'{"id":?}'`, option.PartnerCategoryId)
}
if option.EndTime > 0 {
q.Where(`"order_base".sale_date <?`, time.Unix(option.EndTime/1000, 0))
}
//if option.IsGroupByPartnerCategoryId{
// q.Group(`partner_category`)
//}
... ...
... ... @@ -21,9 +21,9 @@ func GetFirstDateOfMonth(d time.Time) time.Time {
}
//获取传入的时间所在月份的最后一天,即某月最后一天的23:59:59。如传入time.Now(), 返回当前月份的最后一天的23:59:59。
func GetLastDateOfMonth(d time.Time) time.Time {
d = GetFirstDateOfMonth(d).AddDate(0, 1, -1)
return GetEndTime(d)
func GetNextMonthFirstDay(d time.Time) time.Time {
d = GetFirstDateOfMonth(d).AddDate(0, 1, 0)
return GetZeroTime(d)
}
//获取某一天的0点时间
... ... @@ -32,6 +32,6 @@ func GetZeroTime(d time.Time) time.Time {
}
//获取某一天的23点59分59秒
func GetEndTime(d time.Time) time.Time {
return time.Date(d.Year(), d.Month(), d.Day(), 23, 59, 59, 0, time.Local)
func GetNextDayZeroTime(d time.Time) time.Time {
return time.Date(d.Year(), d.Month(), d.Day(), 0, 0, 0, 0, time.Local).AddDate(0, 0, 1)
}
... ...