Просмотр исходного кода

Merge branch 'master' into zengjun

# Conflicts:
#	tests/Services/OracleDOCOrderHeaderService/GetWMSOrderOnStartDateTest.php
#	tests/Services/OracleDOCOrderHeaderService/GetWmsOrderOnStartDateEditTest.php
#	tests/Services/OrderService/SyncOrderTest.php
ajun 5 лет назад
Родитель
Сommit
bf1db165f1
65 измененных файлов с 976 добавлено и 177 удалено
  1. 4 9
      .gitlab-ci.yml
  2. 1 1
      app/Commodity.php
  3. 12 5
      app/Http/Controllers/CommodityController.php
  4. 4 4
      app/Http/Controllers/StoreCheckingReceiveController.php
  5. 14 6
      app/Http/Controllers/StoreController.php
  6. 4 7
      app/Http/Controllers/TestController.php
  7. 1 1
      app/Imports/StoreCheckingReceiveImport.php
  8. 0 1
      app/Imports/StoreCheckingReceiveSheets.php
  9. 6 10
      app/LaborReport.php
  10. 20 2
      app/Services/CommodityService.php
  11. 2 2
      app/Services/CustomerService.php
  12. 72 14
      app/Services/FeatureService.php
  13. 1 1
      app/UserDutyCheck.php
  14. 16 0
      database/factories/CarTypeFactory.php
  15. 16 0
      database/factories/FeatureFactory.php
  16. 1 1
      database/factories/LogisticFactory.php
  17. 21 0
      database/factories/OwnerAreaReportFactory.php
  18. 3 4
      database/factories/OwnerBillReportFactory.php
  19. 9 23
      database/factories/OwnerFeeDetailFactory.php
  20. 2 4
      database/factories/OwnerOutStorageRuleFactory.php
  21. 13 0
      database/factories/OwnerPriceDirectLogisticFactory.php
  22. 4 3
      database/factories/OwnerReportFactory.php
  23. 3 4
      database/factories/OwnerStoragePriceModelFactory.php
  24. 2 4
      database/factories/ProcessMethodFactory.php
  25. 2 4
      database/factories/ShopFactory.php
  26. 2 6
      public/t.php
  27. 25 1
      resources/views/maintenance/priceModel/operation/create.blade.php
  28. 5 0
      resources/views/maintenance/priceModel/operation/index.blade.php
  29. 5 0
      resources/views/store/checkingReceive/mission.blade.php
  30. 51 29
      resources/views/store/checkingReceive/show.blade.php
  31. 1 0
      routes/web.php
  32. 1 1
      tests/Services/CacheService/GetOrExecuteTest.php
  33. 1 1
      tests/Services/CommodityBarcodeService/InsertMany_onCommoditiesTest.php
  34. 2 2
      tests/Services/CommodityService/SyncBarcodesTest.php
  35. 69 0
      tests/Services/CustomerTest.php
  36. 136 0
      tests/Services/FeatureServiceTest.php
  37. 1 1
      tests/Services/OracleDOCOrderHeaderService/GetWMSOrderOnStartDateTest.php
  38. 2 1
      tests/Services/OracleDOCOrderHeaderService/GetWmsOrderOnStartDateEditTest.php
  39. 1 1
      tests/Services/OracleDOCOrderHeaderService/GetWmsOrderOnstartDateCreateTest.php
  40. 0 5
      tests/Services/OrderPackageCommoditiesService/RegroupOrderCommoditiesTest.php
  41. 0 1
      tests/Services/OrderPackageService/SyncOrderPackageTest.php
  42. 0 1
      tests/Services/OrderPackageService/SyncPackageByOrderHeadersTest.php
  43. 4 0
      tests/Services/OrderService/SyncOrderTest.php
  44. 77 0
      tests/Services/OwnerAreaReportServiceTest.php
  45. 65 0
      tests/Services/OwnerBillReportServiceTest.php
  46. 81 0
      tests/Services/OwnerFeeDetailServiceTest.php
  47. 117 0
      tests/Services/OwnerOutStorageRuleServiceTest.php
  48. 79 0
      tests/Services/OwnerPriceDirectLogisticServiceTest.php
  49. 0 17
      tests/Unit/Customer/CustomerTest.php
  50. 18 0
      tests/Unit/EchoTest.php
  51. 0 0
      tests/old/CarTypeTest.php
  52. 0 0
      tests/old/CarrierTest.php
  53. 0 0
      tests/old/CityTest.php
  54. 0 0
      tests/old/ExampleTest.php
  55. 0 0
      tests/old/FULXProcessTest.php
  56. 0 0
      tests/old/MeasureMonitorTest.php
  57. 0 0
      tests/old/MeasuringMachineTest.php
  58. 0 0
      tests/old/PackageTest.php
  59. 0 0
      tests/old/PaperBoxTest.php
  60. 0 0
      tests/old/ProvinceTest.php
  61. 0 0
      tests/old/UnitTest.php
  62. 0 0
      tests/old/WaybillFinancialExceptedTest.php
  63. 0 0
      tests/old/WaybillFinancialSnapshotTest.php
  64. 0 0
      tests/old/WaybillPriceModelTest.php
  65. 0 0
      tests/old/WaybillTest.php

+ 4 - 9
.gitlab-ci.yml

@@ -8,24 +8,19 @@ build_maven:
   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;

+ 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';

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

@@ -10,6 +10,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;
@@ -22,6 +23,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;
@@ -41,7 +43,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;
@@ -90,12 +91,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 = app('CommodityService')->isExist(["barcode"=>"XUNI02"]);
+        dd($a);
     }
 
     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');
     }
 
     //创建或获取进场编号

+ 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)

+ 72 - 14
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,6 +191,18 @@ 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,$ids);

+ 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',
+        'load',
+        'remark'
+    ];
+});

+ 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,    //确认账单金额

+ 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),                          //特征
     ];

+ 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 - 3
database/factories/OwnerReportFactory.php

@@ -4,10 +4,11 @@
 
 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,  //结算月盘点面积

+ 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);
+$a = '12345678.12345';
+echo substr($a, 2, 2);

+ 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/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 */

+ 69 - 0
tests/Services/CustomerTest.php

@@ -0,0 +1,69 @@
+<?php
+
+namespace Tests\Unit\Customer;
+
+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()
+        ];
+    }
+
+    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();
+    }
+    public function testGetSelection(){
+        $models = $this->service->getSelection(["id","name","company_name"]);
+        $this->assertGreaterThanOrEqual(1,count($models));
+        $this->assertArrayHasKey("company_name",$models[0]);
+    }
+    public function testPaginate(){
+        $models = $this->service->paginate(5);
+        $this->assertGreaterThanOrEqual(1,count($models));
+        $this->assertLessThanOrEqual(5,count($models));
+    }
+    public function testFind(){
+        $model = $this->service->find($this->data["models"][0]["id"]);
+        $this->assertNotNull($model);
+    }
+    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);
+    }
+    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();
+    }
+}

+ 136 - 0
tests/Services/FeatureServiceTest.php

@@ -0,0 +1,136 @@
+<?php
+
+namespace Tests\Unit\Customer;
+
+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(),
+        ];
+    }
+
+    public function testGetMapArray(){
+        $models = $this->service->getMapArray();
+        $this->assertGreaterThanOrEqual(3,count($models));
+    }
+    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"]);
+    }
+    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"]);
+    }
+    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);
+    }
+    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/GetWMSOrderOnStartDateTest.php

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

+ 2 - 1
tests/Services/OracleDOCOrderHeaderService/GetWmsOrderOnStartDateEditTest.php

@@ -1,6 +1,6 @@
 <?php
 
-namespace Tests\Services\OracleDocOrderHeaderServie\GetWmsOrderOnStartDateEditTest;
+namespace Tests\Services\OracleDOCOrderHeaderService;
 
 use App\Services\OracleDOCOrderHeaderService;
 use Carbon\Carbon;
@@ -21,6 +21,7 @@ class GetWmsOrderOnStartDateEditTest extends TestCase
 
     public function testGetWmsOrderOnStartDateEdit()
     {
+        $carbon =Carbon::now()->subHours(10);
         $carbon =Carbon::now()->subMinutes(5);
         $orderHeaders = $this->service->getWmsOrderOnStartDateEdit($carbon);
         $this->assertNotNull($orderHeaders);

+ 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;

+ 0 - 5
tests/Services/OrderPackageCommoditiesService/RegroupOrderCommoditiesTest.php

@@ -37,16 +37,11 @@ class RegroupOrderCommoditiesTest extends TestCase
         $date = '2020-06-18 18:13:50';
         $orderHeaders = $this->orderHeaderService->getWMSOrderOnStartDate($date);
         if($orderHeaders->count()==0){
-            var_dump('查询数据为空');
             return;
         }
         $order_nos = Order::all()->map(function($order){
             return $order->code;
         });
-        dd(Order::all()->map(function($order){
-            return $order->created_at;
-        }));
-
         $order_nos = data_get($orderHeaders,'*.orderno');
         $order_commodities = OrderPackageCommodities::query()->with(['commodity','package.order'])->whereHas('package',function($query)use($order_nos){
             $query->whereHas('order',function ($query)use($order_nos){

+ 0 - 1
tests/Services/OrderPackageService/SyncOrderPackageTest.php

@@ -38,7 +38,6 @@ class SyncOrderPackageTest extends TestCase
         $date = '2020-09-18 18:13:50';
         $orderHeaders = $this->orderHeaderService->getWMSOrderOnStartDate($carbon);
         if($orderHeaders->count()==0){
-            var_dump('查询数据为空');
             return;
         }
         $orders = $this->orderService->getByWmsOrders($orderHeaders);

+ 0 - 1
tests/Services/OrderPackageService/SyncPackageByOrderHeadersTest.php

@@ -37,7 +37,6 @@ class SyncPackageByOrderHeadersTest extends TestCase
         $date = '2020-09-18 18:13:50';
         $orderHeaders = $this->orderHeaderService->getWMSOrderOnStartDate($carbon);
         if ($orderHeaders->count() == 0) {
-            var_dump('查询数据为空');
             return;
         }
         $this->service->syncPackageByOrderHeaders($orderHeaders);

+ 4 - 0
tests/Services/OrderService/SyncOrderTest.php

@@ -47,6 +47,8 @@ class SyncOrderTest extends TestCase
     {
         $carbon =Carbon::now()->subHours(1);
         $date = '2020-05-18 18:13:50';
+        //   SO201112029795
+//        $orderHeader = $this->orderHeaderService->getWMSOrderOnStartDate($carbon);
         $orderHeader = OracleDOCOrderHeader::query()->selectRaw(implode(',',OracleDOCOrderHeaderService::$columns))
             ->with(['oracleBASCustomer'=>function($query){
                 $query->selectRaw('BAS_CUSTOMER.CustomerID,BAS_CUSTOMER.Customer_Type,BAS_CUSTOMER.Descr_C,BAS_CUSTOMER.Active_Flag');
@@ -61,7 +63,9 @@ class SyncOrderTest extends TestCase
 //            ->where('orderno','SO201112029795')
             ->where('DOC_Order_Header.addTime','>=',$carbon)
             ->get();
+
         $this->service->syncOrder($orderHeader);
+
         $order = $this->service->getByWmsOrders($orderHeader);
         $this->assertNotNull($order);
         $this->assertNotNull($orderHeader);

+ 77 - 0
tests/Services/OwnerAreaReportServiceTest.php

@@ -0,0 +1,77 @@
+<?php
+
+
+namespace Tests\Services;
+
+
+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();
+    }
+
+    public function testPaginate()
+    {
+        $models = $this->service->paginate(array("paginate"=>5));
+        $this->assertGreaterThanOrEqual(3,count($models));
+        $this->assertLessThanOrEqual(5,count($models));
+    }
+    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);
+    }
+    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();
+    }
+}

+ 65 - 0
tests/Services/OwnerBillReportServiceTest.php

@@ -0,0 +1,65 @@
+<?php
+
+
+namespace Tests\Services;
+
+
+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();
+    }
+
+    public function testPaginate()
+    {
+        $models = $this->service->paginate(array("paginate"=>5));
+        $this->assertGreaterThanOrEqual(3,count($models));
+        $this->assertLessThanOrEqual(5,count($models));
+    }
+    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);
+    }
+    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();
+    }
+}

+ 81 - 0
tests/Services/OwnerFeeDetailServiceTest.php

@@ -0,0 +1,81 @@
+<?php
+
+
+namespace Tests\Services;
+
+
+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();
+    }
+
+    public function testPaginate()
+    {
+        $models = $this->service->paginate(array("paginate"=>5));
+        $this->assertGreaterThanOrEqual(3,count($models));
+        $this->assertLessThanOrEqual(5,count($models));
+    }
+    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();
+    }
+}

+ 117 - 0
tests/Services/OwnerOutStorageRuleServiceTest.php

@@ -0,0 +1,117 @@
+<?php
+
+
+namespace Tests\Services;
+
+
+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();
+    }
+
+    public function testGet()
+    {
+        $models = $this->service->get(["owner_price_operation_id"=>$this->data["ownerPriceOperations"][0]["id"]]);
+        $this->assertCount(2,$models);
+    }
+    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);
+    }
+    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();
+    }
+    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);
+    }
+    public function testFind()
+    {
+        $models = $this->service->find(array_column($this->data["models"],"id"));
+        $this->assertCount(2,$models);
+    }
+    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();
+    }
+}

+ 79 - 0
tests/Services/OwnerPriceDirectLogisticServiceTest.php

@@ -0,0 +1,79 @@
+<?php
+
+
+namespace Tests\Services;
+
+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();
+    }
+
+    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);
+    }
+    public function testCreate()
+    {
+        $model = $this->service->create([
+            "name" => Uuid::uuid1(),
+            "base_km" => 3
+        ]);
+        $this->assertNotNull($model);
+        $this->data["models"][] = $model->toArray();
+    }
+    public function testDestroy()
+    {
+        $result = $this->service->destroy(array_column($this->data["models"],"id"));
+        $this->assertEquals(3,$result);
+        $this->data["models"] = [];
+    }
+    public function testFind()
+    {
+        $model = $this->service->find($this->data["models"][0]["id"]);
+        $this->assertNotNull($model);
+    }
+    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);
+    }
+    public function testUpdateDetail()
+    {
+        OwnerPriceDirectLogisticCar::query()->create([
+            "owner_price_direct_logistic_id" => $this->data["models"][0]["id"],   //直发车计费ID
+            "car_type_id",                      //车型ID
+            "base_fee",                         //起步费
+            "additional_fee",                   //续费(元/KM)
+        ]);
+    }
+
+    public function tearDown(): void
+    {
+        OwnerPriceDirectLogistic::destroy(array_column($this->data["models"],"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