| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- <?php
- namespace App\Http\Controllers;
- use App\Interfaces\SettlementBillControllerInterface;
- use App\Owner;
- use App\OwnerBillReport;
- use App\OwnerBillReportArchive;
- use App\Services\OwnerBillReportArchiveService;
- use App\Services\OwnerStoreOutFeeDetailService;
- use App\Traits\SettlementBillTrait;
- use Illuminate\Http\RedirectResponse;
- use Illuminate\Http\Request;
- use Oursdreams\Export\Export;
- class OwnerStoreOutFeeDetailController extends Controller implements SettlementBillControllerInterface
- {
- use SettlementBillTrait;
- /** @var OwnerStoreOutFeeDetailService $service */
- private $service;
- /** @var OwnerBillReportArchiveService $archiveService */
- private $archiveService;
- public function __construct()
- {
- $this->service = app('OwnerStoreOutFeeDetailService');
- $this->archiveService = app('OwnerBillReportArchiveService');
- $this->middleware('auth');
- }
- public function index(Request $request)
- {
- $paginateParams = $request->input();
- list($permittingOwnerIds, $counting_month, $owner_id) = $this->getRequestParams($request->year, $request->month, $request->owner_id);
- $details = $this->service->get([
- 'counting_month' => $counting_month,
- 'owner_id' => $owner_id,
- 'paginateParams' => $paginateParams,
- ]);
- $owners = Owner::query()->selectRaw("id,name")->whereIn('id', $permittingOwnerIds)->get();
- $owner = Owner::query()->selectRaw("name,id")->find($owner_id);
- $isArchived = $this->archiveService->isArchived($counting_month, $owner_id, $this->service::TYPE);
- $request = $this->buildRequest($request, $counting_month);
- return view('finance.settlementBills.storeOutFee.detail.index', compact('details', 'paginateParams', 'owners', 'owner', 'request', 'isArchived'));
- }
- public function confirmBill(Request $request): RedirectResponse
- {
- list($permittingOwnerIds, $counting_month, $owner_id) = $this->getRequestParams($request->year, $request->month, $request->owner_id);
- $billReport = OwnerBillReport::query()
- ->select('id')
- ->where('owner_id', $owner_id)
- ->where('counting_month', $counting_month)
- ->firstOr(function () {
- return new OwnerBillReport();
- });
- OwnerBillReportArchive::query()->create([
- 'owner_bill_report_id' => $billReport->id ?? null,
- 'owner_id' => $owner_id,
- 'counting_month' => $counting_month,
- 'type' => $this->service::TYPE,
- 'archiver_id' => auth()->id(),
- 'archived_at' => now(),
- 'information' => [],
- ]);
- return back()->with('success', '确认成功');
- }
- public function export(Request $request)
- {
- list($permittingOwnerIds, $counting_month, $owner_id) = $this->getRequestParams($request->year, $request->month, $request->owner_id);
- $query = $this->service->getSql($owner_id, $counting_month);
- if (!$request->exists('checkAllSign')) {
- $query->whereIn('id', explode(',', $request['data']));
- }
- $details = $query->get();
- $json = $this->service->buildExport($details);
- $row = ['作业时间', '作业名称', '上游单号', '订单号', '商品条码', '商品名称', '商品数量', '价格', '合计'];
- return Export::make($row, $json, "出库费明细");
- }
- }
|