<?php
/**
* 积分兑换后台处理操作
* @author moufer<moufer@163.com>
* @copyright www.modoer.com
* @version $Id exchnage.inc.php 1 2008-2-23 20:57 $
*/
(!defined('IN_ADMIN') || !defined('IN_MUDDER')) && exit('Access Denied');

if(!check_submit('dosubmit')) {

    $arr_status = array('1' => '申请中', '2'=>'处理中', '3' => '已发货', '4' => '已退款');

    $current_gift = $db->get_one("SELECT a.*,b.username FROM {$dbpre}exchange a LEFT JOIN {$dbpre}members b ON(a.uid=b.uid) WHERE exchangeid='$exchangeid'");
    !$current_gift && cpmsg("兑换信息不存在。");
    $current_gift['totalprice'] = $current_gift['price'] * $current_gift['number'];
    $giftid = $current_gift['giftid'];
    $storage_gift = $db->get_one("SELECT * FROM {$dbpre}gifts WHERE giftid='$giftid'");

    include cptpl('disposal', MOD_ROOT.'./admin/templates/');

} else {

    $exchangeinfo = $db->get_one("SELECT * FROM {$dbpre}exchange WHERE exchangeid='$exchangeid'");
    !$exchangeinfo && cpmsg('兑换信息不存在。','admincp.php?action='.$action.'&file=list');
    $disposal_status = intval($disposal_status);
    ($disposal_status < 1 || $disposal_status > 4) && cpmsg('未选择兑换操作处理，请返回选择。');
    $status_extra = html_special_chars_ex($status_extra);
    if($disposal_status == 4) {
        $total_price = $exchangeinfo['price'] * $exchangeinfo['number'];
        $db->update("UPDATE {$dbpre}members SET coin=coin+'$total_price' WHERE uid='{$exchangeinfo['uid']}'");
    }
    $db->update("UPDATE {$dbpre}exchange SET status='$disposal_status',status_extra='$status_extra',checker='{$admin->adminname}' WHERE exchangeid='$exchangeid'");
    cpmsg('兑换信息处理完毕。','admincp.php?action='.$action.'&file=list');

}

?>
