Browse Source

Merge branch 'master' into Haozi

haozi 5 years ago
parent
commit
b96f2a3e64
28 changed files with 527 additions and 224 deletions
  1. 7 0
      app/Http/Controllers/CommodityController.php
  2. 4 4
      app/Http/Controllers/StoreCheckingReceiveController.php
  3. 12 6
      app/Http/Controllers/StoreController.php
  4. 3 11
      app/Http/Controllers/TestController.php
  5. 1 1
      app/Imports/StoreCheckingReceiveImport.php
  6. 0 1
      app/Imports/StoreCheckingReceiveSheets.php
  7. 18 0
      app/Services/CommodityService.php
  8. 16 0
      database/factories/CarTypeFactory.php
  9. 1 1
      database/factories/LogisticFactory.php
  10. 4 10
      database/factories/OwnerAreaReportFactory.php
  11. 3 4
      database/factories/OwnerBillReportFactory.php
  12. 9 23
      database/factories/OwnerFeeDetailFactory.php
  13. 2 4
      database/factories/OwnerOutStorageRuleFactory.php
  14. 13 0
      database/factories/OwnerPriceDirectLogisticFactory.php
  15. 3 4
      database/factories/OwnerStoragePriceModelFactory.php
  16. 2 4
      database/factories/ProcessMethodFactory.php
  17. 2 4
      database/factories/ShopFactory.php
  18. 2 6
      public/t.php
  19. 5 0
      resources/views/store/checkingReceive/mission.blade.php
  20. 51 29
      resources/views/store/checkingReceive/show.blade.php
  21. 1 0
      routes/web.php
  22. 11 14
      tests/Services/CustomerTest.php
  23. 58 68
      tests/Services/FeatureServiceTest.php
  24. 36 11
      tests/Services/OwnerAreaReportServiceTest.php
  25. 24 11
      tests/Services/OwnerBillReportServiceTest.php
  26. 43 8
      tests/Services/OwnerFeeDetailServiceTest.php
  27. 117 0
      tests/Services/OwnerOutStorageRuleServiceTest.php
  28. 79 0
      tests/Services/OwnerPriceDirectLogisticServiceTest.php

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

+ 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'=>"收货失败"]);

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

@@ -176,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 = ?");
@@ -204,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);
@@ -247,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 = microtime(true).Str::random(5);
+        $In_New_TraceID_C = $traceId;
         $In_ProductStatus = '00';
         $In_ProductStatus_Descr = '正常';
         $In_HoldRejectCode_C = 'OK';

+ 3 - 11
app/Http/Controllers/TestController.php

@@ -23,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;
@@ -90,17 +91,8 @@ class TestController extends Controller
         }
     }
     public function test4(){
-        dd(strlen(microtime(true).Str::random(5)));
-        $model1 = factory(Feature::class,2)->create([[
-            "type" => "商品名称",
-            "logic" => "包含",
-            "describe"=>"衣服",
-        ],[
-            "type" => "订单类型",
-            "logic" => "不包含",
-            "describe"=>"创建",
-        ]]);
-        dd($model1);
+        $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(),
         ];

+ 18 - 0
app/Services/CommodityService.php

@@ -313,4 +313,22 @@ Class CommodityService
             ])->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;
+    }
 }

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

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

+ 4 - 10
database/factories/OwnerAreaReportFactory.php

@@ -5,19 +5,13 @@
 use App\OwnerAreaReport;
 use Faker\Generator as Faker;
 
-$owner = \App\Owner::query()->first();
-$model = \App\OwnerStoragePriceModel::query()->first();
-$group = \App\UserOwnerGroup::query()->first();
-$factory->define(OwnerAreaReport::class, function (Faker $faker)use($owner,$model,$group) {
-    if (!$owner)$owner = \App\Owner::query()->first();
-    if (!$model)$model = \App\OwnerStoragePriceModel::query()->first();
-    if (!$group)$group = \App\UserOwnerGroup::query()->first();
+$factory->define(OwnerAreaReport::class, function (Faker $faker) {
     $status = ['编辑中','已完成',"编辑中","编辑中"];
     return [
-        "owner_id" => $owner ? $owner->id : factory(\App\Owner::class),             //货主ID
+        "owner_id" => factory(\App\Owner::class),             //货主ID
         "counting_month" => $faker->date(),       //结算月
-        "owner_storage_price_model_id" => $model ? $model->id : factory(\App\OwnerStoragePriceModel::class), //仓储计费ID
-        "user_owner_group_id" => $group ? $group->id : factory(\App\UserOwnerGroup::class),  //项目组ID
+        "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,         //平面区面积

+ 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),  //起步公里数
+    ];
+});

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

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

+ 11 - 14
tests/Services/CustomerTest.php

@@ -17,20 +17,19 @@ class CustomerTest extends TestCase
     {
         parent::setUp();
         $this->service = app(CustomerService::class);
-        $this->data = factory(Customer::class,3)->create()->toArray();
+        $this->data = [
+            "models"=>factory(Customer::class,3)->create()->toArray()
+        ];
     }
 
-    public function create(){
+    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[] = $model;
-        $this->assertEquals($model->code,$this->data["model"]["code"]);
-        $this->assertEquals($model->name,$this->data["model"]["name"]);
-        $this->assertEquals($model->company_name,$this->data["model"]["company_name"]);
+        $this->data["models"][] = $model->toArray();
     }
     public function testGetSelection(){
         $models = $this->service->getSelection(["id","name","company_name"]);
@@ -43,30 +42,28 @@ class CustomerTest extends TestCase
         $this->assertLessThanOrEqual(5,count($models));
     }
     public function testFind(){
-        $model = $this->service->find($this->data["model"]["id"]);
+        $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[0]["id"]],[
+        $row = $this->service->update(["id"=>$this->data["models"][0]["id"]],[
             "name" => $value,
         ]);
-        $this->data["model"]["name"] = $value;
+        $this->data["models"][0]["name"] = $value;
         $this->assertEquals($row,1);
     }
     public function testDestroy()
     {
-        $row = $this->service->destroy($this->data[0]["id"]);
+        $row = $this->service->destroy($this->data["models"][0]["id"]);
         $this->assertEquals($row,1);
-        $this->assertDeleted("customers", $this->data["model"]);
+        $this->assertDeleted("customers", $this->data["models"][0]);
     }
 
     public function tearDown(): void
     {
+        Customer::destroy(array_column($this->data["models"],'id'));
         parent::tearDown();
-        $ids = array_column($this->data,'id');
-        $row = Customer::destroy($ids);
-        $this->assertGreaterThan(0,$row);
     }
 }

+ 58 - 68
tests/Services/FeatureServiceTest.php

@@ -4,6 +4,8 @@ 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
@@ -17,59 +19,19 @@ class FeatureServiceTest extends TestCase
         parent::setUp();
         $this->service = app(FeatureService::class);
         $this->data = [
-            [
-                "type" => "商品名称",
-                "logic" => "包含",
-                "describe"=>"衣服",
-            ],[
-                "type" => "订单类型",
-                "logic" => "不包含",
-                "describe"=>"创建",
-            ],[
-                "type" => "承运商",
-                "logic" => "等于",
-                "describe"=>"顺丰",
-            ],[
-                "type" => "店铺类型",
-                "logic" => "不包含",
-                "describe"=>"日用品",
-            ],[
-                "type" => "商品名称",
-                "logic" => "不包含",
-                "describe"=>"鞋子",
-            ],[
-                "type" => "订单类型",
-                "logic" => "包含",
-                "describe"=>"取消",
-            ],[
-                "type" => "商品名称",
-                "logic" => "包含",
-                "describe"=>"测试",
-            ],[
-                "type" => "订单类型",
-                "logic" => "不包含",
-                "describe"=>"实际",
-            ],[
-                "type" => "店铺类型",
-                "logic" => "等于",
-                "describe"=>"测试",
-            ]
+           "models" => factory(Feature::class,3)->create()->toArray(),
         ];
     }
 
     public function testGetMapArray(){
-        factory(Feature::class,3)->create();
         $models = $this->service->getMapArray();
         $this->assertGreaterThanOrEqual(3,count($models));
     }
     public function testTranslationFeature(){
-        $model1 = factory(Feature::class)->create($this->data[0]);
-        $model2 = factory(Feature::class)->create($this->data[1]);
-        $model3 = factory(Feature::class)->create($this->data[2]);
-        $str = $model1->id."&(".$model2->id."|".$model3->id.")";
+        $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("订单类型",$result[1]["type"]);
+        $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"]);
@@ -77,34 +39,32 @@ class FeatureServiceTest extends TestCase
         $this->assertEquals("或",$result[2]["calculation"]);
     }
     public function testAnalysisFeature(){
-        $model1 = factory(Feature::class)->create($this->data[4]);
-        $model2 = factory(Feature::class)->create($this->data[5]);
-        $model3 = factory(Feature::class)->create($this->data[3]);
+        $models = $this->data["models"];
         $params = [
             [
                 "strategyGroupStartSign" => true,
                 "calculation" => "",
-                "type"=>"商品名称",
-                "logic"=>"不包含",
-                "describe"=>"鞋子",
+                "type"=>$models[0]["type"],
+                "logic"=>$models[0]["logic"],
+                "describe"=>$models[0]["describe"],
                 "strategyGroupEndSign" => false,
             ],[
                 "strategyGroupStartSign" => false,
                 "calculation" => "并且",
-                "type"=>"订单类型",
-                "logic"=>"包含",
-                "describe"=>"取消",
+                "type"=>$models[1]["type"],
+                "logic"=>$models[1]["logic"],
+                "describe"=>$models[1]["describe"],
                 "strategyGroupEndSign" => true,
             ],[
                 "strategyGroupStartSign" => false,
                 "calculation" => "或",
-                "type"=>"店铺类型",
-                "logic"=>"不包含",
-                "describe"=>"日用品",
+                "type"=>$models[2]["type"],
+                "logic"=>$models[2]["logic"],
+                "describe"=>$models[2]["describe"],
                 "strategyGroupEndSign" => false,
             ]
         ];
-        $expected = "(".$model1->id."&".$model2->id.")|".$model3->id;
+        $expected = "(".$models[0]["id"]."&".$models[1]["id"].")|".$models[2]["id"];
         $result = $this->service->analysisFeature($params);
         $this->assertIsArray($result);
         $this->assertCount(2,$result);
@@ -112,9 +72,24 @@ class FeatureServiceTest extends TestCase
         $this->assertEquals($expected,$result["feature"]);
     }
     public function testFormatFeature(){
-        $model1 = factory(Feature::class)->make($this->data[0]);
-        $model2 = factory(Feature::class)->make($this->data[1]);
-        $model3 = factory(Feature::class)->make($this->data[2]);
+        $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 = "商品名称 包含 衣服 并且 (订单类型 不包含 创建 或 承运商 等于 顺丰)";
@@ -125,22 +100,37 @@ class FeatureServiceTest extends TestCase
         $this->assertEquals($expected,$result);
     }
     public function testMatchFeature(){
-        $model1 = factory(Feature::class)->create($this->data[6]);
-        $model2 = factory(Feature::class)->create($this->data[7]);
-        $model3 = factory(Feature::class)->create($this->data[8]);
+        $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"=>"测试商品","order"=>"TEST","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"=>"测试商品","order"=>"实际","shop"=>"测试"];
+        $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 testTruncate(){
-        Feature::query()->truncate();
-        $feature = Feature::query()->get();
-        $this->assertCount(0,$feature);
+    public function tearDown(): void
+    {
+        Feature::destroy(array_column($this->data["models"],"id"));
+        parent::tearDown();
     }
 }

+ 36 - 11
tests/Services/OwnerAreaReportServiceTest.php

@@ -4,23 +4,43 @@
 namespace Tests\Services;
 
 
+use App\Owner;
 use App\OwnerAreaReport;
+use App\OwnerStoragePriceModel;
 use App\Services\OwnerAreaReportService;
-use Illuminate\Database\Eloquent\Collection;
+use App\Unit;
+use App\UserOwnerGroup;
 use Tests\TestCase;
 
 class OwnerAreaReportServiceTest extends  TestCase
 {
     /** @var OwnerAreaReportService */
     public $service;
-    /** @var Collection */
     public $data;
 
     protected function setUp(): void
     {
         parent::setUp();
         $this->service = app(OwnerAreaReportService::class);
-        $this->data = factory(OwnerAreaReport::class,3)->create();
+
+        $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()
@@ -30,23 +50,28 @@ class OwnerAreaReportServiceTest extends  TestCase
         $this->assertLessThanOrEqual(5,count($models));
     }
     public function testUpdate(){
-        $model = $this->data[0];
-        $result = $this->service->update(["id"=>$model->id],[
+        $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);
+        $area = OwnerAreaReport::query()->find($model["id"]);
         $this->assertNotNull($area);
         $this->assertEquals(1000,$area->accounting_area);
     }
     public function testGet(){
-        $ids = implode(",",array_column($this->data->toArray(),"owner_id"));
+        $ids = implode(",",array_column($this->data["models"],"owner_id"));
         $models = $this->service->get(["owner_id"=>$ids]);
         $this->assertGreaterThanOrEqual(3,count($models));
     }
-    public function testTruncate(){
-        OwnerAreaReport::query()->truncate();
-        $models = OwnerAreaReport::query()->get();
-        $this->assertCount(0,$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();
     }
 }

+ 24 - 11
tests/Services/OwnerBillReportServiceTest.php

@@ -4,23 +4,33 @@
 namespace Tests\Services;
 
 
+use App\Owner;
 use App\OwnerBillReport;
 use App\Services\OwnerBillReportService;
-use Illuminate\Database\Eloquent\Collection;
+use App\UserOwnerGroup;
 use Tests\TestCase;
 
 class OwnerBillReportServiceTest extends  TestCase
 {
     /** @var OwnerBillReportService */
     public $service;
-    /** @var Collection */
     public $data;
 
     protected function setUp(): void
     {
         parent::setUp();
         $this->service = app(OwnerBillReportService::class);
-        $this->data = factory(OwnerBillReport::class,3)->create();
+
+        $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()
@@ -30,23 +40,26 @@ class OwnerBillReportServiceTest extends  TestCase
         $this->assertLessThanOrEqual(5,count($models));
     }
     public function testUpdate(){
-        $model = $this->data[0];
-        $result = $this->service->update(["id"=>$model->id],[
+        $model = $this->data["models"][0];
+        $result = $this->service->update(["id"=>$model["id"]],[
             "difference" => 1000,
         ]);
         $this->assertEquals(1,$result);
-        $bill = OwnerBillReport::query()->find($model->id);
+        $bill = OwnerBillReport::query()->find($model["id"]);
         $this->assertNotNull($bill);
         $this->assertEquals(1000,$bill->difference);
     }
     public function testGet(){
-        $ids = implode(",",array_column($this->data->toArray(),"owner_id"));
+        $ids = implode(",",array_column($this->data["models"],"owner_id"));
         $models = $this->service->get(["owner_id"=>$ids]);
         $this->assertGreaterThanOrEqual(3,count($models));
     }
-    public function testTruncate(){
-        OwnerBillReport::query()->truncate();
-        $models = OwnerBillReport::query()->get();
-        $this->assertCount(0,$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();
     }
 }

+ 43 - 8
tests/Services/OwnerFeeDetailServiceTest.php

@@ -4,9 +4,14 @@
 namespace Tests\Services;
 
 
+use App\Logistic;
+use App\Owner;
 use App\OwnerFeeDetail;
+use App\ProcessMethod;
 use App\Services\OwnerFeeDetailService;
-use Illuminate\Database\Eloquent\Collection;
+use App\Shop;
+use App\Unit;
+use App\UserOwnerGroup;
 use Illuminate\Support\Facades\DB;
 use Tests\TestCase;
 
@@ -14,14 +19,38 @@ class OwnerFeeDetailServiceTest extends  TestCase
 {
     /** @var OwnerFeeDetailService */
     public $service;
-    /** @var Collection */
     public $data;
 
     protected function setUp(): void
     {
         parent::setUp();
         $this->service = app(OwnerFeeDetailService::class);
-        $this->data = factory(OwnerFeeDetail::class,3)->create();
+
+        $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()
@@ -32,15 +61,21 @@ class OwnerFeeDetailServiceTest extends  TestCase
     }
     public function testGetSql()
     {
-        $ids = implode(",",array_column($this->data->toArray(),"id"));
+        $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 testTruncate(){
-        OwnerFeeDetail::query()->truncate();
-        $models = OwnerFeeDetail::query()->get();
-        $this->assertCount(0,$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();
+    }
+}