|
|
|
@ -3,6 +3,7 @@ declare (strict_types=1); |
|
|
|
|
|
|
|
namespace app\controller\admin; |
|
|
|
|
|
|
|
use app\model\InvoiceFinalReport; |
|
|
|
use app\model\InvoiceHead; |
|
|
|
use app\model\WechatUser; |
|
|
|
use app\util\ReturnCode; |
|
|
|
@ -82,4 +83,42 @@ class Index extends Base { |
|
|
|
return $this->buildFailed(ReturnCode::RECORD_NOT_FOUND, '记录未找到'); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 结报金额统计-月 |
|
|
|
* @return Response |
|
|
|
* @throws \think\db\exception\DataNotFoundException |
|
|
|
* @throws \think\db\exception\DbException |
|
|
|
* @throws \think\db\exception\ModelNotFoundException |
|
|
|
*/ |
|
|
|
public function getFinalReportData() |
|
|
|
{ |
|
|
|
$dateArr = []; |
|
|
|
$amountArr = []; |
|
|
|
$nowDate = date('Y-m'); |
|
|
|
for ($i = 5; $i >= 1; $i--) { |
|
|
|
$dateArr[] = date('Y-m', strtotime('-' . $i . ' month', strtotime($nowDate))); |
|
|
|
$amountArr[] = 0; |
|
|
|
} |
|
|
|
$dateArr[] = $nowDate; |
|
|
|
|
|
|
|
foreach ($dateArr as $key => $monthDate) { |
|
|
|
|
|
|
|
$start_time = strtotime($monthDate); |
|
|
|
$end_time = strtotime('+1 month', $start_time); |
|
|
|
|
|
|
|
$where = [ |
|
|
|
['report_time', '>=', $start_time], |
|
|
|
['report_time', '<', $end_time] |
|
|
|
]; |
|
|
|
|
|
|
|
$result = (new InvoiceFinalReport())->where($where)->field('sum(`ydzse`) as ydzse_sum')->find(); |
|
|
|
$amountArr[$key] = $result['ydzse_sum'] ?? 0; |
|
|
|
} |
|
|
|
|
|
|
|
return $this->buildSuccess([ |
|
|
|
'date' => $dateArr, |
|
|
|
'data' => $amountArr |
|
|
|
]); |
|
|
|
} |
|
|
|
} |
|
|
|
|