Browse Source

汇总结报统计接口2

master
wanghongjun 11 months ago
parent
commit
7c9fb4b068
  1. 11
      app/controller/admin/Index.php
  2. 6
      app/model/InvoiceFinalReport.php

11
app/controller/admin/Index.php

@ -77,6 +77,14 @@ class Index extends Base {
}
}
$finalReportArr = ['type' => '当月结报金额', 'count' => 0];
$where = [
['report_time', '>=', strtotime(date("Y-m"))],
['report_time', '<', strtotime('+1 month', strtotime(date("Y-m")))]
];
$finalReportArr['count'] = (new InvoiceFinalReport())->getSumAmount($where);
$data['invoice_head_data'][] = $finalReportArr;
return $this->buildSuccess($data);
} catch (\Exception $e) {
@ -112,8 +120,7 @@ class Index extends Base {
['report_time', '<', $end_time]
];
$result = (new InvoiceFinalReport())->where($where)->field('sum(`ydzse`) as ydzse_sum')->find();
$amountArr[$key] = $result['ydzse_sum'] ?? 0;
$amountArr[$key] = (new InvoiceFinalReport())->getSumAmount($where);
}
return $this->buildSuccess([

6
app/model/InvoiceFinalReport.php

@ -7,4 +7,10 @@ use think\Model;
class InvoiceFinalReport extends Model
{
public function getSumAmount($where)
{
$result = $this->where($where)->field('sum(`ydzse`) as ydzse_sum')->find();
return $result['ydzse_sum'] ? number_format($result['ydzse_sum'], 2, '.', ',') : 0;
}
}

Loading…
Cancel
Save