作者 yangfu

1.review code

... ... @@ -11,9 +11,5 @@ require (
github.com/linmadan/egglib-go v0.0.0-20191217144343-ca4539f95bf9
github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644 // indirect
github.com/shopspring/decimal v1.2.0
github.com/tiptok/gocomm v1.0.2
)
replace (
github.com/tiptok/gocomm v1.0.2 => F:\go\src\learn_project\gocomm
github.com/tiptok/gocomm v1.0.5
)
... ...
... ... @@ -12,9 +12,9 @@ import (
// 分红统计
func Statistics(header *protocol.RequestHeader, request *protocol.DividendStatisticsRequest) (rsp *protocol.DividendStatisticsResponse, err error) {
var (
transactionContext, _ = factory.CreateTransactionContext(nil)
OrderBaseResponsitory, _ = factory.CreateOrderBaseRepository(transactionContext)
BusinessBonusRepository, _ = factory.CreateBusinessBonusRepository(transactionContext)
transactionContext, _ = factory.CreateTransactionContext(nil)
OrderBaseResponsitory, _ = factory.CreateOrderBaseRepository(transactionContext)
//BusinessBonusRepository, _ = factory.CreateBusinessBonusRepository(transactionContext)
)
if err = transactionContext.StartTransaction(); err != nil {
return nil, err
... ... @@ -40,17 +40,17 @@ func Statistics(header *protocol.RequestHeader, request *protocol.DividendStatis
bonusQuarters := QuartersBonusStatics(orderBetween, 0)
// 业务分红统计
if bonus, e := BusinessBonusRepository.FindOne(map[string]interface{}{"partner_id": request.PartnerId, "isDisable": 1}); e == nil {
bonusAll.Receivable += bonus.Bonus
bonusAll.Received += bonus.BonusHas
bonusAll.Outstanding += bonus.BonusNot
if bonus.UpdateAt.Unix() >= (request.StartTime/1000) && bonus.UpdateAt.Unix() < (request.EndTime/1000) {
q := quarter(bonus.UpdateAt)
bonusQuarters[q].Receivable += bonus.Bonus
bonusQuarters[q].Received += bonus.BonusHas
bonusQuarters[q].Outstanding += bonus.BonusNot
}
}
//if bonus, e := BusinessBonusRepository.FindOne(map[string]interface{}{"partner_id": request.PartnerId, "isDisable": 1}); e == nil {
// bonusAll.Receivable += bonus.Bonus
// bonusAll.Received += bonus.BonusHas
// bonusAll.Outstanding += bonus.BonusNot
// if bonus.UpdateAt.Unix() >= (request.StartTime/1000) && bonus.UpdateAt.Unix() < (request.EndTime/1000) {
// q := quarter(bonus.UpdateAt)
// bonusQuarters[q].Receivable += bonus.Bonus
// bonusQuarters[q].Received += bonus.BonusHas
// bonusQuarters[q].Outstanding += bonus.BonusNot
// }
//}
rsp = &protocol.DividendStatisticsResponse{}
rsp.Statistics = protocol.DividendStatistics{
... ...
... ... @@ -177,7 +177,7 @@ func Statistics(header *protocol.RequestHeader, request *protocol.OrderStatistic
func List(header *protocol.RequestHeader, request *protocol.OrderListRequest) (rsp *protocol.OrderListResponse, err error) {
var (
transactionContext, _ = factory.CreateTransactionContext(nil)
OrderResponsitory, _ = factory.CreateOrderBaseRepository(transactionContext)
OrderRepository, _ = factory.CreateOrderBaseRepository(transactionContext)
OrderDao, _ = factory.CreateOrderBaseDao(transactionContext)
orders []*domain.OrderBase
total int64
... ... @@ -200,6 +200,8 @@ func List(header *protocol.RequestHeader, request *protocol.OrderListRequest) (r
SortByUpdateTime: domain.DESC,
PartnerId: request.PartnerId,
PartnerCategoryId: request.JoinWay,
OrderType: request.OrderType,
OrderTypes: request.OrderTypes,
}
if request.StartTime > 0 {
queryOption.BeginTime = time.Unix(request.StartTime/1000, 0)
... ... @@ -207,21 +209,18 @@ func List(header *protocol.RequestHeader, request *protocol.OrderListRequest) (r
if request.EndTime > 0 {
queryOption.EndTime = time.Unix(request.EndTime/1000, 0)
}
queryOption.OrderType = request.OrderType
queryOption.OrderTypes = request.OrderTypes
total, orders, _ = OrderResponsitory.Find(utils.ObjectJsonToMap(queryOption))
total, orders, _ = OrderRepository.Find(utils.ObjectJsonToMap(queryOption))
if len(orders) != 0 {
for i := range orders {
rsp.List = append(rsp.List, DomainOrderToOrderListItem(orders[i]))
}
}
// 查询统计数据
// 【特殊处理1】 查询第0页时,需要查询累计实发订单数
if request.PageIndex == 0 {
var (
cumulativeQuantity int
)
//累计实发订单
cumulativeQuantity, _, err = OrderDao.OrderStatics(&domain.OrderStaticQuery{
EndTime: time.Now().Unix() * 1000,
OrderTypes: domain.UserOrderTypes(domain.Career),
... ... @@ -230,7 +229,7 @@ func List(header *protocol.RequestHeader, request *protocol.OrderListRequest) (r
})
rsp.Total = cumulativeQuantity
}
// 今天累计数量特殊处理,不需要返回所有订单总数(因为要复用rsp.Total字段)
//【特殊处理2】 今天累计数量特殊处理 当前查询时间段内所有订单总数(复用rsp.Total字段)
if request.StartTime > 0 && request.EndTime > 0 {
zero := time.Time(xtime.XTime(time.Now()).DayBefore(0)).Unix()
if request.StartTime == (zero * 1000) {
... ...
... ... @@ -145,8 +145,10 @@ func (m *OrderBase) OrderBonusStatic() *OrderStatics {
}
type OrderQueryOption struct {
PartnerId int64 `json:"partnerId,omitempty"`
OrderType int `json:"orderType,omitempty"`
PartnerId int64 `json:"partnerId,omitempty"`
// 订单类型 单个
OrderType int `json:"orderType,omitempty"`
// 订单类型 多个
OrderTypes []int `json:"orderTypes,omitempty"`
OrderStatus int `json:"orderStatus,omitempty"`
BeginTime time.Time `json:"beginTime,omitempty"`
... ...