...
|
...
|
@@ -8,6 +8,8 @@ import ( |
|
|
"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"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/log"
|
|
|
"math"
|
|
|
"time"
|
|
|
)
|
|
|
|
...
|
...
|
@@ -23,6 +25,7 @@ func (ptr *CooperationStatisticsService) CooperationGoodsStatistics(queryOptions |
|
|
OrgId int64 `json:"orgId" valid:"Required"`
|
|
|
RankType int `json:"rankType" valid:"Required"`
|
|
|
Top int `json:"top" valid:"Required"`
|
|
|
Offset int `json:"offset"`
|
|
|
}{}
|
|
|
if err := LoadQueryObject(queryOptions, &request); err != nil {
|
|
|
return nil, err
|
...
|
...
|
@@ -46,6 +49,9 @@ func (ptr *CooperationStatisticsService) CooperationGoodsStatistics(queryOptions |
|
|
if request.Top > 0 {
|
|
|
queryOptions["limit"] = request.Top
|
|
|
}
|
|
|
if request.Offset > 0 {
|
|
|
queryOptions["offset"] = request.Offset
|
|
|
}
|
|
|
goods, err := orderGoodDao.CooperationGoodsStatistics(queryOptions)
|
|
|
if err != nil {
|
|
|
return nil, err
|
...
|
...
|
@@ -131,13 +137,31 @@ func (ptr *CooperationStatisticsService) CompanyDividendsStatistics(queryOptions |
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
orderAmount := ptr.CalculateOrderAmount(queryOptions)
|
|
|
|
|
|
res["creditAccount"] = totalDividends.DividendsEstimate
|
|
|
res["orderAmount"] = totalDividends.OrderAmount
|
|
|
res["dividendsEstimate"] = dividendsEstimate.DividendsEstimate
|
|
|
res["creditAccount"] = dividendsEstimate.DividendsEstimate // 本月账期结算统计
|
|
|
res["orderAmount"] = orderAmount // 订单金额统计
|
|
|
res["dividendsEstimate"] = totalDividends.DividendsEstimate // 分红预算统计
|
|
|
return res, nil
|
|
|
}
|
|
|
|
|
|
func (ptr *CooperationStatisticsService) CalculateOrderAmount(queryOption map[string]interface{}) float64 {
|
|
|
orderDao, err := dao.NewDividendsOrderDao(ptr.transactionContext)
|
|
|
if err != nil {
|
|
|
log.Logger.Error(err.Error())
|
|
|
}
|
|
|
amount, err := orderDao.CalculateDividendsOrderAmount(queryOption)
|
|
|
if err != nil {
|
|
|
log.Logger.Error(err.Error())
|
|
|
}
|
|
|
returnedOrderDao, _ := dao.NewDividendsReturnedOrderDao(ptr.transactionContext)
|
|
|
returnedAmount, _ := returnedOrderDao.CalculateDividendsReturnedOrderAmount(queryOption)
|
|
|
if math.Abs(returnedAmount) > math.Abs(amount) {
|
|
|
return 0
|
|
|
}
|
|
|
return utils.Round(math.Abs(amount)-math.Abs(returnedAmount), 1)
|
|
|
}
|
|
|
|
|
|
func LoadQueryOptions(queryOption map[string]interface{}, keys ...string) (map[string]interface{}, error) {
|
|
|
var res = make(map[string]interface{})
|
|
|
for i := 0; i < len(keys); i++ {
|
...
|
...
|
|