zhouzhendong 4 лет назад
Родитель
Сommit
4e3122dc64
61 измененных файлов с 1311 добавлено и 596 удалено
  1. 47 6
      app/Filters/OrderPackageFilters.php
  2. 12 2
      app/Http/Controllers/ControlPanelController.php
  3. 20 11
      app/Http/Controllers/OrderPackageController.php
  4. 9 2
      app/Http/Controllers/PackageLogisticController.php
  5. 1 0
      app/Http/Controllers/SettlementBillExpressFeeDetailController.php
  6. 2 1
      app/Http/Controllers/SettlementIndemnityFeeController.php
  7. 41 0
      app/Http/Controllers/TestController.php
  8. 4 0
      app/Jobs/LogisticAliJiSuSync.php
  9. 3 0
      app/Jobs/LogisticSFSync.php
  10. 4 0
      app/Jobs/LogisticYDSync.php
  11. 4 0
      app/Jobs/LogisticYTOSync.php
  12. 3 0
      app/Jobs/LogisticZopSync.php
  13. 0 52
      app/Jobs/SettlementBillCountingTask.php
  14. 1 1
      app/Jobs/SettlementBillReportTask.php
  15. 29 3
      app/OrderPackage.php
  16. 33 0
      app/OrderPackageRemark.php
  17. 24 3
      app/OwnerFeeExpress.php
  18. 26 0
      app/OwnerFeeLogistic.php
  19. 13 1
      app/OwnerFeeOperation.php
  20. 7 1
      app/OwnerLogisticFeeReport.php
  21. 7 0
      app/OwnerStoreFeeReport.php
  22. 7 0
      app/OwnerStoreOutFeeReport.php
  23. 4 2
      app/Providers/AppServiceProvider.php
  24. 19 104
      app/Services/LaborReportsCountingRecordService.php
  25. 13 0
      app/Services/OrderPackageRemarkService.php
  26. 58 22
      app/Services/OwnerFeeTotalService.php
  27. 9 39
      app/Services/OwnerLogisticFeeDetailService.php
  28. 27 28
      app/Services/OwnerLogisticFeeReportService.php
  29. 4 2
      app/Services/OwnerProcessSettlementBillService.php
  30. 10 7
      app/Services/OwnerStoreFeeDetailService.php
  31. 23 18
      app/Services/OwnerStoreFeeReportService.php
  32. 11 7
      app/Services/OwnerStoreOutFeeDetailService.php
  33. 40 36
      app/Services/OwnerStoreOutFeeReportService.php
  34. 27 24
      app/Services/OwnerWaybillSettlementBillService.php
  35. 1 0
      config/api_logistic.php
  36. 12 0
      database/factories/OrderPackageRemarkFactory.php
  37. 26 0
      database/factories/OwnerFeeExpressFactory.php
  38. 36 0
      database/factories/OwnerFeeLogisticFactory.php
  39. 32 0
      database/migrations/2021_08_16_102229_change_province_to_province_id_to_owner_logistic_fee_reports_table.php
  40. 34 0
      database/migrations/2021_08_17_112816_add_column_model_id_to_owner_store_fee_reports_table.php
  41. 34 0
      database/migrations/2021_08_17_112924_add_column_model_id_to_owner_store_out_fee_reports_table.php
  42. 50 0
      database/migrations/2021_08_18_111331_add_column_sync_routes_flag_to_order_packages_table.php
  43. 35 0
      database/migrations/2021_08_18_141408_create_order_package_remarks_table.php
  44. 16 0
      database/seeds/OrderPackageRemarkSeeder.php
  45. 21 0
      database/seeds/OwnerFeeExpressSeeder.php
  46. 21 0
      database/seeds/OwnerFeeLogisticSeeder.php
  47. 1 2
      database/seeds/SettlementBillSeeder.php
  48. 211 128
      resources/views/control/panel.blade.php
  49. 5 5
      resources/views/finance/settlementBills/expressFee/detail/index.blade.php
  50. 1 1
      resources/views/finance/settlementBills/expressFee/report/index.blade.php
  51. 9 0
      resources/views/finance/settlementBills/indemnityFee/index.blade.php
  52. 18 18
      resources/views/finance/settlementBills/logisticFee/index.blade.php
  53. 9 0
      resources/views/finance/settlementBills/packingMaterialFee/index.blade.php
  54. 21 9
      resources/views/finance/settlementBills/storeFee/detail/index.blade.php
  55. 3 3
      resources/views/finance/settlementBills/storeFee/report/index.blade.php
  56. 21 9
      resources/views/finance/settlementBills/storeOutFee/detail/index.blade.php
  57. 1 1
      resources/views/finance/settlementBills/storeOutFee/report/index.blade.php
  58. 5 19
      resources/views/finance/settlementBills/totalFee/index.blade.php
  59. 144 28
      resources/views/package/logistic/index.blade.php
  60. 1 0
      routes/apiLocal.php
  61. 1 1
      tests/Feature/LogisticZopSyncTest.php

+ 47 - 6
app/Filters/OrderPackageFilters.php

@@ -4,7 +4,9 @@
 namespace App\Filters;
 
 use App\Order;
+use App\OrderIssue;
 use App\Services\UserService;
+use Illuminate\Database\Eloquent\Builder;
 use Illuminate\Http\Request;
 use Illuminate\Support\Carbon;
 use Illuminate\Support\Str;
@@ -15,7 +17,12 @@ class OrderPackageFilters
     protected $request;
     protected $queryBuilder;
     protected $filters = ['logistic_number', 'status', 'received_at_start',
-        'received_at_end', 'is_weighed', 'logistic', 'owner', 'sent_at_start', 'sent_at_end', 'is_exception', 'exception_type', 'default_date','has_transfer_status'];
+        'default_logistics',
+        'is_issue',
+        'sync_routes_flag',
+        'received_at_end', 'is_weighed', 'logistic', 'owner', 'sent_at_start', 'sent_at_end', 'is_exception', 'exception_type', 'default_date', 'has_transfer_status'];
+
+    protected $orderIssueQuery;
 
     public function __construct(Request $request)
     {
@@ -34,26 +41,37 @@ class OrderPackageFilters
         return $this->queryBuilder;
     }
 
+    public function getOrderIssueQuery(): Builder
+    {
+        if (!$this->orderIssueQuery) {
+            $this->orderIssueQuery = OrderIssue::query()->select('order_id');
+        }
+        return $this->orderIssueQuery;
+    }
+
 
     private function logistic_number($logistic_number)
     {
         if (strpos($logistic_number, ',') || strpos($logistic_number, ',') || strpos($logistic_number, ' ')) {
             $arr = array_filter(preg_split('/[,, ]+/is', $logistic_number));
-            $this->queryBuilder->whereIn('logistic_number',$arr);
+            $this->queryBuilder->whereIn('logistic_number', $arr);
         } else {
-            $this->queryBuilder->where('logistic_number','like',$logistic_number."%");
+            $this->queryBuilder->where('logistic_number', 'like', $logistic_number . "%");
         }
     }
 
     private function exception_type($exception_type)
     {
-        $this->queryBuilder->where('exception_type', $exception_type);
+        $exception_types = array_filter(preg_split('/[,, ]+/is', $exception_type));
+
+        $this->queryBuilder->whereIn('exception_type', $exception_types);
     }
+
     private function has_transfer_status($has_transfer_status)
     {
-        if ($has_transfer_status=='是') {
+        if ($has_transfer_status == '是') {
             $this->queryBuilder->whereNotNull('transfer_status');
-        } elseif ($has_transfer_status=='否') {
+        } elseif ($has_transfer_status == '否') {
             $this->queryBuilder->whereNull('transfer_status');
         }
     }
@@ -115,4 +133,27 @@ class OrderPackageFilters
     {
         $this->queryBuilder->where('sent_at', '>=', now()->startOfDay()->subDays(15))->where('sent_at', '<', now()->startOfDay()->addDay());
     }
+
+    public function default_logistics()
+    {
+        $this->queryBuilder->whereIn('order_id', function ($query) {
+            $query->from('orders')
+                ->select('id')
+                ->whereNotIn('logistic_id', [13, 24, 25, 26, 27, 30, 31, 32, 33, 34, 60, 63, 65, 66, 68, 70, 102, 105, 107, 116,]);
+        });
+    }
+
+    public function is_issue($is_issue)
+    {
+        $this->queryBuilder->whereIn('order_id', function ($query) {
+            $query->from('orders')->select('id')->whereIn('id', function ($query) {
+                $query->from('order_issues')->select('order_id');
+            });
+        });
+    }
+
+    public function sync_routes_flag($sync_routes_flag)
+    {
+        $this->queryBuilder->where('sync_routes_flag', $sync_routes_flag === 'true');
+    }
 }

+ 12 - 2
app/Http/Controllers/ControlPanelController.php

@@ -15,6 +15,7 @@ use App\Services\NewOrderCountingRecordService;
 use App\Services\RealtimePendingOrdersService;
 use App\Services\UserService;
 use App\User;
+use App\UserWorkgroup;
 use Carbon\Carbon;
 use Carbon\CarbonPeriod;
 use Illuminate\Http\Request;
@@ -39,7 +40,8 @@ class ControlPanelController extends Controller
         $menus = app(CheckActiveMenuService::class)->activeMenus();
         $owners = Owner::query()->whereIn('id', $ownerIds)->get();
         $warehousesOrders = app(RealtimePendingOrdersService::class)->warehousesOrders();
-        return view('control.panel', compact('owners', 'menus', 'warehousesOrders'));
+        $userWorkgroups = UserWorkgroup::all();
+        return view('control.panel', compact('owners', 'menus', 'warehousesOrders','userWorkgroups'));
     }
 
     public function orderCountingRecordsApi(Request $request)
@@ -85,16 +87,24 @@ class ControlPanelController extends Controller
 
     public function laborReportsCountingRecordApi(Request $request)
     {
+        /** @var LaborReportsCountingRecordService  $laborReportsCountingRecordService */
         $laborReportsCountingRecordService = app(LaborReportsCountingRecordService::class);
         $start = Carbon::parse($request->start)->gt(Carbon::now()) ? Carbon::now()->toDateString() : $request->start;
         $end = Carbon::parse($request->end)->gt(Carbon::now()) ? Carbon::now()->toDateString() : $request->end;
         $unit = $request->unit;
-        $laborReportsCountingRecords = $laborReportsCountingRecordService->get($start, $end, $unit);
+        $userWorkgroupIds = $request->user_workgroup_ids;
+        $laborReportsCountingRecords = $laborReportsCountingRecordService->get([
+            'start' => $start,
+            'end' => $end,
+            'unit' => $unit,
+            'userWorkgroupIds' => $userWorkgroupIds,
+        ]);
         return compact('laborReportsCountingRecords');
     }
 
     public function laborReportsUserGroupsCountApi(Request $request)
     {
+        /** @var LaborReportsCountingRecordService $laborReportsCountingRecordService */
         $laborReportsCountingRecordService = app(LaborReportsCountingRecordService::class);
         $start = Carbon::parse($request->start)->gt(Carbon::now()) ? Carbon::now()->toDateString() : $request->start;
         $end = Carbon::parse($request->end)->gt(Carbon::now()) ? Carbon::now()->toDateString() : $request->end;

+ 20 - 11
app/Http/Controllers/OrderPackageController.php

@@ -9,21 +9,30 @@ class OrderPackageController extends Controller
 {
     public function update(Request $request)
     {
-        $remarkItem = $request->input('remark');
+        $remark = $request->input('remark');
         /**
          * @var $orderPackage OrderPackage
          */
         $orderPackage = OrderPackage::query()->find($request->input('orderPackageId'));
-        if (is_null($orderPackage->remark)) {
-            $orderPackage->remark = [$remarkItem];
-        } else {
-            $remark = $orderPackage->remark;
-            $remark[] = $remarkItem;
-            $remark = array_reverse($remark);
-            $orderPackage->remark = $remark;
-        }
-        $orderPackage->save();
-        return ['success' => true, 'data' => $orderPackage->refresh()->remark];
+
+        $orderPackage->orderPackageRemarks()
+            ->create([
+                'user_id' => auth()->id(),
+                'content' => $remark,
+            ]);
+        return ['success' => true, 'data' => $orderPackage->orderPackageRemarks()->with('user')->orderByDesc('created_at')->get()];
+    }
+
+    public function destroy(Request $request)
+    {
+        /**
+         * @var $orderPackage OrderPackage
+         */
+        $orderPackage = OrderPackage::query()->find($request->input('orderPackageId'));
+
+
+        $orderPackage->orderPackageRemarks()->where('id',$request->remarkId)->delete();
+        return ['success' => true, 'data' => $orderPackage->orderPackageRemarks()->with('user')->orderByDesc('created_at')->get()];
     }
 
 }

+ 9 - 2
app/Http/Controllers/PackageLogisticController.php

@@ -30,11 +30,18 @@ class PackageLogisticController extends Controller
         $paginateParams = $request->input();
         $orderPackages = OrderPackage::query()
             ->filter($filters)
-            ->whereIn('owner_id', $owner_ids)->with(['order.logistic', 'order.owner', 'order.issue' => function ($query) {
+            ->with(['order.logistic',
+                'orderPackageRemarks'=>function ($query){
+                    $query->with('user')->orderByDesc('created_at');
+                },
+                'order.owner',
+                'order.issue' => function ($query) {
                 $query->with(['issueType', 'logs' => function ($query) {
                     $query->with('user')->orderBy('created_at', 'DESC');
                 }]);
-            }])->orderByDesc('id')->paginate($request->paginate ?? 50);
+            }])
+            ->orderByDesc('id')
+            ->paginate($request->paginate ?? 50);
         $logistics = Logistic::all();
         $owners = Owner::find($owner_ids);
         return view('package.logistic.index', compact('orderPackages', 'logistics', 'owners', 'paginateParams'));

+ 1 - 0
app/Http/Controllers/SettlementBillExpressFeeDetailController.php

@@ -42,6 +42,7 @@ class SettlementBillExpressFeeDetailController extends Controller implements Set
             'counting_month' => $counting_month,
             'paginateParams' => $paginateParams,
         ]);
+//        dd($details);
         $owners = Owner::query()->selectRaw("id,name")->whereIn('id', $permittingOwnerIds)->get();
         $owner = Owner::query()->selectRaw("name,id")->find($owner_id);
         $this->archiveService = app('OwnerBillReportArchiveService');

+ 2 - 1
app/Http/Controllers/SettlementIndemnityFeeController.php

@@ -42,7 +42,8 @@ class SettlementIndemnityFeeController extends Controller implements \App\Interf
         $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,$owner_id);
-        return view('finance.settlementBills.indemnityFee.index', compact('details', 'paginateParams', 'owners', 'owner', 'request', 'isArchived'));
+        $totalFee = $details->sum('baoshi_indemnity_money');
+        return view('finance.settlementBills.indemnityFee.index', compact('details', 'paginateParams', 'owners', 'owner', 'request', 'isArchived','totalFee'));
     }
 
     public function export(Request $request)

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

@@ -33,7 +33,11 @@ use App\RejectedBill;
 use App\Services\CacheShelfService;
 use App\Services\ForeignHaiRoboticsService;
 use App\Services\OrderService;
+use App\Services\OwnerFeeTotalService;
+use App\Services\OwnerLogisticFeeReportService;
 use App\Services\OwnerPriceOperationService;
+use App\Services\OwnerStoreFeeReportService;
+use App\Services\OwnerStoreOutFeeReportService;
 use App\Services\StationService;
 use App\Services\StorageService;
 use App\Station;
@@ -53,6 +57,7 @@ use Illuminate\Support\Facades\Auth;
 use Illuminate\Support\Facades\Cookie;
 use Illuminate\Support\Facades\DB;
 use Illuminate\Support\Facades\Http;
+use PhpOffice\PhpSpreadsheet\Calculation\Web\Service;
 
 class TestController extends Controller
 {
@@ -128,4 +133,40 @@ class TestController extends Controller
         dispatch(new WeightUpdateInstantBill(OrderPackage::query()->find(17000457)));
         dispatch(new WeightUpdateInstantBill(OrderPackage::query()->find(17000456)));
     }
+    public function OwnerStoreFeeReportService_recordReport()
+    {
+        /** @var OwnerStoreFeeReportService $service */
+        $service = app('OwnerStoreFeeReportService');
+        $service->recordReport('2021-08-01');
+    }
+
+    public function OwnerStoreOutFeeReportService_recordReport()
+    {
+        /** @var OwnerStoreOutFeeReportService $service */
+        $service = app('OwnerStoreOutFeeReportService');
+        $service->recordReport('2021-08-01');
+    }
+
+    public function OwnerFeeTotalService_record()
+    {
+        /** @var OwnerFeeTotalService $service */
+        $service = app('OwnerFeeTotalService');
+        $service->record('2021-08-01');
+    }
+
+//快递
+    public function OwnerLogisticFeeReportService_record()
+    {
+        ini_set('max_execution_time',-1);
+
+        /** @var OwnerLogisticFeeReportService $service */
+        $service = app('OwnerLogisticFeeReportService');
+        $service->recordReport('2021-08-01');
+    }
+
+    public function order_packages_sync_routes_flag_init()
+    {
+        OrderPackage::query()->whereNotNull('transfer_status')->update(['sync_routes_flag'=>true]);
+    }
+
 }

+ 4 - 0
app/Jobs/LogisticAliJiSuSync.php

@@ -2,6 +2,7 @@
 
 namespace App\Jobs;
 
+use App\OrderPackage;
 use App\Services\LogisticAliJiSuApiService;
 use App\Services\LogService;
 use App\Services\OrderPackageReceivedSyncService;
@@ -46,6 +47,9 @@ class LogisticAliJiSuSync implements ShouldQueue
     public function handle()
     {
         LogService::log(LogisticAliJiSuSync::class, "{$this->logistic_number}-JOB-AliJiSu", '');
+        //标记上有同步的操作
+        OrderPackage::query()->where('logistic_number', $this->logistic_number)->update(['sync_routes_flag'=> true]);
+
         $this->logisticAliJiSuApiService = app('LogisticAliJiSuApiService');
         try {
             $response = $this->logisticAliJiSuApiService->query($this->logistic_number);

+ 3 - 0
app/Jobs/LogisticSFSync.php

@@ -2,6 +2,7 @@
 
 namespace App\Jobs;
 
+use App\OrderPackage;
 use App\Services\LogisticSFService;
 use App\Services\LogService;
 use Illuminate\Bus\Queueable;
@@ -45,6 +46,8 @@ class LogisticSFSync implements ShouldQueue
     public function handle()
     {
         LogService::log(LogisticSFSync::class, "JOB-SF", $this->logistic_number);
+        //标记上有同步的操作
+        OrderPackage::query()->where('logistic_number', $this->logistic_number)->update(['sync_routes_flag'=> true]);
         $this->logisticSFService = app('LogisticSFService');
         $formedData = $this->logisticSFService->get([$this->logistic_number]);
         $this->orderPackageReceivedSyncService = app('OrderPackageReceivedSyncService');

+ 4 - 0
app/Jobs/LogisticYDSync.php

@@ -2,6 +2,7 @@
 
 namespace App\Jobs;
 
+use App\OrderPackage;
 use App\Services\LogisticYDService;
 use App\Services\LogService;
 use App\Services\OrderPackageReceivedSyncService;
@@ -44,6 +45,9 @@ class LogisticYDSync implements ShouldQueue
     public function handle()
     {
         LogService::log(LogisticYDSync::class, "JOB-YD", $this->logistic_number);
+        //标记上有同步的操作
+        OrderPackage::query()->where('logistic_number', $this->logistic_number)->update(['sync_routes_flag'=> true]);
+
         $this->logisticYDService = app('LogisticYDService');
         //先订阅订单
         $this->logisticYDService->registerApi([$this->logistic_number]);

+ 4 - 0
app/Jobs/LogisticYTOSync.php

@@ -2,6 +2,7 @@
 
 namespace App\Jobs;
 
+use App\OrderPackage;
 use App\Services\LogisticYTOService;
 use App\Services\LogService;
 use App\Services\OrderPackageReceivedSyncService;
@@ -46,6 +47,9 @@ class LogisticYTOSync implements ShouldQueue
     public function handle()
     {
         LogService::log(LogisticYTOSync::class, "JOB-YTO", $this->logistic_number);
+        //标记上有同步的操作
+        OrderPackage::query()->where('logistic_number', $this->logistic_number)->update(['sync_routes_flag'=> true]);
+
         $this->logisticYTOService = app('LogisticYTOService');
         $this->orderPackageReceivedSyncService = app('OrderPackageReceivedSyncService');
         $nativeResponse = $this->logisticYTOService->query($this->logistic_number);

+ 3 - 0
app/Jobs/LogisticZopSync.php

@@ -3,6 +3,7 @@
 namespace App\Jobs;
 
 
+use App\OrderPackage;
 use App\Services\LogisticZopService;
 use App\Services\LogService;
 use App\Services\OrderPackageReceivedSyncService;
@@ -50,6 +51,8 @@ class LogisticZopSync implements ShouldQueue
     public function handle()
     {
         LogService::log(LogisticZopSync::class, "JOB-ZOP", $this->logistic_number);
+        //标记上有同步的操作
+        OrderPackage::query()->where('logistic_number', $this->logistic_number)->update(['sync_routes_flag'=> true]);
         $nativeResponse = $this->logistic_zop_service->query($this->logistic_number);
         $logisticResponseFormatted = $this->logistic_zop_service->format($nativeResponse,$this->logistic_number);
         $this->order_package_received_sync_service->update([$logisticResponseFormatted]);

+ 0 - 52
app/Jobs/SettlementBillCountingTask.php

@@ -1,52 +0,0 @@
-<?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 {
-            //清除历史统计记录
-
-        }
-    }
-}

+ 1 - 1
app/Jobs/SettlementBillReportTask.php

@@ -21,7 +21,7 @@ class SettlementBillReportTask implements ShouldQueue
 {
     use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
 
-    public $timeout = 120;
+    public $timeout = 3600;
 
     public $maxExceptions = 3;
 

+ 29 - 3
app/OrderPackage.php

@@ -24,8 +24,29 @@ class OrderPackage extends Model
 
     use ModelTimeFormat;
 
-    protected $fillable = ['order_id','logistic_number','batch_number',
-        'batch_rule','bulk','weight','length','width','height','paper_box_id','measuring_machine_id','weighed_at','status','sent_at','received_at','exception','transfer_status','remark','owner_id','uploaded_to_wms','exception_type'];
+    protected $fillable = [
+        'order_id',
+        'logistic_number',
+        'batch_number',
+        'batch_rule',
+        'bulk',
+        'weight',
+        'length',
+        'width',
+        'height',
+        'paper_box_id',
+        'measuring_machine_id',
+        'weighed_at',
+        'status',
+        'sent_at',
+        'received_at',
+        'exception',
+        'transfer_status',
+        'owner_id',
+        'uploaded_to_wms',
+        'exception_type',
+        'sync_routes_flag',
+    ];
 
     public function order(){
         return $this->belongsTo('App\Order','order_id','id');
@@ -33,7 +54,7 @@ class OrderPackage extends Model
 
     protected $casts = [
         'transfer_status' => 'array',
-        'remark' => 'array',
+        'sync_routes_flag' => 'boolean',
     ];
 
     public function commodities(): HasMany
@@ -294,4 +315,9 @@ class OrderPackage extends Model
     {
         return $this->belongsTo(Owner::class);
     }
+
+    public function orderPackageRemarks(): HasMany
+    {
+        return $this->hasMany(OrderPackageRemark::class);
+    }
 }

+ 33 - 0
app/OrderPackageRemark.php

@@ -0,0 +1,33 @@
+<?php
+
+namespace App;
+
+use App\Traits\ModelTimeFormat;
+use Illuminate\Database\Eloquent\Model;
+
+use App\Traits\ModelLogChanging;
+use Illuminate\Database\Eloquent\Relations\BelongsTo;
+use Illuminate\Database\Eloquent\SoftDeletes;
+
+class OrderPackageRemark extends Model
+{
+    use ModelLogChanging;
+    use SoftDeletes;
+    use ModelTimeFormat;
+
+    public $fillable = [
+        'order_package_id',
+        'user_id',
+        'content',
+    ];
+
+    public function orderPackage(): BelongsTo
+    {
+        return $this->belongsTo(OrderPackage::class);
+    }
+
+    public function user(): BelongsTo
+    {
+        return $this->belongsTo(User::class);
+    }
+}

+ 24 - 3
app/OwnerFeeExpress.php

@@ -5,6 +5,7 @@ namespace App;
 use Illuminate\Database\Eloquent\Model;
 
 use App\Traits\ModelLogChanging;
+use Illuminate\Database\Eloquent\Relations\BelongsTo;
 
 class OwnerFeeExpress extends Model
 {
@@ -12,8 +13,28 @@ class OwnerFeeExpress extends Model
 
     public $timestamps = false;
     protected $fillable = [
-        "province_id", "logistic_id", "logistic_number",
-        "weight", "initial_weight","initial_weight_price","additional_weight","additional_weight_amount", "additional_weight_price",
-        "total_fee","tax_rate", "created_at","owner_id"
+        "province_id",
+        "logistic_id",
+        "logistic_number",
+        "weight",
+        "initial_weight",
+        "initial_weight_price",
+        "additional_weight",
+        "additional_weight_amount",
+        "additional_weight_price",
+        "total_fee",
+        "tax_rate",
+        "created_at",
+        "owner_id"
     ];
+
+    public function province(): BelongsTo
+    {
+        return $this->belongsTo(Province::class);
+    }
+
+    public function logistic(): BelongsTo
+    {
+        return $this->belongsTo(Logistic::class);
+    }
 }

+ 26 - 0
app/OwnerFeeLogistic.php

@@ -5,6 +5,7 @@ namespace App;
 use Illuminate\Database\Eloquent\Model;
 
 use App\Traits\ModelLogChanging;
+use Illuminate\Database\Eloquent\Relations\BelongsTo;
 
 class OwnerFeeLogistic extends Model
 {
@@ -35,4 +36,29 @@ class OwnerFeeLogistic extends Model
         "remark",
         "created_at",
     ];
+
+    public function province(): BelongsTo
+    {
+        return $this->belongsTo(Province::class);
+    }
+
+    public function city(): BelongsTo
+    {
+        return $this->belongsTo(City::class);
+    }
+
+    public function owner(): BelongsTo
+    {
+        return $this->belongsTo(Owner::class);
+    }
+
+    public function logistic(): BelongsTo
+    {
+        return $this->belongsTo(Logistic::class);
+    }
+
+    public function unit(): BelongsTo
+    {
+        return $this->belongsTo(Unit::class);
+    }
 }

+ 13 - 1
app/OwnerFeeOperation.php

@@ -5,6 +5,8 @@ namespace App;
 use Illuminate\Database\Eloquent\Model;
 
 use App\Traits\ModelLogChanging;
+use Illuminate\Database\Eloquent\Relations\BelongsTo;
+use Illuminate\Database\Eloquent\Relations\HasMany;
 
 class OwnerFeeOperation extends Model
 {
@@ -23,8 +25,18 @@ class OwnerFeeOperation extends Model
         "owner_id",
     ];
 
-    public function details()
+    public function details(): HasMany
     {
         return $this->hasMany(OwnerFeeOperationDetail::class);
     }
+
+    public function model(): BelongsTo
+    {
+        return $this->belongsTo(OwnerPriceOperation::class, 'model_id', 'id');
+    }
+
+    public function commodity(): BelongsTo
+    {
+        return $this->belongsTo(Commodity::class);
+    }
 }

+ 7 - 1
app/OwnerLogisticFeeReport.php

@@ -14,7 +14,7 @@ class OwnerLogisticFeeReport extends Model
     public $fillable = [
         'owner_logistic_sum_fee_report_id',//
         'logistic_id',//承运商
-        'province', //省份
+        'province_id', //省份
         'counted_date',//统计月份
         'initial_weight',//首重
         'initial_weight_price',//首重价格
@@ -32,4 +32,10 @@ class OwnerLogisticFeeReport extends Model
     {
         return $this->belongsTo(Logistic::class);
     }
+
+    public function province(): BelongsTo
+    {
+        return $this->belongsTo(Province::class);
+    }
 }
+

+ 7 - 0
app/OwnerStoreFeeReport.php

@@ -20,6 +20,8 @@ class OwnerStoreFeeReport extends Model
         'amount', //数量
         'fee',//费用
         'work_name',//作业名称
+        'model_id',//计费模型
+        'tax_fee',//税费
     ];
 
     public $timestamps = false;
@@ -43,4 +45,9 @@ class OwnerStoreFeeReport extends Model
     {
         return $this->unit_price . '/' . $this->unit->name;
     }
+
+    public function model(): BelongsTo
+    {
+        return $this->belongsTo(OwnerPriceOperation::class, 'model_id', 'id');
+    }
 }

+ 7 - 0
app/OwnerStoreOutFeeReport.php

@@ -21,6 +21,8 @@ class OwnerStoreOutFeeReport extends Model
         'owner_id',
         'work_name',//作业名称
         'fee',//费用
+        'model_id',//计费模型
+        'tax_fee',//税费
     ];
 
     public $timestamps = false;
@@ -39,4 +41,9 @@ class OwnerStoreOutFeeReport extends Model
     {
         return $this->belongsTo(Owner::class);
     }
+
+    public function model(): BelongsTo
+    {
+        return $this->belongsTo(OwnerPriceOperation::class, 'model_id', 'id');
+    }
 }

+ 4 - 2
app/Providers/AppServiceProvider.php

@@ -167,6 +167,7 @@ use App\Services\RequirementService;
 use App\Services\RequirementUserService;
 use App\Services\WorkOrderService;
 use App\Services\WorkOrderTypeService;
+use App\Services\OrderPackageRemarkService;
 
 class AppServiceProvider extends ServiceProvider
 {
@@ -239,9 +240,9 @@ class AppServiceProvider extends ServiceProvider
         app()->singleton('BatchService',BatchService::class);
         app()->singleton('BatchUpdateService', BatchUpdateService::class);
         app()->singleton('CacheService',CacheService::class);
-        app()->singleton('CityService',CityService::class);
         app()->singleton('CacheShelfService',CacheShelfService::class);
         app()->singleton('CheckActiveMenuService',CheckActiveMenuService::class);
+        app()->singleton('CityService',CityService::class);
         app()->singleton('CommodityBarcodeService',CommodityBarcodeService::class);
         app()->singleton('CommodityMaterialBoxModelService',CommodityMaterialBoxModelService::class);
         app()->singleton('CommodityService', CommodityService::class);
@@ -304,6 +305,7 @@ class AppServiceProvider extends ServiceProvider
         app()->singleton('OrderPackageExceptionTypeCountingRecordService', OrderPackageExceptionTypeCountingRecordService::class);
         app()->singleton('OrderPackageReceivedSyncRecordService', OrderPackageReceivedSyncRecordService::class);
         app()->singleton('OrderPackageReceivedSyncService', OrderPackageReceivedSyncService::class);
+        app()->singleton('OrderPackageRemarkService',OrderPackageRemarkService::class);
         app()->singleton('OrderPackageService', OrderPackageService::class);
         app()->singleton('OrderService', OrderService::class);
         app()->singleton('OrderTrackingService', OrderTrackingService::class);
@@ -381,8 +383,8 @@ class AppServiceProvider extends ServiceProvider
         app()->singleton('UserWorkgroupService', UserWorkgroupService::class);
         app()->singleton('WarehouseService', WarehouseService::class);
         app()->singleton('WaybillFinancialService', WaybillFinancialService::class);
-        app()->singleton('WeighExceptedService', WeighExceptedService::class);
         app()->singleton('WaybillService', WaybillService::class);
+        app()->singleton('WeighExceptedService', WeighExceptedService::class);
         app()->singleton('WorkOrderService',WorkOrderService::class);
         app()->singleton('WorkOrderTypeService',WorkOrderTypeService::class);
     }

+ 19 - 104
app/Services/LaborReportsCountingRecordService.php

@@ -6,6 +6,8 @@ namespace App\Services;
 
 use App\LaborReport;
 use Carbon\Carbon;
+use Illuminate\Database\Eloquent\Builder;
+use Illuminate\Database\Eloquent\Collection;
 use Illuminate\Support\Facades\Cache;
 use Illuminate\Support\Str;
 use App\Traits\ServiceAppAop;
@@ -51,120 +53,33 @@ class LaborReportsCountingRecordService
         return $result->sortBy('id');
     }
 
-    public function get($start, $end, $unit = '日')
-    {
-        $resultByCache = $this->getByCache($start, $end, $unit);
-        if ($resultByCache['dateList'] == []) {
-            return $resultByCache['dataList'];
-        } else {
-            $this->syncDBToCache($resultByCache['dateList'], $unit);
-            return $this->getByCache($start, $end, $unit)['dataList'];
-        }
-    }
-
-    public function getByCache($start, $end, $unit)
-    {
-        $dataList = collect();
-        $dateList = collect($this->periodDateToArray($start, $end, $unit));
-        $result = [];
-        foreach ($dateList as $date) {
-            $key = 'laborReportsCountingRecords_' . $date . '_' . $unit;
-            $item = Cache::get($key);
-            if ($item) {
-                $dataList->push($item);
-                $dateList = $dateList->reject(function ($value) use ($date) {
-                    return $value == $date;
-                });
-            }
-        }
-        $result['dataList'] = $dataList;
-        $result['dateList'] = $dateList->toArray();
-        return $result;
-    }
-
-
     /**
-     * @param $start
-     * @param $end
-     * @param string $unit
-     * @return array
+     * @param $kvPairs
+     * @return array|Builder[]|Collection
      */
-    private function periodDateToArray($start, $end, $unit = '日')
+    public function get($kvPairs)
     {
-        $dataArray = [];
-        switch ($unit) {
-            case '日';
-                foreach (Carbon::parse($start)->daysUntil($end, 1)->toArray() as $item) {
-                    $dataArray[] = $item->toDateString();
-                }
-                break;
-            case '月';
-                foreach (Carbon::parse($start)->monthsUntil($end, 1)->toArray() as $item) {
-                    $dataArray[] = $item->year . '-' . $item->format('m') . '';
-                }
-                break;
-            case '年';
-                foreach (Carbon::parse($start)->yearsUntil($end, 1)->toArray() as $item) {
-                    $dataArray[] = $item->year . '';
-                }
-                break;
-            default:
-                break;
-        }
-        return $dataArray;
-    }
-
-    private function syncDBToCache($dateList, $unit)
-    {
-        switch ($unit) {
+        switch ($kvPairs['unit']) {
             case '日':
-                $query = LaborReport::query()
-                    ->selectRaw("DATE_FORMAT(created_at,'%Y-%m-%d') as date_target, count(DISTINCT enter_number ) as counter");
-                foreach ($dateList as $startOfWeek) {
-                    $query->orWhere(function ($query) use ($startOfWeek) {
-                        $query->whereDate('created_at', $startOfWeek);
-                    });
-                }
-                $dataList = $query->groupBy('date_target')->get();
-                $dataList->each(function ($item) use ($unit) {
-                    $date = $item->date_target;
-                    $key = 'laborReportsCountingRecords_' . $date . '_' . $unit;
-                    Cache::put($key, $item, $this->ttl);
-                });
+                $str = "'%Y-%m-%d'";
                 break;
+
             case '月':
-                $query = LaborReport::query()->selectRaw("DATE_FORMAT(created_at,'%Y-%m') as date_target, count(DISTINCT enter_number ) as counter");
-                foreach ($dateList as $date) {
-                    $query->orWhere(function ($query) use ($date) {
-                        $year = Str::of($date)->explode('-')[0];
-                        $month = Str::of($date)->explode('-')[1];
-                        $query->whereYear('created_at', $year)->whereMonth('created_at', $month);
-                    });
-                }
-                $dataList = $query->groupBy('date_target')->get();
-                $dataList->each(function ($item) use ($unit) {
-                    $date = $item->date_target;
-                    $key = 'laborReportsCountingRecords_' . $date . '_' . $unit;
-                    Cache::put($key, $item, $this->ttl);
-                });
+                $str = "'%Y-%m'";
                 break;
             case '年':
-                $query = LaborReport::query()->selectRaw("DATE_FORMAT(created_at,'%Y') as date_target, count(DISTINCT enter_number ) as counter");
-                foreach ($dateList as $date) {
-                    $query->orWhere(function ($query) use ($date) {
-                        $year = Str::of($date)->explode('-')[0];
-                        $query->whereYear('created_at', $year)->whereYear('created_at', $year);
-                    });
-                }
-                $dataList = $query->groupBy('date_target')->get();
-                $dataList->each(function ($item) use ($unit) {
-                    $date = $item->date_target;
-                    $key = 'laborReportsCountingRecords_' . $date . '_' . $unit;
-                    Cache::put($key, $item, $this->ttl);
-                });
+                $str = "'%Y'";
                 break;
             default:
-                break;
+                $str = "'%Y-%m-%d'";
+        }
+        $queryBuilder = LaborReport::query()
+            ->selectRaw("DATE_FORMAT(created_at,{$str}) as date_target, count(DISTINCT enter_number ) as counter")
+            ->whereBetween('created_at', [$kvPairs['start'], $kvPairs['end']]);
+        if (!empty($kvPairs['userWorkgroupIds'])&&$kvPairs['userWorkgroupIds']!=='all') {
+            $user_workgroup_ids = array_filter(preg_split('/[,, ]+/is', $kvPairs['userWorkgroupIds']));
+            $queryBuilder->whereIn('user_workgroup_id', $user_workgroup_ids);
         }
+        return $queryBuilder->groupBy('date_target')->get();
     }
 }

+ 13 - 0
app/Services/OrderPackageRemarkService.php

@@ -0,0 +1,13 @@
+<?php 
+
+namespace App\Services;
+
+use App\Traits\ServiceAppAop;
+use App\OrderPackageRemark;
+
+class OrderPackageRemarkService
+{
+    use ServiceAppAop;
+    protected $modelClass=OrderPackageRemark::class;
+
+}

+ 58 - 22
app/Services/OwnerFeeTotalService.php

@@ -5,8 +5,10 @@ namespace App\Services;
 use App\OrderIssue;
 use App\Owner;
 use App\OwnerBillReport;
+use App\OwnerFeeOperation;
 use App\OwnerPriceOperation;
 use App\OwnerPriceOperationItem;
+use App\OwnerStoreOutFeeReport;
 use App\Traits\ServiceAppAop;
 use App\OwnerFeeTotal;
 use App\Traits\SettlementBillServiceTrait;
@@ -169,36 +171,70 @@ class OwnerFeeTotalService
                 'name' => $ownerStoragePriceModel->name,
                 'remark' => $remark,
                 'id' => $ownerStoragePriceModel->id,
-                'fee' => number_format($areaFeeService->getTotalFee($owner->id, $counting_month)->storage_fee ?? 0, 2),
+                'fee' => $areaFeeService->getTotalFee($owner->id, $counting_month)->storage_fee ?? 0,
                 'tax_fee' => $areaFeeService->getTotalFee($owner->id, $counting_month)->storage_tax_fee ?? 0
             ];
         }
-
         $ownerPriceOperationsGrouped = $owner->ownerPriceOperations->groupBy('operation_type');
-        /**@var $storeOutFeeDetailsService OwnerStoreOutFeeDetailService */
-        $storeOutFeeDetailsService = app('OwnerStoreOutFeeDetailService');
-        $workFeeTotalGrouped = $storeOutFeeDetailsService->getTotalFee($owner->id, $counting_month)->groupBy('owner_price_operation_id');
-
         //入库
+        $ownerStoreFeeReports = \App\OwnerStoreFeeReport::query()
+            ->selectRaw("
+            sum(fee) as fee,
+            sum(tax_fee) as tax_fee,
+            model_id
+            ")
+            ->where('counting_month', $counting_month)
+            ->where('owner_id', $owner->id)
+            ->groupBy('model_id')
+            ->get();
+        $ownerStoreFeeReportsGroupByModelId = $ownerStoreFeeReports->groupBy('model_id')->toArray();
+
         foreach ($ownerPriceOperationsGrouped['入库'] ?? [] as $ownerPriceOperationsGroupedItem) {
-            $information['storeFee'][] = [
-                'name' => $ownerPriceOperationsGroupedItem->name,
-                'remark' => $this->buildPriceRemarks($ownerPriceOperationsGroupedItem),
-                'id' => $ownerPriceOperationsGroupedItem->id,
-                'fee' => number_format($workFeeTotalGrouped[$ownerPriceOperationsGroupedItem->id][0]->work_fee ?? 0, 2),
-                'tax_fee' => $workFeeTotalGrouped[$ownerPriceOperationsGroupedItem->id][0]->work_tax_fee ?? 0,
-            ];
-        }
+            try {
+                $fee = $ownerStoreFeeReportsGroupByModelId[$ownerPriceOperationsGroupedItem->id][0]['fee'];
+            } catch (\Exception $e) {
+                $fee = $ownerStoreFeeReportsGroupByModelId[$ownerPriceOperationsGroupedItem->target_id][0]['fee'] ?? 0;
+                $ownerPriceOperationsGroupedItem = OwnerPriceOperation::query()->with(['items'])->find($ownerPriceOperationsGroupedItem->target_id);
+            }
+            if ($fee > 0) {
+                $information['storeFee'][] = [
+                    'name' => $ownerPriceOperationsGroupedItem->name,
+                    'remark' => $this->buildPriceRemarks($ownerPriceOperationsGroupedItem),
+                    'id' => $ownerPriceOperationsGroupedItem->id,
+                    'fee' => $fee,
+                    'tax_fee' => $ownerStoreFeeReportsGroupByModelId[$ownerPriceOperationsGroupedItem->id][0]['tax_fee'] ?? 0,
+                ];
+            }
 
+        }
         //出库
+        $ownerStoreOutFeeReports = OwnerStoreOutFeeReport::query()
+            ->selectRaw("
+            sum(fee) as fee,
+            sum(tax_fee) as tax_fee,
+            model_id
+            ")
+            ->where('counting_month', $counting_month)
+            ->where('owner_id', $owner->id)
+            ->groupBy('model_id')
+            ->get();
+        $ownerStoreOutFeeReportsGroupByModelId = $ownerStoreOutFeeReports->groupBy('model_id')->toArray();
         foreach ($ownerPriceOperationsGrouped['出库'] ?? [] as $ownerPriceOperationsGroupedItem) {
-            $information['storeOutFee'][] = [
-                'name' => $ownerPriceOperationsGroupedItem->name,
-                'remark' => $this->buildPriceRemarks($ownerPriceOperationsGroupedItem),
-                'id' => $ownerPriceOperationsGroupedItem->id,
-                'fee' => number_format($workFeeTotalGrouped[$ownerPriceOperationsGroupedItem->id][0]->work_fee ?? 0, 2),
-                'tax_fee' => number_format($workFeeTotalGrouped[$ownerPriceOperationsGroupedItem->id][0]->work_tax_fee ?? 0, 2),
-            ];
+            try {
+                $fee = $ownerStoreOutFeeReportsGroupByModelId[$ownerPriceOperationsGroupedItem->id][0]['fee'];
+            } catch (\Exception $e) {
+                $fee = $ownerStoreOutFeeReportsGroupByModelId[$ownerPriceOperationsGroupedItem->target_id][0]['fee'] ?? 0;
+                $ownerPriceOperationsGroupedItem = OwnerPriceOperation::query()->with(['items'])->find($ownerPriceOperationsGroupedItem->target_id);
+            }
+            if ($fee > 0) {
+                $information['storeOutFee'][] = [
+                    'name' => $ownerPriceOperationsGroupedItem->name,
+                    'remark' => $this->buildPriceRemarks($ownerPriceOperationsGroupedItem),
+                    'id' => $ownerPriceOperationsGroupedItem->id,
+                    'fee' => $fee,
+                    'tax_fee' => $ownerStoreOutFeeReportsGroupByModelId[$ownerPriceOperationsGroupedItem->id][0]['tax_fee'] ?? 0,
+                ];
+            }
         }
         return $information;
     }
@@ -389,7 +425,7 @@ class OwnerFeeTotalService
     private function calTaxRate($totalTaxFee, $totalFee, $ownerFeeTotal)
     {
         try {
-            $taxRate = number_format(($totalTaxFee / $totalFee) * 100, 2) ?? 0;
+            $taxRate = ($totalTaxFee / $totalFee) * 100 ?? 0;
         } catch (\Exception $e) {
             $taxRate = 0;
         }

+ 9 - 39
app/Services/OwnerLogisticFeeDetailService.php

@@ -4,6 +4,7 @@ namespace App\Services;
 
 use App\Logistic;
 use App\OwnerFeeDetail;
+use App\OwnerFeeExpress;
 use App\Traits\ServiceAppAop;
 use App\OwnerLogisticFeeDetail;
 use App\Traits\SettlementBillServiceTrait;
@@ -14,14 +15,15 @@ use Illuminate\Pagination\LengthAwarePaginator;
 class OwnerLogisticFeeDetailService implements \App\Interfaces\SettlementBillDetailInterface
 {
     use SettlementBillServiceTrait;
+
     const TYPE = '快递费-明细';
 
     use ServiceAppAop;
 
     /**
-     * @var $modelClass  OwnerLogisticFeeDetail
+     * @var $modelClass  OwnerFeeExpress
      */
-    protected $modelClass = OwnerLogisticFeeDetail::class;
+    protected $modelClass = OwnerFeeExpress::class;
 
 
     /**
@@ -31,15 +33,7 @@ class OwnerLogisticFeeDetailService implements \App\Interfaces\SettlementBillDet
      */
     public function get(array $kvPairs): LengthAwarePaginator
     {
-        $ownerLogisticFeeDetails = $this->getSql($kvPairs['owner_id'], $kvPairs['counting_month'])->paginate($kvPairs['paginateParams']['paginate'] ?? 50);
-        $items = $this->buildDetails($ownerLogisticFeeDetails);
-        return new LengthAwarePaginator(
-            $items,
-            $ownerLogisticFeeDetails->total(),
-            $ownerLogisticFeeDetails->perPage(),
-            $ownerLogisticFeeDetails->currentPage(),
-            ["path" => $ownerLogisticFeeDetails->path(), "pageName" => "page"]
-        );
+        return $this->getSql($kvPairs['owner_id'], $kvPairs['counting_month'])->paginate($kvPairs['paginateParams']['paginate'] ?? 50);
     }
 
     /**
@@ -50,37 +44,13 @@ class OwnerLogisticFeeDetailService implements \App\Interfaces\SettlementBillDet
     public function getSql($owner_id, $counting_month): Builder
     {
         list($start, $end) = $this->getStartAndEnd($counting_month);
-        return OwnerLogisticFeeDetail::query()->with([
-            'ownerFeeDetailLogistic:id,weight,logistic_fee,logistic_bill',
-            'logistic:id,name'
-        ])
-            ->where('owner_id',$owner_id)
-            ->whereBetween('created_at',[$start, $end])
+        return OwnerFeeExpress::query()
+            ->with(['province', 'logistic'])
+            ->where('owner_id', $owner_id)
+            ->whereBetween('created_at', [$start, $end])
             ->orderBy('logistic_id');
     }
 
-    /**
-     * @param  $ownerLogisticFeeDetails
-     * @return array
-     */
-    public function buildDetails($ownerLogisticFeeDetails): array
-    {
-        $items = [];
-        foreach ($ownerLogisticFeeDetails as $ownerLogisticFeeDetail) {
-            $items[] = [
-                'id' => $ownerLogisticFeeDetail->id,
-                'logistic_name' => $ownerLogisticFeeDetail->logistic->name ?? '',//快递公司
-                'province' => $ownerLogisticFeeDetail->province,//省份
-                'logistic_bill' => $ownerLogisticFeeDetail->logistic_bill ?? '',//快递单号
-                'weight' => $ownerLogisticFeeDetail->ownerFeeDetailLogistic->weight ?? $ownerLogisticFeeDetail->ownerFeeDetail->weight ?? '0.00',//重量
-                'initial_weight_price' => $ownerLogisticFeeDetail->initial_weight_price ?? '',//首重价格
-                'additional_price' => $ownerLogisticFeeDetail->additional_price ?? '',//续重价格
-                'logistic_fee' => $ownerLogisticFeeDetail->fee,//快递费
-            ];
-        }
-        return $items;
-    }
-
     public function switchType($type)
     {
     }

+ 27 - 28
app/Services/OwnerLogisticFeeReportService.php

@@ -4,6 +4,7 @@ namespace App\Services;
 
 use App\OwnerBillReport;
 use App\OwnerBillReportArchive;
+use App\OwnerFeeExpress;
 use App\OwnerLogisticFeeDetail;
 use App\Traits\ServiceAppAop;
 use App\OwnerLogisticFeeReport;
@@ -62,55 +63,53 @@ class OwnerLogisticFeeReportService implements \App\Interfaces\SettlementBillRep
         $this->confirmBillFeeTotal($counting_month, $owner_id);
     }
 
-
-    /**
-     * 生成报表数据
-     * 如果参数$counting_month为空 统计上一个月的
-     * 如果参数$counting_month为2021-01-01 则统计2021-01-01 -- 2021-01-31之间的数据
-     * @param null $counting_month 统计月份,默认统计上个月的 2021-05-01
-     */
     public function recordReport($counting_month = null)
     {
         if (is_null($counting_month)) {
             //默认统计上个月的数据
             $counting_month = now()->subMonth()->startOfMonth()->toDateTimeString();
         }
-        $this->reportDate = $counting_month;
-
-        $start = $this->reportDate;
-        $end = Carbon::parse($this->reportDate)->endOfMonth()->toDateTimeString();
-
-
-        $ownerLogisticFeeDetails = OwnerLogisticFeeDetail::query()
-            ->selectRaw("logistic_id,
-            province,
-            DATE_FORMAT(created_at,
-            '%Y-%m') as counted_date,
+        list($start, $end) = $this->getStartAndEnd($counting_month);
+        $ownerLogisticFeeDetails = OwnerFeeExpress::query()
+            ->selectRaw("
+            province_id,
+            logistic_id,
+            DATE_FORMAT(created_at,'%Y-%m') as counted_date,
             initial_weight,
             initial_weight_price,
             count(1) as initial_amount,
-            additional_price,
+            additional_weight_price,
             additional_weight,
-            sum(additional_weigh_weight) as additional_amount,
-            sum(tax_fee) as tax_fee,
-            sum(fee) as fee,
+            sum(additional_weight_amount) as additional_amount,
+            sum(total_fee*tax_rate) as tax_fee,
+            sum(total_fee) as fee,
+            sum(total_fee) as fee,
             created_at,
             owner_id")
             ->whereBetween('created_at', [$start, $end])
-            ->groupBy('initial_weight', 'initial_weight_price', 'additional_price', 'additional_weight', 'logistic_id', 'province', 'counted_date', 'owner_id')
+            ->groupBy(
+                'initial_weight',
+                'initial_weight_price',
+                'additional_weight_price',
+                'additional_weight',
+                'logistic_id',
+                'province_id',
+                'counted_date',
+                'owner_id')
             ->get();
+
         $ownerLogisticFeeReportArray = [];
 
         foreach ($ownerLogisticFeeDetails as $ownerLogisticFeeDetail) {
             $ownerLogisticFeeReportArray[] = [
                 'logistic_id' => $ownerLogisticFeeDetail->logistic_id,
-                'province' => $ownerLogisticFeeDetail->province,
+                'province_id' => $ownerLogisticFeeDetail->province_id,
                 'counted_date' => Carbon::parse($ownerLogisticFeeDetail->counted_date)->firstOfMonth()->toDateString(),
                 'initial_weight' => $ownerLogisticFeeDetail->initial_weight,
                 'initial_weight_price' => $ownerLogisticFeeDetail->initial_weight_price,
                 'initial_amount' => $ownerLogisticFeeDetail->initial_amount,
                 'additional_weight' => $ownerLogisticFeeDetail->additional_weight,
-                'additional_price' => $ownerLogisticFeeDetail->additional_price,
+                'additional_price' => $ownerLogisticFeeDetail->additional_weight_price,
                 'additional_amount' => $ownerLogisticFeeDetail->additional_amount,
                 'fee' => $ownerLogisticFeeDetail->fee,
                 'tax_fee' => $ownerLogisticFeeDetail->tax_fee,
@@ -119,10 +118,10 @@ class OwnerLogisticFeeReportService implements \App\Interfaces\SettlementBillRep
         }
         //保证接口幂等性 删除统计月的数据
         OwnerLogisticFeeReport::query()->where('counted_date', $counting_month)->delete();
-
         OwnerLogisticFeeReport::query()->insertOrIgnore($ownerLogisticFeeReportArray);
     }
 
+
     /**
      * 订单统计分页查询
      * @param $owner_id
@@ -193,11 +192,11 @@ class OwnerLogisticFeeReportService implements \App\Interfaces\SettlementBillRep
     public function getSql($owner_id, $counting_month): Builder
     {
         return OwnerLogisticFeeReport::query()
-            ->with('logistic:id,name')
+            ->with(['logistic:id,name','province'])
             ->where('owner_id', $owner_id)
             ->where('counted_date', $counting_month)
             ->orderByDesc('logistic_id')
-            ->orderByDesc('province');
+            ->orderByDesc('province_id');
     }
 
     /**

+ 4 - 2
app/Services/OwnerProcessSettlementBillService.php

@@ -6,6 +6,7 @@ use App\Interfaces\SettlementBillDetailInterface;
 use App\OwnerFeeDetail;
 use App\Traits\ServiceAppAop;
 use Illuminate\Database\Eloquent\Builder;
+use Illuminate\Support\Facades\DB;
 
 class OwnerProcessSettlementBillService implements SettlementBillDetailInterface
 {
@@ -62,10 +63,11 @@ class OwnerProcessSettlementBillService implements SettlementBillDetailInterface
     public function getTotalFee($owner_id, $counting_month)
     {
         list($start, $end) = $this->getStartAndEnd($counting_month);
-        return \Illuminate\Support\Facades\DB::table('owner_fee_details')
+        return DB::table('owner_fee_details')
             ->selectRaw("sum(work_fee) as fee,sum(work_tax_fee) as tax_fee")
             ->where('owner_id', $owner_id)
-            ->whereBetween('created_at', [$start, $end])
+            ->whereBetween('worked_at', [$start, $end])
+            ->where('outer_table_name','processes')
             ->first();
     }
 

+ 10 - 7
app/Services/OwnerStoreFeeDetailService.php

@@ -2,6 +2,8 @@
 
 namespace App\Services;
 
+use App\OwnerFeeOperation;
+use App\OwnerPriceOperation;
 use App\Traits\ServiceAppAop;
 use App\OwnerStoreFeeDetail;
 use App\Traits\SettlementBillTrait;
@@ -20,7 +22,6 @@ class OwnerStoreFeeDetailService
     public function get(array $kvPairs): \Illuminate\Contracts\Pagination\LengthAwarePaginator
     {
         return $this->getSql($kvPairs['counting_month'], $kvPairs['owner_id'])->paginate($kvPairs['paginateParams']['paginate'] ?? 50);
-
     }
 
 
@@ -32,12 +33,14 @@ class OwnerStoreFeeDetailService
     public function getSql($counting_month, $owner_id): Builder
     {
         list($start, $end) = $this->getStartAndEnd($counting_month);
-        return OwnerStoreFeeDetail::query()
-            ->with([
-                'ownerFeeDetail:id,worked_at',
-                'commodity:id,name',
-             ])
-            ->whereBetween('created_at', [$start, $end])
+
+        $OwnerPriceOperationQuery = OwnerPriceOperation::query()
+            ->select('id')
+            ->where('operation_type', '入库');
+        return OwnerFeeOperation::query()
+            ->with(['details','model','commodity.barcodes'])
+            ->whereIn('model_id', $OwnerPriceOperationQuery)
+            ->whereBetween('worked_at', [$start, $end])
             ->where('owner_id', $owner_id);
     }
 

+ 23 - 18
app/Services/OwnerStoreFeeReportService.php

@@ -38,29 +38,32 @@ class OwnerStoreFeeReportService implements \App\Interfaces\SettlementBillReport
             //默认统计上个月的数据
             $counting_month = now()->subMonth()->startOfMonth()->toDateString();
         }
-        $this->reportDate = $counting_month;
-
-        $start = $this->reportDate;
-        $end = Carbon::parse($this->reportDate)->endOfMonth()->toDateString();
+        list($start, $end) = $this->getStartAndEnd($counting_month);
         $details =
-            DB::table('owner_store_fee_details')
+            DB::table('owner_fee_operations')
+                ->leftJoin('owner_fee_operation_details','owner_fee_operations.id','=','owner_fee_operation_details.owner_fee_operation_id')
+                ->leftJoin('owner_price_operations','owner_fee_operations.model_id','=','owner_price_operations.id')
                 ->selectRaw("
-                DATE_FORMAT(owner_store_fee_details.created_at,'%Y-%m') as counting_month,
-                unit_id,
-                unit_price,
-                work_name,
-                sum(amount) as amounts ,
-                owner_store_fee_details.owner_id,
-                owner_fee_detail_id,
-                sum(owner_store_fee_details.fee) as fee
+                DATE_FORMAT(owner_fee_operations.worked_at,'%Y-%m') as counting_month,
+                owner_fee_operation_details.unit_id,
+                owner_fee_operation_details.price,
+                owner_price_operations.name,
+                sum(owner_fee_operation_details.amount) as amounts ,
+                owner_fee_operations.owner_id,
+                owner_fee_operations.model_id,
+                sum(owner_fee_operation_details.price*owner_fee_operation_details.amount) as fee,
+                sum(owner_fee_operation_details.price*owner_fee_operation_details.amount*owner_fee_operations.tax_rate) as tax_fee
                 ")
-                ->whereBetween('owner_store_fee_details.created_at', [$start, $end])
+                ->whereBetween('owner_fee_operations.worked_at', [$start, $end])
+                ->whereNotNull('owner_fee_operation_details.price')
+                ->whereNotNull('owner_fee_operation_details.amount')
+                ->whereIn('model_id',\App\OwnerPriceOperation::query()->select('id')->where('operation_type','入库'))
                 ->groupBy(
                     'counting_month',
                     'owner_id',
                     'unit_id',
-                    'unit_price',
-                    'work_name'
+                    'price',
+                    'model_id'
                 )
                 ->get();
         $reports = [];
@@ -75,10 +78,12 @@ class OwnerStoreFeeReportService implements \App\Interfaces\SettlementBillReport
                 'owner_id' => $detail->owner_id,
                 'counting_month' => $counting_month,
                 'unit_id' => $detail->unit_id,
-                'unit_price' => $detail->unit_price,
+                'unit_price' => $detail->price,
                 'amount' => $detail->amounts,
                 'fee' => $detail->fee,
-                'work_name' => $detail->work_name,
+                'work_name' => $detail->name,
+                'model_id' => $detail->model_id,
+                'tax_fee' => $detail->tax_fee,
             ];
         }
         $reports_chunked = array_chunk($reports, 1000);

+ 11 - 7
app/Services/OwnerStoreOutFeeDetailService.php

@@ -4,6 +4,8 @@ namespace App\Services;
 
 use App\Interfaces\SettlementBillDetailInterface;
 use App\OwnerFeeDetail;
+use App\OwnerFeeOperation;
+use App\OwnerPriceOperation;
 use App\Traits\ServiceAppAop;
 use App\OwnerStoreOutFeeDetail;
 use App\Traits\SettlementBillServiceTrait;
@@ -33,13 +35,15 @@ class OwnerStoreOutFeeDetailService implements SettlementBillDetailInterface
     public function getSql($owner_id, $counting_month): Builder
     {
         list($start, $end) = $this->getStartAndEnd($counting_month);
-        return OwnerStoreOutFeeDetail::query()
-            ->with([
-                'commodity:id,name,sku',
-                'ownerFeeDetail:id,worked_at,operation_bill,work_fee'
-            ])
-            ->where('owner_id', $owner_id)
-            ->whereBetween('created_at', [$start, $end]);
+
+        $OwnerPriceOperationQuery = OwnerPriceOperation::query()
+            ->select('id')
+            ->where('operation_type', '出库');
+        return OwnerFeeOperation::query()
+            ->with(['details','model','commodity.barcodes'])
+            ->whereIn('model_id', $OwnerPriceOperationQuery)
+            ->whereBetween('worked_at', [$start, $end])
+            ->where('owner_id', $owner_id);
     }
 
     public function switchType($type)

+ 40 - 36
app/Services/OwnerStoreOutFeeReportService.php

@@ -6,10 +6,12 @@ use App\Interfaces\SettlementBillReportInterface;
 use App\OwnerBillReport;
 use App\OwnerBillReportArchive;
 use App\OwnerFeeDetail;
+use App\OwnerPriceOperation;
 use App\OwnerStoreFeeReport;
 use App\OwnerStoreOutFeeDetail;
 use App\Traits\ServiceAppAop;
 use App\OwnerStoreOutFeeReport;
+use App\Traits\SettlementBillServiceTrait;
 use Carbon\Carbon;
 use Illuminate\Database\Eloquent\Builder;
 use Illuminate\Support\Facades\DB;
@@ -20,46 +22,47 @@ class OwnerStoreOutFeeReportService implements SettlementBillReportInterface
 
     use ServiceAppAop;
 
-    use \App\Traits\SettlementBillServiceTrait;
+    use SettlementBillServiceTrait;
 
     protected $modelClass = OwnerStoreOutFeeReport::class;
-    /** @var $detailService OwnerBillReportArchiveService */
+    /** @var $archiveService OwnerBillReportArchiveService */
     private $archiveService;
 
-    /** @var $detailService OwnerStoreOutFeeDetailService */
-    private $detailService;
 
     public function recordReport($counting_month = null)
     {
-        $this->detailService = app('OwnerStoreOutFeeDetailService');
         if (is_null($counting_month)) {
             //默认统计上个月的数据
             $counting_month = now()->subMonth()->startOfMonth()->toDateString();
         }
-        $this->reportDate = $counting_month;
-        $start = $this->reportDate;
-        $end = Carbon::parse($this->reportDate)->endOfMonth()->toDateString();
-        $details = OwnerStoreOutFeeDetail::query()
-            ->selectRaw("
-                DATE_FORMAT(owner_store_out_fee_details.created_at,'%Y-%m') as counting_month,
-                step,
-                unit_id,
-                unit_price,
-                sum(amount) as  amount ,
-                sum(fee) as  fee ,
-                owner_id,
-                work_name
-            ")
-            ->whereBetween('created_at', [$start, $end])
-            ->groupBy(
-                'counting_month',
-                'step',
-                'unit_id',
-                'unit_price',
-                'owner_id',
-                'work_name'
-            )->get();
-
+        list($start, $end) = $this->getStartAndEnd($counting_month);
+        $details =
+            DB::table('owner_fee_operations')
+                ->leftJoin('owner_fee_operation_details','owner_fee_operations.id','=','owner_fee_operation_details.owner_fee_operation_id')
+                ->leftJoin('owner_price_operations','owner_fee_operations.model_id','=','owner_price_operations.id')
+                ->selectRaw("
+                DATE_FORMAT(owner_fee_operations.worked_at,'%Y-%m') as counting_month,
+                owner_fee_operation_details.unit_id,
+                owner_fee_operation_details.price,
+                owner_price_operations.name,
+                sum(owner_fee_operation_details.amount) as amounts ,
+                owner_fee_operations.owner_id,
+                owner_fee_operations.model_id,
+                sum(owner_fee_operation_details.price*owner_fee_operation_details.amount) as fee,
+                sum(owner_fee_operation_details.price*owner_fee_operation_details.amount*owner_fee_operations.tax_rate) as tax_fee
+                ")
+                ->whereBetween('owner_fee_operations.worked_at', [$start, $end])
+                ->whereNotNull('owner_fee_operation_details.price')
+                ->whereNotNull('owner_fee_operation_details.amount')
+                ->whereIn('model_id', OwnerPriceOperation::query()->select('id')->where('operation_type','出库'))
+                ->groupBy(
+                    'counting_month',
+                    'owner_id',
+                    'unit_id',
+                    'price',
+                    'model_id'
+                )
+                ->get();
         $reports = [];
         foreach ($details as $detail) {
             $counting_month = Carbon::parse($detail->counting_month)->startOfMonth()->toDateString();
@@ -71,20 +74,21 @@ class OwnerStoreOutFeeReportService implements SettlementBillReportInterface
                 'owner_bill_report_id' => $ownerBillReport->id ?? null,
                 'owner_id' => $detail->owner_id,
                 'counting_month' => $counting_month,
-                'step' => $detail->step,
                 'unit_id' => $detail->unit_id,
-                'unit_price' => $detail->unit_price,
-                'amount' => $detail->amount,
+                'unit_price' => $detail->price,
+                'amount' => $detail->amounts,
                 'fee' => $detail->fee,
-                'work_name' => $detail->work_name,
+                'work_name' => $detail->name,
+                'model_id' => $detail->model_id,
+                'tax_fee' => $detail->tax_fee,
             ];
         }
-
+        $reports_chunked = array_chunk($reports, 1000);
         //保证幂等性 插入前删除该月的统计数据
         OwnerStoreOutFeeReport::query()->where('counting_month', $counting_month)->delete();
 
-        foreach (array_chunk($reports, 1000) as $reports_chunked) {
-            OwnerStoreOutFeeReport::query()->insertOrIgnore($reports_chunked);
+        foreach ($reports_chunked as $items) {
+            OwnerStoreOutFeeReport::query()->insertOrIgnore($items);
         }
     }
 

+ 27 - 24
app/Services/OwnerWaybillSettlementBillService.php

@@ -3,6 +3,7 @@
 namespace App\Services;
 
 use App\OwnerFeeDetail;
+use App\OwnerFeeLogistic;
 use App\Traits\ServiceAppAop;
 use App\Waybill;
 use Illuminate\Database\Eloquent\Builder;
@@ -30,10 +31,10 @@ class OwnerWaybillSettlementBillService implements \App\Interfaces\SettlementBil
     public function getSql($owner_id, $counting_month): Builder
     {
         list($start, $end) = $this->getStartAndEnd($counting_month);
-        return Waybill::query()
+        return OwnerFeeLogistic::query()
             ->where('owner_id', $owner_id)
             ->whereBetween('created_at', [$start, $end])
-            ->with(['ownerWayBillFeeDetail', 'logistic', 'warehouseWeightUnit', 'originationCity', 'destinationCity']);
+            ->with(['province', 'logistic', 'city','unit']);
     }
 
     public function switchType($type)
@@ -47,24 +48,24 @@ class OwnerWaybillSettlementBillService implements \App\Interfaces\SettlementBil
         foreach ($details as $detail) {
             $results[] = [
                 $detail->logistic->name ?? '',
-                $detail->order_id ?? '',
-                $detail->recipient ?? '',
-                $detail->recipient_mobile ?? '',
-                $detail->warehouse_weight ?? '',
-                $detail->warehouseWeightUnit->name ?? '',
-                $detail->ownerWayBillFeeDetail->step ?? '',
-                $detail->ownerWayBillFeeDetail->ownerFeeDetail->province ?? '',
-                $detail->destination_city->name ?? '',
-                $detail->ownerWayBillFeeDetail->price ?? '',
-                $detail->ownerWayBillFeeDetail->delivery_fee ?? '',
-                $detail->pick_up_fee ?? '',
-                $detail->ownerWayBillFeeDetail->fuel_fee ?? '',
-                $detail->ownerWayBillFeeDetail->service_fee ?? '',
+                $detail->order_number ?? '',
+                $detail->recipient_name ?? '',
+                $detail->recipient_phone ?? '',
+                $detail->quantity ?? '',
+                $detail->unit->name ?? '',
+                $detail->interval ?? '',
+                $detail->province->name ?? '',
+                $detail->city->name ?? '',
+                $detail->price ?? '',
+                $detail->delivery_fee ?? '',
+                $detail->pick_fee ?? '',
+                $detail->fuel_fee ?? '',
+                $detail->info_fee ?? '',
                 $detail->other_fee ?? '',
-                $detail->dispatch_remark ?? '',
-                $detail->ownerWayBillFeeDetail->originate_fee ?? '',
-                $detail->ownerWayBillFeeDetail->originate_count ?? '',
-                $detail->ownerWayBillFeeDetail->ownerFeeDetail->logistic_fee ?? '',
+                $detail->remark ?? '',
+                $detail->initial_fee ?? '',
+                $detail->initial_amount ?? '',
+                $detail->total_fee ?? '',
             ];
         }
         return $results;
@@ -78,11 +79,13 @@ class OwnerWaybillSettlementBillService implements \App\Interfaces\SettlementBil
     public function getTotalFee($owner_id, $counting_month)
     {
         list($start, $end) = $this->getStartAndEnd($counting_month);
-        return DB::table('owner_way_bill_fee_details')
-            ->selectRaw("sum(owner_fee_details.logistic_fee) as fee,sum(owner_fee_details.logistic_tax_fee) as tax_fee")
-            ->leftJoin('owner_fee_details', 'owner_way_bill_fee_details.owner_fee_detail_id', '=', 'owner_fee_details.id')
-            ->whereBetween('owner_way_bill_fee_details.created_at', [$start, $end])
-            ->where('owner_fee_details.owner_id',$owner_id)
+        return OwnerFeeLogistic::query()
+            ->selectRaw("
+            sum(total_fee) as fee,
+            sum(tax_rate*total_fee) as tax_fee
+            ")
+            ->where('owner_id', $owner_id)
+            ->whereBetween('created_at', [$start, $end])
             ->first();
     }
 }

+ 1 - 0
config/api_logistic.php

@@ -2,6 +2,7 @@
 return [
     'logistic' => [
         'ZTO' => 'ZTO',
+        'ZTO-1' => 'ZTO',
         'SF' => 'SF',
         'YUNDA' => 'YUNDA',
         'STO' => 'STO',

+ 12 - 0
database/factories/OrderPackageRemarkFactory.php

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

+ 26 - 0
database/factories/OwnerFeeExpressFactory.php

@@ -0,0 +1,26 @@
+<?php
+
+/** @var \Illuminate\Database\Eloquent\Factory $factory */
+
+use App\OwnerFeeExpress;
+use Faker\Generator as Faker;
+
+$factory->define(OwnerFeeExpress::class, function (Faker $faker) {
+
+    $created_at = now()->subMonth()->startOfMonth()->addDays(random_int(1, 28));
+    return [
+        "province_id" => random_int(1, 30),
+        "logistic_id" => random_int(1, 10),
+        "logistic_number" => $faker->uuid,
+        "weight" => random_int(1, 100),
+        "initial_weight" => random_int(1, 100),
+        "initial_weight_price" => random_int(1, 100),
+        "additional_weight" => random_int(1, 100),
+        "additional_weight_amount" => random_int(1, 100),
+        "additional_weight_price" => random_int(1, 100),
+        "total_fee" => random_int(1, 100),
+        "tax_rate" => random_int(1, 100),
+        "created_at" => $created_at,
+        "owner_id" => random_int(1, 100),
+    ];
+});

+ 36 - 0
database/factories/OwnerFeeLogisticFactory.php

@@ -0,0 +1,36 @@
+<?php
+
+/** @var \Illuminate\Database\Eloquent\Factory $factory */
+
+use App\Model;
+use App\OwnerFeeLogistic;
+use Faker\Generator as Faker;
+
+$factory->define(OwnerFeeLogistic::class, function (Faker $faker) {
+    $interval = ['0-10000','10000-20000','20000-50000'];
+    $created_at = now()->subMonth()->startOfMonth()->addDays(random_int(1, 28));
+    return [
+        "province_id"=>random_int(1,10),
+        "owner_id"=>random_int(1,10),
+        "city_id"=>random_int(1,10),
+        "logistic_id"=>random_int(1,10),
+        "order_number"=>random_int(1000000,9999999),
+        "recipient_name"=>$faker->name,
+        "recipient_phone"=>$faker->phoneNumber,
+        "quantity"=>random_int(1,100),
+        "unit_id"=>random_int(1,5),
+        "interval"=>$faker->randomElement($interval),
+        "price"=>random_int(1,100),
+        "delivery_fee"=>random_int(1,100),
+        "pick_fee"=>random_int(1,100),
+        "fuel_fee"=>random_int(1,100),
+        "info_fee"=>random_int(1,100),
+        "other_fee"=>random_int(1,100),
+        "initial_fee"=>random_int(1,100),
+        "initial_amount"=>random_int(1,100),
+        "total_fee"=>random_int(1,100),
+        "tax_rate"=>random_int(1,100),
+        "remark"=>$faker->sentence,
+        "created_at"=>$created_at,
+    ];
+});

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

@@ -0,0 +1,32 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class ChangeProvinceToProvinceIdToOwnerLogisticFeeReportsTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('owner_logistic_fee_reports', function (Blueprint $table) {
+            $table->renameColumn('province', 'province_id');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('owner_logistic_fee_reports', function (Blueprint $table) {
+            $table->renameColumn('province_id', 'province');
+        });
+    }
+}

+ 34 - 0
database/migrations/2021_08_17_112816_add_column_model_id_to_owner_store_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 AddColumnModelIdToOwnerStoreFeeReportsTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('owner_store_fee_reports', function (Blueprint $table) {
+            $table->integer('model_id')->comment('计费模型ID');
+            $table->integer('tax_fee')->comment('税费');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('owner_store_fee_reports', function (Blueprint $table) {
+            $table->dropColumn('model_id');
+            $table->dropColumn('tax_fee');
+        });
+    }
+}

+ 34 - 0
database/migrations/2021_08_17_112924_add_column_model_id_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 AddColumnModelIdToOwnerStoreOutFeeReportsTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('owner_store_out_fee_reports', function (Blueprint $table) {
+            $table->integer('model_id')->comment('计费模型ID');
+            $table->integer('tax_fee')->comment('税费');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('owner_store_out_fee_reports', function (Blueprint $table) {
+            $table->dropColumn('model_id');
+            $table->dropColumn('tax_fee');
+        });
+    }
+}

+ 50 - 0
database/migrations/2021_08_18_111331_add_column_sync_routes_flag_to_order_packages_table.php

@@ -0,0 +1,50 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class AddColumnSyncRoutesFlagToOrderPackagesTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('order_packages', function (Blueprint $table) {
+            $table->boolean('sync_routes_flag')->default(false)->comment('是否有同步过信息');
+
+            $table->dropIndex('order_packages_sent_at_exception_index');
+            $table->dropIndex('order_packages_received_at_exception_index');
+            $table->dropIndex('order_packages_logistic_number_index');
+            $table->dropIndex('order_packages_sent_at_exception_type_owner_id_index');
+
+            $table->index(['sent_at','order_id','exception','exception_type','status','received_at','sync_routes_flag'],'order_packages_express_index');
+
+            $table->dropColumn('remark');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('order_packages', function (Blueprint $table) {
+            $table->dropColumn('sync_routes_flag');
+
+            $table->index(['sent_at', 'exception']);
+            $table->index(['received_at', 'exception']);
+            $table->index('logistic_number');
+            $table->index(['sent_at','exception_type','owner_id']);
+
+            $table->dropIndex('order_packages_express_index');
+
+            $table->text('remark')->comment('客服备注');
+        });
+    }
+}

+ 35 - 0
database/migrations/2021_08_18_141408_create_order_package_remarks_table.php

@@ -0,0 +1,35 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class CreateOrderPackageRemarksTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('order_package_remarks', function (Blueprint $table) {
+            $table->id();
+            $table->integer('order_package_id')->index();
+            $table->integer('user_id')->index();
+            $table->string('content')->comment('内容');
+            $table->softDeletes();
+            $table->timestamps();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('order_package_remarks');
+    }
+}

+ 16 - 0
database/seeds/OrderPackageRemarkSeeder.php

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

+ 21 - 0
database/seeds/OwnerFeeExpressSeeder.php

@@ -0,0 +1,21 @@
+<?php
+
+use App\OwnerFeeExpress;
+use Illuminate\Database\Seeder;
+
+class OwnerFeeExpressSeeder extends Seeder
+{
+    /**
+     * Run the database seeds.
+     *
+     * @return void
+     */
+    public function run()
+    {
+        OwnerFeeExpress::query()->truncate();
+        $owners = \App\Owner::query()->limit(10)->get();
+        foreach ($owners as $owner) {
+            factory(OwnerFeeExpress::class)->times(100)->create(['owner_id' => $owner->id]);
+        }
+    }
+}

+ 21 - 0
database/seeds/OwnerFeeLogisticSeeder.php

@@ -0,0 +1,21 @@
+<?php
+
+use App\OwnerFeeLogistic;
+use Illuminate\Database\Seeder;
+
+class OwnerFeeLogisticSeeder extends Seeder
+{
+    /**
+     * Run the database seeds.
+     *
+     * @return void
+     */
+    public function run()
+    {
+        OwnerFeeLogistic::query()->truncate();
+        $owners = \App\Owner::query()->limit(10)->get();
+        foreach ($owners as $owner) {
+            factory(OwnerFeeLogistic::class)->times(100)->create(['owner_id' => $owner->id]);
+        }
+    }
+}

+ 1 - 2
database/seeds/SettlementBillSeeder.php

@@ -24,8 +24,7 @@ class SettlementBillSeeder extends Seeder
             //快递费合计
             SettlementBillExpressFeeReportSeeder::class,
             //快递费明细
-            SettlementBillExpressFeeDetailSeeder::class,
-
+            OwnerFeeExpressSeeder::class,
             //入库费明细
             OwnerStoreFeeDetailSeeder::class,
             //入库费合计

+ 211 - 128
resources/views/control/panel.blade.php

@@ -156,25 +156,27 @@
                     <div class="card">
                         <div class="card-header">
                             <div class="block row">
-                                    <span class="demonstration"></span>
-                                    <el-date-picker
-                                        size="small"
-                                        style="width: 60%;"
-                                        @blur="logisticsCountingRecordsApi()"
-                                        v-model="logisticsCountingRecordsData"
-                                        type="daterange"
-                                        align="right"
-                                        unlink-panels
-                                        range-separator="-"
-                                        start-placeholder="开始日期"
-                                        end-placeholder="结束日期"
-                                        value-format="yyyy-MM-dd"
-                                        :picker-options="pickerOptions">
-                                    </el-date-picker>
-                                    <el-select  placeholder="请选择对应货主" multiple v-model="selectLogisticsOwners" size="small" style="width: 50%"  @change="logisticsCountingRecordsApi('')">
-                                        <el-option label="选择所有" value="all"></el-option>
-                                        <el-option v-for="item in owners" :label="item.name" :value="item.id" :key="item.id"></el-option>
-                                    </el-select>
+                                <span class="demonstration"></span>
+                                <el-date-picker
+                                    size="small"
+                                    style="width: 60%;"
+                                    @blur="logisticsCountingRecordsApi()"
+                                    v-model="logisticsCountingRecordsData"
+                                    type="daterange"
+                                    align="right"
+                                    unlink-panels
+                                    range-separator="-"
+                                    start-placeholder="开始日期"
+                                    end-placeholder="结束日期"
+                                    value-format="yyyy-MM-dd"
+                                    :picker-options="pickerOptions">
+                                </el-date-picker>
+                                <el-select placeholder="请选择对应货主" multiple v-model="selectLogisticsOwners" size="small"
+                                           style="width: 50%" @change="logisticsCountingRecordsApi('')">
+                                    <el-option label="选择所有" value="all"></el-option>
+                                    <el-option v-for="item in owners" :label="item.name" :value="item.id"
+                                               :key="item.id"></el-option>
+                                </el-select>
                             </div>
                         </div>
                         <div class="card-body row">
@@ -205,7 +207,7 @@
                             </div>
                         </div>
                         <div class="card-body row">
-                            <div  id="warehouseCountingRecords" class="col-12"
+                            <div id="warehouseCountingRecords" class="col-12"
                                  style=min-height:500px;"></div>
 
                         </div>
@@ -302,6 +304,16 @@
                                                    v-model="laborReportsCountingRecordUnit">年
                                         </el-button>
                                     </div>
+
+                                    <div class="ml-2">
+                                        <el-select placeholder="请选择对应仓库组" multiple v-model="selectUserGroups"
+                                                   size="small"
+                                                   @change="laborReportsCountingRecordApi('')">
+                                            <el-option label="选择所有" value="all"></el-option>
+                                            <el-option v-for="item in userWorkgroups" :label="item.name" :value="item.id"
+                                                       :key="item.id"></el-option>
+                                        </el-select>
+                                    </div>
                                 </div>
                             </div>
                             <div class="card-body row">
@@ -330,7 +342,7 @@
                                 </el-date-picker>
                             </div>
                             <div class="card-body row">
-                                <div  id="laborReportsUserGroupsCount"
+                                <div id="laborReportsUserGroupsCount"
                                      class="col-12"
                                      style="min-height:500px;"></div>
                             </div>
@@ -340,33 +352,35 @@
             </div>
             <div class="row my-3">
                 @can("控制台-称重统计")
-                <div class="col-6">
-                    <div class="card">
-                        <div class="card-header">
-                            <div class="row">
-                                <el-date-picker size="small" class="col-4 date" @blur="loadWeightInfo()"
-                                                type="daterange" align="right"
-                                                v-model="searchOption.weightDate" unlink-panels range-separator="-"
-                                                start-placeholder="开始日期" end-placeholder="结束日期"
-                                                value-format="yyyy-MM-dd">
-                                </el-date-picker>
-                                <label class="col-3">
-                                    <select class="form-control rounded" v-model="searchOption.weightSelect"
-                                            @change="switchWeightDate()">
-                                        <option v-for="(date,i) in dateOptions" :value="i">@{{ date.text }}</option>
-                                    </select>
-                                </label>
-                                <el-select class="col-3"  placeholder="请选择对应货主" multiple v-model="selectWeightOwners" size="small" style="width: 50%"  @change="loadWeightInfo()">
-                                    <el-option label="选择所有" value="all"></el-option>
-                                    <el-option v-for="item in owners" :label="item.name" :value="item.id" :key="item.id"></el-option>
-                                </el-select>
+                    <div class="col-6">
+                        <div class="card">
+                            <div class="card-header">
+                                <div class="row">
+                                    <el-date-picker size="small" class="col-4 date" @blur="loadWeightInfo()"
+                                                    type="daterange" align="right"
+                                                    v-model="searchOption.weightDate" unlink-panels range-separator="-"
+                                                    start-placeholder="开始日期" end-placeholder="结束日期"
+                                                    value-format="yyyy-MM-dd">
+                                    </el-date-picker>
+                                    <label class="col-3">
+                                        <select class="form-control rounded" v-model="searchOption.weightSelect"
+                                                @change="switchWeightDate()">
+                                            <option v-for="(date,i) in dateOptions" :value="i">@{{ date.text }}</option>
+                                        </select>
+                                    </label>
+                                    <el-select class="col-3" placeholder="请选择对应货主" multiple v-model="selectWeightOwners"
+                                               size="small" style="width: 50%" @change="loadWeightInfo()">
+                                        <el-option label="选择所有" value="all"></el-option>
+                                        <el-option v-for="item in owners" :label="item.name" :value="item.id"
+                                                   :key="item.id"></el-option>
+                                    </el-select>
+                                </div>
+                            </div>
+                            <div class="card-body row">
+                                <div id="weight" class="col-12" style="min-height: 500px"></div>
                             </div>
-                        </div>
-                        <div class="card-body row">
-                            <div id="weight" class="col-12" style="min-height: 500px"></div>
                         </div>
                     </div>
-                </div>
                 @endcan
                 {{--异常分布图--}}
                 <div class="col-6">
@@ -375,13 +389,17 @@
                             <div class="flex-column">
                                 <el-date-picker size="small" class="col-6 date" @blur="loadExceptionTypeInfo()"
                                                 type="daterange" align="right"
-                                                v-model="searchOption.exceptionTypeDate" unlink-panels range-separator="-"
+                                                v-model="searchOption.exceptionTypeDate" unlink-panels
+                                                range-separator="-"
                                                 start-placeholder="开始日期" end-placeholder="结束日期"
                                                 value-format="yyyy-MM-dd">
                                 </el-date-picker>
-                                <el-select class="col-3"  placeholder="请选择对应货主" multiple v-model="selectExceptionTypeOwners" size="small" style="width: 20%"  @change="loadExceptionTypeInfo()">
+                                <el-select class="col-3" placeholder="请选择对应货主" multiple
+                                           v-model="selectExceptionTypeOwners" size="small" style="width: 20%"
+                                           @change="loadExceptionTypeInfo()">
                                     <el-option label="选择所有" value="all"></el-option>
-                                    <el-option v-for="item in owners" :label="item.name" :value="item.id" :key="item.id"></el-option>
+                                    <el-option v-for="item in owners" :label="item.name" :value="item.id"
+                                               :key="item.id"></el-option>
                                 </el-select>
                                 <label class="col-3 ">
                                     <select class="form-control rounded" v-model="searchOption.exceptionTypeSelect"
@@ -403,14 +421,17 @@
                     <div class="card">
                         <div class="card-header">
                             <div class="row">
-                                <el-date-picker size="small" class="col-6 date" @blur="loadOrderPackageReceivedSyncRecordInfo()"
+                                <el-date-picker size="small" class="col-6 date"
+                                                @blur="loadOrderPackageReceivedSyncRecordInfo()"
                                                 type="daterange" align="right"
-                                                v-model="searchOption.OrderPackageReceivedSyncRecordDate" unlink-panels range-separator="-"
+                                                v-model="searchOption.OrderPackageReceivedSyncRecordDate" unlink-panels
+                                                range-separator="-"
                                                 start-placeholder="开始日期" end-placeholder="结束日期"
                                                 value-format="yyyy-MM-dd">
                                 </el-date-picker>
                                 <label class="col-3 offset-3">
-                                    <select class="form-control rounded" v-model="searchOption.OrderPackageReceivedSyncRecordSelect"
+                                    <select class="form-control rounded"
+                                            v-model="searchOption.OrderPackageReceivedSyncRecordSelect"
                                             @change="switchOrderPackageReceivedSyncRecordDate()">
                                         <option v-for="(date,i) in dateOptions" :value="i">@{{ date.text }}</option>
                                     </select>
@@ -434,22 +455,25 @@
             el: "#list",
             data: {
                 myChart: null,
-                menus:{!! $menus !!},
-                owners:{!! $owners !!},
+                menus: {!! $menus !!},
+                owners: {!! $owners !!},
+                userWorkgroups: {!! $userWorkgroups !!},
                 selectOrderOwners: [],
+                selectUserGroups: [],
                 selectLogisticsOwners: [],
                 selectWeightOwners: [],
                 selectExceptionTypeOwners: [],
-                warehousesOrders:{!! $warehousesOrders !!},
-                orderCountingRecords:{},
-                logisticsCountingRecords:{},
-                warehouseCountingRecords:{},
-                laborReportsCountingRecords:{},
-                laborReportsUserGroupsCount:{},
+                warehousesOrders: {!! $warehousesOrders !!},
+                orderCountingRecords: {},
+                logisticsCountingRecords: {},
+                warehouseCountingRecords: {},
+                laborReportsCountingRecords: {},
+                laborReportsUserGroupsCount: {},
                 warehouses: {
                     "WH01": '松江一仓',
                     "WH02": '松江二仓',
-                    "WH03": '嘉定一仓',},
+                    "WH03": '嘉定一仓',
+                },
                 totalOrders: {
                     total: null,
                     createOrder: null,
@@ -489,16 +513,52 @@
                         }
                     }]
                 },
-                dateOptions:[{text:'当天',start:moment().format('yyyy-MM-DD'),end:moment().format('yyyy-MM-DD')},
-                    {text:"昨天",start:moment().subtract("1","day").format('yyyy-MM-DD'),end:moment().subtract("1","day").format('yyyy-MM-DD')},
-                    {text:"本周",start:moment().weekday(1).format('yyyy-MM-DD'),end:moment().weekday(7).format('yyyy-MM-DD')},
-                    {text:"上周",start:moment().weekday(-6).format('yyyy-MM-DD'),end:moment().weekday(0).format('yyyy-MM-DD')},
-                    {text:"本月",start:moment().startOf("month").format('yyyy-MM-DD'),end:moment().endOf("month").format('yyyy-MM-DD')},
-                    {text:"上月",start:moment().month(moment().month() - 1).startOf('month').format('yyyy-MM-DD'),end:moment().month(moment().month() - 1).endOf('month').format('yyyy-MM-DD')},
-                    {text:"本季度",start:moment(moment().quarter(moment().quarter()).startOf('quarter').valueOf()).format('yyyy-MM-DD'),end:moment(moment().quarter(moment().quarter()).endOf('quarter').valueOf()).format('yyyy-MM-DD')},
-                    {text:"上季度",start:moment(moment().quarter(moment().quarter() - 1).startOf('quarter').valueOf()).format('yyyy-MM-DD'),end:moment(moment().quarter(moment().quarter() - 1).endOf('quarter').valueOf()).format('yyyy-MM-DD')},
-                    {text:"本年",start:moment(moment().year(moment().year()).startOf('year').valueOf()).format('yyyy-MM-DD'),end:moment(moment().year(moment().year()).endOf('year').valueOf()).format('yyyy-MM-DD')},
-                    {text:"去年",start:moment(moment().year(moment().year() - 1).startOf('year').valueOf()).format('yyyy-MM-DD'),end:moment(moment().year(moment().year() - 1).endOf('year').valueOf()).format('yyyy-MM-DD')}],
+                dateOptions: [{text: '当天', start: moment().format('yyyy-MM-DD'), end: moment().format('yyyy-MM-DD')},
+                    {
+                        text: "昨天",
+                        start: moment().subtract("1", "day").format('yyyy-MM-DD'),
+                        end: moment().subtract("1", "day").format('yyyy-MM-DD')
+                    },
+                    {
+                        text: "本周",
+                        start: moment().weekday(1).format('yyyy-MM-DD'),
+                        end: moment().weekday(7).format('yyyy-MM-DD')
+                    },
+                    {
+                        text: "上周",
+                        start: moment().weekday(-6).format('yyyy-MM-DD'),
+                        end: moment().weekday(0).format('yyyy-MM-DD')
+                    },
+                    {
+                        text: "本月",
+                        start: moment().startOf("month").format('yyyy-MM-DD'),
+                        end: moment().endOf("month").format('yyyy-MM-DD')
+                    },
+                    {
+                        text: "上月",
+                        start: moment().month(moment().month() - 1).startOf('month').format('yyyy-MM-DD'),
+                        end: moment().month(moment().month() - 1).endOf('month').format('yyyy-MM-DD')
+                    },
+                    {
+                        text: "本季度",
+                        start: moment(moment().quarter(moment().quarter()).startOf('quarter').valueOf()).format('yyyy-MM-DD'),
+                        end: moment(moment().quarter(moment().quarter()).endOf('quarter').valueOf()).format('yyyy-MM-DD')
+                    },
+                    {
+                        text: "上季度",
+                        start: moment(moment().quarter(moment().quarter() - 1).startOf('quarter').valueOf()).format('yyyy-MM-DD'),
+                        end: moment(moment().quarter(moment().quarter() - 1).endOf('quarter').valueOf()).format('yyyy-MM-DD')
+                    },
+                    {
+                        text: "本年",
+                        start: moment(moment().year(moment().year()).startOf('year').valueOf()).format('yyyy-MM-DD'),
+                        end: moment(moment().year(moment().year()).endOf('year').valueOf()).format('yyyy-MM-DD')
+                    },
+                    {
+                        text: "去年",
+                        start: moment(moment().year(moment().year() - 1).startOf('year').valueOf()).format('yyyy-MM-DD'),
+                        end: moment(moment().year(moment().year() - 1).endOf('year').valueOf()).format('yyyy-MM-DD')
+                    }],
                 logisticsCountingRecordsData: [moment().subtract('1', 'month').format('yyyy-MM-DD'),
                     moment(new Date()).format('yyyy-MM-DD')],
                 warehouseCountingRecordsData: [moment().subtract('1', 'month').format('yyyy-MM-DD'),
@@ -538,32 +598,40 @@
                 laborReportsCountingRecordsYearShow: false,
                 laborReportsCountingRecordsStart: moment().subtract('1', 'month').format('yyyy-MM-DD'),
                 laborReportsCountingRecordsEnd: moment(new Date()).format('yyyy-MM-DD'),
-                cardPool:{},
-                searchOption:{
-                    weightDate:[],
+                cardPool: {},
+                searchOption: {
+                    weightDate: [],
                     exceptionTypeDate: [],
-                    weightSelect:"",
-                    exceptionTypeSelect:"",
+                    weightSelect: "",
+                    exceptionTypeSelect: "",
                     OrderPackageReceivedSyncRecordDate: [],
-                    OrderPackageReceivedSyncRecordSelect:"",
+                    OrderPackageReceivedSyncRecordSelect: "",
                 },
             },
-            watch:{
-                selectOrderOwners:function(val,oldval){
-                    let newindex =  val.indexOf('all');
-                    let   oldindex =  oldval.indexOf('all');
-                    if(newindex!=-1 && oldindex==-1 && val.length>1)
-                        this.selectOrderOwners=['all'];
-                    else if(newindex!=-1 && oldindex!=-1 && val.length>1)
-                        this.selectOrderOwners.splice(val.indexOf('all'),1)
+            watch: {
+                selectOrderOwners: function (val, oldval) {
+                    let newindex = val.indexOf('all');
+                    let oldindex = oldval.indexOf('all');
+                    if (newindex != -1 && oldindex == -1 && val.length > 1)
+                        this.selectOrderOwners = ['all'];
+                    else if (newindex != -1 && oldindex != -1 && val.length > 1)
+                        this.selectOrderOwners.splice(val.indexOf('all'), 1)
                 },
-                selectLogisticsOwners:function(val,oldval){
-                    let newindex =  val.indexOf('all');
-                    let   oldindex =  oldval.indexOf('all');
-                    if(newindex!=-1 && oldindex==-1 && val.length>1)
-                        this.selectLogisticsOwners=['all'];
-                    else if(newindex!=-1 && oldindex!=-1 && val.length>1)
-                        this.selectLogisticsOwners.splice(val.indexOf('all'),1)
+                selectUserGroups: function (val, oldval) {
+                    let newindex = val.indexOf('all');
+                    let oldindex = oldval.indexOf('all');
+                    if (newindex != -1 && oldindex == -1 && val.length > 1)
+                        this.selectUserGroups = ['all'];
+                    else if (newindex != -1 && oldindex != -1 && val.length > 1)
+                        this.selectUserGroups.splice(val.indexOf('all'), 1)
+                },
+                selectLogisticsOwners: function (val, oldval) {
+                    let newindex = val.indexOf('all');
+                    let oldindex = oldval.indexOf('all');
+                    if (newindex != -1 && oldindex == -1 && val.length > 1)
+                        this.selectLogisticsOwners = ['all'];
+                    else if (newindex != -1 && oldindex != -1 && val.length > 1)
+                        this.selectLogisticsOwners.splice(val.indexOf('all'), 1)
                 }
             },
             mounted() {
@@ -598,7 +666,7 @@
                 this.warehouseCountingRecordsApi();
 
                 @can('人事管理-临时工报表-可见全部组')
-                this.laborReportsCountingRecordsChart = echarts.init(document.getElementById('laborReportsCountingRecords'));
+                    this.laborReportsCountingRecordsChart = echarts.init(document.getElementById('laborReportsCountingRecords'));
                 this.initLaborReportsCountingRecordsChart();
                 this.laborReportsCountingRecordApi('日');
 
@@ -607,11 +675,11 @@
                 this.laborReportsUserGroupsCountApi();
                 @endcan
 
-                @can("控制台-称重统计")
-                this.cardPool.weight = echarts.init(document.getElementById("weight"));
+                    @can("控制台-称重统计")
+                    this.cardPool.weight = echarts.init(document.getElementById("weight"));
                 this.loadWeightInfo();
                 @endcan
-                this.cardPool.orderPackageReceivedSyncRecord = echarts.init(document.getElementById("orderPackageReceivedSyncRecord"));
+                    this.cardPool.orderPackageReceivedSyncRecord = echarts.init(document.getElementById("orderPackageReceivedSyncRecord"));
                 this.loadOrderPackageReceivedSyncRecordInfo();
                 this.cardPool.exceptionType = echarts.init(document.getElementById("exceptionType"));
                 this.loadExceptionTypeInfo();
@@ -926,6 +994,7 @@
                     formData.append('start', this.laborReportsCountingRecordsStart);
                     formData.append('end', this.laborReportsCountingRecordsEnd);
                     formData.append('unit', laborReportsCountingRecordUnit);
+                    formData.append('user_workgroup_ids', this.selectUserGroups);
                     let _this = this;
                     axios.post('{{url('apiLocal/control/panel/menu/laborReportsCountingRecordApi')}}', formData).then(function (res) {
                         if (res.status === 200) {
@@ -952,22 +1021,26 @@
                         }
                     });
                 },
-                loadWeightInfo(){
+                loadWeightInfo() {
                     window.tempTip.setDuration(3000);
-                    if (!this.searchOption.weightDate[0]){
+                    if (!this.searchOption.weightDate[0]) {
                         window.tempTip.show("开始时间未选择");
                         return;
                     }
-                    if (!this.searchOption.weightDate[1]){
+                    if (!this.searchOption.weightDate[1]) {
                         window.tempTip.show("结束时间未选择");
                         return;
                     }
-                    this.cardPool.weight.showLoading('default',{text:"加 载 中",color:'#C0C0C0'});
+                    this.cardPool.weight.showLoading('default', {text: "加 载 中", color: '#C0C0C0'});
                     let url = "{{url('apiLocal/control/panel/menu/weightApi')}}";
-                    let params = {start:this.searchOption.weightDate[0],end:this.searchOption.weightDate[1],owner_ids:this.selectWeightOwners};
-                    window.tempTip.postBasicRequest(url,params,res=>{
+                    let params = {
+                        start: this.searchOption.weightDate[0],
+                        end: this.searchOption.weightDate[1],
+                        owner_ids: this.selectWeightOwners
+                    };
+                    window.tempTip.postBasicRequest(url, params, res => {
                         this.cardPool.weight.hideLoading();
-                        let myechart = this.cardPool.weight, option = this._setWeightData(res.title,res.data);
+                        let myechart = this.cardPool.weight, option = this._setWeightData(res.title, res.data);
                         myechart.on('updateAxisPointer', function (event) {
                             var xAxisInfo = event.axesInfo[0];
                             if (xAxisInfo) {
@@ -989,60 +1062,70 @@
                         myechart.setOption(option);
                     });
                 },
-                loadOrderPackageReceivedSyncRecordInfo(){
+                loadOrderPackageReceivedSyncRecordInfo() {
                     window.tempTip.setDuration(3000);
-                    if (!this.searchOption.OrderPackageReceivedSyncRecordDate[0]){
+                    if (!this.searchOption.OrderPackageReceivedSyncRecordDate[0]) {
                         window.tempTip.show("开始时间未选择");
                         return;
                     }
-                    if (!this.searchOption.OrderPackageReceivedSyncRecordDate[1]){
+                    if (!this.searchOption.OrderPackageReceivedSyncRecordDate[1]) {
                         window.tempTip.show("结束时间未选择");
                         return;
                     }
-                    this.cardPool.orderPackageReceivedSyncRecord.showLoading('default',{text:"加 载 中",color:'#C0C0C0'});
+                    this.cardPool.orderPackageReceivedSyncRecord.showLoading('default', {
+                        text: "加 载 中",
+                        color: '#C0C0C0'
+                    });
                     let url = "{{url('apiLocal/control/panel/menu/orderPackageReceivedSyncRecordApi')}}";
-                    let params = {start:this.searchOption.OrderPackageReceivedSyncRecordDate[0],end:this.searchOption.OrderPackageReceivedSyncRecordDate[1]};
-                    window.tempTip.postBasicRequest(url,params,res=>{
+                    let params = {
+                        start: this.searchOption.OrderPackageReceivedSyncRecordDate[0],
+                        end: this.searchOption.OrderPackageReceivedSyncRecordDate[1]
+                    };
+                    window.tempTip.postBasicRequest(url, params, res => {
                         this.cardPool.orderPackageReceivedSyncRecord.hideLoading();
                         this.cardPool.orderPackageReceivedSyncRecord.setOption(this._setOrderPackageReceivedSyncRecordData(res.title, res.data));
                     });
                 },
                 loadExceptionTypeInfo() {
                     window.tempTip.setDuration(3000);
-                    if (!this.searchOption.exceptionTypeDate[0]){
+                    if (!this.searchOption.exceptionTypeDate[0]) {
                         window.tempTip.show("开始时间未选择");
                         return;
                     }
-                    if (!this.searchOption.exceptionTypeDate[1]){
+                    if (!this.searchOption.exceptionTypeDate[1]) {
                         window.tempTip.show("结束时间未选择");
                         return;
                     }
-                    this.cardPool.exceptionType.showLoading('default',{text:"加 载 中",color:'#C0C0C0'});
+                    this.cardPool.exceptionType.showLoading('default', {text: "加 载 中", color: '#C0C0C0'});
                     let url = "{{url('apiLocal/control/panel/menu/exceptionTypeApi')}}";
-                    let params = {start:this.searchOption.exceptionTypeDate[0],end:this.searchOption.exceptionTypeDate[1],owner_ids:this.selectExceptionTypeOwners};
-                    window.tempTip.postBasicRequest(url,params,res=>{
+                    let params = {
+                        start: this.searchOption.exceptionTypeDate[0],
+                        end: this.searchOption.exceptionTypeDate[1],
+                        owner_ids: this.selectExceptionTypeOwners
+                    };
+                    window.tempTip.postBasicRequest(url, params, res => {
                         this.cardPool.exceptionType.hideLoading();
                         this.cardPool.exceptionType.setOption(this._setExceptionTypeData(res.data));
                     });
                 },
-                switchWeightDate(){
+                switchWeightDate() {
                     let obj = this.dateOptions[this.searchOption.weightSelect];
-                    this.searchOption.weightDate = [obj.start,obj.end];
+                    this.searchOption.weightDate = [obj.start, obj.end];
                     this.loadWeightInfo();
                 },
-                switchOrderPackageReceivedSyncRecordDate(){
+                switchOrderPackageReceivedSyncRecordDate() {
                     let obj = this.dateOptions[this.searchOption.OrderPackageReceivedSyncRecordSelect];
-                    this.searchOption.OrderPackageReceivedSyncRecordDate = [obj.start,obj.end];
+                    this.searchOption.OrderPackageReceivedSyncRecordDate = [obj.start, obj.end];
                     this.loadOrderPackageReceivedSyncRecordInfo();
                 },
-                switchExceptionTypeDate(){
+                switchExceptionTypeDate() {
                     let obj = this.dateOptions[this.searchOption.exceptionTypeSelect];
-                    this.searchOption.exceptionTypeDate = [obj.start,obj.end];
+                    this.searchOption.exceptionTypeDate = [obj.start, obj.end];
                     this.loadExceptionTypeInfo();
                 },
-                _setWeightData(title, data){
-                    let temp = [],len = data.length -1;
-                    for (let i=0; i < len; i++){
+                _setWeightData(title, data) {
+                    let temp = [], len = data.length - 1;
+                    for (let i = 0; i < len; i++) {
                         temp.push({type: 'line', smooth: true, seriesLayoutBy: 'row', emphasis: {focus: 'series'}});
                     }
                     temp.push({
@@ -1052,7 +1135,7 @@
                         center: ['50%', '32%'],
                         emphasis: {focus: 'data'},
                         label: {
-                            formatter: '{b}: {@'+title+'} ({d}%)'
+                            formatter: '{b}: {@' + title + '} ({d}%)'
                         },
                         encode: {
                             itemName: 'product',
@@ -1061,7 +1144,7 @@
                         }
                     });
                     console.log(temp)
-                   return {
+                    return {
                         legend: {},
                         tooltip: {
                             trigger: 'axis',
@@ -1076,7 +1159,7 @@
                         series: temp
                     };
                 },
-                _setOrderPackageReceivedSyncRecordData(title,data){
+                _setOrderPackageReceivedSyncRecordData(title, data) {
                     return {
                         title: {
                             text: '快递信息同步成功失败占比',
@@ -1085,7 +1168,7 @@
                         tooltip: {
                             trigger: 'item',
                             formatter: function (params) {
-                                return params.data.date + "<br>" + "总量:<span class='text-success font-weight-bold'>" + params.data.total + "</span><br>" + "成功:<span class='text-info font-weight-bold'>" + params.data.count + "</span><br>"+ "承运商:<span class='text-info font-weight-bold'>" + params.data.logistic_name + "</span>";
+                                return params.data.date + "<br>" + "总量:<span class='text-success font-weight-bold'>" + params.data.total + "</span><br>" + "成功:<span class='text-info font-weight-bold'>" + params.data.count + "</span><br>" + "承运商:<span class='text-info font-weight-bold'>" + params.data.logistic_name + "</span>";
                             }
                         }, xAxis: {
                             data: title
@@ -1114,8 +1197,8 @@
                     let resData = [];
                     data.forEach(item => {
                         resData.push({
-                            value:item.count,
-                            name:item.exception_type
+                            value: item.count,
+                            name: item.exception_type
                         })
                     })
                     return {

+ 5 - 5
resources/views/finance/settlementBills/expressFee/detail/index.blade.php

@@ -63,13 +63,13 @@
                 details: [
                         @foreach($details as $detail){
                         id: " {!! $detail['id'] !!}",
-                        logistic_name: " {!! $detail['logistic_name'] !!}",
-                        province: " {!! $detail['province'] !!}",
-                        logistic_bill: "{!! $detail['logistic_bill'] !!}",
+                        logistic_name: " {!! $detail['logistic']['name'] !!}",
+                        province: " {!! $detail['province']['name'] !!}",
+                        logistic_bill: "{!! $detail['logistic_number'] !!}",
                         weight: "{!! $detail['weight'] !!}",
-                        logistic_fee: "{!! $detail['logistic_fee'] !!}",
+                        logistic_fee: "{!! $detail['total_fee'] !!}",
                         initial_weight_price: "{!! $detail['initial_weight_price'] !!}",
-                        additional_price: "{!! $detail['additional_price'] !!}",},
+                        additional_price: "{!! $detail['additional_weight_price'] !!}",},
                     @endforeach
                 ],
                 owners: [@foreach($owners as $owner){name: '{{ $owner->id }}', value: '{{ $owner->name}}'},@endforeach],

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

@@ -86,7 +86,7 @@
                         :rowspan="calRowspan(report.logistic.name)" class="text-center pt-4 bg-light">@{{
                         report.logistic.name }}
                     </td>
-                    <td>@{{ report.province }}</td>
+                    <td>@{{ report.province.name }}</td>
                     <td>@{{ report.initial_weight }}</td>
                     <td>@{{ report.initial_amount }}</td>
                     <td>@{{ report.additional_weight }}</td>

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

@@ -26,6 +26,15 @@
                                 class="text-muted">货主</p></span>
                     </div>
                 </div>
+                <div class="col-3">
+                    <div class="row pt-2">
+                        <span class="fa fa-jpy fa-4x offset-md-3" style="color: #2ca02c;opacity: 0.3"></span>
+                        <span class="ml-4 mt-2">
+                        <h5 class="font-weight-bold">{{ $totalFee }}</h5>
+                        <p class="text-muted">总金额</p>
+                        </span>
+                    </div>
+                </div>
                 <div v-if="(isArchived===1)" class="col-3">
                     <div class="row pt-2">
                         <span class="fa fa-check-circle  fa-4x offset-md-3" aria-hidden="true"

+ 18 - 18
resources/views/finance/settlementBills/logisticFee/index.blade.php

@@ -58,24 +58,24 @@
                     <td><input class="checkItem" type="checkbox" :value="detail.id"></td>
                     <td>@{{ i+1 }}</td>
                     <td>@{{ detail.logistic?detail.logistic.name:'' }}</td>
-                    <td>@{{ detail.order_id }}</td>
-                    <td>@{{ detail.recipient }}</td>
-                    <td>@{{ detail.recipient_mobile }}</td>
-                    <td>@{{ detail.warehouse_weight }}</td>
-                    <td>@{{ detail.warehouse_weight_unit.name }}</td>
-                    <td>@{{ detail.owner_way_bill_fee_detail.step }}</td>
-                    <td>@{{ detail.destination }}</td>
-                    <td>@{{ detail.destination_city.name }}</td>
-                    <td>@{{ detail.owner_way_bill_fee_detail.price }}</td>
-                    <td>@{{ detail.owner_way_bill_fee_detail.delivery_fee }}</td>
-                    <td>@{{ detail.pick_up_fee }}</td>
-                    <td>@{{ detail.owner_way_bill_fee_detail.fuel_fee }}</td>
-                    <td>@{{ detail.owner_way_bill_fee_detail.service_fee }}</td>
+                    <td>@{{ detail.order_number }}</td>
+                    <td>@{{ detail.recipient_name }}</td>
+                    <td>@{{ detail.recipient_phone }}</td>
+                    <td>@{{ detail.quantity }}</td>
+                    <td>@{{ detail.unit.name }}</td>
+                    <td>@{{ detail.interval }}</td>
+                    <td>@{{ detail.province.name }}</td>
+                    <td>@{{ detail.city.name }}</td>
+                    <td>@{{ detail.price }}</td>
+                    <td>@{{ detail.delivery_fee }}</td>
+                    <td>@{{ detail.pick_fee }}</td>
+                    <td>@{{ detail.fuel_fee }}</td>
+                    <td>@{{ detail.info_fee }}</td>
                     <td>@{{ detail.other_fee }}</td>
-                    <td>@{{ detail.dispatch_remark }}</td>
-                    <td>@{{ detail.owner_way_bill_fee_detail.originate_fee }}</td>
-                    <td>@{{ detail.owner_way_bill_fee_detail.originate_count }}</td>
-                    <td>@{{ detail.fee }}</td>
+                    <td>@{{ detail.remark }}</td>
+                    <td>@{{ detail.initial_fee }}</td>
+                    <td>@{{ detail.initial_amount }}</td>
+                    <td>@{{ detail.total_fee }}</td>
                 </tr>
             </table>
             <div class="text-info h5 btn btn">{{$details->count()}}/{{$details->total()}}</div>
@@ -93,7 +93,7 @@
             el: "#list",
             data: {
                 owner: {!! $owner !!},
-                details: [@foreach($details as $detail){!! $detail !!}, @endforeach],
+                details: [@foreach($details as $detail){!! $detail !!},@endforeach],
                 owners: [@foreach($owners as $owner){name: '{{ $owner->id }}', value: '{{ $owner->name}}'},@endforeach],
                 isArchived: {!! $isArchived !!},
                 request: {!! $request !!},

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

@@ -27,6 +27,15 @@
                         <span class="ml-4 mt-2"><h5 class="font-weight-bold">{{ $owner->name }}</h5><p class="text-muted">货主</p></span>
                     </div>
                 </div>
+                <div class="col-3">
+                    <div class="row pt-2">
+                        <span class="fa fa-jpy fa-4x offset-md-3" style="color: #2ca02c;opacity: 0.3"></span>
+                        <span class="ml-4 mt-2">
+                        <h5 class="font-weight-bold">{{ $total_fee }}</h5>
+                        <p class="text-muted">总金额</p>
+                        </span>
+                    </div>
+                </div>
                 <div  v-if="(isArchived===1)" class="col-3">
                     <div class="row pt-2">
                         <span  class="fa fa-check-circle  fa-4x offset-md-3" aria-hidden="true" style="color: #4c2584;opacity: 0.3"></span>

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

@@ -35,15 +35,27 @@
                     :class="selectTr===i+1?'focusing' : ''">
                     <td><input class="checkItem" type="checkbox" :value="detail.id"></td>
                     <td>@{{ i+1 }}</td>
-                    <td>@{{ detail.owner_fee_detail.worked_at }}</td>
-                    <td>@{{ detail.work_name }}</td>
-                    <td>@{{ detail.asn_code }}</td>
-                    <td>@{{ detail.sku }}</td>
-                    <td>@{{ detail.barcode }}</td>
-                    <td>@{{ detail.commodity.name }}</td>
-                    <td>@{{ detail.amount }}</td>
-                    <td>@{{ detail.unit_price }}</td>
-                    <td>@{{ detail.fee }}</td>
+                    <td>@{{ detail.worked_at }}</td>
+                    <td>@{{ detail.model?detail.model.name:'' }}</td>
+                    <td>@{{ detail.doc_number }}</td>
+                    <td>@{{ detail.commodity?detail.commodity.sku:'' }}</td>
+                    <td>@{{ detail.source_number }}</td>
+                    <td>@{{ detail.commodity?detail.commodity.name:'' }}</td>
+                    <td class="m-0 p-0">
+                        <table class="table  m-0 p-0">
+                            <tr v-for="(item_detail,index) of detail.details" :key="index">
+                                <td>@{{ item_detail.amount }}</td>
+                            </tr>
+                        </table>
+                    </td>
+                    <td class="m-0 p-0">
+                        <table class="table  m-0 p-0">
+                            <tr v-for="(item_detail,index) of detail.details" :key="index">
+                                <td>@{{ item_detail.price }}</td>
+                            </tr>
+                        </table>
+                    </td>
+                    <td>@{{ detail.total_fee }}</td>
                 </tr>
             </table>
             <div class="text-info h5 btn btn">{{$details->count()}}/{{$details->total()}}</div>

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

@@ -82,8 +82,8 @@
                 </tr>
                 <tr v-for="(report,i) in reports">
                     <td class="text-center pt-4 bg-light">@{{ report.work_name }}</td>
-                    <td class="m-0 p-0">
-                        <table class="table  m-0 p-0">
+                    <td class="m-0 p-0 overflow-hidden">
+                        <table class="table  m-0 p-0" style="height:50px;">
                             <tr v-for="item in report.data">
                                 <td>@{{ item.unit_price }}/@{{ item.unit.name }}</td>
                             </tr>
@@ -91,7 +91,7 @@
 
                     </td>
                     <td class="m-0 p-0">
-                        <table class="table  m-0 p-0">
+                        <table class="table  m-0 p-0 overflow-hidden" style="height:50px;">
                             <tr v-for="item in report.data">
                                 <td>@{{ item.amount }}</td>
                             </tr>

+ 21 - 9
resources/views/finance/settlementBills/storeOutFee/detail/index.blade.php

@@ -33,16 +33,28 @@
                     :class="selectTr===i+1?'focusing' : ''">
                     <td><input class="checkItem" type="checkbox" :value="detail.id"></td>
                     <td>@{{ i+1 }}</td>
-                    <td>@{{ detail.owner_fee_detail.worked_at }}</td>
-                    <td>@{{ detail.work_name }}</td>
-                    <td>@{{ detail.source_bill }}</td>
-                    <td>@{{ detail.owner_fee_detail.operation_bill }}</td>
-                    <td>@{{ detail.sku }}</td>
-                    <td>@{{ detail.barcode }}</td>
+                    <td>@{{ detail.worked_at }}</td>
+                    <td>@{{ detail.model.name }}</td>
+                    <td>@{{ detail.source_number }}</td>
+                    <td>@{{ detail.doc_number }}</td>
+                    <td>@{{ detail.commodity?detail.commodity.sku:'' }}</td>
+                    <td>@{{ detail.source_number }}</td>
                     <td>@{{ detail.commodity?detail.commodity.name:'' }}</td>
-                    <td>@{{ detail.amount}}</td>
-                    <td>@{{ detail.unit_price}}</td>
-                    <td>@{{ detail.price_remark}}</td>
+                    <td class="m-0 p-0">
+                        <table class="table  m-0 p-0">
+                            <tr v-for="(item_detail,index) of detail.details" :key="index">
+                                <td>@{{ item_detail.amount }}</td>
+                            </tr>
+                        </table>
+                    </td>
+                    <td class="m-0 p-0">
+                        <table class="table  m-0 p-0">
+                            <tr v-for="(item_detail,index) of detail.details" :key="index">
+                                <td>@{{ item_detail.price }}</td>
+                            </tr>
+                        </table>
+                    </td>
+                    <td>@{{ detail.fee_description}}</td>
                     <td>@{{ detail.fee }}</td>
                 </tr>
             </table>

+ 1 - 1
resources/views/finance/settlementBills/storeOutFee/report/index.blade.php

@@ -81,7 +81,7 @@
                     <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.step }}</td>
+                                <td>/</td>
                             </tr>
                         </table>
                     </td>

+ 5 - 19
resources/views/finance/settlementBills/totalFee/index.blade.php

@@ -6,18 +6,6 @@
     <div id="list" class="d-none">
         <div class="container-fluid">
             <div id="form_div"></div>
-            <div class="ml-3 form-inline" id="btn">
-                    <span class="dropdown">
-                        <button type="button"
-                                class="btn btn-outline-dark btn-sm form-control-sm dropdown-toggle tooltipTarget"
-                                data-toggle="dropdown" title="导出所有页将会以搜索条件得到的筛选结果,将其全部记录(每一页)导出">导出Excel
-                        </button>
-                        <div class="dropdown-menu">
-                            <a target="_blank" class="dropdown-item" @click="detailExport(false)" href="javascript:">导出勾选内容</a>
-                            <a target="_blank" class="dropdown-item" @click="detailExport(true)" href="javascript:">导出所有页</a>
-                        </div>
-                    </span>
-            </div>
             <div class="row">
                 <div class="col-3">
                     <div class="row pt-2">
@@ -118,7 +106,7 @@
                     <td class="m-0 p-0">
                         <table class="table  m-0 p-0">
                             <tr v-for="item in feeTotal['information']['storeFee']">
-                                <td class="m-0 p-0" >
+                                <td >
                                     <span v-for="itemInfo in item.remark">@{{ itemInfo }} </span>
                                 </td>
                             </tr>
@@ -161,7 +149,7 @@
                     <td class="m-0 p-0">
                         <table class="table   m-0 p-0">
                             <tr v-for="item in feeTotal['information']['storeOutFee']">
-                                <td class="m-0 p-0" >
+                                <td>
                                     <span v-for="itemInfo in item.remark">@{{ itemInfo }} </span>
                                 </td>
                             </tr>
@@ -310,9 +298,7 @@
                 <tr>
                     <td>包材费</td>
                     <td>包材费</td>
-                    <td><a target="_blank"
-                           href="{{ route('settlementBills.packingMaterialFee',['owner_id' => $request['owner_id'],'year' => $request['year'],'month' => $request['month']]) }}"></a>
-                    </td>
+                    <td><a target="_blank" href="{{ route('settlementBills.packingMaterialFee',['owner_id' => $request['owner_id'],'year' => $request['year'],'month' => $request['month']]) }}">查看明细</a></td>
                     <td>@{{ feeTotal['packing_material_fee'] }}</td>
                     <!--                   TODO -->
                     <td class="m-0 p-0">
@@ -338,7 +324,7 @@
                     <td>卸货费</td>
                     <td>卸货费</td>
                     <td><a target="_blank"
-                           href="{{ route('settlementBills.unloadFee',['owner_id' => $request['owner_id'],'year' => $request['year'],'month' => $request['month']]) }}"></a>
+                           href="{{ route('settlementBills.unloadFee',['owner_id' => $request['owner_id'],'year' => $request['year'],'month' => $request['month']]) }}">查看明细</a>
                     </td>
                     <td>@{{ feeTotal['unload_fee'] }}</td>
                     <!--                   TODO -->
@@ -372,7 +358,7 @@
                         </table>
                     </td>
                     <td class="m-0 p-0">
-                        <table class="table   m-0 p-0"
+                        <table class="table m-0 p-0"
                                v-for="sundryFee in feeTotal['sundry_information']">
                             <tr>
                                 <td><a target="_blank"

+ 144 - 28
resources/views/package/logistic/index.blade.php

@@ -1,8 +1,68 @@
 @extends('layouts.app')
 @section('title')快递查询-包裹管理@endsection
+@section('head')
+    <style>
+        /*备注容器*/
+        .order-package-remarks{
+            position:relative;
+        }
+        /*新建按钮*/
+        .btn-create-remark {
+            width: 25px;
+            height: 25px;
+            line-height: 25px;
+            text-align: center;
+            position: absolute;
+            display: none;
+            background-color: rgb(92, 141, 236);
+            border: blue solid 1px;
+            color: #111;
+            box-shadow: 0 0 6px #4747f1;
+            float: left;
+        }
+        .order-package-remarks:hover .btn-create-remark{
+            display: block;
+        }
+        /*新建输入框*/
+        .remark-input {
+            height: 30px;
+            line-height: 30px;
+            padding-left: 16px;
+            margin-left: 35px;
+            box-shadow: 0 0 6px #fff6a1;
+            border-radius: 5px;
+        }
+        /*删除按钮*/
+        .order-package-remarks table .destroy {
+            float: right;
+            position: absolute;
+            right: 0;
+            padding: 0 !important;
+            width: 29px !important;
+            min-width: 30px !important;
+            border: 0 solid transparent !important;
+        }
 
+        .remark-created_at{
+            border-right: none !important;
+        }
+
+        .btn-destroy-remark {
+            display: none;
+            background-color: rgba(0, 0, 0, 0);
+            border: red solid 1px;
+            color: red;
+            box-shadow: 0 0 6px #ac4a4a;
+        }
+
+        .order-package-remarks table:hover .btn-destroy-remark{
+            display: block;
+        }
+
+    </style>
+@stop
 @section('content')
-    <div id="list" class="d-none">
+    <div id="list" class="d-none package-logistic-index">
         <div class="container-fluid">
             <div id="form_div"></div>
             <div class="ml-3 form-inline" id="btn">
@@ -49,7 +109,14 @@
                     <td>
                         <input class="checkItem" type="checkbox" :value="package.logistic_number">
                     </td>
-                    <td><span>@{{ i+1 }} <span class="badge badge-danger" v-if="package.order.issue">问题件</span></span>
+                    <td>
+                        <span style="position:relative">
+                            @{{ i+1 }}
+                            <span class="badge badge-danger" v-if="package.order.issue">问题件</span>
+                            <span
+                                style="display: inline-block;width: 15px;height: 15px;border-radius: 50%;position: absolute;top: 2px; margin-left: 3px;box-shadow: 0 0 3px #211f1f"
+                                  :style="package.sync_routes_flag?'background-color:#4ed32d':'background-color:#e83939'"></span>
+                        </span>
                     </td>
                     <td>
                         <select class="form-control-sm" v-model="package.exception_type"
@@ -90,30 +157,36 @@
                             </label>
                         </div>
                     </td>
-                    <td @mouseover="remarkHover = package.id"
-                        @mouseleave="remarkHover=null;remark=null;isShowRemarkInput = false">
+                    <td  class="m-0 p-0 order-package-remarks" style="padding-left: 0 !important;padding-right: 0 !important">
                         @can('包裹管理-快递-客服备注')
-                            <button @click="isShowRemarkInput = true" v-if="remarkHover===package.id">新增</button>
-                            <input @keydown.enter="submitRemark(package)"
-                                   v-if="isShowRemarkInput && remarkHover===package.id" type="text" v-model="remark">
-                            <div v-if="package.remark && package.remark.length>0" :id="'remark-'+i">
-                                <div v-if="showRemarkList[i]" class="text-overflow-warp-200 up">
-                                    <p v-for="remark_item in package.remark">
-                                        @{{ remark_item }}
-                                    </p>
-                                </div>
-                                <div class="text-overflow-warp-200" v-else>
-                                    @{{ package.remark[0] }}
-                                </div>
-                            </div>
-                            <div @click="showRemarkItem(i)" v-if="package.remark && package.remark.length > 1">
-                                <label class="text-center mt-0 p-0 cursor-pointer pull-left">
+                        <label :for="'create_remark_'+package.id" class="btn-create-remark" @click="package.input_remark=!package.input_remark">
+                            新
+                        </label>
+                        <input :id="'create_remark_'+package.id" @keyup.enter="submitRemark(package)" v-model="remark" v-show="package.input_remark" type="text" class="remark-input">
+                       <table class="table m-0 p-0 ">
+                           <tr v-show="package.order_package_remarks.length > 0 && package.showMoreRemark===true" v-for="(item,index) of package.order_package_remarks" :key="item.id">
+                               <td :title="item.content" style="width: 100px;overflow:hidden !important;">@{{ item.content }}</td>
+                               <td class="text-secondary">@{{ item.user.name }}</td>
+                               <td class="text-secondary remark-created_at">@{{ item.created_at }}</td>
+                               <td class="destroy"><button   class="btn-destroy-remark" @click="destroyRemark(package,item.id)">删</button></td>
+                           </tr>
+                           <tr v-show="(!package.showMoreRemark) && package.order_package_remarks.length > 0" >
+                               <td :title="package.order_package_remarks[0]? package.order_package_remarks[0].content:''" style="width: 100px;overflow:hidden !important;">@{{ package.order_package_remarks[0]?package.order_package_remarks[0].content:'' }}</td>
+                               <td class="text-secondary">@{{ package.order_package_remarks[0]?package.order_package_remarks[0].user.name:'' }}</td>
+                               <td class="text-secondary remark-created_at">@{{ package.order_package_remarks[0]?package.order_package_remarks[0].created_at:'' }}</td>
+                               <td class="destroy"><button   class="btn-destroy-remark" @click="destroyRemark(package,package.order_package_remarks[0].id)">删</button></td>
+                           </tr>
+                       </table>
+                        <div
+                            class="float-left"
+                            @click="package.showMoreRemark = !package.showMoreRemark" v-show="package.order_package_remarks && package.order_package_remarks.length > 1">
+                            <label class="text-center mt-0 p-0 cursor-pointer pull-left">
                                 <span class="fa"
-                                      :class="package.isShowRemark ? 'fa-angle-double-down' : 'fa-angle-double-right'"></span>
-                                    &nbsp;<span v-if="package.remark && showRemarkList[i]">收起</span><span
-                                        v-else>展开</span>&nbsp;@{{ package.remark.length }} 条
-                                </label>
-                            </div>
+                                      :class="package.showMoreRemark ? 'fa-angle-double-down' : 'fa-angle-double-right'"></span>
+                                &nbsp;<span v-if="package.order_package_remarks && package.showMoreRemark">收起</span><span
+                                    v-else>展开</span>&nbsp;@{{ package.order_package_remarks.length }} 条
+                            </label>
+                        </div>
                         @endcan
                     </td>
                     <td class="text-overflow-warp-200"><span v-if="package.order && package.order.issue">@{{ package.order.issue.result_explain }}</span>
@@ -250,7 +323,9 @@
                             placeholder: '是否有物流信息',
                             data: [{name: '是', value: '是'}, {name: '否', value: '否'}]
                         },
+
                         {name: 'default_date', type: 'checkbox', tip: '默认15天', data: [{name: 'ture', value: '默认15天'}]},
+                        {name: 'default_logistics', type: 'checkbox', tip: '默认承运商', data: [{name: 'ture', value: '默认承运商'}]},
 
                     ], [
                         {
@@ -279,9 +354,9 @@
 
                         {
                             name: 'exception_type',
-                            type: 'select',
+                            type: 'select_multiple_select',
                             tip: ['输入关键词快速定位下拉列表,回车确定', '选择要显示的状态'],
-                            placeholder: '异常类型',
+                            placeholder: ['异常类型', '定位或多选异常类型'],
                             data: [
                                 {name: '疑似库内丢件', value: '疑似库内丢件'},
                                 {name: '揽件异常', value: '揽件异常'},
@@ -292,6 +367,21 @@
                                 {name: '无', value: '无'}
                             ]
                         },
+                        {
+                            name: 'is_issue',
+                            type: 'select',
+                            tip: ['输入关键词快速定位下拉列表,回车确定', '选择要显示的状态'],
+                            placeholder: '是否为问题件',
+                            data: [{name: '是', value: '是'}, {name: '否', value: '否'}]
+                        },
+
+                        {
+                            name: 'sync_routes_flag',
+                            type: 'select',
+                            tip: ['输入关键词快速定位下拉列表,回车确定', '选择要显示的状态'],
+                            placeholder: '是否有查询记录',
+                            data: [{name: true, value: '是'}, {name: false, value: '否'}]
+                        },
                     ]
                 ];
                 _this.form = new query({
@@ -390,9 +480,35 @@
                     }
                     let url = '{{url('apiLocal/package/logistic/')}}';
                     let _this = this;
-                    axios.put(url, {remark: _this.remark, orderPackageId: orderPackage.id}).then(function (response) {
+                    tempTip.setDuration(2000);
+                    tempTip.showSuccess('正在操作请稍后!');
+                    axios.put(url, {remark: _this.remark, orderPackageId: orderPackage.id}).then(response=>{
+                        if (response.data.success) {
+                            orderPackage.order_package_remarks = response.data.data
+                            tempTip.setDuration(2000);
+                            tempTip.showSuccess('成功!');
+                            _this.remark = '';
+                            orderPackage.input_remark = false;
+                        } else {
+                            tempTip.setDuration(5000);
+                            tempTip.show(response.data.fail_info);
+                        }
+                    }).catch(function (err) {
+                        tempTip.setDuration(3000);
+                        tempTip.show("网络错误:" + err)
+                    });
+                },
+                destroyRemark(orderPackage,remarkId) {
+                    let url = '{{url('apiLocal/package/logistic/delete')}}';
+                    if (!confirm('是否却认删除', false)) {
+                        return;
+                    };
+                    let _this = this;
+                    tempTip.setDuration(2000);
+                    tempTip.showSuccess('正在操作请稍后!');
+                    axios.post(url, {orderPackageId: orderPackage.id,remarkId:remarkId}).then(response=>{
                         if (response.data.success) {
-                            orderPackage.remark = response.data.data
+                            orderPackage.order_package_remarks = response.data.data
                             tempTip.setDuration(2000);
                             tempTip.showSuccess('成功!');
                         } else {

+ 1 - 0
routes/apiLocal.php

@@ -222,6 +222,7 @@ Route::group(['prefix' => 'station'],function(){
 /** 包裹 */
 Route::group(['prefix' => 'package'], function () {
     Route::put('logistic', 'OrderPackageController@update')->name('orderPackage.update');
+    Route::post('logistic/delete', 'OrderPackageController@destroy')->name('orderPackage.destroy');
 });
 /** 快递打印 */
 Route::group(['prefix' => 'print'],function (){

+ 1 - 1
tests/Feature/LogisticZopSyncTest.php

@@ -39,7 +39,7 @@ class LogisticZopSyncTest extends TestCase
 
     public function test_get()
     {
-        LogisticZopSync::dispatch('75600272832573');
+        LogisticZopSync::dispatch('75497969890714');
     }