...
|
...
|
@@ -7,7 +7,9 @@ import ( |
|
|
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
|
|
|
"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"
|
|
|
"time"
|
|
|
)
|
|
|
|
|
|
const (
|
...
|
...
|
@@ -24,6 +26,8 @@ const ( |
|
|
CooperationModeStatistics = "CooperationModeStatistics"
|
|
|
// 企业-分红统计
|
|
|
CompanyDividendsStatistics = "CompanyDividendsStatistics"
|
|
|
// 企业、个人 - 分红预算列表
|
|
|
SearchDividendsEstimates = "SearchDividendsEstimates"
|
|
|
)
|
|
|
|
|
|
// CooperationStatisticsService 共创统计服务
|
...
|
...
|
@@ -196,7 +200,78 @@ func (ptr *CooperationStatisticsService) GetContractDividends(queryOptions map[s |
|
|
|
|
|
// 分红统计(分红明细)
|
|
|
func (ptr *CooperationStatisticsService) DividendsStatistics(queryOptions map[string]interface{}) (interface{}, error) {
|
|
|
return nil, nil
|
|
|
// 参数验证
|
|
|
var request = struct {
|
|
|
//企业
|
|
|
CompanyId int64 `json:"companyId"`
|
|
|
OrgId int64 `json:"orgId"`
|
|
|
//个人
|
|
|
UserBaseId int64 `json:"userBaseId"`
|
|
|
}{}
|
|
|
if err := LoadQueryObject(queryOptions, &request); err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
queryOptions = tool_funs.SimpleStructToMap(&request)
|
|
|
|
|
|
type response struct {
|
|
|
Total float64 `json:"total"`
|
|
|
Accounting float64 `json:"accounting"`
|
|
|
Accounted float64 `json:"accounted"`
|
|
|
Paid float64 `json:"paid"`
|
|
|
}
|
|
|
creditAccountDao, _ := dao.NewCreditAccountDao(ptr.transactionContext)
|
|
|
|
|
|
var allDividends = &response{}
|
|
|
if err := creditAccountDao.DividendsStatistics(queryOptions, allDividends); err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
allDividends.Accounting = allDividends.Total - allDividends.Accounted
|
|
|
|
|
|
var annualDividends = &response{}
|
|
|
queryOptions["beginTime"] = time.Date(time.Now().Year(), 1, 1, 0, 0, 0, 0, time.Local)
|
|
|
queryOptions["endTime"] = time.Date(time.Now().Year(), 1, 1, 0, 0, 0, 0, time.Local).AddDate(1, 0, 0)
|
|
|
if err := creditAccountDao.DividendsStatistics(queryOptions, annualDividends); err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
annualDividends.Accounting = annualDividends.Total - annualDividends.Accounted
|
|
|
|
|
|
var quarterDividends = &response{}
|
|
|
queryOptions["beginTime"], queryOptions["endTime"] = quarterBeginEnd()
|
|
|
if err := creditAccountDao.DividendsStatistics(queryOptions, quarterDividends); err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
quarterDividends.Accounting = quarterDividends.Total - quarterDividends.Accounted
|
|
|
|
|
|
ret := map[string]interface{}{
|
|
|
"allDividends": allDividends,
|
|
|
"annualDividends": annualDividends,
|
|
|
"quarterDividends": quarterDividends,
|
|
|
}
|
|
|
return ret, nil
|
|
|
}
|
|
|
|
|
|
func quarterBeginEnd() (time.Time, time.Time) {
|
|
|
y := time.Now().Year()
|
|
|
m := time.Now().Month()
|
|
|
var mBegin, mEnd int
|
|
|
var begin, end time.Time
|
|
|
switch m {
|
|
|
case 4, 5, 6:
|
|
|
mBegin = 4
|
|
|
mEnd = 6
|
|
|
case 7, 8, 9:
|
|
|
mBegin = 7
|
|
|
mEnd = 9
|
|
|
case 10, 11, 12:
|
|
|
mBegin = 10
|
|
|
mEnd = 12
|
|
|
case 1, 2, 3:
|
|
|
mBegin = 1
|
|
|
mEnd = 3
|
|
|
}
|
|
|
begin = time.Date(y, time.Month(mBegin), 1, 0, 0, 0, 0, time.Local)
|
|
|
end = time.Date(y, time.Month(mEnd), 1, 0, 0, 0, 0, time.Local)
|
|
|
return begin, end
|
|
|
}
|
|
|
|
|
|
// 分红预算列表
|
...
|
...
|
|