vipdhf

vipdhf

这家伙有点懒,还没写个性签名!

  • 财富值100
  • 威望值10
  • 总积分410

个人信息

  • 回复了 的评论

    请问下大哥,统一下单配置里 notify_url 设置了

                'body' => '加油',
                'detail' => '加油',
                'trade_type' => 'JSAPI',
                'out_trade_no' => $out_trade_no,
                'total_fee' => 1, // 单位:分
                'notify_url' => 'http://xxx.xxxx.com/weixin/notify-callback',
                //'attach' => '加油',
                'spbill_create_ip' => Yii::$app->request->getUserIP(),
                'openid' => $info->id,
                'sub_mch_id' => $merchant->weixinsellerid,
                //'sub_appid'=> Yii::$app->params['WECHAT']['app_id'],
            ];
    

    然后在

     public function actionNotifyCallback()
        {
            $response = Yii::$app->wechat->payment->handleNotify(function ($notify, $successful) {
                // 使用通知里的 "微信支付订单号" 或者 "商户订单号" 去自己的数据库找到订单
                $order = MarketOrder::find()->where(['orderno' => $notify->out_trade_no])->one();
                if (!$order) { // 如果订单不存在
                    return 'Order not exist.'; // 告诉微信,我已经处理完了,订单没找到,别再通知我了
                }
                // 如果订单存在
                // 检查订单是否已经更新过支付状态
                if ($order->status == 1) { // 假设订单字段“支付时间”不为空代表已经支付
                    return true; // 已经支付成功了就不再更新了
                }
                // 用户是否支付成功
                if ($successful) {
                    // 不是已经支付状态则修改为已经支付状态
                    $order->create_at = time(); // 更新支付时间为当前时间
                    $order->status = 1;
                } else { // 用户支付失败
                    $order->status = 2;
                }
                $order->save(false); // 保存订单
                return true; // 返回处理完成
            });
            $response->send();
        }
    

    为什不能通知,操作我后端相关业务

    最后怎么解决的?

  • 2018-06-04 已签到
    连续签到1天,获得了5个金钱
  • 发布了话题
    Fatal error: require(): Failed opening required
  • 回复了 的评论

    yii2 整合smarty 'cachePath' => '@runtime/Smarty/cache' 但是 没有生成cache文件 为啥?

    程序运行起来后,会自动生成对应的文件夹及文件。

  • 2017-07-18 已签到
    连续签到1天,获得了5个金钱
  • 回复了 的回答
    public function outreport($result){
    	ob_start();
    	// Include the main TCPDF library (search for installation path).
    	vendor('Pdf.tcpdf');
    
    	//实例化
    	$pdf = new \TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
    
    	// 设置文档信息 
    	$pdf->SetCreator(PDF_CREATOR);
    	$pdf->SetAuthor('Nicola Asuni');
    	$pdf->SetTitle('TCPDF Example 001');
    	$pdf->SetSubject('TCPDF Tutorial');
    	$pdf->SetKeywords('TCPDF, PDF, example, test, guide');
    
    	// 设置页眉和页脚信息
    	$pdf->SetHeaderData('', '', '电脑人机工程评估报告', '', array(0,64,255), array(0,64,128));
    	$pdf->setFooterData(array(0,64,0), array(0,64,128));
    
    	// 设置页眉和页脚字体 
    	$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
    	$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
    
    	// 设置默认等宽字体 
    	$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
    
    	// 设置间距 
    	$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
    	$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
    	$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
    
    	// 设置分页 
    	$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
    
    	// set image scale factor
    	$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
    
    	// set some language-dependent strings (optional)
    	if (@file_exists(dirname(__FILE__).'/lang/eng.php')) {
    		require_once(dirname(__FILE__).'/lang/eng.php');
    		$pdf->setLanguageArray($l);
    	}
    
    	// ---------------------------------------------------------
    
    	// set default font subsetting mode
    	$pdf->setFontSubsetting(true);
    
    	//设置字体 
    	$pdf->SetFont('dejavusans', '', 14, '', true);
    	$pdf->SetFont('stsongstdlight', '', 10);
    
    	// Add a page
    	// This method has several options, check the source code documentation for more information.
    	$pdf->AddPage();
    
    	// set text shadow effect
    	$pdf->setTextShadow(array('enabled'=>true, 'depth_w'=>0.2, 'depth_h'=>0.2, 'color'=>array(196,196,196), 'opacity'=>1, 'blend_mode'=>'Normal'));
    
    	// 内容
    	$html =$result['report'];
    
    	// Print text using writeHTMLCell()
    	$pdf->writeHTMLCell(0, 0, '', '', $html, 0, 1, 0, true, '', true);
    
    	// ---------------------------------------------------------
    
    	// Close and output PDF document
    	// This method has several options, check the source code documentation for more information.
    	$dtime = date('Y-m-d');
    	$pdf->Output($dtime.'.pdf', 'I');
    
    	//============================================================+
    	// END OF FILE
    	//============================================================+
    		}
    }
    

    刚刚修改了,修改了config配置:SetHeaderData里中文的解决方法为:tcpdf\config\tcpdf_config.php

    define (‘PDF_FONT_NAME_MAIN’, ’helvetica’);
    
    改为define (‘PDF_FONT_NAME_MAIN’, ’stsongstdlight’);
    
    define (‘PDF_FONT_NAME_DATA’, ’helvetica’);
    
    改为define (‘PDF_FONT_NAME_DATA’, ’stsongstdlight’);
    
  • 回复了 的回答

    我还以为你想吃栗子

    是不是邪恶了

  • 回复了 的回答

    有报错信息没的阿,出啥问题了阿!

    开始用的mpdf,类里面的方法不对,真是郁闷

  • 回复了 的回答
    public function outreport($result){
    	ob_start();
    	// Include the main TCPDF library (search for installation path).
    	vendor('Pdf.tcpdf');
    
    	//实例化
    	$pdf = new \TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
    
    	// 设置文档信息 
    	$pdf->SetCreator(PDF_CREATOR);
    	$pdf->SetAuthor('Nicola Asuni');
    	$pdf->SetTitle('TCPDF Example 001');
    	$pdf->SetSubject('TCPDF Tutorial');
    	$pdf->SetKeywords('TCPDF, PDF, example, test, guide');
    
    	// 设置页眉和页脚信息
    	$pdf->SetHeaderData('', '', '电脑人机工程评估报告', '', array(0,64,255), array(0,64,128));
    	$pdf->setFooterData(array(0,64,0), array(0,64,128));
    
    	// 设置页眉和页脚字体 
    	$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
    	$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
    
    	// 设置默认等宽字体 
    	$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
    
    	// 设置间距 
    	$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
    	$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
    	$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
    
    	// 设置分页 
    	$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
    
    	// set image scale factor
    	$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
    
    	// set some language-dependent strings (optional)
    	if (@file_exists(dirname(__FILE__).'/lang/eng.php')) {
    		require_once(dirname(__FILE__).'/lang/eng.php');
    		$pdf->setLanguageArray($l);
    	}
    
    	// ---------------------------------------------------------
    
    	// set default font subsetting mode
    	$pdf->setFontSubsetting(true);
    
    	//设置字体 
    	$pdf->SetFont('dejavusans', '', 14, '', true);
    	$pdf->SetFont('stsongstdlight', '', 10);
    
    	// Add a page
    	// This method has several options, check the source code documentation for more information.
    	$pdf->AddPage();
    
    	// set text shadow effect
    	$pdf->setTextShadow(array('enabled'=>true, 'depth_w'=>0.2, 'depth_h'=>0.2, 'color'=>array(196,196,196), 'opacity'=>1, 'blend_mode'=>'Normal'));
    
    	// 内容
    	$html =$result['report'];
    
    	// Print text using writeHTMLCell()
    	$pdf->writeHTMLCell(0, 0, '', '', $html, 0, 1, 0, true, '', true);
    
    	// ---------------------------------------------------------
    
    	// Close and output PDF document
    	// This method has several options, check the source code documentation for more information.
    	$dtime = date('Y-m-d');
    	$pdf->Output($dtime.'.pdf', 'I');
    
    	//============================================================+
    	// END OF FILE
    	//============================================================+
    		}
    }
    

    感谢粘贴,现在出现乱码了,调试了也没用

  • 提出了问题
    如何生成pdf,老是报错
见习主管 等级规则
410/500
资料完整度
10/100
用户活跃度
0/100

Ta的关注

1

Ta的粉丝

2

Ta的访客

8