procurement=$procurement; LogService::log(__METHOD__," __construct",json_encode($this->procurement)); } /** * Execute the job. * * @return void */ 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)); $open_ids=[]; foreach ($suppliers as $supplier) { foreach ($supplier->user as $user){ $open_id = $user->userDetail->procurement_wechat_open_id ?? false; if($open_id)$open_ids[]=$open_id; } } $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'] =[ "appid"=>config('weiXin.fuWuHao.appId'), "template_id"=>config('weiXin.fuWuHaoTemplate.order_confirm_inform'), "url"=>"http://weixin.qq.com/download", "miniprogram"=>[ "appid"=>config('weiXin.appId.appId'), "pagepath"=>"pages/login/login" ], 'data'=>[ 'first' => [ "value"=>"尊敬的供应商,你好!", ], 'keyword1' => [ "value"=>$pro->code ?? '', "color"=>"#173177" ], 'keyword2' => [ "value"=>$pro->ownerMaterial->owner->customer->company_name ?? '', "color"=>"#173177" ], 'remark' => [ "value"=>'请及时确认,谢谢。', ], ] ]; LogService::log(__METHOD__,"模板信息3",json_encode($param)); app(ProcurementWeiXinSendMessageService::class)->sendWenChantTemplate($param); } } }