Zhouzhendong 4 лет назад
Родитель
Сommit
9400a93c0c

+ 1 - 1
app/Http/Controllers/RejectedController.php

@@ -322,7 +322,7 @@ class RejectedController extends Controller
     {
         if(!Gate::allows('退货管理-编辑')){return ['success'=>'false','fail_info'=>"没有权限"];   }
         $ids=$request->input('ids')??'';
-        $rejecteds=RejectedBill::whereIn('id',$ids)->get();
+        $rejecteds=RejectedBill::whereIn('id',$ids)->where("is_finished",false)->get();
         $rejecteds->each(function($rejected){
             $rejected['is_finished']=true;
             $re=$rejected->update();

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

@@ -565,4 +565,14 @@ SQL;
         if (count($tasks)==1)$result["lots"] = $tasks[0]->fmlotnum;
         $this->success($result);
     }
+
+    /**
+     * 改变ASN许可规则
+     */
+    public function changeAsnRule()
+    {
+        $ids = request("ids");
+        $val = request("val");
+        $this->success(Owner::query()->whereIn("id",$ids)->update(["is_check_asn"=>$val ? 0 : 1]));
+    }
 }

+ 3 - 1
app/Http/Controllers/StoreController.php

@@ -19,6 +19,7 @@ use Illuminate\Http\RedirectResponse;
 use Illuminate\Http\Request;
 use Illuminate\Http\Response;
 use Illuminate\Routing\Redirector;
+use Illuminate\Support\Facades\Auth;
 use Illuminate\Support\Facades\DB;
 use Illuminate\Support\Facades\Gate;
 use Illuminate\Support\Facades\Validator;
@@ -35,7 +36,8 @@ class StoreController extends Controller
         $storeService=app(StoreService::class);
         $stores=$storeService->paginate($request->input());
         $warehouses=Warehouse::query()->get();
-        $owners=app("OwnerService")->getIntersectPermitting();
+        $ownerIds=app('UserService')->getPermittingOwnerIds(Auth::user());
+        $owners=Owner::query()->select(["id","name","is_check_asn"])->whereIn('id', $ownerIds)->whereNull('deleted_at')->get();
         return view('store.inStorage.index',compact('stores','warehouses','owners','paginateParams'));
     }
     /**

+ 2 - 1
app/Http/Controllers/TestController.php

@@ -10,6 +10,7 @@ use App\MaterialBoxModel;
 use App\Owner;
 use App\OwnerFeeDetail;
 use App\OwnerPriceOperation;
+use App\RejectedBill;
 use Illuminate\Http\Request;
 use Illuminate\Support\Facades\DB;
 use Illuminate\Support\Facades\Http;
@@ -45,7 +46,7 @@ class TestController extends Controller
     }
     public function test()
     {
-        dd(date("Y-m-d",1622908800));
+        dd(RejectedBill::query()->where("is_finished",false)->count());
     }
 
 }

+ 3 - 5
app/Jobs/RejectedBillCreateInstantBill.php

@@ -2,17 +2,16 @@
 
 namespace App\Jobs;
 
+use App\Components\ErrorPush;
 use App\RejectedBill;
-use App\Services\LogService;
 use Illuminate\Bus\Queueable;
 use Illuminate\Contracts\Queue\ShouldQueue;
 use Illuminate\Foundation\Bus\Dispatchable;
 use Illuminate\Queue\InteractsWithQueue;
-use Illuminate\Queue\SerializesModels;
 
 class RejectedBillCreateInstantBill implements ShouldQueue
 {
-    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
+    use Dispatchable, InteractsWithQueue, Queueable, ErrorPush;
 
     protected $rejected;
     /**
@@ -38,8 +37,7 @@ class RejectedBillCreateInstantBill implements ShouldQueue
         try{
             app("RejectedBillService")->buildInstantBill($this->rejected);
         }catch(\Exception $exception){
-            LogService::log(__CLASS__,"退货单建立即时账单",$exception->getMessage()." | ".json_encode($this->rejected));
-            throw new \Exception($e->getMessage());
+            $this->push(__METHOD__."->".__LINE__,"退货单建立即时账单",$exception->getMessage()." | ".json_encode($this->rejected));
         }
     }
 }

+ 6 - 1
app/Owner.php

@@ -38,7 +38,8 @@ class Owner extends Model
         "relevance",            //关联模型的JSON数组
         'subjection',           //主体公司
         'is_tax_exist',         //是否必填税率
-        'model_sequence'        //调箱序列(优先级匹配)
+        'model_sequence',       //调箱序列(优先级匹配)
+        'is_check_asn'          //是否校验ASN(收货时检查此项)
     ];
     //relevance说明 0:仓储 1:作业 2:快递 3:物流 4:直发 5:系统 存储示例:["0","1"]存在仓储与作业计费
     protected $casts = [
@@ -49,6 +50,10 @@ class Owner extends Model
         1 => "宝时物流",
         2 => "宝时供应链",
     ];
+    const IS_CHECK_ASN=[
+        0 => "否",
+        1 => "是"
+    ];
 
     public static function filterAuthorities(){
         $user=Auth::user();

+ 4 - 5
app/Services/common/BatchUpdateService.php

@@ -3,15 +3,14 @@
 
 namespace App\Services\common;
 
-
-use App\Services\LogService;
+use App\Components\ErrorPush;
 use Illuminate\Support\Facades\DB;
 use App\Traits\ServiceAppAop;
 
 
 class BatchUpdateService
 {
-    use ServiceAppAop;
+    use ServiceAppAop,ErrorPush;
     public function batchUpdate($tableName = '', $multipleData = array(), $connection = 'mysql')
     {
         if (count($multipleData) == 1) {
@@ -76,7 +75,7 @@ class BatchUpdateService
             }
             return $bool;
         } catch (\Exception $e) {
-            app('LogService')->log(__METHOD__, __FUNCTION__, '批量更新失败' . $tableName . ' | '.json_encode($multipleData).' | 溯源:'.json_encode($debug) . $e->getMessage() . $e->getTraceAsString());
+            $this->push(__METHOD__."->".__LINE__,"批量更新失败",$tableName . ' | '.json_encode($multipleData).' | 溯源:'.json_encode($debug) . $e->getMessage() . $e->getTraceAsString());
             return false;
         }
     }
@@ -94,7 +93,7 @@ class BatchUpdateService
             app('LogService')->log(__METHOD__, __FUNCTION__, '批量更新本身' .$sql);
             return $bool;
         }catch (\Exception $e){
-            app('LogService')->log(__METHOD__, __FUNCTION__, '批量更新失败 SQL:(' . $sql .") 堆栈:". $e->getMessage() . $e->getTraceAsString());
+            $this->push(__METHOD__."->".__LINE__,"批量更新失败",'SQL:(' . $sql .") 堆栈:". $e->getMessage() . $e->getTraceAsString() . $e->getMessage() . $e->getTraceAsString());
             return false;
         }
     }

+ 32 - 0
database/migrations/2021_08_04_140019_change_owners_table_change_is_check_asn_column.php

@@ -0,0 +1,32 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class ChangeOwnersTableChangeIsCheckAsnColumn extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('owners', function (Blueprint $table) {
+            $table->tinyInteger("is_check_asn")->default(0)->comment("是否校验ASN");
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('owners', function (Blueprint $table) {
+            $table->dropColumn("is_check_asn");
+        });
+    }
+}

+ 50 - 0
resources/views/store/inStorage/_settingAsnRule.blade.php

@@ -0,0 +1,50 @@
+<div class="modal fade" tabindex="-1" role="dialog" id="modal">
+    <div class="modal-dialog modal-lg modal-dialog-centered modal-dialog-scrollable">
+        <div class="modal-content">
+            <div class="modal-header">
+                <div class="font-weight-bold h4">ASN规则</div>
+                <button type="button" class="close" data-dismiss="modal">&times;</button>
+            </div>
+            <div class="modal-body row">
+                <div class="col-5 h-100 card p-0">
+                    <div class="card-header">
+                        <div class="custom-control custom-checkbox">
+                            <input type="checkbox" class="custom-control-input" id="owner" @change="selectAll(false)">
+                            <label class="custom-control-label" for="owner">未设定货主</label>
+                        </div>
+                    </div>
+                    <div class="card-body list-group p-0 overflow-y-scrollbar-200">
+                        <div class="list-group-item" v-for="owner in owners" v-if="!owner.is_show">
+                            <div class="custom-control custom-checkbox">
+                                <input type="checkbox" class="custom-control-input" :id="'owner-'+owner.name" v-model="owner.is_check_asn">
+                                <label class="custom-control-label" :for="'owner-'+owner.name">@{{ owner.value }}</label>
+                            </div>
+                        </div>
+                    </div>
+                </div>
+                <div class="col-2 d-flex align-items-center h-100">
+                    <div class="w-100 text-center cursor-pointer">
+                        <span class="fa fa-angle-double-right fa-3x w-100" @click="changeAsnRule(false)"></span>
+                        <span class="fa fa-angle-double-left fa-3x w-100" @click="changeAsnRule(true)"></span>
+                    </div>
+                </div>
+                <div class="col-5 h-100 card p-0">
+                    <div class="card-header">
+                        <div class="custom-control custom-checkbox">
+                            <input type="checkbox" class="custom-control-input" id="ownerNo" @change="selectAll(true)">
+                            <label class="custom-control-label" for="ownerNo">已设定货主</label>
+                        </div>
+                    </div>
+                    <div class="card-body list-group p-0 overflow-y-scrollbar-200">
+                        <div class="list-group-item" v-for="owner in owners" v-if="owner.is_show">
+                            <div class="custom-control custom-checkbox">
+                                <input type="checkbox" class="custom-control-input" :id="'owner-'+owner.name" v-model="owner.is_check_asn">
+                                <label class="custom-control-label" :for="'owner-'+owner.name">@{{ owner.value }}</label>
+                            </div>
+                        </div>
+                    </div>
+                </div>
+            </div>
+        </div>
+    </div>
+</div>

+ 25 - 2
resources/views/store/inStorage/index.blade.php

@@ -6,6 +6,7 @@
         <div id="form_div"></div>
         <div class="ml-2">
             <button class="btn btn-sm btn-primary" @click="syncStorage()">同步FLUX部分库存</button>
+            <button class="btn btn-sm btn-outline-info" @click="settingAsnRule()">设定ASN收货规则</button>
         </div>
         <table class="table table-striped table-sm text-nowrap table-hover td-min-width-80" id="table">
             <tr v-for="(store,i) in stores" :id="'data-'+store.id" @click="selectTableRow(i,$event)">
@@ -53,6 +54,7 @@
                             </td>
                         </tr>
         </table>
+        @include("store.inStorage._settingAsnRule")
         <div class="text-info h5 btn btn">{{$stores->count()}}/{{$stores->total()}}</div>
         <div>{{$stores->appends($paginateParams)->links()}}</div>
     </div>
@@ -71,8 +73,8 @@
                     @endforeach
                 ],
                 owners:[
-                        @foreach($owners as $owner)
-                    {name:'{{$owner->id}}',value:'{{$owner->name}}'},
+                    @foreach($owners as $owner)
+                    {name:'{{$owner->id}}',value:'{{$owner->name}}',is_show:Boolean({!! $owner->is_check_asn !!})},
                     @endforeach
                 ],
                 warehouses:[
@@ -163,6 +165,27 @@
                         })
                     })
                 },
+                settingAsnRule(){
+                    $("#modal").modal("show");
+                },
+                selectAll(show){
+                    let val = event.target.checked;
+                    this.owners.forEach((owner,index)=>{
+                        if (owner.is_show===show)this.$set(this.owners[index],"is_check_asn",val);
+                    })
+                },
+                changeAsnRule(show){
+                    let pool = [];
+                    this.owners.forEach((owner,index)=>{
+                        if (owner.is_show===show && owner.is_check_asn){
+                            owner.is_show = !owner.is_show;
+                            owner.is_check_asn = !owner.is_check_asn;
+                            this.$set(this.owners,index,owner);
+                            pool.push(owner.name);
+                        }
+                    });
+                    window.tempTip.postBasicRequest("{{url('store/inStorage/changeAsnRule')}}",{ids:pool,val:show},()=>{});
+                }
             }
         });
     </script>

+ 1 - 0
routes/web.php

@@ -488,6 +488,7 @@ Route::group(['middleware'=>'auth'],function ($route){
             Route::post('searchAsn','StorageController@searchAsn');
             Route::post('settingCommodityMaximum','StorageController@settingCommodityMaximum');
             Route::post('checkTask','StorageController@checkTask');
+            Route::post('changeAsnRule','StorageController@changeAsnRule');
         });
         Route::group(['prefix'=>'handInStorage'],function() {
             Route::get('receive',function (){return view('store.handInStorage.receive');});//收货页面