ANG YU 4 лет назад
Родитель
Сommit
ebcdb3ac97
29 измененных файлов с 718 добавлено и 202 удалено
  1. 85 0
      app/Http/Controllers/OwnerBillTotalController.php
  2. 26 1
      app/Http/Controllers/SettlementBillLogisticFeeController.php
  3. 4 4
      app/Http/Controllers/SettlementBillStorageFeeController.php
  4. 26 9
      app/Http/Controllers/SettlementBillStoreFeeReportController.php
  5. 25 0
      app/Http/Controllers/TestController.php
  6. 52 0
      app/Jobs/SettlementBillCountingTask.php
  7. 30 0
      app/OwnerBillTotal.php
  8. 34 29
      app/OwnerStoreFeeDetail.php
  9. 28 28
      app/OwnerStoreFeeReport.php
  10. 2 0
      app/Providers/AppServiceProvider.php
  11. 121 0
      app/Services/OwnerBillTotalService.php
  12. 18 16
      app/Services/OwnerStoreFeeDetailService.php
  13. 27 27
      app/Services/OwnerStoreFeeReportService.php
  14. 8 2
      app/Services/OwnerWaybillSettlementBillService.php
  15. 5 11
      app/Services/SettlementBillsAreaFeeService.php
  16. 12 0
      database/factories/OwnerBillTotalFactory.php
  17. 10 7
      database/factories/OwnerStoragePriceModelFactory.php
  18. 2 3
      database/factories/OwnerStoreFeeDetailFactory.php
  19. 0 2
      database/factories/OwnerStoreFeeReportFactory.php
  20. 36 0
      database/migrations/2021_06_30_113024_create_owner_bill_totals_table.php
  21. 34 0
      database/migrations/2021_07_01_131043_add_owner_price_operation_id__owner_store_fee_details.php
  22. 32 0
      database/migrations/2021_07_01_131350_drop_column_type_owner_store_fee_reports.php
  23. 9 9
      database/seeds/OwnerAreaReportTableSeeder.php
  24. 1 1
      database/seeds/OwnerBillReportTableSeeder.php
  25. 16 0
      database/seeds/OwnerBillTotalSeeder.php
  26. 19 4
      database/seeds/OwnerStoreFeeDetailSeeder.php
  27. 37 17
      resources/views/finance/settlementBills/storageFee/index.blade.php
  28. 1 1
      resources/views/finance/settlementBills/storeFee/detail/index.blade.php
  29. 18 31
      resources/views/finance/settlementBills/storeFee/report/index.blade.php

+ 85 - 0
app/Http/Controllers/OwnerBillTotalController.php

@@ -0,0 +1,85 @@
+<?php
+
+namespace App\Http\Controllers;
+
+use App\OwnerBillTotal;
+use Illuminate\Http\Request;
+
+class OwnerBillTotalController extends Controller
+{
+    /**
+     * Display a listing of the resource.
+     *
+     * @return \Illuminate\Http\Response
+     */
+    public function index()
+    {
+        //
+    }
+
+    /**
+     * Show the form for creating a new resource.
+     *
+     * @return \Illuminate\Http\Response
+     */
+    public function create()
+    {
+        //
+    }
+
+    /**
+     * Store a newly created resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return \Illuminate\Http\Response
+     */
+    public function store(Request $request)
+    {
+        //
+    }
+
+    /**
+     * Display the specified resource.
+     *
+     * @param  \App\OwnerBillTotal  $ownerBillTotal
+     * @return \Illuminate\Http\Response
+     */
+    public function show(OwnerBillTotal $ownerBillTotal)
+    {
+        //
+    }
+
+    /**
+     * Show the form for editing the specified resource.
+     *
+     * @param  \App\OwnerBillTotal  $ownerBillTotal
+     * @return \Illuminate\Http\Response
+     */
+    public function edit(OwnerBillTotal $ownerBillTotal)
+    {
+        //
+    }
+
+    /**
+     * Update the specified resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @param  \App\OwnerBillTotal  $ownerBillTotal
+     * @return \Illuminate\Http\Response
+     */
+    public function update(Request $request, OwnerBillTotal $ownerBillTotal)
+    {
+        //
+    }
+
+    /**
+     * Remove the specified resource from storage.
+     *
+     * @param  \App\OwnerBillTotal  $ownerBillTotal
+     * @return \Illuminate\Http\Response
+     */
+    public function destroy(OwnerBillTotal $ownerBillTotal)
+    {
+        //
+    }
+}

+ 26 - 1
app/Http/Controllers/SettlementBillLogisticFeeController.php

@@ -2,11 +2,36 @@
 
 namespace App\Http\Controllers;
 
+use App\Interfaces\SettlementBillControllerInterface;
+use App\Services\OwnerBillReportArchiveService;
+use App\Services\OwnerWaybillSettlementBillService;
+use App\Traits\SettlementBillTrait;
 use Illuminate\Http\Request;
 
-class SettlementBillLogisticFeeController extends Controller implements \App\Interfaces\SettlementBillControllerInterface
+class SettlementBillLogisticFeeController extends Controller implements SettlementBillControllerInterface
 {
+    use SettlementBillTrait;
+
+    /**
+     * @var $service OwnerWaybillSettlementBillService
+     */
+    private $service;
+
+    /**
+     * @var $archiveService OwnerBillReportArchiveService
+     */
+    private $archiveService;
     //
+
+    /**
+     * SettlementBillLogisticFeeController constructor.
+     */
+    public function __construct()
+    {
+        $this->service = app('OwnerWaybillSettlementBillService');
+        $this->service = app('OwnerBillReportArchiveService');
+    }
+
     public function index(Request $request)
     {
         // TODO: Implement index() method.

+ 4 - 4
app/Http/Controllers/SettlementBillStorageFeeController.php

@@ -40,15 +40,15 @@ class SettlementBillStorageFeeController extends Controller implements \App\Inte
     {
         list($permittingOwnerIds, $counting_month, $owner_id) = $this->getRequestParams($request->year, $request->month, $request->owner_id);
         $isArchived = $this->archiveService->isArchived($counting_month, $owner_id, $this->service::TYPE);
-        list($areaReports, $billReport, $price) = $this->service->get([
+        list($areaReports, $billReport) = $this->service->get([
             'owner_id' => $owner_id,
             'counting_month' => $counting_month,
-            'type' =>$this->service::TYPE,
+            'type' => $this->service::TYPE,
         ]);
         $owners = Owner::query()->find($permittingOwnerIds);
         $owner = Owner::query()->find($owner_id);
         $request = $this->buildRequest($request, $counting_month);
-        return view('finance.settlementBills.storageFee.index', compact('owner', 'owners', 'areaReports', 'billReport', 'price', 'request', 'isArchived'));
+        return view('finance.settlementBills.storageFee.index', compact('owner', 'owners', 'areaReports', 'billReport', 'request', 'isArchived'));
     }
 
 
@@ -63,7 +63,7 @@ class SettlementBillStorageFeeController extends Controller implements \App\Inte
         list($areaReports, $billReport, $price) = $this->service->get([
             'owner_id' => $owner_id,
             'counting_month' => $counting_month,
-            'type' =>$this->service::TYPE,
+            'type' => $this->service::TYPE,
         ]);
         OwnerBillReportArchive::query()->create([
             'owner_bill_report_id' => $billReport->id ?? null,

+ 26 - 9
app/Http/Controllers/SettlementBillStoreFeeReportController.php

@@ -11,12 +11,12 @@ use App\Traits\SettlementBillTrait;
 use Illuminate\Http\RedirectResponse;
 use Illuminate\Http\Request;
 use Oursdreams\Export\Export;
+use Tightenco\Collect\Support\Collection;
 
 class SettlementBillStoreFeeReportController extends Controller
 {
     use SettlementBillTrait;
 
-    //TODO 缺少总计费用
     /* @var OwnerStoreFeeReportService $service */
     private $service;
 
@@ -29,11 +29,12 @@ class SettlementBillStoreFeeReportController extends Controller
         $this->service = app('OwnerStoreFeeReportService');
         $this->archiveService = app('OwnerBillReportArchiveService');
         list($permittingOwnerIds, $counting_month, $owner_id) = $this->service->getRequestParams($request->year, $request->month, $request->owner_id);
-        list($reports, $totalAmount, $totalFee, $newFee, $backFee) = $this->service->get([
+        list($reports, $totalAmount, $totalFee, $owner_price_operation_fees) = $this->service->get([
             'owner_id' => $owner_id,
             'counting_month' => $counting_month,
             'type' => $this->service::TYPE,
         ]);
+        $owner_price_operation_fees = $this->buildOwnerPriceOperationFees($reports, $owner_price_operation_fees);
         $owner = Owner::query()->selectRaw("name,id")->find($owner_id);
         $owners = Owner::query()->selectRaw("id,name")->whereIn('id', $permittingOwnerIds)->get();
         $this->archiveService = app('OwnerBillReportArchiveService');
@@ -42,7 +43,7 @@ class SettlementBillStoreFeeReportController extends Controller
         $request = $this->buildRequest($request, $counting_month);
 
         return view('finance.settlementBills.storeFee.report.index',
-            compact('reports', 'owners', 'owner', 'isArchived', 'request', 'reports', 'totalAmount', 'totalFee', 'newFee', 'backFee'));
+            compact('owners', 'owner', 'isArchived', 'request', 'reports', 'totalAmount', 'totalFee', 'owner_price_operation_fees'));
     }
 
     public function confirmBill(Request $request): RedirectResponse
@@ -57,7 +58,7 @@ class SettlementBillStoreFeeReportController extends Controller
             ->firstOr(function () {
                 return new OwnerBillReport();
             });
-        list($reports, $totalAmount, $totalFee, $newFee, $backFee) = $this->service->get([
+        list($reports, $totalAmount, $totalFee, $owner_price_operation_fees) = $this->service->get([
             'owner_id' => $owner_id,
             'counting_month' => $counting_month,
             'type' => $this->service::TYPE,
@@ -73,8 +74,7 @@ class SettlementBillStoreFeeReportController extends Controller
                 'reports' => $reports,
                 'totalAmount' => $totalAmount,
                 'totalFee' => $totalFee,
-                'newFee' => $newFee,
-                'backFee' => $backFee,
+                'owner_price_operation_fees' => $owner_price_operation_fees
             ],
         ]);
         return back()->with('success', '确认成功');
@@ -85,21 +85,38 @@ class SettlementBillStoreFeeReportController extends Controller
         $this->service = app('OwnerStoreFeeReportService');
         $this->archiveService = app('OwnerBillReportArchiveService');
         list($permittingOwnerIds, $counting_month, $owner_id) = $this->service->getRequestParams($request->year, $request->month, $request->owner_id);
-        list($reports, $totalAmount, $totalFee, $newFee, $backFee) = $this->service->get([
+        list($reports, $totalAmount, $totalFee, $owner_price_operation_fees) = $this->service->get([
             'owner_id' => $owner_id,
             'counting_month' => $counting_month,
             'type' => $this->service::TYPE,
         ]);
         $json = [];
         foreach ($reports as $report) {
+            $operation = $owner_price_operation_fees->firstWhere('owner_price_operation_id',$report['owner_price_operation_id']);
             $json[] = [
-                $report['type'],
+                $operation['owner_price_operation']['name']??$operation['ownerPriceOperation']['name'],
                 $report['unit_price'],
                 $report['amount'],
-                $report['type'] == '新品入库' ? $newFee : $backFee,
+                $operation['fee'],
             ];
         }
         $row = ['名称', '单价', '数量', '合计'];
         return Export::make($row, $json, "入库费合计");
     }
+
+    /**
+     * @param $reports
+     * @param $owner_price_operation_fees
+     * @return \Illuminate\Support\Collection|Collection
+     */
+    private function buildOwnerPriceOperationFees($reports, $owner_price_operation_fees)
+    {
+        $result = [];
+        $reports = $reports->groupBy('owner_price_operation_id');
+        foreach ($owner_price_operation_fees as $price_operation) {
+            $price_operation['data'] = $reports[$price_operation['owner_price_operation_id']];
+            $result[] = $price_operation;
+        }
+        return collect($result);
+    }
 }

+ 25 - 0
app/Http/Controllers/TestController.php

@@ -80,8 +80,10 @@ use App\Services\OrderPackageReceivedSyncService;
 use App\Services\OrderPackageService;
 use App\Services\OrderService;
 use App\Services\OrderTrackingService;
+use App\Services\OwnerBillTotalService;
 use App\Services\OwnerLogisticFeeDetailService;
 use App\Services\OwnerLogisticFeeReportService;
+use App\Services\OwnerStoreFeeReportService;
 use App\Services\RejectedBillService;
 use App\Services\StorageService;
 use App\Services\StoreItemService;
@@ -1731,4 +1733,27 @@ TEXT;
         $asnHerdersUpdated = $oracleDocAsnHerderService->getWmsAsnOnStartDateEdit($last_time);
         $storeItemService->storeItemUpdateByWms($asnHerdersUpdated);
     }
+
+    public function test_ang()
+    {
+        /**@var $service OwnerBillTotalService */
+        $service = app('OwnerBillTotalService');
+        $service->record();
+    }
+
+    public function test_store_record()
+    {
+        /**@var $service OwnerStoreFeeReportService */
+        $service = app('OwnerStoreFeeReportService');
+        list($reports, $totalAmount, $totalFee, $owner_price_operation_fees)=  $service->get([
+            'owner_id' => 8,
+            'counting_month' => '2021-06-01',
+            'type' => '出库费-合计',
+        ]);
+        $reports =  $reports->groupBy('owner_price_operation_id');
+        foreach ($owner_price_operation_fees as $price_operation) {
+            $price_operation->data = $reports[$price_operation->owner_price_operation_id];
+        }
+        return $owner_price_operation_fees;
+    }
 }

+ 52 - 0
app/Jobs/SettlementBillCountingTask.php

@@ -0,0 +1,52 @@
+<?php
+
+namespace App\Jobs;
+
+use Illuminate\Bus\Queueable;
+use Illuminate\Contracts\Queue\ShouldQueue;
+use Illuminate\Foundation\Bus\Dispatchable;
+use Illuminate\Queue\InteractsWithQueue;
+use Illuminate\Queue\SerializesModels;
+
+/**
+ * 生成结算账单统计数据
+ * 每月初始执行
+ * 统计上月的账单数据
+ * Class SettlementBillCountingTask
+ * @package App\Jobs
+ */
+class SettlementBillCountingTask implements ShouldQueue
+{
+    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
+
+    //货主
+    private $owner_id;
+    //统计月份
+    private $counting_month;
+
+    /**
+     * SettlementBillCountingTask constructor.
+     * @param $owner_id
+     * @param $counting_month
+     */
+    public function __construct($owner_id, $counting_month)
+    {
+        $this->owner_id = $owner_id;
+        $this->counting_month = $counting_month;
+    }
+
+
+    /**
+     * Execute the job.
+     *
+     * @return void
+     */
+    public function handle()
+    {
+        if (is_null($this->owner_id)&&is_null($this->counting_month)) {//未指定统计的参数
+        } else {
+            //清除历史统计记录
+
+        }
+    }
+}

+ 30 - 0
app/OwnerBillTotal.php

@@ -0,0 +1,30 @@
+<?php
+
+namespace App;
+
+use Carbon\Carbon;
+use Illuminate\Database\Eloquent\Model;
+
+use App\Traits\ModelLogChanging;
+use Illuminate\Database\Eloquent\Relations\BelongsTo;
+
+class OwnerBillTotal extends Model
+{
+    use ModelLogChanging;
+
+    public $fillable = ['owner_id', 'discount_fee', 'discount_remark', 'counting_month', 'information'];
+
+    public $casts = [
+        'information' => 'array',
+    ];
+
+    public function owner(): BelongsTo
+    {
+        return $this->belongsTo(Owner::class);
+    }
+
+    public function setCountingMonth($value): string
+    {
+        return Carbon::parse($value)->startOfMonth()->toDateString();
+    }
+}

+ 34 - 29
app/OwnerStoreFeeDetail.php

@@ -11,35 +11,35 @@ class OwnerStoreFeeDetail extends Model
 {
     use ModelLogChanging;
 
-    public $fillable = ['owner_fee_detail_id', 'type', 'unit_id', 'unit_price', 'amount', 'owner_id', 'store_item_id'];
-
-    static public $enums = [
-        'type' => [
-            '' => 0,
-            '退货入库' => 1,
-            '新品入库' => 2,
-        ],
-    ];
-
-    function __construct(array $attributes = [])
-    {
-        foreach (self::$enums as &$enum) {
-            $enum = $enum + array_flip($enum);
-        }
-        parent::__construct($attributes);
-    }
-
-    public function getTypeAttribute($value)
-    {
-        if (!$value) return '';
-        return self::$enums['type'][$value];
-    }
-
-    public function setTypeAttribute($value)
-    {
-        if (!$value) return 0;
-        $this->attributes['type'] = self::$enums['type'][$value];
-    }
+    public $fillable = ['owner_fee_detail_id', 'unit_id', 'unit_price', 'amount', 'owner_id', 'store_item_id','owner_price_operation_id'];
+
+//    static public $enums = [
+//        'type' => [
+//            '' => 0,
+//            '退货入库' => 1,
+//            '新品入库' => 2,
+//        ],
+//    ];
+//
+//    function __construct(array $attributes = [])
+//    {
+//        foreach (self::$enums as &$enum) {
+//            $enum = $enum + array_flip($enum);
+//        }
+//        parent::__construct($attributes);
+//    }
+//
+//    public function getTypeAttribute($value)
+//    {
+//        if (!$value) return '';
+//        return self::$enums['type'][$value];
+//    }
+//
+//    public function setTypeAttribute($value)
+//    {
+//        if (!$value) return 0;
+//        $this->attributes['type'] = self::$enums['type'][$value];
+//    }
 
 
     public function ownerFeeDetail(): BelongsTo
@@ -67,4 +67,9 @@ class OwnerStoreFeeDetail extends Model
     {
         return $this->belongsTo(StoreItem::class);
     }
+
+    public function ownerPriceOperation(): BelongsTo
+    {
+        return $this->belongsTo(OwnerPriceOperation::class);
+    }
 }

+ 28 - 28
app/OwnerStoreFeeReport.php

@@ -11,37 +11,37 @@ class OwnerStoreFeeReport extends Model
 {
     use ModelLogChanging;
 
-    public $fillable = ['owner_bill_report_id', 'owner_price_operation_id', 'owner_id', 'counting_month', 'unit_id', 'unit_price', 'amount', 'type', 'fee'];
+    public $fillable = ['owner_bill_report_id', 'owner_price_operation_id', 'owner_id', 'counting_month', 'unit_id', 'unit_price', 'amount', 'fee'];
 
     public $timestamps = false;
 
-    static public $enums = [
-        'type' => [
-            '' => 0,
-            '退货入库' => 1,
-            '新品入库' => 2,
-        ],
-    ];
-
-    function __construct(array $attributes = [])
-    {
-        foreach (self::$enums as &$enum) {
-            $enum = $enum + array_flip($enum);
-        }
-        parent::__construct($attributes);
-    }
-
-    public function getTypeAttribute($value)
-    {
-        if (!$value) return '';
-        return self::$enums['type'][$value];
-    }
-
-    public function setTypeAttribute($value)
-    {
-        if (!$value) return 0;
-        $this->attributes['type'] = self::$enums['type'][$value];
-    }
+//    static public $enums = [
+//        'type' => [
+//            '' => 0,
+//            '退货入库' => 1,
+//            '新品入库' => 2,
+//        ],
+//    ];
+//
+//    function __construct(array $attributes = [])
+//    {
+//        foreach (self::$enums as &$enum) {
+//            $enum = $enum + array_flip($enum);
+//        }
+//        parent::__construct($attributes);
+//    }
+//
+//    public function getTypeAttribute($value)
+//    {
+//        if (!$value) return '';
+//        return self::$enums['type'][$value];
+//    }
+//
+//    public function setTypeAttribute($value)
+//    {
+//        if (!$value) return 0;
+//        $this->attributes['type'] = self::$enums['type'][$value];
+//    }
 
 
     public function ownerBillReport(): BelongsTo

+ 2 - 0
app/Providers/AppServiceProvider.php

@@ -157,6 +157,7 @@ use App\Services\OwnerProcurementSettlementBillService;
 use App\Services\OwnerWaybillSettlementBillService;
 use App\Services\OwnerProcessSettlementBillService;
 use App\Services\OwnerDischargeTaskSettlementBillService;
+use App\Services\OwnerBillTotalService;
 
 class AppServiceProvider extends ServiceProvider
 {
@@ -295,6 +296,7 @@ class AppServiceProvider extends ServiceProvider
         app()->singleton('OwnerAreaReportService', OwnerAreaReportService::class);
         app()->singleton('OwnerBillReportArchiveService',OwnerBillReportArchiveService::class);
         app()->singleton('OwnerBillReportService', OwnerBillReportService::class);
+        app()->singleton('OwnerBillTotalService',OwnerBillTotalService::class);
         app()->singleton('OwnerDischargeTaskSettlementBillService',OwnerDischargeTaskSettlementBillService::class);
         app()->singleton('OwnerFeeDetailService', OwnerFeeDetailService::class);
         app()->singleton('OwnerLogisticFeeDetailService',OwnerLogisticFeeDetailService::class);

+ 121 - 0
app/Services/OwnerBillTotalService.php

@@ -0,0 +1,121 @@
+<?php
+
+namespace App\Services;
+
+use App\Traits\ServiceAppAop;
+use App\OwnerBillTotal;
+
+class OwnerBillTotalService
+{
+    use ServiceAppAop;
+
+    protected $modelClass = OwnerBillTotal::class;
+    const FEE_NAMES = [
+        '仓储费',
+        '入库费',
+        '出库费',
+        '配送费',
+        '库内加工',
+        '系统使用费',
+        '杂项费',
+        '理赔费',
+        '税费',
+    ];
+
+    /**
+     * 生成统计数据
+     * @param string|null $counting_month string 统计月份默认为上一个月
+     */
+    public function record(string $counting_month = null)
+    {
+        if (is_null($counting_month)) {
+            $counting_month = now()->subMonth()->startOfMonth()->toDateString();
+        }
+        /**
+         * 1. 查询需要统计的货主
+         * 2. 遍历货主
+         * 3. 计算单个货主的费用
+         * 4. 从相关表中获取总计信息,填入information
+         * 5. 保存单个货主的信息
+         */
+        //查询需要统计的货主
+        //没有删除的货主,货主删除时间晚于上个月1号的
+        $owners = \App\Owner::query()
+            ->where('deleted_at', '>=', now()->subMonth()->startOfMonth())
+            ->orWhereNull('deleted_at')->get();
+
+        foreach ($owners as $owner) {
+            $information = [];
+            //仓储费
+            $storageFee = $this->getStorageFeeForTotal($counting_month, $owner->id);
+            //入库费
+            $storeFee = $this->getStoreFeeForTotal($counting_month, $owner->id);
+
+            $information[] = [
+                'storageFee' => $storageFee,
+            ];
+            dd($information);
+        }
+
+    }
+
+    /**
+     * 重新统计
+     * @param $owner_id
+     * @param $counting_month
+     */
+    public function restartRecord($owner_id, $counting_month)
+    {
+        OwnerBillTotal::query()
+            ->where('owner_id', $owner_id)
+            ->where('counting_month', $counting_month)
+            ->updateOrInsert();
+    }
+
+
+    public function getRecord(): array
+    {
+        $result = [];
+
+        return $result;
+    }
+
+    /**
+     * 仓储费
+     * @param string|null $counting_month
+     * @param $owner_id
+     * @return array
+     */
+    private function getStorageFeeForTotal(?string $counting_month, $owner_id): array
+    {
+        /** @var  $service  SettlementBillsAreaFeeService */
+        $service = app('SettlementBillsAreaFeeService');
+        list($areaReports, $billReport) = $service->get([
+            'counting_month' => $counting_month,
+            'owner_id' => $owner_id,
+            'type' => $service::TYPE,
+        ]);
+        $storageFee = [
+            'data' => [],
+            'fee' => $billReport->storage_fee,
+        ];
+        foreach ($areaReports as $areaReport) {
+            //起租面积:1.2元/m^3/天
+            $remark = '起租面积:'
+                . $areaReport->ownerStoragePriceModel->minimum_area . ','
+                . $areaReport->ownerStoragePriceModel->price . '/'
+                . $areaReport->ownerStoragePriceModel->unit->name .
+                '/' . $areaReport->ownerStoragePriceModel->timeUnit->name;
+            $storageFee['data'][] = [
+                'name' => $areaReport->ownerStoragePriceModel->name,
+                'remark' => $remark,
+            ];
+        }
+        return $storageFee;
+    }
+
+    private function getStoreFeeForTotal(?string $counting_month, $id)
+    {
+//        $service = app('')
+    }
+}

+ 18 - 16
app/Services/OwnerStoreFeeDetailService.php

@@ -17,25 +17,25 @@ class OwnerStoreFeeDetailService
 
     protected $modelClass = OwnerStoreFeeDetail::class;
 
-    public function get(array $kvPairs)
+    public function get(array $kvPairs): \Illuminate\Contracts\Pagination\LengthAwarePaginator
     {
         return $this->getSql($kvPairs['counting_month'], $kvPairs['owner_id'])->paginate($kvPairs['paginateParams']['paginate'] ?? 50);
 
     }
 
 
-    /**
-     * @param $type
-     * @return int|mixed
-     */
-    public function switchType($type)
-    {
-        //枚举转换
-        if (is_string($type)) {
-            $type = OwnerStoreFeeDetail::$enums['type'][$type];
-        }
-        return $type;
-    }
+//    /**
+//     * @param $type
+//     * @return int|mixed
+//     */
+//    public function switchType($type)
+//    {
+//        //枚举转换
+//        if (is_string($type)) {
+//            $type = OwnerStoreFeeDetail::$enums['type'][$type];
+//        }
+//        return $type;
+//    }
 
     /**
      * @param $counting_month
@@ -46,9 +46,11 @@ class OwnerStoreFeeDetailService
     {
         list($start, $end) = $this->getStartAndEnd($counting_month);
         return OwnerStoreFeeDetail::query()
-            ->with(['ownerFeeDetail:id,work_fee,worked_at', 'storeItem' => function ($query) {
-                $query->selectRaw("id,asn_line_code,sku,commodity_id")->with('commodity:id,name');
-            },])
+            ->with([
+                'ownerFeeDetail:id,work_fee,worked_at',
+                'storeItem' => function ($query) {$query->selectRaw("id,asn_line_code,sku,commodity_id")->with('commodity:id,name');},
+                'ownerPriceOperation:id,name'
+                ])
             ->whereBetween('created_at', [$start, $end])
             ->where('owner_id', $owner_id);
     }

+ 27 - 27
app/Services/OwnerStoreFeeReportService.php

@@ -3,6 +3,7 @@
 namespace App\Services;
 
 use App\OwnerBillReport;
+use App\OwnerStoreFeeDetail;
 use App\Traits\ServiceAppAop;
 use App\OwnerStoreFeeReport;
 use App\Traits\SettlementBillTrait;
@@ -47,11 +48,15 @@ class OwnerStoreFeeReportService
             DB::table('owner_store_fee_details')
                 ->leftJoin('owner_fee_details', 'owner_fee_detail_id', '=', 'owner_fee_details.id')
                 ->selectRaw("DATE_FORMAT(owner_store_fee_details.created_at,'%Y-%m') as counting_month,
-                owner_store_fee_details.type,unit_id,unit_price,sum(amount) as amounts ,
-                owner_store_fee_details.owner_id,owner_fee_detail_id,
-                sum(owner_fee_details.work_fee) as work_fee")
+                unit_id,
+                unit_price,
+                sum(amount) as amounts ,
+                owner_store_fee_details.owner_id,
+                owner_fee_detail_id,
+                sum(owner_fee_details.work_fee) as work_fee,
+                owner_store_fee_details.owner_price_operation_id")
                 ->whereBetween('owner_store_fee_details.created_at', [$start, $end])
-                ->groupBy('counting_month', 'owner_store_fee_details.owner_id', 'owner_store_fee_details.type', 'unit_id', 'unit_price')
+                ->groupBy('counting_month', 'owner_store_fee_details.owner_id', 'owner_store_fee_details.owner_price_operation_id', 'unit_id', 'unit_price')
                 ->get();
         $reports = [];
         foreach ($details as $detail) {
@@ -62,17 +67,19 @@ class OwnerStoreFeeReportService
                 ->where('counting_month', $counting_month)->first();
             $reports[] = [
                 'owner_bill_report_id' => $ownerBillReport->id ?? null,
-                'owner_price_operation_id' => null,//$detail->ownerFeeDetail->ownerPriceOperation->id??null,
+                'owner_price_operation_id' => $detail->owner_price_operation_id,
                 'owner_id' => $detail->owner_id,
                 'counting_month' => $counting_month,
                 'unit_id' => $detail->unit_id,
                 'unit_price' => $detail->unit_price,
                 'amount' => $detail->amounts,
-                'type' => $this->detailService->switchType($detail->type),
                 'fee' => $detail->work_fee,
             ];
         }
-        OwnerStoreFeeReport::query()->insertOrIgnore($reports);
+        $reports_chunked =  array_chunk($reports,1000 );
+        foreach ($reports_chunked as $items) {
+            OwnerStoreFeeReport::query()->insertOrIgnore($items);
+        }
     }
 
     public function get(array $kvPairs): array
@@ -85,27 +92,20 @@ class OwnerStoreFeeReportService
             $reports = collect($archived->information['reports']);
             $totalAmount = $archived->information['totalAmount'];
             $totalFee = $archived->information['totalFee'];
-            $newFee = $archived->information['newFee'];
-            $backFee = $archived->information['backFee'];
+            $owner_price_operation_fees = collect($archived->information['owner_price_operation_fees']);
         } else {
-            $reports = $this->getReports($kvPairs['owner_id'], $kvPairs['counting_month']);
-            $totalAmount = $this->getSql($kvPairs['owner_id'], $kvPairs['counting_month'])->sum('amount');
-            $totalFee = $this->getSql($kvPairs['owner_id'], $kvPairs['counting_month'])->sum('fee');
-            $newFee = $this->getSql($kvPairs['owner_id'], $kvPairs['counting_month'])->where('type', $this->detailService->switchType('新品入库'))->sum('fee');
-            $backFee = $this->getSql($kvPairs['owner_id'], $kvPairs['counting_month'])->where('type', $this->detailService->switchType('退货入库'))->sum('fee');
-        }
-        return array($reports, $totalAmount, $totalFee, $newFee, $backFee);
-    }
-
-    public function getPaginate($owner_id, $counting_month, $paginateParams): LengthAwarePaginator
-    {
-        return $this->getSql($owner_id, $counting_month)
-            ->paginate($paginateParams['paginate'] ?? 50);
-    }
+            $reports = $this->getSql($kvPairs['owner_id'], $kvPairs['counting_month'])->orderByDesc('owner_price_operation_id')->get();
+            $totalAmount = $reports->sum('amount');
+            $totalFee = number_format($reports->sum('fee'),2);
 
-    public function getReports($owner_id, $counting_month)
-    {
-        return $this->getSql($owner_id, $counting_month)->orderByDesc('type')->get();
+            $owner_price_operation_fees =   OwnerStoreFeeReport::query()
+                ->with('ownerPriceOperation:id,name')
+                ->selectRaw("sum(fee) as fee,owner_price_operation_id")
+                ->where('owner_id', $kvPairs['owner_id'])
+                ->where('counting_month', $kvPairs['counting_month'])
+                ->groupBy('owner_price_operation_id')->get();
+        }
+        return array($reports, $totalAmount, $totalFee,$owner_price_operation_fees);
     }
 
     /**
@@ -116,7 +116,7 @@ class OwnerStoreFeeReportService
     public function getSql($owner_id, $counting_month): Builder
     {
         return OwnerStoreFeeReport::query()
-            ->with('unit:id,name')
+            ->with(['unit:id,name'])
             ->where('owner_id', $owner_id)
             ->where('counting_month', $counting_month);
     }

+ 8 - 2
app/Services/OwnerWaybillSettlementBillService.php

@@ -10,12 +10,18 @@ class OwnerWaybillSettlementBillService implements \App\Interfaces\SettlementBil
     use \App\Traits\SettlementBillServiceTrait;
 
 
+    public function get(array $kvPairs)
+    {
+
+    }
+
+
     public function getSql($owner_id, $counting_month): \Illuminate\Database\Eloquent\Builder
     {
         list($start, $end) = $this->getStartAndEnd($counting_month);
         \App\Waybill::query()
-            ->select('id','created_at','wms_bill_number','recipient','recipient_mobile','warehouse_weight','warehouse_weight_unit_id','destination_city_id')
-            ->with(['logistic:id,name','warehouseWeightUnit:id,name','destinationCity.parent'])
+            ->select('id', 'created_at', 'wms_bill_number', 'recipient', 'recipient_mobile', 'warehouse_weight', 'warehouse_weight_unit_id', 'destination_city_id')
+            ->with(['logistic:id,name', 'warehouseWeightUnit:id,name', 'destinationCity.parent'])
             ->where('owner_id', $owner_id)
             ->whereBetween('created_at', [$start, $end]);
     }

+ 5 - 11
app/Services/SettlementBillsAreaFeeService.php

@@ -28,10 +28,12 @@ class SettlementBillsAreaFeeService implements \App\Interfaces\SettlementBillDet
             $archived = $this->archiveService->get($kvPairs);
             $areaReports = collect($archived->information['areaReports']);
             $billReport = collect($archived->information['billReport']);
-            $price = $archived->information['price'];
         } else {
             $areaReports = OwnerAreaReport::query()
-                ->with('ownerStoragePriceModel:id,using_type,price')
+                ->with(['ownerStoragePriceModel'=>function ($query){
+                    $query->selectRaw("id,using_type,price,unit_id,unit_id,time_unit_id,name,minimum_area")
+                        ->with(['unit:id,name', 'timeUnit:id,name']);
+                }])
                 ->where('owner_id', $owner_id)
                 ->where('counting_month', $counting_month)
                 ->get();
@@ -42,16 +44,8 @@ class SettlementBillsAreaFeeService implements \App\Interfaces\SettlementBillDet
                 ->firstOr(function () {
                     return new OwnerBillReport();
                 });
-            $totalArea = $areaReports->reduce(function ($carry, $areaReport) {
-                return $carry + $areaReport->accounting_area;
-            }, 0);
-            try {
-                $price = number_format(($billReport->storage_fee ?? 0) / $totalArea, 3);
-            } catch (\Exception $e) {
-                $price = 0;
-            }
         }
-        return array($areaReports, $billReport, $price);
+        return array($areaReports, $billReport);
     }
 
     public function getSql($owner_id, $counting_month): \Illuminate\Database\Eloquent\Builder

+ 12 - 0
database/factories/OwnerBillTotalFactory.php

@@ -0,0 +1,12 @@
+<?php
+
+/** @var \Illuminate\Database\Eloquent\Factory $factory */
+
+use App\OwnerBillTotal;
+use Faker\Generator as Faker;
+
+$factory->define(OwnerBillTotal::class, function (Faker $faker) {
+    return [
+        //
+    ];
+});

+ 10 - 7
database/factories/OwnerStoragePriceModelFactory.php

@@ -5,17 +5,20 @@
 use App\OwnerStoragePriceModel;
 use Faker\Generator as Faker;
 
-$factory->define(OwnerStoragePriceModel::class, function (Faker $faker){
-    $counting_type = ['包仓','灵活用仓','统单价'];
-    $using_type = ['常温','恒温'];
-    $discount_type = ['无减免','按单减免','固定减免'];
+$factory->define(OwnerStoragePriceModel::class, function (Faker $faker) {
+    $counting_type = ['包仓', '灵活用仓', '统单价'];
+    $using_type = ['常温', '恒温'];
+    $discount_type = ['无减免', '按单减免', '固定减免'];
     return [
         "counting_type" => $counting_type[array_rand($counting_type)],    //计费类型
         "using_type" => $using_type[array_rand($using_type)],       //用仓类型
-        "minimum_area" => mt_rand(100,1000) / 50,     //最低起租面积
-        "price" => mt_rand(1,20) / 10,            //单价
+        "minimum_area" => mt_rand(100, 1000) / 50,     //最低起租面积
+        "price" => mt_rand(1, 20) / 10,            //单价
         "discount_type" => $discount_type[array_rand($discount_type)],    //减免类型
-        "discount_value" => mt_rand(0,10) / 12,   //减免值
+        "discount_value" => mt_rand(0, 10) / 12,   //减免值
 //        "unit_id" => factory(\App\Unit::class) ,          //单位ID
+        'unit_id' => random_int(1, 7),
+        'time_unit_id' => random_int(8, 11),
+        'name' => $faker->title,
     ];
 });

+ 2 - 3
database/factories/OwnerStoreFeeDetailFactory.php

@@ -6,12 +6,11 @@ use App\OwnerStoreFeeDetail;
 use Faker\Generator as Faker;
 
 $factory->define(OwnerStoreFeeDetail::class, function (Faker $faker) {
-    //['owner_fee_detail_id', 'type', 'unit_id', 'unit_price', 'amount', 'owner_id', 'store_item_id']type
-    $type = ['退货入库', '新品入库'];
+    //['owner_fee_detail_id', 'unit_id', 'unit_price', 'amount', 'owner_id', 'store_item_id','owner_price_operation_id']
     return [
         //
         'owner_fee_detail_id' => random_int(1,100),
-        'type' => $faker->randomElement($type),
+        'owner_price_operation_id' => random_int(1, 100),
         'unit_id' => random_int(1, 11),
         'unit_price' => mt_rand(10, 100),
         'amount' => mt_rand(10, 100),

+ 0 - 2
database/factories/OwnerStoreFeeReportFactory.php

@@ -6,7 +6,6 @@ use App\OwnerStoreFeeReport;
 use Faker\Generator as Faker;
 
 $factory->define(OwnerStoreFeeReport::class, function (Faker $faker) {
-    $type = ['退货入库', '新品入库'];
     return [
         'owner_bill_report_id' => random_int(1, 100),
         'owner_price_operation_id' => random_int(1, 100),
@@ -15,7 +14,6 @@ $factory->define(OwnerStoreFeeReport::class, function (Faker $faker) {
         'unit_id'=>random_int(1, 10),
         'unit_price'=>random_int(1, 100),
         'amount'=>random_int(1, 100),
-        'type' => $faker->randomElement($type),
         'fee'=>random_int(1, 100),
     ];
 });

+ 36 - 0
database/migrations/2021_06_30_113024_create_owner_bill_totals_table.php

@@ -0,0 +1,36 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class CreateOwnerBillTotalsTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('owner_bill_totals', function (Blueprint $table) {
+            $table->id();
+            $table->integer('owner_id')->comment('货主');
+            $table->decimal('discount_fee')->comment('优惠金额');
+            $table->string('discount_remark')->comment('优惠说明');
+            $table->date('counting_month')->comment('统计月份');
+            $table->longText('information')->comment('统计信息');
+            $table->timestamps();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('owner_bill_totals');
+    }
+}

+ 34 - 0
database/migrations/2021_07_01_131043_add_owner_price_operation_id__owner_store_fee_details.php

@@ -0,0 +1,34 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class AddOwnerPriceOperationIdOwnerStoreFeeDetails extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('owner_store_fee_details', function (Blueprint $table) {
+            $table->dropColumn('type');
+            $table->integer('owner_price_operation_id')->comment('计费模型');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('owner_store_fee_details', function (Blueprint $table) {
+            $table->integer('type')->comment('类型');
+            $table->dropColumn('owner_price_operation_id');
+        });
+    }
+}

+ 32 - 0
database/migrations/2021_07_01_131350_drop_column_type_owner_store_fee_reports.php

@@ -0,0 +1,32 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class DropColumnTypeOwnerStoreFeeReports extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('owner_store_fee_reports', function (Blueprint $table) {
+            $table->dropColumn('type');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('owner_store_fee_reports', function (Blueprint $table) {
+            $table->integer('type')->comment('类型');
+        });
+    }
+}

+ 9 - 9
database/seeds/OwnerAreaReportTableSeeder.php

@@ -18,15 +18,15 @@ class OwnerAreaReportTableSeeder extends Seeder
         OwnerStoragePriceModel::query()->truncate();
         $owners = \App\Owner::query()->get();
         foreach ($owners as $owner) {
-            $priceModel = factory(OwnerStoragePriceModel::class)->create();
-            factory(OwnerAreaReport::class)->create([
-                'user_owner_group_id' => random_int(1, 100),
-                'owner_id' => $owner->id,
-                'counting_month' => now()->subMonth()->startOfMonth()->toDateString(),
-                'owner_storage_price_model_id' => $priceModel->id
-            ]);
-
-
+            $priceModels = factory(OwnerStoragePriceModel::class)->times(2)->create();
+            foreach ($priceModels as $priceModel) {
+                factory(OwnerAreaReport::class)->create([
+                    'user_owner_group_id' => random_int(1, 100),
+                    'owner_id' => $owner->id,
+                    'counting_month' => now()->subMonth()->startOfMonth()->toDateString(),
+                    'owner_storage_price_model_id' => $priceModel->id
+                ]);
+            }
         }
     }
 }

+ 1 - 1
database/seeds/OwnerBillReportTableSeeder.php

@@ -17,7 +17,7 @@ class OwnerBillReportTableSeeder extends Seeder
         foreach ($owners as $owner) {
             factory(OwnerBillReport::class)->create([
                 'owner_id' => $owner->id,
-                'counting_month' =>'2021-05-01'
+                'counting_month' => now()->subMonth()->startOfMonth()->toDateString(),
             ]);
         }
     }

+ 16 - 0
database/seeds/OwnerBillTotalSeeder.php

@@ -0,0 +1,16 @@
+<?php
+
+use Illuminate\Database\Seeder;
+
+class OwnerBillTotalSeeder extends Seeder
+{
+    /**
+     * Run the database seeds.
+     *
+     * @return void
+     */
+    public function run()
+    {
+        //
+    }
+}

+ 19 - 4
database/seeds/OwnerStoreFeeDetailSeeder.php

@@ -2,6 +2,7 @@
 
 use App\Commodity;
 use App\OwnerFeeDetail;
+use App\OwnerPriceOperation;
 use App\OwnerStoreFeeDetail;
 use App\StoreItem;
 use Illuminate\Database\Seeder;
@@ -19,10 +20,24 @@ class OwnerStoreFeeDetailSeeder extends Seeder
         OwnerStoreFeeDetail::query()->truncate();
         StoreItem::query()->truncate();
         Commodity::query()->truncate();
+        OwnerPriceOperation::query()->truncate();
+        $owners = \App\Owner::query()->limit(10)->get();
+        foreach ($owners as $owner) {
+            $ownerPriceOperations = factory(\App\OwnerPriceOperation::class)->times(2)->create(['operation_type' => '出库']);
+            foreach ($ownerPriceOperations as $operation) {
+                $feeDetails = factory(OwnerFeeDetail::class)->times(100)->create(['owner_id' => $owner->id]);
+                foreach ($feeDetails as $feeDetail) {
+                    factory(OwnerStoreFeeDetail::class)->create([
+                        'owner_price_operation_id' => $operation->id,
+                        'owner_id' => $owner->id,
+                        'owner_fee_detail_id' => $feeDetail->id,
+                    ]);
+                }
+            }
+            factory(StoreItem::class)->times(100)->create();
+            factory(Commodity::class)->times(100)->create(['owner_id' => $owner->id]);
+        }
+
 
-        factory(OwnerStoreFeeDetail::class)->times(100)->create();
-        factory(OwnerFeeDetail::class)->times(100)->create(['owner_id'=>8]);
-        factory(StoreItem::class)->times(100)->create();
-        factory(Commodity::class)->times(100)->create(['owner_id'=>8]);
     }
 }

+ 37 - 17
resources/views/finance/settlementBills/storageFee/index.blade.php

@@ -48,7 +48,7 @@
                 </div>
             </div>
             <table class="table table-striped table-sm text-nowrap table-hover table-bordered" id="table">
-                <tr>
+            <tr>
                     <th>仓库类型</th>
                     <th>使用区域</th>
                     <th>数量</th>
@@ -57,23 +57,24 @@
                     <th>金额</th>
                 </tr>
                 <tr v-for="(areaReport,i) in areaReports">
-                    <td rowspan="3" class="text-center pt-4 bg-light">@{{
-                        areaReport.owner_storage_price_model.using_type }}
+                    <td class="text-center pt-4 bg-light">@{{ areaReport.owner_storage_price_model.using_type }}</td>
+                    <td class="m-0 p-0">
+                        <table class="table table-striped table-sm m-0 p-0">
+                            <tr><td>平面区</td></tr>
+                            <tr><td>整托存储</td></tr>
+                            <tr><td>半托存储</td></tr>
+                        </table>
                     </td>
-                    <td>平面区</td>
-                    <td>@{{ areaReport.area_on_flat?areaReport.area_on_flat:0 }}</td>
-                    <td rowspan="3" class="text-center pt-4 bg-light">@{{ areaReport.accounting_area }}</td>
-                    <td :rowspan="areaReports.length*3" class="text-center pt-4 bg-light">@{{ price }}</td>
-                    <td :rowspan="areaReports.length*3" class="text-center pt-4 bg-light">@{{ billReport.storage_fee }}
+                    <td class="m-0 p-0">
+                        <table class="table table-striped table-sm m-0">
+                            <tr><td>@{{ areaReport.area_on_flat?areaReport.area_on_flat:0 }}</td></tr>
+                            <tr><td>@{{ areaReport.area_on_tray?areaReport.area_on_tray:0 }}</td></tr>
+                            <tr><td>@{{ areaReport.area_on_half_tray?areaReport.area_on_half_tray:0 }}</td></tr>
+                        </table>
                     </td>
-                </tr>
-                <tr v-for="(areaReport,i) in areaReports">
-                    <td>整托存储</td>
-                    <td>@{{ areaReport.area_on_tray?areaReport.area_on_tray:0 }}</td>
-                </tr>
-                <tr v-for="(areaReport,i) in areaReports">
-                    <td>半托存储</td>
-                    <td>@{{ areaReport.area_on_half_tray?areaReport.area_on_half_tray:0 }}</td>
+                    <td>@{{ areaReport.accounting_area }}</td>
+                    <td>@{{ areaReport.owner_storage_price_model.price }}</td>
+                    <td class="text-center pt-4 bg-light" v-if="i===0" :rowspan="areaReports.length">@{{ billReport.storage_fee }}</td>
                 </tr>
             </table>
         </div>
@@ -91,7 +92,6 @@
                 billReport: {!! $billReport !!},
                 owners: [@foreach($owners as $owner){name: '{{ $owner->id }}', value: '{{ $owner->name}}'},@endforeach],
                 owner: {!! $owner !!},
-                price: {!! $price !!},
                 isArchived: {!! $isArchived !!},
                 request: {!! $request !!},
                 selectTr: 0,
@@ -164,6 +164,26 @@
                     appendDom: "btn",
                 });
                 _this.form.init();
+
+                let column = [
+                    {name: 'index', value: '序号', neglect: true},
+                    {name: 'worked_at', value: '作业时间'},
+                    {name: 'work_type', value: '作业名称'},
+                    {name: 'asn_number', value: '入库单号'},
+                    {name: 'sku', value: '商品条码'},
+                    {name: 'commodity_name', value: '商品名称'},
+                    {name: 'amount', value: '数量'},
+                    {name: 'price', value: '单价'},
+                    {name: 'work_fee', value: '入库费'},
+                ];
+                new Header({
+                    el: "table",
+                    name: "detail",
+                    column: column,
+                    data: this.details,
+                    restorationColumn: 'addtime',
+                    fixedTop: ($('#form_div').height()) + ($('#btn').height()) + 1,
+                }).init();
             },
             methods: {
                 areaFeeExport(sign) {

+ 1 - 1
resources/views/finance/settlementBills/storeFee/detail/index.blade.php

@@ -62,7 +62,7 @@
                     <td><input class="checkItem" type="checkbox" :value="detail.id"></td>
                     <td>@{{ i+1 }}</td>
                     <td>@{{ detail.owner_fee_detail.worked_at }}</td>
-                    <td>@{{ detail.type }}</td>
+                    <td>@{{ detail.owner_price_operation.name }}</td>
                     <td>@{{ detail.store_item.asn_line_code }}</td>
                     <td>@{{ detail.store_item.sku }}</td>
                     <td>@{{ detail.store_item.commodity.name }}</td>

+ 18 - 31
resources/views/finance/settlementBills/storeFee/report/index.blade.php

@@ -80,23 +80,24 @@
                     <th>数量</th>
                     <th>合计</th>
                 </tr>
-                <tr v-for="(report,i) in reports"
-                    @click="selectTr===i+1?selectTr=0:selectTr=i+1"
-                    :class="selectTr===i+1?'focusing' : ''">
-                    <td
-                        v-for="type in types"
-                        class="text-center pt-4 bg-light"
-                        v-if="(i==0 || report.type!== reports[i-1].type)&&report.type===type"
-                        :rowspan="calRowspan(type)">@{{ report.type }}
+                <tr v-for="(report,i) in reports">
+                    <td class="text-center pt-4 bg-light">@{{ report.owner_price_operation.name }}</td>
+                    <td class="m-0 p-0">
+                        <table class="table table-striped table-sm m-0 p-0">
+                            <tr v-for="item in report.data">
+                                <td>@{{ item.unit_price }}/@{{ item.unit.name }}</td>
+                            </tr>
+                        </table>
+
+                    </td>
+                    <td class="m-0 p-0">
+                        <table class="table table-striped table-sm m-0 p-0">
+                            <tr v-for="item in report.data">
+                                <td>@{{ item.amount }}</td>
+                            </tr>
+                        </table>
                     </td>
-                    <td>@{{ report.unit_price }}(元/@{{ report.unit.name }})</td>
-                    <td>@{{ report.amount }}</td>
-                    <td class="text-center pt-4 bg-light"
-                        v-if="(i==0 || report.type!== reports[i-1].type)&&report.type==='新品入库'"
-                        :rowspan="calRowspan('新品入库')">{{ $newFee }}</td>
-                    <td class="text-center pt-4 bg-light"
-                        v-if="(i==0 || report.type!== reports[i-1].type)&&report.type==='退货入库'"
-                        :rowspan="calRowspan('退货入库')">{{ $backFee }}</td>
+                    <td class="text-center pt-4 bg-light">@{{ report.fee }}</td>
                 </tr>
             </table>
         </div>
@@ -111,24 +112,15 @@
             el: "#list",
             data: {
                 owner: {!! $owner !!},
-                reports: {!! $reports !!},
                 owners: [@foreach($owners as $owner){name: '{{ $owner->id }}', value: '{{ $owner->name}}'},@endforeach],
                 isArchived: {!! $isArchived !!},
                 request: {!! $request !!},
-                selectTr: 0,
-                types: null
+                reports: {!! $owner_price_operation_fees !!},
             },
             created() {
             },
             mounted() {
                 $('#list').removeClass('d-none');
-
-                let map = [];
-                this.reports.forEach(function (item) {
-                    if (!map[item.type]) map[item.type] = 0
-                    map[item.type]++;
-                })
-
                 let _this = this;
                 $(".up").slideUp();
                 let data = [
@@ -193,13 +185,8 @@
                     appendDom: 'btn'
                 });
                 _this.form.init();
-
-                this.types = Array.from(new Set(this.reports.map(obj => obj.type)));
             },
             methods: {
-                isShowColumn(preType, type, targetType, i) {
-                    return (i === 0 || type !== preType) && type === targetType
-                },
                 calRowspan(type) {
                     return this.reports.filter(item => item.type === type).length;
                 },