예제 #1
0
파일: order.php 프로젝트: dlpc/ecshop
/**
 * 退回余额、积分、红包(取消、无效、退货时),把订单使用余额、积分、红包设为0
 * @param   array   $order  订单信息
 */
function return_user_surplus_integral_bonus($order)
{
    /* 处理余额、积分、红包 */
    if ($order['user_id'] > 0 && $order['surplus'] > 0) {
        $surplus = $order['money_paid'] < 0 ? $order['surplus'] + $order['money_paid'] : $order['surplus'];
        log_account_change($order['user_id'], $surplus, 0, 0, 0, sprintf($GLOBALS['_LANG']['return_order_surplus'], $order['order_sn']));
        /*退货增加代理商余额 by hg*/
        if ($order['admin_agency_id']) {
            agency_order_status($order['order_id'], $order['admin_agency_id'], $order['user_id'], $order['goods_amount']);
        }
        $GLOBALS['db']->query("UPDATE " . $GLOBALS['ecs']->table('order_info') . " SET `order_amount` = '0' WHERE `order_id` =" . $order['order_id']);
    }
    if ($order['user_id'] > 0 && $order['integral'] > 0) {
        log_account_change($order['user_id'], 0, 0, 0, $order['integral'], sprintf($GLOBALS['_LANG']['return_order_integral'], $order['order_sn']));
    }
    if ($order['bonus_id'] > 0) {
        unuse_bonus($order['bonus_id']);
    }
    /* 修改订单 */
    $arr = array('bonus_id' => 0, 'bonus' => 0, 'integral' => 0, 'integral_money' => 0, 'surplus' => 0);
    update_order($order['order_id'], $arr);
}
예제 #2
0
/**
 * 订单退款
 * @param   array   $order          订单
 * @param   int     $refund_type    退款方式 1 到帐户余额 2 到退款申请(先到余额,再申请提款) 3 不处理
 * @param   string  $refund_note    退款说明
 * @param   float   $refund_amount  退款金额(如果为0,取订单已付款金额)
 * @return  bool
 */
function order_refund($order, $refund_type, $refund_note, $refund_amount = 0)
{
    if (1 == $refund_type || 2 == $refund_type) {
        if ($order['admin_agency_id']) {
            agency_order_status($order['order_id'], $order['admin_agency_id'], $order['user_id'], $order['goods_amount']);
        }
    }
    /* 检查参数 */
    $user_id = $order['user_id'];
    if ($user_id == 0 && $refund_type == 1) {
        die('anonymous, cannot return to account balance');
    }
    $amount = $refund_amount > 0 ? $refund_amount : $order['money_paid'];
    if ($amount <= 0) {
        return true;
    }
    if (!in_array($refund_type, array(1, 2, 3))) {
        die('invalid params');
    }
    /* 备注信息 */
    if ($refund_note) {
        $change_desc = $refund_note;
    } else {
        include_once ROOT_PATH . 'languages/' . $GLOBALS['_CFG']['lang'] . '/admin/order.php';
        $change_desc = sprintf($GLOBALS['_LANG']['order_refund'], $order['order_sn']);
    }
    /* 处理退款 */
    if (1 == $refund_type) {
        log_account_change($user_id, $amount, 0, 0, 0, $change_desc);
        return true;
    } elseif (2 == $refund_type) {
        /* 如果非匿名,退回余额 */
        if ($user_id > 0) {
            log_account_change($user_id, $amount, 0, 0, 0, $change_desc);
        }
        /* user_account 表增加提款申请记录 */
        $account = array('user_id' => $user_id, 'amount' => -1 * $amount, 'add_time' => gmtime(), 'user_note' => $refund_note, 'process_type' => SURPLUS_RETURN, 'admin_user' => $_SESSION['admin_name'], 'admin_note' => sprintf($GLOBALS['_LANG']['order_refund'], $order['order_sn']), 'is_paid' => 0, 'admin_agency_id' => $order['admin_agency_id']);
        $GLOBALS['db']->autoExecute($GLOBALS['ecs']->table('user_account'), $account, 'INSERT');
        return true;
    } else {
        return true;
    }
}