Dao.php 2.49 KB
<?php

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

class YHMSupport_Models_AdminActivity_Dao extends YHMSupport_Dao {

    private $_tag = 'support_activity';

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

    /**
     * 活动列表
     * @return type
     */
    function getActivityListPage($offset, $num) {
        return $this->dao()->cache(false)->fetchAll(Activity\Activity::SELECT_ACTIVITY_LIST, array('offset' => $offset, 'num' => $num));
    }

    function add($pid, $activity_name, $start_time, $end_time, $activity_banner, $activity_describe) {
        $data = array(
            'create_pid' => $pid,
            'activity_name' => $activity_name,
            'start_time' => $start_time,
            'end_time' => $end_time,
            'activity_banner' => $activity_banner,
            'activity_describe' => $activity_describe
        );
        return $this->dao()->cache(false)->insert(Activity\Activity::INSERT_INTO_ACTIVITY, $data)->lastInsertId();
    }

    function getActivityGoods($activity_id, $product_skc) {
        return $this->dao()->cache(false)->fetchRow(Activity\Activity::SELECT_ACTIVITY_GOODS, array('activity_id' => $activity_id, 'product_skc' => $product_skc));
    }

    /**
     * 添加单品
     * @param type $activity_id
     * @param type $product_skc
     * @return type
     */
    function addGoods($activity_id, $product_skc) {

        return $this->dao()->cache(false)->insert(Activity\Activity::INSERT_INTO_ACTIVITY_GOODS, array('activity_id' => $activity_id, 'product_skc' => $product_skc))->lastInsertId();
    }

    function set($activity_id, $pid, $activity_name, $start_time, $end_time, $activity_banner, $activity_describe, $status) {
        $data = array(
            'id' => $activity_id,
            'create_pid' => $pid,
            'activity_name' => $activity_name,
            'start_time' => $start_time,
            'end_time' => $end_time,
            'activity_banner' => $activity_banner,
            'activity_describe' => $activity_describe,
            'status' => $status
        );
        return $this->dao()->update(Activity\Activity::UPDATE_ACTIVITY_BY_ID, $data);
    }

    function getActivityGoodsList($activity_id) {
        return $this->dao()->cache(false)->fetchAll(Activity\Activity::SELECT_ACTIVITY_GOODS_LIST, array('activity_id' => $activity_id));
    }

}