Dao.php 2.98 KB
<?php

/**
 * Created by JetBrains PhpStorm.
 * User: elkan
 * Date: 14-8-20
 * Time: 下午6:04
 * To change this template use File | Settings | File Templates.
 */
use YHMOrders\SqlMap\Status;

class YHMOrders_Models_Status_Dao extends YHMOrders_Dao {

    private $_tag = 'orders_status_';

    public function __construct() {
        $this->router = 'status.yhm_orders';
    }

    /**
     * 
     * @param int $store_id
     */
    function getByOrderCode($order_code) {
        return $this->dao()->tag($this->_tag . $order_code)->key('getByOrderCode')->fetchAll(Status\Status::SELECT_ORDER_STATUS_HISTORY_BY_ORDER_CODE, array(
                    'order_code' => $order_code));
    }

    /**
     * 查看是否已有相同的状态
     * @param type $order_code
     * @param type $status
     */
    function getRepeatStatusByOrderCode($order_code, $status) {
        return $this->dao()->tag($this->_tag . $order_code)->key('getRepeatStatusByOrderCode_' . $status)->fetchRow(Status\Status::SELECT_ORDER_STATUS_BY_ORDER_CODE, array(
                    'order_code' => $order_code, 'status' => $status));
    }

    /**
     * 添加订单状态
     * @param integer $order_code
     * @param integer $order_status
     * @param integer $trigger_user
     */
    public function setOrderstatus($order_code, $order_status, $trigger_user) {
        $params = array(
            'order_code' => $order_code,
            'order_status' => $order_status,
            'trigger_user' => $trigger_user
        );
        return $this->dao()->tag($this->_tag . $order_code)->insert(Status\Status::SET_STATUS, $params)->lastInsertId();
    }
    /**
     * 查询订单状态
     * @param type $order_code
     * 
     */
    function getOrderStatus($order_code) {
        return $this->dao()->tag($this->_tag . $order_code)->key('getOrderStatusByList')->fetchAll(Status\Status::SELECT_ORDER_STATUS_BY_LIST, array(
                    'order_code' => $order_code));
    }
     /**
     * 获取某阶段内订单状态列表
     * @param type $time
     * 
     */
    function getOrderStatusByTime($time,$order_status,$type) { 
        if ($type==1)
        {
            echo  $this->dao()->getSql(Status\Status::SELECT_ORDER_STATUS_BY_TIME_LIST, array(
             'order_status' => $order_status,
              'time' => $time
            ));  
        
        return $this->dao()->fetchAll(Status\Status::SELECT_ORDER_STATUS_BY_TIME_LIST, array(
             'order_status' => $order_status,
              'time' => $time
            ));
        }
       else {
       //    $sql="SELECT_ORDER_STATUS_BY_EQTIME_LIST";
                    echo  $this->dao()->getSql(Status\Status::SELECT_ORDER_STATUS_BY_EQTIME_LIST, array(
             'order_status' => $order_status,
              'time' => $time
            ));  
        
        return $this->dao()->fetchAll(Status\Status::SELECT_ORDER_STATUS_BY_EQTIME_LIST, array(
             'order_status' => $order_status,
              'time' => $time
            ));
       }
       
    }
}