/** * postShipping */ public function postShipping() { $data = Input::all(); //$data['paydate'] = strtotime($data['paydate']); //插入payments $shipping = OrderShipping::create($data); $shippings = OrderShipping::where('order_id', Input::get('order_id'))->get(); return View::make('admin.orders.shipping')->with('shippings', $shippings); }
/** * 订单发货【普通的订单发货】 */ public function actionSendOrder() { if (empty($_POST)) { $oInfo = Order::model()->findByPk($_REQUEST['id']); $shippingList = Shipping::model()->getShippingList(); $viewData = array(); $viewData['oInfo'] = $oInfo; $viewData['shippingList'] = $shippingList; $this->render('sendOrder', $viewData); exit; } $res = array('statusCode' => 200, 'message' => '发货成功!'); try { $oInfo = Order::model()->findByPk($_REQUEST['id']); if (empty($oInfo)) { throw new exception('订单不存在!'); } elseif (!in_array($oInfo['order_status'], array(1, 2, 4))) { throw new exception('订单状态错误!'); } //保存发货信息到订单中 $oInfo->shipping_id = intval($_REQUEST['shipping_id']); $oInfo->shipping_sn = intval($_REQUEST['shipping_sn']); $oInfo->shipping_time = time(); $oInfo->order_status = 5; //已发货 $oInfo->shipping_status = 1; //已发货 $flag = $oInfo->save(); if (empty($flag)) { throw new exception('保存运单信息到订单错误!', 500); } //保存订单的发货信息 $m = new OrderShipping(); $m->order_id = $_REQUEST['order_id']; $m->shipping_id = $_REQUEST['shipping_id']; $m->shipping_sn = $_REQUEST['shipping_sn']; $m->shipping_fee = $_REQUEST['shipping_fee']; $m->weight = $_REQUEST['weight']; $m->remark = $_REQUEST['remark']; $m->add_time = time(); $flag = $m->save(); if (empty($flag)) { throw new exception('保存运单信息错误!', 500); } $logData = array(); $logData['order_id'] = $oInfo->id; $logData['type'] = 'AdminSend'; $logData['msg'] = $_REQUEST['remark']; OrderLog::model()->addOrderLog($logData); } catch (exception $e) { $res['statusCode'] = 300; $res['message'] = '发货失败!【' . $e->getMessage() . '】'; } $res['navTabId'] = 'orderList'; $res['callbackType'] = 'closeCurrent'; $res['forwardUrl'] = '/manage/order/index'; $this->ajaxDwzReturn($res); }