where([ 'user_id' => \Yii::$app->user->identity->getId(), 'id' => $order_id ])->one(); if(!$productOrder || $productOrder->cancel_status || $productOrder->is_pay != 1 || $productOrder->refund_status!=1){ throw new Exception('订单不存在'); } $productOrderRefund = ProductOrderRefund::find()->where([ 'user_id' => \Yii::$app->user->identity->getId(), 'order_id' => $order_id, 'is_refund' => 0, //未退款 'status' => 0 //申请退款中 ])->one(); if(!$productOrderRefund){ throw new Exception('订单不存在'); } $t = \Yii::$app->db->beginTransaction(); try { if($productOrder->is_send ==1){ $productOrder->status = ProductOrderEnum::ACCEPTED; } else { $productOrder->status = ProductOrderEnum::WAIT_SEND; } $productOrder->refund_status = 0; $productOrder->refund_time = 0; $productOrder->saveOrFail(); $productOrderRefund->status = 2; $productOrderRefund->saveOrFail(); $t->commit(); return ['撤销退款申请成功']; } catch (\Exception $exception) { $t->rollBack(); throw $exception; } } }