Example #1
0
function coupon_delete($id)
{
    global $_W;
    $id = intval($id);
    $item = pdo_fetch('SELECT acid,id,card_id FROM ' . tablename('coupon') . ' WHERE uniacid = :aid AND id = :id', array(':aid' => $_W['uniacid'], ':id' => $id));
    if (empty($item)) {
        return error(-1, '卡券不存在或已经删除');
    }
    if (empty($item['card_id'])) {
        pdo_delete('coupon', array('id' => $id, 'uniacid' => $_W['uniacid']));
        return true;
    }
    $coupon = new coupon($item['acid']);
    $return = $coupon->DeleteCard($item['card_id']);
    if (is_error($return)) {
        return $return;
    }
    pdo_delete('coupon', array('id' => $id, 'uniacid' => $_W['uniacid']));
    return true;
}