|
@@ -2,18 +2,16 @@
|
|
|
|
|
|
|
|
namespace App\Http\Controllers;
|
|
namespace App\Http\Controllers;
|
|
|
|
|
|
|
|
|
|
+use App\Interfaces\SettlementBillControllerInterface;
|
|
|
use App\Owner;
|
|
use App\Owner;
|
|
|
-use App\OwnerBillReport;
|
|
|
|
|
use App\OwnerBillReportArchive;
|
|
use App\OwnerBillReportArchive;
|
|
|
use App\Services\OwnerBillReportArchiveService;
|
|
use App\Services\OwnerBillReportArchiveService;
|
|
|
use App\Services\OwnerLogisticFeeDetailService;
|
|
use App\Services\OwnerLogisticFeeDetailService;
|
|
|
use App\Traits\SettlementBillTrait;
|
|
use App\Traits\SettlementBillTrait;
|
|
|
-use Carbon\Carbon;
|
|
|
|
|
-use Illuminate\Http\RedirectResponse;
|
|
|
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Request;
|
|
|
use Oursdreams\Export\Export;
|
|
use Oursdreams\Export\Export;
|
|
|
|
|
|
|
|
-class OwnerLogisticFeeDetailController extends Controller
|
|
|
|
|
|
|
+class OwnerLogisticFeeDetailController extends Controller implements SettlementBillControllerInterface
|
|
|
{
|
|
{
|
|
|
use SettlementBillTrait;
|
|
use SettlementBillTrait;
|
|
|
|
|
|
|
@@ -23,6 +21,14 @@ class OwnerLogisticFeeDetailController extends Controller
|
|
|
/** @var $archiveService OwnerBillReportArchiveService */
|
|
/** @var $archiveService OwnerBillReportArchiveService */
|
|
|
private $archiveService;
|
|
private $archiveService;
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * OwnerLogisticFeeDetailController constructor.
|
|
|
|
|
+ */
|
|
|
|
|
+ public function __construct()
|
|
|
|
|
+ {
|
|
|
|
|
+ $this->service = app('OwnerLogisticFeeDetailService');
|
|
|
|
|
+ $this->archiveService = app('OwnerBillReportArchiveService');
|
|
|
|
|
+ }
|
|
|
/**
|
|
/**
|
|
|
* Display a listing of the resource.
|
|
* Display a listing of the resource.
|
|
|
*
|
|
*
|
|
@@ -30,20 +36,24 @@ class OwnerLogisticFeeDetailController extends Controller
|
|
|
public function index(Request $request)
|
|
public function index(Request $request)
|
|
|
{
|
|
{
|
|
|
$paginateParams = $request->input();
|
|
$paginateParams = $request->input();
|
|
|
- list($permittingOwnerIds, $owner_id, $start, $end) = $this->getRequestParams($request->owner_id, $request->year, $request->month);
|
|
|
|
|
- $details = $this->service->getDetails($owner_id, $start, $end, $paginateParams);
|
|
|
|
|
|
|
+ list($permittingOwnerIds, $counting_month, $owner_id) = $this->getRequestParams($request->year, $request->month,$request->owner_id);
|
|
|
|
|
+ $details = $this->service->get([
|
|
|
|
|
+ 'owner_id' => $owner_id,
|
|
|
|
|
+ 'counting_month' => $counting_month,
|
|
|
|
|
+ 'paginateParams' => $paginateParams,
|
|
|
|
|
+ ]);
|
|
|
$owners = Owner::query()->selectRaw("id,name")->whereIn('id', $permittingOwnerIds)->get();
|
|
$owners = Owner::query()->selectRaw("id,name")->whereIn('id', $permittingOwnerIds)->get();
|
|
|
$owner = Owner::query()->selectRaw("name,id")->find($owner_id);
|
|
$owner = Owner::query()->selectRaw("name,id")->find($owner_id);
|
|
|
$this->archiveService = app('OwnerBillReportArchiveService');
|
|
$this->archiveService = app('OwnerBillReportArchiveService');
|
|
|
- $isArchived = $this->archiveService->isArchived($start, $owner_id, OwnerBillReportArchive::$enums['type']['快递费-明细']);
|
|
|
|
|
- $request = $this->buildRequest($request,$start);
|
|
|
|
|
|
|
+ $isArchived = $this->archiveService->isArchived($counting_month, $owner_id, OwnerBillReportArchive::$enums['type']['快递费-明细']);
|
|
|
|
|
+ $request = $this->buildRequest($request, $counting_month);
|
|
|
return view('finance.settlementBills.logisticFee.detail.index', compact('details', 'paginateParams', 'owners', 'owner', 'request', 'isArchived'));
|
|
return view('finance.settlementBills.logisticFee.detail.index', compact('details', 'paginateParams', 'owners', 'owner', 'request', 'isArchived'));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public function export(Request $request)
|
|
public function export(Request $request)
|
|
|
{
|
|
{
|
|
|
- list($permittingOwnerIds, $owner_id, $start, $end) = $this->getRequestParams($request->owner_id, $request->year, $request->month);
|
|
|
|
|
- $query = $this->service->getSql($owner_id, $start, $end);
|
|
|
|
|
|
|
+ list($permittingOwnerIds, $counting_month, $owner_id) = $this->getRequestParams($request->owner_id, $request->year, $request->month);
|
|
|
|
|
+ $query = $this->service->getSql($owner_id, $counting_month);
|
|
|
if (!$request->exists('checkAllSign')) {
|
|
if (!$request->exists('checkAllSign')) {
|
|
|
$query->whereIn('id', explode(',', $request['data']));
|
|
$query->whereIn('id', explode(',', $request['data']));
|
|
|
}
|
|
}
|
|
@@ -55,57 +65,4 @@ class OwnerLogisticFeeDetailController extends Controller
|
|
|
$row = ['主键', '快递公司', '省份', '快递单号', '重量', '首重价格', '续重价格', '快递费',];
|
|
$row = ['主键', '快递公司', '省份', '快递单号', '重量', '首重价格', '续重价格', '快递费',];
|
|
|
return Export::make($row, $json, "快递费用详情");
|
|
return Export::make($row, $json, "快递费用详情");
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * @param $owner_id
|
|
|
|
|
- * @param $year
|
|
|
|
|
- * @param $month
|
|
|
|
|
- * @return array
|
|
|
|
|
- */
|
|
|
|
|
- private function getRequestParams($owner_id, $year, $month): array
|
|
|
|
|
- {
|
|
|
|
|
- $this->service = app('OwnerLogisticFeeDetailService');
|
|
|
|
|
- $this->userService = app('UserService');
|
|
|
|
|
- $permittingOwnerIds = $this->userService->getPermittingOwnerIds(auth()->user());
|
|
|
|
|
- if (is_null($owner_id)) {
|
|
|
|
|
- $owner_id = $permittingOwnerIds[0];
|
|
|
|
|
- }
|
|
|
|
|
- if (is_null($year)) {
|
|
|
|
|
- $year = now()->subMonth()->year;
|
|
|
|
|
- }
|
|
|
|
|
- if (is_null($month)) {
|
|
|
|
|
- $month = now()->subMonth()->month;
|
|
|
|
|
- }
|
|
|
|
|
- $day = Carbon::parse($year . '-' . $month . '-01');
|
|
|
|
|
- return array($permittingOwnerIds, $owner_id, $day->startOfMonth()->toDateString(), $day->endOfMonth()->toDateString());
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * 确认账单
|
|
|
|
|
- * @param Request $request
|
|
|
|
|
- * @return RedirectResponse
|
|
|
|
|
- */
|
|
|
|
|
- public function confirmBill(Request $request)
|
|
|
|
|
- {
|
|
|
|
|
- $this->service = app('OwnerLogisticFeeDetailService');
|
|
|
|
|
- $this->archiveService = app('OwnerBillReportArchiveService');
|
|
|
|
|
- list($permittingOwnerIds, $owner_id, $start, $end) = $this->getRequestParams($request->owner_id, $request->year, $request->month);
|
|
|
|
|
- $billReport = OwnerBillReport::query()
|
|
|
|
|
- ->select('storage_fee', 'id')
|
|
|
|
|
- ->where('owner_id', $owner_id)
|
|
|
|
|
- ->where('counting_month', $start)
|
|
|
|
|
- ->firstOr(function () {
|
|
|
|
|
- return new OwnerBillReport();
|
|
|
|
|
- });
|
|
|
|
|
- OwnerBillReportArchive::query()->create([
|
|
|
|
|
- 'owner_bill_report_id' => $billReport->id ?? null,
|
|
|
|
|
- 'owner_id' => $owner_id,
|
|
|
|
|
- 'counting_month' => $start,
|
|
|
|
|
- 'type' => $this->service::TYPE,
|
|
|
|
|
- 'archiver_id' => auth()->id(),
|
|
|
|
|
- 'archived_at' => now(),
|
|
|
|
|
- 'information' => [],
|
|
|
|
|
- ]);
|
|
|
|
|
- return back()->with('success', '确认成功');
|
|
|
|
|
- }
|
|
|
|
|
}
|
|
}
|