| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- <?php
- namespace addons\DepositPresale\common\logic\notify;
- use addons\DepositPresale\common\models\DepositPresaleOrder;
- use common\models\order\Order;
- use common\traits\ErrorTrait;
- use Exception;
- /**
- * Class FinalPaymentNotify
- * @Author: hua
- * @DateTime: 2021/10/18 9:39
- * @Copyright: copyright (c) 2021 广东七件事集团
- * @package common\logic\notify
- */
- class FinalPaymentNotify
- {
- use ErrorTrait;
- /**
- * @Description: 支付尾款
- * @Author: code farmer 3
- * @DateTime 2022-04-23 17:26:14
- * @param array $order_info
- * @return void
- */
- public function notify($order_info)
- {
- try {
- $order = DepositPresaleOrder::findOne(['order_no' => $order_info['order_no']]);
- $res = DepositPresaleOrder::payFinalPayment($order, $order_info['pay_type']);
- if($res === false) throw new Exception(DepositPresaleOrder::getStaticError());
- $main_order = Order::findOne(['id' => $order['order_id']]);
- if($main_order && $main_order->created_at != $order->created_at){
- $main_order->created_at = $order->created_at;
- $result = $main_order->save();
- if(!$result){
- throw new Exception($main_order->getError());
- }
- }
- $main_res = Order::pay($main_order, $order_info['pay_type'], $main_order['out_trade_no']);
- if($main_res === false) throw new Exception(Order::getStaticError());
- return true;
- } catch (Exception $e) {
- echo $e->getMessage();
- $this->setStaticError($e->getMessage());
- return false;
- }
- }
- }
|