| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- <?php
- namespace common\logic\notify;
- use backend\modules\mall\services\TemplateService;
- use common\models\diy\DiyTemplateOrder;
- use Exception;
- use Yii;
- /**
- * 自定义模板订单支付回调
- * @package common\logic\notify
- */
- class DiyTemplatePayNotify
- {
- /**
- * @param array $order_info
- * @return boolean
- */
- public function notify($order_info)
- {
- try {
- /**
- * @var DiyTemplateOrder|null
- */
- $order = DiyTemplateOrder::getOrderByOrderNo($order_info['order_no']);
- if (empty($order)) {
- throw new Exception('订单不存在');
- }
- // 订单支付
- $order->paid($order_info['pay_type']);
- // 续费模板
- $service = new TemplateService(['mall_id' => $order->mall_id]);
- $service->renewTemplate($order->template_id, $order->duration);
- return true;
- } catch (Exception $e) {
- Yii::error('模板订单支付回调失败错误: ' . json_encode([
- 'line' => $e->getLine(),
- 'msg' => $e->getMessage(),
- ]));
- Yii::error('模板订单支付回调失败参数: ' . json_encode($order_info));
- return false;
- }
- }
- }
|