ANG YU 4 лет назад
Родитель
Сommit
e80ff45ce8

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

@@ -28,6 +28,7 @@ use App\Jobs\LogisticYTOSync;
 use App\Jobs\OrderCreateInstantBill;
 use App\Jobs\OrderFreeze;
 use App\Jobs\ProcurementCheckConfirmInform;
+use App\Jobs\SettlementBillReportTask;
 use App\Jobs\StoreCreateInstantBill;
 use App\Jobs\ResetInstantBill;
 use App\LaborReport;
@@ -1392,4 +1393,9 @@ TEXT;
         ];
         event(new SettlementBillCreateEvent($data, SettlementBillCreateEvent::OWNER_LOGISTIC_FEE_DETAIL));
     }
+
+    public function test_settlement_bill_report_task()
+    {
+        SettlementBillReportTask::dispatchNow();
+    }
 }

+ 66 - 0
app/Jobs/SettlementBillReportTask.php

@@ -0,0 +1,66 @@
+<?php
+
+namespace App\Jobs;
+
+use App\Services\OwnerFeeTotalService;
+use App\Services\OwnerLogisticFeeReportService;
+use App\Services\OwnerStoreFeeReportService;
+use App\Services\OwnerStoreOutFeeReportService;
+use Illuminate\Bus\Queueable;
+use Illuminate\Contracts\Queue\ShouldQueue;
+use Illuminate\Foundation\Bus\Dispatchable;
+use Illuminate\Queue\InteractsWithQueue;
+use Illuminate\Queue\SerializesModels;
+
+/**
+ * 快递 出库 入库 统计报表生成任务
+ * Class SettlementBillReportTask
+ * @package App\Jobs
+ */
+class SettlementBillReportTask implements ShouldQueue
+{
+    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
+
+    public $timeout = 120;
+
+    public $maxExceptions = 3;
+
+    public $tries = 2;
+    /**
+     * Create a new job instance.
+     *
+     * @return void
+     */
+    public function __construct()
+    {
+        //
+    }
+
+    /**
+     * Execute the job.
+     *
+     * @return void
+     */
+    public function handle()
+    {
+        //快递
+        /** @var OwnerLogisticFeeReportService $expressFeeReportService */
+        $expressFeeReportService = app('OwnerLogisticFeeReportService');
+        $expressFeeReportService->recordReport();
+
+        //入库
+        /** @var OwnerStoreFeeReportService $storeFeeReportService */
+        $storeFeeReportService = app('OwnerStoreFeeReportService');
+        $storeFeeReportService->recordReport();
+
+        //出库
+        /** @var OwnerStoreOutFeeReportService $storeOutFeeReportService */
+        $storeOutFeeReportService = app('OwnerStoreOutFeeReportService');
+        $storeOutFeeReportService->recordReport();
+
+        //总账单
+        /** @var OwnerFeeTotalService $feeTotal */
+        $feeTotal = app('OwnerFeeTotalService');
+        $feeTotal->record();
+    }
+}

+ 2 - 1
app/OwnerLogisticFeeDetail.php

@@ -22,7 +22,8 @@ class OwnerLogisticFeeDetail extends Model
         'logistic_id',//承运商
         'owner_id',//货主
         'additional_weigh_weight',//续重重量
-        'tax_fee'//税费
+        'tax_fee',//税费
+        'fee'//费用
     ];
 
     public function ownerFeeDetail(): BelongsTo

+ 1 - 1
app/OwnerStoreOutFeeReport.php

@@ -11,7 +11,7 @@ class OwnerStoreOutFeeReport extends Model
 {
     use ModelLogChanging;
 
-    public $fillable = ['owner_bill_report_id', 'owner_price_operation_id', 'counting_month', 'step', 'unit_id', 'unit_price', 'amount', 'fee', 'owner_id'];
+    public $fillable = ['owner_bill_report_id', 'owner_price_operation_id', 'counting_month', 'step', 'unit_id', 'unit_price', 'amount', 'owner_id'];
 
     public $timestamps = false;
 

+ 3 - 0
app/Services/OwnerFeeTotalService.php

@@ -139,6 +139,7 @@ class OwnerFeeTotalService
      */
     private function buildInformation($owner, $counting_month): array
     {
+        //获取特征信息
         $features = app("FeatureService")->getMapArray();
         OwnerPriceOperation::$features = $features;
         OwnerPriceOperationItem::$features = $features;
@@ -150,6 +151,7 @@ class OwnerFeeTotalService
                 if ($item["strategy"] == "起步") $item["type"] = $item["amount"] ? 0 : 1;
             }
         }
+
         $information = [
             //仓储
             'storageFee' => [],
@@ -176,6 +178,7 @@ class OwnerFeeTotalService
         /**@var $storeOutFeeDetailsService OwnerStoreOutFeeDetailService */
         $storeOutFeeDetailsService = app('OwnerStoreOutFeeDetailService');
         $workFeeTotalGrouped = $storeOutFeeDetailsService->getTotalFee($owner->id, $counting_month)->groupBy('owner_price_operation_id');
+
         //入库
         foreach ($ownerPriceOperationsGrouped['入库'] ?? [] as $ownerPriceOperationsGroupedItem) {
             $information['storeFee'][] = [

+ 2 - 7
app/Services/OwnerLogisticFeeDetailService.php

@@ -23,7 +23,6 @@ class OwnerLogisticFeeDetailService implements \App\Interfaces\SettlementBillDet
      */
     protected $modelClass = OwnerLogisticFeeDetail::class;
 
-    //插入数据 ServiceAppAop的 insert 方法 支持批量
 
     /**
      * 根据货主查询 和时间段查询
@@ -92,7 +91,8 @@ class OwnerLogisticFeeDetailService implements \App\Interfaces\SettlementBillDet
                 'weight' => $ownerLogisticFeeDetail->ownerFeeDetailLogistic->weight ?? $ownerLogisticFeeDetail->ownerFeeDetail->weight ?? '0.00',//重量
                 'initial_weight_price' => $ownerLogisticFeeDetail->initial_weight_price ?? '',//首重价格
                 'additional_price' => $ownerLogisticFeeDetail->additional_price ?? '',//续重价格
-                'logistic_fee' => $ownerLogisticFeeDetail->ownerFeeDetailLogistic->logistic_fee ?? $ownerLogisticFeeDetail->ownerFeeDetail->logistic_fee ?? '0.00',//快递费
+//                'logistic_fee' => $ownerLogisticFeeDetail->ownerFeeDetailLogistic->logistic_fee ?? $ownerLogisticFeeDetail->ownerFeeDetail->logistic_fee ?? '0.00',//快递费
+                'logistic_fee' => $ownerLogisticFeeDetail->fee,//快递费
             ];
         }
         return $items;
@@ -100,23 +100,18 @@ class OwnerLogisticFeeDetailService implements \App\Interfaces\SettlementBillDet
 
     public function switchType($type)
     {
-        // TODO: Implement switchType() method.
     }
 
     public function buildExport($details): array
     {
-        // TODO: Implement buildExport() method.
     }
 
     public function add(array $model)
     {
-        // TODO: Implement add() method.
     }
 
     public function getTotalFee($owner_id, $counting_month)
     {
-        // TODO: Implement getTotalFee() method.
     }
 
-
 }

+ 5 - 1
app/Services/OwnerLogisticFeeReportService.php

@@ -93,6 +93,7 @@ class OwnerLogisticFeeReportService implements \App\Interfaces\SettlementBillRep
             additional_weight,
             sum(additional_weigh_weight) as additional_amount,
             sum(tax_fee) as tax_fee,
+            sum(fee) as fee,
             created_at,
             owner_id")
             ->whereBetween('created_at', [$start, $end])
@@ -111,11 +112,14 @@ class OwnerLogisticFeeReportService implements \App\Interfaces\SettlementBillRep
                 'additional_weight' => $ownerLogisticFeeDetail->additional_weight,
                 'additional_price' => $ownerLogisticFeeDetail->additional_price,
                 'additional_amount' => $ownerLogisticFeeDetail->additional_amount,
-                'fee' => ($ownerLogisticFeeDetail['initial_weight_price'] * $ownerLogisticFeeDetail['initial_amount']) + ($ownerLogisticFeeDetail['additional_amount'] * $ownerLogisticFeeDetail['additional_price']),
+                'fee' => $ownerLogisticFeeDetail->fee,
                 'tax_fee' => $ownerLogisticFeeDetail->tax_fee,
                 'owner_id' => $ownerLogisticFeeDetail->owner_id,
             ];
         }
+        //保证接口幂等性 删除统计月的数据
+        OwnerLogisticFeeReport::query()->where('counted_date', $counting_month)->delete();
+
         OwnerLogisticFeeReport::query()->insertOrIgnore($ownerLogisticFeeReportArray);
     }
 

+ 3 - 0
app/Services/OwnerStoreFeeReportService.php

@@ -75,6 +75,9 @@ class OwnerStoreFeeReportService implements \App\Interfaces\SettlementBillReport
             ];
         }
         $reports_chunked =  array_chunk($reports,1000 );
+        //保证幂等性 插入前删除该月的统计数据
+        OwnerStoreFeeReport::query()->where('counting_month', $counting_month)->delete();
+
         foreach ($reports_chunked as $items) {
             OwnerStoreFeeReport::query()->insertOrIgnore($items);
         }

+ 9 - 1
app/Services/OwnerStoreOutFeeDetailService.php

@@ -3,11 +3,13 @@
 namespace App\Services;
 
 use App\Interfaces\SettlementBillDetailInterface;
+use App\OwnerFeeDetail;
 use App\Traits\ServiceAppAop;
 use App\OwnerStoreOutFeeDetail;
 use App\Traits\SettlementBillServiceTrait;
 use Illuminate\Contracts\Pagination\LengthAwarePaginator;
 use Illuminate\Database\Eloquent\Builder;
+use Illuminate\Database\Eloquent\Collection;
 
 class OwnerStoreOutFeeDetailService implements SettlementBillDetailInterface
 {
@@ -71,10 +73,16 @@ class OwnerStoreOutFeeDetailService implements SettlementBillDetailInterface
         // TODO: Implement add() method.
     }
 
+    /**
+     * 查询指定货主 月份 按照货主 计费模型汇总的 作业费(出入库费)和税费
+     * @param $owner_id
+     * @param $counting_month
+     * @return Builder[]|Collection
+     */
     public function getTotalFee($owner_id, $counting_month)
     {
        list($start, $end) = $this->getStartAndEnd($counting_month);
-        return \App\OwnerFeeDetail::query()
+        return OwnerFeeDetail::query()
             ->selectRaw("owner_price_operation_id,
             sum(work_fee) as work_fee,
             sum(work_tax_fee) as work_tax_fee

+ 30 - 16
app/Services/OwnerStoreOutFeeReportService.php

@@ -39,7 +39,7 @@ class OwnerStoreOutFeeReportService implements SettlementBillReportInterface
         $end = Carbon::parse($this->reportDate)->endOfMonth()->toDateString();
         $details =
             DB::table('owner_store_out_fee_details')
-                ->leftJoin('owner_fee_details', 'owner_store_out_fee_details.owner_fee_detail_id', '=', 'owner_fee_details.id')
+                ->leftJoin('owner_fee_details ', 'owner_store_out_fee_details.owner_fee_detail_id', '=', 'owner_fee_details.id')
                 ->leftJoin('owner_price_operations', 'owner_store_out_fee_details.owner_price_operation_id', '=', 'owner_price_operations.id')
                 ->selectRaw("
                 DATE_FORMAT(owner_store_out_fee_details.created_at,'%Y-%m') as counting_month,
@@ -50,14 +50,14 @@ class OwnerStoreOutFeeReportService implements SettlementBillReportInterface
                 owner_store_out_fee_details.owner_fee_detail_id,
                 owner_store_out_fee_details.owner_price_operation_id,
                 owner_store_out_fee_details.step,
-                sum(owner_fee_details.work_fee) as work_fee,
                 owner_price_operations.name
                 ")
                 ->whereBetween('owner_store_out_fee_details.created_at', [$start, $end])
-                ->groupBy('counting_month',
+                ->groupBy(
+                    'counting_month',
                     'owner_store_out_fee_details.owner_id',
                     'owner_store_out_fee_details.step',
-                    'owner_price_operations.id'
+                    'owner_store_out_fee_details.owner_price_operation_id',
                 )
                 ->get();
         $reports = [];
@@ -76,9 +76,12 @@ class OwnerStoreOutFeeReportService implements SettlementBillReportInterface
                 'unit_id' => $detail->unit_id,
                 'unit_price' => $detail->unit_price,
                 'amount' => $detail->amounts,
-                'fee' => $detail->work_fee,
             ];
         }
+
+        //保证幂等性 插入前删除该月的统计数据
+        OwnerStoreOutFeeReport::query()->where('counting_month', $counting_month)->delete();
+
         foreach (array_chunk($reports, 1000) as $reports_chunked) {
             OwnerStoreOutFeeReport::query()->insertOrIgnore($reports_chunked);
         }
@@ -104,6 +107,7 @@ class OwnerStoreOutFeeReportService implements SettlementBillReportInterface
     function get(array $kvPairs)
     {
         $this->archiveService = app('OwnerBillReportArchiveService');
+        list($start, $end) = $this->getStartAndEnd($kvPairs['counting_month']);
         if ($this->archiveService->isArchived($kvPairs['counting_month'], $kvPairs['owner_id'], $kvPairs['type']) == 1) {
             //查询存档数据
             $archived = $this->archiveService->get($kvPairs);
@@ -118,22 +122,32 @@ class OwnerStoreOutFeeReportService implements SettlementBillReportInterface
                 ->orderBy('owner_price_operation_id')
                 ->get();
 
-            $work_name_fee_total = OwnerStoreOutFeeReport::query()
-                ->leftJoin('owner_price_operations', 'owner_store_out_fee_reports.owner_price_operation_id', '=', 'owner_price_operations.id')
+
+            $work_name_fee_total = \App\OwnerFeeDetail::query()
+                ->leftJoin('owner_price_operations', 'owner_fee_details.owner_price_operation_id', '=', 'owner_price_operations.id')
                 ->selectRaw("
-                sum(owner_store_out_fee_reports.fee) as fee,
-                owner_price_operations.name,
-                owner_price_operations.id
+                     sum(owner_fee_details.work_fee) as fee,
+                     owner_price_operations.name,
+                     owner_price_operations.id
                 ")
-                ->where('owner_id', $kvPairs['owner_id'])
-                ->where('counting_month', $kvPairs['counting_month'])
+                ->whereBetween('owner_fee_details.created_at', [$start, $end])
+                ->where('owner_fee_details.owner_id', $kvPairs['owner_id'])
                 ->groupBy('owner_price_operations.name')
                 ->get();
 
-            $fee_total = OwnerStoreOutFeeReport::query()
-                ->where('owner_id', $kvPairs['owner_id'])
-                ->where('counting_month', $kvPairs['counting_month'])
-                ->sum('fee');
+//            $work_name_fee_total = OwnerStoreOutFeeReport::query()
+//                ->leftJoin('owner_price_operations', 'owner_store_out_fee_reports.owner_price_operation_id', '=', 'owner_price_operations.id')
+//                ->selectRaw("
+//                sum(owner_store_out_fee_reports.fee) as fee,
+//                owner_price_operations.name,
+//                owner_price_operations.id
+//                ")
+//                ->where('owner_id', $kvPairs['owner_id'])
+//                ->where('counting_month', $kvPairs['counting_month'])
+//                ->groupBy('owner_price_operations.name')
+//                ->get();
+
+            $fee_total = $work_name_fee_total->sum('fee');
         }
         return array($reports, $work_name_fee_total, $fee_total);
     }

+ 1 - 0
database/factories/OwnerFeeDetailFactory.php

@@ -26,5 +26,6 @@ $factory->define(OwnerFeeDetail::class, function (Faker $faker) {
         "logistic_tax_fee" => mt_rand(100, 10000) / 10,     //物流税费
         "province" => $faker->randomElement($province),     //物流费
         "logistic_id" => rand(1,100),     //物流费
+        'created_at' => now()->subMonth()->startOfMonth()->addDays(random_int(1, 28)),
     ];
 });

+ 1 - 0
database/factories/OwnerLogisticFeeDetailFactory.php

@@ -20,6 +20,7 @@ $factory->define(OwnerLogisticFeeDetail::class, function (Faker $faker) {
         'owner_id' => random_int(1, 100),
         'additional_weigh_weight' => random_int(1, 100),
         'tax_fee' => random_int(1, 100),
+        'fee' => random_int(1, 100),
         'created_at' => now()->subMonth()->startOfMonth()->addDays(random_int(1, 28))->toDateTimeString(),
         'updated_at' => now()->subMonth()->startOfMonth()->addDays(random_int(1, 28))->toDateTimeString(),
     ];

+ 1 - 0
database/factories/OwnerStoreOutFeeDetailFactory.php

@@ -27,6 +27,7 @@ $factory->define(OwnerStoreOutFeeDetail::class, function (Faker $faker) {
 
         'step' => $faker->randomElement($step),
 
+
         'price_remark' => '起步费:2.2元(5件以内),续费:0.2元/件',
         'created_at' => now()->subMonth()->startOfMonth()->addDays(random_int(0, 28)),
         'updated_at' => now()->subMonth()->startOfMonth()->addDays(random_int(0, 28)),

+ 0 - 2
database/factories/OwnerStoreOutFeeReportFactory.php

@@ -21,8 +21,6 @@ $factory->define(OwnerStoreOutFeeReport::class, function (Faker $faker) {
 
         'amount'=>random_int(1,100),
 
-        'fee'=>random_int(1,100),
-
         'owner_id'=>random_int(1,100),
     ];
 });

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

@@ -0,0 +1,32 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class AddFeeToOwnerLogisticFeeDetailsTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('owner_logistic_fee_details', function (Blueprint $table) {
+            $table->decimal('fee')->comment('快递费');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('owner_logistic_fee_details', function (Blueprint $table) {
+            $table->dropColumn('fee');
+        });
+    }
+}

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

@@ -0,0 +1,34 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class DropFeeToOwnerStoreOutFeeReportsTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('owner_store_out_fee_reports', function (Blueprint $table) {
+            //
+            $table->dropColumn('fee');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('owner_store_out_fee_reports', function (Blueprint $table) {
+            //
+            $table->decimal('fee')->comment('费用');
+        });
+    }
+}

+ 0 - 1
database/seeds/OwnerLogisticFeeDetailSeeder.php

@@ -66,7 +66,6 @@ class OwnerLogisticFeeDetailSeeder extends Seeder
             factory(OwnerLogisticFeeDetail::class)->times(200)->create([
                 'owner_id' => $owner->id,
                 'owner_fee_detail_id' => $feeDetail->id,
-
             ]);
         }
     }

+ 3 - 3
database/seeds/OwnerStoreOutFeeDetailSeeder.php

@@ -17,10 +17,10 @@ class OwnerStoreOutFeeDetailSeeder extends Seeder
     public function run()
     {
         OwnerStoreOutFeeDetail::query()->truncate();
-        OwnerFeeDetail::query()->truncate();
+//        OwnerFeeDetail::query()->truncate();
         Commodity::query()->truncate();
-        OwnerPriceOperation::query()->truncate();
-        OwnerPriceOperationItem::query()->truncate();
+//        OwnerPriceOperation::query()->truncate();
+//        OwnerPriceOperationItem::query()->truncate();
 
         $owners = \App\Owner::query()->limit(10)->get();
         foreach ($owners as $owner) {

+ 8 - 1
database/seeds/OwnerStoreOutFeeReportSeeder.php

@@ -1,5 +1,8 @@
 <?php
 
+use App\Owner;
+use App\OwnerFeeDetail;
+use App\OwnerPriceOperation;
 use App\OwnerStoreOutFeeReport;
 use Illuminate\Database\Seeder;
 
@@ -13,8 +16,12 @@ class OwnerStoreOutFeeReportSeeder extends Seeder
     public function run()
     {
         OwnerStoreOutFeeReport::query()->truncate();
-        $owners = \App\Owner::query()->limit(10)->get();
+        OwnerFeeDetail::query()->truncate();
+        OwnerPriceOperation::query()->truncate();
+        $owners = Owner::query()->limit(10)->get();
         foreach ($owners as $owner) {
+            $priceOperation =  factory(OwnerPriceOperation::class)->create(['operation_type'=>'出库']);
+            factory(\App\OwnerFeeDetail::class)->create(['owner_price_operation_id'=>$priceOperation->id,'owner_id'=>$owner->id]);
             factory(OwnerStoreOutFeeReport::class)->times(100)->create(['owner_id' => $owner->id]);
         }
     }

+ 0 - 9
resources/views/finance/settlementBills/expressFee/report/index.blade.php

@@ -94,15 +94,6 @@
                     <td>@{{ report.fee }}</td>
                 </tr>
             </table>
-{{--            <div class="container" v-if="!(isArchived===1) && reports.length>0">--}}
-{{--                <div class="row">--}}
-{{--                    <div class="col-10"></div>--}}
-{{--                    <div class="col-2">--}}
-{{--                   --}}
-{{--                    </div>--}}
-{{--                </div>--}}
-{{--            </div>--}}
-<!--不是存档的展示分页            -->
             @if($isArchived===2 )
                 <div class="text-info h5 btn btn">{{$reportPaginator->count()??''}}
                     /{{$reportPaginator->total()??''}}</div>

+ 24 - 43
tests/Services/OwnerStoreOutFeeReportService/RecordReportTest.php

@@ -28,50 +28,31 @@ class RecordReportTest extends TestCase
         $this->service = app('OwnerStoreOutFeeReportService');
     }
 
-    public function testReturned()
+    public function test_record()
     {
-//        OwnerPriceOperation::query()->truncate();
-//        OwnerFeeDetail::query()->truncate();
-//        OwnerStoreOutFeeDetail::query()->truncate();
-//        OwnerBillReport::query()->truncate();
-//        OwnerStoreOutFeeReport::query()->truncate();
-//        $ownerPriceOperationIds = factory(OwnerPriceOperation::class)->times(10)->create()->pluck('id');
-//        $ownerFeeDetailIds = [];
-//        foreach ($ownerPriceOperationIds as $ownerPriceOperationId) {
-//            $ownerFeeDetailIds[] = factory(OwnerFeeDetail::class)->create(['owner_price_operation_id' => $ownerPriceOperationId]);
-//        }
-//        foreach ($ownerFeeDetailIds as $ownerFeeDetailId) {
-//            $details = factory(OwnerStoreOutFeeDetail::class)->times(2)->create(['owner_fee_detail_id' => $ownerFeeDetailId]);
-//            foreach ($details as $detail) {
-//                factory(OwnerBillReport::class)->create(['owner_id' => $detail->owner_id, 'counting_month' => $detail->created_at->startOfMonth()->toDateString()]);
-//            }
-//        }
-
-//        $this->service->recordReport();
-        $this->assertTrue(true);
-    }
-
-    public function testReturned2()
-    {
-//        OwnerFeeDetail::query()->truncate();
-//        OwnerStoreOutFeeDetail::query()->truncate();
-//        OwnerStoreOutFeeReport::query()->truncate();
-//        $feeDetails = factory(OwnerFeeDetail::class)->times(10)->create(['owner_id' => 8]);
-//        foreach ($feeDetails as $feeDetail) {
-//            factory(OwnerStoreOutFeeDetail::class)->create([
-//                'owner_fee_detail_id' => $feeDetail->id,
-//                'owner_id' => 8,
-//                'work_name' => 'aaa',
-//                'unit_price' => '1000',
-//                'unit_id' => 1,
-//                'amount' => 10,
-//                'remark' => 'vbbbb',
-//                'step' => '100-200',
-//            ]);
-//        }
-//        $this->service->recordReport();
-        $this->assertTrue(true);
-
+        OwnerStoreOutFeeReport::query()->truncate();
+        OwnerFeeDetail::query()->truncate();
+        OwnerPriceOperation::query()->truncate();
+        OwnerStoreOutFeeDetail::query()->truncate();
+
+        $ownerFeeDetails = factory(OwnerFeeDetail::class)->times(10)->create();
+        $ownerPriceOperations = factory(OwnerPriceOperation::class)->times(2)->create();
+        $ownerStoreOutFeeDetails = [];
+        foreach ($ownerFeeDetails as $ownerFeeDetail) {
+            $id = $ownerPriceOperations->random(1)[0]->id;
+            $ownerStoreOutFeeDetails[] =  factory(OwnerStoreOutFeeDetail::class)->create([
+                'owner_fee_detail_id' => $ownerFeeDetail->id,
+                'owner_id' => 8,
+                'owner_price_operation_id' => $id,
+            ]);
+            $ownerStoreOutFeeDetails[] =  factory(OwnerStoreOutFeeDetail::class)->create([
+                'owner_fee_detail_id' => $ownerFeeDetail->id,
+                'owner_id' => 8,
+                'owner_price_operation_id' => $id,
+            ]);
+        }
+        $this->service->recordReport();
+        $this->assertEquals(collect($ownerFeeDetails)->sum('work_fee'), OwnerStoreOutFeeReport::query()->sum('fee'));
     }
 
     function tearDown(): void