<?php
class CaiwuAction extends AdmAction{
	// 网站首页
	public function index(){
		// 导入分页
		import("@.iGuoji.Page");
		// 订单总数
		$Data = M("Dd");
		$ddSum = $Data->where("dd_step = 2")->count("dd_id");
		// 分页对象
		$page = new Page($ddSum,20);
		// 查询订单
		$Data = M("Dd");
		$ddList = $Data->field("dd_id,yx_name,qf_id,qf_name,zh_name,dd_money,dd_date")
			->join("yeyou_yx ON yx_id = dd_yx")->join("yeyou_qf ON qf_id = dd_qf")
			->join("yeyou_zh ON zh_id = dd_zh")->where("dd_step = 2")
			->limit($page->firstRow.','.$page->listRows)
			->order("dd_date DESC")->select();
		$this->assign("ddList",$ddList);
		// 查询订单，单个
		$dd = INT("dd");
		if($dd){
			$Data = M("Dd");
			$ddObj = $Data->field("dd_id,yx_name,qf_id,qf_name,zh_name,dd_money,dd_step,dd_fs,dd_date")
				->join("yeyou_yx ON yx_id = dd_yx")->join("yeyou_qf ON qf_id = dd_qf")
				->join("yeyou_zh ON zh_id = dd_zh")->where("dd_id = $dd")
				->find();
			if(!$ddObj){
				$this->error("订单不存在!","/Adm/Caiwu/index.html");
				exit;
			}
			$this->assign("ddObj",$ddObj);
		}
		// 显示页面
		$this->assign("code",$page->show());
		$this->display();
	}
}
?>