Dao.php 1.93 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\Delivery;

class YHMOrders_Models_Delivery_Dao extends YHMOrders_Dao
{

    private $_tag = 'orders_delivery_';

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

    /**
     * 查询订单收货地址
     * @param int $order_code
     * @return int
     */
    function getOneByOrderCode($order_code)
    {
        return $this->dao()->tag($this->_tag . $order_code)->key('getOneByOrderCode')->fetchRow(Delivery\Delivery::SELECT_DELIVERY_BY_ORDER_CODE, array('order_code' => $order_code));
    }


    /**
     * 存储订单送货地址
     * @param $orderCode
     * @param $receiverName
     * @param $receiverMobile
     * @param $areaCode
     * @param $address
     * @param $zipCode
     * @return int
     */
    function addDelivery($orderCode, $receiverName, $receiverMobile, $areaCode, $address, $zipCode)
    {
        return $this->dao()->tag($this->_tag . $orderCode)->insert(Delivery\Delivery::INSERT_DELIVERY, array(
            'order_code' => $orderCode,
            'receiver_name' => $receiverName,
            'receiver_mobile' => $receiverMobile,
            'area_code' => $areaCode,
            'address' => $address,
            'zip_code' => $zipCode
        ))->rowCount();
    }
    
    function setDelivery($order_code,$deliver_company_id,$deliver_company_name,$delivery_code){
        $data = array(
                    'order_code' => $order_code,
                    'deliver_company_id'   => $deliver_company_id,
                    'deliver_company_name' => $deliver_company_name,
                    'delivery_code'        => $delivery_code
        );
        return $this->dao()->tag($this->_tag . $order_code)->key('setDelivery')->update(Delivery\Delivery::UPDATE_DELIVERY_BY_ORDER_CODE, $data);
    }

}