...
|
...
|
@@ -5,6 +5,7 @@ import ( |
|
|
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
|
|
|
"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/utils"
|
|
|
"time"
|
|
|
)
|
|
|
|
...
|
...
|
@@ -41,7 +42,8 @@ func (ptr *PgCommonStatisticsService) Scan(keyFlags []int, queryOption map[strin |
|
|
// totalOrganizationUser 统计组织用户
|
|
|
|
|
|
// rankType 排行榜类型,1月榜,2年榜 3总榜,默认展示年榜
|
|
|
func (ptr *PgCommonStatisticsService) CooperationGoodsStatistics(companyId, orgId int64, rankType int) ([]*domain.CooperationGoodsStatisticsDto, error) {
|
|
|
// top 排名前n个
|
|
|
func (ptr *PgCommonStatisticsService) CooperationGoodsStatistics(companyId, orgId int64, rankType int, top int) ([]*domain.CooperationGoodsStatisticsDto, error) {
|
|
|
orderGoodDao, _ := dao.NewOrderGoodDao(ptr.transactionContext)
|
|
|
queryOptions := make(map[string]interface{})
|
|
|
queryOptions["companyId"] = companyId
|
...
|
...
|
@@ -60,7 +62,75 @@ func (ptr *PgCommonStatisticsService) CooperationGoodsStatistics(companyId, orgI |
|
|
queryOptions["beginTime"] = beginTime
|
|
|
queryOptions["endTime"] = endTime
|
|
|
}
|
|
|
return orderGoodDao.CooperationGoodsStatistics(queryOptions)
|
|
|
if top >0{
|
|
|
queryOptions["limit"] = top
|
|
|
}
|
|
|
goods,err:= orderGoodDao.CooperationGoodsStatistics(queryOptions)
|
|
|
if err!=nil{
|
|
|
return nil,err
|
|
|
}
|
|
|
|
|
|
// 2.计算百分比
|
|
|
var totalAmount float64
|
|
|
for i:=range goods{
|
|
|
goods[i].Rank = int32(i)
|
|
|
totalAmount +=goods[i].GoodAmount
|
|
|
}
|
|
|
for i:=range goods{
|
|
|
goods[i].GoodRatio = utils.Round((goods[i].GoodAmount / totalAmount)*100,0)
|
|
|
}
|
|
|
return goods,nil
|
|
|
}
|
|
|
|
|
|
// CooperationModeStatistics 企业-共创模式统计
|
|
|
//
|
|
|
// p1 p1_desc
|
|
|
func (ptr *PgCommonStatisticsService) CooperationModeStatistics(companyId, orgId int64) ([]*domain.CooperationModeStatisticsDto, error){
|
|
|
orderGoodDao, _ := dao.NewOrderGoodDao(ptr.transactionContext)
|
|
|
queryOptions := make(map[string]interface{})
|
|
|
queryOptions["companyId"] = companyId
|
|
|
queryOptions["orgId"] = orgId
|
|
|
|
|
|
modeStatistics,err:= orderGoodDao.CooperationModeStatistics(queryOptions)
|
|
|
if err!=nil{
|
|
|
return nil,err
|
|
|
}
|
|
|
|
|
|
return modeStatistics, nil
|
|
|
}
|
|
|
|
|
|
// DividendsStatistics 分红统计
|
|
|
//
|
|
|
// action 1:当前月
|
|
|
func (ptr *PgCommonStatisticsService) DividendsStatistics(companyId, orgId int64,action int) (interface{}, error){
|
|
|
orderGoodDao, _ := dao.NewOrderGoodDao(ptr.transactionContext)
|
|
|
queryOptions := make(map[string]interface{})
|
|
|
queryOptions["companyId"] = companyId
|
|
|
queryOptions["orgId"] = orgId
|
|
|
var beginTime, endTime time.Time
|
|
|
var res = make(map[string]interface{})
|
|
|
if action==1{
|
|
|
y := time.Now().Year()
|
|
|
m := time.Now().Month()
|
|
|
beginTime = time.Date(y, m, 1, 0, 0, 0, 0, time.Local)
|
|
|
endTime = beginTime.AddDate(0, 1, 0)
|
|
|
queryOptions["beginTime"] = beginTime
|
|
|
queryOptions["endTime"] = endTime
|
|
|
}
|
|
|
totalDividends,err:= orderGoodDao.DividendsStatistics(queryOptions)
|
|
|
if err!=nil{
|
|
|
return nil,err
|
|
|
}
|
|
|
res["creditAccount"] = totalDividends.DividendsEstimate
|
|
|
res["orderAmount"] = totalDividends.OrderAmount
|
|
|
|
|
|
queryOptions["paymentStatus"] = 2
|
|
|
dividendsEstimate,err:= orderGoodDao.DividendsStatistics(queryOptions)
|
|
|
if err!=nil{
|
|
|
return nil,err
|
|
|
}
|
|
|
res["dividendsEstimate"] = dividendsEstimate.DividendsEstimate
|
|
|
return res, nil
|
|
|
}
|
|
|
|
|
|
func (ptr *PgCommonStatisticsService) loadQueryOptions(queryOption map[string]interface{}, keys ...string) (map[string]interface{}, error) {
|
...
|
...
|
|