Преглед изворни кода

去除队列日志,添加采购单权限

hu hao пре 5 година
родитељ
комит
f1caf622c6

+ 0 - 3
app/Http/Controllers/ProcurementController.php

@@ -150,10 +150,7 @@ class ProcurementController extends Controller
         $procurementService=app(ProcurementService::class);
         $deadline=$procurementService->computeDeadline($procurement->created_at);
         $procurement->update(['code'=>$procurement_code,'deadline'=>$deadline]);
-        LogService::log(__METHOD__,"进入发送模板队列start",json_encode($procurement));
         dispatch(new ProcurementConfirmInform($procurement));  //推送发送订单通知消息模板  队列
-//        ProcurementConfirmInform::dispatch($procurement);
-        LogService::log(__METHOD__,"进入发送模板队列end",json_encode($procurement));
         $procurement = $procurement->loadMissing(['initiator','ownerMaterial.material','ownerMaterial.owner.customer','ownerMaterial.file','supplier']);
         if ($procurement) return ['success' => true,'data' => $procurement];
         else return ['success' => false, 'message' => '添加失败'];

+ 0 - 4
app/Http/Controllers/TestController.php

@@ -1265,8 +1265,4 @@ where purch.islower=1 and deliver.id>'.$id);
         }
         ProcurementCheckSheet::query()->insert($insert_);
     }
-    public function test111(){
-
-        dd(  Carbon::parse(1618826299)->toDateTimeString());
-    }
 }

+ 8 - 0
app/Http/Controllers/api/thirdPart/weixin/ProcurementController.php

@@ -114,10 +114,14 @@ class ProcurementController extends Controller
     //生产中的订单
     public function getProductionProcurement(): \Illuminate\Http\JsonResponse
     {
+        /**@var SupplierService $supplierService*/
+        $supplierService=app(SupplierService::class);
+        $supplier_ids=$supplierService->screenSupplierIds();
         $procurements=Procurement::query()
             ->with('ownerMaterial.material')
             ->whereIn('type',[0,2])
             ->where('status',4) //4:生产中
+            ->whereIn('supplier_id',$supplier_ids)
             ->get();
         if ($procurements) return $this->success($procurements);
     }
@@ -131,9 +135,13 @@ class ProcurementController extends Controller
 
     public function getProcurementDeliveries(): \Illuminate\Http\JsonResponse
     {
+        /**@var SupplierService $supplierService*/
+        $supplierService=app(SupplierService::class);
+        $supplier_ids=$supplierService->screenSupplierIds();
         $procurementDeliveries=ProcurementDeliverie::query()
             ->with('procurement.ownerMaterial.material')
             ->whereIn('status',[0,1])//1:待送货,2:送货中
+            ->whereIn('supplier_id',$supplier_ids)
             ->get();
         $procurementDeliveries=$procurementDeliveries->filter(function ($item){
             return isset($item->procurement);

+ 1 - 10
app/Jobs/ProcurementConfirmInform.php

@@ -3,7 +3,6 @@
 namespace App\Jobs;
 
 use App\Procurement;
-use App\Services\LogService;
 use App\Services\ProcurementWeiXinSendMessageService;
 use Illuminate\Bus\Queueable;
 use Illuminate\Contracts\Queue\ShouldQueue;
@@ -25,7 +24,6 @@ class ProcurementConfirmInform implements ShouldQueue
     public function __construct(Procurement $procurement)
     {
         $this->procurement=$procurement;
-        LogService::log(__METHOD__," __construct",json_encode($this->procurement));
     }
 
     /**
@@ -35,14 +33,9 @@ class ProcurementConfirmInform implements ShouldQueue
      */
     public function handle()
     {
-        LogService::log(__METHOD__,"log procurement",json_encode($this->procurement));
         $pro=$this->procurement->loadMissing(['ownerMaterial.material.supplier.user.userDetail','ownerMaterial.owner.customer']);
         $suppliers=$pro->ownerMaterial->material->supplier ?? false;
-        if(!$suppliers){
-            LogService::log(__METHOD__,"suppliers not find ",json_encode($this->procurement['id']));
-            return ;
-        }
-        LogService::log(__METHOD__,"采购单耗材关联供应商1",json_encode($suppliers));
+        if(!$suppliers) return ;
         $open_ids=[];
         foreach ($suppliers as $supplier) {
             foreach ($supplier->user as $user){
@@ -51,7 +44,6 @@ class ProcurementConfirmInform implements ShouldQueue
             }
         }
         $open_ids=array_unique($open_ids);
-        LogService::log(__METHOD__,"发送用户openid2",json_encode($open_ids));
         foreach ($open_ids as $open_id){
             $param['touser'] =$open_id;
             $param['mp_template_msg'] =[
@@ -79,7 +71,6 @@ class ProcurementConfirmInform implements ShouldQueue
                     ],
                 ]
             ];
-            LogService::log(__METHOD__,"模板信息3",json_encode($param));
             app(ProcurementWeiXinSendMessageService::class)->sendWenChantTemplate($param);
         }
 

+ 14 - 0
app/Procurement.php

@@ -96,4 +96,18 @@ class Procurement extends Model
 //            }
 //        }
 //    }
+//    protected static function booted()
+//    {
+//        /** @var User $user */
+//        $user = Auth::user();
+//        if ($user && !$user->isSuperAdmin()) {
+//            /** @var \stdClass $user */
+//            $ids = array_column(DB::select(DB::raw("SELECT supplier_id FROM supplier_user WHERE user_id = ?"),[$user->id]),"supplier_id");
+//            if (count($ids)>0){
+//                static::addGlobalScope('supplier', function (Builder $builder)use ($ids) {
+//                    $builder->whereIn('supplier_id',$ids);
+//                });
+//            }
+//        }
+//    }
 }

+ 0 - 1
app/Services/ProcurementWeiXinSendMessageService.php

@@ -61,7 +61,6 @@ class ProcurementWeiXinSendMessageService
         curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
         $output = curl_exec($curl);
         curl_close($curl);
-        LogService::log(__METHOD__,"模板信息4",json_encode($output));
         return $output;
     }