/** * 修改订单状态 */ public static function editState($state) { $model = Order::findOne($state['id']); if (!$model) { return false; } $model->setAttributes(['state' => $state['state'], 'edittime' => time()]); return $model->save(); }
public function getOrderProducts($model) { $order = Order::findOne($model->id); $result = '<ul>'; foreach ($order->orderItems as $item) { if ($item->product) { $result .= '<li><a href="/' . $item->product->slug_ru . '">' . $item->title . '. ' . $item->price . ' ' . $item->product->currency . ' (' . $item->quantity . ' шт.)' . '</a></li>'; } else { $result = '<li>Товар был удален.</li>'; } } $result .= '</ul>'; return $result; }
public function updateOrderStatus($id, $orderStatus) { $model = Order::findOne($id); if (!$model) { return false; } //订单状态: 0-待付款 1-待发货 2-已发货 3-待评论 4-交易成功 5-已关闭 switch ($orderStatus) { case 0: //待付款 $model->orderStatus = 0; $model->onSaleTime = date('Y-m-d H:i:s', time()); break; case 1: //已经付款 等待发货 $model->orderStatus = 1; $model->orderPayTime = date('Y-m-d H:i:s', time()); break; case 2: //系统已经发货,等待快递反馈运单信息 $model->orderStatus = 2; break; case 3: //已经收货 等待评论 $model->orderStatus = 3; $model->isConfirm = 1; $model->confirmTime = date('Y-m-d H:i:s', time()); break; case 4: //已经评论,交易完成 $model->orderStatus = 4; break; case 5: //交易关闭(取消、订单等待支付时间过期等) $model->orderStatus = 5; break; } if ($model->save()) { return true; } return false; }
public function actionDeliverorder() { $user = new AdminUser(); if (!$user->checkUserIsLogin()) { $this->redirect(Variable::$home_url); return; } $req = Yii::$app->request; //创建一个请求对象 $form = new OrderDeliverForm(); $form->setScenario('update'); $id = trim($req->get('id')); if (!is_numeric($id) || $id == 0) { $this->redirect(Variable::$orderManger_url); return; } $orderModel = Order::findOne($id); $orderExpressInfoModel = (new OrderExpressInfo())->findOne(['orderId' => $id]); $userAddressModel = (new UserAddress())->findOne(['id' => $orderModel->addressId]); $orderStyleModel = (new Express())->find()->all(); //修改 if ($form->load($req->post()) && $form->validate()) { $isSuccess = (new OrderExpressInfo())->deliver($id, $form->expressNo, $form->expressStyle, $form->expressChart); if ($isSuccess) { $form->addError('', '订单发货成功'); } else { $form->addError('', '订单发货失败'); } } $form->orderNo = $orderModel->orderNo; $form->orderMoney = $orderModel->orderMoney; $form->orderStatus = $orderModel->orderStatus; $form->orderPayMethod = $orderModel->orderPayMethod; $form->orderStatus = $orderModel->orderStatus; if ($orderExpressInfoModel) { $form->expressNo = $orderExpressInfoModel->expressNo; $form->expressStyle = $orderExpressInfoModel->expressStyle; } return $this->render(Variable::$deliverOrder_view, ['model' => $form, 'orderModel' => $orderModel, 'orderExpressInfoModel' => $orderExpressInfoModel, 'orderStyleModel' => $orderStyleModel, 'userAddressModel' => $userAddressModel]); }
/** * Finds the Order model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param string $id * @return Order the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Order::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
private function _getOrder($orderId) { if ($orderId != null) { $order = Order::findOne($orderId); if ($order != null) { return $order; } else { return null; } } else { return null; } }