...
|
...
|
@@ -7,6 +7,7 @@ import ( |
|
|
"github.com/linmadan/egglib-go/utils/tool_funs"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
|
|
|
"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"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/log"
|
|
|
"math"
|
...
|
...
|
@@ -91,7 +92,7 @@ func (ptr *CooperationStatisticsService) CooperationModeStatistics(queryOptions |
|
|
}
|
|
|
queryOptions = tool_funs.SimpleStructToMap(&request)
|
|
|
|
|
|
modeStatistics, err := orderGoodDao.CooperationModeStatistics(queryOptions)
|
|
|
modeStatistics, err := orderGoodDao.CooperationCompanyModeStatistics(queryOptions)
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
...
|
...
|
@@ -201,7 +202,34 @@ func (ptr *CooperationStatisticsService) CompanyCooperationUsersStatistics(query |
|
|
}
|
|
|
queryOptions = tool_funs.SimpleStructToMap(&request)
|
|
|
|
|
|
type response struct {
|
|
|
var responses []usersStatisticsResponse
|
|
|
creditAccountDao, _ := dao.NewCreditAccountDao(ptr.transactionContext)
|
|
|
if err := creditAccountDao.CooperationUsersDividendsStatistics(queryOptions, &responses); err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
|
|
|
var retMap = make([]interface{}, 0)
|
|
|
for i := range responses {
|
|
|
responses[i].CooperationTime = time.Now().Unix() * 1000
|
|
|
unPaidAmount := responses[i].DividesAmount - responses[i].ActuallyPaidAmount
|
|
|
retMap = append(retMap, map[string]interface{}{
|
|
|
"dividendsOrderAmount": responses[i].DividendsOrderAmount,
|
|
|
"dividesAmount": responses[i].DividesAmount,
|
|
|
"unPaidAmount": unPaidAmount,
|
|
|
"cooperationTime": time.Now().Unix() * 1000,
|
|
|
"participator": map[string]interface{}{
|
|
|
"userId": responses[i].UserId,
|
|
|
"userInfo": map[string]interface{}{
|
|
|
"userName": responses[i].UserName,
|
|
|
},
|
|
|
},
|
|
|
})
|
|
|
}
|
|
|
|
|
|
return retMap, nil
|
|
|
}
|
|
|
|
|
|
type usersStatisticsResponse struct {
|
|
|
CooperationTime int64 `json:"cooperationTime"`
|
|
|
DividendsOrderAmount float64 `json:"dividendsOrderAmount"`
|
|
|
DividesAmount float64 `json:"dividesAmount"` // 分红金额
|
...
|
...
|
@@ -211,8 +239,94 @@ func (ptr *CooperationStatisticsService) CompanyCooperationUsersStatistics(query |
|
|
UserName string `json:"userName"`
|
|
|
|
|
|
Participator interface{} `json:"participator"`
|
|
|
}
|
|
|
|
|
|
// 公司 - 共创用户模式统计
|
|
|
func (ptr *CooperationStatisticsService) CooperationUserModeStatistics(queryOptions map[string]interface{}) (interface{}, error) {
|
|
|
// 参数验证
|
|
|
var request = struct {
|
|
|
UserId int64 `json:"offset" valid:"Required"`
|
|
|
//OrgId int64 `json:"orgId" valid:"Required"`
|
|
|
}{}
|
|
|
if err := LoadQueryObject(queryOptions, &request); err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
var responses []response
|
|
|
queryOptions = tool_funs.SimpleStructToMap(&request)
|
|
|
|
|
|
orderGoodDao, _ := dao.NewOrderGoodDao(ptr.transactionContext)
|
|
|
modeStatistics, err := orderGoodDao.CooperationUserModeStatistics(queryOptions)
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
if len(modeStatistics) == 0 {
|
|
|
return struct{}{}, nil
|
|
|
}
|
|
|
|
|
|
var modeNumbers []string
|
|
|
var mapModeStatistics = make(map[string]*domain.CooperationModeStatisticsDto)
|
|
|
for i := range modeStatistics {
|
|
|
mapModeStatistics[modeStatistics[i].CooperationModeNumber] = modeStatistics[i]
|
|
|
modeNumbers = append(modeNumbers, modeStatistics[i].CooperationModeNumber)
|
|
|
}
|
|
|
|
|
|
cooperationModeRepository, _ := repository.NewCooperationModeRepository(ptr.transactionContext)
|
|
|
_, cooperModes, err := cooperationModeRepository.Find(map[string]interface{}{"cooperationModeNumbers": modeNumbers})
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
var cooperationTypes, dividendsExpenseByTypes, orderAmountByTypes []interface{}
|
|
|
var totalOrderAmount float64
|
|
|
var totalDividendAmount float64
|
|
|
for i := range cooperModes {
|
|
|
m := cooperModes[i]
|
|
|
if modeStatistics, ok := mapModeStatistics[m.CooperationModeNumber]; ok {
|
|
|
totalOrderAmount += modeStatistics.OrderAmount
|
|
|
totalDividendAmount += modeStatistics.SettlementAmount
|
|
|
dividendsExpenseByTypes = append(dividendsExpenseByTypes, map[string]interface{}{
|
|
|
"dividendsTypeName": m.CooperationModeName + "分红支出",
|
|
|
"dividendsExpense": modeStatistics.SettlementAmount,
|
|
|
})
|
|
|
orderAmountByTypes = append(orderAmountByTypes, map[string]interface{}{
|
|
|
"orderAmount": modeStatistics.OrderAmount,
|
|
|
"orderTypeName": m.CooperationModeName + "成交订单",
|
|
|
})
|
|
|
}
|
|
|
cooperationTypes = append(cooperationTypes, map[string]interface{}{
|
|
|
"cooperationModeId": m.CooperationModeId,
|
|
|
"cooperationModeName": m.CooperationModeName,
|
|
|
"cooperationModeNumber": m.CooperationModeNumber,
|
|
|
})
|
|
|
}
|
|
|
return map[string]interface{}{
|
|
|
"cooperationTypes": cooperationTypes,
|
|
|
"dividendsDetails": map[string]interface{}{
|
|
|
"dividendsExpense": totalDividendAmount,
|
|
|
"dividendsExpenseByTypes": dividendsExpenseByTypes,
|
|
|
},
|
|
|
"orderDetails": map[string]interface{}{
|
|
|
"orderAmount": totalOrderAmount,
|
|
|
"orderAmountByTypes": orderAmountByTypes,
|
|
|
},
|
|
|
}, nil
|
|
|
}
|
|
|
|
|
|
// 公司 - 共创用户分红支付统计
|
|
|
func (ptr *CooperationStatisticsService) CompanyPaymentHistoryStatistics(queryOptions map[string]interface{}) (interface{}, error) {
|
|
|
// 参数验证
|
|
|
var request = struct {
|
|
|
Limit int `json:"limit" valid:"Required"`
|
|
|
Offset int `json:"offset"`
|
|
|
OrgId int64 `json:"orgId" valid:"Required"`
|
|
|
SortByActuallyPaidAmount int `json:"sortByActuallyPaidAmount" valid:"Required"`
|
|
|
BeginTime time.Time `json:"beginTime"`
|
|
|
EndTime time.Time `json:"endTime"`
|
|
|
}{}
|
|
|
if err := LoadQueryObject(queryOptions, &request); err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
queryOptions = tool_funs.SimpleStructToMap(&request)
|
|
|
|
|
|
var responses []usersStatisticsResponse
|
|
|
creditAccountDao, _ := dao.NewCreditAccountDao(ptr.transactionContext)
|
|
|
if err := creditAccountDao.CooperationUsersDividendsStatistics(queryOptions, &responses); err != nil {
|
|
|
return nil, err
|
...
|
...
|
@@ -220,14 +334,9 @@ func (ptr *CooperationStatisticsService) CompanyCooperationUsersStatistics(query |
|
|
|
|
|
var retMap = make([]interface{}, 0)
|
|
|
for i := range responses {
|
|
|
responses[i].CooperationTime = time.Now().Unix() * 1000
|
|
|
unPaidAmount := responses[i].DividesAmount - responses[i].ActuallyPaidAmount
|
|
|
retMap = append(retMap, map[string]interface{}{
|
|
|
"dividendsOrderAmount": responses[i].DividendsOrderAmount,
|
|
|
"dividesAmount": responses[i].DividesAmount,
|
|
|
"unPaidAmount": unPaidAmount,
|
|
|
"cooperationTime": time.Now().Unix() * 1000,
|
|
|
"participator": map[string]interface{}{
|
|
|
"paymentAmount": responses[i].ActuallyPaidAmount,
|
|
|
"user": map[string]interface{}{
|
|
|
"userId": responses[i].UserId,
|
|
|
"userInfo": map[string]interface{}{
|
|
|
"userName": responses[i].UserName,
|
...
|
...
|
|