作者 yangfu

合约 分红明细修改

... ... @@ -76,7 +76,7 @@ func (dao *CreditAccountDao) DividendsStatistics(queryOptions map[string]interfa
query.ColumnExpr(`sum((case when payment_status = 1 then settlement_amount else 0 end)) unpaid`)
query.ColumnExpr(`sum((case when settlement_time is not null then settlement_amount else 0 end)) accounted `)
if v, ok := queryOptions["beginTime"]; ok && !(v.(time.Time).IsZero()) {
query.Where(`created_at>? `, queryOptions["beginTime"])
query.Where(`created_at>=? `, queryOptions["beginTime"])
query.Where(`created_at<? `, queryOptions["endTime"])
}
if v, ok := queryOptions["userBaseId"]; ok && v.(int64) > 0 {
... ...
... ... @@ -506,7 +506,7 @@ func (ptr *CooperationStatisticsService) PaymentHistoryHistogramStatistics(query
var values []float64
var queryItems []queryItem
if !request.BeginTime.IsZero() && request.BeginTime.AddDate(0, 3, 0).Before(request.EndTime) {
queryItems, xAxisData = histogramStatisticsByYear()
queryItems, xAxisData = histogramStatisticsByYear(request.BeginTime)
} else {
queryItems, xAxisData = histogramStatisticsByMonth()
}
... ... @@ -566,10 +566,10 @@ func histogramStatisticsByMonth() ([]queryItem, []string) {
return ret, xAxisData
}
func histogramStatisticsByYear() ([]queryItem, []string) {
func histogramStatisticsByYear(beginTime time.Time) ([]queryItem, []string) {
ret := make([]queryItem, 0)
var xAxisData = []string{"3月", "6月", "9月", "12月"}
year, _ := time.Now().Year(), time.Now().Month()
year := beginTime.Year()
var increase = 3
for i := 0; i < 4; i++ {
ret = append(ret, queryItem{
... ...
... ... @@ -9,7 +9,6 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/dao"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/repository"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/utils"
"strconv"
"time"
)
... ... @@ -297,7 +296,7 @@ func (ptr *CooperationStatisticsService) GetContractDividends(queryOptions map[s
}
// 2.合约分红列表
creditAccountRepository, _ := repository.NewCreditAccountRepository(ptr.transactionContext)
creditAccountRepository, _ := repository.NewDividendsEstimateRepository(ptr.transactionContext)
queryOptions["cooperationContractNumber"] = contract.CooperationContractNumber
_, creditAccounts, err := creditAccountRepository.Find(queryOptions)
if err != nil {
... ... @@ -308,11 +307,7 @@ func (ptr *CooperationStatisticsService) GetContractDividends(queryOptions map[s
var orderGoodIds []int64
for i := range creditAccounts {
a := creditAccounts[i]
for j := range a.AccountDetail {
if a.AccountDetail[j].OrderGoodId > 0 {
orderGoodIds = append(orderGoodIds, a.AccountDetail[j].OrderGoodId)
}
}
orderGoodIds = append(orderGoodIds, a.OrderGoodId)
}
var mapOrderGoods = make(map[int64]*domain.OrderGood)
if len(orderGoodIds) > 0 {
... ... @@ -329,35 +324,30 @@ func (ptr *CooperationStatisticsService) GetContractDividends(queryOptions map[s
var dividends = make([]interface{}, 0)
for i := range creditAccounts {
a := creditAccounts[i]
for j := range a.AccountDetail {
participateType, _ := strconv.Atoi(a.ParticipateType)
detail := a.AccountDetail[j]
item := map[string]interface{}{
"creditAccountId": a.CreditAccountId,
"orderGoodName": "",
"dividendsType": 0,
"dividendsRatio": 0,
"dividendsAmount": detail.DividendsAmount,
"dividendsUser": map[string]interface{}{
"userInfo": a.Participator.UserInfo,
"userId": a.Participator.UserId,
},
"dividendsParticipateType": participateType,
"dividendsAccountStatus": a.PaymentStatus,
"dividendsEstimateTime": a.CreatedAt.Unix() * 1000,
"orderOrReturnedOrderNum": a.CreditAccountOrderNum,
}
if detail.OrderGoodAmount > 0 {
item["dividendsRatio"] = utils.Round(detail.DividendsAmount/detail.OrderGoodAmount*100, 2)
}
item["dividendsType"] = a.AccountDetail[j].DividendsType
if v, ok := mapOrderGoods[detail.OrderGoodId]; ok {
item["orderGoodName"] = v.OrderGoodName
}
dividends = append(dividends, item)
participateType := a.DividendsParticipateType
item := map[string]interface{}{
"creditAccountId": a.DividendsEstimateId,
"orderGoodName": "",
"dividendsType": a.DividendsType,
"dividendsRatio": 0,
"dividendsAmount": a.DividendsAmount,
"dividendsUser": map[string]interface{}{
"userInfo": a.DividendsUser.UserInfo,
"userId": a.DividendsUser.UserId,
},
"dividendsParticipateType": participateType,
"dividendsAccountStatus": 0, //TODO:分红状态
"dividendsEstimateTime": a.CreatedAt.Unix() * 1000,
"orderOrReturnedOrderNum": a.DividendsEstimateOrderNumber,
}
if v, ok := mapOrderGoods[a.OrderGoodId]; ok {
item["orderGoodName"] = v.OrderGoodName
if v.OrderGoodAmount > 0 {
item["dividendsRatio"] = utils.Round(a.DividendsAmount/v.OrderGoodAmount*100, 2)
}
}
dividends = append(dividends, item)
}
res["dividends"] = dividends
return res, nil
... ...