<?php

// 获取募捐详细信息
require_once ("../user_include.inc");

ErrorLogger::doOutput("Compass...ajax_get_donation_event_list.php....Start.", 0);

//获取参数
$unionId = ParamUtil::getRequestString("unionId");
$eventId = ParamUtil::getRequestNumber("eventId", 0);

//判断用户是否存在
$param = array();
$param['unionid'] = $unionId;
$param['delete_flg'] = false;
$userList = UserMst::getList($param,'id','desc', 0, 1);
if(empty($userList)) {
	$result["message"] = "用户不存在！";
	responseNG($result);
}

//判断募捐活动是否存在
$donationEventDat = DonationsEventDat::getById($eventId);
if(empty($donationEventDat)) {
	$result["message"] = "参数错误！";
	responseNG($result);
}

//查询捐款人员名单
$userDonationList = array();
$param = array();
$param['donation_id'] = $donationEventDat->id;
$param['status'] = "SUCCESS";//只显示支付成功的记录
$param['delete_flg'] = false;
$tmpList = UserDonationDat::getList($param,'id','desc');
if(!empty($tmpList)) {
	foreach($tmpList as $tmp) {
		$userMst = UserMst::getById($tmp->id);
		if(!empty($userMst)) {
			$userDonationList[] = array("name"=>$userMst->name, "money"=>$tmp->money);
		}
	}
}

//组装返回数据
$result["donationEventDat"] = $donationEventDat;
$result["userDonationList"] = $userDonationList;


ErrorLogger::doOutput("Compass...ajax_get_donation_event_list.php....End.", 0);


//返回结果
responseOK($result);

function responseNG($result) {
	$result = array("status"=>"NG", "result"=>$result);
	print json_encode($result);
	exit;
}
function responseOK($result) {
	$result = array("status"=>"OK", "result"=>$result);
	print json_encode($result);
	exit;
}
?>