where('status',1)->whereDate('created_at',$date)->orderBy('id')->get(); foreach($refunds as $key=>$val){ $sub_mchid=Store::withTrashed()->where('is_failure',0)->where('id',$val->store_id)->value('sub_mchid'); $withdraw_id=$val->transaction_id; $out_request_no=$val->order_no; $url='https://api.mch.weixin.qq.com/v3/ecommerce/fund/withdraw/'.$withdraw_id.'?sub_mchid='.$sub_mchid;//查询地址 // $url='https://api.mch.weixin.qq.com/v3/ecommerce/fund/withdraw/out-request-no/'.$out_request_no.'?sub_mchid='.$sub_mchid; $merchant_id=config('wechat.payment.default.mch_id');//商户号 $serial_no=config('wechat.payment.default.serial_no');//不是平台证书序列号 $mch_private_key=$handle->getPublicKey();//读取商户api证书公钥 getPublicKey()获取方法 见下文 $timestamp=time();//时间戳 $nonce=$handle->nonce_str();//随机字符串 $body=""; $sign=$handle->sign($url,'GET',$timestamp,$nonce,$body,$mch_private_key,$merchant_id,$serial_no);//签名 $header=[ 'Authorization:WECHATPAY2-SHA256-RSA2048 ' . $sign, 'Accept:application/json', 'User-Agent:' . $merchant_id, 'Content-Type:application/json', 'Wechatpay-Serial:' . $handle->getzhengshu()//获取平台证书序列号 ]; $result=$handle->curl($url,'',$header,'GET'); $result=json_decode($result,true); // log::info('ssss---ssss---ssss---ssss'); if($val->status_code<>$result['status']){ Log::info('提现5状态有误:'.$val->store_id.'---'.$val->order_no.'---'.$result['status']); Store::withTrashed()->where('is_failure',0)->where('id',$val->store_id)->decrement('withdrawal',$val->money); if($result['status']=='FAIL' ||$result['status']=='REFUND' ||$result['status']=='CLOSE'){ $reason=$result['reason']; }else{ $reason=null; } Amount::where('transaction_id',$withdraw_id) ->update([ 'status'=>0, 'status_code'=>$result['status'], 'reason'=>$reason ]); } } } }