فهرست منبع

Merge branch 'zzd' of ssh://was.baoshi56.com:10022/var/git/bswas

 Conflicts:
	app/Http/Controllers/TestController.php
	app/Owner.php
	resources/views/customer/project/index.blade.php
	resources/views/customer/project/part/_two.blade.php
LD 5 سال پیش
والد
کامیت
b02f41e281
46فایلهای تغییر یافته به همراه1255 افزوده شده و 167 حذف شده
  1. 50 0
      app/Console/Commands/BeforeCreateOwnerReport.php
  2. 7 8
      app/Console/Commands/CreateOwnerReport.php
  3. 31 0
      app/Console/Commands/InventoryDailyLoggingOwner.php
  4. 4 1
      app/Console/Kernel.php
  5. 16 0
      app/DeliveryAppointment.php
  6. 5 0
      app/DeliveryAppointmentCar.php
  7. 18 1
      app/Http/Controllers/CarTypesController.php
  8. 8 7
      app/Http/Controllers/CustomerController.php
  9. 171 1
      app/Http/Controllers/DeliveryAppointmentController.php
  10. 31 9
      app/Http/Controllers/PriceModelController.php
  11. 37 0
      app/Http/Controllers/TaxRateController.php
  12. 13 1
      app/Http/Controllers/TestController.php
  13. 1 2
      app/Imports/AppointmentDetail.php
  14. 11 2
      app/Owner.php
  15. 9 1
      app/OwnerReport.php
  16. 4 0
      app/Providers/AppServiceProvider.php
  17. 78 0
      app/Services/DeliveryAppointmentService.php
  18. 5 1
      app/Services/OrderService.php
  19. 10 13
      app/Services/OwnerPriceExpressService.php
  20. 62 42
      app/Services/OwnerPriceOperationService.php
  21. 37 0
      app/Services/OwnerService.php
  22. 8 8
      app/Services/OwnerStoragePriceModelService.php
  23. 18 0
      app/TaxRate.php
  24. 1 1
      app/Warehouse.php
  25. 9 0
      config/appointment.php
  26. 66 0
      database/migrations/2021_03_06_090856_create_tax_rates_table.php
  27. 36 0
      database/migrations/2021_03_08_170734_change_owner_reports_table.php
  28. 13 1
      resources/sass/text.scss
  29. 122 23
      resources/views/customer/project/area.blade.php
  30. 11 3
      resources/views/customer/project/create.blade.php
  31. 6 2
      resources/views/customer/project/index.blade.php
  32. 9 3
      resources/views/customer/project/part/_storage.blade.php
  33. 7 5
      resources/views/customer/project/part/_two.blade.php
  34. 4 0
      resources/views/maintenance/menu.blade.php
  35. 23 0
      resources/views/maintenance/taxRate/_edit.blade.php
  36. 88 0
      resources/views/maintenance/taxRate/index.blade.php
  37. 28 0
      resources/views/maintenance/warehouse/create.blade.php
  38. 28 0
      resources/views/maintenance/warehouse/edit.blade.php
  39. 8 1
      resources/views/maintenance/warehouse/index.blade.php
  40. 0 12
      resources/views/store/checkingReceive/_selectDate.blade.php
  41. 1 5
      resources/views/store/checkingReceive/menu.blade.php
  42. 27 0
      resources/views/store/deliveryAppointment/_selectDate.blade.php
  43. 103 12
      resources/views/store/deliveryAppointment/appointment.blade.php
  44. 12 0
      resources/views/store/deliveryAppointment/menu.blade.php
  45. 6 2
      resources/views/store/menu.blade.php
  46. 13 0
      routes/web.php

+ 50 - 0
app/Console/Commands/BeforeCreateOwnerReport.php

@@ -0,0 +1,50 @@
+<?php
+
+namespace App\Console\Commands;
+
+use App\OwnerReport;
+use App\Services\OwnerService;
+use Illuminate\Console\Command;
+use Illuminate\Support\Facades\Cache;
+
+class BeforeCreateOwnerReport extends Command
+{
+    /**
+     * The name and signature of the console command.
+     *
+     * @var string
+     */
+    protected $signature = 'beforeCreateOwnerReport';
+
+    /**
+     * The console command description.
+     *
+     * @var string
+     */
+    protected $description = 'Create owner report in advance and build cache';
+
+
+    /**
+     * Execute the console command.
+     *
+     */
+    public function handle()
+    {
+        /** @var OwnerService $ownerService */
+        $ownerService = app('OwnerService');
+        $chunks = ($ownerService->get([],["ownerStoragePriceModels"],false,true))->chunk(50);
+        foreach ($chunks as $owners){
+            $insert = [];
+            $date = date("Y-m-d");
+            foreach ($owners as $owner){
+                $insert[] = [
+                    "owner_id"       => $owner->id,
+                    "counting_month" => date("Y-m-d"),
+                    "created_at"     => $date
+                ];
+                Cache::put(date("Y-m")."|".$owner->id,0,2764800);
+            }
+            OwnerReport::query()->insert($insert);
+        }
+    }
+}

+ 7 - 8
app/Console/Commands/CreateOwnerReport.php

@@ -8,6 +8,7 @@ use App\OwnerReport;
 use App\Services\common\BatchUpdateService;
 use App\Services\LogService;
 use Illuminate\Console\Command;
+use Illuminate\Support\Facades\Cache;
 use Illuminate\Support\Facades\DB;
 
 class CreateOwnerReport extends Command
@@ -82,7 +83,7 @@ class CreateOwnerReport extends Command
                 $historyReportMap[$report->owner_id."_".$report->counting_month] = $report->current_month_counting_area;
                 continue;
             }
-            $reportMap[$report->owner_id."_".$report->counting_month] = $report->id;
+            $reportMap[$report->owner_id."_".$report->counting_month] = $report;
         }
 
         //组装账单记录
@@ -97,20 +98,18 @@ class CreateOwnerReport extends Command
         ]];
         $createReports = [];
         foreach ($areas as $area){
-            $total = $area->owner ? ($map[$area->owner->code] ?? 0) : 0;
-            if ($reportMap[$area->owner_id."_".$area->counting_month] ?? false){
+            $report = $reportMap[$area->owner_id."_".$area->counting_month] ?? false;
+            if ($report){
                 $updateReports[] = [
-                    "id"=>$reportMap[$area->owner_id."_".$area->counting_month],
-                    "total" =>$total,
-                    "daily_average_order_amount"=>round($total / $lastDay,2),
+                    "id"=>$report->id,
+                    "daily_average_order_amount"=>round(($report->to_business_quantity+$report->to_customer_quantity) / $lastDay,2),
                     "current_month_counting_area"=>$area->total ?? 0,
                     "owner_bill_report_id" => $billMap[$area->owner_id."_".$area->counting_month] ?? 0,
                 ];
             }else $createReports[] = [
                 "owner_id"=>$area->owner_id,
                 "counting_month"=>$area->counting_month."-01",
-                "total" =>$total,
-                "daily_average_order_amount"=>round($total / $lastDay,2),
+                "daily_average_order_amount"=>0,
                 "current_month_counting_area"=>$area->total ?? 0,
                 "owner_bill_report_id" => $billMap[$area->owner_id."_".$area->counting_month] ?? 0,
                 "last_month_counting_area" => $historyReportMap[$area->owner_id."_".($historyYear."-".$historyMonth)] ?? 0,

+ 31 - 0
app/Console/Commands/InventoryDailyLoggingOwner.php

@@ -3,7 +3,9 @@
 namespace App\Console\Commands;
 
 use App\CommodityBarcode;
+use App\OwnerAreaReport;
 use App\Services\CommodityService;
+use App\Services\common\BatchUpdateService;
 use App\Services\LogService;
 use Illuminate\Console\Command;
 use App\InventoryDailyLoggingOwner as LoggingOwner;
@@ -96,6 +98,8 @@ class InventoryDailyLoggingOwner extends Command
         }
         //第二个数组作为批量插入使用
         $data = [];
+        //盘点货主记录
+        $inventories = [];
         //遍历第一个数组,此时已经去重完成,直接取对应参数push进data中
         foreach ($inventoryDailyLogs as $inventoryDailyLog){
             //寻找己方库中是否存在对应商品,存在更新其长宽高体积,不存在录入
@@ -141,9 +145,36 @@ class InventoryDailyLoggingOwner extends Command
                 "gross_weight"=>$gross_weight,
                 "depository_id"=>$depository ? $depository->id : null,
             ];
+            if (array_key_exists($commodity['owner_id'],$inventories)){
+                $inventories[$commodity['owner_id']]["volume"] += $volumn_occupied;
+                $inventories[$commodity['owner_id']]["amount"] += $inventoryDailyLog['amount'];
+            }else{
+                $inventories[$commodity['owner_id']] = [
+                    "volume" => $volumn_occupied,
+                    "amount" => $inventoryDailyLog['amount'],
+                ];
+            }
         }
         DB::table('inventory_daily_logs')->insert($data);
         app('LogService')->log(__METHOD__,"同步库存每日记录",json_encode($data));
+        if (count($inventories)>0){
+            $update = [["id","accounting_area"]];
+            $areas = OwnerAreaReport::query()->with("ownerStoragePriceModel.unit")
+                ->whereIn("owner_id",array_keys($inventories))
+                ->where("counting_month",'like',date("Y-m")."%")->get();
+            foreach ($areas as $area){
+                $unit = $area->ownerStoragePriceModel->unit->name ?? null;
+                if ($unit!='m³' || $unit!='件')continue;
+                $update[] = [
+                    "id"              => $area->id,
+                    "accounting_area" => $unit=='m³' ? $inventories[$area->owner_id]["volume"] : $inventories[$area->owner_id]["amount"],
+                ];
+            }
+            if (count($update)>1){
+                app(BatchUpdateService::class)->batchUpdate("owner_area_reports",$update);
+                LogService::log(__CLASS__,"监听货主记录时修改面积报信息",json_encode($inventories));
+            }
+        }
     }
 
     public function getLoggingOwners(){

+ 4 - 1
app/Console/Kernel.php

@@ -2,6 +2,7 @@
 
 namespace App\Console;
 
+use App\Console\Commands\BeforeCreateOwnerReport;
 use App\Console\Commands\ClearCancelledOrderTask;
 use App\Console\Commands\CreateWeightStatistic;
 use App\Console\Commands\FluxOrderFix;
@@ -21,7 +22,7 @@ use Illuminate\Console\Scheduling\Schedule;
 use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
 use Illuminate\Foundation\Console\ModelMakeCommand;
 
-class Kernel extends ConsoleKernel
+class  Kernel extends ConsoleKernel
 {
     /**
      * The Artisan commands provided by your application.
@@ -44,6 +45,7 @@ class Kernel extends ConsoleKernel
         ClearCancelledOrderTask::class,
         WasSyncWmsAsnInformation::class,
         CreateWeightStatistic::class,
+        BeforeCreateOwnerReport::class,
     ];
 
     /**
@@ -62,6 +64,7 @@ class Kernel extends ConsoleKernel
         $schedule->command('createOwnerReport')->monthlyOn(1);
         $schedule->command('createOwnerBillReport')->monthlyOn(1);
         $schedule->command('createOwnerAreaReport')->monthlyOn(1);
+        $schedule->command('beforeCreateOwnerReport')->monthlyOn(1);
         $schedule->command('sync:batch')->everyMinute();
         $schedule->command('sync:order')->everyMinute();
         $schedule->command('syncOrderPackageLogisticRouteTask')->dailyAt('1:20');//同步快递信息到orderPackage

+ 16 - 0
app/DeliveryAppointment.php

@@ -24,6 +24,22 @@ class DeliveryAppointment extends Model
         "date_period",
         "status",
     ];
+    //时段 映射date_period字段
+    const PERIOD=[
+        0 => "9-11",
+        1 => "13-17",
+    ];
+    //时长 映射PERIOD常量
+    const HOUR=[
+        0 => 3,
+        1 => 5
+    ];
+    //状态
+    const STATUS=[
+        0 => "待收",
+        1 => "取消",
+        2 => "完成",
+    ];
 
     public function cars()
     {   //车辆

+ 5 - 0
app/DeliveryAppointmentCar.php

@@ -21,6 +21,11 @@ class DeliveryAppointmentCar extends Model
     ];
     public $timestamps=false;
 
+    const STATUS=[
+        0 => "待送",
+        1 => "已送"
+    ];
+
     public function deliveryAppointment()
     {   //预约信息
         return $this->belongsTo(DeliveryAppointment::class);

+ 18 - 1
app/Http/Controllers/CarTypesController.php

@@ -3,14 +3,16 @@
 namespace App\Http\Controllers;
 
 use App\CarType;
+use App\Components\AsyncResponse;
 use Illuminate\Http\Request;
 use Illuminate\Support\Facades\Auth;
+use Illuminate\Support\Facades\DB;
 use Illuminate\Support\Facades\Gate;
 use Illuminate\Support\Facades\Validator;
 
 class CarTypesController extends Controller
 {
-
+    use AsyncResponse;
     public function index()
     {
         if(!Gate::allows('车型-查询')){ return redirect(url('/'));  }
@@ -93,4 +95,19 @@ class CarTypesController extends Controller
         ]);
         return $validator;
     }
+
+    public function batchInsert()
+    {
+        $arr = request("arr");
+        if (!$arr)$this->error("非法参数");
+        DB::transaction(function()use($arr){
+            $cars = CarType::query()->whereIn("name",$arr)->lockForUpdate()->get()->toArray();
+            $result = array_diff($arr,array_column($cars,"name"));
+            if ($result){
+                foreach ($result as &$r)$r = ["name"=>$r];
+                CarType::query()->insert($result);
+            }
+        });
+        $this->success(CarType::query()->select("id","name")->whereIn("name",$arr)->get());
+    }
 }

+ 8 - 7
app/Http/Controllers/CustomerController.php

@@ -114,7 +114,7 @@ class CustomerController extends Controller
         if(!Gate::allows('客户管理-项目-查询')){ return redirect('denied');  }
         /** @var OwnerService $service */
         $service = app('OwnerService');
-        $withs = ['customer',"userOwnerGroup","contracts","ownerStoragePriceModels","ownerAreaReport"=>function($query){
+        $withs = ['customer',"userOwnerGroup","contracts","taxRate","ownerStoragePriceModels","ownerAreaReport"=>function($query){
             $month = date('Y-m');
             /** @var Builder $query */
             $query->where("counting_month","like",$month."%");
@@ -129,7 +129,7 @@ class CustomerController extends Controller
         foreach ($owners as $owner){
             $list[] = [
                 $owner->customer ? $owner->customer->name : '',
-                $owner->tax_rate,
+                $owner->taxRate->name ?? '',
                 $owner->name,
                 $owner->code,
                 $owner->created_at,
@@ -180,7 +180,7 @@ class CustomerController extends Controller
         $owner = app('OwnerService')->update($owner,[
             "customer_id"           => request("customer_id"),
             "warehouse_id"          => request("warehouse_id"),
-            "tax_rate"              => request("tax_rate"),
+            "tax_rate_id"           => request("tax_rate_id"),
             "linkman"               => request("linkman"),
             "phone_number"          => request("phone_number"),
             "user_owner_group_id"   => request("owner_group_id"),
@@ -241,13 +241,14 @@ class CustomerController extends Controller
         $this->gate("客户管理-项目-面积-编辑");
         if (!request("id")) $this->error("非法参数");
 
+        $total = ((int)request("areaOnTray")*2.5) +
+            ((int)request("areaOnHalfTray")*1.8) + ((int)request("areaOnFlat")*1.3);
         $obj = [
             "user_owner_group_id" => request("ownerGroupId"),
             "area_on_tray" => request("areaOnTray"),
             "area_on_half_tray" => request("areaOnHalfTray"),
             "area_on_flat" => request("areaOnFlat"),
-            "accounting_area" => ((int)request("areaOnTray")*2.5) +
-                ((int)request("areaOnHalfTray")*1.8) + ((int)request("areaOnFlat")*1.3),
+            "accounting_area" => intval($total*1000)/1000,
         ];
         app('OwnerAreaReportService')->update(["id"=>request("id")],$obj);
         $this->success($obj);
@@ -430,7 +431,7 @@ class CustomerController extends Controller
             'customer_id'=>['required'],
             'owner_group_id'=>['required'],
             'warehouse_id'=>['required'],
-            'tax_rate' => ["nullable",'numeric'],
+            'tax_rate_id' => ["required",'integer'],
             'waring_line_on' => ["nullable",'integer'],
         ],[
             'required'=>':attribute 为必填项',
@@ -442,7 +443,7 @@ class CustomerController extends Controller
             'warehouse_id'=>'仓库',
             'customer_id'=>'客户',
             'owner_group_id'=>'工作组',
-            'tax_rate' => '税率',
+            'tax_rate_id' => '税率',
             'waring_line_on' => '月单量预警'
         ]);
         return $validator;

+ 171 - 1
app/Http/Controllers/DeliveryAppointmentController.php

@@ -2,8 +2,20 @@
 
 namespace App\Http\Controllers;
 
+use App\CarType;
+use App\CommodityBarcode;
 use App\Components\AsyncResponse;
+use App\DeliveryAppointment;
+use App\DeliveryAppointmentCar;
+use App\DeliveryAppointmentDetail;
 use App\Imports\AppointmentDetail;
+use App\Warehouse;
+use Carbon\Carbon;
+use Carbon\CarbonPeriod;
+use Illuminate\Database\Eloquent\Builder;
+use Illuminate\Support\Facades\Auth;
+use Illuminate\Support\Facades\DB;
+use Illuminate\Support\Facades\Validator;
 
 class DeliveryAppointmentController extends Controller
 {
@@ -11,11 +23,169 @@ class DeliveryAppointmentController extends Controller
     public function appointment()
     {
         $owners = app("OwnerService")->getIntersectPermitting();
-        return view("store.checkingReceive.appointment",compact("owners"));
+        $cars = CarType::query()->get();
+        $warehouses = Warehouse::query()->select("id","name")->get();
+        return view("store.deliveryAppointment.appointment",compact("owners","cars","warehouses"));
     }
 
     public function import()
     {
         $this->importExcel(new AppointmentDetail());
     }
+
+    /**
+     * 获取产能
+     *
+     */
+    public function getCapacity()
+    {
+        /** @var \stdClass $warehouse */
+        $warehouse = Warehouse::query()->find(request("warehouse_id"));
+        $tonne = request("tonne");
+        $cubicMeter = request("cubic_meter");
+        $amount = request("detail_amount");
+        if (!$warehouse || (!$tonne && !$cubicMeter))$this->error("非法参数");
+        $need = app("DeliveryAppointmentService")->calculateCapacity($tonne,$cubicMeter,$amount,$warehouse->reduced_production_capacity_coefficient);//所需产能
+        $start = Carbon::tomorrow();
+        $end = Carbon::today()->addDays(7);
+        $map = [];
+        DeliveryAppointment::query()->selectRaw("appointment_date,date_period,SUM(capacity) AS capacity")
+            ->whereBetween("appointment_date",[$start->toDateString(),$end->toDateString()])
+            ->where("status",0)
+            ->where("warehouse_id",$warehouse->id)
+            ->groupBy(["appointment_date","date_period"])->get()
+            ->each(function ($appointment)use(&$map){
+                $map[$appointment->appointment_date."-".$appointment->date_period] = $appointment->capacity;
+            });
+        $list = [];
+        $capacity = $warehouse->production_capacity;
+        foreach (CarbonPeriod::create($start,$end) as $date){
+            /** @var $date Carbon */
+            $date = $date->format("Y-m-d");
+            $periods = [];
+            foreach (DeliveryAppointment::PERIOD as $key=>$period){
+                $total = $capacity*DeliveryAppointment::HOUR[$key];//仓库该时段产能总量
+                $used = $map[$date."-".$key] ?? 0; //已使用产能
+                $available = $total-$used; //可用产能
+                if ($available < $need)$periods[] = ["time"=>$period,"index"=>$key,"isAvailable"=>false];
+                else $periods[] = ["time"=>$period,"index"=>$key,"isAvailable"=>true];
+            }
+            $list[] = ["date"=>$date,"period"=>$periods];
+        }
+        $this->success($list);
+    }
+
+    /**
+     * 确定预约
+     */
+    public function submitAppointment()
+    {
+        $model = request("model");
+        $selectDate = request("selectDate");
+        $details = request("details");
+        $errors = Validator::make($model,[
+            "owner_id" => ["required","integer"],
+            "warehouse_id" => ["required","integer"],
+            "tonne" => ["required_without:cubic_meter","numeric"],
+            "cubic_meter" => ["required_without:tonne","numeric"],
+            "box_amount" => ["nullable","integer"],
+            "cars.*.license_plate_number" => ["required","size:7"],
+            "cars.*.car_id" => ["nullable","integer"],
+            "cars.*.driver_phone" => ["nullable"],
+            "cars.*.driver_name" => ["nullable"],
+        ],[
+            'required'=>':attribute 不应为空',
+            'integer'=>':attribute 应为数值',
+            'required_without'=>':attribute 不应为空',
+            'numeric'=>':attribute 必须为数字',
+            'size'=>':attribute 非法',
+        ],[
+            'owner_id'=>'货主',
+            'warehouse_id'=>'仓库',
+            'tonne'=>'吨',
+            'cubic_meter'=>'立方',
+            'cars.*.license_plate_number'=>'车牌号',
+            'cars.*.car_id'=>'车型',
+            'cars.*.driver_phone'=>'司机电话',
+            'cars.*.driver_name'=>'司机姓名',
+        ])->errors();
+        if (count($errors)>0)$this->success(["errors"=>$errors]);
+        $errors = Validator::make($selectDate,[
+            "date" => ["required","date","after:today"],
+            "time" => ["required","integer"],
+        ])->errors();
+        if (count($errors)>0)$this->error("未选定预约日期");
+
+        DB::transaction(function ()use($model,$selectDate,$details){
+            $result = DeliveryAppointment::query()->selectRaw("appointment_date,date_period,SUM(capacity) AS capacity")
+                ->where("appointment_date",$selectDate["date"])
+                ->where("date_period",$selectDate["time"])
+                ->where("warehouse_id",$model["warehouse_id"])
+                ->where("status",0)
+                ->groupBy(["appointment_date","date_period"])
+                ->lockForUpdate()->first();
+            /** @var \stdClass $warehouse */
+            $warehouse = Warehouse::query()->find($model["warehouse_id"]);
+            $need = app("DeliveryAppointmentService")->
+            calculateCapacity($model["tonne"],$model["cubic_meter"],count($details),
+                $warehouse->reduced_production_capacity_coefficient);
+            if ($result){
+                $total = $warehouse->production_capacity*DeliveryAppointment::HOUR[$selectDate["time"]];
+                $available = $total-$result->capacity;
+                if ($available < $need)$this->success(["isFail"=>false]);
+            }
+            /** @var \stdClass $appointment */
+            $appointment = DeliveryAppointment::query()->create([
+                "user_id"               => Auth::id(),
+                "owner_id"              => $model["owner_id"],
+                "procurement_number"    => $model["procurement_number"],
+                "asn_number"            => $model["asn_number"],
+                "warehouse_id"          => $model["warehouse_id"],
+                "tonne"                 => $model["tonne"],
+                "cubic_meter"           => $model["cubic_meter"],
+                "box_amount"            => $model["box_amount"],
+                "capacity"              => $need,
+                "appointment_date"      => $selectDate["date"],
+                "date_period"           => $selectDate["time"],
+            ]);
+            if ($details)app("DeliveryAppointmentService")->insertDetails($appointment,$details);
+            $insert = [];
+            foreach ($model["cars"] as $index=>$car){
+                $rand = mt_rand(0,9);
+                $len = strlen($appointment->id);
+                $ten = $len < 2 ? "0" : substr($appointment->id,$len-2,1);
+                $one = substr($appointment->id,$len-1,1);
+                //唯一码 随机数+十位+当前下标+个位+日期
+                $number = $rand.$ten.$index.$one.date("d");
+                $insert[] = [
+                    "delivery_appointment_id" => $appointment->id,
+                    "license_plate_number"    => $car["license_plate_number"],
+                    "car_id"                  => $car["car_id"],
+                    "driver_name"             => $car["driver_name"],
+                    "driver_phone"            => $car["driver_phone"],
+                    "appointment_number"      => $number,
+                ];
+            }
+            DeliveryAppointmentCar::query()->insert($insert);
+            //md5加密在密文第五位后插入
+            $md5 = substr_replace(md5(date("m-d")),$appointment->id,5,0);
+            $this->success(["key"=>$md5]);
+        });
+    }
+
+    /**
+     * 根据key取id 鉴权数据
+     */
+    public function showAppointmentInfo()
+    {
+        $key = request("k");
+        $len = strlen($key);
+        $id = substr($key,5,$len-32);
+        $md5 = substr($id,0,5).substr($id,5+$len-32);
+        if ($md5!==md5(date("m-d")))return "错误";
+        /** @var \stdClass $appointment */
+        $appointment = DeliveryAppointment::query()->with("cars")->find($id);
+        if (!$appointment || $appointment->user_id != Auth::id())return "错误";
+        return $appointment->cars;
+    }
 }

+ 31 - 9
app/Http/Controllers/PriceModelController.php

@@ -83,7 +83,9 @@ class PriceModelController extends Controller
         ]);
         $model = new OwnerStoragePriceModel();
         $model->id = $request->input("id");
-        $model->owners()->sync(explode(",",$request->input("owner_id")));
+        $result = $model->owners()->sync(explode(",",$request->input("owner_id")));
+        app("OwnerService")->refreshRelevance($result["attached"],0);
+        app("OwnerService")->refreshRelevance($result["detached"],0,true);
         LogService::log(__METHOD__,"计费模型-修改仓储计费",json_encode($request->input(),JSON_UNESCAPED_UNICODE));
         return response()->redirectTo('maintenance/priceModel/storage')->with('successTip',"更新成功!");
     }
@@ -293,7 +295,11 @@ class PriceModelController extends Controller
         }
         //录入中间表
         /** @var OwnerPriceOperation $ownerPriceOperation */
-        if ($request->input("owner_id"))$ownerPriceOperation->ownerPriceOperationOwners()->sync($request->input("owner_id"));
+        if ($request->input("owner_id")){
+            $result = $ownerPriceOperation->ownerPriceOperationOwners()->sync($request->input("owner_id"));
+            app("OwnerService")->refreshRelevance($result["attached"],1);
+            app("OwnerService")->refreshRelevance($result["detached"],1,true);
+        }
         LogService::log(__METHOD__,"计费模型-录入作业计费",json_encode($request->input(),JSON_UNESCAPED_UNICODE));
         return response()->redirectTo("maintenance/priceModel/operation")->with("successTip","创建“".$request->input("name")."”成功");
     }
@@ -347,7 +353,11 @@ class PriceModelController extends Controller
         }
         //录入中间表
         /** @var OwnerPriceOperation $model */
-        if ($request->input("owner_id"))$model->ownerPriceOperationOwners()->sync($request->input("owner_id"));
+        if ($request->input("owner_id")){
+            $result = $model->ownerPriceOperationOwners()->sync($request->input("owner_id"));
+            app("OwnerService")->refreshRelevance($result["attached"],1);
+            app("OwnerService")->refreshRelevance($result["detached"],1,true);
+        }
         LogService::log(__METHOD__,"计费模型-修改作业计费",json_encode($request->input(),JSON_UNESCAPED_UNICODE));
         return response()->redirectTo("maintenance/priceModel/operation")->with("successTip","修改“".$request->input("name")."”成功");
     }
@@ -480,7 +490,9 @@ class PriceModelController extends Controller
             "initial_weight" => $request->input("initial_weight"),
             "additional_weight" => $request->input("additional_weight"),
         ]);
-        $model->owners()->sync($request->input("owner_id"));
+        $result = $model->owners()->sync($request->input("owner_id"));
+        app("OwnerService")->refreshRelevance($result["attached"],2);
+        app("OwnerService")->refreshRelevance($result["detached"],2,true);
         $model->logistics()->sync($request->input("logistic_id"));
         LogService::log(__METHOD__,"计费模型-录入快递计费",json_encode($request->input(),JSON_UNESCAPED_UNICODE));
         return response()->redirectTo("maintenance/priceModel/express")->with("successTip","录入“".$request->input("name")."”成功");
@@ -510,7 +522,9 @@ class PriceModelController extends Controller
         ]);
         $model = new OwnerPriceExpress();
         $model->id = $id;
-        $model->owners()->sync($request->input("owner_id"));
+        $result = $model->owners()->sync($request->input("owner_id"));
+        app("OwnerService")->refreshRelevance($result["attached"],2);
+        app("OwnerService")->refreshRelevance($result["detached"],2,true);
         $model->logistics()->sync($request->input("logistic_id"));
         LogService::log(__METHOD__,"计费模型-修改快递计费",json_encode($request->input(),JSON_UNESCAPED_UNICODE));
         return response()->redirectTo("maintenance/priceModel/express")->with("successTip","修改“".$request->input("name")."”成功");
@@ -588,7 +602,9 @@ class PriceModelController extends Controller
             "other_unit_id" => $request->input("other_unit_id"),
             "other_unit_range" => $request->input("other_unit_range"),
         ]);
-        $model->owners()->sync($request->input("owner_id"));
+        $result = $model->owners()->sync($request->input("owner_id"));
+        app("OwnerService")->refreshRelevance($result["attached"],3);
+        app("OwnerService")->refreshRelevance($result["detached"],3,true);
         $model->logistics()->sync($request->input("logistic_id"));
         LogService::log(__METHOD__,"计费模型-录入物流计费",json_encode($request->input(),JSON_UNESCAPED_UNICODE));
         return response()->redirectTo("maintenance/priceModel/logistic")->with("successTip","创建“".$request->input("name")."”成功");
@@ -622,7 +638,9 @@ class PriceModelController extends Controller
         ]);
         $model = new OwnerPriceLogistic();
         $model->id = $id;
-        $model->owners()->sync($request->input("owner_id"));
+        $result = $model->owners()->sync($request->input("owner_id"));
+        app("OwnerService")->refreshRelevance($result["attached"],3);
+        app("OwnerService")->refreshRelevance($result["detached"],3,true);
         $model->logistics()->sync($request->input("logistic_id"));
         LogService::log(__METHOD__,"计费模型-修改物流计费",json_encode($request->input(),JSON_UNESCAPED_UNICODE));
         return response()->redirectTo("maintenance/priceModel/logistic")->with("successTip","修改“".$request->input("name")."”成功");
@@ -876,7 +894,9 @@ class PriceModelController extends Controller
             "name" => $request->input("name"),
             "base_km" => $request->input("base_km"),
         ]);
-        $model->owners()->sync($request->input("owner_id"));
+        $result = $model->owners()->sync($request->input("owner_id"));
+        app("OwnerService")->refreshRelevance($result["attached"],4);
+        app("OwnerService")->refreshRelevance($result["detached"],4,true);
         LogService::log(__METHOD__,"计费模型-录入直发车计费",json_encode($request->input(),JSON_UNESCAPED_UNICODE));
         return response()->redirectTo("maintenance/priceModel/directLogistic")->with("successTip","创建“".$request->input("name")."”成功");
     }
@@ -911,7 +931,9 @@ class PriceModelController extends Controller
         ]);
         $model = new OwnerPriceDirectLogistic();
         $model->id = $id;
-        $model->owners()->sync($request->input("owner_id"));
+        $result = $model->owners()->sync($request->input("owner_id"));
+        app("OwnerService")->refreshRelevance($result["attached"],4);
+        app("OwnerService")->refreshRelevance($result["detached"],4,true);
         LogService::log(__METHOD__,"计费模型-修改直发车计费",json_encode($request->input(),JSON_UNESCAPED_UNICODE));
         return response()->redirectTo("maintenance/priceModel/directLogistic")->with("successTip","修改“".$request->input("name")."”成功");
     }

+ 37 - 0
app/Http/Controllers/TaxRateController.php

@@ -0,0 +1,37 @@
+<?php
+
+namespace App\Http\Controllers;
+
+use App\Components\AsyncResponse;
+use App\TaxRate;
+
+class TaxRateController extends Controller
+{
+    use AsyncResponse;
+    public function get()
+    {
+        return TaxRate::query()->get();
+    }
+
+    public function index()
+    {
+        $taxRates = TaxRate::query()->orderByDesc("id")->paginate(50);
+        return view("maintenance.taxRate.index",compact("taxRates"));
+    }
+
+    public function save()
+    {
+        $this->gate("税率-编辑");
+        $value = request("value");
+        if (!is_numeric($value) || $value>=100)$this->error("非法值");
+        if (request("id"))$taxRate = TaxRate::query()->where("id",request("id"))->update(["value"=>$value]);
+        else $taxRate = TaxRate::query()->create(["value"=>$value]);
+        $this->success($taxRate);
+    }
+
+    public function destroy()
+    {
+        $this->gate("税率-删除");
+        $this->success(TaxRate::destroy(request("id")));
+    }
+}

+ 13 - 1
app/Http/Controllers/TestController.php

@@ -6,6 +6,7 @@ namespace App\Http\Controllers;
 use App\Authority;
 use App\Batch;
 use App\Carrier;
+use App\CarType;
 use App\City;
 use App\Commodity;
 use App\CommodityBarcode;
@@ -16,6 +17,7 @@ use App\Console\Commands\SyncBatchTask;
 use App\Console\Commands\SyncWmsCommoditiesInformation;
 use App\Console\Commands\SyncWMSOrderTask;
 use App\Console\Commands\WasSyncWmsAsnInformation;
+use App\DeliveryAppointment;
 use App\Exceptions\ErrorException;
 use App\Events\CancelOrder;
 use App\Events\SendEmailEvent;
@@ -54,6 +56,7 @@ use App\OwnerFeeDetail;
 use App\OwnerFeeDetailLogistic;
 use App\OwnerPriceOperation;
 use App\OwnerPriceOperationItem;
+use App\OwnerStoragePriceModel;
 use App\Package;
 use App\Process;
 use App\ProcessDaily;
@@ -157,7 +160,16 @@ class TestController extends Controller
         dd(Region::query()->where("id", ">=", 404)->where("id", "<=", 432)->delete());
     }
     public function tt1(){
-        dd(config('database.redis.options.prefix'));
+        $a = 88;
+        $id = md5(date("m-d"));
+        dump($id);
+        $id = substr_replace($id,$a,5,0);
+        dump($id);
+        $len = strlen($id);
+        dump(substr($id,5,$len-32));
+        $id = substr($id,0,5).substr($id,5+$len-32);
+        dump($id);
+        dd($id == md5(date("m-d")));
     }
 
     public function zzd()

+ 1 - 2
app/Imports/AppointmentDetail.php

@@ -30,11 +30,10 @@ class AppointmentDetail implements ToCollection,WithMultipleSheets,WithHeadingRo
         $header = $collection->first();
         foreach ($this->row as $row)if (!isset($header[$row]))$this->error("表头不存在“".$row."”");
         $errors = Validator::make($collection->toArray(),[
-            "*.条码" => ["required_without_all:*.商品名称,*.数量"],
+            "*.条码" => ["required_without:*.商品名称"],
             "*.商品名称" => ["required_without:*.条码"],
             "*.数量" => ["required_without:*.条码","integer","min:1"],
         ],[
-            'required_without_all'=>':attribute 条码与商品名称,数量至少存在一组',
             'required_without'=>':attribute 条码与商品名称,数量至少存在一组',
             'integer'=>':attribute 必须为数字',
             'min'=>':attribute 非法',

+ 11 - 2
app/Owner.php

@@ -24,16 +24,21 @@ class Owner extends Model
         'checking_count',       //审核数量
         'deleted_at',           //删除时间
         "customer_id",          //客户ID
-        "tax_rate",             //税率
+        "tax_rate_id",          //税率
         "linkman",              //联系人
         "phone_number",         //联系电话
         "user_owner_group_id",  //项目组ID
         "waring_line_on",       //月单量预警
         "description",          //描述
         "warehouse_id",         //仓库ID
-        "user_workgroup_id",     //仓库小组(工作组)
+        "user_workgroup_id",    //仓库小组(工作组)
+        "relevance",             //关联模型的JSON数组
         'subjection'             //主体公司
     ];
+    //relevance说明 0:仓储 1:作业 2:快递 3:物流 4:直发 存储示例:["0","1"]存在仓储与作业计费
+    protected $casts = [
+        "relevance" => "array"
+    ];
     const subjection=[
         0=>'',
         1 => "宝时物流",
@@ -122,4 +127,8 @@ class Owner extends Model
     {   //耗材
         return $this->hasMany(OwnerMaterial::class,"owner_id","id");
     }
+    public function taxRate()
+    {   //税率
+        return $this->belongsTo(TaxRate::class);
+    }
 }

+ 9 - 1
app/OwnerReport.php

@@ -17,12 +17,16 @@ class OwnerReport extends Model
         "owner_id",                     //货主ID
         "counting_month",               //结算月
         "daily_average_order_amount",   //日均单量
-        "total",                        //总单量
+        "to_business_quantity",         //ToB单量
+        "to_customer_quantity",         //ToC单量
         "current_month_counting_area",  //结算月盘点面积
         "last_month_counting_area",     //结算月上月盘点面积
         "owner_bill_report_id"          //账单ID
     ];
     public $timestamps = false;
+    protected $appends=[
+        "total"
+    ];
 
     public function owner()
     {   //货主
@@ -40,4 +44,8 @@ class OwnerReport extends Model
     {
         return substr($value,0,7);
     }
+    public function getTotalAttribute()
+    {   //总单量
+        return $this->to_business_quantity + $this->to_customer_quantity;
+    }
 }

+ 4 - 0
app/Providers/AppServiceProvider.php

@@ -93,6 +93,8 @@ use App\Services\WeighExceptedService;
 use App\Services\OrderFreezeService;
 use App\Services\RegionService;
 use App\Services\UserWorkgroupService;
+use App\Services\DeliveryAppointment;
+use App\Services\DeliveryAppointmentService;
 use Illuminate\Queue\Events\JobFailed;
 use Illuminate\Support\Facades\Queue;
 use Illuminate\Support\Facades\Schema;
@@ -157,6 +159,8 @@ class AppServiceProvider extends ServiceProvider
         app()->singleton('CustomerLogStatusService',CustomerLogStatusService::class);
         app()->singleton('CustomerService',CustomerService::class);
         app()->singleton('DataHandlerService',DataHandlerService::class);
+        app()->singleton('DeliveryAppointment',DeliveryAppointment::class);
+        app()->singleton('DeliveryAppointmentService',DeliveryAppointmentService::class);
         app()->singleton('DepositoryService',DepositoryService::class);
         app()->singleton('FeatureService',FeatureService::class);
         app()->singleton('ForeignHaiRoboticsService',ForeignHaiRoboticsService::class);

+ 78 - 0
app/Services/DeliveryAppointmentService.php

@@ -0,0 +1,78 @@
+<?php 
+
+namespace App\Services;
+
+use App\CommodityBarcode;
+use App\DeliveryAppointmentDetail;
+use App\Traits\ServiceAppAop;
+use App\DeliveryAppointment;
+use Illuminate\Database\Eloquent\Builder;
+
+class DeliveryAppointmentService
+{
+    use ServiceAppAop;
+    protected $modelClass=DeliveryAppointment::class;
+
+    /**
+     * 根据吨,立方,SKU减产系数计算产能
+     *
+     * @param double $tonne
+     * @param double $cubicMeter
+     * @param int $amount
+     * @param int $rpcc reduced_production_capacity_coefficient
+     *
+     * @return double
+     */
+    public function calculateCapacity($tonne, $cubicMeter, $amount, $rpcc)
+    {
+        $need = max(($tonne*config("appointment.production_capacity.tonne")),
+            ($cubicMeter*config("appointment.production_capacity.cubic_meter")));
+        $coefficient = config("appointment.production_capacity.coefficient");
+        if ($amount && ($need/$amount < $coefficient)){
+            $need *= 1-(($coefficient-($need/$amount))*($rpcc/100));
+        }
+        return $need;
+    }
+
+    /**
+     * 根据提供的详情数组插入详情
+     *
+     * @param DeliveryAppointment|object $parent
+     * @param array $details
+     * @param string $name
+     * @param string $amount
+     * @param string $barCode
+     */
+    public function insertDetails($parent, array $details, $name="name", $amount="amount", $barCode="bar_code")
+    {
+        $codes = [];
+        $names = [];
+        foreach ($details as $detail){
+            if ($detail[$barCode])$codes[] = $detail[$barCode];
+            else $names[] = $detail[$name];
+        }
+        $map = [];//存储条码与ID的映射
+        CommodityBarcode::query()->with("commodity")->whereHas("commodity",function ($query)use($parent){
+            /** @var Builder $query */
+            $query->where("owner_id",$parent->owner_id);
+        })->whereIn("code",$codes)->orWhereHas("commodity",function ($query)use($names){
+            /** @var Builder $query */
+            $query->whereIn("name",$names);
+        })->get()->each(function ($commodity)use(&$map){
+            $map[$commodity->code] = $commodity->commodity_id;
+            $map[$commodity->commodity->name] = $commodity->commodity_id;
+        });
+        $insert = [];//插入的元素
+        foreach ($details as $detail){
+            $code = $detail[$barCode];
+            $insert[] = [
+                "delivery_appointment_id" => $parent->id,
+                "commodity_id"            => $code ? ($map[$code] ?? null) : ($map[$detail[$name]] ?? null),
+                "bar_code"                => $code,
+                "name"                    => $detail[$name],
+                "amount"                  => $detail[$amount],
+            ];
+        }
+        if ($insert)DeliveryAppointmentDetail::query()->insert($insert);
+    }
+}

+ 5 - 1
app/Services/OrderService.php

@@ -1023,7 +1023,9 @@ class OrderService
         $weight = 0;
         $logistic_bill = "";
 
-        if (!$order->logistic || $order->logistic->type != "快递")$logistic_fee = null;
+        if (!$order->logistic || $order->logistic->type == "物流")$logistic_fee = null;
+
+
 
         $items = [];
         foreach ($order->packages as &$package){
@@ -1249,4 +1251,6 @@ sql;
         return $result;
     }
 
+
+
 }

+ 10 - 13
app/Services/OwnerPriceExpressService.php

@@ -130,19 +130,16 @@ class OwnerPriceExpressService
     {
         if (!$weight)return -2;
 
-        $key = "price_express_".$province_id."_".$logistic_id."_".$owner_id;
-        $model = app(CacheService::class)->getOrExecute($key,function ()use($owner_id, $logistic_id, $province_id){
-            return OwnerPriceExpress::query()->with(["details"=>function($query)use($province_id){
-                /** @var Builder $query */
-                $query->where("province_id",$province_id);
-            }])->whereHas("owners",function ($query)use($owner_id){
-                /** @var Builder $query */
-                $query->where("id",$owner_id);
-            })->whereHas("logistics",function ($query)use($logistic_id){
-                /** @var Builder $query */
-                $query->where("id",$logistic_id);
-            })->first();
-        });
+        $model = OwnerPriceExpress::query()->with(["details"=>function($query)use($province_id){
+            /** @var Builder $query */
+            $query->where("province_id",$province_id);
+        }])->whereHas("owners",function ($query)use($owner_id){
+            /** @var Builder $query */
+            $query->where("id",$owner_id);
+        })->whereHas("logistics",function ($query)use($logistic_id){
+            /** @var Builder $query */
+            $query->where("id",$logistic_id);
+        })->first();
         if (!$model || !$model->details)return -1;
         if ($weight <= $model->initial_weight)return $model->details[0]->initial_weight_price;
         $weight -= $model->initial_weight;

+ 62 - 42
app/Services/OwnerPriceOperationService.php

@@ -124,7 +124,7 @@ class OwnerPriceOperationService
 
         if (!$rules)return -2;  //规则不存在跳出
 
-        $total = Cache::get(date("Y-m")."_".$matchObject["owner_id"]); //获取该货主本月单量
+        $total = Cache::get(date("Y-m")."|".$matchObject["owner_id"]); //获取该货主本月单量
         foreach ($rules as $rule){
             if (!$rule->items)continue; //不存在子规则跳出
             $isDiscount = false;    //是否存在满减
@@ -145,47 +145,7 @@ class OwnerPriceOperationService
                 //未被标记过处理时间或处理时间不为本月,或上次处理值过期,处理历史即时账单
                 $pivot = DB::selectOne(DB::raw("SELECT * FROM owner_price_operation_owner WHERE owner_price_operation_id = ? AND owner_id = ?"),[$rule->id,$owner_id]);
                 if ($pivot && (!$pivot->discount_date || substr($pivot->discount_date,0,7)!=date("Y-m") || $pivot->target_value < $targetValue)){
-                    try{
-                        DB::beginTransaction();
-                        $month = date("Y-m");
-                        $day = date("t",strtotime($month));
-                        foreach (OwnerFeeDetail::query()->with(["order.logistic","order.shop","order.packages.commodities.commodity","order.batch"])
-                                     ->where("owner_id",$owner_id)
-                                     ->whereBetween("worked_at",[$month."-01",$month."-".$day])->get() as $detail){
-                            $order = $detail->order;
-
-                            $logistic_fee = 0;
-                            $commodities = [];
-                            foreach ($order->packages as &$package){
-                                // 四维转二维
-                                foreach($package->commodities as &$commodity){
-                                    $commodity["commodity_name"] = $commodity->commodity ? $commodity->commodity->name : '';
-                                    $commodity["sku"] = $commodity->commodity ? $commodity->commodity->sku : '';
-                                }
-                                $commodities = array_merge($commodities,$package->commodities->toArray());
-                            }
-                            if ($logistic_fee!==null && $logistic_fee<0)$logistic_fee = null;
-
-                            $object = ["commodities"=>$commodities,
-                                "logistic_name"=>($order->logistic ? $order->logistic->name : ''),
-                                "shop_name"=>($order->shop ? $order->shop->name : ''),
-                                "order_type"=>$order->order_type,
-                                "batch_type" => $order->batch ? $order->batch->wms_type : '',
-                                "owner_id"=>$order->owner_id];
-                            $mapping = ["packages"=>"commodities","商品名称"=>"commodity_name",
-                                "承运商"=>"logistic_name", "店铺类型"=>"shop_name",
-                                "订单类型"=>"order_type","波次类型"=>"batch_type"];
-                            $money = $this->matchItem($rule->items,$mapping,$object,$units,$owner_id,false,$isDiscount,$discountIndex);
-                            if ($money>0)$detail->update(["work_fee"=>$money]);
-                            else LogService::log(__CLASS__,"处理历史即时账单时发生匹配错误","账单主键:".$detail->id."; 错误代码".$money);
-                        };
-                        DB::update(DB::raw("UPDATE owner_price_operation_owner SET discount_date = ?,target_value = ? WHERE  owner_price_operation_id = ? AND owner_id = ?"),
-                            [date("Y-m-d"),$targetValue,$rule->id,$owner_id]);
-                        DB::commit();
-                    }catch (\Exception $e){
-                        DB::rollBack();
-                        LogService::log(__CLASS__,"处理历史即时账单时发生系统错误","计费模型主键:".$rule->id."; 错误信息".$e->getMessage());
-                    }
+                    $this->handlePastBill($targetValue,$rule,$owner_id,$units,$discountIndex,$pivot);
                 }
             }
             if ($rule->strategy == '特征'){//特征策略匹配
@@ -355,4 +315,64 @@ class OwnerPriceOperationService
             $this->settingCount($packages,$amountColumn,$startNumber);
         }
     }
+
+    /**
+     * 处理历史账单
+     *
+     * @param int $targetValue
+     * @param object $rule
+     * @param int $owner_id
+     * @param array $units
+     * @param int $discountIndex
+     * @param object $pivot
+     */
+    public function handlePastBill($targetValue, $rule, $owner_id, $units, $discountIndex, $pivot)
+    {
+        //先标记成功 进入处理
+        DB::update(DB::raw("UPDATE owner_price_operation_owner SET discount_date = ?,target_value = ? WHERE  owner_price_operation_id = ? AND owner_id = ?"),
+            [date("Y-m-d"),$targetValue,$rule->id,$owner_id]);
+
+        try{
+            DB::beginTransaction();
+            $month = date("Y-m");
+            $day = date("t",strtotime($month));
+            foreach (OwnerFeeDetail::query()->with(["order.logistic","order.shop","order.packages.commodities.commodity","order.batch"])
+                         ->where("owner_id",$owner_id)
+                         ->whereBetween("worked_at",[$month."-01",$month."-".$day])->get() as $detail){
+                $order = $detail->order;
+
+                $logistic_fee = 0;
+                $commodities = [];
+                foreach ($order->packages as &$package){
+                    // 四维转二维
+                    foreach($package->commodities as &$commodity){
+                        $commodity["commodity_name"] = $commodity->commodity ? $commodity->commodity->name : '';
+                        $commodity["sku"] = $commodity->commodity ? $commodity->commodity->sku : '';
+                    }
+                    $commodities = array_merge($commodities,$package->commodities->toArray());
+                }
+                if ($logistic_fee!==null && $logistic_fee<0)$logistic_fee = null;
+
+                $object = ["commodities"=>$commodities,
+                    "logistic_name"=>($order->logistic ? $order->logistic->name : ''),
+                    "shop_name"=>($order->shop ? $order->shop->name : ''),
+                    "order_type"=>$order->order_type,
+                    "batch_type" => $order->batch ? $order->batch->wms_type : '',
+                    "owner_id"=>$order->owner_id];
+                $mapping = ["packages"=>"commodities","商品名称"=>"commodity_name",
+                    "承运商"=>"logistic_name", "店铺类型"=>"shop_name",
+                    "订单类型"=>"order_type","波次类型"=>"batch_type"];
+                $money = $this->matchItem($rule->items,$mapping,$object,$units,$owner_id,false,true,$discountIndex);
+                if ($money>0)$detail->update(["work_fee"=>$money]);
+                else LogService::log(__CLASS__,"处理历史即时账单时发生匹配错误","账单主键:".$detail->id."; 错误代码".$money);
+            };
+            DB::commit();
+        }catch (\Exception $e){
+            DB::rollBack();
+            //处理失败回退标记
+            DB::update(DB::raw("UPDATE owner_price_operation_owner SET discount_date = ?,target_value = ? WHERE  owner_price_operation_id = ? AND owner_id = ?"),
+                [$pivot->discount_date,$pivot->target_value,$rule->id,$owner_id]);
+            LogService::log(__CLASS__,"处理历史即时账单时发生系统错误","计费模型主键:".$rule->id."; 错误信息".$e->getMessage());
+        }
+    }
 }

+ 37 - 0
app/Services/OwnerService.php

@@ -5,6 +5,7 @@ namespace App\Services;
 use App\Authority;
 use App\OracleBasCustomer;
 use App\Owner;
+use App\Services\common\BatchUpdateService;
 use App\User;
 use Carbon\Carbon;
 use Illuminate\Database\Eloquent\Builder;
@@ -364,4 +365,40 @@ sql
         DB::table("authority_role")->whereIn("id_authority",$ids)->delete();
         Authority::destroy($ids);
     }
+
+    /**
+     * 计费模型变动时更新货主中关联属性
+     *
+     * @param integer|array $owner
+     * @param integer $type
+     * @param bool $isDestroy
+     *
+     */
+    public function refreshRelevance($owner, $type, $isDestroy)
+    {
+        if (!$owner)return;
+        if (!is_array($owner))$owner = [$owner];
+        $owners = Owner::query()->select("id","relevance")->find($owner);
+        $update = [["id","relevance"]];
+        foreach ($owners as $ow){
+            $relevance = $ow->relevance ?? [];
+            $index = array_search($type,$ow->relevance);
+            $exist = $index===false ? false : true;
+            if ($exist && $isDestroy){
+                $arr = array_splice($relevance,$index,1);
+                $update[] = [
+                    "id"=>$ow->id,
+                    "relevance"=>json_encode($arr),
+                ];
+            }
+            if (!$exist && !$isDestroy){
+                $arr = array_push($relevance,$type);
+                $update[] = [
+                    "id"=>$ow->id,
+                    "relevance"=>json_encode($arr),
+                ];
+            }
+        }
+        if (count($update)>1)app(BatchUpdateService::class)->batchUpdate("owners",$update);
+    }
 }

+ 8 - 8
app/Services/OwnerStoragePriceModelService.php

@@ -52,9 +52,9 @@ class OwnerStoragePriceModelService
     //暂时不考虑单位换算问题:后期可能存在多单位换算,此处仅视为单位为 m²,m³
     public function calculationAmount(OwnerStoragePriceModel $model, $area, $owner_id = null, $month = null)
     {
+        /** @var \stdClass $model */
         if (!$model || !$area) return 0;
         if ($area < $model->minimum_area) $area = $model->minimum_area;
-        $money = $area*$model->price;
         switch ($model->discount_type){
             case "按单减免":
                 if ($owner_id && $month){
@@ -62,29 +62,29 @@ class OwnerStoragePriceModelService
                         $report = OwnerReport::query()->select("id","total")
                             ->where("owner_id",$owner_id)
                             ->where("counting_month","like",$month."%")->first();
-                        $money -= $report ? ($report->total)*($model->discount_value) : 0;
+                        if ($report && $report->total>=0)$area -= floor($report->total/$model->discount_value);
                     }else{
                         $days = date('t', strtotime($month."-01"));
-                        $money *= $days;
+                        $area *= $days;
                         for($i=1;$i<=$days;$i++){
                             $d = $i<10 ? "0".$i : $i;
                             $query = DB::raw("SELECT COUNT(1) c FROM orders WHERE wms_status = ? and updated_at between ? and ?");
                             $count = DB::selectOne($query,['订单完成',$month."-".$d." 00:00:00",$month."-".$d." 23:59:59"]);
-                            $money -= $count ? ($count->c)*($model->discount_value) : 0;
+                            if ($count && $count->c>=0)$area -= floor($count->c/$model->discount_value);
                         }
                     }
                 }
                 break;
             case "固定减免":
                 if ($model->timeUnit->name == '月'){
-                    $money -= $model->discount_value;
+                    $area -= $model->discount_value;
                 }else{
                     $days = date('t', strtotime($month."-01"));
-                    $money *= $days;
-                    $money -= $days*$model->discount_value;
+                    $area *= $days;
+                    $area -= $days*$model->discount_value;
                 }
                 break;
         }
-        return $money;
+        return $area*$model->price;
     }
 }

+ 18 - 0
app/TaxRate.php

@@ -0,0 +1,18 @@
+<?php
+
+namespace App;
+
+use App\Traits\ModelTimeFormat;
+use Illuminate\Database\Eloquent\Model;
+
+use App\Traits\ModelLogChanging;
+
+class TaxRate extends Model
+{
+    use ModelLogChanging;
+    use ModelTimeFormat;
+
+    protected $fillable=[
+        "value"
+    ];
+}

+ 1 - 1
app/Warehouse.php

@@ -12,7 +12,7 @@ class Warehouse extends Model
     use ModelLogChanging;
 
     use ModelTimeFormat;
-    protected $fillable=['name','code'];
+    protected $fillable=['name','code',"production_capacity","reduced_production_capacity_coefficient"];
 
     public function userWorkgroups(){
         return $this->hasMany('App\UserWorkgroup');

+ 9 - 0
config/appointment.php

@@ -0,0 +1,9 @@
+<?php
+
+return [
+    "production_capacity" => [
+        "tonne"       => 1,
+        "cubic_meter" => 1,
+        "coefficient" => 5,
+    ],
+];

+ 66 - 0
database/migrations/2021_03_06_090856_create_tax_rates_table.php

@@ -0,0 +1,66 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class CreateTaxRatesTable extends Migration
+{
+    protected $values = [
+        0,3,6,11
+    ];
+    protected $authorities = [
+        "税率",
+        "税率-查询",
+        "税率-编辑",
+        "税率-删除",
+        "入库管理-客户预约-预约",
+        "入库管理-客户预约"
+    ];
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('tax_rates', function (Blueprint $table) {
+            $table->id();
+            $table->decimal("value",5,2)->unique()->comment("值");
+            $table->timestamps();
+        });
+        Schema::table('owners', function (Blueprint $table) {
+            $table->dropColumn("tax_rate");
+            $table->bigInteger("tax_rate_id")->nullable()->comment("外键税率");
+            $table->string("relevance")->nullable()->comment("关联模型的JSON数组");
+        });
+        foreach ($this->values as $value) \App\TaxRate::query()->firstOrCreate(["value"=>$value]);
+        foreach ($this->authorities as $authority)\App\Authority::query()->firstOrCreate(["name"=>$authority],["name"=>$authority,"alias_name"=>$authority]);
+        \App\Authority::query()->where("name","入库管理-盘收一体-客户预约")->delete();
+        Schema::table('warehouses', function (Blueprint $table) {
+            $table->decimal("production_capacity")->default(0)->comment("产能");
+            $table->integer("reduced_production_capacity_coefficient")->default(0)->comment("SKU减产系数");
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('tax_rates');
+        Schema::table('owners', function (Blueprint $table) {
+            $table->dropColumn("tax_rate_id");
+            $table->decimal("tax_rate")->nullable()->comment("税率");
+            $table->dropColumn("relevance");
+        });
+        foreach ($this->authorities as $authority)\App\Authority::query()->where("name",$authority)->delete();
+        \App\Authority::query()->firstOrCreate(["name"=>"入库管理-盘收一体-客户预约"],["name"=>"入库管理-盘收一体-客户预约","alias_name"=>"入库管理-盘收一体-客户预约"]);
+        Schema::table('warehouses', function (Blueprint $table) {
+            $table->dropColumn("production_capacity");
+            $table->dropColumn("reduced_production_capacity_coefficient");
+        });
+    }
+}

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

@@ -0,0 +1,36 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class ChangeOwnerReportsTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('owner_reports', function (Blueprint $table) {
+            $table->dropColumn("total");
+            $table->integer('to_business_quantity')->default(0)->comment("to b 单量");
+            $table->integer('to_customer_quantity')->default(0)->comment("to c 单量");
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('owner_reports', function (Blueprint $table) {
+            $table->integer('total')->nullable()->comment("结算月总单量");
+            $table->dropColumn("to_business_quantity");
+            $table->dropColumn("to_customer_quantity");
+        });
+    }
+}

+ 13 - 1
resources/sass/text.scss

@@ -193,4 +193,16 @@
     position: absolute;
     left: 55%;
     top: 2px;
-}
+}
+
+//浅色
+.opacity{
+    opacity: 0.6;
+}
+
+//选中的黑色阴影效果
+.box-shadow-dark{
+    box-shadow: 0 0 10px 5px rgba(0,0,0,0.9);
+    z-index:100;
+    position:relative;
+}

+ 122 - 23
resources/views/customer/project/area.blade.php

@@ -8,19 +8,20 @@
 
         @include("customer._selectedOwner")
         @include("customer.project._editArea")
-        <div id="form_div"></div>
-        <div>
-            <button type="button" class="btn btn-outline-dark btn-sm dropdown-toggle tooltipTarget" :class="[checkData.length>0?'btn-dark text-light':'']"
-                    data-toggle="dropdown" title="导出所有页将会以搜索条件得到的筛选结果,将其全部记录(每一页)导出">
-                导出Excel
-            </button>
-            <div class="dropdown-menu">
-                <a class="dropdown-item" @click="areaExport(false)" href="javascript:">导出勾选内容</a>
-                <a class="dropdown-item" @click="areaExport(true)" href="javascript:">导出所有页</a>
+        <!-- pc >544 -->
+        <div class="d-none d-sm-block">
+            <div id="form_div"></div>
+            <div>
+                <button type="button" class="btn btn-outline-dark btn-sm dropdown-toggle tooltipTarget" :class="[checkData.length>0?'btn-dark text-light':'']"
+                        data-toggle="dropdown" title="导出所有页将会以搜索条件得到的筛选结果,将其全部记录(每一页)导出">
+                    导出Excel
+                </button>
+                <div class="dropdown-menu">
+                    <a class="dropdown-item" @click="areaExport(false)" href="javascript:">导出勾选内容</a>
+                    <a class="dropdown-item" @click="areaExport(true)" href="javascript:">导出所有页</a>
+                </div>
+                <button class="ml-1 btn btn-sm btn-outline-primary" data-toggle="modal" data-target="#selectedOwner">新 增</button>
             </div>
-            <button class="ml-1 btn btn-sm btn-outline-primary" data-toggle="modal" data-target="#selectedOwner">新 增</button>
-        </div>
-        <div>
             <label for="all" id="cloneCheckAll" class="d-none">
                 <input id="all" type="checkbox" @click="checkAll($event)">全选
             </label>
@@ -35,7 +36,7 @@
                     <td>
                         <span v-if="area.status=='编辑中'">
                             <button class="btn btn-sm btn-outline-info" @click="edit(area,i)">编辑</button>
-                            <button class="btn btn-sm btn-outline-success" v-if="area.accountingArea" @click="audit(i)">审核</button>
+                            @can("客户管理-项目-用仓盘点-审核")<button class="btn btn-sm btn-outline-success" v-if="area.accountingArea" @click="audit(i)">审核</button>@endcan
                         </span>
                         <span v-if="area.status=='已完成'" class="text-success font-weight-bold">@{{ area.status }}</span>
                         <span v-if="area.status=='已审核'" class="text-primary font-weight-bold">@{{ area.status }}</span>
@@ -53,8 +54,95 @@
                     <td>@{{ area.accountingArea }}</td>
                 </tr>
             </table>
-            {{$areas->appends($params)->links()}}
         </div>
+        <!-- phone <544 -->
+        <div class="d-xl-none">
+            <div v-for="(area,i) in areas" class="mt-1 border border-1 rounded"
+                 @click="openAll(i)">
+                <div class="row">
+                    <div class="col-4">
+                        <label class="text-muted">序号:</label>@{{ i+1 }}
+                    </div>
+                    <div class="col-4 text-center">
+                        <b :class="area.status=='编辑中' ? 'text-secondary' : (area.status=='已完成' ? 'text-success' : 'text-primary')">@{{ area.status }}</b>
+                    </div>
+                    <div class="col-4">
+                        <span class="pull-right mr-1 text-primary font-weight-bold small" v-if="area.unitName=='m²' && area.status=='编辑中'">点击展开编辑</span>
+                    </div>
+                </div>
+                <div class="row">
+                    <div class="col-6">
+                        <label class="text-muted">项目:</label>@{{ area.ownerName }}
+                    </div>
+                    <div class="col-6">
+                        <label class="text-muted">客户:</label>@{{ area.customerName }}
+                    </div>
+                </div>
+                <div class="row">
+                    <div class="col-6">
+                        <label class="text-muted">用仓:</label>@{{ area.ownerStoragePriceModel }}
+                    </div>
+                    <div class="col-6">
+                        <label class="text-muted">单位:</label>@{{ area.unitName }}
+                    </div>
+                </div>
+                <div class="row">
+                    <div class="col-6">
+                        <label class="text-muted">项目组:</label>@{{ area.userOwnerGroupName }}
+                    </div>
+                    <div class="col-6">
+                        <label class="text-muted">结算月:</label>@{{ area.countingMonth }}
+                    </div>
+                </div>
+                <div class="row font-weight-bold">
+                    <div class="col-6">
+                        <label class="text-dark">结算值:</label>@{{ area.accountingArea }}
+                    </div>
+                    <div class="col-6">
+                        <label class="text-dark">平面区:</label>@{{ area.areaOnFlat }}
+                    </div>
+                </div>
+                <div class="row font-weight-bold">
+                    <div class="col-6">
+                        <label class="text-dark">货物整托:</label>@{{ area.areaOnTray }}
+                    </div>
+                    <div class="col-6">
+                        <label class="text-dark">货物半托:</label>@{{ area.areaOnHalfTray }}
+                    </div>
+                </div>
+                <div :id="'area_'+i" class="up" v-if="area.unitName=='m²' && area.status=='编辑中'">
+                    <div class="row">
+                        <label class="text-dark col-4">平面区:</label>
+                        <label class="col-8">
+                            <input :id="'item-'+i+'-areaOnFlat'" class="form-control form-control-sm" type="number" step="0.01" min="0" :value="area.areaOnFlat" @click="$event.stopPropagation();">
+                        </label>
+                    </div>
+                    <div class="row">
+                        <label class="text-dark col-4">货物整托:</label>
+                        <label class="col-8">
+                            <input :id="'item-'+i+'-areaOnTray'" class="form-control form-control-sm" type="number" step="0.01" min="0" :value="area.areaOnTray" @click="$event.stopPropagation();">
+                        </label>
+                    </div>
+                    <div class="row">
+                        <label class="text-dark col-4">货物半托:</label>
+                        <label class="col-8">
+                            <input :id="'item-'+i+'-areaOnHalfTray'" class="form-control form-control-sm" type="number" step="0.01" min="0" :value="area.areaOnHalfTray" @click="$event.stopPropagation();">
+                        </label>
+                    </div>
+                    <div class="row">
+                        <div class="col-10 offset-1">
+                            @can('客户管理-项目-用仓盘点-审核')<button type="button" @click.stop="submitArea(i)" class="btn btn-sm btn-outline-primary w-100">提交编辑</button>@endcan
+                        </div>
+                    </div>
+                </div>
+                <div class="row mt-2" v-if="area.status=='编辑中'">
+                    <div class="col-10 offset-1">
+                        @can('客户管理-项目-用仓盘点-审核')<button type="button" @click.stop="audit(i)" class="btn btn-sm btn-outline-success w-100">审核</button>@endcan
+                    </div>
+                </div>
+            </div>
+        </div>
+        {{$areas->appends($params)->links()}}
     </div>
 @stop
 
@@ -123,6 +211,7 @@
                 }
             },
             mounted(){
+                $(".up").slideUp();
                 $('#container').removeClass('d-none');
                 let data=[
                     [
@@ -173,6 +262,9 @@
                 },0);
             },
             methods:{
+                openAll(index){
+                    $("#area_"+index).slideToggle();
+                },
                 areaExport(isAll){
                     let url = '{{url('customer/project/area/export')}}';
                     let token='{{ csrf_token() }}';
@@ -196,22 +288,29 @@
                     this.area = Object.assign({},area);
                     this.index = index;
                 },
-                submitArea(){
+                submitArea(i = null){
                     let url = "{{url('customer/project/updateArea')}}";
-                    window.tempTip.postBasicRequest(url,this.area,res=>{
-                        if (this.areas[this.index].ownerGroupId !== res.user_owner_group_id){
-                            this.areas[this.index].ownerGroupId = res.user_owner_group_id;
+                    let param = this.area;
+                    let index = this.index;
+                    if (i!==null){
+                        index = i;
+                        param = {id:this.areas[i].id,areaOnTray:document.getElementById("item-"+i+"-areaOnTray").value,
+                            areaOnHalfTray:document.getElementById("item-"+i+"-areaOnHalfTray").value,areaOnFlat:document.getElementById("item-"+i+"-areaOnFlat").value};
+                    }
+                    window.tempTip.postBasicRequest(url,param,res=>{
+                        if (this.areas[index].ownerGroupId !== res.user_owner_group_id){
+                            this.areas[index].ownerGroupId = res.user_owner_group_id;
                             this.ownerGroups.some(group=>{
                                 if(group.name === res.user_owner_group_id){
-                                    this.areas[this.index].userOwnerGroupName = group.value;
+                                    this.areas[index].userOwnerGroupName = group.value;
                                     return true;
                                 }
                             });
                         }
-                        this.areas[this.index].areaOnTray = res.area_on_tray;
-                        this.areas[this.index].areaOnHalfTray = res.area_on_half_tray;
-                        this.areas[this.index].areaOnFlat = res.area_on_flat;
-                        this.areas[this.index].accountingArea = res.accounting_area;
+                        this.areas[index].areaOnTray = res.area_on_tray;
+                        this.areas[index].areaOnHalfTray = res.area_on_half_tray;
+                        this.areas[index].areaOnFlat = res.area_on_flat;
+                        this.areas[index].accountingArea = res.accounting_area;
                         $("#editArea").modal("hide");
                         return "修改成功";
                     },true);

+ 11 - 3
resources/views/customer/project/create.blade.php

@@ -96,7 +96,7 @@
                     owner_group_id : "{{$owner->user_owner_group_id ?? ''}}",
                     user_workgroup_id : "{{$owner->user_workgroup_id ?? ''}}",
                     warehouse_id : "{{ $owner->warehouse_id ?? ''}}",
-                    tax_rate : "{{$owner->tax_rate ?? ''}}",
+                    tax_rate_id : "{{$owner->tax_rate_id ?? ''}}",
                     linkman : "{{$owner->linkman ?? ''}}",
                     phone_number : "{{$owner->phone_number ?? ''}}",
                     description : "{{$owner->description ?? ''}}",
@@ -266,6 +266,7 @@
                     if (!this.owner.id)return;
                     if (base === this.base)return;
                     if (base === 'three') this._loadStorage();
+                    if (base === 'two')this._getTaxRates()
                     this.base = base;
                 },
                 //切换类型
@@ -381,6 +382,8 @@
                     if (!this.owner.customer_id) error["customer_id"] = ["必须选择客户"];
                     if (!this.owner.owner_group_id) error["owner_group_id"] = ["必须选择项目小组"];
                     if (!this.owner.warehouse_id) error["warehouse_id"] = ["必须选择仓库"];
+                    if (!this.owner.user_workgroup_id) error["user_workgroup_id"] = ["必须选择仓库小组"];
+                    if (!this.owner.tax_rate_id) error["tax_rate_id"] = ["必须选择税率"];
                     if (JSON.stringify(error) !== "{}"){
                         this.errors = error;
                         return;
@@ -392,7 +395,7 @@
                     params.owner_group_id !== old.owner_group_id ||
                     params.user_workgroup_id !== old.user_workgroup_id ||
                     params.warehouse_id !== old.warehouse_id ||
-                    params.tax_rate !== old.tax_rate ||
+                    params.tax_rate_id !== old.tax_rate_id ||
                     params.waring_line_on !== old.waring_line_on ||
                     params.phone_number !== old.phone_number ||
                     params.subjection !== old.subjection ||
@@ -409,7 +412,7 @@
                             this.ownerTemp.owner_group_id = res.owner_group_id;
                             this.ownerTemp.user_workgroup_id = res.user_workgroup_id;
                             this.ownerTemp.warehouse_id = res.warehouse_id;
-                            this.ownerTemp.tax_rate = res.tax_rate;
+                            this.ownerTemp.tax_rate_id = res.tax_rate_id;
                             this.ownerTemp.waring_line_on = res.waring_line_on;
                             this.ownerTemp.phone_number = res.phone_number;
                             this.ownerTemp.description = res.description;
@@ -567,6 +570,11 @@
                     let url = "{{url('maintenance/carType/get')}}";
                     window.axios.post(url).then(res=>{this._setModelData("cars",res.data);});
                 },
+                //获取税率
+                _getTaxRates(){
+                    let url = "{{url('maintenance/taxRate/get')}}";
+                    window.axios.post(url).then(res=>{this._setModelData("taxRates",res.data);});
+                },
                 //保存模型
                 saveModel(){
                     this._clearRefuse();

+ 6 - 2
resources/views/customer/project/index.blade.php

@@ -62,7 +62,7 @@
             <table class="d-none" id="headerRoll"></table>
             <table class="table table-sm text-nowrap table-striped table-hover" id="headerParent">
                 <tr id="header"></tr>
-                <tr v-for="(owner,i) in owners" @click="selectTableRow(owner.id,$event)">
+                <tr v-for="(owner,i) in owners" :class="owner.id==id ? 'focusing' : ''"  @click="(selectTableRow(owner.id,$event)) && (id=owner.id)">
                     <td>
                         <label><input type="checkbox" :value="owner.id" v-model="checkData"></label>
                     </td>
@@ -71,6 +71,7 @@
                     <td>@{{ owner.customer_name }}</td>
                     <td>@{{ owner.user_owner_group_name }}</td>
                     <td>@{{ owner.user_work_group_name }}</td>
+                    <td><b>@{{ owner.relevance.length }}</b>/5</td>
                     <td>@{{ owner.created_at }}</td>
                     <td>@{{ owner.customer_company_name }}</td>
                     <td>@{{ ownerSubjection[owner.subjection] }}</td>
@@ -102,6 +103,7 @@
                 owners : [
                     @foreach($owners as $owner)
                     {   id : "{{$owner->id}}",
+                        relevance:@json($owner->relevance ?? []),
                         customer_name:"{{$owner->customer ? $owner->customer->name : ''}}",
                         //tax_rate  : "{{--{{$owner->tax_rate}}--}}",
                         name : "{{$owner->name}}",
@@ -147,7 +149,8 @@
                     @endforeach
                 ],
                 ownerSubjection:{!! json_encode(\App\Owner::subjection,JSON_UNESCAPED_UNICODE) !!},
-                selectTr:''
+                selectTr:'',
+                id:"",
             },
             mounted(){
                 $('#container').removeClass('d-none');
@@ -177,6 +180,7 @@
                     {name:'customer',value: '客户'},
                     {name:'user_owner_group_name',value: '项目小组'},
                     {name:'user_work_group_name',value: '仓库小组'},
+                    {name:'relevance', neglect: true,value: '计费模型填写情况'},
                     {name:'created_at',value: '创建日期'},
                     {name:'customer_full_name',value: '公司全称'},
                     {name:'subjection',value: '主体公司'},

+ 9 - 3
resources/views/customer/project/part/_storage.blade.php

@@ -74,10 +74,16 @@
         <strong>@{{ errors.discount_type[0] }}</strong>
     </span>
 </div>
-<div class="row mt-3">
+<div class="row mt-3" v-if="model.storage.discount_type != '无减免'">
     <label for="discount_value" class="col-2">减免值</label>
-    <input id="discount_value" type="number" min="0" step="0.001" class="col-6 form-control"
-           :class="errors.discount_value ? 'is-invalid' : ''" v-model="model.storage.discount_value">
+    <label class="col-6 mb-0 input-group ml-0">
+        <input id="discount_value" type="number" min="0" step="0.01" class="col-6 form-control" style="margin-left: -4%"
+               :class="errors.discount_value ? 'is-invalid' : ''" v-model="model.storage.discount_value">
+        <span class="d-block input-group-append">
+            <span class="input-group-text font-weight-bold" v-if="model.storage.discount_type == '按单减免'">单减 1@{{ poolMapping.units[model.storage.unit_id] }}</span>
+            <span class="input-group-text font-weight-bold" v-else>@{{ poolMapping.units[model.storage.unit_id] }}</span>
+        </span>
+    </label>
     <span class="invalid-feedback mt-0 offset-2" role="alert" v-if="errors.discount_value">
         <strong>@{{ errors.discount_value[0] }}</strong>
     </span>

+ 7 - 5
resources/views/customer/project/part/_two.blade.php

@@ -28,7 +28,7 @@
     </span>
 </div>
 <div class="row mt-3">
-    <label for="user_workgroup_id" class="col-2">仓库小组</label>
+    <label for="user_workgroup_id" class="col-2 text-info">仓库小组</label>
     <select id="user_workgroup_id" v-model="owner.user_workgroup_id" @change="selectGroup()" class="form-control form-control-sm col-4 mb-0" :class="errors.user_workgroup_id ? 'is-invalid' : ''" >
         <option v-for="userGroup in filterUserGroups" :value="userGroup.id" v-if="userGroup.warehouse_id == owner.warehouse_id">@{{ userGroup.name }}</option>
     </select>
@@ -44,10 +44,12 @@
     </select>
 </div>
 <div class="row mt-3">
-    <label for="tax_rate" class="col-2">税率<span class="badge badge-secondary">%</span></label>
-    <input type="number" v-model="owner.tax_rate" step="0.01" id="tax_rate" class="form-control form-control-sm col-3 mb-0" :class="errors.tax_rate ? 'is-invalid' : ''">
-    <span class="invalid-feedback offset-2 mt-0" role="alert" v-if="errors.tax_rate">
-        <strong>@{{ errors.tax_rate[0] }}</strong>
+    <label for="tax_rate_id" class="col-2 text-info">税率</label>
+    <select id="tax_rate_id" v-model="owner.tax_rate_id" class="form-control form-control-sm col-4 mb-0" :class="errors.tax_rate_id ? 'is-invalid' : ''" >
+        <option v-for="taxRate in pool.taxRates" :value="taxRate.id">@{{ taxRate.value }}%</option>
+    </select>
+    <span class="invalid-feedback offset-2 mt-0" role="alert" v-if="errors.tax_rate_id">
+        <strong>@{{ errors.tax_rate_id[0] }}</strong>
     </span>
 </div>
 <div class="row mt-3">

+ 4 - 0
resources/views/maintenance/menu.blade.php

@@ -115,6 +115,10 @@
                 <li class="nav-item">
                     <a class="nav-link text-muted" href="{{url('maintenance/supplier')}}" :class="{active:isActive('supplier',2)}">供应商</a>
                 </li>@endcan
+            @can('税率')
+                <li class="nav-item">
+                    <a class="nav-link text-muted" href="{{url('maintenance/taxRate')}}" :class="{active:isActive('taxRate',2)}">税率</a>
+                </li>@endcan
             @can('系统配置')
                 <li class="nav-item">
                     <a class="nav-link text-muted" href="{{url('maintenance/configuration')}}" :class="{active:isActive('configuration',2)}">系统配置</a>

+ 23 - 0
resources/views/maintenance/taxRate/_edit.blade.php

@@ -0,0 +1,23 @@
+<div class="modal fade" tabindex="-1" role="dialog" id="modal">
+    <div class="modal-dialog modal-lg modal-dialog-centered modal-dialog-scrollable">
+        <div class="modal-content">
+            <div class="modal-header">
+                <button type="button" class="close" data-dismiss="modal">&times;</button>
+            </div>
+            <div class="modal-body">
+                <div class="row">
+                    <label class="col-2 offset-1" for="value">税率</label>
+                    <label class="col-6 mb-0 input-group">
+                        <input type="number" min="0" step="0.01"  class="form-control" v-model="taxRate.value">
+                        <span class="d-block input-group-append">
+                            <span class="input-group-text font-weight-bold">%</span>
+                        </span>
+                    </label>
+                </div>
+            </div>
+            <div class="modal-footer">
+                <button type="button" class="btn btn-success" @click="submit()">提交</button>
+            </div>
+        </div>
+    </div>
+</div>

+ 88 - 0
resources/views/maintenance/taxRate/index.blade.php

@@ -0,0 +1,88 @@
+@extends('layouts.app')
+@section('title')设置@endsection
+@section('content')
+    <span id="nav2">
+       @component('maintenance.menu')@endcomponent
+    </span>
+    <div class="container-fluid" id="container">
+        <div class="card">
+            <div class="card-body">
+                @include("maintenance.taxRate._edit")
+                <div class="row pull-left ml-1">
+                    @can("税率-编辑")<button class="btn btn-outline-info mb-1 mr-3" @click="openModal()"><span class="fa fa-plus"></span>&nbsp;新&nbsp;&nbsp;增</button>@endcan
+                </div>
+                <table class="table table-hover table-striped text-nowrap">
+                    <tr>
+                        <th>序号</th>
+                        <th>税率</th>
+                        <th>创建时间</th>
+                        <th>最后操作时间</th>
+                        <th></th>
+                    </tr>
+                    <tr v-for="(taxRate,i) in taxRates">
+                        <td>@{{ i+1 }}</td>
+                        <td>@{{ taxRate.value }}%</td>
+                        <td class="text-muted">@{{ taxRate.created_at }}</td>
+                        <td class="text-muted">@{{ taxRate.updated_at }}</td>
+                        <td>
+                            @can("税率-编辑")<button class="btn btn-sm btn-outline-info" @click="openModal(taxRate)">改</button>@endcan
+                            @can("税率-删除")<button class="btn btn-sm btn-outline-danger" @click="deleteModel(taxRate,i)">删</button>@endcan
+                        </td>
+                    </tr>
+                </table>
+            </div>
+        </div>
+    </div>
+@stop
+@section("lastScript")
+    <script>
+        new Vue({
+            el:"#container",
+            data:{
+                taxRates:[
+                    @foreach($taxRates as $taxRate)@json($taxRate),@endforeach
+                ],
+                taxRate:{},
+            },
+            methods:{
+                openModal(model){
+                    if (model) this.taxRate={id:model.id,value:model.value};
+                    else this.taxRate={};
+                    $("#modal").modal("show");
+                },
+                submit(){
+                    let url="{{url('maintenance/taxRate/save')}}";
+                    let msg=this.taxRate.id ? "成功修改税率"  : "成功新增税率";
+                    window.tempTip.postBasicRequest(url,this.taxRate,(res)=>{
+                        if (this.taxRate.id){
+                            this.taxRates.some((model)=> {
+                                if (model.id === this.taxRate.id){
+                                    model.value = this.taxRate.value;
+                                    return true;
+                                }
+                            });
+                        }else this.taxRates.unshift({
+                            id:res.id,
+                            value:res.value,
+                            created_at:res.created_at,
+                            updated_at:res.updated_at,
+                        });
+                        $("#modal").modal("hide");
+                        return msg;
+                    },true);
+                },
+                deleteModel(model,index){
+                    let url="{{url('maintenance/taxRate/destroy')}}";
+                    let params = {id:model.id};
+                    let msg="成功删除税率“"+model.value+"%”";
+                    window.tempTip.confirm("您确定要删除税率“"+model.value+"%”吗?",()=>{
+                        window.tempTip.postBasicRequest(url,params,res=>{
+                            this.$delete(this.taxRates,index);
+                            return msg;
+                        });
+                    });
+                },
+            },
+        });
+    </script>
+@stop

+ 28 - 0
resources/views/maintenance/warehouse/create.blade.php

@@ -38,6 +38,34 @@
                             @enderror
                         </div>
                     </div>
+                    <div class="form-group row">
+                        <label for="production_capacity" class="col-2 col-form-label text-right">产能</label>
+                        <div class="col-8">
+                            <input id="production_capacity" type="number" step="0.01" min="0" class="form-control @error('production_capacity') is-invalid @enderror"
+                                   name="production_capacity" autocomplete="off" value="{{ old('production_capacity') }}" required>
+                            @error('production_capacity')
+                            <span class="invalid-feedback" role="alert">
+                                <strong>{{ $message }}</strong>
+                            </span>
+                            @enderror
+                        </div>
+                    </div>
+                    <div class="form-group row">
+                        <label for="reduced_production_capacity_coefficient" class="col-2 col-form-label text-right">SKU减产系数</label>
+                        <div class="col-8 input-group">
+                            <input id="reduced_production_capacity_coefficient" type="number" class="form-control @error('reduced_production_capacity_coefficient') is-invalid @enderror"
+                                   step="1" min="0" max="100" autocomplete="off"
+                                   name="reduced_production_capacity_coefficient"  value="{{ old('reduced_production_capacity_coefficient') }}" required>
+                            <span class="d-block input-group-append">
+                                <span class="input-group-text font-weight-bold">%</span>
+                            </span>
+                            @error('reduced_production_capacity_coefficient')
+                            <span class="invalid-feedback" role="alert">
+                                <strong>{{ $message }}</strong>
+                            </span>
+                            @enderror
+                        </div>
+                    </div>
                     <div class="form-group row">
                         <div class="col-8 offset-2">
                             <input type="submit" class="btn btn-success form-control">

+ 28 - 0
resources/views/maintenance/warehouse/edit.blade.php

@@ -44,6 +44,34 @@
                             @enderror
                         </div>
                     </div>
+                    <div class="form-group row">
+                        <label for="production_capacity" class="col-2 col-form-label text-right">产能</label>
+                        <div class="col-8">
+                            <input id="production_capacity" type="number" step="0.01" min="0" class="form-control @error('production_capacity') is-invalid @enderror"
+                                   name="production_capacity" autocomplete="off" value="{{ old('production_capacity') ?? $warehouse->production_capacity }}" required>
+                            @error('production_capacity')
+                            <span class="invalid-feedback" role="alert">
+                                <strong>{{ $message }}</strong>
+                            </span>
+                            @enderror
+                        </div>
+                    </div>
+                    <div class="form-group row">
+                        <label for="reduced_production_capacity_coefficient" class="col-2 col-form-label text-right">SKU减产系数</label>
+                        <div class="col-8 input-group">
+                            <input id="reduced_production_capacity_coefficient" type="number" class="form-control @error('reduced_production_capacity_coefficient') is-invalid @enderror"
+                                   step="1" min="0" max="100" autocomplete="off"
+                                   name="reduced_production_capacity_coefficient"  value="{{ old('reduced_production_capacity_coefficient') ?? $warehouse->reduced_production_capacity_coefficient }}" required>
+                            <span class="d-block input-group-append">
+                                <span class="input-group-text font-weight-bold">%</span>
+                            </span>
+                            @error('reduced_production_capacity_coefficient')
+                            <span class="invalid-feedback" role="alert">
+                                <strong>{{ $message }}</strong>
+                            </span>
+                            @enderror
+                        </div>
+                    </div>
                     <div class="form-group row">
                         <div class="col-8 offset-2">
                             <input type="submit" class="btn btn-outline-dark form-control">

+ 8 - 1
resources/views/maintenance/warehouse/index.blade.php

@@ -17,6 +17,8 @@
                         <th>ID</th>
                         <th>仓库名</th>
                         <th>仓库代码</th>
+                        <th>产能</th>
+                        <th>SKU减产系数</th>
                         <th>创建时间</th>
                         <th>操作</th>
                     </tr>
@@ -24,6 +26,8 @@
                         <td class="text-muted">@{{warehouse.id}}</td>
                         <td>@{{warehouse.name}}</td>
                         <td>@{{warehouse.code}}</td>
+                        <td>@{{warehouse.production_capacity}}</td>
+                        <td>@{{warehouse.reduced_production_capacity_coefficient}}%</td>
                         <td class="text-muted">@{{warehouse.created_at}}</td>
                         <td>
                             @can('仓库-编辑')
@@ -46,7 +50,10 @@
             data:{
                 warehouses:[
                     @foreach( $warehouses as $warehouse )
-                    {id:'{{$warehouse->id}}',name:'{{$warehouse->name}}',code:'{{$warehouse->code}}',created_at:'{{$warehouse->created_at}}'},
+                    {id:'{{$warehouse->id}}',name:'{{$warehouse->name}}',
+                        production_capacity:"{{$warehouse->production_capacity}}",
+                        reduced_production_capacity_coefficient:"{{$warehouse->reduced_production_capacity_coefficient}}",
+                        code:'{{$warehouse->code}}',created_at:'{{$warehouse->created_at}}'},
                     @endforeach
                 ],
             },

+ 0 - 12
resources/views/store/checkingReceive/_selectDate.blade.php

@@ -1,12 +0,0 @@
-<div class="modal fade" tabindex="-1" role="dialog" id="selectDate">
-    <div class="modal-dialog modal-lg modal-dialog-centered">
-        <div class="modal-content">
-            <div class="modal-body">
-
-            </div>
-            <div class="modal-footer">
-                <button type="button" class="btn btn-success pull-right" @click="createReport()">生成</button>
-            </div>
-        </div>
-    </div>
-</div>

+ 1 - 5
resources/views/store/checkingReceive/menu.blade.php

@@ -4,13 +4,9 @@
             <ul class="nav nav-pills">
                 @can('入库管理-盘收一体-任务')
                     <li class="nav-item">
-                        <a target="store/checkingReceive/mission" class="nav-link" href="{{url('store/checkingReceive/mission')}}" :class="{active:isActive('mission',3)}">任务</a>
+                        <a target="store/checkingReceive/mission" class="nav-link" href="{{url('store/checkingReceive/mission')}}" :class="{active:isActive('',4)}">任务</a>
                     </li> @endcan
                 {{$slot}}
-                @can('入库管理-盘收一体-客户预约')
-                <li class="nav-item">
-                    <a target="store/checkingReceive/mission" class="nav-link" href="{{url('store/checkingReceive/appointment')}}" :class="{active:isActive('appointment',3)}">客户预约</a>
-                </li> @endcan
             </ul>
         </div>
     </div>

+ 27 - 0
resources/views/store/deliveryAppointment/_selectDate.blade.php

@@ -0,0 +1,27 @@
+<div class="modal fade" id="modal" tabindex="-1" role="dialog" aria-hidden="true">
+    <div class="modal-dialog modal-dialog-centered modal-lg" role="document">
+        <div class="modal-content">
+            <div class="modal-header">
+                <div class="text-center font-weight-bold">预约时间</div>
+                <button type="button" class="close" data-dismiss="modal">&times;</button>
+            </div>
+            <div class="modal-body">
+                <div class="row">
+                    <div v-for="capacity in capacities" :style="{width:(100/capacities.length)+'%'}" class="container">
+                        <div class="row">
+                            <div class="col-12 text-center">@{{ capacity.date }}</div>
+                        </div>
+                        <div class="row border border-2 rounded" v-for="period in capacity.period" style="min-height: 50px;"
+                             :class="[period.isAvailable ? 'cursor-pointer text-dark bg-info' : 'opacity bg-secondary',
+                             selectDate.date==capacity.date && selectDate.time==period.index ? 'box-shadow-dark' : '']" @click="selectPeriod(capacity.date,period.index,period.isAvailable)">
+                            <div class="col-12 m-auto text-center">@{{ period.time }}</div>
+                        </div>
+                    </div>
+                </div>
+            </div>
+            <div class="modal-footer">
+                <button class="col-12 btn btn-success" @click="submitAppointment()">确定预约</button>
+            </div>
+        </div>
+    </div>
+</div>

+ 103 - 12
resources/views/store/checkingReceive/appointment.blade.php → resources/views/store/deliveryAppointment/appointment.blade.php

@@ -4,7 +4,7 @@
 @section('content')
     <span id="nav2">
     @component('store.menu')@endcomponent
-    @component('store.checkingReceive.menu')@endcomponent
+    @component('store.deliveryAppointment.menu')@endcomponent
     </span>
     <div class="container-fluid" id="container">
         <div class="card">
@@ -30,9 +30,10 @@
                                 </label>
                                 <label class="col-2">
                                     <div class="dropdown">
-                                        <input type="text" class="form-control" v-model="car.car_id" :id="'car-'+i" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
-                                        <div class="dropdown-menu" :aria-labelledby="'car-'+i">
-
+                                        <input type="text" class="form-control" v-model="car.car_name" :id="'car-'+i" @input="searchCar(car.car_name)"
+                                               data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
+                                        <div class="dropdown-menu" :aria-labelledby="'car-'+i" v-show="car.car_name && haystack.length>0">
+                                            <span class="row offset-1 text-secondary" v-for="c in haystack" @click="selectCar(c,i)">@{{ c.name }}<br></span>
                                         </div>
                                     </div>
                                 </label>
@@ -71,7 +72,9 @@
                     </div>
                     <div class="row mt-2 ml-1">
                         <label class="col-2" for="warehouse">仓库</label>
-                        <input class="col-6 form-control" type="text" id="warehouse" v-model="model.warehouse_id" :class="errors.warehouse_id ? 'is-invalid' : ''">
+                        <select id="warehouse" v-model="model.warehouse_id" class="col-4 form-control" :class="errors.warehouse_id ? 'is-invalid' : ''">
+                            <option v-for="warehouse in warehouses" :value="warehouse.id">@{{ warehouse.name }}</option>
+                        </select>
                     </div>
                     <label class="row mt-0 mb-0 ml-1" v-if="errors.warehouse_id">
                         <label class="offset-2 text-danger font-weight-bold small">@{{ errors.warehouse_id[0] }}</label>
@@ -108,6 +111,7 @@
                         <button type="button" class="btn btn-success col-8 offset-2" @click="submit()">提 交 预 约</button>
                     </div>
                 </div>
+                @include("store.deliveryAppointment._selectDate")
             </div>
         </div>
     </div>
@@ -118,25 +122,41 @@
         new Vue({
             el:"#container",
             data:{
-                cars:[],
+                cars:[@foreach($cars as $car)@json($car),@endforeach],
                 model:{
                     cars:[{license_plate_number:"",car_id:"",driver_name:"",driver_phone:""}],
                 },
-                owners:@json($owners),
+                owners:[@foreach($owners as $owner)@json($owner),@endforeach],
+                warehouses:[@foreach($warehouses as $warehouse)@json($warehouse),@endforeach],
                 fileName:"",
                 details:[],
                 errors : {
                     details:"",
                 },
-                datePeriod : {
-                    0:"9-11",1:"13-17",
-                },
+                haystack:[],
+                capacities:[],
+                selectDate:{},
             },
             mounted(){
                 if (this.owners.length === 1)this.$set(this.model,"owner_id",this.owners[0].id);
                 $('#openFile').tooltip();
             },
             methods:{
+                selectCar(car,index){
+                    this.model.cars[index].car_id = car.id;
+                    this.model.cars[index].car_name = car.name;
+                },
+                searchCar(name){
+                    if (!name){
+                        this.haystack = [];
+                        return;
+                    }
+                    let stack = [];
+                    this.cars.forEach(car=>{
+                        if (car.name.indexOf(name)!==-1)stack.push(car);
+                    });
+                    this.haystack = stack;
+                },
                 seekOwner(e){
                     let val = e.target.value;
                     this.owners.some(owner=>{
@@ -156,7 +176,7 @@
                     this.fileName = file.name;
                     let formData = new FormData();
                     formData.append("file",file);
-                    window.axios.post('{{url('store/checkingReceive/appointment/import')}}',formData,{
+                    window.axios.post('{{url('store/deliveryAppointment/appointment/import')}}',formData,{
                         'Content-Type':'multipart/form-data'
                     }).then(res=>{
                         if (!res.data.success){
@@ -207,15 +227,86 @@
                         errors.tonne = ["吨与立方值至少填写一个"];
                         errors.cubic_meter = ["立方值与吨至少填写一个"];
                     }
+                    let change = [];
+                    let insert = [];
                     this.model.cars.forEach((car,i)=>{
                         if (!car.license_plate_number) errors[i+".license_plate_number"] = ["不得为空"];
+                        if (!car.car_id && car.car_name){
+                            if (this.cars.every(c=>{
+                               if (c.name === car.car_name){
+                                   car.car_id = c.id;
+                                   return false;
+                               }
+                               return true;
+                            })){
+                                change.push({index:i,name:car.car_name});
+                                if (insert.indexOf(car.car_name)===-1)insert.push(car.car_name);
+                            }
+                        }
                     });
                     if (JSON.stringify(errors) !== "{}"){
                         errors.details=this.errors.details;
                         this.errors = errors;
                         return
                     }
-                    window.tempTip.postBasicRequest();
+                    if (change.length>0)this._addCars(insert,change);
+                    let param = {
+                        warehouse_id:this.model.warehouse_id,
+                        tonne:this.model.tonne,
+                        cubic_meter:this.model.cubic_meter,
+                        detail_amount:this.details.length,
+                    };
+                    window.tempTip.postBasicRequest("{{url('store/deliveryAppointment/getCapacity')}}",param,res=>{
+                        this.capacities = res;
+                        $("#modal").modal("show");
+                    });
+                },
+                _addCars(arr,change){
+                    window.tempTip.postBasicRequest("{{url('maintenance/carType/batchInsert')}}",{arr:arr},res=>{
+                        res.forEach(data=>{
+                            change.forEach(car=>{
+                                if (data.name === car.name)this.model.cars[car.index].car_id = data.id;
+                            });
+                        });
+                    });
+                },
+                selectPeriod(date,time,isSelect){
+                    if (isSelect) this.selectDate = {date:date,time:time};
+                },
+                submitAppointment(){
+                    window.tempTip.setDuration(3000);
+                    window.tempTip.setIndex(1099);
+                    if (!this.selectDate.date){
+                        window.tempTip.show("尚未选择预约时间");
+                        return;
+                    }
+                    let url = "{{url('store/deliveryAppointment/submitAppointment')}}";
+                    let param = {
+                        model:this.model,
+                        details:this.details,
+                        date:this.selectDate,
+                    };
+                    window.tempTip.postBasicRequest(url,param,res=>{
+                        if (res.errors){
+                            this.errors = errors;
+                            return;
+                        }
+                        if (res.isFail){
+                            this.capacities.some(capacity=>{
+                                if (capacity.date === this.selectDate.date){
+                                    capacity.period.some(p=>{
+                                        if (p.index === this.selectDate.time){
+                                            p.isAvailable = false;
+                                            return true;
+                                        }
+                                    });
+                                    return true;
+                                }
+                            });
+                            window.tempTip.show("该预约时段已经被抢占了,请选择其他时段");
+                            return;
+                        }
+                    },true);
                 },
             },
         });

+ 12 - 0
resources/views/store/deliveryAppointment/menu.blade.php

@@ -0,0 +1,12 @@
+<div id="nav2">
+    <div class="container-fluid nav3">
+        <div class="card menu-third" >
+            <ul class="nav nav-pills">
+                @can('入库管理-客户预约-预约')
+                <li class="nav-item">
+                    <a target="store/checkingReceive/mission" class="nav-link" href="{{url('store/deliveryAppointment/appointment')}}" :class="{active:isActive('appointment',3)}">客户预约</a>
+                </li> @endcan
+            </ul>
+        </div>
+    </div>
+</div>

+ 6 - 2
resources/views/store/menu.blade.php

@@ -6,9 +6,13 @@
                 <li class="nav-item">
                     <a target="store/inStorage/index" class="nav-link"  href="{{url('store/inStorage/index')}}" :class="{active:isActive('inStorage',2)}">入库</a>
                 </li> @endcan
-                @can('入库管理-盘收一体')
+            @can('入库管理-盘收一体')
+            <li class="nav-item">
+                <a target="store/checkingReceive/mission" class="nav-link"  href="{{url('store/checkingReceive/mission')}}" :class="{active:isActive('checkingReceive',2)}">盘收一体</a>
+            </li> @endcan
+            @can('入库管理-客户预约')
                 <li class="nav-item">
-                    <a target="store/checkingReceive/mission" class="nav-link"  href="{{url('store/checkingReceive/mission')}}" :class="{active:isActive('checkingReceive',2)}">盘收一体</a>
+                    <a target="store/deliveryAppointment/appointment" class="nav-link"  href="{{url('store/deliveryAppointment/appointment')}}" :class="{active:isActive('deliveryAppointment',2)}">客户预约</a>
                 </li> @endcan
             @can('入库管理-快速入库')
                 <li class="nav-item">

+ 13 - 0
routes/web.php

@@ -188,6 +188,12 @@ Route::group(['prefix'=>'maintenance'],function(){
     });
     Route::group(['prefix'=>'carType'],function (){
         Route::post('get','CarTypesController@get');
+        Route::post('batchInsert','CarTypesController@batchInsert');
+    });
+    Route::group(['prefix'=>'taxRate'],function (){
+        Route::post('get','TaxRateController@get');
+        Route::post('save','TaxRateController@save');
+        Route::post('destroy','TaxRateController@destroy');
     });
     Route::group(['prefix'=>"log"],function (){
         Route::get("exception",'LogController@exception');
@@ -214,6 +220,7 @@ Route::group(['prefix'=>'maintenance'],function(){
 
     Route::get('syncRedisLogs','LogController@syncRedisLogs');
     Route::get('region', 'RegionController@index');
+    Route::get('taxRate', 'TaxRateController@index');
     Route::resource('log', 'LogController');
     Route::resource('user', 'UserController');
     Route::resource('role', 'RoleController');
@@ -406,7 +413,13 @@ Route::group(['prefix'=>'store'],function(){
         Route::post('insertItem','StoreCheckingReceiveController@insertItem');
         Route::get('mission','StoreCheckingReceiveController@mission');
         Route::post('destroyItem','StoreCheckingReceiveController@destroyItem');
+    });
+
+    /** 客户预约 */
+    Route::group(['prefix'=>'deliveryAppointment'],function(){
         Route::get('appointment','DeliveryAppointmentController@appointment');
+        Route::post('getCapacity','DeliveryAppointmentController@getCapacity');
+        Route::post('submitAppointment','DeliveryAppointmentController@submitAppointment');
         Route::group(['prefix'=>'appointment'],function(){
             Route::post('import','DeliveryAppointmentController@import');
         });