Parcourir la source

Merge branch 'master' into SyncOrder_Tack

# Conflicts:
#	database/factories/CommodityFactory.php
#	tests/Services/OracleDOCOrderHeaderService/GetWMSOrderOnStartDateTest.php
#	tests/Services/OracleDOCOrderHeaderService/GetWmsOrderOnStartDateEditTest.php
#	tests/Services/OrderPackageCommoditiesService/RegroupOrderCommoditiesTest.php
#	tests/Services/OrderPackageService/SyncOrderPackageTest.php
#	tests/Services/OrderPackageService/SyncPackageByOrderHeadersTest.php
#	tests/Services/OrderService/SyncOrderTest.php
ajun il y a 5 ans
Parent
commit
b0821c5d79
79 fichiers modifiés avec 2071 ajouts et 203 suppressions
  1. 20 9
      .gitlab-ci.yml
  2. 1 1
      app/Commodity.php
  3. 12 5
      app/Http/Controllers/CommodityController.php
  4. 67 0
      app/Http/Controllers/PackageController.php
  5. 4 4
      app/Http/Controllers/StoreCheckingReceiveController.php
  6. 14 6
      app/Http/Controllers/StoreController.php
  7. 5 7
      app/Http/Controllers/TestController.php
  8. 1 1
      app/Imports/StoreCheckingReceiveImport.php
  9. 0 1
      app/Imports/StoreCheckingReceiveSheets.php
  10. 6 10
      app/LaborReport.php
  11. 23 0
      app/OrderPackage.php
  12. 20 2
      app/Services/CommodityService.php
  13. 2 2
      app/Services/CustomerService.php
  14. 76 15
      app/Services/FeatureService.php
  15. 1 1
      app/Services/OwnerPriceExpressService.php
  16. 3 4
      app/Services/OwnerPriceLogisticService.php
  17. 31 15
      app/Services/OwnerPriceOperationService.php
  18. 3 3
      app/Services/OwnerStoragePriceModelService.php
  19. 1 1
      app/Services/common/QueryService.php
  20. 1 1
      app/UserDutyCheck.php
  21. 16 0
      database/factories/CarTypeFactory.php
  22. 10 1
      database/factories/CommodityFactory.php
  23. 16 0
      database/factories/FeatureFactory.php
  24. 1 1
      database/factories/LogisticFactory.php
  25. 21 0
      database/factories/OwnerAreaReportFactory.php
  26. 3 4
      database/factories/OwnerBillReportFactory.php
  27. 0 1
      database/factories/OwnerFactory.php
  28. 9 23
      database/factories/OwnerFeeDetailFactory.php
  29. 2 4
      database/factories/OwnerOutStorageRuleFactory.php
  30. 15 0
      database/factories/OwnerPriceDirectLogisticCarFactory.php
  31. 13 0
      database/factories/OwnerPriceDirectLogisticFactory.php
  32. 4 6
      database/factories/OwnerPriceExpressFactory.php
  33. 16 0
      database/factories/OwnerPriceExpressProvinceFactory.php
  34. 23 0
      database/factories/OwnerPriceLogisticDetailFactory.php
  35. 19 0
      database/factories/OwnerPriceLogisticFactory.php
  36. 6 4
      database/factories/OwnerReportFactory.php
  37. 3 4
      database/factories/OwnerStoragePriceModelFactory.php
  38. 2 4
      database/factories/ProcessMethodFactory.php
  39. 2 4
      database/factories/ShopFactory.php
  40. 2 6
      public/t.php
  41. 25 1
      resources/views/maintenance/priceModel/operation/create.blade.php
  42. 5 0
      resources/views/maintenance/priceModel/operation/index.blade.php
  43. 5 0
      resources/views/store/checkingReceive/mission.blade.php
  44. 51 29
      resources/views/store/checkingReceive/show.blade.php
  45. 1 0
      routes/web.php
  46. 1 1
      tests/Inventory/Services/InventoryAccountService/InventoryAccountService_CreateInventoryMissionRecordTest.php
  47. 1 1
      tests/Services/CacheService/GetOrExecuteTest.php
  48. 1 1
      tests/Services/CommodityBarcodeService/InsertMany_onCommoditiesTest.php
  49. 2 2
      tests/Services/CommodityService/SyncBarcodesTest.php
  50. 87 0
      tests/Services/CustomerService/CustomerTest.php
  51. 151 0
      tests/Services/FeatureService/FeatureServiceTest.php
  52. 1 1
      tests/Services/OracleDOCOrderHeaderService/GetWmsOrderOnstartDateCreateTest.php
  53. 86 0
      tests/Services/OwnerAreaReportService/OwnerAreaReportServiceTest.php
  54. 74 0
      tests/Services/OwnerBillReportService/OwnerBillReportServiceTest.php
  55. 87 0
      tests/Services/OwnerFeeDetailService/OwnerFeeDetailServiceTest.php
  56. 135 0
      tests/Services/OwnerOutStorageRuleService/OwnerOutStorageRuleServiceTest.php
  57. 199 0
      tests/Services/OwnerPriceDirectLogisticService/OwnerPriceDirectLogisticServiceTest.php
  58. 203 0
      tests/Services/OwnerPriceExpressService/OwnerPriceExpressServiceTest.php
  59. 220 0
      tests/Services/OwnerPriceLogisticService/OwnerPriceLogisticServiceTest.php
  60. 169 0
      tests/Services/OwnerPriceOperationService/OwnerPriceOperationServiceTest.php
  61. 72 0
      tests/Services/OwnerStoragePriceModelService/OwnerStoragePriceModelServiceTest.php
  62. 0 17
      tests/Unit/Customer/CustomerTest.php
  63. 18 0
      tests/Unit/EchoTest.php
  64. 0 0
      tests/old/CarTypeTest.php
  65. 0 0
      tests/old/CarrierTest.php
  66. 0 0
      tests/old/CityTest.php
  67. 0 0
      tests/old/ExampleTest.php
  68. 0 0
      tests/old/FULXProcessTest.php
  69. 0 0
      tests/old/MeasureMonitorTest.php
  70. 0 0
      tests/old/MeasuringMachineTest.php
  71. 0 0
      tests/old/PackageTest.php
  72. 0 0
      tests/old/PaperBoxTest.php
  73. 0 0
      tests/old/ProvinceTest.php
  74. 0 0
      tests/old/UnitTest.php
  75. 0 0
      tests/old/WaybillFinancialExceptedTest.php
  76. 0 0
      tests/old/WaybillFinancialSnapshotTest.php
  77. 0 0
      tests/old/WaybillPriceModelTest.php
  78. 0 0
      tests/old/WaybillTest.php
  79. 3 0
      tests/webApi/thirdPart/haiq/storage.http

+ 20 - 9
.gitlab-ci.yml

@@ -2,30 +2,41 @@ stages:
   - build
   - test
   - deploy
+cache:
+  paths:
+    - vendor/
+    - node_modules/
+    - .env
+before_script:
+  # Install composer dependencies
+#  - wget https://composer.github.io/installer.sig -O - -q | tr -d '\n' > installer.sig
+#  - php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
+#  - php -r "if (hash_file('SHA384', 'composer-setup.php') === file_get_contents('installer.sig')) { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
+#  - php composer-setup.php
+#  - php -r "unlink('composer-setup.php'); unlink('installer.sig');"
+#  - php composer.phar install
+  - echo "before script"
+
+
 
 build_maven:
   stage: build
   tags:
     - was
   script:
-    - echo "build maven....."
-    - echo "mvn clean"
-    - echo "done"
+    - echo "build ....."
 
 test_springboot:
   stage: test
   tags:
     - was
   script:
-    - echo "run java test....."
-    - echo "java -test"
-    - echo "done"
+    - echo "run test....."
+    - vendor/bin/phpunit --testsuite=Unit
 
 deploy_springboot:
   stage: deploy
   tags:
     - was
   script:
-    - echo "deploy springboot...."
-    - echo "run mvn install"
-    - echo "done"
+    - echo "deploy ...."

+ 1 - 1
app/Commodity.php

@@ -9,7 +9,7 @@ use App\Traits\ModelTimeFormat;
 class Commodity extends Model
 {
     use ModelTimeFormat;
-    protected $fillable=['name','sku','owner_id','created_at','length','width','height','volumn',"type","pack"];
+    protected $fillable=['name','sku','owner_id','created_at','length','width','height','volumn',"type","pack_spec"];
     protected $appends=['barcode'];
 //    protected $appends=['barcode','owner_name','owner_code'];
 

+ 12 - 5
app/Http/Controllers/CommodityController.php

@@ -132,6 +132,13 @@ class CommodityController extends Controller
         return view('maintenance.commodity.import');
     }
 
+    public function isExist(Request $request)
+    {
+        if (app('CommodityService')->isExist($request->input()))
+            return ["success"=>true];
+        else return ["success"=>false];
+    }
+
     public function importExcel(Request $request)
     {
         $isOverride = $request->input('isOverride');
@@ -217,7 +224,7 @@ class CommodityController extends Controller
         $commodities = $commodityService->getOwnerCommodities(['owner_id' => $owner_id, 'sku'=>$skus]);
         $updateCommodities = [];
         $updateCommodities[] = [
-            'id', 'sku', 'name', 'length', 'width', 'height', 'volumn',"pack"
+            'id', 'sku', 'name', 'length', 'width', 'height', 'volumn',"pack_spec"
         ];
         $barcodeMap = [];
         $commoditiesId = [];
@@ -229,7 +236,7 @@ class CommodityController extends Controller
             if (($commodity->sku != $trimSku) || ($commodity->length != $wms->skulength)
                 || ($commodity->width != $wms->skuwidth) || ($commodity->name != $wms->descr_c)
                 || ($commodity->height != $wms->skuhigh) || ($commodity->volumn != $wms->cube)
-                || ($commodity->pack === null)){
+                || ($commodity->pack_spec === null)){
                 $updateCommodities[] = [
                     'id'=>$commodity->id,
                     'sku'=>$trimSku,
@@ -238,7 +245,7 @@ class CommodityController extends Controller
                     'width' => $wms->skuwidth,
                     'height' => $wms->skuhigh,
                     'volumn' => $wms->cube,
-                    "pack"  => $wms->packid == 'STANDARD' ? 0 : explode("/",$wms->packid)[1],
+                    "pack_spec"  => $wms->packid == 'STANDARD' ? 0 : explode("/",$wms->packid)[1],
                 ];
             }
             if ($wms->alternate_sku1){
@@ -300,7 +307,7 @@ class CommodityController extends Controller
                 'width' => $wms->skuwidth,
                 'height' => $wms->skuhigh,
                 'volumn' => $wms->cube,
-                "pack"  => $wms->packid == 'STANDARD' ? 0 : explode("/",$wms->packid)[1],
+                "pack_spec"  => $wms->packid == 'STANDARD' ? 0 : explode("/",$wms->packid)[1],
                 "created_at" => $today,
             ];
             $barcodeMap[$wms->sku] = [];
@@ -340,7 +347,7 @@ class CommodityController extends Controller
                             'width' => $goods['width'],
                             'height' => $goods['height'],
                             'volumn' => $goods['volumn'],
-                            "pack" => $goods["pack"],
+                            "pack_spec" => $goods["pack_spec"],
                         ];
                         unset($createCommodities[$barcodeIndex[$code->code]]);
                         break;

+ 67 - 0
app/Http/Controllers/PackageController.php

@@ -44,6 +44,7 @@ class PackageController extends Controller
      */
     public function store(Request $request)
     {
+        $start_at = microtime(true);
         if(!Gate::allows('称重管理-录入')){ return redirect(url('/'));  }
         $this->validator($request)->validate();
         $logistic_number=$request->input('logistic_number');
@@ -56,6 +57,9 @@ class PackageController extends Controller
         $package=null;
         $successTip = '操作成功';
 
+        $time1 = floor((microtime(true)-$start_at));
+        app('LogService')->log(__METHOD__,'timemark_'.__FUNCTION__,"{$batch_number} 1:$time1");
+        $start_at = microtime(true);
 
         /** @var OrderPackage $package */
         if ($order_code){
@@ -71,24 +75,62 @@ class PackageController extends Controller
             }
         }
         $accomplishToWMS=new Api\thirdPart\flux\PackageController();
+
+
+        $time1 = floor((microtime(true)-$start_at));
+        app('LogService')->log(__METHOD__,'timemark_'.__FUNCTION__,"{$batch_number} 2:$time1");
+        $start_at = microtime(true);
+
         if($batch_number){
             app('LogService')->log(__METHOD__,'活动波次开始同步_'.__FUNCTION__,json_encode($package),Auth::user()['name']);
 //            $this->syncBatch($package->batch_number,$weight,null,null,null,Carbon::now(),null);
             $result=$accomplishToWMS->markWMSOnBatch($batch_number,$weight);
+
+
+            $time1 = floor((microtime(true)-$start_at));
+            app('LogService')->log(__METHOD__,'timemark_'.__FUNCTION__,"{$batch_number} 3:$time1");
+            $start_at = microtime(true);
+
             OrderPackage::createPackagesFromBatchCode($batch_number,$weight);
+
+
+            $time1 = floor((microtime(true)-$start_at));
+            app('LogService')->log(__METHOD__,'timemark_'.__FUNCTION__,"{$batch_number} 4:$time1");
+            $start_at = microtime(true);
+
             if($package&&$package->isActivityBatch())
                 $package->unifyThisMeasureUnderSameBatch();
 
+
+
+            $time1 = floor((microtime(true)-$start_at));
+            app('LogService')->log(__METHOD__,'timemark_'.__FUNCTION__,"{$batch_number} 5.1:$time1");
+            $start_at = microtime(true);
+
+
             if ($result['result']){
                 Controller::logS(__METHOD__,'SUCCESS_'.__FUNCTION__,'批量更改波次上传成功'.$batch_number);
                 $successTip = "批量录入波次成功!波次号:$batch_number";
                 return redirect('package/create')->with('successTip', $successTip);
             }
             Controller::logS(__METHOD__,'error_'.__FUNCTION__,'批量更改波次上传异常:'.$result['message'].$batch_number);
+
+
+            $time1 = floor((microtime(true)-$start_at));
+            app('LogService')->log(__METHOD__,'timemark_'.__FUNCTION__,"{$batch_number} 5.2:$time1");
+            $start_at = microtime(true);
+
             return redirect('package/create')->with('successError','录入失败!'.$result['message']);
         }
         if (!$package && !$logistic_number)return redirect('package/create')->with('successError','录入失败!系统内没有对应波次的包裹!');
         if ($package){
+
+
+            $time1 = floor((microtime(true)-$start_at));
+            app('LogService')->log(__METHOD__,'timemark_'.__FUNCTION__,"{$batch_number} 7:$time1");
+            $start_at = microtime(true);
+
+
             if(!$package->batch_number)$package->batch_number=$batch_number;
             //if(!$package->order_code)$package->order_code=$order_code;
             $package->fetchAllFromOracle();
@@ -103,7 +145,20 @@ class PackageController extends Controller
             $package->save();
             app('LogService')->log(__METHOD__,'create_'.__FUNCTION__,json_encode($package),Auth::user()['name']);
 //            event(new WeighedEvent($package));
+
+
+            $time1 = floor((microtime(true)-$start_at));
+            app('LogService')->log(__METHOD__,'timemark_'.__FUNCTION__,"{$batch_number} 7.1:$time1");
+            $start_at = microtime(true);
+
+
         }else{
+
+            $time1 = floor((microtime(true)-$start_at));
+            app('LogService')->log(__METHOD__,'timemark_'.__FUNCTION__,"{$batch_number} 7.3:$time1");
+            $start_at = microtime(true);
+
+
             /** @var OrderPackageService */
             $package = app('OrderPackageService')->firstOrCreate($logistic_number,[
                 'weight'=>$weight,
@@ -124,7 +179,19 @@ class PackageController extends Controller
             }
             $package->save();
             $successTip = $str;
+
+            $time1 = floor((microtime(true)-$start_at));
+            app('LogService')->log(__METHOD__,'timemark_'.__FUNCTION__,"{$batch_number} 7.4:$time1");
+            $start_at = microtime(true);
+
+
         }
+
+        $time1 = floor((microtime(true)-$start_at));
+        app('LogService')->log(__METHOD__,'timemark_'.__FUNCTION__,"{$batch_number} 8:$time1");
+        $start_at = microtime(true);
+
+
         return redirect('package/create')->with('successTip', $successTip);
     }
 

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

@@ -296,7 +296,7 @@ class StoreCheckingReceiveController extends Controller
         ]);
         if (count($docAsnDetails) < 1) return ['success'=>false, 'data'=>'该货主下此ASN号不存在'];
 
-        $diffAmount = 0;
+        $diffAmount = null;
         $skus = [];
         foreach ($docAsnDetails as $detail){
             if ($skus[$detail->sku] ?? false) $skus[$detail->sku] += $detail->expectedqty;
@@ -322,7 +322,7 @@ class StoreCheckingReceiveController extends Controller
                 $item->asn_diff_amount = $asn_diff_amount;
                 unset($skus[$item->commodity->sku]);
             }
-            $diffAmount += $item->asn_diff_amount;
+            if ($item->asn_diff_amount)$diffAmount += $item->asn_diff_amount;
         }
         if (count($updateItems) > 0){
             app('StoreCheckingReceiveItemService')->batchUpdate($updateItems);
@@ -357,7 +357,7 @@ class StoreCheckingReceiveController extends Controller
             if (count($createItems) > 0)app('StoreCheckingReceiveItemService')->insert($createItems);
         }
         $data = app('StoreCheckingReceiveService')->updateFind($storeCheckingReceive,[
-            'asn'=>$asn,'is_asn_diff'=>$diffAmount==0 ? "否" : "是",'status'=>'已ASN入库'
+            'asn'=>$asn,'is_asn_diff'=>$diffAmount===0 ? "否" : "是",'status'=>'已ASN入库'
         ]);
         app('LogService')->log(__METHOD__,"修改盘收任务",json_encode($data,JSON_UNESCAPED_UNICODE));
         return ['success'=>true, 'data'=>$data];
@@ -375,7 +375,7 @@ class StoreCheckingReceiveController extends Controller
         if ($storeCheckingReceive->status == '已收货')return ['success'=>false, 'data'=>'盘收任务已结束'];
 
         $storeController = new StoreController();
-        $result = $storeController->quickStorage($storeCheckingReceive->asn,"正品",null);
+        $result = $storeController->quickStorage($storeCheckingReceive->asn,"正品",null,false);
         if ($result['success']) $data = $storeCheckingReceiveService->updateFind($storeCheckingReceive,['status'=>"已收货"]);
         else{
             $data = $storeCheckingReceiveService->updateFind($storeCheckingReceive,['status'=>"收货失败"]);

+ 14 - 6
app/Http/Controllers/StoreController.php

@@ -22,8 +22,10 @@ use Illuminate\Routing\Redirector;
 use Illuminate\Support\Facades\DB;
 use Illuminate\Support\Facades\Gate;
 use Illuminate\Support\Facades\Validator;
+use Illuminate\Support\Str;
 use Illuminate\View\View;
 use App\Http\Controllers\Api\thirdPart\flux\StoreController as FStoreController;
+use Ramsey\Uuid\Uuid;
 
 class StoreController extends Controller
 {
@@ -174,15 +176,20 @@ class StoreController extends Controller
         return ['success'=>false, 'data'=>"失败!请检查错误日志"];
     }
 
-    public function quickStorage($asnno,$quality,$depository_code)
+    public function quickStorage($asnno,$quality,$depository_code,$isVerification = true)
     {
+        $task = Store::query()->where("asn_code",$asnno)->where("stored_method","快速入库")
+            ->where("status","已入库")->first();
+        if ($task)return ['success'=>false, 'data'=>"已被快速入库"];
         $db = DB::connection('oracle');
         $query = DB::raw("SELECT * FROM DOC_ASN_HEADER WHERE ASNNO = ?");
         $asn = $db->selectOne($query,[$asnno]);
         if (!$asn) return ['success'=>false, 'data'=>"单据号不存在"];
         if ($asn->asnstatus != '00')return ['success'=>false, 'data'=>'单据号状态非创建订单'];
-        if (array_search($asn->customerid,array_values(config('stores.owners'))) === false)return ['success'=>false, 'data'=>"不允许该货主快速入库"];
-        if (array_search($asn->asntype,array_values(config('stores.types'))) === false)return ['success'=>false, 'data'=>"该单据类型不允许被入库"];
+        if ($isVerification){
+            if (array_search($asn->customerid,array_values(config('stores.owners'))) === false)return ['success'=>false, 'data'=>"不允许该货主快速入库"];
+            if (array_search($asn->asntype,array_values(config('stores.types'))) === false)return ['success'=>false, 'data'=>"该单据类型不允许被入库"];
+        }
         $query = DB::raw("SELECT b.ALTERNATE_SKU1,h.WAREHOUSEID,h.asnno,d.ASNLINENO,d.SKUDESCRC,h.CUSTOMERID,d.SKU,d.PACKID,d.RECEIVEDQTY_EACH,d.EXPECTEDQTY_EACH,d.LOTATT01,d.LOTATT02,d.lotatt04,".
             "d.lotatt05,d.lotatt08,d.USERDEFINE1,d.USERDEFINE2,d.USERDEFINE3,d.USERDEFINE4,d.USERDEFINE5,d.RECEIVINGLOCATION FROM DOC_ASN_DETAILS d ".
             " LEFT JOIN BAS_SKU b ON d.CUSTOMERID = b.CUSTOMERID AND d.SKU = b.SKU INNER JOIN DOC_ASN_HEADER h ON d.ASNNO = h.ASNNO WHERE h.ASNNO = ?");
@@ -202,8 +209,9 @@ class StoreController extends Controller
         $items = [];
         $toDay = Carbon::now()->toDateTimeString();
         $depositories = [];
+        $traceId = rand(100,999);
         foreach ($details as $detail) {
-            $result = $this->executeSP($detail,$asnno,$depository_code,$db,$quality,$conn,$sql_sp);
+            $result = $this->executeSP($detail,$asnno,$depository_code,$db,$quality,$conn,$sql_sp,$traceId);
             if (substr($result, 0, 3) != '000') {
                 oci_close($conn);
                 app('LogService')->log(__METHOD__,"快速入库-FLUX收货失败","ASNNO:".$asnno.";ERROR:".$result);
@@ -245,13 +253,13 @@ class StoreController extends Controller
         return ['success'=>true,"data"=>"已成功将“".$asnno."”入库"];
     }
 
-    private function executeSP($detail, $asnno, $depository_code, $db, $quality, $conn, $sql_sp){
+    private function executeSP($detail, $asnno, $depository_code, $db, $quality, $conn, $sql_sp,$traceId){
         $IN_Warehouse = $detail->warehouseid ?? '';
         $In_Process_Action = '3';
         $In_ASNNo_C = $detail->asnno ?? '';
         $In_ASNLineNo_C = $detail->asnlineno ?? '';
         $In_FMTraceID_C = '';
-        $In_New_TraceID_C = '';
+        $In_New_TraceID_C = $traceId;
         $In_ProductStatus = '00';
         $In_ProductStatus_Descr = '正常';
         $In_HoldRejectCode_C = 'OK';

+ 5 - 7
app/Http/Controllers/TestController.php

@@ -11,6 +11,7 @@ use App\Events\CancelOrder;
 use App\Imports\OrderTrackingImport;
 use App\InventoryAccount;
 use App\LaborReport;
+use App\Feature;
 use App\Log;
 use App\Logistic;
 use App\OracleActAllocationDetails;
@@ -23,6 +24,7 @@ use App\OrderCommodity;
 use App\OrderIssue;
 use App\OrderPackage;
 use App\Owner;
+use App\OwnerAreaReport;
 use App\Package;
 use App\Process;
 use App\ProcessDaily;
@@ -32,6 +34,7 @@ use App\RejectedBillItem;
 use App\Services\CacheService;
 use App\Services\common\BatchUpdateService;
 use App\Services\common\DataHandlerService;
+use App\Services\FeatureService;
 use App\Services\InventoryCompareService;
 use App\Services\OracleDocAsnHerderService;
 use App\Services\OracleDOCOrderHeaderService;
@@ -42,7 +45,6 @@ use App\Services\OrderTrackingService;
 use App\Services\OwnerService;
 use App\Services\StoreService;
 use App\Services\WarehouseService;
-use App\Unit;
 use App\User;
 use App\Warehouse;
 use Carbon\Carbon;
@@ -91,12 +93,8 @@ class TestController extends Controller
         }
     }
     public function test4(){
-        DB::beginTransaction();
-        Unit::query()->lockForUpdate()->where("id",14)->first();
-        for($i=0;$i<=100;$i++){
-            sleep(1);
-            var_dump($i);
-        }
+        $a = new FeatureService();
+        dd($a->matchFeature("1&2&3",[],[]));
     }
 
     public function updateLaborRemark(){

+ 1 - 1
app/Imports/StoreCheckingReceiveImport.php

@@ -160,7 +160,7 @@ class StoreCheckingReceiveImport implements ToCollection,WithHeadingRow
                 $date = Carbon::now();
                 foreach ($commoditiesTem as $item){
                     //对比本地与导入的存在商品中条码差异 补充数据库
-                    foreach (array_unique(array_diff($skuMap[$item->sku], $item->barcodes)) as $code){
+                    foreach (array_unique(array_diff($skuMap[$item->sku], $item->barcodes->toArray())) as $code){
                         $barcodes[] = [
                             'commodity_id' => $item->id,
                             'code' => $code,

+ 0 - 1
app/Imports/StoreCheckingReceiveSheets.php

@@ -8,7 +8,6 @@ class StoreCheckingReceiveSheets implements WithMultipleSheets
 {
     public function sheets(): array
     {
-        // TODO: Implement sheets() method.
         return [
           0 => new StoreCheckingReceiveImport(),
         ];

+ 6 - 10
app/LaborReport.php

@@ -202,11 +202,9 @@ class LaborReport extends Model
     //进场时间
     public function getEnterAtAttribute()
     {
-        if ($this['userDutyCheck']&&$this['userDutyCheck']['type']=='登入')
-        return $this['userDutyCheck']?$this['userDutyCheck']['checked_at']:null;
-//        $laborReportStatus=LaborReportStatus::where('labor_report_id',$this['id'])->where('status','未审核')->orderBy('id','desc')->first();
-//        if (empty($laborReportStatus))return null;
-//        return Carbon::parse($laborReportStatus['created_at'])->format('Y-m-d H:i:s');
+        $laborReportStatus=LaborReportStatus::where('labor_report_id',$this['id'])->where('status','未审核')->orderBy('id','desc')->first();
+        if (empty($laborReportStatus))return null;
+        return Carbon::parse($laborReportStatus['created_at'])->format('Y-m-d H:i:s');
     }
 
     public function getEnteringRecordAttribute()
@@ -221,11 +219,9 @@ class LaborReport extends Model
 
     public function getExitAtAttribute()
     {
-        if ($this['userDutyCheck']&&$this['userDutyCheck']['type']=='登出')
-            return $this['userDutyCheck']?$this['userDutyCheck']['checked_at']:null;
-//        $laborReportStatus=LaborReportStatus::where('labor_report_id',$this['id'])->where('status','已退场')->orderBy('id','desc')->first();
-//        if (empty($laborReportStatus))return null;
-//        return Carbon::parse($laborReportStatus['created_at'])->format('Y-m-d H:i:s');
+        $laborReportStatus=LaborReportStatus::where('labor_report_id',$this['id'])->where('status','已退场')->orderBy('id','desc')->first();
+        if (empty($laborReportStatus))return null;
+        return Carbon::parse($laborReportStatus['created_at'])->format('Y-m-d H:i:s');
     }
 
     //创建或获取进场编号

+ 23 - 0
app/OrderPackage.php

@@ -96,6 +96,10 @@ class OrderPackage extends Model
         $this['batch_number'] = $this->oracleInfo['waveno']??null;
     }
     static public function createPackagesFromBatchCode($batchCode,$weight){
+        $start_at = microtime(true);
+
+
+
         $queryBuilder=OracleDOCOrderHeader::query()->select(self::$oracleOrderHeaderFields);
         $queryBuilder->where('doc_order_header.waveno',$batchCode);
         $queryBuilder->leftJoin('act_allocation_details','act_allocation_details.orderno','doc_order_header.orderno');
@@ -104,6 +108,12 @@ class OrderPackage extends Model
         $resultOracleObjs_grouped=$resultOracleObjs->groupBy('soreference5');
         $packages = [];
         $now = Carbon::now();
+
+
+        $time1 = floor((microtime(true)-$start_at));
+        app('LogService')->log(__METHOD__,'timemark_'.__FUNCTION__,"{$batchCode} 3.1:$time1");
+        $start_at = microtime(true);
+
         foreach($resultOracleObjs_grouped as $resultOracleObj_grouped){
             $resultOracleObj = $resultOracleObj_grouped[0];
             /** @var OrderService $orderService*/
@@ -123,6 +133,13 @@ class OrderPackage extends Model
                 "created_at"=>$now,
             ]);
         }
+
+
+        $time1 = floor((microtime(true)-$start_at));
+        app('LogService')->log(__METHOD__,'timemark_'.__FUNCTION__,"{$batchCode} 3.2:$time1");
+        $start_at = microtime(true);
+
+
         $packagesLogisticNumbers = array_map(function ($orderPackage) {
             return $orderPackage['logistic_number'];
         } ,$packages);
@@ -143,6 +160,12 @@ class OrderPackage extends Model
         DB::transaction(function ()use($newPackages){
             OrderPackage::query()->insert($newPackages);
         });
+
+
+        $time1 = floor((microtime(true)-$start_at));
+        app('LogService')->log(__METHOD__,'timemark_'.__FUNCTION__,"{$batchCode} 3.3:$time1");
+        $start_at = microtime(true);
+
         app('LogService')->log(__METHOD__,"批量录入包裹成功",json_encode($packages),Auth::user()['id']);
     }
     public function unifyThisMeasureUnderSameBatch(){

+ 20 - 2
app/Services/CommodityService.php

@@ -303,7 +303,7 @@ Class CommodityService
                 "owner_id" => $owner_id,
                 "sku" => $sku
             ]);
-            if (!$commodity || $commodity->pack === null){
+            if (!$commodity || $commodity->pack_spec === null){
                 $owner = app("OwnerService")->find($owner_id);
                 $action = new CommodityController();
                 $action->syncOwnerCommodities($owner->id,$owner->code,$sku);
@@ -311,7 +311,25 @@ Class CommodityService
             return $that->first([
                 "owner_id" => $owner_id,
                 "sku" => $sku
-            ])->pack;
+            ])->pack_spec;
         });
     }
+
+    //是否存在
+    public function isExist(array $params)
+    {
+        $query = Commodity::query();
+        if ($params["barcode"] ?? false) {
+            $query->whereHas("barcodes",function ($query)use($params){
+                /** @var Builder $query */
+                $query->where("code",$params["barcode"]);
+            });
+            unset($params["barcode"]);
+        }
+        foreach ($params as $column => $param){
+            $query->where($column,$param);
+        }
+        if ($query->count() > 0)return true;
+        return false;
+    }
 }

+ 2 - 2
app/Services/CustomerService.php

@@ -11,9 +11,9 @@ Class CustomerService
         return Customer::query()->select($column)->get();
     }
 
-    public function paginate()
+    public function paginate($paginate = 50)
     {
-        return Customer::query()->orderByDesc('id')->paginate(50);
+        return Customer::query()->orderByDesc('id')->paginate($paginate);
     }
 
     public function create(array $params)

+ 76 - 15
app/Services/FeatureService.php

@@ -16,6 +16,22 @@ Class FeatureService
         return $map;
     }
 
+    /**
+     *  将特征翻译为数组显示
+     *      $str : "1&2|(3&4)"
+     *      array:[
+     *          "strategyGroupStartSign" => false,  //是否为策略组起点,这将在解析时解析为 (
+                "calculation" => "",                //运算规则,目前仅有 &,| 翻译后填入
+                "type"=>"",                         //特征类型
+                "id"=>"",                           //特征ID
+                "logic"=>"",                        //特征逻辑
+                "describe"=>"",                     //特征信息
+                "strategyGroupEndSign" => false,    //是否为策略组终点,这将在解析时解析为 )
+     *      ]
+     *
+     * @param string $str
+     * @return array
+     */
     public function translationFeature($str)
     {
         if (!$str)return null;
@@ -24,14 +40,14 @@ Class FeatureService
         $sign = 0;  //为第二次切割做起点标记
         $model = [];//第二次切割数组
         $ids = [];//记录出现的特征ID,统一查询
-        foreach ($result[0] as $index => &$str){
-            if (is_numeric($str)){
+        foreach ($result[0] as $index => &$item){
+            if (is_numeric($item)){
                 $model[] = array_slice($result[0],$sign,($index-$sign)+1);
                 $sign = $index+1;
-                $ids[] = $str;
+                $ids[] = $item;
                 continue;
             }
-            if ($index == count($result[0])-1 && $str == ')'){
+            if ($index == count($result[0])-1 && $item == ')'){
                 $model[] = [")"];
             }
         }//以数字为标准切割策略组
@@ -50,17 +66,17 @@ Class FeatureService
                 "describe"=>"",  //特征信息
                 "strategyGroupEndSign" => false,//是否为策略组终点,这将在解析时解析为 )
             ];//最终对象组模型,策略组将几组特征组合引用
-            foreach ($m as $str){
-                if (is_numeric($str)){//填入特征信息
-                    if (isset($featureMap[$str])){
-                        $arr["type"] = $features[$featureMap[$str]]->type;
-                        $arr["id"] = $features[$featureMap[$str]]->id;
-                        $arr["logic"] = $features[$featureMap[$str]]->logic;
-                        $arr["describe"] = $features[$featureMap[$str]]->describe;
+            foreach ($m as $string){
+                if (is_numeric($string)){//填入特征信息
+                    if (isset($featureMap[$string])){
+                        $arr["type"] = $features[$featureMap[$string]]->type;
+                        $arr["id"] = $features[$featureMap[$string]]->id;
+                        $arr["logic"] = $features[$featureMap[$string]]->logic;
+                        $arr["describe"] = $features[$featureMap[$string]]->describe;
                     }
                     continue;
                 }
-                switch ($str){//特殊字符的翻译
+                switch ($string){//特殊字符的翻译
                     case "(":
                         $arr["strategyGroupStartSign"] = true;
                         break;
@@ -84,6 +100,24 @@ Class FeatureService
         return $model;
     }
 
+    /**
+     *  与translationFeature相反,将一组与translationFeature参数解析为简述
+     *      $features:[
+     *          "strategyGroupStartSign" => false,  //是否为策略组起点,这将在解析时解析为 (
+                "calculation" => "",                //运算规则,目前仅有 &,| 翻译后填入
+                "type"=>"",                         //特征类型
+                "id"=>"",                           //特征ID
+                "logic"=>"",                        //特征逻辑
+                "describe"=>"",                     //特征信息
+                "strategyGroupEndSign" => false,    //是否为策略组终点,这将在解析时解析为 )
+     *      ]
+     *      array:[
+     *          "feature"   //简述结果
+     *          "map"       //简述中出现的Map特征对象重组为key-val数组
+     *      ]
+     * @param array $features
+     * @return array
+     */
     public function analysisFeature($features)
     {
         $str = "";
@@ -98,7 +132,7 @@ Class FeatureService
             $feature["id"] = $f->id;
             $map[$feature["id"]] = $f;
             if ($feature["calculation"] == '并且')$str .= '&';
-            else $str .= '|';
+            if ($feature["calculation"] == '或') $str .= '|';
             if ($feature["strategyGroupStartSign"])$str .= "(";
             $str .= $feature["id"];
             if ($feature["strategyGroupEndSign"])$str .= ")";
@@ -106,6 +140,18 @@ Class FeatureService
         return ['feature'=>$str,"map"=>$map];
     }
 
+    /**
+     * 格式化简述特征为可阅读显示
+     *      $features : 特征对象集 重组为key-val数组数据,key为ID
+     *      $value : 简述特征 例: "1&2|(3&4)"
+     *      $columnMapping : 特征type属性字段映射 例:["商品名称"=>"commodity_name"],指定该参数会使特征格式化为SQL段
+     *      string : 例:"商品名称 包含 衣服 并且(订单类型 等于 创建订单 或者 承运商 不包含 顺丰)"
+     *
+     * @param array $features
+     * @param string $value
+     * @param array $columnMapping
+     * @return string
+     */
     public function formatFeature(array $features, $value, $columnMapping = null)
     {
         if (!$features)return $value;
@@ -130,7 +176,7 @@ Class FeatureService
                             $logic = " = ";
                             break;
                     }
-                    $str = $column.$logic.$describe;
+                    $str = $column.$logic."'".$describe."'";
                 }else $str = $features[$str]["type"].' '.$features[$str]["logic"].' '.$features[$str]["describe"];
             }
             if ($str == "&"){
@@ -145,8 +191,23 @@ Class FeatureService
         return implode("",$result[0]);
     }
 
+    /**
+     *  匹配特征
+     *      $vale : 特征简述 例: "1&2|(3|4)"
+     *      $columnMapping : 列映射 例:["商品名称"=>"commodity_name"]
+     *      $matchObject : 被匹配对象,必须存在列映射所指定字段 例:["commodity_name"=>"衣服"]
+     *      bool true匹配成功 false匹配失败
+     *
+     * @param string $value
+     * @param array $columnMapping
+     * @param array $matchObject
+     * @return bool
+     */
     public function matchFeature($value, $columnMapping, $matchObject) :bool
     {
+        preg_match_all('/\d+|[\&\|\(\)]/',$value,$result);
+        if (implode("",$result[0]) != $value)return false;
+
         preg_match_all('/\d+/',$value,$ids);
         if ($ids[0])$fs = Feature::query()->whereIn("id",$ids[0])->get();
         else return false;
@@ -154,7 +215,7 @@ Class FeatureService
         foreach ($fs as $f){
             $features[$f->id] = $f;
         }
-        preg_match_all('/\d+|[\&\|\(\)]/',$value,$result);
+
         foreach ($result[0] as &$str) {
             if (is_numeric($str) && isset($features[$str])) {
                 $column = $features[$str]["type"];

+ 1 - 1
app/Services/OwnerPriceExpressService.php

@@ -125,6 +125,6 @@ Class OwnerPriceExpressService
         if ($weight < $model->initial_weight)$weight = $model->initial_weight;
         $initialMoney = $model->initial_weight*$model->details[0]->initial_weight_price;
         $weight -= $model->initial_weight;
-        return ($weight*$model->details[0]->additional_weight_price)+$initialMoney;
+        return (ceil($weight/$model->additional_weight)*$model->details[0]->additional_weight_price)+$initialMoney;
     }
 }

+ 3 - 4
app/Services/OwnerPriceLogisticService.php

@@ -131,9 +131,8 @@ Class OwnerPriceLogisticService
     private function calculation($amount, $detail, $fee)
     {
         if ($amount < $detail->initial_amount)$amount = $detail->initial_amount; //小于起始数以起始数为准
-        $initialMoney = $detail->initial_amount*$detail->unit_price; //起始数计费
-        $amount -= $detail->initial_amount; //减起始数为续数
-        if ($initialMoney < $detail->initial_fee)$initialMoney = $detail->initial_fee; //小于起始计费以起始计费为准
-        return ($amount*$detail->unit_price)+$initialMoney+$detail->delivery_fee+$fee;
+        $money = $amount * $detail->unit_price;
+        if ($money < $detail->initial_fee)$money = $detail->initial_fee; //小于起始计费以起始计费为准
+        return $money+$detail->delivery_fee+$fee;
     }
 }

+ 31 - 15
app/Services/OwnerPriceOperationService.php

@@ -119,7 +119,7 @@ Class OwnerPriceOperationService
             $query->orderByRaw("CASE strategy  WHEN '默认' THEN 1 WHEN '特征' THEN 2 WHEN '起步' THEN 3 END DESC,priority DESC");
         }] : ['ownerInStorageRule'] ;
         $rules = OwnerPriceOperation::query()->with($withs)
-            ->where("operation_type","出库")
+            ->where("operation_type",$type)
             ->whereHas("ownerPriceOperationOwners",function ($query)use($owner_id){
                 /** @var Builder $query */
                 $query->where("id",$owner_id);
@@ -128,27 +128,34 @@ Class OwnerPriceOperationService
         if (!$rules)return -2;
 
         if ($type == '入库'){
-            foreach ($rules as $rule){
+            foreach ($rules as $index => $rule){
+                $sum = $amount;
                 if (!$rule->ownerInStorageRule)continue;
                 if ($rule->strategy == '特征'){
                     $bool = app("FeatureService")->matchFeature($rule->feature,$columnMapping,$matchObject);
                     if ($bool === true){
                         if (!isset($units[$rule->ownerInStorageRule->unit_id])) return -3;
                         if ($units[$rule->ownerInStorageRule->unit_id] == '箱'){ //为箱时同步商品寻找箱规
-                            $amount = $this->changeUnit($amount,$owner_id,$sku);
-                            if ($amount<0) return $amount;
+                            $sum = $this->changeUnit($sum,$owner_id,$sku);
+                            if ($sum<0){
+                                if ($index == count($rules)-1)return $sum;
+                                continue;
+                            }
                         }
-                        if ($units[$rule->ownerInStorageRule->unit_id] == '单')$amount = 1; //为单时数量设为1;
-                        return ceil($amount/$rule->ownerInStorageRule->amount)*$rule->ownerInStorageRule->unit_price;
+                        if ($units[$rule->ownerInStorageRule->unit_id] == '单')$sum = 1; //为单时数量设为1;
+                        return ceil($sum/$rule->ownerInStorageRule->amount)*$rule->ownerInStorageRule->unit_price;
                     };
                 }else{
                     if (!isset($units[$rule->ownerInStorageRule->unit_id])) return -3;
                     if ($units[$rule->ownerInStorageRule->unit_id] == '箱'){ //为箱时同步商品寻找箱规
-                        $amount = $this->changeUnit($amount,$owner_id,$sku);
-                        if ($amount<0) return $amount;
+                        $sum = $this->changeUnit($sum,$owner_id,$sku);
+                        if ($sum<0){
+                            if ($index == count($rules)-1)return $sum;
+                            continue;
+                        }
                     }
-                    if ($units[$rule->ownerInStorageRule->unit_id] == '单')$amount = 1; //为单时数量设为1;
-                    return ceil($amount/$rule->ownerInStorageRule->amount)*$rule->ownerInStorageRule->unit_price;
+                    if ($units[$rule->ownerInStorageRule->unit_id] == '单')$sum = 1; //为单时数量设为1;
+                    return ceil($sum/$rule->ownerInStorageRule->amount)*$rule->ownerInStorageRule->unit_price;
                 };
             }
             return -7;
@@ -179,7 +186,8 @@ Class OwnerPriceOperationService
     private function matchOutStorage($amount, $rules, $columnMapping, $matchObject, $units, $owner_id, $sku)
     {
         $money = 0;
-        foreach ($rules as $rule){
+        foreach ($rules as $index => $rule){
+            $sum = $amount;
             switch ($rule->strategy){
                 case "起步":
                     $money = $rule->amount * $rule->unit_price;
@@ -197,17 +205,25 @@ Class OwnerPriceOperationService
                     if (app("FeatureService")->matchFeature($rule->feature,$columnMapping,$matchObject)){
                         if (!isset($units[$rule->unit_id]) || $units[$rule->unit_id] == '单') return -3;
                         if ($units[$rule->unit_id] == '箱'){ //为箱时同步商品寻找箱规
-                            $amount = $this->changeUnit($amount,$owner_id,$sku);
+                            $sum = $this->changeUnit($sum,$owner_id,$sku);
+                            if ($sum<0){
+                                if ($index == count($rules)-1)return $sum;
+                                break;
+                            }
                         }
-                        return (ceil($amount/$rule->amount)*$rule->unit_price)+$money;
+                        return (ceil($sum/$rule->amount)*$rule->unit_price)+$money;
                     };
                     break;
                 case "默认":
                     if (!isset($units[$rule->unit_id]) || $units[$rule->unit_id] == '单') return -3;
                     if ($units[$rule->unit_id] == '箱'){ //为箱时同步商品寻找箱规
-                        $amount = $this->changeUnit($amount,$owner_id,$sku);
+                        $sum = $this->changeUnit($sum,$owner_id,$sku);
+                        if ($sum<0){
+                            if ($index == count($rules)-1)return $sum;
+                            break;
+                        }
                     }
-                    return (ceil($amount/$rule->amount)*$rule->unit_price)+$money;
+                    return (ceil($sum/$rule->amount)*$rule->unit_price)+$money;
                     break;
             }
         }

+ 3 - 3
app/Services/OwnerStoragePriceModelService.php

@@ -43,10 +43,10 @@ Class OwnerStoragePriceModelService
     }
 
     //暂时不考虑单位换算问题:后期可能存在多单位换算,此处仅视为单位为 m²
-    public function calculationAmount(OwnerStoragePriceModel $model, $area, $owner_id = null, $month = null) :int
+    public function calculationAmount(OwnerStoragePriceModel $model, $area, $owner_id = null, $month = null)
     {
         if (!$model || !$area) return 0;
-        if ((int)$area < $model->minimum_area) $area = (int)$model->minimum_area;
+        if ($area < $model->minimum_area) $area = $model->minimum_area;
         $money = $area*$model->price;
         switch ($model->discount_type){
             case "按单减免":
@@ -58,7 +58,7 @@ Class OwnerStoragePriceModelService
                 }
                 break;
             case "固定减免":
-                $money -= (int)$model->discount_value;
+                $money -= $model->discount_value;
                 break;
         }
         return $money;

+ 1 - 1
app/Services/common/QueryService.php

@@ -42,7 +42,7 @@ Class QueryService
                     $queryTemp=$queryTemp->where($tableName.$column,'like','%'.$params[$param].'%')
                         ->where($tableName.'created_at','>',$today);
                     if($queryTemp->count()==0 || $queryTemp->first()[$column]==$params[$param]){
-                        $query=$query->where($tableName.$column,$params[$param]);
+                        $query=$query->where($tableName.$column,"like",$params[$param]."%");
                     }else{
                         $query=$query->where($tableName.$column,'like','%'.$params[$param].'%')
                             ->where($tableName.'created_at','>',$today);

+ 1 - 1
app/UserDutyCheck.php

@@ -28,7 +28,7 @@ class UserDutyCheck extends Model
         return $this->belongsTo('App\UserWorkgroup','workgroup_id','id');
     }
     public function laborReport(){
-        return $this->hasOne('App\LaborReport');
+        return $this->belongsTo('App\LaborReport');
     }
 
     public function laborEnterCheck(){

+ 16 - 0
database/factories/CarTypeFactory.php

@@ -0,0 +1,16 @@
+<?php
+
+/** @var \Illuminate\Database\Eloquent\Factory $factory */
+
+use App\CarType;
+use Faker\Generator as Faker;
+
+$factory->define(CarType::class, function (Faker $faker) {
+    return [
+        'name' => $faker->name,
+        'model' => $faker->name,
+        'length' => mt_rand(6,250) / 4,
+        'load' => mt_rand(6,250) / 4,
+        'remark' => $faker->text(20),
+    ];
+});

+ 10 - 1
database/factories/CommodityFactory.php

@@ -6,7 +6,16 @@ use App\Commodity;
 use Faker\Generator as Faker;
 
 $factory->define(Commodity::class, function (Faker $faker) {
+    $type = ["无","临时"];
     return [
-
+        'name' => $faker->name,
+        'sku' => md5(date('Ymd').\Illuminate\Support\Str::random(3)),
+        'owner_id' => factory(\App\Owner::class),
+        'length' => mt_rand(1,90) / 3,
+        'width' => mt_rand(1,90) / 3,
+        'height' => mt_rand(1,90) / 3,
+        'volumn' => mt_rand(10,900) / 3,
+        "type" => $type[array_rand($type)],
+        "pack_spec" => mt_rand(1,100)
     ];
 });

+ 16 - 0
database/factories/FeatureFactory.php

@@ -0,0 +1,16 @@
+<?php
+
+/** @var \Illuminate\Database\Eloquent\Factory $factory */
+
+use App\Feature;
+use Faker\Generator as Faker;
+
+$factory->define(Feature::class, function (Faker $faker) {
+    $type = ['商品名称','订单类型','承运商','店铺类型'];
+    $logic = ['包含','不包含','等于'];
+    return [
+        "type" => $type[array_rand($type)],     //类型
+        "logic" => $logic[array_rand($logic)],    //逻辑
+        "describe" => \Illuminate\Support\Str::random(5), //特征
+    ];
+});

+ 1 - 1
database/factories/LogisticFactory.php

@@ -8,6 +8,6 @@ use Faker\Generator as Faker;
 $factory->define(Logistic::class, function (Faker $faker) {
     return [
         'name' => $faker->name,
-        'code' => \Illuminate\Support\Str::random(8),
+        'code' => \Illuminate\Support\Str::random(3).md5(\Illuminate\Support\Str::random(5)),
     ];
 });

+ 21 - 0
database/factories/OwnerAreaReportFactory.php

@@ -0,0 +1,21 @@
+<?php
+
+/** @var \Illuminate\Database\Eloquent\Factory $factory */
+
+use App\OwnerAreaReport;
+use Faker\Generator as Faker;
+
+$factory->define(OwnerAreaReport::class, function (Faker $faker) {
+    $status = ['编辑中','已完成',"编辑中","编辑中"];
+    return [
+        "owner_id" => factory(\App\Owner::class),             //货主ID
+        "counting_month" => $faker->date(),       //结算月
+        "owner_storage_price_model_id" => factory(\App\OwnerStoragePriceModel::class), //仓储计费ID
+        "user_owner_group_id" => factory(\App\UserOwnerGroup::class),  //项目组ID
+        "area_on_tray" => mt_rand(5,1000) / 6,         //货物整托
+        "area_on_half_tray" => mt_rand(5,1000) / 6,    //货物半托
+        "area_on_flat" => mt_rand(5,1000) / 6,         //平面区面积
+        "accounting_area" => mt_rand(50,10000) / 6,      //结算面积
+        "status" => $status[array_rand($status)]            //状态
+    ];
+});

+ 3 - 4
database/factories/OwnerBillReportFactory.php

@@ -4,13 +4,12 @@
 
 use App\OwnerBillReport;
 use Faker\Generator as Faker;
-$owner = \App\Owner::query()->whereNotNull("user_owner_group_id")->first();
-$factory->define(OwnerBillReport::class, function (Faker $faker)use(&$owner) {
-    if (!$owner)$owner = \App\Owner::query()->whereNotNull("user_owner_group_id")->first();
+
+$factory->define(OwnerBillReport::class, function (Faker $faker) {
     $initial_fee = mt_rand(0,50000) / 10;
     $confirm_fee = mt_rand(0,50000) / 10;
     return [
-        "owner_id" => $owner ? $owner->id : factory(\App\Owner::class),       //项目ID
+        "owner_id" => factory(\App\Owner::class),       //项目ID
         "counting_month" => $faker->date(), //结算月
         "initial_fee" => $initial_fee,    //原始账单金额
         "confirm_fee" => $confirm_fee,    //确认账单金额

+ 0 - 1
database/factories/OwnerFactory.php

@@ -10,7 +10,6 @@ $factory->define(Owner::class, function (Faker $faker) {
         'name' => $faker->name,                 //名称
         'code' => \Illuminate\Support\Str::random(5).date('yymmdd'),                 //代码
         'checking_count' => mt_rand(0,5),       //审核数量
-        "customer_id" => factory(App\Customer::class),          //客户ID
         "tax_rate" => mt_rand(0,100) / 10,             //税率
         "contract_number" => \Illuminate\Support\Str::random(5).date('yymmdd'),      //合同号
         "salesman" => $faker->name,             //销售名称

+ 9 - 23
database/factories/OwnerFeeDetailFactory.php

@@ -5,34 +5,20 @@
 use App\OwnerFeeDetail;
 use Faker\Generator as Faker;
 
-$owner = \App\Owner::query()->whereNotNull('customer_id')->first();
-if ($owner)$shop = \App\Shop::query()->where("owner_id",$owner->id)->first();
-else $shop = null;
-$logistic = \App\Logistic::query()->first();
-$method = \App\ProcessMethod::query()->first();
-$factory->define(OwnerFeeDetail::class, function (Faker $faker)use(&$owner,&$shop,&$logistic,&$method) {
-    if (!$owner)$owner = \App\Owner::query()->whereNotNull('customer_id')->first();
-    if (!$shop){
-        if ($owner)$shop = \App\Shop::query()->where("owner_id",$owner->id)->first();
-        else $shop = null;
-    }
-    if (!$logistic) $logistic = \App\Logistic::query()->first();
-    if (!$method)$method = \App\ProcessMethod::query()->first();
+$factory->define(OwnerFeeDetail::class, function (Faker $faker) {
     $type = ["发货","收货","增值服务"];
     return [
-        "owner_id"          => $owner ? $owner->id : factory(\App\Owner::class),         //货主ID
+        "owner_id"          => factory(\App\Owner::class),         //货主ID
         "worked_at"         => $faker->date(),//作业时间
-        "type"              =>$type[array_rand($type)],//类型
-        "shop_id"           =>$shop ? $shop->id : factory(\App\Shop::class),//店铺ID
+        "type"              => $type[array_rand($type)],//类型
+        "shop_id"           => factory(\App\Shop::class),//店铺ID
         "operation_bill"    => \Illuminate\Support\Str::random(10),//发/收/退/提货单号
         "consignee_name"    => $faker->name,   //收件人
-        "consignee_phone"   =>$faker->phoneNumber,  //收件人电话
-        "commodity_amount"  =>mt_rand(0,100), //商品数量
-        "logistic_bill"     =>\Illuminate\Support\Str::random(12),    //快递单号
-        "volume"            =>mt_rand(10,2600) / 88,//体积
-        "weight"            =>mt_rand(10,2600) / 88,           //重量
-        "logistic_id"       =>$logistic ? $logistic->id : factory(\App\Logistic::class),      //物流ID
-        "process_method_id" =>$method ? $method->id : factory(\App\ProcessMethod::class),//加工类型ID
+        "consignee_phone"   => $faker->phoneNumber,  //收件人电话
+        "commodity_amount"  => mt_rand(0,100), //商品数量
+        "logistic_bill"     => \Illuminate\Support\Str::random(12),    //快递单号
+        "volume"            => mt_rand(10,2600) / 88,//体积
+        "weight"            => mt_rand(10,2600) / 88,           //重量
         "work_fee"          =>mt_rand(100,10000) / 10,         //作业费
         "logistic_fee"      =>mt_rand(100,10000) / 10,     //物流费
     ];

+ 2 - 4
database/factories/OwnerOutStorageRuleFactory.php

@@ -5,15 +5,13 @@
 use App\OwnerOutStorageRule;
 use Faker\Generator as Faker;
 
-$unit = \App\Unit::query()->first();
-$factory->define(OwnerOutStorageRule::class, function (Faker $faker)use(&$unit) {
-    if (!$unit)$unit = \App\Unit::query()->first();
+$factory->define(OwnerOutStorageRule::class, function (Faker $faker) {
     $strategy = ['默认','特征'];
     return [
         "owner_price_operation_id"          => factory(\App\OwnerPriceOperation::class),         //作业计费ID
         "strategy"                          =>$strategy[array_rand($strategy)],         //策略
         "amount"                            =>mt_rand(0,100),                           //起步数
-        "unit_id"                           => $unit ? $unit->id : factory(\App\Unit::class),//单位ID
+        "unit_id"                           => factory(\App\Unit::class),//单位ID
         "unit_price"                        =>mt_rand(10,100) / 12,                       //单价
         "feature"                           =>\Illuminate\Support\Str::random(6),                          //特征
     ];

+ 15 - 0
database/factories/OwnerPriceDirectLogisticCarFactory.php

@@ -0,0 +1,15 @@
+<?php
+
+/** @var \Illuminate\Database\Eloquent\Factory $factory */
+
+use App\OwnerPriceDirectLogisticCar;
+use Faker\Generator as Faker;
+
+$factory->define(OwnerPriceDirectLogisticCar::class, function (Faker $faker) {
+    return [
+        "owner_price_direct_logistic_id" => factory(\App\OwnerPriceDirectLogistic::class),   //直发车计费ID
+        "car_type_id" => factory(\App\CarType::class),                      //车型ID
+        "base_fee" => mt_rand(6,250) / 4,                         //起步费
+        "additional_fee" => mt_rand(6,250) / 4,                   //续费(元/KM)
+    ];
+});

+ 13 - 0
database/factories/OwnerPriceDirectLogisticFactory.php

@@ -0,0 +1,13 @@
+<?php
+
+/** @var \Illuminate\Database\Eloquent\Factory $factory */
+
+use App\OwnerPriceDirectLogistic;
+use Faker\Generator as Faker;
+
+$factory->define(OwnerPriceDirectLogistic::class, function (Faker $faker) {
+    return [
+        "name" => $faker->name.md5(\Illuminate\Support\Str::random(3)),     //名称
+        "base_km" => mt_rand(1,100),  //起步公里数
+    ];
+});

+ 4 - 6
database/factories/OwnerPriceExpressFactory.php

@@ -5,12 +5,10 @@
 use App\OwnerPriceExpress;
 use Faker\Generator as Faker;
 
-$unit = \App\Unit::query()->first();
-$factory->define(OwnerPriceExpress::class, function (Faker $faker)use(&$unit) {
-    if (!$unit)$unit = \App\Unit::query()->first();
+$factory->define(OwnerPriceExpress::class, function (Faker $faker) {
     return [
-        "name" => $faker->name,                     //名称
-        "initial_weight_unit_id" => $unit ? $unit->id : factory(\App\Unit::class),   //首重单位
-        "additional_weight_unit_id" => $unit ? $unit->id : factory(\App\Unit::class),//续重单位
+        "name" => $faker->name,
+        "initial_weight" => mt_rand(6,260) / 5,
+        "additional_weight" => mt_rand(6,260) / 5,
     ];
 });

+ 16 - 0
database/factories/OwnerPriceExpressProvinceFactory.php

@@ -0,0 +1,16 @@
+<?php
+
+/** @var \Illuminate\Database\Eloquent\Factory $factory */
+
+use App\OwnerPriceExpressProvince;
+use Faker\Generator as Faker;
+
+$factory->define(OwnerPriceExpressProvince::class, function (Faker $faker) {
+    $province = \App\Province::query()->first();
+    return [
+        "owner_price_express_id" => factory(\App\OwnerPriceExpress::class),   //快递价格ID
+        "province_id" => $province->id,              //省份ID
+        "initial_weight_price" => mt_rand(6,260) / 5,     //初始单价
+        "additional_weight_price"=>mt_rand(6,260) / 5,  //续重单价
+    ];
+});

+ 23 - 0
database/factories/OwnerPriceLogisticDetailFactory.php

@@ -0,0 +1,23 @@
+<?php
+
+/** @var \Illuminate\Database\Eloquent\Factory $factory */
+
+use App\OwnerPriceLogisticDetail;
+use Faker\Generator as Faker;
+
+$factory->define(OwnerPriceLogisticDetail::class, function (Faker $faker) {
+    $province = \App\Province::query()->first();
+    $city = \App\City::query()->where("province_id",$province->id)->first();
+    return [
+        "owner_price_logistic_id" => factory(\App\OwnerPriceLogistic::class),  //物流计费
+        "unit_id" => factory(\App\Unit::class),                  //单位ID
+        "range" => "0-5",                    //区间
+        "province_id" => $province->id,              //省份ID
+        "city_id" => $city->id,                  //城市ID
+        "unit_price" => mt_rand(1,36) / 3,               //单价
+        "delivery_fee" => mt_rand(1,136) / 3,             //送货费
+        "initial_fee" => mt_rand(1,136) / 3,              //起始计费
+        "initial_amount" => mt_rand(1,136) / 3,           //起始计数
+        "rate" =>  mt_rand(1,136) / 3,                       //费率
+    ];
+});

+ 19 - 0
database/factories/OwnerPriceLogisticFactory.php

@@ -0,0 +1,19 @@
+<?php
+
+/** @var \Illuminate\Database\Eloquent\Factory $factory */
+
+use App\OwnerPriceLogistic;
+use Faker\Generator as Faker;
+
+$factory->define(OwnerPriceLogistic::class, function (Faker $faker) {
+    return [
+        "name" => $faker->name,             //名称
+        "unit_range" => "0-5,5-10,10-15,15-20",       //单价一区间
+        "unit_id" => factory(\App\Unit::class),          //单位一ID
+        "other_unit_range" => "0-5,5-10,10-15,15-20,30-", //单位二区间
+        "other_unit_id" => factory(\App\Unit::class),    //单位二ID
+        "pick_up_price" => mt_rand(2,230) / 3,    //提货费
+        "fuel_price" => mt_rand(2,230) / 3,       //燃油附加费
+        "service_price" => mt_rand(2,230) / 3,    //信息服务费
+    ];
+});

+ 6 - 4
database/factories/OwnerReportFactory.php

@@ -4,14 +4,16 @@
 
 use App\OwnerReport;
 use Faker\Generator as Faker;
-
-$factory->define(OwnerReport::class, function (Faker $faker) {
+$owner = \App\Owner::query()->first();
+$factory->define(OwnerReport::class, function (Faker $faker)use($owner) {
+    if (!$owner)$owner = \App\Owner::query()->first();
     return [
-        "owner_id" => factory(App\Owner::class),                     //货主ID
+        "owner_id" => $owner ? $owner->id : factory(App\Owner::class),                     //货主ID
         "counting_month" => $faker->date(),               //结算月
         "daily_average_order_amount" => mt_rand(0,10000),  //日均单量
         "current_month_counting_area" => mt_rand(100,100000) / 50,  //结算月盘点面积
         "last_month_counting_area"   => mt_rand(100,100000) / 50,  //结算月上月盘点面积
-        "owner_bill_report_id"  =>factory(App\OwnerBillReport::class)        //账单ID
+        "owner_bill_report_id"  =>factory(App\OwnerBillReport::class),        //账单ID
+        "total" => mt_rand(1,2000),
     ];
 });

+ 3 - 4
database/factories/OwnerStoragePriceModelFactory.php

@@ -4,9 +4,8 @@
 
 use App\OwnerStoragePriceModel;
 use Faker\Generator as Faker;
-$unit = \App\Unit::query()->first();
-$factory->define(OwnerStoragePriceModel::class, function (Faker $faker) use(&$unit){
-    if (!$unit) $unit = \App\Unit::query()->first();
+
+$factory->define(OwnerStoragePriceModel::class, function (Faker $faker){
     $counting_type = ['包仓','灵活用仓','统单价'];
     $using_type = ['常温','恒温'];
     $discount_type = ['无减免','按单减免','固定减免'];
@@ -17,6 +16,6 @@ $factory->define(OwnerStoragePriceModel::class, function (Faker $faker) use(&$un
         "price" => mt_rand(1,20) / 10,            //单价
         "discount_type" => $discount_type[array_rand($discount_type)],    //减免类型
         "discount_value" => mt_rand(0,10) / 12,   //减免值
-        "unit_id" => $unit ? $unit->id : factory(\App\Unit::class),          //单位ID
+        "unit_id" => factory(\App\Unit::class) ,          //单位ID
     ];
 });

+ 2 - 4
database/factories/ProcessMethodFactory.php

@@ -5,12 +5,10 @@
 use App\ProcessMethod;
 use Faker\Generator as Faker;
 
-$unit = \App\Unit::query()->first();
-$factory->define(ProcessMethod::class, function (Faker $faker)use(&$unit) {
-    if (!$unit)$unit = \App\Unit::query()->first();
+$factory->define(ProcessMethod::class, function (Faker $faker) {
     return [
         'name' => $faker->name,
-        "unit_id" => $unit ? $unit->id : factory(\App\Unit::class),
+        "unit_id" => factory(\App\Unit::class),
         "unit_price" => mt_rand(10,50) / 9,
     ];
 });

+ 2 - 4
database/factories/ShopFactory.php

@@ -5,11 +5,9 @@
 use App\Shop;
 use Faker\Generator as Faker;
 
-$owner = \App\Owner::query()->whereNotNull('customer_id')->first();
-$factory->define(Shop::class, function (Faker $faker)use(&$owner) {
-    if (!$owner) $owner = \App\Owner::query()->whereNotNull('customer_id')->first();
+$factory->define(Shop::class, function (Faker $faker) {
     return [
         'name' => $faker->name,
-        'owner_id' => $owner ? $owner->id : factory(\App\Owner::class),
+        'owner_id' => factory(\App\Owner::class),
     ];
 });

+ 2 - 6
public/t.php

@@ -1,8 +1,4 @@
 <?php
 
-$a= null ?? false;
-
-$b= [] ?? false;
-
-var_dump($a);
-var_dump($b);
+$start_at = microtime(true);
+echo (microtime(true)-$start_at)*1000;

+ 25 - 1
resources/views/maintenance/priceModel/operation/create.blade.php

@@ -57,7 +57,10 @@
             </div>
             <div class="row mt-3">
                 <label class="col-2">特征:</label>
-                <label v-if="model.feature">@{{ model.feature }}</label>
+                <label v-if="model.feature">
+                    @{{ model.feature }}
+                    <input hidden name="feature" :value="model.feature" type="text">
+                </label>
                 <button type="button" class="btn btn-dark col-2 ml-2" @click="showAddFeatureModal(-1,model.feature)">调整特征</button>
             </div>
             <div class="row mt-3">
@@ -175,6 +178,7 @@
                 thisIndex : "",
                 errors:{!! $errors !!},
                 existStrategy:{default:false,starting:false},
+                oldFeature : '',
             },
             methods:{
                 outRuleUnique(strategy){
@@ -203,10 +207,30 @@
                     this.$delete(this.model.rules,index);
                 },
                 showAddFeatureModal(index,feature){
+                    if (!feature){
+                        this.features = [{
+                            "strategyGroupStartSign": false,
+                            "calculation" : "",
+                            "type" : "",
+                            "id" : "",  //特征ID
+                            "logic" : "",  //特征逻辑
+                            "describe" : "",  //特征信息
+                            "strategyGroupEndSign" : false,
+                        }];
+                        this.thisIndex = index;
+                        $("#addFeatureModal").modal("show");
+                        return;
+                    }
+                    if (this.oldFeature == feature) {
+                        this.thisIndex = index;
+                        $("#addFeatureModal").modal("show");
+                        return;
+                    }
                     window.axios.post("{{url('maintenance/priceModel/operation/getFeatures')}}", {feature:feature})
                         .then(res=>{
                             if (res.data.success){
                                 this.features = res.data.data;
+                                this.oldFeature = feature;
                                 if (!this.features || this.features.length === 0){
                                     this.features = [{
                                         "strategyGroupStartSign": false,

+ 5 - 0
resources/views/maintenance/priceModel/operation/index.blade.php

@@ -77,6 +77,11 @@
                             <th class="text-center">特征</th>
                             <th></th>
                         </tr>
+                        <tr v-if="ownerOutStorageRules[thisId] && ownerOutStorageRules[thisId].length == 0">
+                            <td colspan="8">
+                                @can("计费模型-作业-编辑")<button class="btn btn-sm btn-outline-info" @click="showAddRuleModal()">新增</button>@endcan
+                            </td>
+                        </tr>
                         <tr v-for="(item,i) in ownerOutStorageRules[thisId]">
                             <td>
                                 <span v-if="updateDetailId != item.id">

+ 5 - 0
resources/views/store/checkingReceive/mission.blade.php

@@ -250,18 +250,23 @@
                 },
                 receipt(index){
                     window.tempTip.confirm('是否要进行快速收货?',()=>{
+                        window.tempTip.setDuration(9999);
+                        window.tempTip.waitingTip("执行中......");
                         let storeCheckingReceive = this.storeCheckingReceives[index];
                         axios.post('{{url('store/checkingReceive/mission/receipt')}}',{id:storeCheckingReceive.id})
                             .then(res=>{
                                 if (res.data.success) {
+                                    window.tempTip.cancelWaitingTip();
                                     window.tempTip.setDuration(2000);
                                     window.tempTip.showSuccess("快速收货完成!");
                                     storeCheckingReceive.status = res.data.data.status;
                                     return;
                                 }
+                                window.tempTip.cancelWaitingTip();
                                 window.tempTip.setDuration(3000);
                                 window.tempTip.show(res.data.data);
                             }).catch(err=>{
+                            window.tempTip.cancelWaitingTip();
                             window.tempTip.setDuration(3000);
                             window.tempTip.show("网络错误:"+err);
                         })

+ 51 - 29
resources/views/store/checkingReceive/show.blade.php

@@ -216,7 +216,9 @@
     new Vue({
         el:"#container",
         data:{
-            storeCheckingReceive:{id:'{{$storeCheckingReceive->id}}',owner_name:'{{$storeCheckingReceive->owner ? $storeCheckingReceive->owner->name : ''}}',
+            storeCheckingReceive:{id:'{{$storeCheckingReceive->id}}',
+                owner_id:'{{$storeCheckingReceive->owner_id}}',
+                owner_name:'{{$storeCheckingReceive->owner ? $storeCheckingReceive->owner->name : ''}}',
                                 created_at:'{{$storeCheckingReceive->created_at}}',asn:'{{$storeCheckingReceive->asn}}',status:'{{$storeCheckingReceive->status}}'},
             storeCheckingReceiveItems:[
                 @foreach($storeCheckingReceive->storeCheckingReceiveItems as $storeCheckingReceiveItem)
@@ -339,6 +341,10 @@
             scanListening: function () {
                 let _this = this;
                 $(document).on('keypress', function (e) {
+                    if (!status.barcodeDisable && !_this.focusing && e.keyCode===13 && !_this.inputting.amount){
+                        document.getElementById('amount').focus();
+                        return;
+                    }
                     if(_this.focusing!=='document'){return}
                     if(!_this.status.barcodeDisable){return}
                     if (e.keyCode !== 13) {
@@ -400,40 +406,56 @@
                 }
                 if(!this.inputting.barcode){window.tempTip.show('请扫入条码');return;}
                 else if(!this.inputting.bin_number){window.tempTip.show('请输入隔口号');return;}
-                axios.post('{{url('store/checkingReceive/insertItem')}}',{mission_id : this.storeCheckingReceive.id,goods : this.inputting})
+
+                window.axios.post('{{url('maintenance/commodity/isExist')}}',{owner_id:this.storeCheckingReceive.owner_id,barcode:this.inputting.barcode})
                     .then(res=>{
-                        if (res.data.success) {
-                            this.lastScannedBarcode = this.inputting.barcode;
-                            if (res.data.type === 'create'){
-                                this._addStoreCheckingReceiveItem(res.data.data);
-                                window.tempTip.setDuration(2000);
-                                window.tempTip.showSuccess('成功提交:' + this.inputting.barcode);
-                            }else{
-                                if (this.storeCheckingReceiveItems.length > 0 && res.data.data.id === this.storeCheckingReceiveItems[0].id){
-                                    this.storeCheckingReceiveItems[0].counted_amount = res.data.data.counted_amount;
-                                    this.storeCheckingReceiveItems[0].imported_diff_amount = res.data.data.imported_diff_amount;
-                                    this.storeCheckingReceiveItems[0].asn_diff_amount = res.data.data.asn_diff_amount;
-                                    this.storeCheckingReceiveItems[0].bin_number = res.data.data.bin_number;
-                                }else{
-                                    this._removeCheckingReceiveItem(res.data.data.id);
-                                    this._addStoreCheckingReceiveItem(res.data.data);
-                                }
-                                this.inputting.amount = res.data.data.counted_amount;
-                                window.tempTip.setDuration(2000);
-                                window.tempTip.showSuccess('成功增加“'+this.inputting.barcode+'”实盘数量')
-                            }
-                            if (this.status.commitButtonVisible) this.status.commitButtonVisible=false;
-                            this.audioDing();
-                            if (this.inputMode === 'regular')this.cleanInputs();
-                            if (this.inputting.bin_number && !this.status.binDisable)this.status.binDisable = true;
-                            return;
+                        if (res.data.success) exe();
+                        else{
+                            window.tempTip.confirm("商品信息不存在,是否录入为新商品",function () {
+                                exe();
+                            });
                         }
-                        window.tempTip.setDuration(3000);
-                        window.tempTip.show(res.data.data);
                     }).catch(err=>{
                     window.tempTip.setDuration(3000);
                     window.tempTip.show("网络错误:"+err);
                 });
+                let _this = this;
+                function exe(){
+                    axios.post('{{url('store/checkingReceive/insertItem')}}',{mission_id : _this.storeCheckingReceive.id,goods : _this.inputting})
+                        .then(res=>{
+                            if (res.data.success) {
+                                _this.lastScannedBarcode = _this.inputting.barcode;
+                                if (res.data.type === 'create'){
+                                    _this._addStoreCheckingReceiveItem(res.data.data);
+                                    window.tempTip.setDuration(2000);
+                                    window.tempTip.showSuccess('成功提交:' + _this.inputting.barcode);
+                                }else{
+                                    if (_this.storeCheckingReceiveItems.length > 0 && res.data.data.id === _this.storeCheckingReceiveItems[0].id){
+                                        _this.storeCheckingReceiveItems[0].counted_amount = res.data.data.counted_amount;
+                                        _this.storeCheckingReceiveItems[0].imported_diff_amount = res.data.data.imported_diff_amount;
+                                        _this.storeCheckingReceiveItems[0].asn_diff_amount = res.data.data.asn_diff_amount;
+                                        _this.storeCheckingReceiveItems[0].bin_number = res.data.data.bin_number;
+                                    }else{
+                                        _this._removeCheckingReceiveItem(res.data.data.id);
+                                        _this._addStoreCheckingReceiveItem(res.data.data);
+                                    }
+                                    _this.inputting.amount = res.data.data.counted_amount;
+                                    window.tempTip.setDuration(2000);
+                                    window.tempTip.showSuccess('成功增加“'+_this.inputting.barcode+'”实盘数量')
+                                }
+                                if (_this.status.commitButtonVisible) _this.status.commitButtonVisible=false;
+                                _this.audioDing();
+                                if (_this.inputMode === 'regular')_this.cleanInputs();
+                                if (_this.inputting.bin_number && !_this.status.binDisable)_this.status.binDisable = true;
+                                return;
+                            }
+                            window.tempTip.setDuration(3000);
+                            window.tempTip.show(res.data.data);
+                        }).catch(err=>{
+                        window.tempTip.setDuration(3000);
+                        window.tempTip.show("网络错误:"+err);
+                    });
+                }
             },
             _addStoreCheckingReceiveItem(item){
                 let storeCheckingReceiveItem = {

+ 1 - 0
routes/web.php

@@ -42,6 +42,7 @@ Route::group(['prefix'=>'maintenance'],function(){
         });
         Route::get('import', 'CommodityController@import');
         Route::post('syncWMS','CommodityController@syncWMS');
+        Route::post('isExist','CommodityController@isExist');
     });
     /** 货主 */
     Route::group(['prefix'=>'owners'],function(){

+ 1 - 1
tests/Inventory/Services/InventoryAccountService/InventoryAccountService_CreateInventoryMissionRecordTest.php

@@ -18,7 +18,7 @@ class InventoryServiceCreateInventoryMissionRecordTest extends TestCase
     public $wmsInventoryAccounts;
     function setUp(): void
     {
-        parent::setUp(); // TODO: Change the autogenerated stub
+        parent::setUp();
         $this->inventory=factory(InventoryAccount::class)->create();
         $this->realService=new InventoryAccountService();
         $this->wmsInventoryAccounts=$this->realService->conditionPortStock('2020-08-20','2020-08-20',3);

+ 1 - 1
tests/Services/CacheService/GetOrExecuteTest.php

@@ -1,6 +1,6 @@
 <?php
 
-namespace Tests\Services\CacheService\GetOrExecuteTest;
+namespace Tests\Services\CacheService;
 
 use App\Services\CacheService;
 use Illuminate\Support\Facades\Cache;

+ 1 - 1
tests/Services/CommodityBarcodeService/InsertMany_onCommoditiesTest.php

@@ -1,6 +1,6 @@
 <?php
 
-namespace Tests\Services\CacheService\GetOrExecuteTest;
+namespace Tests\Services\CommodityBarcodeService;
 
 use App\Commodity;
 use App\CommodityBarcode;

+ 2 - 2
tests/Services/CommodityService/SyncBarcodesTest.php

@@ -1,6 +1,6 @@
 <?php
 
-namespace Tests\Services\CacheService\GetOrExecuteTest;
+namespace Tests\Services\CommodityService;
 
 use App\Commodity;
 use App\CommodityBarcode;
@@ -11,7 +11,7 @@ use Illuminate\Database\Eloquent\Collection;
 use Illuminate\Support\Facades\Cache;
 use Tests\TestCase;
 
-class InsertMany_onCommoditiesTest extends TestCase
+class SyncBarcodesTest extends TestCase
 {
 
     /** @var CommodityService $service */

+ 87 - 0
tests/Services/CustomerService/CustomerTest.php

@@ -0,0 +1,87 @@
+<?php
+
+namespace Tests\Unit\Customer\CustomerService;
+
+use App\Customer;
+use App\Services\CustomerService;
+use Illuminate\Support\Str;
+use Tests\TestCase;
+
+class CustomerTest extends TestCase
+{
+    /** @var CustomerService */
+    public $service;
+    public $data;
+
+    protected function setUp(): void
+    {
+        parent::setUp();
+        $this->service = app(CustomerService::class);
+        $this->data = [
+            "models"=>factory(Customer::class,3)->create()->toArray()
+        ];
+    }
+
+    /**
+     * @group customer
+     */
+    public function testCreate(){
+        $model = $this->service->create([
+            "code" => date('Ymd').Str::random(4),
+            "name" => date('Ymd').Str::random(5),
+            "company_name" => date('Ymd').Str::random(6),
+        ]);
+        $this->assertNotNull($model);
+        $this->data["models"][] = $model->toArray();
+    }
+    /**
+     * @group customer
+     */
+    public function testGetSelection(){
+        $models = $this->service->getSelection(["id","name","company_name"]);
+        $this->assertGreaterThanOrEqual(1,count($models));
+        $this->assertArrayHasKey("company_name",$models[0]);
+    }
+    /**
+     * @group customer
+     */
+    public function testPaginate(){
+        $models = $this->service->paginate(5);
+        $this->assertGreaterThanOrEqual(1,count($models));
+        $this->assertLessThanOrEqual(5,count($models));
+    }
+    /**
+     * @group customer
+     */
+    public function testFind(){
+        $model = $this->service->find($this->data["models"][0]["id"]);
+        $this->assertNotNull($model);
+    }
+    /**
+     * @group customer
+     */
+    public function testUpdate()
+    {
+        $value = date('YmdH').Str::random(4);
+        $row = $this->service->update(["id"=>$this->data["models"][0]["id"]],[
+            "name" => $value,
+        ]);
+        $this->data["models"][0]["name"] = $value;
+        $this->assertEquals($row,1);
+    }
+    /**
+     * @group customer
+     */
+    public function testDestroy()
+    {
+        $row = $this->service->destroy($this->data["models"][0]["id"]);
+        $this->assertEquals($row,1);
+        $this->assertDeleted("customers", $this->data["models"][0]);
+    }
+
+    public function tearDown(): void
+    {
+        Customer::destroy(array_column($this->data["models"],'id'));
+        parent::tearDown();
+    }
+}

+ 151 - 0
tests/Services/FeatureService/FeatureServiceTest.php

@@ -0,0 +1,151 @@
+<?php
+
+namespace Tests\Unit\Customer\FeatureService;
+
+use App\Feature;
+use App\Services\FeatureService;
+use Illuminate\Support\Str;
+use Ramsey\Uuid\Uuid;
+use Tests\TestCase;
+
+class FeatureServiceTest extends TestCase
+{
+    /** @var FeatureService */
+    public $service;
+    public $data;
+
+    protected function setUp(): void
+    {
+        parent::setUp();
+        $this->service = app(FeatureService::class);
+        $this->data = [
+           "models" => factory(Feature::class,3)->create()->toArray(),
+        ];
+    }
+
+    /**
+     * @group customer
+     */
+    public function testGetMapArray(){
+        $models = $this->service->getMapArray();
+        $this->assertGreaterThanOrEqual(3,count($models));
+    }
+    /**
+     * @group customer
+     */
+    public function testTranslationFeature(){
+        $str = $this->data["models"][0]["id"]."&(".$this->data["models"][1]["id"]."|".$this->data["models"][2]["id"].")";
+        $result = $this->service->translationFeature($str);
+        $this->assertEquals(3,count($result));
+        $this->assertEquals($this->data["models"][1]["type"],$result[1]["type"]);
+        $this->assertEquals(false,$result[0]["strategyGroupStartSign"]);
+        $this->assertEquals(true,$result[1]["strategyGroupStartSign"]);
+        $this->assertEquals("并且",$result[1]["calculation"]);
+        $this->assertEquals(true,$result[2]["strategyGroupEndSign"]);
+        $this->assertEquals("或",$result[2]["calculation"]);
+    }
+    /**
+     * @group customer
+     */
+    public function testAnalysisFeature(){
+        $models = $this->data["models"];
+        $params = [
+            [
+                "strategyGroupStartSign" => true,
+                "calculation" => "",
+                "type"=>$models[0]["type"],
+                "logic"=>$models[0]["logic"],
+                "describe"=>$models[0]["describe"],
+                "strategyGroupEndSign" => false,
+            ],[
+                "strategyGroupStartSign" => false,
+                "calculation" => "并且",
+                "type"=>$models[1]["type"],
+                "logic"=>$models[1]["logic"],
+                "describe"=>$models[1]["describe"],
+                "strategyGroupEndSign" => true,
+            ],[
+                "strategyGroupStartSign" => false,
+                "calculation" => "或",
+                "type"=>$models[2]["type"],
+                "logic"=>$models[2]["logic"],
+                "describe"=>$models[2]["describe"],
+                "strategyGroupEndSign" => false,
+            ]
+        ];
+        $expected = "(".$models[0]["id"]."&".$models[1]["id"].")|".$models[2]["id"];
+        $result = $this->service->analysisFeature($params);
+        $this->assertIsArray($result);
+        $this->assertCount(2,$result);
+        $this->assertArrayHasKey("feature",$result);
+        $this->assertEquals($expected,$result["feature"]);
+    }
+    /**
+     * @group customer
+     */
+    public function testFormatFeature(){
+        $model1 = factory(Feature::class)->make([
+            "id" => 1,
+            "type"=>"商品名称",
+            "logic"=>"包含",
+            "describe"=>"衣服"
+        ]);
+        $model2 = factory(Feature::class)->make([
+            "id" => 2,
+            "type"=>"订单类型",
+            "logic"=>"不包含",
+            "describe"=>"创建"
+        ]);
+        $model3 = factory(Feature::class)->make([
+            "id"=>3,
+            "type"=>"承运商",
+            "logic"=>"等于",
+            "describe"=>"顺丰"
+        ]);
+        $features = [1=>$model1,2=>$model2,3=>$model3];
+        $result = $this->service->formatFeature($features,"1&(2|3)");
+        $expected = "商品名称 包含 衣服 并且 (订单类型 不包含 创建 或 承运商 等于 顺丰)";
+        $this->assertEquals($expected,$result);
+        $columnMapping = ["商品名称"=>"commodity_name","订单类型"=>"order_type","承运商"=>"logistic_name"];
+        $result = $this->service->formatFeature($features,"1&(2|3)",$columnMapping);
+        $expected = "commodity_name like '%衣服%' and (order_type not like '%创建%' or logistic_name = '顺丰')";
+        $this->assertEquals($expected,$result);
+    }
+    /**
+     * @group customer
+     */
+    public function testMatchFeature(){
+        $model1 = factory(Feature::class)->create([
+            "type" => "商品名称",
+            "logic"=>"包含",
+            "describe"=>Uuid::uuid1(),
+        ]);
+        $model2 = factory(Feature::class)->create([
+            "type" => "订单类型",
+            "logic"=>"不包含",
+            "describe"=>Uuid::uuid1(),
+        ]);
+        $model3 = factory(Feature::class)->create([
+            "type" => "店铺类型",
+            "logic"=>"等于",
+            "describe"=>Uuid::uuid1(),
+        ]);
+        $this->data["models"][] = $model1->toArray();
+        $this->data["models"][] = $model2->toArray();
+        $this->data["models"][] = $model3->toArray();
+        $columnMapping = ["商品名称"=>"commodity","订单类型"=>"order","店铺类型"=>"shop"];
+        $matchObject = ["commodity"=>Str::random(2).$model1->describe,"order"=>$model1->describe,"shop"=>$model3->describe];
+        $value = $model1->id."&(".$model2->id."&".$model3->id.")";
+        $result = $this->service->matchFeature($value,$columnMapping,$matchObject);
+        $this->assertEquals(true,$result);
+        $matchObject = ["commodity"=>$model1->describe.Str::random(2),"order"=>$model2->describe.Str::random(2),"shop"=>"1"];
+        $result = $this->service->matchFeature($value,$columnMapping,$matchObject);
+        $this->assertEquals(false,$result);
+    }
+
+    public function tearDown(): void
+    {
+        Feature::destroy(array_column($this->data["models"],"id"));
+        parent::tearDown();
+    }
+}

+ 1 - 1
tests/Services/OracleDOCOrderHeaderService/GetWmsOrderOnstartDateCreateTest.php

@@ -1,6 +1,6 @@
 <?php
 
-namespace Tests\Services\OracleDOCOrderHeaderService\GetWmsOrderOnStartDateCreateTest;
+namespace Tests\Services\OracleDOCOrderHeaderService;
 
 use App\OracleDOCOrderHeader;
 use App\Services\OracleDOCOrderHeaderService;

+ 86 - 0
tests/Services/OwnerAreaReportService/OwnerAreaReportServiceTest.php

@@ -0,0 +1,86 @@
+<?php
+
+
+namespace Tests\Services\OwnerAreaReportService;
+
+
+use App\Owner;
+use App\OwnerAreaReport;
+use App\OwnerStoragePriceModel;
+use App\Services\OwnerAreaReportService;
+use App\Unit;
+use App\UserOwnerGroup;
+use Tests\TestCase;
+
+class OwnerAreaReportServiceTest extends  TestCase
+{
+    /** @var OwnerAreaReportService */
+    public $service;
+    public $data;
+
+    protected function setUp(): void
+    {
+        parent::setUp();
+        $this->service = app(OwnerAreaReportService::class);
+
+        $userOwnerGroup = factory(\App\UserOwnerGroup::class)->create();
+        $owner = factory(\App\Owner::class)->create([
+            "user_owner_group_id"=>$userOwnerGroup->id,
+        ]);
+        $unit = factory(Unit::class)->create();
+        $ownerStoragePriceModel = factory(\App\OwnerStoragePriceModel::class)->create([
+            "unit_id" => $unit->id,
+        ]);
+
+        $this->data["owners"] = [$owner->toArray()];
+        $this->data["units"] = [$unit->toArray()];
+        $this->data["ownerStoragePriceModels"] = [$ownerStoragePriceModel->toArray()];
+        $this->data["userOwnerGroups"] = [$userOwnerGroup->toArray()];
+        $this->data["models"] = factory(OwnerAreaReport::class,3)->create([
+            "owner_id" => $owner->id,
+            "owner_storage_price_model_id" => $ownerStoragePriceModel->id,
+            "user_owner_group_id" => $userOwnerGroup->id,
+        ])->toArray();
+    }
+
+    /**
+     * @group customer
+     */
+    public function testPaginate()
+    {
+        $models = $this->service->paginate(array("paginate"=>5));
+        $this->assertGreaterThanOrEqual(3,count($models));
+        $this->assertLessThanOrEqual(5,count($models));
+    }
+    /**
+     * @group customer
+     */
+    public function testUpdate(){
+        $model = $this->data["models"][0];
+        $result = $this->service->update(["id"=>$model["id"]],[
+            "accounting_area" => 1000,
+        ]);
+        $this->assertEquals(true,$result);
+        $area = OwnerAreaReport::query()->find($model["id"]);
+        $this->assertNotNull($area);
+        $this->assertEquals(1000,$area->accounting_area);
+    }
+    /**
+     * @group customer
+     */
+    public function testGet(){
+        $ids = implode(",",array_column($this->data["models"],"owner_id"));
+        $models = $this->service->get(["owner_id"=>$ids]);
+        $this->assertGreaterThanOrEqual(3,count($models));
+    }
+
+    protected function tearDown(): void
+    {
+        Owner::destroy(array_column($this->data["owners"],"id"));
+        Unit::destroy(array_column($this->data["units"],"id"));
+        OwnerStoragePriceModel::destroy(array_column($this->data["ownerStoragePriceModels"],"id"));
+        UserOwnerGroup::destroy(array_column($this->data["userOwnerGroups"],"id"));
+        OwnerAreaReport::destroy(array_column($this->data["models"],"id"));
+        parent::tearDown();
+    }
+}

+ 74 - 0
tests/Services/OwnerBillReportService/OwnerBillReportServiceTest.php

@@ -0,0 +1,74 @@
+<?php
+
+
+namespace Tests\Services\OwnerBillReportService;
+
+
+use App\Owner;
+use App\OwnerBillReport;
+use App\Services\OwnerBillReportService;
+use App\UserOwnerGroup;
+use Tests\TestCase;
+
+class OwnerBillReportServiceTest extends  TestCase
+{
+    /** @var OwnerBillReportService */
+    public $service;
+    public $data;
+
+    protected function setUp(): void
+    {
+        parent::setUp();
+        $this->service = app(OwnerBillReportService::class);
+
+        $userOwnerGroup = factory(\App\UserOwnerGroup::class)->create();
+        $owner = factory(\App\Owner::class)->create([
+            "user_owner_group_id"=>$userOwnerGroup->id,
+        ]);
+
+        $this->data["owners"] = [$owner->toArray()];
+        $this->data["userOwnerGroups"] = [$userOwnerGroup->toArray()];
+        $this->data["models"] = factory(OwnerBillReport::class,3)->create([
+            "owner_id" => $owner->id,
+        ])->toArray();
+    }
+
+    /**
+     * @group customer
+     */
+    public function testPaginate()
+    {
+        $models = $this->service->paginate(array("paginate"=>5));
+        $this->assertGreaterThanOrEqual(3,count($models));
+        $this->assertLessThanOrEqual(5,count($models));
+    }
+    /**
+     * @group customer
+     */
+    public function testUpdate(){
+        $model = $this->data["models"][0];
+        $result = $this->service->update(["id"=>$model["id"]],[
+            "difference" => 1000,
+        ]);
+        $this->assertEquals(1,$result);
+        $bill = OwnerBillReport::query()->find($model["id"]);
+        $this->assertNotNull($bill);
+        $this->assertEquals(1000,$bill->difference);
+    }
+    /**
+     * @group customer
+     */
+    public function testGet(){
+        $ids = implode(",",array_column($this->data["models"],"owner_id"));
+        $models = $this->service->get(["owner_id"=>$ids]);
+        $this->assertGreaterThanOrEqual(3,count($models));
+    }
+
+    protected function tearDown(): void
+    {
+        UserOwnerGroup::destroy(array_column($this->data["userOwnerGroups"],"id"));
+        Owner::destroy(array_column($this->data["owners"],"id"));
+        OwnerBillReport::destroy(array_column($this->data["models"],"id"));
+        parent::tearDown();
+    }
+}

+ 87 - 0
tests/Services/OwnerFeeDetailService/OwnerFeeDetailServiceTest.php

@@ -0,0 +1,87 @@
+<?php
+
+
+namespace Tests\Services\OwnerFeeDetailService;
+
+
+use App\Logistic;
+use App\Owner;
+use App\OwnerFeeDetail;
+use App\ProcessMethod;
+use App\Services\OwnerFeeDetailService;
+use App\Shop;
+use App\Unit;
+use App\UserOwnerGroup;
+use Illuminate\Support\Facades\DB;
+use Tests\TestCase;
+
+class OwnerFeeDetailServiceTest extends  TestCase
+{
+    /** @var OwnerFeeDetailService */
+    public $service;
+    public $data;
+
+    protected function setUp(): void
+    {
+        parent::setUp();
+        $this->service = app(OwnerFeeDetailService::class);
+
+        $unit = factory(Unit::class)->create();
+        $logistic = factory(Logistic::class)->create();
+        $processMethod = factory(ProcessMethod::class)->create([
+            "unit_id" => $unit->id,
+        ]);
+        $userOwnerGroup = factory(\App\UserOwnerGroup::class)->create();
+        $owner = factory(\App\Owner::class)->create([
+            "user_owner_group_id"=>$userOwnerGroup->id,
+        ]);
+        $shop = factory(Shop::class)->create([
+            "owner_id" => $owner->id,
+        ]);
+
+        $this->data["userOwnerGroups"] = [$userOwnerGroup->toArray()];
+        $this->data["owners"] = [$owner->toArray()];
+        $this->data["shops"] = [$shop->toArray()];
+        $this->data["units"] = [$unit->toArray()];
+        $this->data["logistics"] = [$logistic->toArray()];
+        $this->data["processMethods"] = [$processMethod->toArray()];
+        $this->data["models"] = factory(OwnerFeeDetail::class,3)->create([
+            "logistic_id"       => $logistic->id,      //物流ID
+            "process_method_id" => $processMethod->id,//加工类型ID
+            "owner_id" => $owner->id,
+            "shop_id" => $shop->id
+        ])->toArray();
+    }
+
+    /**
+     * @group customer
+     */
+    public function testPaginate()
+    {
+        $models = $this->service->paginate(array("paginate"=>5));
+        $this->assertGreaterThanOrEqual(3,count($models));
+        $this->assertLessThanOrEqual(5,count($models));
+    }
+    /**
+     * @group customer
+     */
+    public function testGetSql()
+    {
+        $ids = implode(",",array_column($this->data["models"],"id"));
+        $sql = $this->service->getSql(["id"=>$ids]);
+        $models = DB::select(DB::raw($sql));
+        $this->assertCount(3,$models);
+    }
+
+    public function tearDown(): void
+    {
+        UserOwnerGroup::destroy(array_column($this->data["userOwnerGroups"],"id"));
+        Owner::destroy(array_column($this->data["owners"],"id"));
+        Shop::destroy(array_column($this->data["shops"],"id"));
+        Unit::destroy(array_column($this->data["units"],"id"));
+        Logistic::destroy(array_column($this->data["logistics"],"id"));
+        ProcessMethod::destroy(array_column($this->data["processMethods"],"id"));
+        OwnerFeeDetail::destroy(array_column($this->data["models"],"id"));
+        parent::tearDown();
+    }
+}

+ 135 - 0
tests/Services/OwnerOutStorageRuleService/OwnerOutStorageRuleServiceTest.php

@@ -0,0 +1,135 @@
+<?php
+
+
+namespace Tests\Services\OwnerOutStorageRuleService;
+
+
+use App\OwnerOutStorageRule;
+use App\OwnerPriceOperation;
+use App\Services\OwnerOutStorageRuleService;
+use App\Unit;
+use Tests\TestCase;
+
+class OwnerOutStorageRuleServiceTest extends  TestCase
+{
+    /** @var OwnerOutStorageRuleService */
+    public $service;
+    public $data;
+
+    protected function setUp(): void
+    {
+        parent::setUp();
+        $this->service = app(OwnerOutStorageRuleService::class);
+
+        $this->data["units"] = [];
+        $unit1 = Unit::query()->where("name","件")->first();
+        if (!$unit1){
+            $unit1 = factory(Unit::class)->create([
+                "name" => "件"
+            ]);
+            $this->data["units"][] = $unit1->toArray();
+        }
+        $unit2 = Unit::query()->where("name","箱")->first();
+        if (!$unit2){
+            $unit2 = factory(Unit::class)->create([
+                "name" => "箱"
+            ]);
+            $this->data["units"][] = $unit2->toArray();
+        }
+        $ownerPriceOperation = factory(OwnerPriceOperation::class)->create();
+
+
+        $this->data["ownerPriceOperations"] = [$ownerPriceOperation->toArray()];
+        $this->data["models"] = [];
+        $this->data["models"][] = factory(OwnerOutStorageRule::class)->create([
+            "owner_price_operation_id" => $ownerPriceOperation->id,
+            "unit_id" => $unit1->id,
+        ])->toArray();
+        $this->data["models"][] = factory(OwnerOutStorageRule::class)->create([
+            "owner_price_operation_id" => $ownerPriceOperation->id,
+            "unit_id" => $unit2->id,
+        ])->toArray();
+    }
+
+    /**
+     * @group customer
+     */
+    public function testGet()
+    {
+        $models = $this->service->get(["owner_price_operation_id"=>$this->data["ownerPriceOperations"][0]["id"]]);
+        $this->assertCount(2,$models);
+    }
+    /**
+     * @group customer
+     */
+    public function testUpdate()
+    {
+        $model = $this->data["models"][0];
+        $result = $this->service->update(["id"=>$model["id"]],[
+            "unit_price" => 1.33,
+            "priority" => 99,
+            "amount" => 50
+        ]);
+        $this->assertEquals(1,$result);
+        $expected = OwnerOutStorageRule::query()->find($model["id"]);
+        $this->assertEquals(99,$expected->priority);
+        $this->assertEquals(1.33,$expected->unit_price);
+        $this->assertEquals(50,$expected->amount);
+    }
+    /**
+     * @group customer
+     */
+    public function testCreate()
+    {
+        $model = $this->service->create([
+            "owner_price_operation_id" => 1,         //作业计费ID
+            "strategy" => "特征",                         //出库策略
+            "amount" => 20,                           //起步数
+            "unit_id" => 2,                          //单位ID
+            "unit_price" => 2,                       //单价
+            "feature" => "1&3",                          //特征
+            "priority" => 6,                         //优先级 值越大越高
+        ]);
+        $this->assertNotNull($model);
+        $this->data["models"][] = $model->toArray();
+    }
+    /**
+     * @group customer
+     */
+    public function testFindUpdate()
+    {
+        $model = OwnerOutStorageRule::query()->find($this->data["models"][0]["id"]);
+        $result = $this->service->findUpdate($model,[
+            "unit_price" => 0.566,
+        ]);
+        $this->assertEquals(1,$result);
+    }
+    /**
+     * @group customer
+     */
+    public function testFind()
+    {
+        $models = $this->service->find(array_column($this->data["models"],"id"));
+        $this->assertCount(2,$models);
+    }
+    /**
+     * @group customer
+     */
+    public function testIsExist()
+    {
+        $result = $this->service->isExist([
+            "id" => $this->data["models"][0]["id"],
+            "owner_price_operation_id" => $this->data["models"][0]["owner_price_operation_id"],
+            "strategy" => $this->data["models"][0]["strategy"],
+        ]);
+        $this->assertGreaterThan(0,$result);
+    }
+
+    public function tearDown(): void
+    {
+        Unit::destroy(array_column($this->data["units"],"id"));
+        OwnerPriceOperation::destroy(array_column($this->data["ownerPriceOperations"],"id"));
+        OwnerOutStorageRule::destroy(array_column($this->data["models"],"id"));
+        parent::tearDown();
+    }
+}

+ 199 - 0
tests/Services/OwnerPriceDirectLogisticService/OwnerPriceDirectLogisticServiceTest.php

@@ -0,0 +1,199 @@
+<?php
+
+
+namespace Tests\Services\OwnerPriceDirectLogisticService;
+
+use App\CarType;
+use App\Owner;
+use App\OwnerPriceDirectLogistic;
+use App\OwnerPriceDirectLogisticCar;
+use App\Services\OwnerPriceDirectLogisticService;
+use Ramsey\Uuid\Uuid;
+use Tests\TestCase;
+
+class OwnerPriceDirectLogisticServiceTest extends  TestCase
+{
+    /** @var OwnerPriceDirectLogisticService */
+    public $service;
+    public $data;
+
+    protected function setUp(): void
+    {
+        parent::setUp();
+        $this->service = app(OwnerPriceDirectLogisticService::class);
+
+        $this->data["models"] = factory(OwnerPriceDirectLogistic::class,3)->create()->toArray();
+    }
+
+    /**
+     * @group customer
+     */
+    public function testPaginate()
+    {
+        $models = $this->service->paginate();
+        $this->assertGreaterThanOrEqual(3,count($models));
+        $this->assertLessThanOrEqual(50,count($models));
+        $models = $this->service->paginate($this->data["models"][0]["id"]);
+        $this->assertCount(1,$models);
+    }
+    /**
+     * @group customer
+     */
+    public function testCreate()
+    {
+        $model = $this->service->create([
+            "name" => Uuid::uuid1(),
+            "base_km" => 3
+        ]);
+        $this->assertNotNull($model);
+        $this->data["models"][] = $model->toArray();
+    }
+    /**
+     * @group customer
+     */
+    public function testDestroy()
+    {
+        $result = $this->service->destroy(array_column($this->data["models"],"id"));
+        $this->assertEquals(3,$result);
+        $this->data["models"] = [];
+    }
+    /**
+     * @group customer
+     */
+    public function testFind()
+    {
+        $model = $this->service->find($this->data["models"][0]["id"]);
+        $this->assertNotNull($model);
+    }
+    /**
+     * @group customer
+     */
+    public function testUpdate()
+    {
+        $id = $this->data["models"][0]["id"];
+        $result = $this->service->update(["id"=>$id],[
+            "base_km" => 3
+        ]);
+        $this->assertEquals(1,$result);
+        $model = OwnerPriceDirectLogistic::query()->find($id);
+        $this->assertEquals(3,$model->base_km);
+    }
+    /**
+     * @group customer
+     */
+    public function testUpdateDetail()
+    {
+        $car = factory(\App\CarType::class)->create();
+        $model = factory(OwnerPriceDirectLogisticCar::class)->create([
+            "owner_price_direct_logistic_id" => $this->data["models"][0]["id"],   //直发车计费ID
+            "car_type_id" => $car->id,                      //车型ID
+        ]);
+        $result = $this->service->updateDetail(["id"=>$model->id],["base_fee"=>0.01]);
+        $this->assertEquals(1,$result);
+        OwnerPriceDirectLogisticCar::destroy($model->id);
+        CarType::destroy($car->id);
+    }
+    /**
+     * @group customer
+     */
+    public function testIsExistDetail()
+    {
+        $car = factory(\App\CarType::class)->create();
+        $model = factory(OwnerPriceDirectLogisticCar::class)->create([
+            "owner_price_direct_logistic_id" => $this->data["models"][0]["id"],   //直发车计费ID
+            "car_type_id" => $car->id,                      //车型ID
+        ]);
+        $result = $this->service->isExistDetail(["owner_price_direct_logistic_id"=>$this->data["models"][0]["id"]]);
+        $this->assertGreaterThan(0,$result);
+        OwnerPriceDirectLogisticCar::destroy($model->id);
+        CarType::destroy($car->id);
+    }
+    /**
+     * @group customer
+     */
+    public function testCreatedDetail()
+    {
+        $model = $this->service->createDetail([
+            "owner_price_direct_logistic_id" => $this->data["models"][0]["id"],   //直发车计费ID
+            "car_type_id" => 1,
+            "base_fee" => 1,
+            "additional_fee" => 1,
+        ]);
+        $this->assertNotNull($model);
+        OwnerPriceDirectLogisticCar::destroy($model->id);
+    }
+    /**
+     * @group customer
+     */
+    public function testDestroyDetail()
+    {
+        $car = factory(\App\CarType::class)->create();
+        $model = factory(OwnerPriceDirectLogisticCar::class)->create([
+            "owner_price_direct_logistic_id" => $this->data["models"][0]["id"],   //直发车计费ID
+            "car_type_id" => $car->id,                      //车型ID
+        ]);
+        $result = $this->service->destroyDetail($model->id);
+        $this->assertEquals(1,$result);
+        CarType::destroy($car->id);
+    }
+    /**
+     * @group customer
+     */
+    public function testGetExistOwnerName()
+    {
+        $owner = factory(Owner::class)->create([
+            "user_owner_group_id" => 1,
+        ]);
+        /** @var OwnerPriceDirectLogistic $model */
+        $model = OwnerPriceDirectLogistic::query()->find($this->data["models"][0]["id"]);
+        $model->owners()->sync([$owner->id]);
+        $result = $this->service->getExistOwnerName($owner->id,$this->data["models"][0]["id"]);
+        $this->assertCount(0,$result);
+        $result = $this->service->getExistOwnerName($owner->id,null);
+        $this->assertCount(1,$result);
+        $this->assertEquals($owner->name,$result[0]);
+        Owner::destroy($owner->id);
+        $model->owners()->sync([]);
+    }
+    /**
+     * @group customer
+     */
+    public function testMatching()
+    {
+        $model = factory(OwnerPriceDirectLogistic::class)->create([
+            "base_km" => 2,
+        ]);
+        $this->data["models"][] = $model->toArray();
+        $owner = factory(Owner::class)->create([
+            "user_owner_group_id" => 1,
+        ]);
+        $model->owners()->sync([$owner->id]);
+        $cars = factory(\App\CarType::class,2)->create();
+        $item1 = factory(OwnerPriceDirectLogisticCar::class)->create([
+            "owner_price_direct_logistic_id" => $model->id,   //直发车计费ID
+            "car_type_id" => $cars[0]->id,                      //车型ID
+            "base_fee" => 1.5,                         //起步费
+            "additional_fee" =>2.5,                   //续费(元/KM)
+        ]);
+        $item2 = factory(OwnerPriceDirectLogisticCar::class)->create([
+            "owner_price_direct_logistic_id" => $model->id,   //直发车计费ID
+            "car_type_id" => $cars[1]->id,                      //车型ID
+            "base_fee" =>1.3,                         //起步费
+            "additional_fee" =>1.6,                   //续费(元/KM)
+        ]);
+        $result = $this->service->matching(10,$owner->id,$cars[0]->id);
+        $this->assertEquals(23,$result);
+        $result = $this->service->matching(10,$owner->id,$cars[1]->id);
+        $this->assertEquals(15.4,$result);
+        $model->owners()->sync([]);
+        Owner::destroy($owner->id);
+        CarType::destroy(array_column($cars->toArray(),"id"));
+        OwnerPriceDirectLogisticCar::destroy([$item1->id,$item2->id]);
+    }
+
+    public function tearDown(): void
+    {
+        OwnerPriceDirectLogistic::destroy(array_column($this->data["models"],"id"));
+        parent::tearDown();
+    }
+}

+ 203 - 0
tests/Services/OwnerPriceExpressService/OwnerPriceExpressServiceTest.php

@@ -0,0 +1,203 @@
+<?php
+
+
+namespace Tests\Services\OwnerPriceExpressService;
+
+
+use App\Logistic;
+use App\Owner;
+use App\OwnerPriceExpress;
+use App\OwnerPriceExpressProvince;
+use App\Province;
+use App\Services\OwnerPriceExpressService;
+use Illuminate\Support\Str;
+use Tests\TestCase;
+
+class OwnerPriceExpressServiceTest extends  TestCase
+{
+    /** @var OwnerPriceExpressService */
+    public $service;
+    public $data;
+
+    protected function setUp(): void
+    {
+        parent::setUp();
+        $this->service = app(OwnerPriceExpressService::class);
+
+        $this->data["models"] = factory(OwnerPriceExpress::class,2)->create()->toArray();
+    }
+
+    /**
+     * @group customer
+     */
+    public function testPaginate()
+    {
+        $models = $this->service->paginate();
+        $this->assertGreaterThanOrEqual(2,count($models));
+        $models = $this->service->paginate($this->data["models"][0]["id"]);
+        $this->assertCount(1,$models);
+    }
+    /**
+     * @group customer
+     */
+    public function testFind()
+    {
+        $model = $this->service->find($this->data["models"][0]["id"]);
+        $this->assertNotNull($model);
+    }
+    /**
+     * @group customer
+     */
+    public function testUpdateDetail()
+    {
+        $detail = factory(OwnerPriceExpressProvince::class)->create([
+            "owner_price_express_id" => $this->data["models"][0]["id"],   //快递价格ID
+        ]);
+        $result = $this->service->updateDetail(["id"=>$detail->id],["initial_weight_price"=>5]);
+        $this->assertEquals(1,$result);
+        OwnerPriceExpressProvince::destroy($detail->id);
+    }
+    /**
+     * @group customer
+     */
+    public function testCreate()
+    {
+        $model = $this->service->create([
+            "name" => md5(Str::random(8)),
+            "initial_weight" => mt_rand(6,260) / 5,
+            "additional_weight" => mt_rand(6,260) / 5,
+        ]);
+        $this->assertNotNull($model);
+        $this->data["models"][] = $model->toArray();
+    }
+    /**
+     * @group customer
+     */
+    public function testCreateDetail()
+    {
+        $model = $this->service->createDetail([
+            "owner_price_express_id" => $this->data["models"][0]["id"],
+            "province_id" => 1,
+            "initial_weight_price" => mt_rand(6,260) / 5,
+            "additional_weight_price"=>mt_rand(6,260) / 5,
+        ]);
+        $this->assertNotNull($model);
+        $this->assertNotNull($model->id);
+        OwnerPriceExpressProvince::destroy($model->id);
+    }
+    /**
+     * @group customer
+     */
+    public function testIsExistDetail()
+    {
+        $province = Province::query()->first();
+        $detail = factory(OwnerPriceExpressProvince::class)->create([
+            "owner_price_express_id" => $this->data["models"][0]["id"],
+            "province_id" => $province->id
+        ]);
+        $result = $this->service->isExistDetail([
+            "owner_price_express_id"=>$this->data["models"][0]["id"],
+            "province_id" => $province->id
+        ]);
+        $this->assertGreaterThan(0,$result);
+        OwnerPriceExpressProvince::destroy($detail->id);
+    }
+    /**
+     * @group customer
+     */
+    public function testDestroyDetail()
+    {
+        $detail = factory(OwnerPriceExpressProvince::class)->create([
+            "owner_price_express_id" => $this->data["models"][0]["id"],
+        ]);
+        $result = $this->service->destroyDetail($detail->id);
+        $this->assertEquals(1,$result);
+    }
+    /**
+     * @group customer
+     */
+    public function testGetExistOwnerName()
+    {
+        $owner = factory(Owner::class)->create([
+            "user_owner_group_id" => 1,
+        ]);
+        /** @var OwnerPriceExpress $model */
+        $model = OwnerPriceExpress::query()->find($this->data["models"][0]["id"]);
+        $model->owners()->sync([$owner->id]);
+        $result = $this->service->getExistOwnerName([$owner->id],$this->data["models"][0]["id"]);
+        $this->assertCount(0,$result);
+        $result = $this->service->getExistOwnerName([$owner->id]);
+        $this->assertCount(1,$result);
+        $this->assertEquals($owner->name,$result[0]);
+        Owner::destroy($owner->id);
+        $model->owners()->sync([]);
+    }
+    /**
+     * @group customer
+     */
+    public function testGetExistLogisticName()
+    {
+        $logistic = factory(Logistic::class)->create();
+        /** @var OwnerPriceExpress $model */
+        $model = OwnerPriceExpress::query()->find($this->data["models"][0]["id"]);
+        $model->logistics()->sync([$logistic->id]);
+
+        $result = $this->service->getExistLogisticName([$logistic->id],$this->data["models"][0]["id"]);
+        $this->assertCount(0,$result);
+        $result = $this->service->getExistLogisticName([$logistic->id]);
+        $this->assertCount(1,$result);
+        $this->assertEquals($logistic->name,$result[0]);
+
+        Logistic::destroy($logistic->id);
+        $model->logistics()->sync([]);
+    }
+    /**
+     * @group customer
+     */
+    public function testDestroy()
+    {
+        $result = $this->service->destroy($this->data["models"][0]["id"]);
+        $this->assertEquals(1,$result);
+        unset($this->data["models"][0]);
+    }
+    /**
+     * @group customer
+     */
+    public function testUpdate()
+    {
+        $result = $this->service->update(["id"=>$this->data["models"][0]["id"]],["initial_weight"=>3]);
+        $this->assertEquals(1,$result);
+    }
+    /**
+     * @group customer
+     */
+    public function testMatching()
+    {
+        /** @var OwnerPriceExpress $model */
+        $model = factory(OwnerPriceExpress::class)->create([
+            "initial_weight" => 2.4,
+            "additional_weight" => 3.1,//16.2
+        ]);
+        $this->data["models"][] = $model->toArray();
+        $detail = factory(OwnerPriceExpressProvince::class)->create([
+            "owner_price_express_id" => $model->id,
+            "province_id" => 1,
+            "initial_weight_price" => 2,     //初始单价 4.8
+            "additional_weight_price"=>2.2,  //续重单价
+        ]);
+        $model->owners()->sync([1]);
+        $model->logistics()->sync([1]);
+        $result = $this->service->matching(18.6,1,1,1);
+        $this->assertEquals(18,$result);
+        $model->owners()->sync([]);
+        $model->logistics()->sync([]);
+        OwnerPriceExpressProvince::destroy($detail->id);
+    }
+
+
+    public function tearDown(): void
+    {
+        OwnerPriceExpress::destroy(array_column($this->data["models"],"id"));
+        parent::tearDown();
+    }
+}

+ 220 - 0
tests/Services/OwnerPriceLogisticService/OwnerPriceLogisticServiceTest.php

@@ -0,0 +1,220 @@
+<?php
+
+
+namespace Tests\Services\OwnerPriceLogisticService;
+
+use App\Logistic;
+use App\Owner;
+use App\OwnerPriceLogistic;
+use App\OwnerPriceLogisticDetail;
+use App\Services\OwnerPriceLogisticService;
+use App\Unit;
+use Illuminate\Support\Str;
+use Tests\TestCase;
+
+class OwnerPriceLogisticServiceTest extends  TestCase
+{
+    /** @var OwnerPriceLogisticService */
+    public $service;
+    public $data;
+
+    protected function setUp(): void
+    {
+        parent::setUp();
+        $this->service = app(OwnerPriceLogisticService::class);
+
+        $units = factory(Unit::class,2)->create();
+        $this->data["units"] = $units->toArray();
+        $this->data["details"] = [];
+        $this->data["owners"] = [];
+        $this->data["logistics"] = [];
+        $this->data["models"] = factory(OwnerPriceLogistic::class,3)->create([
+            "unit_id" => $units[0]->id,
+            "other_unit_id" => $units[1]->id,
+        ])->toArray();
+    }
+
+    /**
+     * @group customer
+     */
+    public function testPaginate()
+    {
+        $models = $this->service->paginate();
+        $this->assertGreaterThanOrEqual(3,count($models));
+        $this->assertLessThanOrEqual(50,count($models));
+    }
+    /**
+     * @group customer
+     */
+    public function create()
+    {
+        $model = $this->service->create([
+            "name" => md5(Str::random(7)),
+            "unit_range" => "0-5,5-10,10-15,15-20",
+            "unit_id" => $this->data["units"][0]["id"],
+            "other_unit_range" => "0-5,5-10,10-15,15-20,30-",
+            "other_unit_id" => $this->data["units"][1]["id"],
+            "pick_up_price" => mt_rand(2,230) / 3,
+            "fuel_price" => mt_rand(2,230) / 3,
+            "service_price" => mt_rand(2,230) / 3,
+        ]);
+        $this->assertNotNull($model);
+        $this->data["models"][] = $model->toArray();
+    }
+    /**
+     * @group customer
+     */
+    public function testFind()
+    {
+        $model = $this->service->find($this->data["models"][0]["id"]);
+        $this->assertNotNull($model);
+    }
+    /**
+     * @group customer
+     */
+    public function testUpdate()
+    {
+        $result = $this->service->update(["id"=>$this->data["models"][0]["id"]],[
+            "fuel_price" => 2.222,
+        ]);
+        $this->assertEquals(1,$result);
+    }
+    /**
+     * @group customer
+     */
+    public function testUpdateDetail()
+    {
+        $province = \App\Province::query()->first();
+        $city = \App\City::query()->where("province_id",$province->id)->first();
+        $detail = factory(OwnerPriceLogisticDetail::class)->create([
+            "owner_price_logistic_id" => $this->data["models"][0]["id"],  //物流计费
+            "unit_id" => 1,                  //单位ID
+            "range" => "0-5",                    //区间
+            "province_id" => $province->id,              //省份ID
+            "city_id" => $city->id,
+        ]);
+        $this->assertNotNull($detail);
+        $this->data["details"][] = $detail->toArray();
+        $result = $this->service->updateDetail(["id"=>$detail->id],["range"=>"30-"]);
+        $this->assertEquals(1,$result);
+    }
+    /**
+     * @group customer
+     */
+    public function testIsExistDetail()
+    {
+        $detail = factory(OwnerPriceLogisticDetail::class)->create([
+            "owner_price_logistic_id" => $this->data["models"][0]["id"],  //物流计费
+            "unit_id" => 1,                  //单位ID
+        ]);
+        $this->data["details"][] = $detail->toArray();
+        $result = $this->service->isExistDetail(["unit_id"=>1,"owner_price_logistic_id"=> $this->data["models"][0]["id"]]);
+        $this->assertGreaterThan(0,$result);
+    }
+    /**
+     * @group customer
+     */
+    public function testCreateDetail()
+    {
+        $detail = $this->service->createDetail([
+            "owner_price_logistic_id" => 1,
+            "unit_id" => 1,
+            "range" => "0-5",
+            "province_id" => 1,
+            "city_id" => 1,
+            "unit_price" => mt_rand(1,36) / 3,
+            "delivery_fee" => mt_rand(1,136) / 3,
+            "initial_fee" => mt_rand(1,136) / 3,
+            "initial_amount" => mt_rand(1,136) / 3,
+            "rate" =>  mt_rand(1,136) / 3,
+        ]);
+        $this->assertNotNull($detail);
+        $this->data["details"][] = $detail->toArray();
+    }
+    /**
+     * @group customer
+     */
+    public function testDestroyDetail()
+    {
+        $detail = factory(OwnerPriceLogisticDetail::class)->create([
+            "owner_price_logistic_id" => $this->data["models"][0]["id"],  //物流计费
+            "unit_id" => 1,                  //单位ID
+        ]);
+        $this->data["details"][] = $detail->toArray();
+        $result = $this->service->destroyDetail($detail->id);
+        $this->assertEquals(1,$result);
+    }
+    /**
+     * @group customer
+     */
+    public function testCheckRange()
+    {
+        $result = $this->service->checkRange("0-5,5-10,10-15,15-30,30-");
+        $this->assertEquals(true,$result);
+        $result = $this->service->checkRange("0-5,5-10,10-15,15-30");
+        $this->assertEquals(false,$result);
+        $result = $this->service->checkRange("0-5,5-10,10-15,16-30,30-");
+        $this->assertEquals(false,$result);
+        $result = $this->service->checkRange("0-55-10,10-15,16-30,30-");
+        $this->assertEquals(false,$result);
+    }
+    /**
+     * @group customer
+     */
+    public function testMatching()
+    {
+        /** @var OwnerPriceLogistic $model */
+        $model = factory(OwnerPriceLogistic::class)->create([
+            "name" => md5(date('Ymd')).Str::random(4),             //名称
+            "unit_range" => "0-5,5-10,10-15,15-20",       //单价一区间
+            "unit_id" => 1,          //单位一ID
+            "other_unit_range" => "0-5,5-10,10-15,15-20,30-", //单位二区间
+            "other_unit_id" => 2,    //单位二ID
+            "pick_up_price" => 1.5,    //提货费
+            "fuel_price" => 2.5,       //燃油附加费
+            "service_price" => 3.5,    //信息服务费
+        ]);
+        $this->data["models"][] = $model->toArray();
+        $owner = factory(Owner::class)->create([
+            "user_owner_group_id" => 1
+        ]);
+        $this->data["owners"][] = $owner->toArray();
+        $logistic = factory(Logistic::class)->create();
+        $this->data["logistics"][] = $owner->toArray();
+        $model->owners()->sync([$owner->id]);
+        $model->logistics()->sync([$logistic->id]);
+        $detail = factory(OwnerPriceLogisticDetail::class)->create([
+            "owner_price_logistic_id" => $model->id,  //物流计费
+            "unit_id" => 1,                  //单位ID
+            "range" => "10-30",                    //区间
+            "province_id" => 1,              //省份ID
+            "city_id" => 1,                  //城市ID
+            "unit_price" => 32.6,               //单价
+            "delivery_fee" => 123,             //送货费
+            "initial_fee" => 500,              //起始计费
+            "initial_amount" => 6,           //起始计数
+            "rate" =>  0,                       //费率
+        ]);//7.5
+        $this->data["details"][] = $detail->toArray();
+        $result = $this->service->matching(20,$owner->id,$logistic->id,1,1,1);
+        $this->assertEquals(782.5,$result);
+        $result = $this->service->matching(31,$owner->id,$logistic->id,1,1,1);
+        $this->assertEquals(-1,$result);
+    }
+
+    public function tearDown(): void
+    {
+        Unit::destroy(array_column($this->data["units"],"id"));
+        foreach ($this->data["models"] as $model){
+            /** @var OwnerPriceLogistic $item */
+            $item = OwnerPriceLogistic::query()->find($model["id"]);
+            $item->owners()->sync([]);
+            $item->logistics()->sync([]);
+        }
+        OwnerPriceLogistic::destroy(array_column($this->data["models"],"id"));
+        OwnerPriceLogisticDetail::destroy(array_column($this->data["details"],"id"));
+        Owner::destroy(array_column($this->data["owners"],"id"));
+        Logistic::destroy(array_column($this->data["logistics"],"id"));
+        parent::tearDown();
+    }
+}

+ 169 - 0
tests/Services/OwnerPriceOperationService/OwnerPriceOperationServiceTest.php

@@ -0,0 +1,169 @@
+<?php
+
+
+namespace Tests\Services\OwnerPriceOperationService;
+
+use App\Commodity;
+use App\Owner;
+use App\OwnerInStorageRule;
+use App\OwnerOutStorageRule;
+use App\OwnerPriceOperation;
+use App\Services\FeatureService;
+use App\Services\OwnerPriceOperationService;
+use App\Unit;
+use Mockery\Mock;
+use Tests\TestCase;
+
+class OwnerPriceOperationServiceTest extends  TestCase
+{
+    /** @var OwnerPriceOperationService */
+    public $service;
+    public $data;
+
+    protected function setUp(): void
+    {
+        parent::setUp();
+        $this->service = app(OwnerPriceOperationService::class);
+
+        $this->data["units"] = [];
+        $pieces = Unit::query()->where("name","件")->first();
+        $box = Unit::query()->where("name","箱")->first();
+        $single = Unit::query()->where("name","单")->first();
+        if (!$pieces){
+            $pieces = factory(Unit::class)->create(["name"=>"件"]);
+            $this->data["units"][] = $pieces->toArray();
+        }
+        if (!$box){
+            $box = factory(Unit::class)->create(["name"=>"箱"]);
+            $this->data["units"][] = $box->toArray();
+        }
+        if (!$single){
+            $single = factory(Unit::class)->create(["name"=>"单"]);
+            $this->data["units"][] = $single->toArray();
+        }
+        $model1 = factory(OwnerPriceOperation::class)->create([
+            "operation_type"=>"入库",   //操作类型
+            "strategy"      =>"默认",         //策略
+        ]);
+        $model2 = factory(OwnerPriceOperation::class)->create([
+            "operation_type"=>"入库",   //操作类型
+            "strategy"      =>"特征",         //策略
+        ]);
+        $model3 = factory(OwnerPriceOperation::class)->create([
+            "operation_type"=>"出库",   //操作类型
+            "strategy"      =>"默认",         //策略
+        ]);
+        $model4 = factory(OwnerPriceOperation::class)->create([
+            "operation_type"=>"出库",   //操作类型
+            "strategy"      =>"特征",         //策略
+        ]);
+        $this->data["models"] = [$model1->toArray(),$model2->toArray(),$model3->toArray(),$model4->toArray()];
+
+        $in1 = factory(OwnerInStorageRule::class)->create([
+            "owner_price_operation_id"  => $model1->id, //作业计费ID
+            "amount"                    => 5,                   //计量
+            "unit_id"                   => $pieces->id,//单位ID
+            "unit_price"                => 2.22,               //单价
+        ]);
+        $in2 = factory(OwnerInStorageRule::class)->create([
+            "owner_price_operation_id"  => $model2->id, //作业计费ID
+            "amount"                    => 5,                   //计量
+            "unit_id"                   => $box->id,//单位ID
+            "unit_price"                => 3.22,               //单价
+        ]);
+        $out1 = factory(OwnerOutStorageRule::class)->create([
+            "owner_price_operation_id"          => $model3->id,
+            "strategy"                          =>"起步",
+            "amount"                            =>6,
+            "unit_id"                           => $pieces->id,
+            "unit_price"                        => 2.22,
+        ]);
+        $out4 = factory(OwnerOutStorageRule::class)->create([
+            "owner_price_operation_id"          => $model3->id,
+            "strategy"                          => "默认",
+            "amount"                            => 6,
+            "unit_id"                           => $box->id,
+            "unit_price"                        => 3.22,
+        ]);
+        $out5 = factory(OwnerOutStorageRule::class)->create([
+            "owner_price_operation_id"          => $model3->id,
+            "strategy"                          =>"特征",
+            "amount"                            => 6,
+            "unit_id"                           => $single->id,
+            "unit_price"                        => 4.22,
+        ]);
+        $out6 = factory(OwnerOutStorageRule::class)->create([
+            "owner_price_operation_id"          => $model4->id,
+            "strategy"                          =>"起步",
+            "amount"                            => 6,
+            "unit_id"                           => $pieces->id,
+            "unit_price"                        => 5.1,
+        ]);
+        $out7 = factory(OwnerOutStorageRule::class)->create([
+            "owner_price_operation_id"          => $model4->id,
+            "strategy"                          => "默认",
+            "amount"                            => 6,
+            "unit_id"                           => $pieces->id,
+            "unit_price"                        => 5.2,
+        ]);
+        $out8 = factory(OwnerOutStorageRule::class)->create([
+            "owner_price_operation_id"          => $model4->id,
+            "strategy"                          =>"特征",
+            "amount"                            => 6,
+            "unit_id"                           => $box->id,
+            "unit_price"                        => 5.3,
+        ]);
+        $this->data["in"] = [$in1->toArray(),$in2->toArray()];
+        $this->data["out"] = [$out1->toArray(),$out4->toArray(),$out5->toArray(),$out6->toArray(),$out7->toArray(),$out8->toArray()];
+        $owner = factory(Owner::class)->create([
+            "user_owner_group_id" => 1,
+        ]);
+        $model1->ownerPriceOperationOwners()->sync([$owner->id]);
+        $model2->ownerPriceOperationOwners()->sync([$owner->id]);
+        $model3->ownerPriceOperationOwners()->sync([$owner->id]);
+        $model4->ownerPriceOperationOwners()->sync([$owner->id]);
+        $this->data["owners"] = [$owner->toArray()];
+        $this->data["commodities"] = [];
+        $commodity = factory(Commodity::class)->create([
+            'sku' => md5(date('Ymd').\Illuminate\Support\Str::random(3)),
+            'owner_id' => $owner->id,
+            "pack_spec" => 3
+        ]);
+        $this->data["commodities"][] = $commodity->toArray();
+    }
+
+    /**
+     * @group customer
+     */
+    public function testMatchRule()
+    {
+        $this->partialMock(FeatureService::class,function ($mock){
+            /** @var Mock $mock */
+            $mock->shouldReceive("matchFeature")->andReturn(true);
+        });
+        $result = $this->service->matchRule(55,[],[],$this->data["owners"][0]["id"],$this->data["commodities"][0]["sku"],"入库");
+        $this->assertEquals(12.88,$result);
+        $result = $this->service->matchRule(56,[],[],$this->data["owners"][0]["id"],null,"入库");
+        $this->assertEquals(26.64,$result);
+        $result = $this->service->matchRule(57,[],[],$this->data["owners"][0]["id"],$this->data["commodities"][0]["sku"],"出库");
+        $this->assertEquals(46.5,$result);
+        $result = $this->service->matchRule(58,[],[],$this->data["owners"][0]["id"],null,"出库");
+        $this->assertEquals(77.4,$result);
+    }
+
+    public function tearDown(): void
+    {
+        Unit::destroy(array_column($this->data["units"],"id"));
+        OwnerPriceOperation::destroy(array_column($this->data["models"],"id"));
+        foreach ($this->data["models"] as $d){
+            $model = new OwnerPriceOperation();
+            $model->id = $d["id"];
+            $model->ownerPriceOperationOwners()->sync([]);
+        }
+        OwnerInStorageRule::destroy(array_column($this->data["in"],"id"));
+        OwnerOutStorageRule::destroy(array_column($this->data["out"],"id"));
+        Owner::destroy(array_column($this->data["owners"],"id"));
+        Commodity::destroy(array_column($this->data["commodities"],"id"));
+        parent::tearDown();
+    }
+}

+ 72 - 0
tests/Services/OwnerStoragePriceModelService/OwnerStoragePriceModelServiceTest.php

@@ -0,0 +1,72 @@
+<?php
+
+
+namespace Tests\Services\OwnerStoragePriceModelService;
+
+use App\Owner;
+use App\OwnerReport;
+use App\OwnerStoragePriceModel;
+use App\Services\OwnerStoragePriceModelService;
+use Tests\TestCase;
+
+class OwnerStoragePriceModelServiceTest extends  TestCase
+{
+    /** @var OwnerStoragePriceModelService */
+    public $service;
+    public $data;
+
+    protected function setUp(): void
+    {
+        parent::setUp();
+        $this->service = app(OwnerStoragePriceModelService::class);
+
+        $this->data["models"] = [
+            factory(OwnerStoragePriceModel::class)->create([
+                "minimum_area" => 600,     //最低起租面积
+                "price" => 80.4,            //单价
+                "discount_type" => "按单减免",    //减免类型
+                "discount_value" => 0.1,   //减免值
+                "unit_id" => 1,          //单位ID
+            ])->toArray(),
+            factory(OwnerStoragePriceModel::class)->create([
+                "minimum_area" => 600,     //最低起租面积
+                "price" => 80.4,            //单价
+                "discount_type" => "固定减免",    //减免类型
+                "discount_value" => 3.6,   //减免值
+                "unit_id" => 1,          //单位ID
+            ])->toArray(),
+        ];
+        $this->data["owners"] = [
+            factory(Owner::class)->create(["user_owner_group_id"=>1])->toArray()
+        ];
+        $this->data["reports"] = [
+            factory(OwnerReport::class)->create([
+                "owner_id" => $this->data["owners"][0]["id"],
+                "owner_bill_report_id"  =>1,
+                "total" => 1587,
+                "counting_month" => "2020-10-10"
+            ])->toArray()
+        ];
+    }
+
+    /**
+     * @group customer
+     */
+    public function testCalculationAmount()
+    {
+        $model = OwnerStoragePriceModel::query()->find($this->data["models"][0]["id"]);
+        $result = $this->service->calculationAmount($model,548.98,$this->data["owners"][0]["id"],"2020-10-10");
+        $this->assertEquals(48081.3,$result);
+        $model = OwnerStoragePriceModel::query()->find($this->data["models"][1]["id"]);
+        $result = $this->service->calculationAmount($model,548.98,$this->data["owners"][0]["id"],"2020-10-10");
+        $this->assertEquals(48236.4,$result);
+    }
+
+    public function tearDown(): void
+    {
+        OwnerStoragePriceModel::destroy(array_column($this->data["models"],"id"));
+        Owner::destroy(array_column($this->data["owners"],"id"));
+        OwnerReport::destroy(array_column($this->data["reports"],"id"));
+        parent::tearDown();
+    }
+}

+ 0 - 17
tests/Unit/Customer/CustomerTest.php

@@ -1,17 +0,0 @@
-<?php
-
-namespace Tests\Unit\Customer;
-
-use PHPUnit\Framework\TestCase;
-
-class CustomerTest extends TestCase
-{
-    /**
-     * web访问
-     *
-     * @return void
-     */
-    public function testProjectReportIndex(){
-
-    }
-}

+ 18 - 0
tests/Unit/EchoTest.php

@@ -0,0 +1,18 @@
+<?php
+
+namespace Tests\Unit;
+
+use App\Services\CacheService;
+use Illuminate\Support\Facades\Cache;
+use Tests\TestCase;
+
+class EchoTest extends TestCase
+{
+
+
+    public function testEcho(){
+        echo "\nabc3213123\n";
+        $this->assertEquals(3,2);
+    }
+
+}

+ 0 - 0
tests/Unit/CarTypeTest.php → tests/old/CarTypeTest.php


+ 0 - 0
tests/Unit/CarrierTest.php → tests/old/CarrierTest.php


+ 0 - 0
tests/Unit/CityTest.php → tests/old/CityTest.php


+ 0 - 0
tests/Unit/ExampleTest.php → tests/old/ExampleTest.php


+ 0 - 0
tests/Unit/FULXProcessTest.php → tests/old/FULXProcessTest.php


+ 0 - 0
tests/Unit/MeasureMonitorTest.php → tests/old/MeasureMonitorTest.php


+ 0 - 0
tests/Unit/MeasuringMachineTest.php → tests/old/MeasuringMachineTest.php


+ 0 - 0
tests/Unit/PackageTest.php → tests/old/PackageTest.php


+ 0 - 0
tests/Unit/PaperBoxTest.php → tests/old/PaperBoxTest.php


+ 0 - 0
tests/Unit/ProvinceTest.php → tests/old/ProvinceTest.php


+ 0 - 0
tests/Unit/UnitTest.php → tests/old/UnitTest.php


+ 0 - 0
tests/Unit/WaybillFinancialExceptedTest.php → tests/old/WaybillFinancialExceptedTest.php


+ 0 - 0
tests/Unit/WaybillFinancialSnapshotTest.php → tests/old/WaybillFinancialSnapshotTest.php


+ 0 - 0
tests/Unit/WaybillPriceModelTest.php → tests/old/WaybillPriceModelTest.php


+ 0 - 0
tests/Unit/WaybillTest.php → tests/old/WaybillTest.php


+ 3 - 0
tests/webApi/thirdPart/haiq/storage.http

@@ -8,6 +8,9 @@
 POST http://bswas/api/thirdPart/haiq/storage/relocate
 
 ###
+POST http://bswas/api/thirdPart/haiq/pickStation/processed
+
+###