瀏覽代碼

Merge branch 'master' of ssh://47.103.131.176:10022/var/git/bswas

zhouzhendong 4 年之前
父節點
當前提交
e1d12400de

+ 1 - 0
app/Http/Controllers/OwnerController.php

@@ -6,6 +6,7 @@ use App\Authority;
 use App\Components\AsyncResponse;
 use App\Events\CustomerStored;
 use App\Owner;
+use App\OwnerGroup;
 use Exception;
 use Illuminate\Http\Request;
 use Illuminate\Http\Response;

+ 84 - 0
app/Http/Controllers/OwnerGroupController.php

@@ -0,0 +1,84 @@
+<?php
+
+namespace App\Http\Controllers;
+
+use Illuminate\Http\Request;
+use Illuminate\Support\Facades\Gate;
+use Illuminate\Support\Facades\Validator;
+
+class OwnerGroupController
+{
+    public function index(Request $request)
+    {
+        if (!Gate::allows('货主组别-查询')) {
+            return redirect('denied');
+        }
+        $params = $request->all();
+        $groups = app('OwnerGroupService')->paginate($params);
+        return response()->view("maintenance.OwnerGroup.index", compact("groups"));
+    }
+
+    public function create()
+    {
+        if (!Gate::allows('货主组别-录入')) {
+            return redirect('denied');
+        }
+        return response()->view("maintenance.ownerGroup.create");
+    }
+
+    public function store(Request $request)
+    {
+        if (!Gate::allows('货主组别-录入')) {
+            return redirect('denied');
+        }
+        $this->validator($request->input())->validate();
+        app('OwnerGroupService')->create([
+            "name" => $request->input("name"),
+        ]);
+        return response()->redirectTo("maintenance/ownerGroup")->with("successTip","成功创建货主组别“".$request->input("name")."”");
+    }
+
+    public function edit($id)
+    {
+        if (!Gate::allows('货主组别-编辑')) {
+            return redirect('denied');
+        }
+        $group = app('OwnerGroupService')->find($id);
+        return response()->view('maintenance.ownerGroup.create', compact("group"));
+    }
+
+    public function update(Request $request, $id)
+    {
+        if(!Gate::allows('货主组别-编辑')){ return redirect('denied');  }
+        $this->validator($request->input(),$id)->validate();
+        $result = app('OwnerGroupService')->update(["id"=>$id],[
+            "name"=>$request->input("name"),
+        ]);
+        if ($result == 1){
+            return response()->redirectTo("maintenance/ownerGroup")->with("successTip","成功修改基础设置-货主组别“".$request->input("name")."”的信息");
+        }
+        return response()->view("exception.default",["code"=>"509"]);
+    }
+
+    public function destroy($id)
+    {
+        if(!Gate::allows('货主组别-删除')){ return ["success"=>false,"data"=>"无权操作!"];  }
+        $result = app('OwnerGroupService')->destroy($id);
+        if ($result == 1)return ["success"=>true];
+        return ["success"=>false,"data"=>"删除了“".$result."”行"];
+    }
+
+    private function validator(array $params, $id = null)
+    {
+        return Validator::make($params,[
+            'name'=>['required',$id?"unique:owner_groups,name,$id":'unique:owner_groups,name','max:20'],
+        ],[
+            'required'=>':attribute 为必填项',
+            'max'=>':attribute 字符过多或输入值过大',
+            'unique'=>':attribute 已存在',
+        ],[
+            'name'=>'货主组别名称',
+        ]);
+    }
+
+}

+ 2 - 0
app/Http/Controllers/UserController.php

@@ -3,6 +3,8 @@
 namespace App\Http\Controllers;
 
 use App\Components\AsyncResponse;
+use App\Owner;
+use App\OwnerGroup;
 use App\Role;
 use App\Supplier;
 use App\User;

+ 27 - 40
app/Http/Controllers/WaybillController.php

@@ -16,6 +16,8 @@ use App\Services\WaybillPayoffService;
 use App\Services\WaybillPriceModelService;
 use App\Services\WaybillService;
 use App\Traits\ModelLogChanging;
+use App\Terminal;
+use App\TerminalPrinter;
 use App\UploadFile;
 use App\WaybillAuditLog;
 use App\WaybillOnTop;
@@ -59,13 +61,19 @@ class WaybillController extends Controller
         if(!Gate::allows('运输管理-运单-查询')){ return view("exception.authority");  }
         $paginateParams = $request->input();
         $waybills=app('waybillService')->paginate($request->input());
+        $mac_addr = getMacAddr();
+        $print = TerminalPrinter::with(['terminal','logistics'])
+            ->whereHas('terminal',function ($query)use($mac_addr){$query->where('ip',$mac_addr);})
+            ->whereHas('logistics',function ($query){$query->where('logistic_id',15);})
+            ->first();
+        $print = $print->printer_name??'EK100B';
         return view('transport.waybill.index', [
             'waybills' => $waybills,
             'logistics' => $logisticService->getSelection(["id","name"],"物流"),
             'owners' => $ownerService->getIntersectPermitting(),
             "carTypes" => CarType::query()->get(),
             'paginateParams'=>$paginateParams,
-            'uriType'=>$request->uriType??'']);
+            'uriType'=>$request->uriType??'','print_name'=> $print]);
     }
 
 
@@ -770,10 +778,12 @@ SQL;
         ])->direct();
     }
 
-    private function deliveringQuery(Request $request): Builder
-    {
-        $waybills= Waybill::query()->where("type","专线")->with(["order","logistic"])
-            ->whereNotNull("logistic_id")->whereNotNull("deliver_at")->whereIn("status",["已审核","待终审"]);
+    //发运
+    public function delivering(Request $request){
+        if (!Auth::user())return view('exception.login');
+        $waybills= Waybill::query()->where("type","专线")
+            ->whereNotNull("logistic_id")->whereNotIn("status",["未审核","待重审"])
+            ->orderByDesc("id");
         if (!Auth::user()->isSuperAdmin()){
             $carriersUsers=DB::table('logistic_user')->where('user_id',Auth::id())->get();
             $carrierIds=array_column($carriersUsers->toArray(),'logistic_id');
@@ -783,31 +793,12 @@ SQL;
         if ($searchText)$waybills->where(function ($query)use($searchText){
             $query->where("waybill_number",'like','%'.$searchText.'%')->orWhere("carrier_bill",'like','%'.$searchText.'%');
         });
-        $lastId = $request->get("lastId","");
-        if ($lastId)$waybills->where("id","<",$lastId);
-        $date = $request->get("date");
-        if ($date)$waybills->where("deliver_at",'like',$date."%");
-        return $waybills;
-    }
-    //发运
-    public function delivering(Request $request){
-        $groups = $this->deliveringQuery($request)->selectRaw("date_format(deliver_at, '%Y-%m-%d') date")
-            ->orderByDesc(DB::raw("date"))->groupByRaw("date")->get();
-        $searchText = $request->get("searchText","");
-        return view('transport.waybill.delivering',compact('groups',"searchText"));
-    }
-
-    /**
-     * 懒加载发运数据
-     */
-    public function loadData(Request $request)
-    {
-        if (!Auth::user())$this->error("登录信息失效");
-        $this->success($this->deliveringQuery($request)->orderByDesc("id")->get());
+        $waybills = $waybills->get();
+        return view('transport.waybill.delivering',compact('waybills',"searchText"));
     }
     //承运商提交
     public function storeCarrierBill(Request $request){
-        if(!Gate::allows("运输管理-承运商调度"))return ["error"=>"无权操作!"];
+        //if(!Gate::allows("运输管理-承运商调度"))return ["error"=>"无权操作!"];
         $errors=Validator::make($request->input(),[
             'id'=>'required|integer',
             'carrier_bill'=>'required',
@@ -833,16 +824,10 @@ SQL;
         if (count($errors)>0)return ["errors"=>$errors];
         $waybill=Waybill::query()->find($request->input('id'));
         if (!$waybill)return ["error"=>"未找到该运单!"];
-        $request->offsetSet("carrier_weight_unit_id",$unit2->id);
-        $request->offsetSet("carrier_weight_unit_id_other",$unit->id);
-        $request->offsetSet("amount_unit_id",$unit1->id);
-        $request->offsetSet("status","待终审");
+        $request->offsetSet("carrier_weight_unit_id",$unit2);
+        $request->offsetSet("carrier_weight_unit_id_other",$unit);
+        $request->offsetSet("amount_unit_id",$unit1);
         $waybill->fill($request->input());
-        WaybillAuditLog::query()->create([
-            'waybill_id'=>$waybill->id,
-            'audit_stage'=>'调度阶段',
-            'user_id'=>Auth::id(),
-        ]);
         $waybill->update();
         return $waybill;
     }
@@ -1119,9 +1104,11 @@ SQL;
         for ($i=1;$i<$waybills->count();$i++){
             //信息一致性校验
             $identical = ($waybill->order && ($waybills[$i]->order->consignee_name!=$waybill->order->consignee_name
-                        || $waybills[$i]->order->consignee_phone!=$waybill->order->consignee_phone)) ||
+                        || $waybills[$i]->order->consignee_phone!=$waybill->order->consignee_phone
+                        || $waybills[$i]->order->address!=$waybill->order->address)) ||
                 (!$waybill->order && ($waybills[$i]->recipient!=$waybill->recipient
-                    || $waybills[$i]->recipient_mobile!=$waybill->recipient_mobile));
+                    || $waybills[$i]->recipient_mobile!=$waybill->recipient_mobile
+                    || $waybills[$i]->destination!=$waybill->destination));
             if (array_search($waybills[$i]->status,["未审核","已审核"])===false
                 || $identical)$this->error("信息不一致,无法进行合并");
             $destroys[] = $waybills[$i]->id;
@@ -1274,7 +1261,8 @@ SQL;
                             || $item->order->consignee_phone!=$waybill->order->consignee_phone
                             || $item->order->address!=$waybill->order->address)) ||
                     (!$waybill->order && ($item->recipient!=$waybill->recipient
-                            || $item->recipient_mobile!=$waybill->recipient_mobile));
+                            || $item->recipient_mobile!=$waybill->recipient_mobile
+                            || $item->destination!=$waybill->destination));
                 if ($identical)$this->error("订单信息不一致,无法统一发货");
                 $destroys[] = $item->id;
                 $waybill->source_bill .= $item->source_bill ? ",".$item->source_bill : '';
@@ -1291,7 +1279,6 @@ SQL;
             $owner = array_unique($owner);
             if (count($owner)>1)$waybill->merge_owner = implode(',',$owner);
             $waybill->deliver_at = date("Y-m-d H:i:s");
-            $waybill->logistic_id = \request("logistic");
             if ($waybill->status=='未审核')$waybill->status = '已审核';
             $waybill->update();
             Waybill::destroy($destroys);

+ 2 - 1
app/Owner.php

@@ -39,7 +39,8 @@ class Owner extends Model
         'subjection',           //主体公司
         'is_tax_exist',         //是否必填税率
         'model_sequence',       //调箱序列(优先级匹配)
-        'is_check_asn'          //是否校验ASN(收货时检查此项)
+        'is_check_asn',          //是否校验ASN(收货时检查此项)
+        'owner_group_id',        // 所属组别
     ];
     //relevance说明 0:仓储 1:作业 2:快递 3:物流 4:直发 5:系统 存储示例:["0","1"]存在仓储与作业计费
     protected $casts = [

+ 20 - 0
app/OwnerGroup.php

@@ -0,0 +1,20 @@
+<?php
+
+namespace App;
+
+use App\Traits\ModelTimeFormat;
+use Illuminate\Database\Eloquent\Model;
+
+use App\Traits\ModelLogChanging;
+
+class OwnerGroup extends Model
+{
+    use ModelLogChanging;
+
+    use ModelTimeFormat;
+    public $fillable = [
+        'name',                 //名称
+    ];
+
+
+}

+ 0 - 1
app/Providers/AppServiceProvider.php

@@ -261,7 +261,6 @@ class AppServiceProvider extends ServiceProvider
         app()->singleton('LogisticZopService', LogisticZopService::class);
         app()->singleton('MaterialBoxModelService',MaterialBoxModelService::class);
         app()->singleton('MaterialBoxService', MaterialBoxService::class);
-        app()->singleton('MeasureMonitorService',MeasureMonitorService::class);
         app()->singleton('MenuService',MenuService::class);
         app()->singleton('NewOrderCountingRecordService',NewOrderCountingRecordService::class);
         app()->singleton('OracleActAllocationDetailService', OracleActAllocationDetailService::class);

+ 31 - 0
app/Utils/helpers.php

@@ -78,3 +78,34 @@ function httpPost($uri = '', $body = '', $header = ''):array
     $data = $res->getBody()->getContents();
     return json_decode($data,  true);
 }
+
+function getMacAddr($type = PHP_OS):string
+{
+    $return_array = []; $mac_addr = '';
+    switch (strtolower($type)){
+        case 'linux' :
+            @exec('ifconfig -a', $return_array);
+            break;
+        case 'solaris' :
+        case 'unix' :
+        case 'aix' : break;
+        default:
+            @exec('ipconfig /all', $return_array);
+            if (empty($return_array)){
+                $ipconfig = $_SERVER['WINDIR'].'system32ipconfig.exe';
+                if (is_file($ipconfig)) @exec($ipconfig.' /all', $return_array);
+                else @exec($_SERVER['WINDIR'].'systemipconfig.exe /all', $return_array);
+            }
+            break;
+
+    }
+    $temp_array = [];
+    foreach ($return_array as $value){
+        if (preg_match('/[0-9a-f][0-9a-f][:-]'.'[0-9a-f][0-9a-f][:-]'.'[0-9a-f][0-9a-f][:-]'.'[0-9a-f][0-9a-f][:-]'.'[0-9a-f][0-9a-f][:-]'.'[0-9a-f][0-9a-f]/i', $value, $temp_array)){
+            $mac_addr = $temp_array[0];
+            break;
+        }
+    }
+    unset($temp_array);
+    return $mac_addr;
+}

+ 25 - 0
database/seeds/OwnerGroupSeeder.php

@@ -0,0 +1,25 @@
+<?php
+
+use Illuminate\Database\Seeder;
+
+class OwnerGroupSeeder extends Seeder
+{
+    /**
+     * Run the database seeds.
+     *
+     * @return void
+     */
+    public function run()
+    {
+        //
+        $data = [];
+        for ($i=0;$i<200;$i++){
+            $data[$i] = [
+                'name' => '分组名'.$i,
+                'created_at' => date('Y-m-d H:i:s'),
+                'updated_at' => date('Y-m-d H:i:s'),
+            ];
+        }
+        \Illuminate\Support\Facades\DB::table('owner_groups')->insert($data);
+    }
+}

+ 1 - 1
resources/js/vue/tree.vue

@@ -76,4 +76,4 @@
         border-width: 0.05em;
         border-color: #aaa;
     }
-</style>
+</style>

+ 5 - 3
resources/views/maintenance/owner/index.blade.php

@@ -45,15 +45,17 @@
             data:{
                 owners:[
                     @foreach( $owners as $owner )
-                    {id:'{{$owner->id}}',code:'{{$owner->code}}',name:'{{$owner->name}}',created_at:'{{$owner->created_at}}'},
+                    {id:'{{$owner->id}}',code:'{{$owner->code}}',name:'{{$owner->name}}',group:'{{$owner->ownerGroup->name??''}}',created_at:'{{$owner->created_at}}'},
                     @endforeach
                 ],
                 selectTr:0
             },
             mounted:function(){
                 let data = [
-                   [{name: 'code', type: 'input',tip:'可支持多货主编码,模糊搜索可在两侧添加百分号(%)进行',placeholder:'货主编码'},
-                   {name: 'name', type: 'input',tip:'可支持多货主名称,模糊搜索可在两侧添加百分号(%)进行',placeholder:'货主名称'}]
+                   [
+                    {name: 'code', type: 'input',tip:'可支持多货主编码,模糊搜索可在两侧添加百分号(%)进行',placeholder:'货主编码'},
+                    {name: 'name', type: 'input',tip:'可支持多货主名称,模糊搜索可在两侧添加百分号(%)进行',placeholder:'货主名称'},
+                   ]
                 ];
                 this.from =new query({
                     el: '#form_div',

+ 1 - 2
resources/views/maintenance/user/edit.blade.php

@@ -140,7 +140,6 @@
                             </div>
                         </div>
                     </div>
-
                     <hr class="col-8 offset-2 border-info">
                     <div class="form-group row">
                         <div class="col-8 offset-2">
@@ -482,7 +481,7 @@
                         }
                     }
                 },
-            },
+            }
         });
 
     </script>

+ 19 - 5
resources/views/transport/waybill/edit.blade.php

@@ -34,7 +34,7 @@
                                     <div class="h5 mb-3 col-8">
                                         <button type="button" @click="waybill.type='专线'" class="btn" :class="waybill.type=='专线'?'btn-primary':'btn-outline-primary'">专线</button>
                                         <button type="button" @click="waybill.type='直发车'" class="btn ml-2" :class="waybill.type=='直发车'?'btn-primary':'btn-outline-primary'">直发车</button>
-                                        <button type="button" @click="waybill.type='德邦物流'" class="btn ml-2" :class="waybill.type=='德邦物流'?'btn-primary':'btn-outline-primary'">德邦物流</button>
+                                        <button type="button" v-on:click="dbwl" @click="waybill.type='德邦物流'" class="btn ml-2" :class="waybill.type=='德邦物流'?'btn-primary':'btn-outline-primary'">德邦物流</button>
                                     </div>
                                     <input name="type" id="type" :value="waybill.type" hidden>
                                 </div>
@@ -60,10 +60,10 @@
                             <div class="form-group row">
                                 <label for="deliver_at" class="col-2 col-form-label text-right text-primary">发货时间 *</label>
                                 <div class="col-8 form-inline">
-                                    <input  id="deliver_at_date" @input="spliceDeliverAt" name="deliver_at_date" type="date" class="form-control col-4 @error('deliver_at_date') is-invalid @enderror"
-                                            value="@if(old('deliver_at_date')){{ old('deliver_at_date') }}@else{{$waybill->deliver_at_date}}@endif">
+                                    <input  id="deliver_at_date"  @input="spliceDeliverAt" name="deliver_at_date" type="date" class="form-control col-4 @error('deliver_at_date') is-invalid @enderror"
+                                            v-model="waybill.deliver_at_date">
                                     <input  id="deliver_at_time" @input="spliceDeliverAt" name="deliver_at_time" type="time" class="form-control col-4 @error('deliver_at_date') is-invalid @enderror"
-                                            value="@if(old('deliver_at_time')){{ old('deliver_at_time') }}@else{{$waybill->deliver_at_time}}@endif">
+                                            v-model="waybill.deliver_at_time">
                                     <input hidden id="deliver_at"  name="deliver_at" type="text" class="form-control col-4">
                                 </div>
                             </div>
@@ -71,7 +71,7 @@
                                 <label for="inquire_tel" class="col-2 col-form-label text-right text-primary">查件电话 *</label>
                                 <div class="col-8">
                                     <input id="inquire_tel" name="inquire_tel" type="text" class="form-control col-8 @error('inquire_tel') is-invalid @enderror"
-                                           value="@if(old('inquire_tel')){{ old('inquire_tel') }}@else{{$waybill->inquire_tel}}@endif">
+                                           v-model="waybill.inquire_tel" >
                                 </div>
                             </div>
                             <div v-if="waybill.logistic_id == 15 || waybill.type=='德邦物流'" style="background: black">
@@ -518,6 +518,9 @@
                     pay_type: '{{ old("pay_type") ?? $waybill->pay_type}}',
                     back_sign_bill: '{{ old("back_sign_bill") ?? $waybill->back_sign_bill}}',
                     package_service: '{{ old("package_service") ?? $waybill->package_service}}',
+                    inquire_tel: '{{ old("inquire_tel") ?? $waybill->inquire_tel}}',
+                    deliver_at_date: '{{old("deliver_at_date") ?? $waybill->deliver_at_date}}',
+                    deliver_at_time: '{{old("deliver_at_time") ?? $waybill->deliver_at_time}}'
                 },
                 order:{!! $waybill->order ?? '{}' !!},
                 waybillTemp:{!! $waybill !!},
@@ -739,6 +742,17 @@
                             this.waybill.destination_city_id = res.id;
                             $("#selectedProvince").modal("hide");
                         });
+                },
+                dbwl:function () {
+                    this.waybill.logistic_id = 15;
+                    this.waybill.logistic_id = 15;
+                    this.waybill.amount = 1;
+                    this.waybill.amount_unit_id = 5;
+                    this.waybill.inquire_tel = '13761413262';
+                    this.waybill.dispatch_remark = '13761413262';
+                    let  date = new Date();
+                    this.waybill.deliver_at_date = date.getFullYear()+'-'+("0" + (date.getMonth() + 1)).slice(-2) + '-'+date.getDate();
+                    this.waybill.deliver_at_time = date.getHours()+':'+date.getMinutes();
                 }
             },
             created(){

+ 5 - 18
resources/views/transport/waybill/index.blade.php

@@ -702,18 +702,7 @@
                         window.tempTip.show("至少选择两条运单进行合并");
                         return;
                     }
-                    let presetAddress = undefined;
-                    let isCheck = this.waybills.every(waybill=>{
-                        if (checkData.includes(waybill.id)){
-                            if (presetAddress===undefined){
-                                presetAddress = waybill.destination;
-                                return true;
-                            }
-                            if (presetAddress!==waybill.destination)return false;
-                        }
-                        return true;
-                    });
-                    window.tempTip.confirm(isCheck ? "确定要合并选中运单吗?" : "目的地址不一致确定仍要进行合并吗?",()=>{
+                    window.tempTip.confirm("确定要合并选中运单吗?",()=>{
                         window.tempTip.setDuration(5000);
                         window.tempTip.waitingTip("合并中,请稍等...");
                         window.tempTip.postBasicRequest("{{url('transport/waybill/waybillMerge')}}",{ids:checkData},res=>{
@@ -853,7 +842,7 @@
                 rendingHeader(){
                     let column = [
                         {name:'operation',value: '操作', neglect: true, class:"td-operation"},
-                         @can('运输管理-运单-置顶'){name:'onTop',value: '置顶', neglect: true, class:"td-operation"},@endcan
+                        {name:'onTop',value: '置顶', neglect: true, class:"td-operation"},
                         {name:'status',value: '状态', class:"td-operation"},
                         {name:'express_face_list',value: '快递面单是否打印', class:"td-warm"},
                         {name:'index',value: '序号', neglect: true, class:"td-warm"},
@@ -894,8 +883,6 @@
                         {name:'dispatch_remark',value: '调度备注', class:"td-helpful"},
                             @can('运输管理-运单-删除'){name:'remove',value: '操作', neglect: true, class:"td-delete"},@endcan
                     ];
-                    let isOnTop = column[1].name === 'onTop';
-                    let couLen = (column[column.length-1].name==='remove' ? column.length : column.length+1)-((isOnTop ? 4 : 3)+15+17);
                     new Header({
                         el: "table",
                         name: "waybill",
@@ -904,11 +891,11 @@
                         restorationColumn: 'id',
                         fixedTop:($('#form_div').height())+2,
                         before : [
-                            {colspan:isOnTop ? '4' : '3',value: '', class:"table-header-layer-1"},
+                            {colspan:'4',value: '', class:"table-header-layer-1"},
                             {colspan:'15',value: '运单信息',font:"fa fa-file-text-o", class:"table-header-layer-1"},
                             {colspan:'17',value: '运输信息',font:"fa fa-truck", class:"table-header-layer-1"},
-                            {colspan:couLen,value: '收费信息',font:"fa fa-rmb", class:"table-header-layer-1"},
-                            @can('运输管理-运单-删除'){colspan:'1',value: '',font:"", class:"table-header-layer-1"},@endcan
+                            {colspan:'5',value: '收费信息',font:"fa fa-rmb", class:"table-header-layer-1"},
+                                @can('运输管理-运单-删除'){colspan:'1',value: '',font:"", class:"table-header-layer-1"},@endcan
                         ],
                     }).init();
                 },