<?php
class Order_OrderInterceptController extends Ec_Controller_Action
{
    public function preDispatch()
    {
        $this->tplDirectory = "order/views/default/";
        $this->serviceClass = new Service_Orders();
    }
    /**
     * @todo 截单申请（订单装袋以后的单）
     */
    public function packinterceptAction() {
        if ($this->_request->isPost()) {
            $response = array('state' => 0, 'message' => '');
            $code = trim($this->_request->getParam('code'));
            $reason = trim($this->_request->getParam('reason'));
            if (empty($code)) {
                $response['message'] = '请输入订单号';
                exit(Zend_Json::encode($response));
            }
            if (empty($reason)) {
                $response['message'] = '请填写拦截原因';
                exit(Zend_Json::encode($response));
            }
            $orderRow = Service_Orders::getByField($code, 'order_code');
            if (empty($orderRow)) {
                $response['message'] = '找不到订单，请校对所输入单号是否正确';
                exit(Zend_Json::encode($response));
            }
            $dispatchProcess = new Service_OrderDispatchProcess();
            $result = $dispatchProcess->packOrderStop($code, $reason);
            exit(Zend_Json::encode($result));
        } else {
            echo Ec::renderTpl($this->tplDirectory . "stop_packorder.tpl", 'layout');
        }
    }



}