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

包裹异常修改与权限
异常状态判断优化

ANG YU 5 лет назад
Родитель
Сommit
865b63f497

+ 5 - 0
app/Http/Controllers/PackageLogisticController.php

@@ -32,4 +32,9 @@ class PackageLogisticController extends Controller
         $owners = Owner::find($owner_ids);
         return view('package.logistic.index', compact('orderPackages', 'logistics', 'owners', 'paginateParams'));
     }
+
+    public function update(Request $request)
+    {
+        OrderPackage::query()->where('id',$request['id'])->update($request->only('exception_type'));
+    }
 }

+ 8 - 16
app/Jobs/LogisticZopSync.php

@@ -86,7 +86,7 @@ class LogisticZopSync implements ShouldQueue
             $resultItem['status'] = null;
             $resultItem['transfer_status'] = [];
         }
-        $resultItem = $this->setExceptionType($resultItem, $lastRoute->scanDate / 1000);
+        $resultItem = $this->setExceptionType($resultItem, $lastRoute?$lastRoute->scanDate / 1000:null);
         if ($resultItem['status'] == null) {
             unset($resultItem['status']);
             unset($resultItem['transfer_status']);
@@ -175,7 +175,6 @@ class LogisticZopSync implements ShouldQueue
             $conclusion |= ($last_routed_duration > $SENDING_RESPONSE_HOURS && $data['status'] == '派送中') ? $IS_SENDING_NO_RESPONSE : 0;
             return $conclusion;
         })();
-//        dd($conclusion,$IS_ROUTED | $IS_IN_VALID_TIME| $IS_WEIGHED|$IS_SENDING|$IS_SENDING_NO_RESPONSE);
         switch ($conclusion) {
             case $IS_IN_VALID_TIME:
                 $data['exception_type'] = '疑似库内丢件';
@@ -183,28 +182,21 @@ class LogisticZopSync implements ShouldQueue
             case $IS_IN_VALID_TIME | $IS_WEIGHED:
                 $data['exception_type'] = '揽件异常';
                 break;
-
             case $IS_ROUTED | $IS_IN_VALID_TIME | $IS_SHORT_NO_RESPONSE:
-            case $IS_ROUTED | $IS_IN_VALID_TIME | $IS_SHORT_NO_RESPONSE |$IS_WEIGHED:
+            case $IS_ROUTED | $IS_IN_VALID_TIME | $IS_SHORT_NO_RESPONSE | $IS_WEIGHED:
                 $data['exception_type'] = '中转异常';
                 break;
-            case $IS_ROUTED | $IS_IN_VALID_TIME| $IS_LONG_NO_RESPONSE:
-            case $IS_ROUTED | $IS_IN_VALID_TIME| $IS_LONG_NO_RESPONSE|$IS_WEIGHED:
+            case $IS_ROUTED | $IS_IN_VALID_TIME | $IS_LONG_NO_RESPONSE:
+            case $IS_ROUTED | $IS_IN_VALID_TIME | $IS_LONG_NO_RESPONSE | $IS_WEIGHED:
                 $data['exception_type'] = '疑似丢件';
                 break;
-            case $IS_ROUTED | $IS_IN_VALID_TIME|$IS_SENDING|$IS_SENDING_NO_RESPONSE:
-            case $IS_ROUTED | $IS_IN_VALID_TIME|$IS_SENDING|$IS_SENDING_NO_RESPONSE|$IS_WEIGHED:
-            case $IS_ROUTED | $IS_IN_VALID_TIME|$IS_SENDING|$IS_SENDING_NO_RESPONSE|$IS_WEIGHED|$IS_SHORT_NO_RESPONSE:
-            case $IS_ROUTED | $IS_IN_VALID_TIME|$IS_SENDING|$IS_SENDING_NO_RESPONSE|$IS_WEIGHED|$IS_SHORT_NO_RESPONSE|$IS_LONG_NO_RESPONSE:
-            case $IS_ROUTED | $IS_IN_VALID_TIME|$IS_SENDING|$IS_SENDING_NO_RESPONSE|$IS_WEIGHED|$IS_LONG_NO_RESPONSE:
-            case $IS_ROUTED | $IS_IN_VALID_TIME|$IS_SENDING|$IS_SENDING_NO_RESPONSE|$IS_SHORT_NO_RESPONSE|$IS_LONG_NO_RESPONSE:
-            case $IS_ROUTED | $IS_IN_VALID_TIME|$IS_SENDING|$IS_SENDING_NO_RESPONSE|$IS_SHORT_NO_RESPONSE:
-            case $IS_ROUTED | $IS_IN_VALID_TIME|$IS_SENDING|$IS_SENDING_NO_RESPONSE|$IS_LONG_NO_RESPONSE:
-            $data['exception_type'] = '派件异常';
-                break;
             default:
                 break;
         }
+        if($conclusion
+            ==($conclusion | $IS_ROUTED | $IS_IN_VALID_TIME | $IS_SENDING | $IS_SENDING_NO_RESPONSE)){
+            $data['exception_type'] = '派件异常';
+        }
         switch ($conclusion) {
             case $IS_IN_VALID_TIME:
             case $IS_IN_VALID_TIME | $IS_WEIGHED:

+ 1 - 1
app/OrderPackage.php

@@ -23,7 +23,7 @@ class OrderPackage extends Model
     use ModelTimeFormat;
 
     protected $fillable = ['order_id','logistic_number','batch_number',
-        'batch_rule','bulk','weight','length','width','height','paper_box_id','measuring_machine_id','weighed_at','status','sent_at','received_at','exception','transfer_status','remark','owner_id','uploaded_to_wms'];
+        'batch_rule','bulk','weight','length','width','height','paper_box_id','measuring_machine_id','weighed_at','status','sent_at','received_at','exception','transfer_status','remark','owner_id','uploaded_to_wms','exception_type'];
 
     public function order(){
         return $this->belongsTo('App\Order','order_id','id');

+ 6 - 10
app/Services/LogisticSFService.php

@@ -312,19 +312,15 @@ xml;
             case $IS_ROUTED | $IS_IN_VALID_TIME | $IS_LONG_NO_RESPONSE | $IS_WEIGHED:
                 $data['exception_type'] = '疑似丢件';
                 break;
-            case $IS_ROUTED | $IS_IN_VALID_TIME | $IS_SENDING | $IS_SENDING_NO_RESPONSE:
-            case $IS_ROUTED | $IS_IN_VALID_TIME | $IS_SENDING | $IS_SENDING_NO_RESPONSE | $IS_WEIGHED:
-            case $IS_ROUTED | $IS_IN_VALID_TIME | $IS_SENDING | $IS_SENDING_NO_RESPONSE | $IS_WEIGHED | $IS_SHORT_NO_RESPONSE:
-            case $IS_ROUTED | $IS_IN_VALID_TIME | $IS_SENDING | $IS_SENDING_NO_RESPONSE | $IS_WEIGHED | $IS_SHORT_NO_RESPONSE | $IS_LONG_NO_RESPONSE:
-            case $IS_ROUTED | $IS_IN_VALID_TIME | $IS_SENDING | $IS_SENDING_NO_RESPONSE | $IS_WEIGHED | $IS_LONG_NO_RESPONSE:
-            case $IS_ROUTED | $IS_IN_VALID_TIME | $IS_SENDING | $IS_SENDING_NO_RESPONSE | $IS_SHORT_NO_RESPONSE | $IS_LONG_NO_RESPONSE:
-            case $IS_ROUTED | $IS_IN_VALID_TIME | $IS_SENDING | $IS_SENDING_NO_RESPONSE | $IS_SHORT_NO_RESPONSE:
-            case $IS_ROUTED | $IS_IN_VALID_TIME | $IS_SENDING | $IS_SENDING_NO_RESPONSE | $IS_LONG_NO_RESPONSE:
-                $data['exception_type'] = '派件异常';
-                break;
             default:
                 break;
         }
+
+        if($conclusion
+            ==($conclusion | $IS_ROUTED | $IS_IN_VALID_TIME | $IS_SENDING | $IS_SENDING_NO_RESPONSE)){
+            $data['exception_type'] = '派件异常';
+        }
+
         switch ($conclusion) {
             case $IS_IN_VALID_TIME:
             case $IS_IN_VALID_TIME | $IS_WEIGHED:

+ 36 - 0
database/migrations/2021_04_12_144644_add_authority_update_order_packages_exception_type.php

@@ -0,0 +1,36 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class AddAuthorityUpdateOrderPackagesExceptionType extends Migration
+{
+
+    protected $authorities = [
+        "包裹管理-快递-异常类型-编辑",
+    ];
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        foreach ($this->authorities as $authority){
+            \App\Authority::query()->firstOrCreate(["name"=>$authority],["name"=>$authority,"alias_name"=>$authority]);
+        }
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        foreach ($this->authorities as $authority){
+            \App\Authority::query()->where('name', $authority)->delete();
+        }
+    }
+}

+ 31 - 1
resources/views/package/logistic/index.blade.php

@@ -10,6 +10,8 @@
             <div id="form_div"></div>
             <table class="table table-striped table-sm text-nowrap table-hover">
                 <tr>
+                    <th>异常类型修改</th>
+                    <th>序号</th>
                     <th>单号</th>
                     <th>状态</th>
                     <th>快递公司</th>
@@ -19,10 +21,19 @@
                     <th>称重日期</th>
                     <th>异常标记</th>
                     <th>异常说明</th>
+                    <th>异常类型</th>
                     <th>快递路由</th>
                     <th>客服备注</th>
                 </tr>
                 <tr v-for="(package,i) in packages" @click="selectTr===i+1?selectTr=0:selectTr=i+1" :class="selectTr===i+1?'focusing' : ''">
+                    <td>
+                        <select v-model="package.exception_type" @change="package.showEditButton = true">
+                            <option :disabled="!exception_editable" v-for="(value,index) in exception_types" :value="value" :name="value" :key="index">@{{ value }}</option>
+                        </select>
+                        <button class="btn btn-info btn-sm text-white mr-1" @click="updateExceptionType(package)" v-if="package.showEditButton">
+                            更新状态</button>
+                    </td>
+                    <td>@{{ i+1 }}</td>
                     <td>@{{ package.logistic_number }}</td>
                     <td>@{{ package.status }}</td>
                     <td>@{{ package.order != null  ? package.order.logistic.name : '#' }}</td>
@@ -32,6 +43,7 @@
                     <td>@{{ package.weighed_at }}</td>
                     <td>@{{ package.exception }}</td>
                     <td>@{{ package.exception_message }}</td>
+                    <td>@{{ package.exception_type }}</td>
                     <td>
                         <div v-if="package.transfer_status && package.transfer_status.length>0" class="text-overflow-warp-200 up" :id="'route-'+i">
                             <p v-for="route in package.transfer_status">
@@ -83,7 +95,18 @@
                     @endforeach
                 ],
                 showList: {},
-                selectTr: 0
+                selectTr: 0,
+                exception_types: [
+                    '疑似库内丢件',
+                    '揽件异常',
+                    '中转异常',
+                    '疑似丢件',
+                    '派件异常',
+                    '其他',
+                    '无',
+                ],
+                exception_editable: @can('包裹管理-快递-异常类型-编辑') true @else false  @endcan,
+                selectedExceptionType: '修改异常类型'
             },
             created() {
                 $.each(this.packages, function (index, item) {
@@ -198,6 +221,13 @@
                     }
                     this.$forceUpdate();
                 },
+                updateExceptionType(orderPackages) {
+                    let  url = '{{ url("package/logistic") }}' +'/'+ orderPackages.id;
+                    let data =  {id:orderPackages['id'],exception_type: orderPackages.exception_type}
+                    axios.patch(url, data).then((res)=>{
+                        window.tempTip.showSuccess('异常状态修改成功');
+                    });
+                }
             },
             filters: {
                 toObjected: function (value) {