Explorar o código

Merge branch 'master' into Haozi

haozi %!s(int64=5) %!d(string=hai) anos
pai
achega
5e6eed7720
Modificáronse 43 ficheiros con 842 adicións e 431 borrados
  1. 0 2
      app/Commodity.php
  2. 10 0
      app/Http/Controllers/ControlPanelController.php
  3. 262 10
      app/Http/Controllers/CustomerController.php
  4. 0 54
      app/Http/Controllers/PackageController.php
  5. 42 8
      app/Http/Controllers/TestController.php
  6. 0 1
      app/Http/Controllers/api/thirdPart/flux/SortingController.php
  7. 24 0
      app/Http/Controllers/api/thirdPart/haiq/PickStationController.php
  8. 0 15
      app/OrderPackage.php
  9. 4 3
      app/Services/CommodityService.php
  10. 50 8
      app/Services/FeatureService.php
  11. 0 1
      app/Services/LogService.php
  12. 1 0
      app/Services/LogisticService.php
  13. 6 2
      app/Services/OracleBasCustomerService.php
  14. 21 0
      app/Services/OrderCountingRecordService.php
  15. 6 2
      app/Services/OrderPackageCommoditiesService.php
  16. 5 2
      app/Services/OrderPackageService.php
  17. 6 8
      app/Services/OrderService.php
  18. 89 81
      app/Services/OwnerPriceOperationService.php
  19. 7 11
      app/Services/ShopService.php
  20. 1 2
      app/Services/WarehouseService.php
  21. 1 1
      database/migrations/2020_09_10_143926_drop_shop_unique_name_index.php
  22. 17 15
      database/migrations/2020_09_20_142656_change_order_issue.php
  23. 7 5
      database/migrations/2020_10_14_112825_add_order_issue_second_client_no.php
  24. 2 2
      public/js/app.js
  25. 194 145
      resources/views/control/panel.blade.php
  26. 1 1
      resources/views/customer/project/area.blade.php
  27. 1 1
      resources/views/customer/project/create.blade.php
  28. 2 2
      resources/views/maintenance/priceModel/operation/_addFeature.blade.php
  29. 2 1
      resources/views/maintenance/priceModel/operation/create.blade.php
  30. 8 8
      resources/views/order/index/delivering.blade.php
  31. 3 0
      routes/api/thirdPart/haiq.php
  32. 8 0
      tests/Services/FeatureService/FeatureServiceTest.php
  33. 1 1
      tests/Services/OracleDOCOrderHeaderService/GetWMSOrderOnStartDateTest.php
  34. 2 1
      tests/Services/OracleDOCOrderHeaderService/GetWmsOrderOnStartDateEditTest.php
  35. 7 2
      tests/Services/OrderCountingRecordService/DateTestTest.php
  36. 11 0
      tests/Services/OrderService/CreateOrFindOrderInfoTest.php
  37. 0 4
      tests/Services/OrderService/GetOrderByLogisticNumberTest.php
  38. 0 1
      tests/Services/OrderService/LogisticNumberFirstOrCreateOrderTest.php
  39. 0 4
      tests/Services/OrderService/SyncOrderByWMSOrderHeaderTest.php
  40. 16 14
      tests/Services/OwnerPriceOperationService/OwnerPriceOperationServiceTest.php
  41. 9 11
      tests/Services/WarehouseService/GetByWmsOrderTest.php
  42. 16 0
      tests/webApi/thirdPart/haiq/pickStation.http
  43. 0 2
      tests/webApi/thirdPart/haiq/storage.http

+ 0 - 2
app/Commodity.php

@@ -36,8 +36,6 @@ class Commodity extends Model
         return $this->owner['code']??'';
     }
 
-
-
     public function newBarcode($barcode){
         $barcodeModel = $this->barcodes()->where('code', $barcode)->first();
         if(!$barcodeModel){

+ 10 - 0
app/Http/Controllers/ControlPanelController.php

@@ -12,6 +12,16 @@ use Illuminate\Http\Request;
 
 class ControlPanelController extends Controller
 {
+
+
+    /**
+     * ControlPanelController constructor.
+     */
+    public function __construct()
+    {
+        $this->middleware('auth');
+    }
+
     public function index()
     {
         /**

+ 262 - 10
app/Http/Controllers/CustomerController.php

@@ -11,7 +11,6 @@ use Exception;
 use Illuminate\Database\Eloquent\Builder;
 use Illuminate\Http\Request;
 use Illuminate\Http\Response;
-use Illuminate\Support\Facades\Auth;
 use Illuminate\Support\Facades\DB;
 use Illuminate\Support\Facades\Gate;
 use Illuminate\Support\Facades\Http;
@@ -142,31 +141,284 @@ class CustomerController extends Controller
             "Content-type"=>"application/octet-stream",
             "Content-Disposition"=>"attachment; filename=客户报表-".date('ymdHis').'.xlsx',
         ]);
-        $customers = $service->get(Auth::user(),['customer_id'=>true],['customer']);
-        return response()->view('customer.project.index');
     }
 
     public function projectCreate()
     {
         if(!Gate::allows('客户管理-项目-录入')){ return redirect('denied');  }
-        return response()->view('customer.project.create');
+        $customers = app('CustomerService')->getSelection();
+        $ownerGroups = app('UserOwnerGroupService')->getSelection();
+        $storagePriceModels = app('OwnerStoragePriceModelService')->getSelection(["id","counting_type","using_type","minimum_area","price","unit_id"],["unit"=>function($query){$query->select("id","name");}]);
+        $owner = null;
+        return response()->view('customer.project.create',compact("customers","ownerGroups","storagePriceModels","owner"));
     }
 
-    public function projectArea()
+    public function seekOwner(Request $request)
+    {
+        $params = $request->input();
+        $params["customer_id"] = true;
+        $owner = app('OwnerService')->first($params,["customer_id"=>"null"]);
+        if ($owner)return ["success"=>true,"data"=>$owner];
+        else return ["success"=>false];
+    }
+
+    public function projectStore(Request $request)
+    {
+        if(!Gate::allows('客户管理-项目-录入')){ return redirect('denied');  }
+        $this->validator($request->input())->validate();
+        $params = $request->input();
+        if ($params["id"]){
+            /** @var Owner $owner */
+            $owner = app('OwnerService')->find($params["id"]);
+            app('OwnerService')->update($owner,[
+                "customer_id"           => $params["customer_id"],
+                "tax_rate"              => $params["tax_rate"],
+                "contract_number"       => $params["contract_number"],
+                "salesman"              => $params["salesman"],
+                "linkman"               => $params["linkman"],
+                "phone_number"          => $params["phone_number"],
+                "user_owner_group_id"   => $params["owner_group_id"],
+                "waring_line_on"        => $params["waring_line_on"],
+                "description"           => $params["description"],
+            ],[
+                "ownerStoragePriceModels" => explode(',',$params["owner_storage_price_model_id"])
+            ]);
+            $msg = "成功更新“".$owner->name."”的信息!";
+        }else{
+            $owner = app('OwnerService')->create([
+                "name"                  => $params["name"],
+                "code"                  => $params["code"],
+                "customer_id"           => $params["customer_id"],
+                "tax_rate"              => $params["tax_rate"],
+                "contract_number"       => $params["contract_number"],
+                "salesman"              => $params["salesman"],
+                "linkman"               => $params["linkman"],
+                "phone_number"          => $params["phone_number"],
+                "user_owner_group_id"   => $params["owner_group_id"],
+                "waring_line_on"        => $params["waring_line_on"],
+                "description"           => $params["description"],
+            ],[
+                "ownerStoragePriceModels" => explode(',',$params["owner_storage_price_model_id"])
+            ]);
+            $msg = "成功创建“".$owner->name."”项目!";
+        }
+        return response()->redirectTo('customer/project/index')->with('successTip',$msg);
+    }
+
+    //获取货主下所有相关计费模型
+    public function getOwnerPriceModel(Request $request)
+    {
+        $owner = new Owner();
+        $owner->id = $request->id;
+        $owner->load(["ownerPriceOperations","ownerPriceExpresses","ownerPriceLogistics","ownerPriceDirectLogistics"]);
+        return ["success"=>true,"data"=>["ownerPriceOperations"=>$owner->ownerPriceOperations,
+            "ownerPriceExpresses"=>$owner->ownerPriceExpresses,
+            "ownerPriceLogistics"=>$owner->ownerPriceLogistics,
+            "ownerPriceDirectLogistics"=>$owner->ownerPriceDirectLogistics]];
+    }
+
+    public function projectEdit($id)
+    {
+        if(!Gate::allows('客户管理-项目-编辑')){ return redirect('denied');  }
+        /** @var Owner $owner */
+        $owner = app('OwnerService')->find($id);
+        $owner->owner_storage_price_model_id = $owner->getOwnerStoragePriceModelIds();
+        $customers = app('CustomerService')->getSelection();
+        $ownerGroups = app('UserOwnerGroupService')->getSelection();
+        $storagePriceModels = app('OwnerStoragePriceModelService')->getSelection(["id","counting_type","using_type","minimum_area","price","unit_id"],["unit"=>function($query){$query->select("id","name");}]);
+        return response()->view('customer.project.create',compact("customers","ownerGroups","storagePriceModels",'owner'));
+    }
+
+    public function projectArea(Request $request)
     {
         if(!Gate::allows('客户管理-项目-面积')){ return redirect('denied');  }
-        return response()->view('customer.project.area');
+        $areas = app('OwnerAreaReportService')->paginate($request->input(),["owner"=>function($query){$query->with(["customer","ownerStoragePriceModels"]);}]);
+        $ownerGroups = app('UserOwnerGroupService')->getSelection();
+        $customers = app('CustomerService')->getSelection();
+        $owners = app('OwnerService')->getSelection();
+        $params = $request->input();
+        return response()->view('customer.project.area',compact("areas","ownerGroups","customers","owners","params"));
     }
 
-    public function financeInstantBill()
+    public function updateArea(Request $request)
+    {
+        if(!Gate::allows('客户管理-项目-面积-编辑')){ return ["success"=>false,'data'=>"无权操作!"];  }
+        if (!($request->id ?? false) || !($request->area ?? false)) return ["success"=>false,'data'=>"传递错误!"];
+        $values = $request->area ?? null;
+        if (!$values)return ["success"=>true,"data"=>$values];
+        foreach ($values as $column=>$value){
+            if ($value && (!is_numeric($value) || $value<0))return ["success"=>false,'data'=>$column."非数字或小于0!"];
+        }
+        $accounting_area = ((int)$values["area_on_tray"]*205) + ((int)$values["area_on_half_tray"]*1.8) + ((int)$values["area_on_flat"]*1.3);
+        $values["accounting_area"] = $accounting_area;
+        if (app('OwnerAreaReportService')->update(["id"=>$request->id],$values))
+            return ["success"=>true,"data"=>$values];
+        return ["success"=>false,"data"=>"未知错误!"];
+    }
+
+    public function projectAreaExport(Request $request)
+    {
+        if(!Gate::allows('客户管理-项目-面积')){ return redirect('denied');  }
+        $params = $request->input();
+        if ($request->checkAllSign)unset($params['checkAllSign']);
+        else $params = ["id"=>$request->data];
+        /** @var OwnerAreaReportService $serves */
+        $serves = app('OwnerAreaReportService');
+        $areas = $serves->get($params,["owner"=>function($query){$query->with(["customer","ownerStoragePriceModels","userOwnerGroup"]);}]);
+
+        $column = ["状态","项目组","客户","子项目","结算月","录入时间","用仓类型","货物整托","货物半托","平面区面积","结算面积"];
+        $list = [];
+        foreach ($areas as $area){
+            $list[] = [
+                $area->status,
+                $area->owner ? ($area->owner->userOwnerGroup ? $area->owner->userOwnerGroup->name : '') : '',
+                $area->owner ? ($area->owner->customer ? $area->owner->customer->name : '') : '',
+                $area->owner ? $area->owner->name : '',
+                $area->counting_month,
+                $area->updated_at,
+                $area->owner ? implode(",",array_unique(array_column(($area->owner->ownerStoragePriceModels)->toArray(),"using_type"))) : '',
+                $area->area_on_tray,
+                $area->area_on_half_tray,
+                $area->area_on_flat,
+                $area->accounting_area,
+            ];
+        }
+
+        $post = Http::post(config('go.export.url'),['type'=>'base','data'=>json_encode(["row"=>$column,"list"=>$list],JSON_UNESCAPED_UNICODE)]);
+        if ($post->status() == 500){
+            throw new Exception($post->header("Msg"));
+        }
+        return response($post,200, [
+            "Content-type"=>"application/octet-stream",
+            "Content-Disposition"=>"attachment; filename=项目面积报表-".date('ymdHis').'.xlsx',
+        ]);
+    }
+
+    public function financeInstantBill(Request $request)
     {
         if(!Gate::allows('客户管理-财务-即时账单')){ return redirect('denied');  }
-        return response()->view('customer.finance.instantBill');
+        $params = $request->input();
+        $shops = app('ShopService')->getSelection();
+        $customers = app('CustomerService')->getSelection();
+        $owners = app('OwnerService')->getSelection();
+        $details = app('OwnerFeeDetailService')->paginate($params,["owner"=>function($query){$query->with("customer");},"shop","processMethod","logistic"]);
+        return response()->view('customer.finance.instantBill',compact("details","params","shops","customers","owners"));
     }
 
-    public function financeBillConfirmation()
+    public function financeInstantBillExport(Request $request)
+    {
+        if(!Gate::allows('客户管理-财务-即时账单')){ return redirect('denied');  }
+        $params = $request->input();
+        if ($request->checkAllSign)unset($params['checkAllSign']);
+        else $params = ["id"=>$request->data];
+        $sql = app('OwnerFeeDetailService')->getSql($params);
+
+        $row = ["客户", "项目", "作业时间", "类型","店铺", "单号(发/收/退/提)", "收件人", "收件人电话", "商品数量",
+            "物流/快递单号", "体积", "重量", "承运商", "操作费", "物流费", "合计"];
+        $column = ["customer_name", "owner_name", "worked_at", "type","shop_name", "operation_bill", "consignee_name", "consignee_phone", "commodity_amount",
+            "logistic_bill", "volume", "weight", "logistic_name", "work_fee", "logistic_fee", "total"];
+        $rule = ["work_fee"=>"mysqlDate"];
+
+        $post = Http::post(config('go.export.url'),['type'=>'unify','sql'=>$sql, 'connection'=>'mysql',
+            'row'=>json_encode($row,JSON_UNESCAPED_UNICODE), 'column'=>json_encode($column), 'rule'=>json_encode($rule)]);
+        if ($post->status() == 500){
+            throw new Exception($post->header("Msg"));
+        }
+        return response($post,200, [
+            "Content-type"=>"application/octet-stream",
+            "Content-Disposition"=>"attachment; filename=即时账单记录-".date('ymdHis').'.xlsx',
+        ]);
+    }
+
+    public function financeBillConfirmation(Request $request)
+    {
+        if(!Gate::allows('客户管理-财务-账单确认')){ return redirect('denied');  }
+        $params = $request->input();
+        $ownerGroups = app('UserOwnerGroupService')->getSelection();
+        $customers = app('CustomerService')->getSelection();
+        $owners = app('OwnerService')->getSelection();
+        $bills = app('OwnerBillReportService')->paginate($params,["owner"=>function($query){
+            /** @var Builder $query */
+            $query->with(["customer","userOwnerGroup"]);
+        }]);
+        return response()->view('customer.finance.billConfirmation',compact("params","owners","ownerGroups","customers","bills"));
+    }
+
+    public function financeBillConfirmationExport(Request $request)
     {
         if(!Gate::allows('客户管理-财务-账单确认')){ return redirect('denied');  }
-        return response()->view('customer.finance.billConfirmation');
+        $params = $request->input();
+        if ($request->checkAllSign)unset($params['checkAllSign']);
+        else $params = ["id"=>$request->data];
+        /** @var OwnerBillReportService $serves */
+        $serves = app('OwnerBillReportService');
+        $bills = $serves->get($params,["owner"=>function($query){
+            /** @var Builder $query */
+            $query->with(["customer","userOwnerGroup"]);
+        }]);
+
+        $column = ["项目小组","客户","子项目","结算月","录入日期","原始账单金额","确认账单金额","差额","状态"];
+        $list = [];
+        foreach ($bills as $bill){
+            $list[] = [
+                $bill->owner ? ($bill->owner->userOwnerGroup ? $bill->owner->userOwnerGroup->name : '') : '',
+                $bill->owner ? ($bill->owner->customer ? $bill->owner->customer->name : '') : '',
+                $bill->owner ? $bill->owner->name : '',
+                $bill->counting_month,
+                $bill->updated_at,
+                $bill->initial_fee,
+                $bill->confirm_fee,
+                $bill->difference,
+                $bill->confirmed == '是' ? '已确认' : '未确认',
+            ];
+        }
+
+        $post = Http::post(config('go.export.url'),['type'=>'base','data'=>json_encode(["row"=>$column,"list"=>$list],JSON_UNESCAPED_UNICODE)]);
+        if ($post->status() == 500){
+            throw new Exception($post->header("Msg"));
+        }
+        return response($post,200, [
+            "Content-type"=>"application/octet-stream",
+            "Content-Disposition"=>"attachment; filename=客户账单报表-".date('ymdHis').'.xlsx',
+        ]);
+    }
+
+    public function updateBillReport(Request $request)
+    {
+        if(!Gate::allows('客户管理-财务-账单确认-编辑')){ return ["success"=>false,'data'=>"无权操作!"];  }
+        if (!$request->confirm_fee || !is_numeric($request->confirm_fee) || $request->confirm_fee<0)return ["success"=>false,"data"=>"非法金额参数"];
+        $date = date('Y-m-d H:i:s');
+        app('OwnerBillReportService')->update(["id"=>$request->id],["confirm_fee"=>$request->confirm_fee,"difference"=>DB::raw($request->confirm_fee.'- initial_fee'),"updated_at"=>$date]);
+        return ["success"=>true,"data"=>$date];
+    }
+
+    public function billConfirm(Request $request)
+    {
+        if(!Gate::allows('客户管理-财务-账单确认-完结')){ return ["success"=>false,'data'=>"无权操作!"];  }
+        if (!($request->id ?? false))return["success"=>false,"data"=>"非法参数"];
+        app('OwnerBillReportService')->update(["id"=>$request->id],["confirmed"=>"是"]);
+        return ["success"=>true];
+    }
+
+    private function validator(array $params){
+        $id = $params['id'] ?? null;
+        $validator=Validator::make($params,[
+            'id' => ['required_without_all:code,name'],
+            'code'=>['required','max:50',$id ? "unique:owners,code,$id":'unique:owners,code'],
+            'name'=>['required','max:50'],
+            'customer_id'=>['required'],
+            'owner_group_id'=>['required'],
+            'tax_rate' => ['required','numeric'],
+        ],[
+            'required'=>':attribute 为必填项',
+            'unique'=>':attribute 已存在',
+        ],[
+            'code'=>'项目代码',
+            'name'=>'项目名称',
+            'customer_id'=>'客户',
+            'owner_group_id'=>'工作组',
+            'tax_rate' => '税率'
+        ]);
+        return $validator;
     }
 }

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

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

+ 42 - 8
app/Http/Controllers/TestController.php

@@ -44,6 +44,7 @@ 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;
@@ -52,6 +53,7 @@ use Illuminate\Support\Facades\Auth;
 use Illuminate\Support\Facades\Cache;
 use Illuminate\Http\Request;
 use Illuminate\Support\Facades\DB;
+use Illuminate\Support\Facades\Redis;
 use Illuminate\Support\Str;
 use Maatwebsite\Excel\Facades\Excel;
 use Ramsey\Collection\Collection;
@@ -92,8 +94,12 @@ class TestController extends Controller
         }
     }
     public function test4(){
-        $a = new FeatureService();
-        dd($a->matchFeature("1&2&3",[],[]));
+        $units = Unit::get();
+        //dd($units);
+        foreach ($units as $index => $unit){
+            if ($index!=1)unset($units[$index]);
+        }
+        dd($units);
     }
 
     public function updateLaborRemark(){
@@ -955,10 +961,14 @@ where (commodities.owner_id,commodity_barcodes.code) in (select commodities.owne
         app(StoreService::class)->syncWmsAsnData($startDate);
     }
 
-    public function chageOrder()
+    public function changeOrder()
     {
+        /**
+         * @var OrderService $orderService
+         */
         $carbon =Carbon::now()->subMinutes(30);
-        $orderHeader = OracleDOCOrderHeader::query()->selectRaw(implode(',',OracleDOCOrderHeaderService::$columns))
+        var_dump('$orderHeader',new Carbon());
+        $orderHeader_start = 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');
             },'oracleDOCOrderDetails'=>function($query){
@@ -969,14 +979,15 @@ where (commodities.owner_id,commodity_barcodes.code) in (select commodities.owne
                 $query->selectRaw('BAS_Codes.CodeID,BAS_Codes.CodeName_C,BAS_Codes.Code');
             }])
             ->where('DOC_Order_Header.addTime','>=',$carbon)
-//            ->where('orderno','SO201112029795')
+//            ->where('DOC_Order_Header.editTime','>=',$carbon)
             ->get();
-        var_dump($orderHeader->count());
         var_dump((string)Carbon::now());
-        /** @var OrderService $orderService */
+
         $orderService = app('OrderService');
-        $orderService->syncOrder($orderHeader);
+        $orderService->syncOrder($orderHeader_start);
+//      $orderService->syncOrder($orderHeader_edit);
         var_dump((string)Carbon::now());
+//      orderService  getCreateOrderModelsByWMSOrderHeaders
     }
 
     public function testOrderPackages(){
@@ -1120,4 +1131,27 @@ where (commodities.owner_id,commodity_barcodes.code) in (select commodities.owne
 //        app('LogService')->log(__METHOD__,__FUNCTION__,json_encode(['$orderIds'=>$orderIds,'$orderPackages'=>$orderPackages,'$orderPackageIds'=>$orderPackageIds,'$orderTrackingIds'=>$orderTrackingIds,]));
 //
 //    }
+
+    public function testSyncOrder()
+     {
+        $carbon =Carbon::now()->subHours(1);
+        $date = '2020-05-18 18:13:50';
+        $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');
+            },'oracleDOCOrderDetails'=>function($query){
+                $query->selectRaw('doc_order_details.orderNo,doc_order_details.customerid,doc_order_details.sku,doc_order_details.QtyOrdered');
+            }, 'actAllocationDetails'=>function($query){
+                $query->selectRaw('ACT_Allocation_Details.AllocationDetailsID,ACT_Allocation_Details.OrderNo,ACT_Allocation_Details.Qty_Each,ACT_Allocation_Details.PickToTraceID,ACT_Allocation_Details.CustomerID,ACT_Allocation_Details.Sku');
+            },'oracleBASCode'=>function($query){
+                $query->selectRaw('BAS_Codes.CodeID,BAS_Codes.CodeName_C,BAS_Codes.Code');
+            }])
+//            ->where('DOC_Order_Header.addTime','>=',$startDate)
+//            ->where('orderno','SO201112029795')
+            ->where('DOC_Order_Header.addTime','>=',$carbon)
+            ->get();
+        /** @var OrderService $service */
+        $service = app('OrderService');
+        $service->syncOrder($orderHeader);
+    }
 }

+ 0 - 1
app/Http/Controllers/api/thirdPart/flux/SortingController.php

@@ -187,7 +187,6 @@ class SortingController extends Controller
         return true;
     }
 
-
     public function informBatchFinished(Batch $batch){
         $sendingData=['request'=>[]];
         $batch->orders()->each(function (Order $order)use($batch,&$sendingData){

+ 24 - 0
app/Http/Controllers/api/thirdPart/haiq/PickStationController.php

@@ -0,0 +1,24 @@
+<?php
+
+
+namespace App\Http\Controllers\api\thirdPart\haiq;
+
+
+
+
+use Illuminate\Http\Request;
+
+class PickStationController
+{
+    protected $request;
+
+    public function __construct()
+    {
+    }
+
+    public function processed(Request $request){
+        $success = $request->input('success');
+        $code= $success?200:0;
+        return ['code'=>$code,'errMsg'=>'','data'=>$request->all()];
+    }
+}

+ 0 - 15
app/OrderPackage.php

@@ -96,7 +96,6 @@ class OrderPackage extends Model
         $this['batch_number'] = $this->oracleInfo['waveno']??null;
     }
     static public function createPackagesFromBatchCode($batchCode,$weight){
-        $start_at = microtime(true);
 
 
 
@@ -109,11 +108,6 @@ class OrderPackage extends Model
         $packages = [];
         $now = Carbon::now();
 
-
-        $time1 = floor((microtime(true)-$start_at));
-        app('LogService')->log(__METHOD__,'timemark_'.__FUNCTION__,"{$batchCode} 3.1:$time1");
-        $start_at = microtime(true);
-
         foreach($resultOracleObjs_grouped as $resultOracleObj_grouped){
             $resultOracleObj = $resultOracleObj_grouped[0];
             /** @var OrderService $orderService*/
@@ -135,11 +129,6 @@ class OrderPackage extends Model
         }
 
 
-        $time1 = floor((microtime(true)-$start_at));
-        app('LogService')->log(__METHOD__,'timemark_'.__FUNCTION__,"{$batchCode} 3.2:$time1");
-        $start_at = microtime(true);
-
-
         $packagesLogisticNumbers = array_map(function ($orderPackage) {
             return $orderPackage['logistic_number'];
         } ,$packages);
@@ -162,10 +151,6 @@ class OrderPackage extends Model
         });
 
 
-        $time1 = floor((microtime(true)-$start_at));
-        app('LogService')->log(__METHOD__,'timemark_'.__FUNCTION__,"{$batchCode} 3.3:$time1");
-        $start_at = microtime(true);
-
         app('LogService')->log(__METHOD__,"批量录入包裹成功",json_encode($packages),Auth::user()['id']);
     }
     public function unifyThisMeasureUnderSameBatch(){

+ 4 - 3
app/Services/CommodityService.php

@@ -177,15 +177,17 @@ Class CommodityService
     {
         if(!$params) return [];
         $bas_sku_arr = OracleBasSKU::query()
+            ->selectRaw('customerid,sku,descr_c,skulength,skuwidth,skuhigh,cube')
             ->whereIn('CustomerID',data_get($params,'*.owner_code'))
             ->whereIn('Sku',data_get($params,'*.sku'))
             ->get();
         $insert_params = [];
-
+        $created_at = Carbon::now()->format('Y-m-d H:i:s');
         foreach ($bas_sku_arr as $bas_sku) {
             $owner = $owners_code_map[$bas_sku->customerid] ?? '';
             if(!$owner)continue;
-            $created_at = Carbon::now()->format('Y-m-d H:i:s');
+            if($bas_sku->sku==null)continue;
+            if($bas_sku->descr_c=='')continue;
             $insert_params[] = [
                 'owner_id' => $owner->id,
                 'sku' => $bas_sku->sku,
@@ -197,7 +199,6 @@ Class CommodityService
                 'volumn' => $bas_sku->cube
             ];
         }
-
         if(count($insert_params) > 0){
             try {
                 $this->insert($insert_params);

+ 50 - 8
app/Services/FeatureService.php

@@ -196,31 +196,43 @@ Class FeatureService
      *      $vale : 特征简述 例: "1&2|(3|4)"
      *      $columnMapping : 列映射 例:["商品名称"=>"commodity_name"]
      *      $matchObject : 被匹配对象,必须存在列映射所指定字段 例:["commodity_name"=>"衣服"]
+     *      $isMultiMatching 是否开启多重匹配 开启将匹配对象视为二维数组深层寻找商品(入库需要)
      *      bool true匹配成功 false匹配失败
      *
      * @param string $value
      * @param array $columnMapping
      * @param array $matchObject
+     * @param bool $isMultiMatching
      * @return bool
      */
-    public function matchFeature($value, $columnMapping, $matchObject) :bool
+    public function matchFeature($value, $columnMapping, $matchObject, $isMultiMatching = false) :bool
     {
         preg_match_all('/\d+|[\&\|\(\)]/',$value,$result);
         if (implode("",$result[0]) != $value)return false;
 
-        preg_match_all('/\d+/',$value,$ids);
-        if ($ids[0])$fs = Feature::query()->whereIn("id",$ids[0])->get();
-        else return false;
-        $features = [];
-        foreach ($fs as $f){
-            $features[$f->id] = $f;
-        }
+        $features = app(CacheService::class)->getOrExecute($value,function ()use($value){
+            preg_match_all('/\d+/',$value,$ids);
+            if ($ids[0])$fs = Feature::query()->whereIn("id",$ids[0])->get();
+            else return false;
+            $features = [];
+            foreach ($fs as $f){
+                $features[$f->id] = $f;
+            }
+            return $features;
+        });
+
 
         foreach ($result[0] as &$str) {
             if (is_numeric($str) && isset($features[$str])) {
                 $column = $features[$str]["type"];
                 $logic = $features[$str]["logic"];
                 $describe = $features[$str]["describe"];
+                if ($column == '商品名称' && $isMultiMatching){
+                    $packageColumn = $columnMapping["packages"] ?? "packages";
+                    $packages = $matchObject[$packageColumn] ?? [];
+                    $str = $this->multiMatching($packages,$logic,$describe,$columnMapping[$column] ?? '');
+                    continue;
+                }
                 $value = isset($columnMapping[$column]) ? $matchObject[$columnMapping[$column]] : '';
                 switch ($logic) {
                     case "包含":
@@ -247,4 +259,34 @@ Class FeatureService
         return eval("return $is;");
     }
 
+    /**
+     * 多重子项匹配
+     *
+     * @param array $packages
+     * @param string $logic
+     * @param string $describe
+     * @param string $column
+     * @return string           //"true" || "false"
+     */
+    private function multiMatching($packages, $logic, $describe, $column):string
+    {
+        if(!$column)return 'false';
+
+        foreach ($packages as $package){
+            $value = $package[$column] ?? '';
+            switch ($logic) {
+                case "包含":
+                    if (mb_strpos($value,$describe)!==false)return 'true';
+                    break;
+                case "不包含":
+                    if (mb_strpos($value,$describe) === false)return 'true';
+                    break;
+                case "等于":
+                    if ($value == $describe)return 'true';
+                    break;
+            }
+        }
+        return "false";
+    }
+
 }

+ 0 - 1
app/Services/LogService.php

@@ -7,7 +7,6 @@ namespace App\Services;
 use App\Log;
 use Exception;
 use Illuminate\Support\Facades\Redis;
-use Illuminate\Support\Facades\Request;
 
 class LogService
 {

+ 1 - 0
app/Services/LogisticService.php

@@ -46,6 +46,7 @@ Class LogisticService
     public function createLogisticByCarrierIds($codes){
         if(!$codes){return [];}
         $baseCustomers = OracleBasCustomer::query()
+            ->selectRaw('Customer_Type,CustomerID,Descr_C')
             ->where('Customer_Type','CA')
             ->whereIn('CustomerID',$codes)
             ->get();

+ 6 - 2
app/Services/OracleBasCustomerService.php

@@ -14,9 +14,13 @@ Class OracleBasCustomerService
     public function getWareHouse($customerIDs = null)
     {
         if(!$customerIDs){
-            return OracleBasCustomer::query()->where('Customer_Type','WH')->get();
+            return OracleBasCustomer::query()->selectRaw('Customer_Type,CustomerId,Descr_C')->where('Customer_Type','WH')->get();
         }
-        return  OracleBasCustomer::query()->where('Customer_Type','WH')->get();
+        return  OracleBasCustomer::query()
+            ->selectRaw('Customer_Type,CustomerId,Descr_C')
+            ->where('Customer_Type','WH')
+            ->whereIn('CustomerId',$customerIDs)
+            ->get();
     }
     public function getCustomers($codes)
     {

+ 21 - 0
app/Services/OrderCountingRecordService.php

@@ -228,6 +228,27 @@ class OrderCountingRecordService
                 break;
         }
         $result = collect();
+
+        foreach ($targetOwnerIdsUnderDates as $dateStr => $ownerIds) {
+            if ($dateStr != Carbon::now()->format('Y-m-d')
+                || $dateStr != Carbon::now()->year . '-' . Carbon::now()->week
+                ||$dateStr != Carbon::now()->year . '-' . Carbon::now()->month)
+            {
+                foreach ($ownerIds as $ownerId) {
+                    if ($resultOrders->where('date_target', $dateStr)->where('owner_id', $ownerId)->count()==0) {
+                        $result->push([
+                            'owner_id' =>$ownerId,
+                            'shop_id' => null,
+                            'warehouse_id' => null,
+                            'logistic_id' => null,
+                            'date_target' => $dateStr,
+                            'counting_unit' => $unit,
+                            'amount' => 0,
+                        ]);
+                    }
+                }
+            }
+        }
         $resultOrders->each(function ($order) use (&$result, $unit) {
             $orderCountingRecord = new OrderCountingRecord([
                 'owner_id' => $order->owner_id,

+ 6 - 2
app/Services/OrderPackageCommoditiesService.php

@@ -775,6 +775,7 @@ class OrderPackageCommoditiesService
         foreach ($inner_params as $inner_param) {
             if($inner_param['logistic_number'] === '*' || $inner_param['logistic_number'] === ' ')continue;
             $package = $dataHandlerService->getKeyValue(['logistic_number'=>$inner_param['logistic_number']],$package_map);
+            if(!$package)continue;
             $commodity = $commodity_map[' owner='.$inner_param['owner_code'].' sku='.$inner_param['sku']] ?? null;
             $create_params[] = [
                 'order_package_id'=>$package->id,
@@ -786,8 +787,11 @@ class OrderPackageCommoditiesService
         }
         if(count($create_params)>0){
             try {
-                $bool = $this->insert($create_params);
-                LogService::log(__METHOD__,__FUNCTION__,'批量添加 orderCommodity --'. $bool ." || ".count($create_params).' || '.json_encode($create_params));
+                $inner_array = array_chunk($create_params,1000);
+                foreach ($inner_array as $item) {
+                    $bool = $this->insert($item);
+                    LogService::log(__METHOD__,__FUNCTION__,'批量添加 orderCommodity --'. $bool ." || ".count($create_params).' || '.json_encode($create_params));
+                }
             } catch (\Exception $e) {
                 LogService::log(__METHOD__,__FUNCTION__.'error','批量添加 orderCommodity error'." || ".count($create_params).' || '.json_encode($create_params));
             }

+ 5 - 2
app/Services/OrderPackageService.php

@@ -439,8 +439,11 @@ class OrderPackageService
         }
         if(count($inner_params)>0){
             try {
-                $bool = $this->insert($inner_params);
-                $bool ? LogService::log(__METHOD__, __FUNCTION__, '批量添加 OrderPackage ' . count($inner_params) . ' || ' . json_encode($inner_params)) : null;
+                $inner_array = array_chunk($inner_params,1000);
+                foreach ($inner_array as $params) {
+                    $bool = $this->insert($params);
+                    $bool ? LogService::log(__METHOD__, __FUNCTION__, '批量添加 OrderPackage ' . count($inner_params) . ' || ' . json_encode($inner_params)) : null;
+                }
             } catch (\Exception $e) {
                 LogService::log(__METHOD__, __FUNCTION__, '批量添加 OrderPackage error ' . count($inner_params) . ' || ' .json_encode($e->getMessage()). json_encode($inner_params).json_encode($e->getTraceAsString()));
             }

+ 6 - 8
app/Services/OrderService.php

@@ -30,10 +30,11 @@ class OrderService
         if(count($params)==0) return true;
         try {
             $bool= Order::query()->insert($params);
-            app('LogService')->log(__METHOD__, __FUNCTION__, '批量创建 Order' . json_encode($params));
+            if($bool)app('LogService')->log(__METHOD__, __FUNCTION__, '批量创建 Order' . json_encode($params));
+            else app('LogService')->log(__METHOD__,'ERROR'. __FUNCTION__, '批量创建 Order ERROR' . json_encode($params));
             return $bool;
         } catch (\Exception $e) {
-            app('LogService')->log(__METHOD__, __FUNCTION__, '批量创建 Order error' . json_encode($params).json_encode($e->getMessage()).json_encode($e->getTraceAsString()));
+            app('LogService')->log(__METHOD__, 'ERROR'.__FUNCTION__, '批量创建 Order ERROR' . json_encode($params).json_encode($e->getMessage()).json_encode($e->getTraceAsString()));
             return false;
         }
     }
@@ -977,17 +978,14 @@ class OrderService
          */
         $orderPackageService = app('OrderPackageService');
         $orderPackageCommoditiesService = app('OrderPackageCommoditiesService');
-        $order = Order::query()->with('packages.commodities')->where('code',$orderHeader->orderno)->first();
-        if($order) return $order;
-        $create_param = $this->getParamByOrderHeader($orderHeader);
+        $orderHeaders = [$orderHeader];
         try {
-            $orderHeaders = [$orderHeader];
-            $order = Order::query()->create($create_param);
+            $this->syncOrderByWMSOrderHeaders($orderHeaders);
             $orderPackageService->syncOrderPackage($orderHeaders);
             $orderPackageCommoditiesService->syncOrderPackageCommodities($orderHeaders);
             return  Order::query()->with('packages.commodities')->where('code',$orderHeader->orderno)->first();
         } catch (\Exception $e) {
-            app('LogService')->log(__METHOD__, 'Error'.__FUNCTION__, '创建 Order Error' .' || '. json_encode($order).' || '.json_encode($e->getMessage()).' || '.json_encode($e->getTraceAsString()));
+            app('LogService')->log(__METHOD__, 'Error'.__FUNCTION__, '创建 Order Error' .' || '. json_encode($orderHeader).' || '.json_encode($e->getMessage()).' || '.json_encode($e->getTraceAsString()));
             return null;
         }
     }

+ 89 - 81
app/Services/OwnerPriceOperationService.php

@@ -97,26 +97,26 @@ Class OwnerPriceOperationService
     /** 参数顺序: 数量 匹配对象 列映射 货主ID 单位ID 类型 SKU .
      *  匹配顺序: 类型 货主 策略 单位 特征                    ..多对多匹配规则废弃,1对1,设单位必定为件,对应规则必然只有一项存在
      *  单位匹配: 件,箱,单 由小到大,依次换算匹配           .
-     * @param int $amount
+     *
+     *  2:没有总数量存在,都为子项内数量
+     *
      * @param array|object $matchObject  key-val
      * @param array $columnMapping       key-val
      * @param string $owner_id
      * @param string $type
      * @param string $sku
      * @return double
-     * 错误代码: -1:非法数量 -2:无计费模型 -3:未知单位 -4:sku为空 -5:货主未找到 -6:无箱规 -7:未匹配到计费模型
+     * 错误代码: -1:无匹配对象 -2:无计费模型 -3:未知单位 -4:sku为空 -5:货主未找到 -6:无箱规 -7:未匹配到计费模型
      */
-    public function matchRule($amount, $matchObject, $columnMapping, $owner_id, $sku = null, $type = '出库')
+    public function matchRule($matchObject, $columnMapping, $owner_id, $sku = null, $type = '出库')
     {
-        if ($amount <= 0 )return -1;
-
         $unitModels = Unit::query()->whereIn("name",["件","箱","单"])->get();
         $units = [];
         foreach ($unitModels as $unitModel)$units[$unitModel->id] = $unitModel->name;
 
         $withs = $type=='出库' ? ['ownerOutStorageRules'=>function($query){
             /** @var Builder $query */
-            $query->orderByRaw("CASE strategy  WHEN '默认' THEN 1 WHEN '特征' THEN 2 WHEN '起步' THEN 3 END DESC,priority DESC");
+            $query->orderByRaw("CASE strategy  WHEN '起步' THEN 1 WHEN '默认' THEN 2 WHEN '特征' THEN 3 END DESC,priority DESC");
         }] : ['ownerInStorageRule'] ;
         $rules = OwnerPriceOperation::query()->with($withs)
             ->where("operation_type",$type)
@@ -128,7 +128,15 @@ Class OwnerPriceOperationService
         if (!$rules)return -2;
 
         if ($type == '入库'){
-            foreach ($rules as $index => $rule){
+            $amountColumn = $columnMapping["amount"] ?? "amount";
+            $packageColumn = $columnMapping["packages"] ?? "packages";
+            $packages = $matchObject[$packageColumn] ?? false;
+            if (!$packages)return -1;
+
+            $amount = 0;
+            foreach ($packages as $package)$amount += $package[$amountColumn] ?? 0;
+            if (!$amount)return -1;
+            foreach ($rules as $rule){
                 $sum = $amount;
                 if (!$rule->ownerInStorageRule)continue;
                 if ($rule->strategy == '特征'){
@@ -137,10 +145,7 @@ Class OwnerPriceOperationService
                         if (!isset($units[$rule->ownerInStorageRule->unit_id])) return -3;
                         if ($units[$rule->ownerInStorageRule->unit_id] == '箱'){ //为箱时同步商品寻找箱规
                             $sum = $this->changeUnit($sum,$owner_id,$sku);
-                            if ($sum<0){
-                                if ($index == count($rules)-1)return $sum;
-                                continue;
-                            }
+                            if ($sum<0)return $sum;
                         }
                         if ($units[$rule->ownerInStorageRule->unit_id] == '单')$sum = 1; //为单时数量设为1;
                         return ceil($sum/$rule->ownerInStorageRule->amount)*$rule->ownerInStorageRule->unit_price;
@@ -149,10 +154,7 @@ Class OwnerPriceOperationService
                     if (!isset($units[$rule->ownerInStorageRule->unit_id])) return -3;
                     if ($units[$rule->ownerInStorageRule->unit_id] == '箱'){ //为箱时同步商品寻找箱规
                         $sum = $this->changeUnit($sum,$owner_id,$sku);
-                        if ($sum<0){
-                            if ($index == count($rules)-1)return $sum;
-                            continue;
-                        }
+                        if ($sum<0)return $sum;
                     }
                     if ($units[$rule->ownerInStorageRule->unit_id] == '单')$sum = 1; //为单时数量设为1;
                     return ceil($sum/$rule->ownerInStorageRule->amount)*$rule->ownerInStorageRule->unit_price;
@@ -166,11 +168,11 @@ Class OwnerPriceOperationService
             if ($rule->strategy == '特征'){
                 $bool = app("FeatureService")->matchFeature($rule->feature,$columnMapping,$matchObject);//匹配特征
                 if ($bool === true){
-                    $money = $this->matchOutStorage($amount,$rule->ownerOutStorageRules,$columnMapping,$matchObject,$units,$owner_id,$sku);
+                    $money = $this->matchOutStorage($rule->ownerOutStorageRules,$columnMapping,$matchObject,$units,$owner_id,$sku);
                     if ($money>0)return $money;
                 };
             }else{
-                $money = $this->matchOutStorage($amount,$rule->ownerOutStorageRules,$columnMapping,$matchObject,$units,$owner_id,$sku);
+                $money = $this->matchOutStorage($rule->ownerOutStorageRules,$columnMapping,$matchObject,$units,$owner_id,$sku);
                 if ($money>0)return $money;
             };
         }
@@ -183,87 +185,93 @@ Class OwnerPriceOperationService
         if (!$pack)return -6;
         return ceil($amount/$pack);
     }
-    private function matchOutStorage($amount, $rules, $columnMapping, $matchObject, $units, $owner_id, $sku)
+
+    private function matchOutStorage($rules, $columnMapping, $matchObject, $units, $owner_id, $sku)
     {
-        $money = 0;
-        foreach ($rules as $index => $rule){
-            $sum = $amount;
-            switch ($rule->strategy){
-                case "起步":
-                    $money = $rule->amount * $rule->unit_price;
-                    if ($units[$rule->unit_id] == '箱') { //为箱时同步商品寻找箱规
-                        if (!$sku)return -4;
-                        $pack = app("CommodityService")->getPack($owner_id,$sku);
-                        if (!$pack)return -6;
-                        $rule->amount *= $pack;
-                    }
+        $amountColumn = $columnMapping["amount"] ?? "amount";
+        $packageColumn = $columnMapping["packages"] ?? "packages";
+        $packages = $matchObject[$packageColumn] ?? false;
+        $commodityColumn = $columnMapping["商品名称"] ?? 'commodity';
+        if (!$packages)return -1;
 
-                    if ($amount < $rule->amount)$amount = $rule->amount;
-                    else $amount -= $rule->amount;
-                    break;
+        $unitName = "";
+        foreach ($rules as $rule){
+            switch ($rule->strategy){
                 case "特征":
-                    if (app("FeatureService")->matchFeature($rule->feature,$columnMapping,$matchObject)){
-                        if (!isset($units[$rule->unit_id]) || $units[$rule->unit_id] == '单') return -3;
+                    foreach ($packages as &$package){
+                        if ($package["price"] ?? false)continue;
+                        if (!app("FeatureService")->matchFeature($rule->feature,["商品名称"=>"commodity"],["commodity"=>$package[$commodityColumn] ?? ''])) continue;
+
+                        if (!$unitName)$unitName = $units[$rule->unit_id];
+                        else {
+                            if ($unitName != $units[$rule->unit_id])
+                                return -3;
+                        }
+                        $package["price"] = $rule->unit_price;
+                        if (!isset($units[$rule->unit_id]) || $units[$rule->unit_id] == '单')return -3;
                         if ($units[$rule->unit_id] == '箱'){ //为箱时同步商品寻找箱规
-                            $sum = $this->changeUnit($sum,$owner_id,$sku);
-                            if ($sum<0){
-                                if ($index == count($rules)-1)return $sum;
-                                break;
-                            }
+                            $amount = $this->changeUnit($package[$amountColumn],$owner_id,$sku);
+                            if ($amount<0)return $amount;
+                            $package[$amountColumn] = $amount;
                         }
-                        return (ceil($sum/$rule->amount)*$rule->unit_price)+$money;
-                    };
+                    }
                     break;
                 case "默认":
-                    if (!isset($units[$rule->unit_id]) || $units[$rule->unit_id] == '单') return -3;
-                    if ($units[$rule->unit_id] == '箱'){ //为箱时同步商品寻找箱规
-                        $sum = $this->changeUnit($sum,$owner_id,$sku);
-                        if ($sum<0){
-                            if ($index == count($rules)-1)return $sum;
-                            break;
+                    foreach ($packages as &$package){
+                        if ($package["price"] ?? false)continue; //校验是否已匹配到
+                        if (!$unitName)$unitName = $units[$rule->unit_id]; //校验单位是否一致
+                        else {
+                            if ($unitName != $units[$rule->unit_id])
+                                return -3;
+                        }
+
+                        $package["price"] = $rule->unit_price;
+                        if (!isset($units[$rule->unit_id]) || $units[$rule->unit_id] == '单')return -3;
+                        if ($units[$rule->unit_id] == '箱'){ //为箱时同步商品寻找箱规
+                            $amount = $this->changeUnit($package[$amountColumn],$owner_id,$sku);
+                            if ($amount<0)return $amount;
+                            $package[$amountColumn] = $amount;
                         }
                     }
-                    return (ceil($sum/$rule->amount)*$rule->unit_price)+$money;
                     break;
+                default:
+                    if ($unitName && $unitName != $units[$rule->unit_id])return -3; //校验单位是否一致
+
+                    $money = $rule->amount * $rule->unit_price;
+                    $startNumber = $rule->amount;
+                    $packages = $this->settingCount($packages,$amountColumn,$startNumber);
+                    if ($packages){
+                        foreach ($packages as $package){
+                            $money += $package[$amountColumn] * $package["price"];
+                        }
+                    }
+                    return $money;
             }
         }
         return -7;
     }
-
-    private function matchInStorage($amount, $matchObject, $columnMapping, $owner_id, $unit_id, $rules, $sku, $units = null, $isMatch = false)
+    //设置数量
+    private function settingCount($packages,$amountColumn,$startNumber)
     {
-        /*foreach ($rules as $rule){
-            if ($unit_id != $rule->ownerInStorageRule->unit_id)continue;
-            else{
-                if ($rule->strategy == '特征'){
-                    $bool = app("FeatureService")->matchFeature($rule->feature,$columnMapping,$matchObject);
-                    if ($bool === true){
-                        return ceil($amount/$rule->ownerInStorageRule->amount)*$rule->ownerInStorageRule->unit_price;
-                    };
-                }else{
-                    return ceil($amount/$rule->ownerInStorageRule->amount)*$rule->ownerInStorageRule->unit_price;
-                };
+        if (!$packages) return null;
+        $maxPrice = 0;
+        $index = null;
+        foreach ($packages as $i => $package){
+            if ($package[$amountColumn] <= 0){
+                unset($packages[$i]);continue;
+            }
+            if ($package["price"] > $maxPrice){
+                $maxPrice = $package["price"];
+                $index = $i;
             }
         }
-        //单位换算
-        if (!$units){
-            $unitModels = Unit::query()->whereIn("name",["件","箱","单"])->get();
-            if (!$unitModels) return null;
-            foreach ($unitModels as $unitModel)$units[$unitModel->name] = $unitModel->id;
+        if ($packages[$index][$amountColumn] >= $startNumber){
+            $packages[$index][$amountColumn] -= $startNumber;
+            return $packages;
+        }else{
+            unset($packages[$index]);
+            $startNumber -= $packages[$index][$amountColumn];
+            $this->settingCount($packages,$amountColumn,$startNumber);
         }
-        $name = array_search($unit_id,$units);
-        //递归匹配
-        switch ($name){
-            case "件"://布尔值校验是否匹配过件来确保箱只匹配一次件
-                return $this->matchInStorage($amount, $matchObject, $columnMapping, $owner_id, $units["箱"], $rules, $sku, $units, true);
-            case "箱"://箱存在向下向上转换
-                if ($isMatch){
-                    return $this->matchInStorage($amount, $matchObject, $columnMapping, $owner_id, $units["单"], $rules, $sku, $units);
-                }else{
-                    return $this->matchInStorage($amount, $matchObject, $columnMapping, $owner_id, $units["件"], $rules, $sku, $units);
-                }
-            case "单"://三次匹配皆无,返回null
-                return null;
-        }*/
     }
 }

+ 7 - 11
app/Services/ShopService.php

@@ -31,8 +31,8 @@ class ShopService
     }
 
     public function getByWmsOrders($orderHeaders)
-    {    //issuepartyname
-        $maps = [];
+    {
+        $maps = []; //issuepartyname
         foreach ($orderHeaders as $orderHeader) {
             $value = ['owner_code'=>$orderHeader->customerid,'issuepartyname'=>$orderHeader->issuepartyname];
             if(!in_array($value,$maps))
@@ -46,10 +46,10 @@ class ShopService
             })->whereIn('name',$issuepartynames)->get();
         if($shops->count() < count($issuepartynames)){
             $shops_code = data_get($shops,'*.name');
-            $issuepartynames = array_diff($issuepartynames,$shops_code);
+            $names = array_diff($issuepartynames,$shops_code);
             $params = [];
             foreach ($maps as $item){
-               if(in_array($item['issuepartyname'],$issuepartynames))
+               if(in_array($item['issuepartyname'],$names))
                    $params[] = $item;
             }
             $shops_list = $this->createByNameAndOwnerCode($params);
@@ -59,9 +59,7 @@ class ShopService
     }
 
     public function createByNameAndOwnerCode(array $params){
-        $owners = Owner::query()
-            ->whereIn('code',data_get($params,'*.owner_code'))
-            ->get();
+        $owners = Owner::query()->whereIn('code',data_get($params,'*.owner_code'))->get();
         $owners_map = [];
         foreach ($owners as $owner) {
             $owners_map[$owner->code] = $owner;
@@ -82,11 +80,9 @@ class ShopService
                 app('LogService')->log(__METHOD__, __FUNCTION__, '批量创建 shop ' . count($insert_params) . json_encode($insert_params));
             }
         } catch (\Exception $e) {
-            app('LogService')->log(__METHOD__, __FUNCTION__, '批量创建 shop ' . json_encode($insert_params) .'||'.$e->getMessage().'||'.$e->getTraceAsString());
+            app('LogService')->log(__METHOD__, 'Error '.__FUNCTION__, '批量创建 shop Error' . json_encode($insert_params) .'||'.$e->getMessage().'||'.$e->getTraceAsString());
         } finally {
-            return Shop::query()
-                ->whereIn('name',data_get($params,'*.issuepartyname'))
-                ->get();
+            return Shop::query()->whereIn('name',data_get($params,'*.issuepartyname'))->get();
         }
     }
 

+ 1 - 2
app/Services/WarehouseService.php

@@ -42,7 +42,7 @@ Class WarehouseService
         $oracleBasCustomers=app(OracleBasCustomerService::class)->getWareHouse($warehouse_ids);
         $warehouses=Warehouse::query()->where('code',data_get($oracleBasCustomers,'*.CustomerID'))->get();
         $oracleBasCustomers=$oracleBasCustomers->filter(function($oracleBasCustomer)use($warehouses){
-            return $warehouses->where('code',$oracleBasCustomer->warehouseid)->count()>0;
+            return $warehouses->where('code',$oracleBasCustomer->warehouseid)->count()==0;
         });
         foreach ($oracleBasCustomers as $oracleBasCustomer){
             $wereHouse=Warehouse::query()->create([
@@ -78,7 +78,6 @@ Class WarehouseService
                 'created_at' => $created_at,
             ];
         }
-
         try {
             if (count($insert_params) > 0) {
                 $this->insert($insert_params);

+ 1 - 1
database/migrations/2020_09_10_143926_drop_shop_unique_name_index.php

@@ -27,7 +27,7 @@ class DropShopUniqueNameIndex extends Migration
     public function down()
     {
         Schema::table('shops', function (Blueprint $table) {
-            $table->string('name')->unique();
+            $table->string('name')->unique('shops_name_unique');
         });
     }
 }

+ 17 - 15
database/migrations/2020_09_20_142656_change_order_issue.php

@@ -18,12 +18,13 @@ class ChangeOrderIssue extends Migration
             $table->string('logistic_number_return')->nullable()->index()->after('order_id');
         });
 
-        $orderIssues = \App\OrderIssue::query()->get();
-
-        foreach ($orderIssues as $orderIssue) {
-            $rejectedBill = $orderIssue->hasOne(RejectedBill::class, 'id', 'rejected_bill_id')->first();
-            if($rejectedBill ?? false){
-                $orderIssue->update(['logistic_number_return'=>$rejectedBill->logistic_number_return ?? null]);
+        $orderIssues = \App\OrderIssue::query()->withTrashed()->get();
+        if($orderIssues->count()>0){
+            foreach ($orderIssues as $orderIssue) {
+                $rejectedBill = $orderIssue->hasOne(RejectedBill::class, 'id', 'rejected_bill_id')->first();
+                if($rejectedBill ?? false){
+                    $orderIssue->update(['logistic_number_return'=>$rejectedBill->logistic_number_return ?? null]);
+                }
             }
         }
 
@@ -45,17 +46,18 @@ class ChangeOrderIssue extends Migration
 //            $table->integer('rejected_bill_id')->index()->nullable()->comment('退回单')->after('order_id');
 //        });
 
-        $orderIssues = \App\OrderIssue::query()->get();
-
-        foreach ($orderIssues as $orderIssue) {
-            $rejectedBill =  $orderIssue->hasOne(RejectedBill::class, 'logistic_number_return', 'logistic_number_return')->first();
-            if($rejectedBill ?? false){
-                $orderIssue->update(['rejected_bill_id'=>$rejectedBill->id ?? null]);
+        $orderIssues = \App\OrderIssue::query()->withTrashed()->get();
+        if($orderIssues->count()>0){
+            foreach ($orderIssues as $orderIssue) {
+                $rejectedBill =  $orderIssue->hasOne(RejectedBill::class, 'logistic_number_return', 'logistic_number_return')->first();
+                if($rejectedBill ?? false){
+                    $orderIssue->update(['rejected_bill_id'=>$rejectedBill->id ?? null]);
+                }
             }
         }
 
-        Schema::table('order_issues',function (Blueprint $table) {
-            $table->dropColumn('logistic_number_return');
-        });
+//        Schema::table('order_issues',function (Blueprint $table) {
+//            $table->dropColumn('logistic_number_return');
+//        });
     }
 }

+ 7 - 5
database/migrations/2020_10_14_112825_add_order_issue_second_client_no.php

@@ -18,11 +18,13 @@ class AddOrderIssueSecondClientNo extends Migration
         Schema::table('order_issues', function (Blueprint $table) {
             $table->string('second_client_no')->index()->nullable()->comment('二次客户订单号')->after('second_order_id');
         });
-        $orderIssues = \App\OrderIssue::query()->whereNotNull('second_order_id')->get();
-        foreach ($orderIssues as $orderIssue) {
-            $order = $orderIssue->hasOne('App\Order', 'id', 'second_order_id')->first();
-            if($order ?? false){
-                $orderIssue->update(['second_client_no'=>$order->client_code ?? null]);
+        $orderIssues = \App\OrderIssue::query()->withTrashed()->whereNotNull('second_order_id')->get();
+        if($orderIssues->count() > 0){
+            foreach ($orderIssues as $orderIssue) {
+                $order = $orderIssue->hasOne('App\Order', 'id', 'second_order_id')->first();
+                if($order ?? false){
+                    $orderIssue->update(['second_client_no'=>$order->client_code ?? null]);
+                }
             }
         }
     }

+ 2 - 2
public/js/app.js

@@ -86472,8 +86472,8 @@ module.exports = tempTip;
 /*! no static exports found */
 /***/ (function(module, exports, __webpack_require__) {
 
-__webpack_require__(/*! D:\wamp64\www\bswas\resources\js\app.js */"./resources/js/app.js");
-module.exports = __webpack_require__(/*! D:\wamp64\www\bswas\resources\sass\app.scss */"./resources/sass/app.scss");
+__webpack_require__(/*! D:\phpstudy_pro\WWW\bswas\resources\js\app.js */"./resources/js/app.js");
+module.exports = __webpack_require__(/*! D:\phpstudy_pro\WWW\bswas\resources\sass\app.scss */"./resources/sass/app.scss");
 
 
 /***/ }),

+ 194 - 145
resources/views/control/panel.blade.php

@@ -4,88 +4,61 @@
     <link href="{{ mix('css/element-ui.css') }}" rel="stylesheet">
 @endsection
 @section('content')
-    <div class="container-fluid" id="list">
-        <div class="card">
-            <h5 class="card-header">最近使用功能</h5>
-            <div class="card-body row">
-                <ul class="list-group" v-for="(menu,index) in menus">
-                    <div class="container-fluid btn-group justify-content-center">
-                        <a class="btn-primary btn-lg" v-if="index<=3" :href="'/'+menu.route">@{{ menu.name }}</a>
-                    </div>
-                    <div v-if="menu.secondLevelMenu && menu.secondLevelMenu.length>0&&index<=3">
-                        <div class="container-fluid btn-group m-1">
-                            <a class="bth btn-sm btn-info m-1" v-for="(secondMenu,index) in menu.secondLevelMenu"
-                               :href="'/'+secondMenu.route" v-if="index < 2"> @{{ secondMenu.name }}</a>
+    <div class="d-none" id="list">
+        <div class="container-fluid">
+            <div class="card">
+                <h5 class="card-header">最近使用功能</h5>
+                <div class="card-body row">
+                    <ul class="list-group" v-for="(menu,index) in menus">
+                        <div class="container-fluid btn-group justify-content-center">
+                            <a class="btn-primary btn-lg" v-if="index<=3" :href="'/'+menu.route">@{{ menu.name }}</a>
                         </div>
-                    </div>
-                </ul>
-            </div>
-        </div>
-        <div class="row my-3">
-            <div class="col-2">
-                <div class="card">
-                    <div class="card-header text-dark h5">
-                        <p>实时待处理订(总):@{{ totalOrders.total }}</p>
-                    </div>
-                    <div class="card-body">
-                        <p>创建订单:@{{ totalOrders.createOrder }}</p>
-                        <p>分配完成:@{{ totalOrders.assignedComplete }}</p>
-                        <p>部分分配:@{{ totalOrders.partialAllocation }}</p>
-                        <p>部分装箱:@{{ totalOrders.partPacking }}</p>
-                        <p>播种完成:@{{ totalOrders.sowComplete }}</p>
-                    </div>
+                        <div v-if="menu.secondLevelMenu && menu.secondLevelMenu.length>0&&index<=3">
+                            <div class="container-fluid btn-group m-1">
+                                <a class="bth btn-sm btn-info m-1" v-for="(secondMenu,index) in menu.secondLevelMenu"
+                                   :href="'/'+secondMenu.route" v-if="index < 2"> @{{ secondMenu.name }}</a>
+                            </div>
+                        </div>
+                    </ul>
                 </div>
             </div>
-            <div class="col-2" v-for="(warehousesOrder,index) in warehousesOrders">
-                <div class="card">
-                    <div class="card-header text-success h5">
-                        <p>@{{ getWareHouse(warehousesOrder.name) }}:@{{ warehousesOrder.total }}</p>
-                    </div>
-                    <div class="card-body">
-                        <p>创建订单:@{{ warehousesOrder.createOrder }}</p>
-                        <p>分配完成:@{{ warehousesOrder.assignedComplete }}</p>
-                        <p>部分分配:@{{ warehousesOrder.partialAllocation }}</p>
-                        <p>部分装箱:@{{ warehousesOrder.partPacking }}</p>
-                        <p>播种完成:@{{ warehousesOrder.sowComplete }}</p>
+            <div class="row my-3">
+                <div class="col-2">
+                    <div class="card">
+                        <div class="card-header text-dark h5">
+                            <p>实时待处理订(总):@{{ totalOrders.total }}</p>
+                        </div>
+                        <div class="card-body">
+                            <p>创建订单:@{{ totalOrders.createOrder }}</p>
+                            <p>分配完成:@{{ totalOrders.assignedComplete }}</p>
+                            <p>部分分配:@{{ totalOrders.partialAllocation }}</p>
+                            <p>部分装箱:@{{ totalOrders.partPacking }}</p>
+                            <p>播种完成:@{{ totalOrders.sowComplete }}</p>
+                        </div>
                     </div>
                 </div>
-            </div>
-        </div>
-        <div class="row my-3">
-            <div class="col-5">
-                <div class="card">
-                    <div class="card-header">
-                            <span class="demonstration" ></span>
-                            <el-date-picker @blur="orderCountingRecordApi('')"
-                                v-model="orderCountingRecordsDate"
-                                type="daterange"
-                                align="right"
-                                unlink-panels
-                                range-separator="-"
-                                start-placeholder="开始日期"
-                                end-placeholder="结束日期"
-                                value-format="yyyy-MM-dd"
-                                :picker-options="pickerOptions">
-                            </el-date-picker>
-                            <el-button type="primary" value="日" @click="orderCountingRecordApi('日')" v-model="orderCountingRecordsUnit">日</el-button>
-                            <el-button type="primary" value="周" @click="orderCountingRecordApi('周')" v-model="orderCountingRecordsUnit">周</el-button>
-                            <el-button type="primary" value="月" @click="orderCountingRecordApi('月')" v-model="orderCountingRecordsUnit">月</el-button>
-                    </div>
-                    <div class="card-body row">
-                        <div id="orderCountingRecords" class="col" style="width:600px;height:600px;"></div>
+                <div class="col-2" v-for="(warehousesOrder,index) in warehousesOrders">
+                    <div class="card">
+                        <div class="card-header text-success h5">
+                            <p>@{{ getWareHouse(warehousesOrder.name) }}:@{{ warehousesOrder.total }}</p>
+                        </div>
+                        <div class="card-body">
+                            <p>创建订单:@{{ warehousesOrder.createOrder }}</p>
+                            <p>分配完成:@{{ warehousesOrder.assignedComplete }}</p>
+                            <p>部分分配:@{{ warehousesOrder.partialAllocation }}</p>
+                            <p>部分装箱:@{{ warehousesOrder.partPacking }}</p>
+                            <p>播种完成:@{{ warehousesOrder.sowComplete }}</p>
+                        </div>
                     </div>
                 </div>
             </div>
-            <div class="col-7">
-                <div class="row">
-                    <div class="col-6">
-                        <div class="card">
-                            <div class="card-header">
-                                <div class="col-5 row">
-                                    <div class="block">
-                                        <span class="demonstration"></span>
-                                        <el-date-picker @blur="logisticsCountingRecordsApi()"
-                                            v-model="logisticsCountingRecordsData"
+            <div class="row my-3">
+                <div class="col-5">
+                    <div class="card">
+                        <div class="card-header">
+                            <span class="demonstration"></span>
+                            <el-date-picker @blur="orderCountingRecordApi('')"
+                                            v-model="orderCountingRecordsDate"
                                             type="daterange"
                                             align="right"
                                             unlink-panels
@@ -94,92 +67,151 @@
                                             end-placeholder="结束日期"
                                             value-format="yyyy-MM-dd"
                                             :picker-options="pickerOptions">
-                                        </el-date-picker>
+                            </el-date-picker>
+                            <el-button type="primary" value="日" @click="orderCountingRecordApi('日')"
+                                       v-model="orderCountingRecordsUnit">日
+                            </el-button>
+                            <el-button type="primary" value="周" @click="orderCountingRecordApi('周')"
+                                       v-model="orderCountingRecordsUnit">周
+                            </el-button>
+                            <el-button type="primary" value="月" @click="orderCountingRecordApi('月')"
+                                       v-model="orderCountingRecordsUnit">月
+                            </el-button>
+                        </div>
+                        <div class="card-body row">
+                            <div v-show="orderCountingRecordsShow" id="orderCountingRecords" class="col"
+                                 style="width:600px;height:600px;"></div>
+                        </div>
+                        <div v-show="!orderCountingRecordsShow" class="text-center">
+                            <h3>正在加载...</h3>
+                        </div>
+                    </div>
+                </div>
+                <div class="col-7">
+                    <div class="row">
+                        <div class="col-6">
+                            <div class="card">
+                                <div class="card-header">
+                                    <div class="col-5 row">
+                                        <div class="block">
+                                            <span class="demonstration"></span>
+                                            <el-date-picker @blur="logisticsCountingRecordsApi()"
+                                                            v-model="logisticsCountingRecordsData"
+                                                            type="daterange"
+                                                            align="right"
+                                                            unlink-panels
+                                                            range-separator="-"
+                                                            start-placeholder="开始日期"
+                                                            end-placeholder="结束日期"
+                                                            value-format="yyyy-MM-dd"
+                                                            :picker-options="pickerOptions">
+                                            </el-date-picker>
+                                        </div>
+                                    </div>
+                                </div>
+                                <div class="card-body row">
+                                    <div v-show="logisticsCountingRecordsShow" id="logisticsCountingRecords" class="col"
+                                         style="width: 600px;height:600px;"></div>
+                                    <div v-show="!logisticsCountingRecordsShow" class="text-center">
+                                        <h3>正在加载...</h3>
                                     </div>
                                 </div>
                             </div>
-                            <div class="card-body row">
-                                <div id="logisticsCountingRecords" class="col"
-                                     style="width: 600px;height:600px;"></div>
+                        </div>
+                        <div class="col-6">
+                            <div class="card">
+                                <div class="card-header">
+                                    <div class="col-5 row">
+                                        <div class="block">
+                                            <span class="demonstration"></span>
+                                            <el-date-picker @blur="warehouseCountingRecordsApi()"
+                                                            v-model="warehouseCountingRecordsData"
+                                                            type="daterange"
+                                                            align="right"
+                                                            unlink-panels
+                                                            range-separator="-"
+                                                            start-placeholder="开始日期"
+                                                            end-placeholder="结束日期"
+                                                            value-format="yyyy-MM-dd"
+                                                            :picker-options="pickerOptions">
+                                            </el-date-picker>
+                                        </div>
+                                    </div>
+                                </div>
+                                <div class="card-body row">
+                                    <div v-show="warehouseCountingRecordsShow" id="warehouseCountingRecords" class="col"
+                                         style="width: 600px;height:600px;"></div>
+                                    <div v-show="!warehouseCountingRecordsShow">
+                                        正在加载
+                                    </div>
+                                </div>
                             </div>
                         </div>
                     </div>
-                    <div class="col-6">
+                </div>
+                @can('人事管理-临时工报表-可见全部组')
+                    <div class="col-5">
                         <div class="card">
                             <div class="card-header">
-                                <div class="col-5 row">
-                                    <div class="block">
-                                        <span class="demonstration"></span>
-                                        <el-date-picker @blur="warehouseCountingRecordsApi()"
-                                            v-model="warehouseCountingRecordsData"
-                                            type="daterange"
-                                            align="right"
-                                            unlink-panels
-                                            range-separator="-"
-                                            start-placeholder="开始日期"
-                                            end-placeholder="结束日期"
-                                            value-format="yyyy-MM-dd"
-                                            :picker-options="pickerOptions">
-                                        </el-date-picker>
-                                    </div>
-                                </div>
+                                <span class="demonstration"></span>
+                                <el-date-picker @blur="laborReportsCountingRecordApi('')"
+                                                v-model="laborReportsCountingRecordsDate"
+                                                type="daterange"
+                                                align="right"
+                                                unlink-panels
+                                                range-separator="-"
+                                                start-placeholder="开始日期"
+                                                end-placeholder="结束日期"
+                                                value-format="yyyy-MM-dd"
+                                                :picker-options="pickerOptions">
+                                </el-date-picker>
+                                <el-button type="primary" value="日" @click="laborReportsCountingRecordApi('日')"
+                                           v-model="laborReportsCountingRecordUnit">日
+                                </el-button>
+                                <el-button type="primary" value="周" @click="laborReportsCountingRecordApi('周')"
+                                           v-model="laborReportsCountingRecordUnit">周
+                                </el-button>
+                                <el-button type="primary" value="月" @click="laborReportsCountingRecordApi('月')"
+                                           v-model="laborReportsCountingRecordUnit">月
+                                </el-button>
                             </div>
                             <div class="card-body row">
-                                <div id="warehouseCountingRecords" class="col"
-                                     style="width: 600px;height:600px;"></div>
+                                <div v-show="laborReportsCountingRecordsShow" id="laborReportsCountingRecords" class="col"
+                                     style="width:600px;height:600px;"></div>
+                                <div v-show="!laborReportsCountingRecordsShow">
+                                    正在加载
+                                </div>
                             </div>
                         </div>
                     </div>
-                </div>
-            </div>
-            @can('人事管理-临时工报表-可见全部组')
-            <div class="col-5">
-                <div class="card">
-                    <div class="card-header">
-                        <span class="demonstration" ></span>
-                        <el-date-picker @blur="laborReportsCountingRecordApi('')"
-                                        v-model="laborReportsCountingRecordsDate"
-                                        type="daterange"
-                                        align="right"
-                                        unlink-panels
-                                        range-separator="-"
-                                        start-placeholder="开始日期"
-                                        end-placeholder="结束日期"
-                                        value-format="yyyy-MM-dd"
-                                        :picker-options="pickerOptions">
-                        </el-date-picker>
-                        <el-button type="primary" value="日" @click="laborReportsCountingRecordApi('日')" v-model="laborReportsCountingRecordUnit">日</el-button>
-                        <el-button type="primary" value="周" @click="laborReportsCountingRecordApi('周')" v-model="laborReportsCountingRecordUnit">周</el-button>
-                        <el-button type="primary" value="月" @click="laborReportsCountingRecordApi('月')" v-model="laborReportsCountingRecordUnit">月</el-button>
-                    </div>
-                    <div class="card-body row">
-                        <div id="laborReportsCountingRecords" class="col" style="width:600px;height:600px;"></div>
-                    </div>
-                </div>
-            </div>
-            <div class="col-7">
+                    <div class="col-7">
 
-                <div class="card">
-                    <div class="card-header">
-                        <span class="demonstration" ></span>
-                        <el-date-picker @blur="laborReportsUserGroupsCountApi('')"
-                                        v-model="laborReportsUserGroupsCountDate"
-                                        type="daterange"
-                                        align="right"
-                                        unlink-panels
-                                        range-separator="-"
-                                        start-placeholder="开始日期"
-                                        end-placeholder="结束日期"
-                                        value-format="yyyy-MM-dd"
-                                        :picker-options="pickerOptions">
-                        </el-date-picker>
-                    </div>
-                    <div class="card-body row">
-                        <div id="laborReportsUserGroupsCount" class="col" style="width:600px;height:600px;"></div>
+                        <div class="card">
+                            <div class="card-header">
+                                <span class="demonstration"></span>
+                                <el-date-picker @blur="laborReportsUserGroupsCountApi('')"
+                                                v-model="laborReportsUserGroupsCountDate"
+                                                type="daterange"
+                                                align="right"
+                                                unlink-panels
+                                                range-separator="-"
+                                                start-placeholder="开始日期"
+                                                end-placeholder="结束日期"
+                                                value-format="yyyy-MM-dd"
+                                                :picker-options="pickerOptions">
+                                </el-date-picker>
+                            </div>
+                            <div class="card-body row">
+                                <div v-show="laborReportsUserGroupsCountShow" id="laborReportsUserGroupsCount" class="col"
+                                     style="width:600px;height:600px;"></div>
+                                <div v-show="!laborReportsUserGroupsCountShow">
+                                    正在加载
+                                </div>
+                            </div>
+                        </div>
                     </div>
-                </div>
+                @endcan
             </div>
-            @endcan
         </div>
     </div>
 @endsection
@@ -251,9 +283,15 @@
                 laborReportsUserGroupsCountDate: [moment(new Date(new Date().getTime() - 3600 * 1000 * 24 * 30)).format('yyyy-MM-DD'),
                     moment(new Date()).format('yyyy-MM-DD')],
                 orderCountingRecordsUnit: '日',
-                laborReportsCountingRecordUnit: '日'
+                laborReportsCountingRecordUnit: '日',
+                orderCountingRecordsShow: true,
+                logisticsCountingRecordsShow: true,
+                warehouseCountingRecordsShow: true,
+                laborReportsCountingRecordsShow: true,
+                laborReportsUserGroupsCountShow: true,
             },
             mounted: function () {
+                $('#list').removeClass('d-none');
                 let _this = this;
                 this.warehouses = {
                     "WH01": '松江一仓',
@@ -432,6 +470,7 @@
                     formData.append('start', this.orderCountingRecordsDate[0]);
                     formData.append('end', this.orderCountingRecordsDate[1]);
                     formData.append('unit', orderCountingRecordsUnit);
+                    this.orderCountingRecordsShow = false;
                     let _this = this;
                     axios.post('{{url('apiLocal/control/panel/menu/orderCountingRecordApi')}}', formData).then(function (res) {
                         if (res.status === 200) {
@@ -440,10 +479,12 @@
                             _this.orderCountingRecordsData = [];
                             _this.initOrderCountingRecords();
                             _this.initOrderCountingRecordsChart();
+                            _this.orderCountingRecordsShow = true;
                         }
                     });
                 },
                 logisticsCountingRecordsApi() {
+                    this.logisticsCountingRecordsShow = false;
                     let formData = new FormData();
                     formData.append('start', this.logisticsCountingRecordsData[0]);
                     formData.append('end', this.logisticsCountingRecordsData[1]);
@@ -452,11 +493,13 @@
                         if (res.status === 200) {
                             _this.logisticsCountingRecords = res.data.logisticsCountingRecords;
                             _this.initLogisticsCountingRecordsChart();
+                            _this.logisticsCountingRecordsShow =true;
                         }
                     });
                 },
 
                 warehouseCountingRecordsApi() {
+                    this.warehouseCountingRecordsShow = false;
                     let formData = new FormData();
                     formData.append('start', this.warehouseCountingRecordsData[0]);
                     formData.append('end', this.warehouseCountingRecordsData[1]);
@@ -465,11 +508,14 @@
                         if (res.status === 200) {
                             _this.warehouseCountingRecords = res.data.warehouseCountingRecords;
                             _this.initWarehouseCountingRecordsChart();
+                            _this.warehouseCountingRecordsShow = true;
+
                         }
                     });
                 },
 
                 laborReportsCountingRecordApi(laborReportsCountingRecordUnit) {
+                    this.laborReportsCountingRecordsShow = false;
                     if (laborReportsCountingRecordUnit === '') {
                         laborReportsCountingRecordUnit = this.laborReportsCountingRecordUnit;
                     }
@@ -486,10 +532,12 @@
                             _this.laborReportsCountingRecordsData = [];
                             _this.initLaborReportsCountingRecords();
                             _this.initLaborReportsCountingRecordsChart();
+                            _this.laborReportsCountingRecordsShow = true;
                         }
                     });
                 },
                 laborReportsUserGroupsCountApi() {
+                    this.laborReportsUserGroupsCountShow = false;
                     let formData = new FormData();
                     formData.append('start', this.laborReportsUserGroupsCountDate[0]);
                     formData.append('end', this.laborReportsUserGroupsCountDate[1]);
@@ -498,6 +546,7 @@
                         if (res.status === 200) {
                             _this.laborReportsUserGroupsCount = res.data.laborReportsUserGroupsCount;
                             _this.initLaborReportsUserGroupsCountChart();
+                            _this.laborReportsUserGroupsCountShow = true;
                         }
                     });
                 },

+ 1 - 1
resources/views/customer/project/area.blade.php

@@ -30,7 +30,7 @@
                     <td>@{{ i+1 }}</td>
                     <td>
                         <span v-if="area.status=='已完成'" class="text-success">@{{ area.status }}</span>
-                        <span v-else><button class="btn btn-sm btn-outline-info" @click="edit(area,i)">编辑</button></span>
+                        <span v-if="area.status!='已完成' && editIndex!=i"><button class="btn btn-sm btn-outline-info" @click="edit(area,i)">编辑</button></span>
                         <span v-if="editIndex==i">
                             <button class="btn btn-sm btn-success" @click="submitArea()">确定</button>
                             <button class="btn btn-sm btn-danger" @click="editIndex='-1'">取消</button>

+ 1 - 1
resources/views/customer/project/create.blade.php

@@ -57,7 +57,7 @@
                 </div>
                 <div class="row mt-3">
                     <label for="tax_rate" class="col-2">税率<span class="badge badge-secondary">%</span></label>
-                    <input type="number" v-model="owner.tax_rate" id="tax_rate" class="form-control form-control-sm col-3 mb-0" :class="errors.tax_rate ? 'is-invalid' : ''"  name="tax_rate">
+                    <input type="number" v-model="owner.tax_rate" step="0.01" id="tax_rate" class="form-control form-control-sm col-3 mb-0" :class="errors.tax_rate ? 'is-invalid' : ''"  name="tax_rate">
                     <span class="invalid-feedback offset-2 mt-0" role="alert" v-if="errors.tax_rate">
                         <strong>@{{ errors.tax_rate[0] }}</strong>
                     </span>

+ 2 - 2
resources/views/maintenance/priceModel/operation/_addFeature.blade.php

@@ -27,12 +27,12 @@
                         </label>
                         <label class="col-2">
                             <select class="form-control form-control-sm" v-model="feature.type">
-                                <option v-for="t in type" :value="t">@{{ t }}</option>
+                                <option v-for="t in type" :value="t" v-if="(thisIndex == '-1' && t != '商品名称') || (thisIndex != '-1' && t=='商品名称')">@{{ t }}</option>
                             </select>
                         </label>
                         <label class="col-1">
                             <select class="form-control form-control-sm" v-model="feature.logic">
-                                <option v-for="l in logic" :value="l">@{{ l }}</option>
+                                <option v-for="l in logic" :value="l" v-if="thisIndex == '-1' || l != '不包含'">@{{ l }}</option>
                             </select>
                         </label>
                         <label class="col-4">

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

@@ -80,7 +80,8 @@
                         <div class="row">
                             <div class="col-4 form-inline">
                                 <label for="amount"><span v-if="model.operation_type=='出库'">起步数:</span><span v-else>计量:</span></label>
-                                <input id="amount" type="number" :class="errors['rules.'+i+'.amount'] ? 'is-invalid' : ''" v-model="rule.amount" class="form-control" required>
+                                <input id="amount" :readonly="(model.operation_type=='出库' && rule.strategy=='起步') || model.operation_type!='出库' ? false : true"
+                                       type="number" :class="errors['rules.'+i+'.amount'] ? 'is-invalid' : ''" v-model="rule.amount" class="form-control" required>
                                 <span class="invalid-feedback mt-0 offset-2" role="alert" v-if="errors['rules.'+i+'.amount']">
                                     <strong>必须为整数</strong>
                                 </span>

+ 8 - 8
resources/views/order/index/delivering.blade.php

@@ -106,8 +106,8 @@
                                     <td><div style="width: 180px;overflow: hidden">@{{ oracleDOCOrderDetail.sku }}</div></td>
                                     <td><div style="width: 180px;overflow: hidden">@{{ oracleDOCOrderDetail.alternate_sku1 }}</div></td>
                                     <td>
-                                        <div class="text-truncate text-primary tooltipTarget" style="width: 100px;cursor:pointer;text-decoration: underline" title="双击展开" @dblclick="nowrapText($event)">@{{ oracleDOCOrderDetail.descr_c  }}</div>
-                                        <div class="text-nowrap tooltipTarget"  style="display: none;cursor:pointer" @dblclick="truncateText($event)" title="双击收起">@{{ oracleDOCOrderDetail.descr_c  }}</div>
+                                        <div class="text-truncate text-primary tooltipTarget" style="width: 100px;cursor:pointer;text-decoration: underline" title="双击展开全部" @dblclick="nowrapText($event)">@{{ oracleDOCOrderDetail.descr_c  }}</div>
+                                        <div class="text-nowrap tooltipTarget"  style="display: none;cursor:pointer" @dblclick="truncateText($event)" title="双击收起全部">@{{ oracleDOCOrderDetail.descr_c  }}</div>
 {{--                                        <div :title="oracleDOCOrderDetail.descr_c" class="tooltipTarget" style="width: 180px;overflow: hidden">@{{ oracleDOCOrderDetail.descr_c }}</div>--}}
                                     </td>
                                     <td>@{{ oracleDOCOrderDetail.qtyordered }}</td>
@@ -808,14 +808,14 @@
                     })
                 },
                 truncateText(e){
-                    let nowrapSpan = $(e.target);
-                    nowrapSpan.hide();
-                    nowrapSpan.siblings('.text-truncate').show();
+                    $table = $(e.target).parents('.table').first();
+                    $table.find('.text-nowrap').hide();
+                    $table.find('.text-truncate').show();
                 },
                 nowrapText(e) {
-                    let truncateSpan = $(e.target);
-                    truncateSpan.hide();
-                    truncateSpan.siblings('.text-nowrap').show();
+                    $table = $(e.target).parents('.table').first();
+                    $table.find('.text-truncate').hide();
+                    $table.find('.text-nowrap').show();
                 },
                 getTagOrder(orderNos){
                     this.tagOrders = []

+ 3 - 0
routes/api/thirdPart/haiq.php

@@ -10,3 +10,6 @@ use Illuminate\Support\Facades\Route;
 Route::group(['prefix'=>'storage'],function(){
     Route::post('relocate', "StorageController@relocate");//移库
 });
+Route::group(['prefix'=>'pickStation'],function(){
+    Route::post('processed', "PickStationController@processed");//移库
+});

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

@@ -133,11 +133,19 @@ class FeatureServiceTest extends TestCase
         $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);
+
+        $columnMapping = ["商品名称"=>"commodity","订单类型"=>"order","店铺类型"=>"shop","packages"=>"ps"];
+        $matchObject = ["ps"=>[["a"=>1,"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,true);
+        $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);

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

@@ -21,7 +21,7 @@ class GetWMSOrderOnStartDateTest extends TestCase
 
     public function testGetWMSOrderOnStartDate()
     {
-        $carbon =Carbon::now()->subSeconds(10);
+        $carbon =Carbon::now()->subMinutes(5);
         $orderHeaders = $this->service->getWMSOrderOnStartDate($carbon);
         $this->assertNotNull($orderHeaders);
         $orderHeader = $orderHeaders->first();

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

@@ -15,13 +15,14 @@ class GetWmsOrderOnStartDateEditTest extends TestCase
 
     public function setUp(): void
     {
-        $this->service = app(OracleDOCOrderHeaderService::class);
         parent::setUp();
+        $this->service = app(OracleDOCOrderHeaderService::class);
     }
 
     public function testGetWmsOrderOnStartDateEdit()
     {
         $carbon =Carbon::now()->subHours(10);
+        $carbon =Carbon::now()->subMinutes(5);
         $orderHeaders = $this->service->getWmsOrderOnStartDateEdit($carbon);
         $this->assertNotNull($orderHeaders);
         $orderHeader = $orderHeaders->first();

+ 7 - 2
tests/Services/OrderCountingRecordService/DateTestTest.php

@@ -11,8 +11,13 @@ use Tests\TestCase;
 
 class DateTestTest extends TestCase
 {
-    public function test01()
+    /**
+     * @test
+     */
+    public function carbon_date_equals()
     {
-        $this->assertTrue(true);
+        $this->assertTrue('2020-11-25' == Carbon::now()->format('Y-m-d'));
+        $this->assertTrue('2020-48' == Carbon::now()->year . '-' . Carbon::now()->week);
+        $this->assertTrue('2020-11' == Carbon::now()->year . '-' . Carbon::now()->month);
     }
 }

+ 11 - 0
tests/Services/OrderService/CreateOrFindOrderInfoTest.php

@@ -17,6 +17,7 @@ class CreateOrFindOrderInfoTest extends TestCase
 
     /**
      * @var OrderService $orderService
+     * @var Order $order
      */
     public $orderService;
     public $data = [];
@@ -37,4 +38,14 @@ class CreateOrFindOrderInfoTest extends TestCase
         $this->order->delete();
     }
 
+    public function testCreateOrFindOrderInfo1()
+    {
+        $orderHeader = $this->data['orderHeader'];
+        $orderHeader->customerid = null;
+        $orderHeader->warehouseid = null;
+        $orderHeader->userdefine1 = null;
+        $this->orderService->createOrFindOrderInfo($this->data['orderHeader']);
+
+    }
+
 }

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

@@ -28,19 +28,15 @@ class GetOrderByLogisticNumberTest extends TestCase
     {
         $order_package = OrderPackage::query()->orderByDesc('id')->first();
         $logistic_number = $order_package->logistic_number;
-//        var_dump($logistic_number);
         $orderHeader = OracleDOCOrderHeader::query()->whereHas('actAllocationDetails',function($query)use($order_package){
             $query->where('PickToTraceID',$order_package->logistic_number);
         })->first();
-//        var_dump($orderHeader?$orderHeader->orderno:'');
 
         if(!$orderHeader){
             $orderHeader = OracleDOCOrderHeader::query()->with('actAllocationDetails')->orderBy('AddTime')->first();
-//            var_dump($orderHeader?$orderHeader->orderno:'查询为空');
             $logistic_number = data_get($orderHeader,'actAllocationDetails.*.picktotraceid')[0];
         }
         $order = $this->service->getOrderByLogisticNumber($logistic_number);
-//        var_dump($order,$logistic_number,$orderHeader,$order_package);
         $this->assertEquals((string)$orderHeader->addtime,(string)$order->created_at);
         $this->assertEquals($orderHeader->orderno,$order->code);
 

+ 0 - 1
tests/Services/OrderService/LogisticNumberFirstOrCreateOrderTest.php

@@ -23,7 +23,6 @@ class LogisticNumberFirstOrCreateOrderTest extends TestCase
     {
         $logistic_number = OracleActAllocationDetails::query()->first()->picktotraceid;
         $order = $this->service->logisticNumberFirstOrCreateOrder($logistic_number);
-//        var_dump($order,$logistic_number);
         $this->assertNotEmpty($order);
     }
 }

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

@@ -48,9 +48,7 @@ class SyncOrderByWMSOrderHeaderTest extends TestCase
         $date = '2020-09-18 18:13:50';
         $orderHeaders = $this->orderHeaderService->getWMSOrderOnStartDate($carbon);
         $this->service->syncOrderByWMSOrderHeaders($orderHeaders);
-        $existOrders = $this->service->getByWmsOrders($orderHeaders);
         $collect =null;
-
         foreach ($orderHeaders as $orderHeader) {
             $code = $orderHeader->orderno;
             $order = $collect->where('code',$code)->first();
@@ -77,11 +75,9 @@ class SyncOrderByWMSOrderHeaderTest extends TestCase
             $this->assertEquals($order->province ,$orderHeader->c_province);
             $this->assertEquals($order->city ,$orderHeader->c_city);
             $this->assertEquals($order->district ,$orderHeader->c_district);
-
             $this->assertEquals($order->client_code ,$orderHeader->soreference1);
             $this->assertEquals($order->wms_edittime ,(string)$orderHeader->edittime);
             $this->assertEquals($order->wms_status ,$orderHeader->oracleBASCode_codename_c);
-
             $this->assertEquals((string)$order->created_at ,(string)$orderHeader->addtime);
         }
     }

+ 16 - 14
tests/Services/OwnerPriceOperationService/OwnerPriceOperationServiceTest.php

@@ -75,41 +75,37 @@ class OwnerPriceOperationServiceTest extends  TestCase
             "owner_price_operation_id"          => $model3->id,
             "strategy"                          =>"起步",
             "amount"                            =>6,
-            "unit_id"                           => $pieces->id,
+            "unit_id"                           => $box->id,
             "unit_price"                        => 2.22,
         ]);
         $out4 = factory(OwnerOutStorageRule::class)->create([
             "owner_price_operation_id"          => $model3->id,
             "strategy"                          => "默认",
-            "amount"                            => 6,
             "unit_id"                           => $box->id,
             "unit_price"                        => 3.22,
         ]);
         $out5 = factory(OwnerOutStorageRule::class)->create([
             "owner_price_operation_id"          => $model3->id,
             "strategy"                          =>"特征",
-            "amount"                            => 6,
-            "unit_id"                           => $single->id,
+            "unit_id"                           => $box->id,
             "unit_price"                        => 4.22,
         ]);
         $out6 = factory(OwnerOutStorageRule::class)->create([
             "owner_price_operation_id"          => $model4->id,
             "strategy"                          =>"起步",
             "amount"                            => 6,
-            "unit_id"                           => $pieces->id,
+            "unit_id"                           => $box->id,
             "unit_price"                        => 5.1,
         ]);
         $out7 = factory(OwnerOutStorageRule::class)->create([
             "owner_price_operation_id"          => $model4->id,
             "strategy"                          => "默认",
-            "amount"                            => 6,
-            "unit_id"                           => $pieces->id,
+            "unit_id"                           => $box->id,
             "unit_price"                        => 5.2,
         ]);
         $out8 = factory(OwnerOutStorageRule::class)->create([
             "owner_price_operation_id"          => $model4->id,
             "strategy"                          =>"特征",
-            "amount"                            => 6,
             "unit_id"                           => $box->id,
             "unit_price"                        => 5.3,
         ]);
@@ -141,14 +137,20 @@ class OwnerPriceOperationServiceTest extends  TestCase
             /** @var Mock $mock */
             $mock->shouldReceive("matchFeature")->andReturn(true);
         });
-        $result = $this->service->matchRule(55,[],[],$this->data["owners"][0]["id"],$this->data["commodities"][0]["sku"],"入库");
+        $result = $this->service->matchRule(["packages"=>[["commodity"=>"测试","amount"=>55]]],[],$this->data["owners"][0]["id"],$this->data["commodities"][0]["sku"],"入库");
         $this->assertEquals(12.88,$result);
-        $result = $this->service->matchRule(56,[],[],$this->data["owners"][0]["id"],null,"入库");
+        $result = $this->service->matchRule(["packages"=>[["commodity"=>"测试","amount"=>57]]],[],$this->data["owners"][0]["id"],$this->data["commodities"][0]["sku"],"出库");
+        $this->assertEquals(99.5,$result);
+    }
+    /**
+     * @group customer
+     */
+    public function testMatchRule1()
+    {
+        $result = $this->service->matchRule(["packages"=>[["commodity"=>"测试","amount"=>56]]],[],$this->data["owners"][0]["id"],$this->data["commodities"][0]["sku"],"入库");
         $this->assertEquals(26.64,$result);
-        $result = $this->service->matchRule(57,[],[],$this->data["owners"][0]["id"],$this->data["commodities"][0]["sku"],"出库");
-        $this->assertEquals(46.5,$result);
-        $result = $this->service->matchRule(58,[],[],$this->data["owners"][0]["id"],null,"出库");
-        $this->assertEquals(77.4,$result);
+        $result = $this->service->matchRule(["packages"=>[["commodity"=>"测试","amount"=>58]]],[],$this->data["owners"][0]["id"],$this->data["commodities"][0]["sku"],"出库");
+        $this->assertEquals(58.4,$result);
     }
 
     public function tearDown(): void

+ 9 - 11
tests/Services/WarehouseService/GetByWmsOrderTest.php

@@ -2,6 +2,7 @@
 
 namespace Tests\Services\WarehouseService\GetByWmsOrdersTest;
 
+use App\OracleBasCustomer;
 use App\OracleDOCOrderHeader;
 use App\Services\WarehouseService;
 use App\Warehouse;
@@ -13,26 +14,23 @@ class GetByWmsOrderTest extends TestCase
 
     /** @var WarehouseService $service */
     public $service;
-
+    public $data = [];
 
     public function setUp(): void
     {
-        $this->service = app(WarehouseService::class);
         parent::setUp();
+        $this->service = app(WarehouseService::class);
+        $basCustomers = OracleBasCustomer::query()->selectRaw('Customer_Type,CustomerId,Descr_C')->where('Customer_Type','WH')->get();
+        foreach ($basCustomers as $basCustomer) {
+            $this->data['data'][]['warehouseid'] =  $basCustomer->customerid;
+        }
     }
 
     public function testGetByWmsOrder()
     {
-        $carbon = Carbon::now()->subMinutes(10);
-        $orders = OracleDOCOrderHeader::query()->where('addtime',">=",$carbon)->get();
-        $warehouse_ids = data_get($orders,'*.warehouseid');
-        $warehouses =  $this->service->getByWmsOrders($orders);
+        $warehouses =  $this->service->getByWmsOrders($this->data['data']);
+        $warehouse_ids = data_get($this->data['data'],'*.warehouseid');
         $warehouse_s = Warehouse::query()->whereIn('code',$warehouse_ids)->get();
-//        var_dump($warehouses->map(function($item){
-//            return [$item->id,$item->name,$item->code];
-//        }),$warehouse_s->map(function($item){
-//            return [$item->id,$item->name,$item->code];
-//        }));
         $this->assertEquals($warehouses->count(),$warehouse_s->count());
     }
 }

+ 16 - 0
tests/webApi/thirdPart/haiq/pickStation.http

@@ -0,0 +1,16 @@
+# For a quick start check out our HTTP Requests collection (Tools|HTTP Client|Open HTTP Requests Collection).
+##
+## Following HTTP Request Live Templates are available:
+## * 'gtrp' and 'gtr' create a GET request with or without query parameters;
+## * 'ptr' and 'ptrp' create a POST request with a simple or parameter-like body;
+## * 'mptr' and 'fptr' create a POST request to submit a form with a text or file field (multipart/form-data);
+
+
+POST http://bswas/api/thirdPart/haiq/pickStation/processed
+Content-Type: application/json
+
+{"success":true}
+###
+
+
+

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

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