Exemplo n.º 1
0
<?php

require_once dirname(dirname(__FILE__)) . '/app.php';
need_manager();
$action = strval($_GET['action']);
$id = abs(intval($_GET['id']));
if ('orderrefund' == $action) {
    need_auth('admin');
    $order = Table::Fetch('order', $id);
    $rid = strtolower(strval($_GET['rid']));
    if ($rid == 'credit') {
        ZFlow::CreateFromRefund($order);
    } else {
        Table::UpdateCache('order', $id, array('service' => 'cash', 'state' => 'unpay'));
    }
    /* team -- */
    $team = Table::Fetch('team', $order['team_id']);
    team_state($team);
    if ($team['state'] != 'failure') {
        $minus = $team['conduser'] == 'Y' ? 1 : $order['quantity'];
        Table::UpdateCache('team', $team['id'], array('now_number' => array("now_number - {$minus}")));
    }
    /* card refund */
    if ($order['card_id']) {
        Table::UpdateCache('card', $order['card_id'], array('consume' => 'N', 'team_id' => 0, 'order_id' => 0));
    }
    /* coupons */
    if (in_array($team['delivery'], array('coupon', 'pickup'))) {
        $coupons = Table::Fetch('coupon', array($order['id']), 'order_id');
        foreach ($coupons as $one) {
            Table::Delete('coupon', $one['id']);
Exemplo n.º 2
0
     $team['state'] = team_state($team);
     if ($team['state'] != 'none' || $team['now_number'] > 0) {
         json('This deal is over or has buyers, can not delete it', 'alert');
     }
     Table::Delete('team', $id);
     Table::Delete('order', $id, 'team_id');
     Table::Delete('deals_charity', $id, 'deal_id');
     Session::Set('notice', "Deal {$id} is deleted successfully!");
     json(null, 'refresh');
 } else {
     if ('teamrefund' == $action) {
         $team = Table::Fetch('team', $id);
         $c = array('team_id' => $id, 'state' => 'pay');
         $os = DB::LimitQuery('order', array('condition' => $c));
         foreach ($os as $o) {
             ZFlow::CreateFromRefund($o);
         }
         Table::UpdateCache('team', $id, array('state' => 'refund'));
         Session::Set('notice', "Deal's serial number: {$id} refund successfully");
         json(null, 'refresh');
     } else {
         if ('userview' == $action) {
             $user = Table::Fetch('user', $id);
             $html = render('ajax_dialog_user');
             json($html, 'dialog');
         } else {
             if ('usermoney' == $action) {
                 $user = Table::Fetch('user', $id);
                 $money = abs(intval($_GET['money']));
                 if (!$money) {
                     json('Topup value should be positive.', 'alert');