...
|
...
|
@@ -118,7 +118,6 @@ func (ptr *CooperationStatisticsService) CompanyDividendsStatistics(queryOptions |
|
|
}
|
|
|
queryOptions = tool_funs.SimpleStructToMap(&request)
|
|
|
|
|
|
orderGoodDao, _ := dao.NewOrderGoodDao(ptr.transactionContext)
|
|
|
var beginTime, endTime time.Time
|
|
|
var res = make(map[string]interface{})
|
|
|
if request.Action == 1 {
|
...
|
...
|
@@ -129,23 +128,28 @@ func (ptr *CooperationStatisticsService) CompanyDividendsStatistics(queryOptions |
|
|
queryOptions["beginTime"] = beginTime
|
|
|
queryOptions["endTime"] = endTime
|
|
|
}
|
|
|
totalDividends, err := orderGoodDao.CompanyDividendsStatistics(queryOptions)
|
|
|
|
|
|
dividendsEstimateDao, _ := dao.NewDividendsEstimateDao(ptr.transactionContext)
|
|
|
dividendsEstimate, err := dividendsEstimateDao.CountDividendsEstimateDividendsAmount(queryOptions)
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
queryOptions["paymentStatus"] = 2
|
|
|
dividendsEstimate, err := orderGoodDao.CompanyDividendsStatistics(queryOptions)
|
|
|
if err != nil {
|
|
|
var dividends = &CreditAccountStatisticsResponse{}
|
|
|
orderGoodDao, _ := dao.NewCreditAccountDao(ptr.transactionContext)
|
|
|
if err := orderGoodDao.DividendsStatistics(queryOptions, dividends); err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
orderAmount := ptr.CalculateOrderAmount(queryOptions)
|
|
|
|
|
|
res["creditAccount"] = dividendsEstimate.DividendsEstimate // 本月账期结算统计
|
|
|
res["orderAmount"] = orderAmount // 订单金额统计
|
|
|
res["dividendsEstimate"] = totalDividends.DividendsEstimate // 分红预算统计
|
|
|
res["creditAccount"] = dividends.Paid // 本月账期结算统计
|
|
|
res["orderAmount"] = orderAmount // 订单金额统计
|
|
|
res["dividendsEstimate"] = utils.Round(dividendsEstimate, 1) // 分红预算统计
|
|
|
return res, nil
|
|
|
}
|
|
|
|
|
|
// CalculateOrderAmount 计算订单总金额
|
|
|
// 订单总金额 = 订单总金额 - 退货总金额
|
|
|
func (ptr *CooperationStatisticsService) CalculateOrderAmount(queryOption map[string]interface{}) float64 {
|
|
|
orderDao, err := dao.NewDividendsOrderDao(ptr.transactionContext)
|
|
|
if err != nil {
|
...
|
...
|
@@ -157,9 +161,9 @@ func (ptr *CooperationStatisticsService) CalculateOrderAmount(queryOption map[st |
|
|
}
|
|
|
returnedOrderDao, _ := dao.NewDividendsReturnedOrderDao(ptr.transactionContext)
|
|
|
returnedAmount, _ := returnedOrderDao.CalculateDividendsReturnedOrderAmount(queryOption)
|
|
|
if math.Abs(returnedAmount) > math.Abs(amount) {
|
|
|
return 0
|
|
|
}
|
|
|
//if math.Abs(returnedAmount) > math.Abs(amount) {
|
|
|
// return 0
|
|
|
//}
|
|
|
return utils.Round(math.Abs(amount)-math.Abs(returnedAmount), 1)
|
|
|
}
|
|
|
|
...
|
...
|
|