weizong song 1 month ago
parent d722b84c80
commit 17d7a7437f

@ -358,6 +358,7 @@ class StatisticsController extends CommonController
if ($mode == 'order') {
$orderBalances = Orders::query()
->withoutGlobalScopes()
->leftJoin("project", "project.id", "=", "orders.project_id")
->leftJoin("customers", "customers.id", "=", "orders.customer_id")
->leftJoin("patient", "patient.id", "=", "orders.patient_id")
->leftJoin("balance", function ($join) use ($before_datetime_text) {
@ -372,10 +373,12 @@ class StatisticsController extends CommonController
->groupBy(
"orders.id",
"orders.serial",
"project.name",
"orders.from_date",
"orders.to_date",
"orders.contact",
"orders.mobile",
"orders.status",
"customers.mobile",
"patient.name"
)
@ -384,10 +387,21 @@ class StatisticsController extends CommonController
->get([
"orders.id",
"orders.serial",
"project.name as project_name",
"orders.from_date",
"orders.to_date",
"orders.contact",
"orders.mobile as contact_mobile",
DB::raw("'" . $before_datetime_text . "' as point_time"),
DB::raw("
CASE orders.status
WHEN " . Orders::STATUS_UNCONFIRMED . " THEN '" . Orders::TEXT_UNCONFIRMED . "'
WHEN " . Orders::STATUS_UNASSIGNED . " THEN '" . Orders::TEXT_UNASSIGNED . "'
WHEN " . Orders::STATUS_ONGOING . " THEN '" . Orders::TEXT_ONGOING . "'
WHEN " . Orders::STATUS_FINISHED . " THEN '" . Orders::TEXT_FINISHED . "'
ELSE orders.status
END as status_name
"),
"customers.mobile as customer_mobile",
"patient.name as patient_name",
DB::raw("COALESCE(SUM(balance.money), 0) as balance"),

@ -47,6 +47,9 @@
<label class="control-label mr-1">截止日期</label><input
value="{{ $before_date }}" class="form-control mr-1" name="before_date"
data-plugin="date-picker">
@if(\App\Models\CommonModel::checkExport())
<button class="btn btn-primary ml-1" type="button" onclick="exportOrderBalanceExcel()">导出Excel</button>
@endif
@endif
<button type="submit" class="btn btn-primary ml-1">查询</button>
</form>
@ -58,7 +61,10 @@
<thead>
<tr>
<th class="p-1" style="white-space: nowrap">序号</th>
<th class="p-1" style="white-space: nowrap">项目名称</th>
<th class="p-1" style="white-space: nowrap">时点</th>
<th class="p-1" style="white-space: nowrap">订单号</th>
<th class="p-1" style="white-space: nowrap">订单状态</th>
<th class="p-1" style="white-space: nowrap">客户手机号</th>
<th class="p-1" style="white-space: nowrap">联系人</th>
<th class="p-1" style="white-space: nowrap">联系电话</th>
@ -72,7 +78,10 @@
@foreach($orderBalances as $item)
<tr>
<td class="p-1">{{ $loop->iteration }}</td>
<td class="p-1">{{ $item->project_name }}</td>
<td class="p-1">{{ $item->point_time }}</td>
<td class="p-1">{{ $item->serial }}</td>
<td class="p-1">{{ $item->status_name }}</td>
<td class="p-1">{{ $item->customer_mobile }}</td>
<td class="p-1">{{ $item->contact }}</td>
<td class="p-1">{{ $item->contact_mobile }}</td>
@ -122,4 +131,10 @@
</div>
@include("plugins.datatable")
<script>
function exportOrderBalanceExcel() {
$('.dt-buttons .buttons-excel').first().click();
}
</script>
@endsection

Loading…
Cancel
Save