public static function getButtons($order, $settings) { /** * Setting */ self::$settings = $settings; $sumReturn = 0; $status = Dictionary::statusRussian($order->status); switch ($order->status) { case Order::C_ORDER_STATUS_NEW: $activity = self::buttons('showStatus', $order->id) . self::buttons('createBill', $order->id); break; case Order::C_ORDER_STATUS_PAYABLE: $activity = self::buttons('showStatus', $order->id) . self::buttons('payBill', $order->id) . self::buttons('cancelBill', $order->id); break; case Order::C_ORDER_STATUS_CANCELED: $activity = self::buttons('showStatus', $order->id); break; case Order::C_ORDER_STATUS_EXPIRED: $activity = self::buttons('showStatus', $order->id); break; case Order::C_ORDER_STATUS_PAID: $activity = self::buttons('showStatus', $order->id) . self::buttons('payReturn', $order->id); break; case Order::C_ORDER_STATUS_RETURNING: $activity = self::buttons('showStatus', $order->id) . self::buttons('statusReturn', $order->id); $statusReturn = $order->PayReturn->find($order->idLastReturn)->status; //Вычисляем сумму возврата $returnsBefore = $order->PayReturn; foreach ($returnsBefore as $one) { $sumReturn += $one->sum; } if ($sumReturn < $order->sum && $statusReturn == Order::C_RETURN_STATUS_RETURNED) { $activity .= self::buttons('payReturn', $order->id); } $sumReturn = number_format($sumReturn, 2, '.', ' '); $status .= ' / ' . Dictionary::statusRussian($statusReturn); break; default: $status = 'Ошибка'; $activity = 'Ошибка статуса'; } return array('status' => $status, 'activity' => $activity, 'sumReturn' => $sumReturn); }
/** * Проверка статуса возврат оплаты * * @param Order $order * * @return array */ public function statusReturn($order) { $payReturn = PayReturn::find($order->idLastReturn); if (!$payReturn) { return $this->resultMessage('Нет такого возврата'); } $gate = new Gateway($this->makeCurl()); $isSuccess = $gate->doRequestReturnStatus($payReturn->order_id, $payReturn->id); if (!$isSuccess) { return $this->resultMessage($gate->getError()); } $newReturnStatus = $payReturn->changeStatus($gate->getValuePayReturnStatus()); $message = 'Текущий статус возврата - ' . Dictionary::statusRussian($newReturnStatus); return $this->resultMessage($message, 'Сообщение'); }